record.vue 9.85 KB
<template>
  <div class="live-room">
    <div class="live-room container">
      <div class="flex">
        <!-- <el-form>
          <el-form-item>
            <el-button :size="size" type="primary" class="el-icon-plus" @click="handleEdit(1)">新增直播</el-button>
          </el-form-item>
        </el-form> -->
        <el-form :inline="true" style="width: 100%" :model="searchForm" label-width="85px" label-position="right">
          <el-row>
            <!-- <el-col :span="6"></el-col> -->
            <el-form-item size="small" label="服务名称">
              <el-input :size="size" v-model="searchForm.couponName" placeholder="请输入服务名称" clearable></el-input>
            </el-form-item>
            <el-form-item size="small" label="核销用户">
              <el-input :size="size" v-model="searchForm.userReq" placeholder="请输入核销用户" clearable></el-input>
            </el-form-item>
            <el-form-item size="small" label="核销员" style="margin-left: -10px">
              <el-input :size="size" v-model="searchForm.verificationOperator" placeholder="请输入核销员" clearable></el-input>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item size="small" label="关联信息">
              <el-input :size="size" v-model="searchForm.orderCode" placeholder="请输入关联信息" clearable></el-input>
            </el-form-item>
            <el-form-item size="small" label="核销日期">
              <!-- verificationTimeStart    verificationTimeEnd -->
              <!-- <el-input :size="size" v-model="searchForm.name" placeholder="请输入核销员" clearable></el-input> -->
              <el-date-picker :size="size" v-model="searchForm.daterange" type="daterange" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions || {}"></el-date-picker>
            </el-form-item>

            <el-form-item size="small" class="fr-mr0">
              <el-button :size="size" type="primary" @click="openDialog">核销</el-button>
              <el-button :size="size" type="primary" @click="handleSearch">查询</el-button>
              <el-button :size="size" type="primary" @click="handleExport">导出</el-button>
              <el-button :size="size" @click="handleReset">重置</el-button>
            </el-form-item>
          </el-row>
        </el-form>
      </div>
      <GLTable ref="memberRecordRef" v-if="isReload" :noDataImg="url" @setTableFinishFun="setTableFinishFun" :searchForm="searchFormTable" :tableParams="tableParams" :getListApi="getListApi" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn">
        <span slot="orderCodeHtml" slot-scope="scope">
          <span class="cursor-pointer" @click="couponNameHandleDetail(scope.scope)" v-if="scope.scope.directionalGiftId">{{ scope.scope.directionalGiftName }}</span>
          <span class="cursor-pointer" @click="orderCodeHandleDetail(scope.scope)" v-else>{{ scope.scope.orderCode }}</span>
        </span>
        <span slot="verificationTime" slot-scope="scope">
          <span>{{ dateFormatFun(scope.scope.verificationTime) }}</span>
        </span>
      </GLTable>
       <GLDialog mode="mid" title="优惠券核销(请确保用户到店后核销,避免引起不必要问题)" :hasFooter="hasFooter" :type="'error'" @onOk="handleConfirm" @onCancel="handleClose" :visible.sync="isDialogVisible">
       <div class="content-body">
          <el-form :rules="rules" ref="ruleForm" :model="ruleForm" label-width="80px">
            <!-- style="width: 440px" -->
            <el-form-item size="small" label="核销码" prop="verficationCode" style="width: 380px">
              <el-input size="small" v-model.trim="ruleForm.verficationCode" maxlength="50" placeholder="请输入核销码"></el-input>
            </el-form-item>
          </el-form>
        </div>
       </GLDialog>
     
    </div>
  </div>
</template>

<script>
// import { getRecordListApi, getVerificationCode, verificationExportApi } from '@/api/modules/record'
import url from '@/assets/empty.png'
import { dateFormat } from '@/utils/index.js'
import { exportFn } from '@/common/constant'
export default {
  name: 'record',
  data() {
    return {
      ruleForm: {
        verficationCode: ''
      },
      isDialogVisible: false,
      rules: {
        verficationCode: [{ required: true, message: '请输入核销码', trigger: 'blur' }]
      },
      url: url,
      isReload: true,
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now() || time.getTime() < new Date('2017-12-31').getTime()
        }
      },
      size: 'small',
      searchForm: {
        // couponId:222 //卷id
        //userCouponId //用户卷id
        // name: '',
        // daterange:''
        couponName: '',
        userReq: '',
        verificationOperator: '',
        orderCode: '',
        merchantId: 0,
        discountTypes: [7]
      },
      // 44187877
      searchFormTable: {},
      // 表格组件
      getListApi: this.$apis.record.getRecordListApi,
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      // 表格参数
      tableParams: {
        listName: 'list',
        tableOption: false,
        tableColumns: [
          {
            label: '服务名称',
            prop: 'couponName',
            width: '180'
            // formatter: cellValue => {
            //   return cellValue.startTime + '-' + cellValue.endTime
            // }
          },
          {
            label: '剩余待核销次数',
            prop: 'residueAmount',
            formatter: cellValue => {
              return cellValue.residueAmount || cellValue.residueAmount == 0 ? cellValue.residueAmount : '不限制次数'
            }
          },
          {
            label: '核销用户',
            prop: 'phone'
          },
          {
            label: '核销员',
            prop: 'verificationOperator'
          },
          {
            label: '关联信息',
            addHtml: 'orderCodeHtml'
          },
          {
            label: '核销日期',
            prop: 'verificationTime',
            addHtml: 'verificationTime'
          }
        ]
      },
      merchantId: 0
    }
  },
  created() {
    if (window.__POWERED_BY_QIANKUN__) {
      //运行在qiankun容器中
      this.merchantId = this.$globalState.session.merchantId
      this.searchForm.merchantId = this.merchantId
    }
  },
  methods: {
    // 跳转到礼包领取详情页
    couponNameHandleDetail(row) {
      console.log('row', row)
      this.$router.push({
        path: '/giftBag/giftDetail',
        query: {
          id: row.directionalGiftId
        }
      })
    },
    // 跳转到订单详情页
    orderCodeHandleDetail(row) {
      this.$router.push({
        path: '/memberCenter/orderDetail',
        query: {
          id: row.id,
          detail: row
        }
      })
    },
    dateFormatFun(date) {
      return dateFormat(date)
    },

    getParams() {
      var params = JSON.parse(JSON.stringify(this.searchForm))
      if (params.daterange) {
        params.verificationTimeStart = this.searchForm.daterange[0]
        params.verificationTimeEnd = this.searchForm.daterange[1]
      } else {
        if (params.beginTime) delete params.beginTime && delete params.endTime
      }
      delete params.daterange
      return params
    },

    beforeSearchFn() {
      return new Promise((resolve, reject) => {
        this.searchFormTable = this.getParams()
        resolve()
      })
    },
    setTableFinishFun() {
      //接收到的数据为空
      if (!this.$refs.memberRecordRef.data.length) {
        this.$refs.memberRecordRef.setTableHeightFun()
      }
    },
    handleShareClose() {
      this.isShareVisible = !this.isShareVisible
    },

    handleDetail(row) {
      this.$router.push({
        name: 'ServicesLiveRoomLiveControl',
        params: {
          id: row.id
        }
      })
    },
    openDialog() {
      this.isDialogVisible = true
    },
    handleClose() {
      this.isDialogVisible = !this.isDialogVisible
      this.$refs.ruleForm.resetFields()
    },
    handleConfirm() {
      // getRecordListApi
      this.$refs['ruleForm'].validate(valid => {
        if (!valid) {
          return
        }
        let params = {}
        params.verficationCode = this.ruleForm.verficationCode
        // params.discountTypes=[7]
        this.$apis.record.getVerificationCode(params).then(res => {
          if (res) {
            this.handleClose()
            this.handleSearch()
          }
        })
      })
    },
    // 1-新增;2-编辑
    handleEdit(addOrEdit, row) {
      // console.log(row)
      // this.$history.push('services/liveRoom/editLiveRoom', { addOrEdit: addOrEdit, row: row || {} })
      // this.eventBus.$emit('editRoom', {
      //   addOrEdit: addOrEdit,
      //   id: row ? row.id : ''
      // })
      this.$router.push({
        name: 'ServicesLiveRoomEditLiveRoom',
        params: {
          addOrEdit: addOrEdit,
          id: row ? row.id : '-1'
        }
        // name: 'editLiveRoom',
        // path: '/liveRoom/editLiveRoom'
      })
    },

    handleExport(row) {
      var params = this.getParams()
      this.$apis.record.verificationExportApi(params).then(res => {
        exportFn(res)
      })
    },

    handleSearch() {
      this.$refs.memberRecordRef.refreshTable()
    },
    handleReset() {
      // this.searchForm = { merchantId: 44184606 }
      // this.handleSearch()
      this.isReload = false
      this.searchForm = { merchantId: this.merchantId, discountTypes: [7] }
      this.$nextTick(() => {
        this.isReload = true
      })
    }
  }
}
</script>

<style lang="scss" scoped>
/deep/.el-input--small .el-input__inner {
  width: 215px;
}
.el-range-editor.is-active,
.el-range-editor.is-active:hover {
  border-color: #5850ff;

  width: 215px;
}
.el-range-editor--small.el-input__inner {
  width: 215px;
}


</style>