ReceptionTable.vue 8.91 KB
<!-- 预警明细 -->
<template>
  <!-- <div> -->
  <div>
    <div class="header">
      <d2-search
        ref="showSearch"
        class="show-search"
        :search-form="searchForm"
        :form-data="showFormData"
        label-width="100px"
      />
      <div class="up-btns">
        <el-button
          :id="tableParams.btnId"
          size="small"
          type="primary"
        >
          查询
        </el-button>
        <el-button
          size="small"
          @click="handleReset"
        >
          重置
        </el-button>
      </div>
    </div>
    <!-- </div> -->
    <div class="d2-container-content">
      <d2-table-header>
        <auth-button category="Button" />
      </d2-table-header>
      <d2-table
        ref="detailListTable"
        :search-form="searchForm"
        :table-params="tableParams"
        :get-list-api="getListApi"
        :before-search-fn="beforeSearchFn"
      >
        <div
          slot="auth-button"
          slot-scope="scope"
        >
          <el-button
            type="text"
            @click="handleDetail(scope.scope)"
          >接待详情</el-button>
        </div>
      </d2-table>
    </div>
  </div>
  <!-- </div> -->
</template>

<script>
import { downLoadFile } from '@/common/util'
import { getReceptionDetailPage, getReceptionDetailReport, getReceptionStaffList } from '@api/earlyWarningManager'

export default {
  name: 'Details',
  props: {
    searchTime: {
      type: Object,
      default: () => { }
    },
    pageData: {
      type: Object,
      default: () => { }
    },
    show: Boolean
  },
  watch: {
    show: {
      async handler (newVal) {
        if (newVal) {
          if (!this.initStatus || this.searchTimeStatus) {
            if (!this.initStatus) await this.getReceptionStaffList()
            if (this.searchTimeStatus) this.timerSearch()
            this.initStatus = true
          }
        }
      },
      immediate: true,
      deep: true
    },
    searchTime (n) {
      if (this.initStatus) {
        if (this.show) this.timerSearch()
        else this.searchTimeStatus = true
      }
    }
  },
  data () {
    return {
      initStatus: false,
      searchTimeStatus: false,
      searchForm: {
        orderFinishFlag: null,
        staffUUid: null
      },
      showFormData: [{
        label: '驻店人员',
        name: 'staffUUid',
        type: 'select',
        isClear: true,
        optionList: [],
        optionId: 'staffId',
        optionLabel: 'staffName',
      }, {
        label: '成交结果',
        name: 'orderFinishFlag',
        type: 'select',
        isClear: true,
        optionList: [
          {
            confId: null,
            confValue: '全部'
          },
          {
            confId: '1',
            confValue: '是'
          },
          {
            confId: '0',
            confValue: '否'
          }
        ],
        optionId: 'confId',
        optionLabel: 'confValue',
      }],
      getListApi: getReceptionDetailPage,
      // 表格参数
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        // tableOption: true,
        tableOption: { width: '150px' },
        tableColumns: [
          {
            label: '驻店人员',
            prop: 'employeeName',
            width: '150'
          }, {
            label: '接待日期',
            prop: 'receptionDate',
            width: '100'
          }, {
            label: '客户姓名',
            prop: 'customerName',
          }, {
            label: '车型',
            prop: 'carModel',
          }, {
            label: 'APP接待结果',
            width: '130',
            formatter (row) {
              let result = {
                1: "成交",
                0: "战败"
              }[row.receptionStatus]
              return result || "-"
            }
          }, {
            label: '关联订单成交',
            prop: 'orderFinishFlag',
            width: '130',
            formatter (row) {
              return row.orderFinishFlag ? '成交' : '战败'
            }
          }, {
            label: '质检评分',
            prop: "score",
            formatter (row) {
              return row.score != null ? row.score : '-'
            }
          }, {
            label: '攻防评分',
            prop: "defencePoint",
            formatter (row) {
              return row.defencePoint != null ? row.defencePoint : '-'
            }
          }, {
            label: '客户类型识别',
            prop: "customerTypeName",
            width: '130',
          }, {
            label: '开始接待时间',
            width: '150',
            prop: "startTime"
          }, {
            label: '结束接待时间',
            width: '150',
            prop: "endTime"
          }, {
            label: '接待时长',
            width: '130',
            prop: "seconds",
          }, {
            label: '安心包是否开口',
            prop: "axbOpenFlag",
            width: 130,
            formatter (row) {
              return row.axbOpenFlag ? "是" : "否"
            }
          },
          {
            label: '安心包是否成交',
            prop: "isFinishFlag",
            width: 130,
            formatter (row) {
              return row.finishFlag ? "是" : "否"
            }
          }
        ]
      },
    }
  },

  computed: {
  },
  mounted () {
  },

  methods: {
    timerSearch () {
      this.searchForm.staffUUid = ''
      this.getReceptionStaffList()
      const detailListTable = this.$refs?.detailListTable
      if (detailListTable) {
        detailListTable.page.currentPage = 1
        detailListTable.refreshTable && detailListTable.refreshTable()
        this.searchTimeStatus = false
      }

    },
    async getReceptionStaffList () {
      await this.beforeSearchFn()
      let params = JSON.parse(JSON.stringify(this.searchForm))
      delete params.staffUUid
      delete params.orderFinishFlag
      const res = await getReceptionStaffList({
        currentPage: 1,
        pageSize: 99999,
        ...params
      })
      this.showFormData[0].optionList = res
    },
    beforeSearchFn () {
      return new Promise(resolve => {
        let { startDate, endDate } = this.searchTime,
          { businessType, merchantId } = this.pageData
        this.searchForm.startTime = startDate
        this.searchForm.endTime = endDate
        //业务场景 1.延保 2.轻改 3.权益
        this.searchForm.bussinessType = {
          2: 2,
          3: 3,
          4: 1
        }[businessType]//传过来的businessType 归属业务(2-轻改,3-权益,4-延保)
        this.searchForm.merchantNo = merchantId
        resolve()
      })
    },
    handleReset () {
      this.searchForm = this.$options.data.call(this).searchForm
      this.$refs.detailListTable.refreshTable()
    },

    async handleExport () {
      await this.beforeSearchFn()
      let params = this.searchForm
      console.log(params)
      getReceptionDetailReport(params).then((res) => {
        res && downLoadFile(res)
      })
    },

    handleDetail (row) {
      const list = this.$refs.detailListTable.data,
        currentNum = list.findIndex((e) => e.id == row.id)
      this.$emit('openReceptionDialog', {
        qualityDetailList: list,
        isQualityVisible: true,
        currentNum
      })
    },
    closeDialog () {
      // this.$refs.qualityDetail.onPageHide()
      this.isQualityVisible = false
      // this.onPageShow()
    },

  }
}

</script>
<style lang="scss" scoped>
.m-t-40 {
  margin-top: 40px;
}
@mixin priorityBase {
  // margin-left: auto;
  width: 32px;
  border-radius: 239px;
  font-size: 14px;
  text-align: center;
  margin-right: 8px;
  display: inline-block;
}
.priority-one {
  @include priorityBase();
  border: 1px solid #eb4e4e;
  color: #eb4e4e;
}
.priority-two {
  @include priorityBase();
  border: 1px solid #ff8d1a;
  color: #ff8d1a;
}
.priority-three {
  @include priorityBase();
  border: 1px solid #ffc300;
  color: #ffc300;
}

@mixin stageBase {
  width: 80px;
  border-radius: 239px;
  font-size: 14px;
  text-align: center;
  display: inline-block;
}
.stage-one {
  @include stageBase();
  border: 1px solid #ff8d1a;
  background: #ff8d1a1a;
  color: #ff8d1a;
}
.stage-two {
  @include stageBase();
  border: 1px solid #eb4e4e;
  background: #eb4e4e1a;
  color: #eb4e4e;
}

@mixin typeBase {
  width: 52px;
  border-radius: 239px;
  opacity: 1;
  font-size: 14px;
  text-align: center;
  line-height: 24px;
  display: inline-block;
}

.type-yellow {
  @include typeBase();
  background: #ff8d1a1a;
  color: #ff8d1a;
}
.type-blue {
  @include typeBase();
  background: #5850ff1a;
  color: #5850ff;
}
.type-green {
  @include typeBase();
  background: #43cf7c1a;
  color: #43cf7c;
}
.d2-container-content {
  padding-bottom: 16px;
  &::before {
    height: 16px;
    background: #eff3f6;
    content: "";
    display: block;
    width: calc(100% + 40px);
    margin-left: -20px;
  }
}
.dialog {
  width: 100vw;
  height: 100vh;
}
</style>