detail.vue 8.16 KB
<template>
  <div class="layout">
    <div class="fixed-content">
      <template v-for="(i,index) in fixedForm">
        <template>
          <div
            :key="index"
            class="item flex"
          >
            <div class="label">{{i.label}}:</div>
            <div class="value">
              <template v-if="i.formatter">
                {{i.formatter(data)}}
              </template>
              <template v-else>
                {{ data[i.key] || '--'}}
              </template>
            </div>
          </div>
        </template>
      </template>
    </div>
    <div class="container">
      <div class="sticky">
        <GLCombiForm
          ref="showSearch"
          :rowNumber="1"
          :formObj="searchForm"
          :formData="searchFormData"
          @handleOk="handleSearch"
          @handleRest="handleReset"
        ></GLCombiForm>
        <div class="sticky-btns">
          <div class="btns">
            <el-button
              type="default"
              @click="handleExport"
            >导出</el-button>
          </div>
        </div>
      </div>
      <div class="tabelList">
        <GLTable
          ref="listRef"
          :getListApi="getListApi"
          :searchForm="tableSearchForm"
          :noDataImg="url"
          :tableParams="tableParams"
          :pageConf="pageConf"
          :beforeSearchFn="beforeSearchFn"
        >
          <template
            slot="claimState"
            slot-scope="scope"
          >
            <div :class="`status status-${scope.scope.claimState}`">
              {{{
                '0':'未领取',
                '1':'已领取'
              }[scope.scope.claimState]}}
          </div>
        </template>
        </GLTable>
      </div>
    </div>
  </div>
</template>

<script type='text/ecmascript-6'>
import url from '@/assets/empty.png'
import { exportFn } from '@/common/constant'
import util from '@/utils/util'
import * as dayjs from 'dayjs'
const solitaireTableColumns = [
  {
    label: '手机号码',
    prop: 'phone',
    minWidth: 120
  },
  {
    label: '用户名称',
    prop: 'name',
    minWidth: 100
  },
  {
    label: '接龙数字',
    prop: 'relayContent',
    minWidth: 100
  },
  {
    label: '接龙时间',
    minWidth: 100,
    formatter (cell) {
      return dayjs(cell.relayTime).format('YYYY/MM/DD HH:mm:ss')
    }
  },
], winningTableColumns = [
  {
    label: '手机号码',
    prop: 'phone',
    minWidth: 120
  },
  {
    label: '用户名称',
    prop: 'name',
    minWidth: 100
  },
  {
    label: '接龙数字',
    prop: 'relayContent',
    minWidth: 100
  },
  {
    label: '接龙时间',
    minWidth: 100,
    formatter (cell) {
      return dayjs(cell.relayTime).format('YYYY/MM/DD HH:mm:ss')
    }
  },
  {
    label: '状态',
    minWidth: 100,
    addHtml: 'claimState'
  },
]
export default {
  name: 'detail',
  data () {
    return {
      url,
      data: {},
      tableSearchForm: {},
      fixedForm: [
        {
          label: '卡片标题',
          key: 'title'
        },
        {
          label: '创建时间',
          formatter (cell) {
            return dayjs(cell.createdTime).format('YYYY/MM/DD HH:mm:ss')
          }
        },
        {
          label: '开奖时间',
          formatter (cell) {
            return dayjs(cell.lotteryTime).format('YYYY/MM/DD HH:mm:ss')
          }
        },
        {
          label: '中奖数字',
          formatter (cell) {
            return cell.numType == 1 ? `随机(${cell.numWin || '--'})` : cell.numWin || '--'
          }
        },
        {
          label: '关联奖品',
          formatter: cell => {
            return `${{
              1: '红包活动',
              2: '优惠券',
              3: '权益卡券'
            }[cell.rewardType]}-${cell.rewardName}`
          }
        },
        {
          label: '所属渠道',
          key: 'merchantName'
        },
      ],
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      searchForm: {
        phone: '',
        name: '',
        activityTime: ''
      },
      searchFormData: [
        {
          label: '手机号码',
          name: 'phone',
          type: 'input',
          maxlength: 11
        },
        {
          label: '用户名称',
          name: 'name',
          type: 'input',
          maxlength: 100
        },
        {
          label: '接龙时间',
          name: 'activityTime',
          type: 'datePicker',
          isClear: true,
          valueFormat: 'yyyy-MM-dd',
          customPickerOptions: {
            disabledDate (date) {
              const yesterday = new Date(new Date().setDate(new Date().getDate()))
              return date > yesterday
            }
          }
        },
      ],
      getListApi: this.$apis.solitaire.getSolitaireAewardList,
      tableParams: {
        listName: 'list',
        tableColumns: this.$route.query.type ? winningTableColumns : solitaireTableColumns
      },
    }
  },
  mounted () {
    this.getSolitaireDetail()
  },
  methods: {
    async getSolitaireDetail () {
      try {
        const { relayLotteryId } = this.$route.query,
          data = await this.$apis.solitaire.getSolitaireDetail({ relayLotteryId })
        this.data = data
        this.$loading().close()
      } catch (error) {
        this.$loading().close()
      }

    },
    getParams () {
      let params = JSON.parse(JSON.stringify(this.searchForm))
      if (params.activityTime) {
        params.startRelayTime = dayjs(params.activityTime[0]).format('YYYY-MM-DD') + ' 00:00:00'
        params.endRelayTime = dayjs(params.activityTime[1]).format('YYYY-MM-DD') + ' 23:59:59'
      }
      delete params.activityTime
      if (this.$route.query.type) params.winState = 2//中奖明细 
      params.relayLotteryId = this.$route.query.relayLotteryId
      return params
    },
    beforeSearchFn () {
      return new Promise(resolve => {
        this.tableSearchForm = this.getParams()
        resolve()
      })
    },
    handleSearch () {
      this.$refs.listRef.refreshTable()
    },
    handleReset () {
      this.searchForm = this.$options.data.call(this).searchForm
      this.handleSearch()
    },
    handleExport () {
      const target = this.$route.query.type ? 'exportSolitaireAewardList' : 'exportSolitaireUserList'
      this.$apis.solitaire[target]({ ...this.getParams(), ...this.$refs.listRef.page }).then(res => {
        exportFn(res)
      })
    },
    download (url) {
      util.downloadIamge(url)
    },
  }
}
</script>

<style scoped lang='scss'>
.layout {
  height: calc(100vh - 80px);

  .fixed-content {
    height: 100px;
    background: #ffffff;
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    font-size: 14px;
    color: #666666;
    .item {
      line-height: 20px;
      .label {
        width: 154px;
        text-align: right;
        flex-shrink: 0;
      }
      .value {
        color: #333333;
      }
    }
  }
  .container {
    height: calc(100% - 116px);
    background-color: #fff;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    padding: 20px;
    overflow-y: scroll;
    .sticky {
      position: relative;
      z-index: 2;
      /deep/.el-tag--info {
        max-width: 50%;
      }
      &-btns {
        position: absolute;
        right: 0;
        bottom: 10px;
        overflow: hidden;
        .el-button + .el-button {
          margin-left: 8px;
        }
        .btns {
          transition: all 0.25s;
          .el-button {
            padding: 8px 15px;
            min-width: 60px;
          }
        }
      }
    }
    .qr {
      width: 36px;
      height: 36px;
      img {
        width: 100%;
        height: 100%;
        vertical-align: top;
      }
    }
  }
}
.img-plus {
  width: 200px;
  height: 200px;
}
.download-img {
  cursor: pointer;
  margin-top: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #5850ff;
  line-height: 20px;
  text-align: center;
}
.status {
  display: flex;
  align-items: center;
  &::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 100%;
    margin-right: 8px;
    background: #999999;
  }
}
.status-0 {
  &::before {
    background: #f8b757;
  }
}
.status-1 {
  &::before {
    background: #4aca74;
  }
}
</style>