record.vue 9.55 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="verificationTime" slot-scope="scope">
          <span>{{ dateFormatFun(scope.scope.verificationTime) }}</span>
        </span>
      </GLTable>
      <glsx-dialog title="优惠券核销(请确保用户到店后核销,避免引起不必要问题)" :hasScroll="false" width="580px" btnCloseLabel="取消" :noClose="false" :noCancel="true" btnSize="small" :isVisible="isDialogVisible" :showClose="false" @closeDialog="handleClose" @confirmDialog="handleConfirm">
        <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>
      </glsx-dialog>
    </div>
  </div>
</template>

<script>
import glsxDialog from '@/components/glsx-dialog'
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',
   components: {
    glsxDialog
  },
  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: 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: 'userName',
 
          },
          {
            label: '核销员',
            prop: 'verificationOperator'
          },
          {
            label: '关联订单号',
            prop: 'orderCode',
    
          },
          {
            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: {
    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]
        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()
      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;
}
/deep/.el-dialog__header {
  padding-top: 20px;
  padding-bottom: 20px;
}
/deep/ .el-dialog__body {
  // border-bottom: 1px solid #e6e6e6;
  // border-top: 1px solid #e6e6e6;

  padding: 30px 20px;
  .content-body {
    .el-input--small .el-input__inner {
      width:300px
    }
  }
}
/deep/ .el-dialog__footer {
  // text-align: center;
  padding-top: 12px;
  padding-bottom: 12px;
}
</style>