couponsOrder.vue 10.9 KB
<template>
  <div class="order-container">
    <div class="pannel">
      <GLCombiForm ref="showSearch" :searchSelectObj="searchSelectObj" :formObj="searchForm" :formData="searchFormData" @handleOk="toHandlerFindParam" @handleRest="handleRestFn"></GLCombiForm>
    </div>

    <div class="pannel tableTopButton">
      <el-button size="small" type="primary" plain @click="toshowDialog">查看礼券</el-button>
      <GLButton size="small" fn="导出礼券" @click="toExport">导出</GLButton>
    </div>

    <div class="table_wrap">
      <GLTable ref="table" :tableData="tableData" :tableTotal="tableTotal" :tableParams="tableParams" @refreshTable="toGetCouponsList"></GLTable>
    </div>
    <GLDialog :visible.sync="dialogTableVisible" bigTitle="111" mode="big" :hasFooter="false">
      <div slot="custombigtitle" class="customTitle">
        <div class="title1">共计{{ tabletotal1 }}条数据</div>
        <span class="h9_title">门店新车精品礼券由</span>
        <span class="title2">专属顾问</span>
        <span class="h9_title">进行配置,如需新增详情请联系管理员。</span>
      </div>
      <GLTable ref="table1" :tableTotal="tabletotal1" :hasNum="false" :tableData="tableData1" :tableParams="tableParams1" @refreshTable="toOpenCoupons"></GLTable>
    </GLDialog>
  </div>
</template>

<script>
import { findCoupons, checkCoupons, exportCoupons, getEmployName } from '../../api/modules/rules'
import { converterApi } from '../../api/modules/converter'
import utils from '../../util/util'
export default {
  name: '',
  data() {
    return {
      tableParams: {
        tableOption: false,
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        tableColumns: [
          {
            label: '领用时间',
            prop: 'createdDate',
            width: '180'
          },
          {
            label: '客户姓名',
            prop: 'customerName',
            width: '280'
          },
          {
            label: '手机号',
            prop: 'customerPhone',
            width: '150'
          },
          {
            label: '礼券名称',
            prop: 'couponName',
            width: '280px'
          },
          {
            label: '发券人',
            prop: 'employeeName',
            width: '120px'
          },
          {
            label: '核销状态',
            prop: 'status'
          },
          {
            label: '转化人',
            prop: 'sellerName',
            width: '280'
          },
          {
            label: '核销时间',
            prop: 'usedTime',
            width: '180'
          }
        ]
      },
      tableParams1: {
        tableOption: false,
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        tableColumns: [
          {
            label: '礼券批次号',
            prop: 'merchantCouponCode'
          },
          {
            label: '礼券名称',
            prop: 'couponName'
          },
          {
            label: '适用产品',
            prop: 'couponTypeName'
          },
          {
            label: '总数',
            prop: 'amount',
            width: '120px'
          },
          {
            label: '余量',
            prop: 'remainAmount',
            width: '120px'
          },
          {
            label: '发放',
            prop: 'getAmount',
            width: '100px'
          },
          {
            label: '核销',
            prop: 'usedAmount',
            width: '100px'
          },
          {
            label: '配置时间',
            prop: 'createdDate'
          }
        ]
      },
      tableData: [],
      tableData1: [],
      tableTotal: 0,
      tabletotal1: 0,
      employeeNameData: [],
      dialogTableVisible: false,
      /**新加搜索栏参数 */
      searchSelectObj: {
        columType: {
          attr: 1,
          value: ''
        }
      },
      searchForm: {
        customName: '',
        hxstatus: '',
        dateBetween: '',
        phoneNum: '',
        hxdateBetween: '',
        employeeName: ''
      },
      searchFormData: [
        {
          label: '客户姓名',
          name: 'customName',
          type: 'input',
          isClear: true
        },
        {
          label: '核销状态',
          name: 'hxstatus',
          type: 'select',
          optionId: 'confId',
          optionLabel: 'confName',
          isClear: true,
          noFilter: true,
          optionList: [
            {
              confId: 'Y',
              confName: '已核销'
            },
            {
              confId: 'N',
              confName: '待核销'
            }
          ]
        },
        {
          label: '领用时间',
          name: 'dateBetween',
          type: 'datePicker',
          isClear: true
        },
        {
          type: 'doubleSelect',
          selectName: 'columType',
          isClear: true,
          selectOption: [
            {
              label: '发券人',
              name: 1
            },
            {
              label: '转化人',
              name: 2
            }
          ],
          name: 'employeeName',
          optionId: 'confId',
          optionLabel: 'confName',
          optionList: [],
          handleSelectChange: value => {
            this.getEmployNameList(value)
          }
        },
        {
          label: '手机号',
          name: 'phoneNum',
          type: 'input',
          isClear: true,
          maxlength: '11'
        },
        {
          label: '核销时间',
          name: 'hxdateBetween',
          type: 'datePicker',
          isClear: true
        }
      ]
    }
  },
  created() {},
  mounted() {
    this.toGetCouponsList()
    this.toOpenCoupons()
    this.getEmployNameList(1)
    let that = this
    window.addEventListener('resize', () => {
      let width = document.body.clientWidth
      that.screenWidth = width
    })
  },
  methods: {
    handleRestFn() {
      this.searchForm = {
        customName: '',
        hxstatus: '',
        dateBetween: '',
        phoneNum: '',
        hxdateBetween: '',
        employeeName: ''
      }
      this.newCurrentHttpParma = {}
      this.toGetCouponsList()
    },
    // 处理查询条件
    toHandlerFindParam() {
      let params = {}
      if (this.searchForm.customName) {
        //客户姓名
        params.customerName = this.searchForm.customName
      }
      if (this.searchForm.hxstatus) {
        //核销状态
        params['usedFlagList[0]'] = this.searchForm.hxstatus
      }
      if (this.searchForm.dateBetween) {
        //领用时间
        let startDate = utils.dateFormat(this.searchForm.dateBetween[0], 'YYYY-MM-DD 00:00:00')
        let endDate = utils.dateFormat(this.searchForm.dateBetween[1], 'YYYY-MM-DD 23:59:59')
        params.startDate = startDate
        params.endDate = endDate
      }
      //发券人
      if (this.searchForm.employeeName != '' && this.columType) {
        params.columType = this.columType
        let name = this.columType == 1 ? 'employeeNameList[0]' : 'sellerNameList[0]'
        params[name] = this.employeeNameData[this.searchForm.employeeName]
      }
      if (this.searchForm.hxdateBetween) {
        // 核销时间
        let startDate = utils.dateFormat(this.searchForm.hxdateBetween[0], 'YYYY-MM-DD 00:00:00')
        let endDate = utils.dateFormat(this.searchForm.hxdateBetween[1], 'YYYY-MM-DD 23:59:59')
        params.startUsedTime = startDate
        params.endUsedTime = endDate
      }
      if (this.searchForm.phoneNum) {
        // 手机号
        params.customerPhone = this.searchForm.phoneNum
      }
      this.newCurrentHttpParma = params
      this.$refs.table.page.pageNum = 1
      this.toGetCouponsList()
    },
    toshowDialog() {
      this.dialogTableVisible = true
    },
    toGetCouponsList() {
      let method = findCoupons()
      let para = {
        routerMethod: method,
        currentPage: this.$refs.table.page.pageNum,
        pageSize: this.$refs.table.page.pageSize,
        ...this.newCurrentHttpParma
      }
      converterApi(para).then(res => {
        if (!res) {
          return
        }
        res.list.length ? (this.$refs.table.tableHeightValues = '') : this.$refs.table.setTableHeightFun()
        this.tableData = res.list.map(item => {
          item.createdDate = utils.dateFormat(item.createdDate, 'YYYY-MM-DD HH:mm:ss')
          item.usedTime = item.usedTime ? utils.dateFormat(item.usedTime, 'YYYY-MM-DD HH:mm:ss') : '--'
          item.status = item.usedFlag == 'Y' ? '已核销' : '待核销'
          item.sellerName = item.sellerName || '--'
          item.couponName = `${item.couponName}${item.customerCouponCode}`
          return item
        })
        this.tableTotal = res.total
        this.exportHttp = {
          currentPage: this.$refs.table.page.pageNum,
          pageSize: this.$refs.table.page.pageSize,
          ...this.newCurrentHttpParma
        }
      })
    },
    toOpenCoupons() {
      const { session } = this.$globalState
      let merchantId = session.merchantId
      let method = checkCoupons()
      let para = {
        routerMethod: method,
        currentPage: this.dialogTableVisible ? this.$refs.table1.page.pageNum : 1,
        pageSize: this.dialogTableVisible ? this.$refs.table1.page.pageSize : 10,
        merchantId,
        orderType: 6
      }
      converterApi(para).then(res => {
        this.tabletotal1 = res.total
        this.tableData1 = res.list.map(item => {
          item.createdDate = item.createdDate ? utils.dateFormat(item.createdDate, 'YYYY-MM-DD HH:mm:ss') : '--'
          item.couponTypeName = item.couponInfo.couponTypeName
          return item
        })
      })
    },
    toExport() {
      let method = exportCoupons()
      let para = {
        routerMethod: method,
        ...this.exportHttp
      }
      converterApi(para).then(res => {
        let tempaa = utils.getExplorer()
        if (tempaa == 'QQ') {
          window.open(res)
          return
        }
        let iframe = document.createElement('iframe')
        iframe.style.display = 'none'
        iframe.src = res
        document.body.appendChild(iframe)
      })
    },
    // 获取发券人和转化人列表
    getEmployNameList(type) {
      this.columType = type
      let method = getEmployName()
      let para = {
        routerMethod: method,
        columType: type,
        currentPage: 1,
        pageSize: 100
      }
      converterApi(para).then(res => {
        this.employeeNameData = res
        let arr = []
        res.forEach((item, index) => {
          arr.push({
            confId: index,
            confName: item
          })
        })
        this.searchFormData[3].optionList = arr
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.pannel {
  padding: 0 15px;
}
.table_wrap {
  padding: 0 15px;
  padding-bottom: 10px;
}
.customTitle {
  display: flex;
  align-items: center;
  .title1 {
    font-size: 20px;
    font-weight: 500;
    color: #333333;
    margin-right: 11px;
  }
  .title2 {
    font-size: 14px;
    font-weight: 400;
    color: #5850ff;
  }
}
</style>