historicalPerformance.vue 19.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
<!-- 员工历史业绩 -->
<template>
  <div class="historicalPerformance">
    <div class="content">
      <div class="header">
        <div class="name">{{ performanceData.staffName }}</div>
        <div><span>|</span>{{ performanceData.staffPhone }}<span>|</span>{{ performanceData.hireType == 1 ? '校招管培生' : performanceData.hireType == 2 ? '社会招聘' : '-' }}</div>
      </div>
      <div class="content-warp">
        <el-table :data="performanceTableData" border>
          <el-table-column label="序号" type="index" :index="(index) => index + 1" width="60" align="center"></el-table-column>
          <el-table-column label="月份" prop="" align="center">           
            <template slot-scope="scope">
              <span>{{ scope.row.monthStr }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center">
            <template slot="header">
              <span>基本工资</span>
            </template>
            <template slot-scope="scope">
              <span>{{ !isEmpty(scope.row.actualBasicSalary) ? `¥${scope.row.actualBasicSalary}` : '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center">
            <template slot="header">
              <span>保底工资</span>
            </template>
            <template slot-scope="scope">
              <span>{{ !isEmpty(scope.row.minimumSalary) ? `¥${scope.row.minimumSalary}` : '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center">
            <template slot="header">
              <span>作为导师收入</span>
            </template>
            <template slot-scope="scope">
              <span>{{ !isEmpty(scope.row.mentorCommission) ? `¥${scope.row.mentorCommission}` : '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center">
            <template slot="header">
              <span>门店提成</span>
            </template>
            <template slot-scope="scope">
              <span>{{ !isEmpty(scope.row.merchantCommission) ? `¥${scope.row.merchantCommission}` : '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center">
            <template slot="header">
              <span>平板扣款</span>
            </template>
            <template slot-scope="scope">
              <span>{{ !isEmpty(scope.row.padDeductMoney) ? `- ¥${Math.abs(scope.row.padDeductMoney)}` : '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center">
            <template slot="header">
              <span>日报扣款</span>
            </template>
            <template slot-scope="scope">
              <span>{{ !isEmpty(scope.row.dailyDeductMoney) ? `- ¥${Math.abs(scope.row.dailyDeductMoney)}` : '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center">
            <template slot="header">
              <span>退单冲减</span>
            </template>
            <template slot-scope="scope">
              <span>{{ !isEmpty(scope.row.refundOffset) ? `- ¥${Math.abs(scope.row.refundOffset)}` : '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center">
            <template slot="header">
              <span>正负冲减</span>
            </template>
            <template slot-scope="scope">
              <span>{{ !isEmpty(scope.row.otherDeduction) ? `¥${scope.row.otherDeduction}` : '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" label="递延金扣款">
            <template slot-scope="scope">
              <span>{{ scope.row.deferExpenses ? `- ¥${Math.abs(scope.row.deferExpenses)}` : '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" label="递延金纳入">
            <template slot-scope="scope">
              <span v-if="isEmpty(scope.row.deferIncome)">-</span>
              <el-tooltip class="item" effect="dark" v-else placement="top">
                <template slot="content">
                  <p>{{ getMonthSixMonthsBack(scope.row) }}月递延金</p>
                </template>
                <span>{{ `¥${scope.row.deferIncome}` }}</span>
              </el-tooltip>
            </template>
          </el-table-column>
          <el-table-column align="center">
            <template slot="header">
              <span>合计应发工资</span>
            </template>
            <template slot-scope="scope">
              <span v-if="scope.row.correct">
                <span>{{ `¥${scope.row.correctSalary}` }}</span>
                <span class="change-flag">改</span>
              </span>
              <span v-else>
                <span>{{ scope.row.correctSalary ? `¥${scope.row.correctSalary}` : '-' }}</span>
                <span class="empty-flag"></span>
              </span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" fixed="right">
            <template slot-scope="scope">
              <span style="margin-right: 10px;">
                <auth-button :data="scope.row"
                          :show-btn-ids="['9120509']" v-if="showBtn(scope.row)" />
              </span>
              <auth-button :data="scope.row" :show-btn-ids="['9120510']"></auth-button>
            </template>
          </el-table-column>
          <template slot="empty">
            <div v-if="whiteFlag">暂无数据</div>
            <div v-else style="color: #F47F13;">内容白名单可见</div>
          </template>
        </el-table>
        <div class="total-amount">总计实发工资:
          <span v-if="whiteFlag" class="amount">{{ totalActualSalary }}元</span>
          <span v-else style="color: #F47F13;">内容白名单可见</span>
        </div>
      </div>
    </div>
    <div class="content">
      <div class="header">
        <div class="name">历史订单</div>
      </div>
      <div class="content-warp">
        <d2-table-header :left-span="0">
          <div class="scene-type">
            <el-radio-group v-model="activeName" @change="handleSceneChange">
              <el-radio-button size="small" label="1">轻改</el-radio-button>
              <el-radio-button size="small" label="0">会员权益/升级</el-radio-button>
            </el-radio-group>
          </div>
          <div>
            <label>订单月份:</label>
            <el-date-picker
              size="small"
              v-model="monthRange"
              type="monthrange"
              range-separator="至"
              start-placeholder="开始月份"
              end-placeholder="结束月份"
              popper-class="statement-of-history-performance-month-picker"
              style="margin-right: 8px;width: 284px"
              @change="handleMonthRangeBlur"
              :picker-options="rangePickerOptions">
            </el-date-picker>
          </div>
        </d2-table-header>
        <el-table :data="orderTableData" border>
          <el-table-column label="日期" prop="" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.dataDate }}</span>
            </template>
          </el-table-column>
          <el-table-column label="开单门店" prop="" align="center">
            <template slot-scope="scope">
              <span>{{ `${scope.row.merchantName}${scope.row.merchantId}` || '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center">
            <template slot="header">
              <span>订单数</span>
              <el-tooltip class="item" effect="dark" placement="top">
                <template slot="content">
                  <p>该员工按日在当前门店当天所累计的总实际订单数,员工输入当天交车数才显示数据</p>
                </template>
                <i class="el-icon-question"></i>
              </el-tooltip>
            </template>
            <template slot-scope="scope">
              <span>{{ !isEmpty(scope.row.orderCount) ? scope.row.orderCount : '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center">
            <template slot="header">
              <span>交车数</span>
              <el-tooltip class="item" effect="dark" placement="top">
                <template slot="content">
                  <p>该员工按日在当前门店录入的新车交付数总数</p>
                </template>
                <i class="el-icon-question"></i>
              </el-tooltip>
            </template>
            <template slot-scope="scope">
              <span>{{ !isEmpty(scope.row.deliveryCount) ? scope.row.deliveryCount : '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center">
            <template slot="header">
              <span>渗透率</span>
              <el-tooltip class="item" effect="dark" placement="top">
                <template slot="content">
                  <p>该员工订单数/交车数的比值取整数</p>
                </template>
                <i class="el-icon-question"></i>
              </el-tooltip>
            </template>
            <template slot-scope="scope">
              <span>{{ !isEmpty(scope.row.deliveryCount) ? scope.row.deliveryCount == 0 ? '0%' : `${Math.round(scope.row.orderCount/scope.row.deliveryCount)*100}%`  : '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center">
            <template slot="header">
              <span>当天产值</span>
              <el-tooltip class="item" effect="dark" placement="top">
                <template slot="content">
                  <p>当天订单数的产值累计</p>
                </template>
                <i class="el-icon-question"></i>
              </el-tooltip>
            </template>
            <template slot-scope="scope">
              <span>{{ !isEmpty(scope.row.totalPrice) ? `¥${scope.row.totalPrice}` : '-' }}</span>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="page.currentPage"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="page.pageSize"
          :total="total"
          layout="sizes,total,->,prev,pager,next,jumper"
        />
      </div>
    </div>
    <!-- 修订合计应发工资 -->
    <revised-salary-dialog :revised-salary-visible="revisedSalaryVisible" v-if="revisedSalaryVisible" :revised-salary-row="revisedSalaryRow" @dialogClose="handleSalaryCloseDialog"></revised-salary-dialog>
    <!-- 工资明细 -->
    <salary-details-dialog :salary-details-visible="salaryDetailsVisible" v-if="salaryDetailsVisible" @dialogClose="handleSalaryDetailsColseDialog" :detail-row="detailRow"></salary-details-dialog>
  </div>
</template>
<script>
import { staffLevelList, staffSceneLabelList } from '@/common/constants.js'
import { mapActions, mapState } from "vuex"
import revisedSalaryDialog from './revisedSalaryDialog.vue'
import salaryDetailsDialog from './salaryDetailsDialog.vue'
import { rangePickerOptions } from '@/common/format'
import { Util, deepClone } from "@/common/util"
import { getStaffHistoryOrderListApi, getStaffHistoryApi, getCommissionLogicApi, getStaffSalaryStatisticsApi, getStoreLastDetailApi, staffWhiteListFlagApi } from '@/api/resident'
import { filterStr, isEmpty } from '../util'
import BigNumber from 'bignumber.js'
export default {
  name: 'HistoricalPerformance',
  components: {
    revisedSalaryDialog,
    salaryDetailsDialog
  },
  props: {
    queryData: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      isEmpty,
      rangePickerOptions: rangePickerOptions,
      performanceData: {},
      performanceTableData: [],
      orderTableData: [],
      monthRange: [],
      revisedSalaryVisible: false,
      salaryDetailsVisible: false,
      totalActualSalary: '',
      staffSceneLabelList: deepClone(staffSceneLabelList),
      revisedSalaryRow: {},
      total: 0,
      page: {
        pageSize: 10,
        currentPage: 1
      },
      activeName: '1', // 默认选中轻改
      configDetailInfo: {},
      whiteFlag: false
    }
  },
  computed: {
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList
    })
  },
  mounted() {
    this.performanceData = {
      ...this.performanceData,
      ...this.queryData
    }
  },
  methods: {
    ...mapActions({
      get: "d2admin/base/get",
      close: "d2admin/page/close"
    }),
    getMonthSixMonthsBack(rowData) {
      const currentDate = new Date()
      const month = rowData?.salaryMonth.split('-')[1]
      const specifiedDate = new Date(currentDate.getFullYear(), month - 1) // 创建指定月份的日期对象
      specifiedDate.setMonth(specifiedDate.getMonth() - 6) // 向前推 6 个月
      return (specifiedDate.getMonth() + 1)
    },
    resetData() {
      // if (this.performanceData.hireType == 1) {
        // this.getCommissionLogic()
      // }
      this.getPerformanceStatic()
      this.getOrderData()
      this.getStaffWhite()
    },
    // 仅展示不包含当月的前三个月内
    showBtn(row) {
      const currentDate = new Date()
      const currentYear = currentDate.getFullYear()
      const currentMonth = currentDate.getMonth() + 1
      const [year, month] = row.salaryMonth?.split('-').map(Number)
      const inputMonth = (year * 12) + month // 将年转换为月份并加上当前月份
      const currentTotalMonths = (currentYear * 12) + currentMonth // 当前时间的总月份数
      return (currentTotalMonths - inputMonth) <= 3
    },
    // 获取是否有查看工资的权限
    getStaffWhite() {
      staffWhiteListFlagApi({}).then(res => {
        this.whiteFlag = res
        this.getPerformanceData()
      })
    },
    getPerformanceStatic() {
      getStaffSalaryStatisticsApi({staffPhone: this.queryData?.staffPhone}).then(res => {
        this.totalActualSalary = res.totalActualSalary || 0
      })
    },
    // 工资明细
    handleSalaryDetail(row) {
      this.detailRow = {
        ...row,
        hireType: this.queryData?.hireType
      }
      this.handleSalaryDetailsColseDialog()
    },
    handleSalaryDetailsColseDialog() {
      this.salaryDetailsVisible = !this.salaryDetailsVisible
    },
    getParams() {
      const startDate = deepClone(this.monthRange?.[0]) || ''
      const endDate = deepClone(this.monthRange?.[1]) || ''
      endDate && endDate.setMonth(endDate.getMonth() + 1)
      let params = {
        startDate: startDate ? Util.dateFormate(startDate, 'YYYY-MM-DD HH:mm:ss') : '',
        endDate: endDate ? Util.dateFormate(endDate?.setDate(0), 'YYYY-MM-DD') + ' 23:59:59' : '',
        sceneType: this.activeName,
        staffPhone: this.queryData?.staffPhone
      }
      return params
    },

    // 获取业绩数据
    getPerformanceData() {
      getStaffHistoryApi({ staffPhone: this.queryData?.staffPhone, pageSize: 12, currentPage: 1 }).then(res => {
        const chineseNums = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
        res?.list?.forEach(row => {
          const month = row?.salaryMonth?.split('-')?.[1] - 1
          const basicSalary = new BigNumber(row?.actualBasicSalary || 0)
          const commissionPrice = new BigNumber(row?.commissionPrice || 0)
          const minimumSalary = new BigNumber(row?.minimumSalary || 0)
          row.monthStr = chineseNums[month]
          row.staffSceneLabelStr = filterStr(row.staffSceneLabel, this.staffSceneLabelList)
          row.jobTypeStr = filterStr(row.jobTypes, staffLevelList, this.performanceData?.hireType)
          row.personalSalary = basicSalary.plus(commissionPrice).toNumber() < minimumSalary.toNumber() ? minimumSalary.toNumber() : basicSalary.plus(commissionPrice).toNumber() // 基本工资+提成<保底工资,则取保底工资
        })
        this.performanceTableData = (this.whiteFlag ? res?.list : []) || []
      })
    },
    // 每页条数
    handleSizeChange(value) {
      this.page.pageSize = value
      this.getOrderData()
    },
    // 页码
    handleCurrentChange(value) {
      this.page.currentPage = value
      this.getOrderData()
    },
    handleSceneChange() {
      this.page.currentPage = 1
      this.getOrderData()
    },
    handleMonthRangeBlur(e) {
      this.page.currentPage = 1
      // 获取历史订单数据
      this.getOrderData()
    },
    getOrderData() {
      let params = this.getParams()
      params = {
        ...this.page,
        ...params
      }
      getStaffHistoryOrderListApi(params).then(res => {
        this.orderTableData = res?.list || []
        this.total = res?.total || 0
      })
    },
    // 修订工资
    handleEditSalary(row) {
      this.revisedSalaryRow = row
      this.handleSalaryCloseDialog()
    },
    handleSalaryCloseDialog(e) {
      if (e?.flag) {
        // 刷新业绩列表数据
        this.getPerformanceData()
      }
      this.revisedSalaryVisible = !this.revisedSalaryVisible
    }
  }
}
</script>
<style lang="scss" scoped>
.historicalPerformance {
  background: #fff;
  .content {
    .header{
      padding: 0 20px;
      height: 48px;
      display: flex;
      align-items: center;
      font-size: 14px;
      border-bottom: 1px solid #E5E5E5;
      .name{
        font-size: 18px;
        font-weight: bold;
        color: #333333;
      }
      span{
        color: #CCCCCC;
        margin: 0 8px;
      }
    }
    .content-warp{
      padding: 16px 20px;
      .plan-item{
        margin-bottom: 16px;
        font-size: 14px;
        display: flex;
        label{
          width: 138px;
          height: 32px;
          line-height: 32px;
          flex-shrink: 0;
          color: #666666;
          text-align: right;
        }
        .line-h-32{
          height: 32px;
          line-height: 32px;
        }
        .label-value{
          .wid_432{
            width: 432px;
            margin-bottom: 16px;
          }
          .wid_136 {
            width: 136px;
            margin-bottom: 16px;
          }
          span{
            margin: 0 4px;
          }
        }
      }
      ::v-deep .el-table thead tr th{
        background-color: #F2F4F7;
        color: #333333;
        font-weight: 500;
        i{
          color: #999999;
        }
      }
      ::v-deep .table-header{
        margin-bottom: 10px;
        .el-col{
          display: flex;
          justify-content: space-between;
        }
        .scene-type{
          display: flex;
          align-items: center;
          margin-right: 20px;
        }
        label{
          height: 32px;
          line-height: 32px;
          color: #1D1D1D;
        }
      }
    }
    .total-amount{
      height: 60px;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      font-size: 18px;
      color: #333333;
      .amount{
        color: #2A58AD;
        font-weight: bold;
      }
    }
  }
  .change-flag{
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    background: #f47f131a;
    font-size: 12px; 
    color: #F47F13;
    margin-left: 4px;
  }
  .empty-flag{
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-left: 4px;
  }
}
</style>
<style lang="scss">
.statement-of-history-performance-month-picker {
  .el-month-table .in-range .cell:hover {
    color: #FFFFFF;
  }
} 
</style>