index.vue 9.29 KB
<template>
  <div class="container">
    <GLCombiForm
      ref="showSearch"
      :rowNumber="2"
      :formObj="searchForm"
      :formData="searchFormData"
      @handleOk="handleSearch"
      @handleRest="handleReset"
    ></GLCombiForm>
    <div class="sticky-btns">
      <el-button
        type="default"
        plain
        @click="jump"
        size="small"
      >门店客户积分充值</el-button>
      <GLButton @click="toSMS" fn="提醒短信" size="small">提醒短信</GLButton>
      <el-button @click="handleExport" size="small">导出
      </el-button>
    </div>
    <div class="tabelList">
      <GLTable
        ref="listRef"
        :getListApi="getListApi"
        :searchForm="tableSearchForm"
        :tableParams="tableParams"
        :pageConf="pageConf"
      >
        <template
          slot="customerNumber"
          slot-scope="scope"
        >
          <div
            class="link"
            @click="openDetail(scope.scope.id)"
          >{{scope.scope.customerNumber}}</div>
        </template>
        <template
          slot="status"
          slot-scope="scope"
        >
          <div class="status-box">
            <span :class="['status',`status-${scope.scope.status}`]"></span>
            {{{0:'待充值',1:'充值成功'}[scope.scope.status]}}
          </div>
        </template>
        <template
          slot="auth-button"
          slot-scope="scope"
        >
          <GLTableButton
            :buttonList="tableButtonList"
            :buttonItem="scope.scope"
            :buttonNum="3"
          ></GLTableButton>
        </template>>
      </GLTable>
    </div>
    <detail-dialog :detailObj.sync="detailObj" />
    <audit-dialog :auditObj.sync="auditObj" />
  </div>
</template>

<script type='text/ecmascript-6'>
import detailDialog from './components/detailDialog.vue'
import * as dayjs from 'dayjs'
import auditDialog from './components/auditDialog.vue'
export default {
  name: '',
  components: {
    detailDialog,
    auditDialog
  },
  data () {
    return {
      pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
      searchForm: {
        batchNo: '',
        merchantName: '',
        customerName: '',
        customerPhone: '',
        createdDate: [],
        auditDate: [],
        status: ''
      },
      searchFormData: [
        {
          label: '批次',
          name: 'batchNo',
          type: 'input',
          maxlength: 100
        },
        {
          label: '商户名称',
          name: 'merchantName',
          type: 'input',
          maxlength: 100
        },
        {
          label: '用户姓名',
          name: 'customerName',
          type: 'input',
          maxlength: 100
        },
        {
          label: '用户手机号',
          name: 'customerPhone',
          type: 'input',
          maxlength: 13
        },
        {
          label: '创建时间',
          name: 'createdDate',
          type: 'datePicker',
          valueFormat: 'yyyy-MM-dd',
          isClear: true,
          customPickerOptions: {
            disabledDate (date) {
              const yesterday = new Date(new Date().setDate(new Date().getDate()))
              if (date > yesterday) {
                return true
              }
              return false
            }
          }
        },
        {
          label: '状态',
          name: 'status',
          type: 'select',
          maxlength: 100,
          optionList: [
            { text: '全部', id: '' },
            { text: '待充值 ', id: '0' },
            { text: '充值成功', id: '1' }
          ],
          optionId: 'id',
          optionLabel: 'text'
        },
        {
          label: '审核时间',
          name: 'auditDate',
          type: 'datePicker',
          valueFormat: 'yyyy-MM-dd',
          isClear: true,
          customPickerOptions: {
            disabledDate (date) {
              const yesterday = new Date(new Date().setDate(new Date().getDate()))
              if (date > yesterday) {
                return true
              }
              return false
            }
          }
        },
      ],
      getListApi: this.$apis.points.getIntegralList,
      tableParams: {
        listName: 'list',
        tableOption: true,
        tableColumns: [
          {
            label: '商户名称',
            prop: 'merchantName',
            minWidth: 150
          },
          {
            label: '批次',
            prop: 'batchNo',
            minWidth: 120
          },
          {
            label: '客户数量',
            addHtml: 'customerNumber',
            minWidth: 100
          },
          {
            label: '充值积分数',
            minWidth: 120,
            prop: 'totalIntegral',
          },
          {
            label: '状态',
            minWidth: 120,
            addHtml: 'status',
          },
          {
            label: '创建人',
            prop: 'createdByName',
            minWidth: 150,
          },
          {
            label: '创建时间',
            minWidth: 150,
            formatter: cell => dayjs(cell.createdDate).format('YYYY/MM/DD HH:mm:ss')
          },
          {
            label: '审核人',
            prop: 'auditBy',
            minWidth: 150,
          },
          {
            label: '审核时间',
            minWidth: 150,
            formatter: cell => cell.auditDate ? dayjs(cell.auditDate).format('YYYY/MM/DD HH:mm:ss') : ''
          },
        ]
      },
      tableButtonList: [
        {
          type: 'GLButton',
          name: '审核',
          attrs: {
            type: 'text',
            fn: '审核'
          },
          condition: row => row.status == 0,
          listeners: {
            click: row => this.auditObj = {
              show: true,
              row
            }
          }
        },
        {
          type: 'el-button',
          name: '详情',
          attrs: {
            type: 'text',
          },
          condition: row => row.status == 1,
          listeners: {
            click: row => this.editForm(row)
          }
        },
        {
          type: 'GLButton',
          name: '编辑',
          attrs: {
            type: 'text',
            fn: '编辑'
          },
          condition: row => row.status == 0,
          listeners: {
            click: row => this.editForm(row, 'edit')
          }
        },
      ],
      showImportRecord: false,
      tableSearchForm: {},
      detailObj: {},
      auditObj: {}
    }
  },
	created () {
		/** loginpath:标识系统
		 * 门店版:/login
		 * 1、筛选去掉“商户名称”
		 * 2、去掉“提醒短信” - 系统权限控制
		 * 3、列表去掉“审核”和“编辑” - 系统权限控制
		 * 运营版:/oss
		 */
		if(this.$globalState.session.loginpath == '/login') {
			// 1、筛选去掉“商户名称”
			const searchIdx = this.searchFormData.findIndex(item => item.name == 'merchantName')
			if(searchIdx != -1) {
				this.searchFormData.splice(searchIdx, 1)
			}
		}
  },
  mounted () {
  },
  methods: {
    handleSearch () {
      this.tableSearchForm = this.getParams()
      this.$refs.listRef.refreshTable()
    },
    handleReset () {
      this.searchForm = this.$options.data.call(this).searchForm
      this.handleSearch()
    },
    handleExport () {
      const params = this.getParams()
      this.$apis.points.exportIntegralList({ ...params, ...this.$refs.listRef.page }).then(res => {
        this.$utils.aToExport(res)
      })
    },
    getParams () {
      let params = JSON.parse(JSON.stringify(this.searchForm))
      this.setTimeFormat(params, 'createdDate', 'createdDateBegin', 'createdDateEnd')
      this.setTimeFormat(params, 'auditDate', 'auditDateBegin', 'auditDateEnd')
      return params
    },
    setTimeFormat (target, name, start, end) {
      if (target[name] && target[name].length) {
        target[start] = `${dayjs(target[name][0]).format('YYYY-MM-DD')} 00:00:00`
        target[end] = `${dayjs(target[name][1]).format('YYYY-MM-DD')} 23:59:59`
        delete target[name]
      }
    },
    jump () {
      this.$router.push({
        path: '/storeCredit/add',
        query: {
          $title: '门店客户积分充值',
          type:'addRecharge'
        }
      })
    },
    openDetail (recordId) {
      this.detailObj = {
        show: true,
        recordId
      }
    },
    editForm (row, type = '') {
      this.$router.push({
        path: '/storeCredit/add',
        query: {
          $title: type ? '编辑门店客户积分充值' : '查看门店客户积分充值',
          id: row.id,
          type
        }
      })
    },
    toSMS(){
      this.$router.push({
        path: '/sms/index',
        query: {
          $title: '提醒短信',
        }
      })
    }

  }
}
</script>

<style scoped lang='scss'>
.container {
  height: 100%;
  background-color: #fff;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  padding: 20px;

  .sticky-btns {
    margin-bottom: 10px;
    display: flex;
    justify-content: flex-end;
    .el-button {
      min-width: 60px;
    }
    .el-button + .el-button {
      margin-left: 10px;
    }
  }
  .link {
    color: #5850ff;
    cursor: pointer;
  }
}
.status-box {
  display: flex;
  align-items: center;
  .status {
    width: 6px;
    height: 6px;
    border-radius: 4px;
    background: #fdb757;
    margin-right: 8px;
  }
  .status-1 {
    background: #2cca74;
  }
}
</style>