explainDialog.vue 4.57 KB
<template>
  <GLDialog :title="title" mode="mid" :visible.sync="isVisible" okText="确定" :before-close="handleClose" @onOk="handleConfirm" @onCancel="handleClose">
    <div class="explain-title">示例规则定义</div>
    <p class="business-info" v-if="diffExplain == 'constructionBonus'">升级订单施工奖励:70.00元;战败订单施工奖励:50.00元</p>
    <GLTable v-else :tableData="tableData" :tableParams="tableParams" :hasPage="false"></GLTable>
    <div class="explain-title mt20">示例业务场景</div>
    <div class="business-info" v-html="infoHtml"></div>
  </GLDialog>
</template>

<script>
export default {
  data() {
    return {
      tableParams: {
        tableColumns: [
          {
            label: '区间开始值',
            prop: 'startValue'
          },
          {
            label: '区间结束值',
            prop: 'endValue'
          },
          {
            label: '奖励金额/元',
            prop: 'calculateValue'
          }
        ]
      },
      tableData: []
    }
  },
  props: {
    isExplain: {
      type: Boolean,
      default: false
    },
    diffExplain: {
      type: String,
      default: ''
    }
  },
  computed: {
    title() {
      const titleObj = {
        commissionBonus: '提成奖励示例说明',
        highCustomerUnitBonus: '高客单奖励示例说明',
        successRateBonus: '成交率奖励示例说明',
        constructionBonus: '施工奖励示例说明'
      }
      return titleObj[this.diffExplain]
    },
    infoHtml() {
      const infoObj = {
        commissionBonus: `<div class='mb10'>员工A在某个月中完成升级订单5个,对应的订单产值1000.00元、1500.00元、2000.00元、2500.00元、3000.00元,</div>
<div class='mb10'>则月度的平均客单价=升级订单总产值/升级订单数量=2000.00元,对应规则的提成比例=10.00%,按每个升级订单的产值*10%计算每单提成;</div>
<div class='mb10'>则员工A在该月份获得的总提成奖励=100.00+150.00+200.00+250.00+300.00=1000.00元。</div>`,
        highCustomerUnitBonus: `<div class='mb10'>员工A在某个月中完成升级订单5个,对应的订单产值1000.00元、1500.00元、2000.00元、2500.00元、3000.00元,</div>
<div class='mb10'>按高客单奖励规则,产值在0.00-2000.00元的订单每单奖励0.00元(不奖励),产值在2000.00元以上的订单每单奖励100.00元;</div>
<div class='mb10'>则员工A在该月份获得的高客单奖励=0.00+0.00+0.00+100.00+100.00=200元。</div>`,
        successRateBonus: `<div class='mb10'>员工A在某个月中完成升级订单9个,战败订单1个</div>
<div class='mb10'>则月度的成交率=升级订单数/(升级订单数+战败订单数)=90.00%,对应规则的奖励金额=1000.00元;</div>
<div class='mb10'>则员工A在该月份获得的成交率奖励=1000.00元。</div>`,
        constructionBonus: `<div class='mb10'>员工A在某个月中施工了升级订单5个,施工了战败订单5个;</div>
<div class='mb10'>则员工A在该月份获得的总提成奖励=(70.00*5)+(50.00*5)=600.00元。</div>`
      }
      return infoObj[this.diffExplain]
    },
    isVisible() {
      return this.isExplain
    }
  },
  watch: {
    diffExplain(newVal) {
        console.log(newVal)
      if (newVal == 'successRateBonus') {
        this.tableData = [
          { startValue: '', endValue: '80%', calculateValue: 0.0 },
          { startValue: '80.01%', endValue: '90%', calculateValue: 1000.0 },
          { startValue: '90.01%', endValue: '', calculateValue: 2000.0 }
        ]
      } else if (newVal == 'commissionBonus') {
        this.tableData = [
          { startValue: 0.0, endValue: 2000.0, calculateValue: '10%' },
          { startValue: 2000.01, endValue: '', calculateValue: '20%' }
        ]
      } else {
        this.tableData = [
          { startValue: 0.0, endValue: 2000.0, calculateValue: 0.0 },
          { startValue: 2000.01, endValue: '', calculateValue: 2000.01 }
        ]
      }
      if (newVal == 'commissionBonus') {
        this.tableParams.tableColumns[2].label = '提成比例'
      } else {
        this.tableParams.tableColumns[2].label = '奖励金额/元'
      }
    }
  },
  methods: {
    handleConfirm() {
      this.$emit('handleClose')
    },
    handleClose() {
      this.$emit('handleClose')
    }
  }
}
</script>

<style lang="scss">
.explain-title {
  font-weight: 600;
  font-size: 16px;
  color: #333333;
  margin-bottom: 10px;
}

.business-info {
  font-size: 14px;
  color: #333333;
  line-height: 18px;
}

.mb10 {
  margin-bottom: 10px;
}

.mt20 {
  margin-top: 20px;
}
</style>