employeeTasksView.vue 10.6 KB
<!-- 驻店员工查看任务 -->
<template>
  <d2-container :loading="$store.state.d2admin.loading.value">
    <div class="d2-container-content">
      <p class="edit-sub-title">
        查看员工任务
      </p>
      <glsx-combi-form class="edit-form-container"
                       ref="editFormRef2"
                       label-width="154px"
                       default-width="432px"
                       :is-block="true"
                       form-ref="editChildRef"
                       :form-obj="viewInfo"
                       :form-data="viewFormData">
        <div slot="inStoreTarget">
          <d2-table :array-span-method="arraySpanMethod" :table-data="viewInfo.tableData" :table-params="tableParams" :has-page="false">
            <!-- 车主类型 -->
            <template slot="selectCarType" slot-scope="scope">
              <div v-if="scope.scope.selectCarType == 0">无</div>
              <div v-if="scope.scope.selectCarType == 1">车辆价格:{{ scope.scope.minCarPrice }}-{{ scope.scope.maxCarPrice }}万</div>
              <div v-if="scope.scope.selectCarType == 2">车辆类型:
                <span v-for="(subItem, subIndex) in scope.scope.carList" :key="subIndex">{{ `${subItem.carSeriesName}` }}<span v-if="subIndex < scope.scope.carList.length - 1"> / </span></span>
              </div>
            </template>
            <!-- 主推产品套餐 -->
            <template slot="selectPackageType" slot-scope="scope">
              <div v-if="scope.scope.selectPackageType == 0">无</div>
              <!-- 单商品/多个商品 -->
              <div v-if="scope.scope.selectPackageType == 1">
                <div style="padding: 0 3px;width: 180px;overflow: hidden; text-overflow: ellipsis;white-space: nowrap;" v-for="(subItem, subIndex) in scope.scope.packageList" :key="subIndex">{{ subItem.upgradeGoodsName }}</div>
              </div>
              <!-- 商品组合 -->
              <div v-if="scope.scope.selectPackageType == 2">
                <span v-for="(subItem, subIndex) in scope.scope.packageList" :key="subIndex">{{ subItem.upgradeGoodsName }}<span v-if="subIndex < scope.scope.packageList.length - 1"> + </span></span>
              </div>
            </template>
            <!-- 目标转化率 -->
            <template slot="conversionRate" slot-scope="scope">
              <div v-if="scope.scope.selectPackageType == 1">
                <div v-for="(subItem, subIndex) in scope.scope.packageList" :key="subIndex">{{ `${subItem.conversionRate}%` || '-' }}</div>
              </div>
              <div v-else>{{ `${scope.scope.conversionRate}%` || '-' }}</div>
            </template>
            <!-- 目标转化率提成 -->
            <template slot="conversionRatePercentage" slot-scope="scope">
              <div v-if="scope.scope.selectPackageType == 1">
                <div v-for="(subItem, subIndex) in scope.scope.packageList" :key="subIndex">{{ `${subItem.conversionRatePercentage}%` || '-' }}</div>
              </div>
              <div v-else>{{ `${scope.scope.conversionRatePercentage}%` || '-' }}</div>
            </template>
            <!-- 客单价 -->
            <template slot="customerUnitPrice" slot-scope="scope">
              <div v-if="scope.scope.selectPackageType == 1">
                <div v-for="(subItem, subIndex) in scope.scope.packageList" :key="subIndex">{{ `¥${subItem.customerUnitPrice}` || '-' }}</div>
              </div>
              <div v-else>{{ `¥${scope.scope.customerUnitPrice}` || '-' }}</div>
            </template>
            <!-- 客单价提成 -->
            <template slot="customerUnitPricePercentage" slot-scope="scope">
              <div v-if="scope.scope.selectPackageType == 1">
                <div v-for="(subItem, subIndex) in scope.scope.packageList" :key="subIndex">{{ `${subItem.customerUnitPricePercentage}%` || '-' }}</div>
              </div>
              <div v-else>{{ `${scope.scope.customerUnitPricePercentage}%` || '-' }}</div>
            </template>
          </d2-table>
        </div>
      </glsx-combi-form>
      <div class="page_footer">
        <el-button type="primary" @click="handleClose">
          返回
        </el-button>
      </div>
    </div>
  </d2-container>
</template>
<script>
import { mapActions } from 'vuex'
import { getStaffTaskDetailApi } from '@api/inStoreTargetConfig'
export default {
  name: 'EmployeeTaskView',
  data() {
    return {
      viewFormData: [{
        label: '门店名称',
        isHide: false,
        name: 'merchantName',
        type: 'showTxt'
      }, {
        label: '业务场景',
        isHide: false,
        name: 'sceneTypeTxt',
        type: 'showTxt'
      }, {
        label: '驻店员工',
        isHide: false,
        name: 'staffName',
        type: 'showTxt'
      }, {
        label: '联系方式',
        isHide: false,
        name: 'phoneNumber',
        type: 'showTxt'
      }, {
        label: '考核周期',
        isHide: false,
        name: 'checkMonthPeriod',
        type: 'showTxt'
      }, {
        label: '驻店目标',
        isHide: false,
        addHtml: 'inStoreTarget'
      }],
      tableParams: {
        tableColumns: [{
          label: '月度',
          prop: 'checkMonth',
          formatter: (cellValue) => {
            return { 1: '首月', 2: '次月', 3: '第三月' }[cellValue?.checkMonth]
          }
        }, {
          label: '周期',
          prop: 'checkPeriod',
          formatter: (cellValue) => {
            return { 1: '上半月', 2: '下半月' }[cellValue?.checkPeriod]
          }
        }, {
          label: '车主类型',
          prop: 'selectCarType',
          addHtml: 'selectCarType'
        }, {
          label: '主推产品套餐',
          prop: 'studentNumber',
          width: '180',
          addHtml: 'selectPackageType'
        }, {
          label: '目标转化率',
          prop: 'conversionRate',
          addHtml: 'conversionRate'
        }, {
          label: '提成系数',
          prop: 'conversionRatePercentage',
          addHtml: 'conversionRatePercentage'
        }, {
          label: '目标客单价',
          prop: 'customerUnitPrice',
          addHtml: 'customerUnitPrice'
        }, {
          label: '提成系数',
          prop: 'customerUnitPricePercentage',
          addHtml: 'customerUnitPricePercentage'
        }]
      },
      viewInfo: {
        tableData: []
      },
      spanArr1: [],
      spanIndex1: 0,
      spanArr2: [],
      spanIndex2: 0,
      spanArr3: [],
      spanIndex3: 0
    }
  },
  mounted() {
    const routerQuery = this.$route.query
    // 获取详情
    this.getDetailInfo(routerQuery)
  },
  methods: {
    ...mapActions({
      get: 'd2admin/base/get',
      close: 'd2admin/page/close'
    }),
    getDetailInfo(routerQuery) {
      getStaffTaskDetailApi({ id: routerQuery?.id }).then(res => {
        res.taskList?.forEach(val => {
          val.checkMonth = res?.checkMonth
          val.checkPeriod = res?.checkPeriod
        })
        res = {
          merchantName: res?.targetCofig?.merchantName,
          sceneTypeTxt: ['会员权益/升级', '精品升级'][res?.targetCofig?.sceneType] || '-',
          staffName: res.staffName,
          phoneNumber: res.phoneNumber,
          checkMonthPeriod: `${{ 1: '首月', 2: '次月', 3: '第三月' }[res?.checkMonth]}-${{ 1: '上半月', 2: '下半月' }[res?.checkPeriod]}`,
          tableData: res?.taskList || []
        }
        this.viewInfo = res || {}
        this.merge(res?.tableData)
      }).catch(() => {})
    },
    // 合并表格
    arraySpanMethod({ row, column, rowIndex, columnIndex }) {
      const len = this.viewInfo?.tableData?.length
      const t = 10
      if (columnIndex === 0) {
        // 第一列 序号
        const _row_1 = this.spanArr1[rowIndex]
        const _col_1 = _row_1 > 0 ? 1 : 0
        return {
          rowspan: _row_1,
          colspan: _col_1
        }
      } else if (columnIndex === 1) {
        // 第二列 月度
        const _row_2 = this.spanArr2[rowIndex]
        const _col_2 = _row_2 > 0 ? 1 : 0
        return {
          rowspan: _row_2,
          colspan: _col_2
        }
        // 第三列 周期
      } else if (columnIndex === 2) {
        const _row_3 = this.spanArr3[rowIndex]
        const _col_3 = _row_3 > 0 ? 1 : 0
        return {
          rowspan: _row_3,
          colspan: _col_3
        }
      } else if (columnIndex === t) {
        const _row_4 = len
        const _col_4 = 1
        return {
          rowspan: _row_4,
          colspan: _col_4
        }
      } else if (rowIndex === len) {
        return {
          rowspan: 1,
          colspan: 1
        }
      }
    },
    // 初始化合并行数组
    mergeInit() {
      this.spanArr1 = [] // 合并序号
      this.spanIndex1 = 0 // 合并序号索引
      this.spanArr2 = [] // 合并月度
      this.spanIndex2 = 0 // 合并月度索引
      this.spanArr3 = [] // 合并周期
      this.spanIndex3 = 0 // 合并周期索引
    },
    //  合并表格
    merge(data) {
      this.mergeInit()
      if (data.length > 0) {
        for (var i = 0; i < data.length; i++) {
          if (i === 0) {
            // 第一行必须存在,以第一行为基准
            this.spanArr1.push(1) // 合并序号
            this.spanIndex1 = 0
            this.spanArr2.push(1) // 合并月度
            this.spanIndex2 = 0
            this.spanArr3.push(1) // 合并周期
            this.spanIndex3 = 0
          } else {
            // 根据月度和考核周期进行合并
            if (data[i].checkMonth == data[i - 1].checkMonth && data[i].checkPeriod == data[i - 1].checkPeriod) {
              this.spanArr1[this.spanIndex1] += 1
              this.spanArr1.push(0)
              this.spanArr2[this.spanIndex2] += 1
              this.spanArr2.push(0)
              this.spanArr3[this.spanIndex3] += 1
              this.spanArr3.push(0)
            } else {
              this.spanArr1.push(1)
              this.spanIndex1 = i
              this.spanArr2.push(1)
              this.spanIndex2 = i
              this.spanArr3.push(1)
              this.spanIndex3 = i
            }
          }
        }
      }
    },
    // 返回
    handleClose() {
      this.close({ tagName: '/inStoreGoalsConfig' })
      // 返回后列表页tab默认选中驻店员工目标项
      this.$router.push({
        name: 'inStoreGoalsConfig',
        params: {
          tabPane: "1",
          tabLabel: "staffTargetList"
        }
      })
      this.close({ tagName: '/employeeTasksView' })
    }
  }
}
</script>
<style scoped lang="scss">
.edit-sub-title {
  padding-bottom: 14px;
  border-bottom: 1px solid #e8e8ea;
}
.page_footer{
  display: flex;
  justify-content: center;
}
::v-deep .el-form-item__content{
  width: calc(100% - 154px);
}
</style>