deductionDialog.vue 7.25 KB
<!-- 扣款明细 -->
<template>
  <div class="deduction-dialog">
    <d2-dialog
        :is-visible="visible"
        noCancel
        :isShowFooter="false"
        width="720px"
        @closeDialog="handleConfirm"
        @confirmDialog="handleConfirm"
      >
      <div slot="sub-title" class="title">扣款明细
        <el-tooltip class="item" effect="light" popper-class="sub-title-tooltip" placement="right">
          <template slot="content">
            <img style="width: 800px;" :src="`https://img02.glsx.com.cn/weapp/resource/saas/dj/images/deduction_tips_img.png?v=${new Date().getTime()}`" />
          </template>
          <i class="el-icon-info"></i>
        </el-tooltip>
      </div>
      <div class="content" v-if="show">
        <div class="item" v-for="item in formData" :key="item.value">
          <div class="label">{{ item.label }}:</div>
          <div class="value">
            <el-input :value="formatMoney(infoData[item.value], item)" disabled></el-input>
            <div v-if="item.tipsKey && infoData[item.value]" class="value-tips">
              月度总提成的<span style="color: #2A58AD;">{{infoData[item.tipsKey]}}%</span>延迟6个月发放
            </div>
            <div v-if="item.hasDetail" class="value-tips">
              <template v-if="item.value === 'dailyDeductMoney'">
                <div class="deduct-item" v-if="infoData.dailyDeductDetailData1.length">精品升级 本月扣
                  <span v-for="(subItem, subIndex) in infoData.dailyDeductDetailData1" :key="subIndex" class="tips-text">{{ subItem }}日
                    <span v-if="subIndex !== infoData.dailyDeductDetailData1.length - 1">、</span>
                  </span>
                </div>
                <div class="deduct-item" v-if="infoData.dailyDeductDetailData2.length">会员权益/升级 本月扣
                  <span v-for="(subItem, subIndex) in infoData.dailyDeductDetailData2" :key="subIndex" class="tips-text">{{ subItem }}日
                    <span v-if="subIndex !== infoData.dailyDeductDetailData2.length - 1">、</span>
                  </span>
                </div>
              </template>
              <template v-else-if="item.value === 'padDeductMoney'">
                <div>
                  本月录音数<span class="tips-text">{{ infoData.recordingCount || 0 }}</span>条 本月总触客数<span class="tips-text">{{ infoData.toShopFilmCount || 0 }}</span>人
                </div>
              </template>
              <template v-else-if="item.value === 'performancePenalty' && !isEmpty(infoData.performanceSalarDeductionRatio)">
                <div v-if="infoData.monthTotalPrice == 0">
                  若月底产值为0时,绩效工资扣减<span class="tips-text">{{ `${infoData.performanceSalarDeductionRatio}%` }}</span>
                </div>
                <div v-else>
                  若月底产值不为0时,绩效工资扣减<span class="tips-text">{{ `${infoData.performanceSalarDeductionRatio}%` }}</span>
                </div>
              </template>
            </div>
          </div>
        </div>
      </div>
    </d2-dialog>
  </div>
</template>

<script>
import { getStaffDeductDetailAPI } from '@api/resident'
import { isEmpty, filterStr } from '../util.js'
import BigNumber from 'bignumber.js'
export default {
  name: 'BasicSalaryDialog',
  data() {
    return {
      isEmpty,
      dialogConfig: {
        title: '',
        width: '720px'
      },
      formData: [
        {
          label: '日报扣款',
          value: 'dailyDeductMoney',
          hasDetail: true
        },
        {
          label: '平板扣款',
          value: 'padDeductMoney',
          hasDetail: true
        },
        {
          label: '递延金扣款',
          value: 'deferExpenses',
          tipsKey: 'deferredRatio'
        },
        {
          label: '递延金纳入',
          value: 'deferIncome',
          tipsKey: 'deferredRatio2'
        },
        {
          label: '退单冲减',
          value: 'refundOffset'
        },
        {
          label: '绩效工资扣减',
          value: 'performancePenalty',
          hasDetail: true
        },
        {
          label: '其它应发/应扣',
          value: 'otherDeduction'
        }
      ],
      infoData: {},
      show: false
    }
  },
  props: {
    deductionVisible: {
      type: Boolean,
      default: false
    },
    detailRow: {
      type: Object,
      default: () => {}
    },
    detailInfo: {
      type: Object,
      default: () => {}
    }
  },
  computed: {
    visible: {
      get() {
        return this.deductionVisible
      },
      set(newVal) {
        this.$emit('dialogClose', { flag: newVal, attrName: 'deductionVisible' })
      }
    }
  },
  mounted() {
    this.getDeductDetail()
  },
  methods: {
    formatMoney(value, item) {
      const num = Number(value);
      return isNaN(num) ? '0元' : `${num}元`;
    },
    handleConfirm() {
      this.$emit('dialogClose')
    },
    getDeductDetail() {
      getStaffDeductDetailAPI({ id: this.detailRow?.id }).then(res => {
        const performanceSalary = new BigNumber(res.performanceSalary || 0) // 绩效工资
        const actualPerformanceSalary = new BigNumber(res.actualPerformanceSalary || 0) // 实际绩效工资
        this.infoData = {
          ...res,
          refundOffset: !this.isEmpty(res?.refundOffset) ? `-${Math.abs(res?.refundOffset)}` : 0,
          dailyDeductDetailData1: res?.dailyDeductDetailData1?.length ? this.getSortedDays(res?.dailyDeductDetailData1) : [],
          dailyDeductDetailData2: res?.dailyDeductDetailData2?.length ? this.getSortedDays(res?.dailyDeductDetailData2) : [],
          performancePenalty: !this.isEmpty(performanceSalary.minus(actualPerformanceSalary).toNumber()) ? `-${Math.abs(performanceSalary.minus(actualPerformanceSalary).toNumber())}` : 0
        }
        this.show = true
      })
    },
    getSortedDays(dateArray, ascending = true) {
      // 1. 按日期排序
      const sortedDates = dateArray.sort((a, b) => {
        return ascending ? new Date(a) - new Date(b) : new Date(b) - new Date(a)
      })
      return sortedDates.map(date => {
        const day = date.split("-")[2]
        return parseInt(day, 10).toString()
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.deduction-dialog {
  ::v-deep .el-dialog__header {
    border-bottom: 1px solid #e6e6e6;
  }
  ::v-deep .el-dialog__headerbtn .el-dialog__close {
    color: #666;
    font-weight: 600;
    font-size: 20px;
  }
  ::v-deep .dialog-sub-title {
    color: #333333;
    font-family: PingFangSC-Medium;
    font-size: 20px;
    font-weight: 600;
  }
  .content{
    padding: 0 30px;
    max-height: calc(68vh - 70px);
    overflow-y: auto;
    .item {
      display: flex;
      // align-items: center;
      margin-bottom: 20px;
      .label {
        width: 110px;
        text-align: right;
        margin-top: 8px;
        color: #333333;
      }
      .value {
        width: 432px;
        .value-tips {
          margin-top: 8px;
          color: #666666;
          .tips-text {
            color: #5579bd;
          }
        }
        .deduct-item{
          margin-top: 5px;
          &:first-child {
            margin: 0;
          }
        }
      }
    }
  }
}
</style>
<style>
.sub-title-tooltip {
  max-width: 810px !important;
  width: 810px !important;
}
</style>