detailDialog.vue 4.81 KB
<template>
  <div v-if="detailObj.show">
    <GLDialog
      mode="big"
      bigTitle="查看"
      :visible.sync="detailObj.show"
      :hasFooter="false"
      :before-close="handleClose"
    >
      <GLTable
        v-loading="loading"
        ref="serviceRef"
        :getListApi="getListApi"
        :searchForm="searchForm"
        :tableParams="tableParams"
        :pageConf="pageConf"
        :beforeSearchFn="beforeSearchFn"
      >
        <template
          slot="oilList"
          slot-scope="scope"
        >
          <template v-if="scope.scope.oilList && scope.scope.oilList.length">

            <div class="flex">
              <span>{{ filterData(scope.scope.oilList,'oilList').slice(0, 1).join('、') }}</span>
              <el-popover
                placement="top"
                width="fit-content"
                trigger="hover"
              >
                <div
                  v-for="(item,index) in filterData(scope.scope.oilList,'oilList')"
                  :key="index"
                >
                  {{item}}
                </div>
                <span
                  class="more-info"
                  slot="reference"
                >...({{ scope.scope.oilList.length }})</span>
              </el-popover>
            </div>
          </template>
          <template v-else>
            无
          </template>
        </template>
        <template
          slot="couponList"
          slot-scope="scope"
        >
          <template v-if="scope.scope.couponList && scope.scope.couponList.length">
            <div class="flex">
              <span>{{ filterData(scope.scope.couponList,'couponList').slice(0, 1).join('、') }}</span>
              <el-popover
                placement="top"
                width="fit-content"
                trigger="hover"
              >
                <div
                  v-for="(item,index) in filterData(scope.scope.couponList,'couponList')"
                  :key="index"
                >
                  {{item}}
                </div>
                <span
                  class="more-info"
                  slot="reference"
                >...({{ scope.scope.couponList.length }})</span>
              </el-popover>
            </div>
          </template>
          <template v-else>
            无
          </template>
        </template>
      </GLTable>
    </GLDialog>
  </div>
</template>

<script type='text/ecmascript-6'>
import NP from 'number-precision'
export default {
  name: '',

  props: {
    detailObj: {
      type: Object,
      default: () => { }
    }
  },
  data () {
    return {
      NP,
      loading: false,
      pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
      getListApi: this.$apis.points.getCustomerIntegralList,
      searchForm: {},
      tableParams: {
        listName: 'list',
        tableColumns: [
          {
            label: '保单号',
            prop: 'policyNo',
            minWidth: 200
          },
          {
            label: '用户姓名',
            prop: 'customerName',
            minWidth: 100
          },
          {
            label: '身份证号',
            minWidth: 200,
            prop: 'idCardNo',
          },
          {
            label: '用户手机号',
            minWidth: 150,
            prop: 'customerPhone',
          },
          {
            label: '返现金额',
            minWidth: 150,
            prop: 'cashBackValue'
          },
          {
            label: '商品兑换积分',
            prop: 'buyValue',
            minWidth: 150,
          },
          {
            label: '赠送油券',
            addHtml: 'oilList',
            minWidth: 260,
          },
          {
            label: '赠送自店服务',
            addHtml: 'couponList',
            minWidth: 260,
          },
          {
            label: '充值积分小计',
            minWidth: 150,
            formatter: cell => {
              const { oilList, cashBackValue, buyValue } = cell
              let total = NP.plus((cashBackValue || 0), (buyValue || 0))
              oilList && oilList.map(i => total += NP.times(i.amount, i.salesPrice, 0.01))
              return total
            }
          },
        ]
      },
    }
  },
  mounted () {
  },
  methods: {
    beforeSearchFn () {
      return new Promise(resolve => {
        this.searchForm.recordId = this.detailObj.recordId
        this.loading = false
        resolve()
      })
    },
    handleClose () {
      this.$emit('update:detailObj', {})
    },
    filterData (list, name) {
      return list?.map(i => {
        return name == 'oilList' ? `${i.aliasName}*${i.amount} (${NP.times(i.amount, i.salesPrice, 0.01)}积分)` : `${i.couponName}*${i.amount}`
      }) || []
    },
  }
}
</script>

<style scoped lang='scss'>
.more-info {
  white-space: nowrap;
  color: #5850ff;
  cursor: pointer;
}
</style>