index.vue 8.21 KB
<template>
  <div class="equity">
    <div class="container">
      <GLCombiForm ref="showSearch" :rowNumber="1" :formObj="searchForm" :formData="showFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
      <div class="table-header">
        <div>
          总数量:
          <span class="txt-blue">{{ stockData.count }}</span>
          ,待激活数量:
          <span class="txt-blue">{{ stockData.waitActivationCount }}</span>
          ,已激活数量:
          <span class="txt-blue">{{ stockData.activatedCount }}</span>
        </div>
        <el-button size="small" @click="exportExcel">导出</el-button>
      </div>

      <!-- 表格区域 开始 -->
      <GLTable ref="equityRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm" :tableParams="tableParams" :pageConf="pageConf" @setTableFinishFun="setTableFinishFun"></GLTable>
      <!-- 表格区域 end -->
    </div>
  </div>
</template>

<script>
import * as dayjs from 'dayjs'
import url from '@/assets/empty.png'
export default {
  name: 'equity',
  data() {
    return {
      stockData: {},
      size: 'small',
      url: url,
      searchForm: {
        vdCardCodeLike: '',
        businessCodeLike: '',
        deliveryNumberLike: '',
        merchantName: '',
        activationBusinessCodeLike: '',
        cardStatus: '',
        activationMerchantName: '',
        activationCustomerName: '',
        activationCustomerPhoneLike: ''
      },
      showFormData: [
        {
          label: '卡号',
          name: 'vdCardCodeLike',
          type: 'input',
          maxlength: '20',
          isClear: true
        },
        {
          label: '关联业务单号',
          name: 'businessCodeLike',
          type: 'input',
          maxlength: '20',
          isClear: true
        },
        {
          label: '关联发货单号',
          name: 'deliveryNumberLike',
          type: 'input',
          maxlength: '20',
          isClear: true
        },
        {
          label: '所属商户',
          name: 'merchantName',
          type: 'input',
          maxlength: '20',
          isClear: true
        },
        {
          label: '激活业务单号',
          name: 'activationBusinessCodeLike',
          type: 'input',
          maxlength: '20',
          isClear: true
        },
        {
          label: '状态',
          name: 'cardStatus',
          type: 'select',
          optionList: [],
          optionId: 'confId',
          optionLabel: 'confLabel',
          optionsName: 'cardStatusList'
        },
        {
          label: '激活门店',
          name: 'activationMerchantName',
          type: 'input',
          maxlength: '20',
          isClear: true
        },
        {
          label: '激活客户',
          name: 'activationCustomerName',
          type: 'input',
          isClear: true
        },

        {
          label: '客户手机号',
          name: 'activationCustomerPhoneLike',
          type: 'input',
          isClear: true
        }
      ],
      // 表格
      getListApi: this.$apis.equity.getListApi,
      tableParams: {
        listName: 'list',
        tableOption: false,
        tableColumns: [
          {
            label: '卡号',
            prop: 'vdCardCode',
            width: 180
          },
          {
            label: '入库时间',
            prop: 'warehouseTime',
            formatter: cellValue => {
              return dayjs(cellValue.warehouseTime).format('YYYY-MM-DD HH:mm:ss')
            },
            width: 180
          },
          {
            label: '关联业务单号',
            prop: 'businessCode',
            width: 150,
            line: 1
          },
          {
            label: '关联发货单号',
            prop: 'deliveryNumber',
            width: 150,
            line: 1
          },
          {
            label: '所属商户',
            prop: 'merchantName',
            width: 150,
            line: 1
          },
          {
            label: '状态',
            prop: 'cardStatus',
            width: 100,
            formatter: cellValue => {
              return this.baseData.cardStatusList.find(item => item.confId === cellValue.cardStatus?.toString())?.confLabel
            }
          },
          {
            label: '激活业务单号',
            prop: 'activationBusinessCode',
            width: 150
          },
          {
            label: '激活时间',
            prop: 'activationTime',
            formatter: cellValue => {
              return cellValue.activationTime ? dayjs(cellValue.activationTime).format('YYYY-MM-DD HH:mm:ss') : '--'
            },
            width: 180
          },

          {
            label: '激活门店',
            prop: 'activationMerchantName',
            width: 120,
            line: 1
          },
          {
            label: '激活客户',
            prop: 'activationCustomerName',
            line: 1
          },
          {
            label: '客户手机号',
            prop: 'activationCustomerPhone',
            formatter: cellValue => {
              return cellValue.activationCustomerPhone || '-'
            },
            width: 120
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
      // 基本数据
      baseData: {
        cardStatusList: [
          {
            confId: '1',
            confLabel: '待激活'
          },
          {
            confId: '2',
            confLabel: '已激活'
          }
        ]
      }
    }
  },

  created() {
    this.getStockVdCard()
    this.getOptionsList('showFormData')
  },

  methods: {
    getStockVdCard() {
      var params = this.searchForm
      this.$apis.equity.getStockVdCard(params).then(res => {
        this.stockData = res
      })
    },
    getOptionsList(formName, hasAll = true, refreshSigle) {
      if (refreshSigle) {
        var item = this[formName].find(k => k.name == refreshSigle)
        var index = this[formName].findIndex(k => k.name == refreshSigle)
        this.$set(this[formName][index], 'optionList', this.$common.utils.deepClone(this.baseData[item.optionsName]))
        if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
          const temp = {}
          temp[this[formName][index].optionId] = ''
          temp[this[formName][index].optionLabel] = '全部'
          this[formName][index].optionList.unshift(temp)
        }
      } else {
        this[formName].forEach((item, index) => {
          if (item.type === 'select' && this.baseData[item.optionsName].length) {
            this.$set(this[formName][index], 'optionList', this.$common.utils.deepClone(this.baseData[item.optionsName]))
            if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
              const temp = {}
              temp[this[formName][index].optionId] = ''
              temp[this[formName][index].optionLabel] = '全部'
              this[formName][index].optionList.unshift(temp)
            }
          }
        })
      }
    },
    setTableFinishFun() {
      //接收到的数据为空
      this.$refs.equityRef.data.length ? (this.$refs.equityRef.tableHeightValues = '') : this.$refs.equityRef.setTableHeightFun()
    },
    exportExcel() {
      var params = this.searchForm
      this.$apis.equity.exportExcel(params).then(res => {
        window.location.href = res.replace(/https?:/, '')
      })
    },
    handleSearch() {
      this.$refs.equityRef.refreshTable()
      this.getStockVdCard()
    },

    handleReset() {
      this.searchForm = {
        vdCardCode: '',
        businessCode: '',
        deliveryNumber: '',
        merchantName: '',
        activationBusinessCode: '',
        cardStatus: '',
        activationMerchantName: '',
        activationCustomerName: '',
        activationCustomerPhone: ''
      }
      this.handleSearch()
    }
  }
}
</script>

<style scoped lang="scss">
@import '@/assets/css/mixin.scss';

.equity {
  background: #fff;
  padding: 20px;
  .table-header {
    @include space-between_center;
    margin-bottom: 10px;

    h2 {
      font-weight: 600;
      font-size: 16px;
      color: #333;
    }
  }
}
</style>