index.vue 8.4 KB
<!-- 权益卡管理 -->
<template>
  <div>
    <d2-container>
      <div class="header"
           slot="header"
           style="padding: 10px 20px;">
        <d2-search ref="showSearch"
                   class="show-search"
                   label-width="110px"
                   :search-form="searchForm"
                   :form-data="showFormData" />
        <div class="up-btns">
          <el-button @click="handleSearch"
                     size="small"
                     type="primary">
            查询
          </el-button>
          <el-button size="small"
                     @click="handleReset">
            重置
          </el-button>
        </div>
      </div>
      <div class="d2-container-content">
        <d2-table-header :left-span="20">
          <span slot="left">
            总数量:<span class="count-txt">{{ statisticsData.count }}</span>,
            待激活数量:<span class="count-txt">{{
              statisticsData.waitActivationCount }}</span>,已激活数量:<span class="count-txt">{{
              statisticsData.activatedCount }}</span></span>
          <auth-button category="Button" />
        </d2-table-header>
        <d2-table ref="recordTable"
                  :get-list-api="getListApi"
                  :search-form="searchFormSearch"
                  :table-params="tableParams"
                  :before-search-fn="beforeSearchFn">
          <auth-button slot="auth-button"
                       slot-scope="scope"
                       :data="scope.scope" />
        </d2-table>
      </div>
    </d2-container>
  </div>
</template>

<script>
import { Util, deepClone } from '@/common/util'
import { mapActions, mapState } from 'vuex'
import { vdCardPage, vdCardCount } from '@api/stockManage'
export default {
  name: 'BenefitCardManageList',
  components: {
  },
  data() {
    return {
      userInfo: this.$store.state.d2admin.user.info,
      statisticsData: {},
      searchForm: {
        vdCardCodeLike: '',
        businessCodeLike: '',
        deliveryNumberLike: '',
        merchantName: '',
        activationBusinessCodeLike: '',
        cardStatus: '',
        activationMerchantName: '',
        activationCustomerName: '',
        activationCustomerPhoneLike: ''
      },
      searchFormSearch: {},
      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: vdCardPage,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: false,
        tableColumns: [{
          label: '卡号',
          prop: 'vdCardCode',
          width: 150
        },
        {
          label: '入库时间',
          prop: 'warehouseTime',
          formatter: cellValue => {
            return cellValue.warehouseTime ? Util.dateFormate(cellValue.warehouseTime, 'YYYY-MM-DD HH:mm:ss') : ''
          },
          width: 180
        },
        {
          label: '关联业务单号',
          prop: 'businessCode',
          width: 150
        },
        {
          label: '关联发货单号',
          prop: 'deliveryNumber',
          width: 150
        },
        {
          label: '所属商户',
          prop: 'merchantName',
          width: 150
        },
        {
          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 ? Util.dateFormate(cellValue.activationTime, 'YYYY-MM-DD HH:mm:ss') : ''
          },
          width: 180
        },

        {
          label: '激活门店',
          prop: 'activationMerchantName',
          width: 120
        },
        {
          label: '激活客户',
          prop: 'activationCustomerName',
          width: 120
        },
        {
          label: '客户手机号',
          prop: 'activationCustomerPhone',
          width: 200,
          formatter: cellValue => {
            return cellValue.activationCustomerPhone || '-'
          }
        }
        ]
      },
      baseData: {
        cardStatusList: [
          {
            confId: '1',
            confLabel: '待激活'
          },
          {
            confId: '2',
            confLabel: '已激活'
          }
        ]
      },
      stockDetailDialogVisible: false,
      stockMonthVisible: false,
      recordInfo: null
    }
  },
  computed: {
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList
    })
  },
  mounted() {
    this.getBaseData()
    this.vdCardCount()
  },

  methods: {
    ...mapActions({
      get: 'd2admin/base/get',
      close: 'd2admin/page/close'
    }),
    ...mapActions('d2admin/user', ['actionSetDownloadList']),

    async getBaseData() {
      this.getOptionsList()
    },

    // 统计
    vdCardCount() {
      const _params = this.searchFormSearch
      vdCardCount(_params).then(res => {
        this.statisticsData = res || []
      })
    },

    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchFormSearch = deepClone(this.searchForm)
        resolve()
      })
    },

    getOptionsList() {
      this.showFormData.forEach((item, index) => {
        if (item.type === 'select') {
          if (this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this.showFormData[index].optionLabel] !== '全部') {
            const temp = {}
            temp[this.showFormData[index].optionId] = ''
            temp[this.showFormData[index].optionLabel] = '全部'
            this.baseData[item.optionsName].unshift(temp)
          }
          this.$set(this.showFormData[index], 'optionList', this.baseData[item.optionsName])
        }
      })
    },

    handleSearch() {
      this.$refs.recordTable.refreshTable(true, true)
      this.vdCardCount()
    },
    handleReset() {
      this.searchForm = {
        vdCardCodeLike: '',
        businessCodeLike: '',
        deliveryNumberLike: '',
        merchantName: '',
        activationBusinessCodeLike: '',
        cardStatus: '',
        activationMerchantName: '',
        activationCustomerName: '',
        activationCustomerPhoneLike: ''
      }
      this.$refs.recordTable.refreshTable()
    },

    handleExport() {
      var params = this.searchFormSearch
      params.method = 'dj.api.smartcarlife.stock.vdCard.export.async'
      const list = [
        ...this.dowloadList,
        {
          name: '权益卡管理列表',
          exportParam: JSON.stringify(params),
          status: 'waiting',
          timeid: new Date().getTime()
        }
      ]
      this.actionSetDownloadList({ list, type: 'dowloadList' })
    }

  }
}

</script>
<style scoped>
.count-txt {
  font-weight: 700;
  color: #2a58ad;
  margin: 0 2px;
}

.leftSpan {
  display: inline-block;
  box-sizing: border-box;
  margin-right: 10px;
}
</style>