technicianPerformance.vue 12.6 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
<template>
  <div class="shop">
    <template>
      <el-alert title="每月最后一天24:00按当月业务完成情况自动计算员工绩效。"
                show-icon
                class="tip-cla"></el-alert>
    </template>
    <div class="container">
      <GLCombiForm ref="showSearch"
                   :rowNumber="1"
                   :formObj="searchForm"
                   :formData="showFormData"
                   @handleOk="handleSearch"
                   @handleRest="handleReset">
        <div slot="performanceMonth">
          <el-date-picker v-model="searchForm.performanceMonth"
                          type="month"
                          placeholder="选择月"
                          value-format="yyyy-MM"
                          format="yyyy-MM"
                          clearable
                          :picker-options="pickerOption"></el-date-picker>
        </div>
      </GLCombiForm>
      <div class="table-header">
        <h2>技师绩效列表</h2>
        <div>
          <el-button size="small"
                     @click="exportExcel_summary"
                     plain>导出汇总表</el-button>
          <el-button size="small"
                     @click="exportExcel_detail">导出明细</el-button>
          <el-button size="small"
                     @click="batchDistribute">批量下发</el-button>
        </div>
      </div>

      <!-- 表格区域 开始 -->
      <GLTable ref="residentRef"
               :getListApi="getListApi"
               :noDataImg="url"
               :searchForm="tableSearchForm"
               :tableParams="tableParams"
               :pageConf="pageConf"
               :beforeSearchFn="beforeSearchFn"
               @setTableFinishFun="setTableFinishFun">
        <div class="tb-ellipsis"
             slot="yqMerchantName"
             slot-scope="scope">
          <el-popover placement="top"
                      popper-class="base-popper"
                      trigger="hover"
                      :content="scope.scope.yqMerchantName">
            <span slot="reference">
              {{ scope.scope.yqMerchantName }}
            </span>
          </el-popover>
        </div>
        <div slot="applyStatus"
             slot-scope="scope"
             class="flex">
          <div :class="['dot', statusClass[scope.scope.status]]"></div>
          {{ reviewStatusObj[scope.scope.status] }}
        </div>
        <!-- <div class="table-btns"
             slot="auth-button"
             slot-scope="scope">
          <GLTableButton :buttonList="tableButtonList"
                         :buttonItem="scope.scope"
                         :buttonNum="3"></GLTableButton>
        </div> -->
        <div class="table-btns"
             slot="auth-button"
             slot-scope="scope">
          <el-button type="text"
                     v-if="scope.scope.status == 0"
                     @click="handleCorrection(scope.scope)">校正</el-button>
          <el-button type="text"
                     v-if="scope.scope.status == 0"
                     @click="distribute(scope.scope)">下发</el-button>
          <el-button type="text"
                     @click="handleDetail(scope.scope)">查看明细</el-button>
        </div>
      </GLTable>
      <!-- 表格区域 end -->
    </div>
    <TechnicianDetailDialog v-if="isTechnicianVisible"
                            :isVisible="isTechnicianVisible"
                            :recordInfo="recordInfo"
                            @handleClose="handleDetail"></TechnicianDetailDialog>
    <TechnicianCorrectionDialog v-if="isCorrectionVisible"
                                :isVisible="isCorrectionVisible"
                                :recordInfo="recordInfo"
                                @handleClose="handleCorrectionClose"></TechnicianCorrectionDialog>
  </div>
</template>

<script>
// import * as dayjs from 'dayjs'
import url from '@/assets/empty.png'
import { downLoadFile } from '@/common/format'
import TechnicianDetailDialog from './technicianDetailDialog.vue'
import TechnicianCorrectionDialog from './technicianCorrectionDialog.vue'
export default {
  name: 'TechnicianPerformance',
  data() {
    return {
      size: 'small',
      url: url,
      userInfo: {},
      searchForm: {
        performanceMonth: '',
        staffName: '',
        staffPhone: '',
        yqMerchantId: '',
        status: '',
        staffType: 1 //员工类型(0:驻店,1:技师)
      },
      tableSearchForm: {},
      showFormData: [
        {
          label: '绩效月份',
          prop: 'performanceMonth',
          addHtml: 'performanceMonth'
        },
        {
          label: '员工姓名',
          name: 'staffName',
          type: 'input',
          isClear: true,
          maxlength: 20
        },
        {
          label: '员工手机号',
          name: 'staffPhone',
          type: 'input',
          inputType: 'number',
          isClear: true,
          maxlength: '11'
        },
        {
          label: '所属服务中心',
          name: 'yqMerchantId',
          type: 'select',
          optionList: [],
          optionId: 'yqMerchantId',
          optionLabel: 'yqMerchantName',
          optionsName: 'merchantList'
        },
        {
          label: '状态',
          name: 'status',
          type: 'select',
          optionList: [],
          optionId: 'confId',
          optionLabel: 'confName',
          optionsName: 'statusList'
        }
      ],
      pickerOption: {
        disabledDate(date) {
          if (date > new Date()) {
            return true
          }
          return false
        }
      },
      // 表格
      getListApi: this.$apis.performanceManage.getListApi,
      tableParams: {
        listName: 'list',
        mutiSelectUniqueKey: 'id',
        mutiSelectName: 'technicianPerformance',
        checkSelectable: row => {
          return row.status == 0
        },
        tableOption: true,
        tableColumns: [
          {
            label: '员工姓名',
            prop: 'staffName',
            width: 130,
            line: 1
          },
          {
            label: '员工手机号',
            prop: 'staffPhone',
            width: 130
          },
          {
            label: '所属服务中心',
            prop: 'yqMerchantName',
            addHtml: 'yqMerchantName',
            minWidth: 120
          },
          {
            label: '基本工资',
            prop: 'basicWage',
            width: 120,
            formatter: cellValue => {
              return cellValue.basicWage || cellValue.basicWage == 0 ? cellValue.basicWage.toFixed(2) : '-'
            }
          },
          {
            label: '保底工资',
            prop: 'minimumWage',
            width: 120,
            formatter: cellValue => {
              return cellValue.minimumWage || cellValue.minimumWage == 0 ? cellValue.minimumWage.toFixed(2) : '-'
            }
          },
          {
            label: '施工奖励',
            prop: 'constructionBonus',
            width: 120,
            formatter: cellValue => {
              return cellValue.constructionBonus || cellValue.constructionBonus == 0 ? cellValue.constructionBonus.toFixed(2) : '-'
            }
          },
          {
            label: '其他费用',
            prop: 'otherExpenses',
            width: 100,
            formatter: cellValue => {
              return cellValue.otherExpenses || cellValue.otherExpenses == 0 ? cellValue.otherExpenses.toFixed(2) : '-'
            }
          },
          {
            label: '最终工资',
            prop: 'finalWage',
            width: 100,
            formatter: cellValue => {
              return cellValue.finalWage || cellValue.finalWage == 0 ? cellValue.finalWage.toFixed(2) : '-'
            }
          },
          {
            label: '状态',
            prop: 'status',
            width: '100px',
            addHtml: 'applyStatus'
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
      statusClass: {
        0: 'grey',
        1: 'green'
      },
      reviewStatusObj: {
        0: '未下发',
        1: '已下发'
      },
      isTechnicianVisible: false,
      isCorrectionVisible: false,
      recordInfo: {},
      // 基本数据
      baseData: {
        merchantList: [],
        statusList: [
          {
            confId: 0,
            confName: '未下发'
          },
          {
            confId: 1,
            confName: '已下发'
          }
        ]
      },
      setMonthFlag: false //第一次进入页面时设置绩效月份参数值
    }
  },
  components: {
    TechnicianDetailDialog,
    TechnicianCorrectionDialog
  },
  mounted() {
    this.userInfo = this.$globalState.session
    this.getServiceCenterList()
  },
  methods: {
    getLastMonth() {
      // 获取上个月日期
      var date = new Date()
      var year = date.getFullYear()
      var month = date.getMonth()
      if (month == 0) {
        year = year - 1
        month = 12
      }
      month = month > 10 ? month : '0' + month
      this.searchForm.performanceMonth = year.toString() + '-' + month
    },
    getServiceCenterList() {
      const params = {
        partnerMerchantId: this.userInfo.merchantId
      }
      this.$apis.customer.getServiceCenterList(params).then(res => {
        this.baseData.merchantList = res
        this.$utils.getOptionsList(this, 'showFormData')
      })
    },
    getParams() {
      var params = JSON.parse(JSON.stringify(this.searchForm))
      return params
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        if (!this.setMonthFlag) {
          //进入页面时设置绩效月份参数值
          this.getLastMonth()
        }
        this.tableSearchForm = this.getParams()
        this.setMonthFlag = true
        resolve()
      })
    },
    handleSearch() {
      this.$refs.residentRef.refreshTable()
    },
    handleReset() {
      this.searchForm = {
        performanceMonth: '',
        staffName: '',
        staffPhone: '',
        yqMerchantId: '',
        status: '',
        staffType: 1
      }
      this.handleSearch()
    },
    handleDetail(row) {
      this.recordInfo = row ? row : {}
      this.isTechnicianVisible = !this.isTechnicianVisible
    },
    handleCorrection(row) {
      this.recordInfo = row ? row : {}
      this.isCorrectionVisible = !this.isCorrectionVisible
    },
    handleCorrectionClose() {
      this.isCorrectionVisible = !this.isCorrectionVisible
      this.$refs.residentRef.refreshTable()
    },
    // 下发操作
    distribute(row) {
      var selectedData = []
      selectedData.push(row)
      this.distribute_commit(selectedData)
    },
    // 批量下发
    batchDistribute() {
      var selectedData = []
      if (this.$refs.residentRef.mutiSelectArr.technicianPerformance) {
        selectedData = this.$refs.residentRef.mutiSelectArr.technicianPerformance
      }
      this.distribute_commit(selectedData)
    },

    distribute_commit(selectedData) {
      if (!selectedData?.length) {
        this.$message({
          message: '请选择需要下发的记录',
          type: 'warning',
          showClose: true
        })
        return false
      }
      var idList = selectedData.map(item => {
        return item.id
      })
      this.$confirm('<strong>是否确定下发?</strong> <div>完成工资记录下发后,员工可查看到对应的工资记录,且不允许再修改</div> ', '提示', {
        dangerouslyUseHTMLString: true,
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$apis.performanceManage.batchIssueApi({ idList: idList }).then(res => {
            this.$notify({
              type: 'success',
              title: res.message || '操作成功'
            })
            this.$refs.residentRef.refreshTable()
          })
        })
        .catch(err => {
          console.log(err)
        })
    },
    exportExcel_summary() {
      var params = this.getParams()
      this.$apis.performanceManage.exportSummaryApi(params).then(res => {
        downLoadFile(res)
      })
    },
    exportExcel_detail() {
      var params = this.getParams()
      this.$apis.performanceManage.exportDetailApi(params).then(res => {
        downLoadFile(res)
      })
    }
  }
}
</script>
<style scoped>
.tip-cla {
  margin: 16px 0 16px 0;
  width: 1184px;
  height: 40px;
  background: #e4e3ff;
  border-radius: 4px;
}

.flex {
  display: flex;
  align-items: center;
}

.dot {
  width: 6px;
  height: 6px;
  background: #5850ff;
  border-radius: 4px;
  margin-right: 6px;
}

.green {
  background: #4aca74;
}

.red {
  background: #eb4e4e;
}

.grey {
  background: #999999;
}
</style>