cardDetail.vue 10.1 KB
<template>
  <div>
    <!-- 领卡用户明细 -->
    <GLDialog mode="big" :hasFooter="false" :close-on-click-modal="false" bigTitle="领卡用户明细" :visible.sync="isVisible" @close="handleReset()">
      <div class="contain equity-wrap" style="margin: 20px 0px 20px 0px !important">
        <glsx-combi-form ref="showSearch" labelWidth="120px" defaultWidth="215px" :formObj="batchListSearch" :formData="userDetailForm">
          <span slot="footer" class="footer-btns"></span>
        </glsx-combi-form>
        <div style="padding: 0 20px 20px">
          <div style="float: right; margin-right: 0; margin-bottom: 10px">
            <el-button plain size="small" @click="handleReset('reset')">重置</el-button>
            <el-button size="small" @click="handleSearch">查询</el-button>
            <el-button size="small" @click="handleExport" class="selectBtn">导出</el-button>
          </div>
          <GLTable ref="userDetailTable" :hasNum="false" @hook:mounted="setTabelHeight" :searchForm="searchForm" :tableParams="batchTableParams" :getListApi="getListApi" :pageConf="batchPageConf" :noDataImg="url" :beforeSearchFn="beforeSearchFn">
            <div class="flex_sc" slot="status" slot-scope="scope">
              <div class="table_point" :style="{ background: colors[scope.scope.status] }"></div>
              <span :style="{color:scope.scope.status==1 ? '#2CCA74': '#CCC'}">{{ setStatusVal(scope.scope.status) }}</span>
            </div>
            <!-- <div slot="status" slot-scope="scope">
                <p :style="{color:scope.scope.status==1 ? '#2CCA74': '#CCC'}">{{ setStatusVal(scope.scope.status) }}</p>
              </div> -->
          </GLTable>
        </div>
      </div>
    </GLDialog>
  </div>
</template>

<script type='text/ecmascript-6'>
import url from '@/assets/empty.png'
const activeTypeList = [
  {
    confId: '',
    confName: '全部'
  },
  {
    confId: 0,
    confName: '试用领取'
  },
  {
    confId: 1,
    confName: '设备号激活'
  },
  {
    confId: 2,
    confName: '权益卡号激活'
  },
  {
    confId: 3,
    confName: '零一裂变'
  },
  {
    confId: 4,
    confName: '裂变赠送'
  },
  {
    confId: 5,
    confName: '绑定挪车贴'
  },
  {
    confId: 6,
    confName: '付费开通'
  },
  {
    confId: 8,
    confName: '通过门店ID激活'
  },
  {
    confId: 9,
    confName: '嘀加其他权益提单'
  },
  {
    confId: 10,
    confName: '自研裂变'
  },
  {
    confId: 11,
    confName: '通过门店套餐赠送'
  },
  {
    confId: 12,
    confName: '无忧服务'
  }
]
export default {
  name: 'detailDialog',
  data() {
    return {
      url,
      cardClassId: '',
      tableData: [],
      isVisible: false,
      getListApi: this.$apis.equityApi.getcardRecordList,
      // editRuleUser:{
      //   mobile:[
      //      {
      //       validator: (rule, value, callback) => {
      //         let phoneReg = /^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/;
      //         return phoneReg.test(value) ? callback() : callback(new Error('请输入正确的手机号'))
      //       }, trigger: 'change'
      //     }
      //   ]
      // },
      batchListSearch: {
        mobile: '', //手机号
        merchantName: '', //开通门店
        activeType: '', //开通方式
        status: '', // 状态
        activeTime: [], // 开通日期
        memberType: ''
      },
      searchForm: {},
      baseData: {
        activeTypeList: [
          {
            confId: 1,
            confName: '输入设备号激活'
          },
          {
            confId: 2,
            confName: '输入权益卡号激活'
          },
          {
            confId: 3,
            confName: '零一裂变激活'
          },
          {
            confId: 4,
            confName: '会员赠送激活'
          },
          {
            confId: 5,
            confName: '挪车贴绑定激活'
          },
          {
            confId: 6,
            confName: '购买权益卡激活'
          },
          {
            confId: 9,
            confName: '嘀加购买权益订单赠送'
          },
          {
            confId: 10,
            confName: '通过裂变激活'
          },
          {
            confId: 11,
            confName: '门店套餐赠送'
          },
          {
            confId: 12,
            confName: '购买数字化权益赠送'
          }
        ]
      },

      userDetailForm: [
        {
          label: '用户信息',
          name: 'mobile',
          type: 'input',
          maxlength: 11,
          placeholder: '请输入手机号'
        },
        {
          label: '门店',
          name: 'merchantName',
          type: 'input',
          maxlength: 15,
          placeholder: '请输入门店名称'
        },
        {
          label: '会员类型',
          name: 'memberType',
          type: 'select',
          optionList: [
            {
              memberId: '',
              memberName: '全部'
            },
            {
              memberId: 1,
              memberName: '正式会员'
            },
            {
              memberId: 2,
              memberName: '试用会员'
            }
          ],
          optionId: 'memberId',
          optionLabel: 'memberName',
          optionsName: 'memberType'
        },
        {
          label: '开通方式',
          name: 'activeType',
          type: 'select',
          optionList: activeTypeList,
          optionId: 'confId',
          optionLabel: 'confName',
          optionsName: 'activeType'
        },
        {
          label: '状态',
          name: 'status',
          type: 'select',
          optionList: [
            {
              statusId: '',
              statusName: '全部'
            },
            {
              statusId: 1,
              statusName: '生效中'
            },
            {
              statusId: 2,
              statusName: '已失效'
            }
          ],
          optionId: 'statusId',
          optionLabel: 'statusName',
          optionsName: 'status'
        },
        {
          label: '开通日期',
          name: 'activeTime',
          type: 'datePicker',
          valueFormat: 'yyyy-MM-dd',
          pickerOptions: 'beforeRangePickerOptions'
        }
      ],
      batchTableParams: {
        listName: 'list',
        tableOption: false,
        tableColumns: [
          {
            label: '手机号码',
            prop: 'mobile'
            // minWidth: '200'
          },
          {
            label: '会员类型',
            prop: 'memberType',
            formatter: cellValue => {
              return cellValue.memberType == 1 ? '正式会员' : '试用会员'
            }
          },
          {
            label: '开通门店',
            prop: 'merchantName',
            width: 200
          },
          {
            label: '开通方式',
            prop: 'activeTypeDescList',
            width: '200',
            line: 1,
            formatter: cellValue => {
              // return cellValue.activeTypeDescList || "-"
              if (cellValue.activeTypeDescList && Array.isArray(cellValue.activeTypeDescList) && cellValue.activeTypeDescList.length > 0) {
                return cellValue.activeTypeDescList.join('+')
              } else {
                return '-'
              }
            }
          },
          {
            label: '状态',
            prop: 'status',
            addHtml: 'status'
          },
          {
            label: '开通日期',
            prop: 'activeTime',
            width: 200,
            formatter: cellValue => {
              if (cellValue.activeTime) {
                const dateArr = cellValue.activeTime.split(' ')
                return cellValue.activeTime.split(' ')[0]
              } else {
                return '-'
              }
            }
          }
        ]
      },
      batchPageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      colors: ['', '#2CCA74', '#999999']
    }
  },
  mounted() {},
  methods: {
    show(row) {
      this.isVisible = !this.isVisible
      this.cardClassId = row.id
      this.$nextTick(() => {
        this.$refs.userDetailTable.refreshTable()
      })
    },
    setStatusVal(status) {
      return { 1: '生效中', 2: '已失效' }[status]
    },
    setTabelHeight() {
      this.$refs.userDetailTable.tableHeightValues = '328'
    },
    beforeSearchFn() {
      return new Promise((resolve, reject) => {
        this.searchForm = { ...this.setParams() }
        console.log(this.searchForm, this.batchListSearch, '参数')
        resolve()
      })
    },
    setParams() {
      let params = JSON.parse(JSON.stringify(this.batchListSearch))
      if (Array.isArray(params.activeTime) && params.activeTime.length > 0) {
        params.startTime = params.activeTime[0] + ' 00:00:00'
        params.endTime = params.activeTime[1] + ' 23:59:59'
      }
      params.cardClassId = this.cardClassId
      params.ossUseer = true
      params.userInfo = params.mobile
      delete params.activeTime
      delete params.mobile
      console.log(params)
      return params
    },
    handleExport() {
      const parmas = { ...this.setParams() }
      this.$apis.equityApi.exportcardRecordList(parmas).then(({ code, data, message }) => {
        if (code == 0) {
          var a = document.createElement('a')
          a.setAttribute('id', 'exportToExport')
          a.setAttribute('href', data)
          a.setAttribute('target', '_blank')
          document.body.appendChild(a)
          a.click()
        } else {
          this.$message.error(message)
        }
      })
    },
    handleSearch() {
      this.$refs.userDetailTable.refreshTable()
    },
    handleReset(type) {
      this.batchListSearch = {
        mobile: '',
        merchantName: '',
        activeType: '',
        status: '',
        activeTime: [],
        memberType: ''
      }
      if (type === 'reset') {
        this.handleSearch()
      }
    }
  }
}
</script>
<style lang="scss" scoped>
/deep/ .user-detail-dialog {
  .el-form-item {
    margin-right: 0;
  }
  .el-input--small .el-input__inner {
    width: 215px;
  }
  .el-table__row {
    .el-table__cell {
      padding: 9px 0;
    }
  }
}
</style>