detail.vue 4.59 KB
<template>
  <div class="points">
    <div class="points edit-box">
      <div class="container m-b-20 top">
        <div class="page-title">积分详情</div>
        <div class="flex box">
          <div class="flex block" v-for="(item, index) in detailFormData" :key="index">
            <img class="icon" :src="require(`@/assets/point-custom-${index}.png`)" />
            <div>
              <div>{{ item.title }}</div>
              <div class="num">{{ detailData[item.name] || 0 }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="container">
      <GLCombiForm ref="showSearch" :rowNumber="1" :formObj="searchForm" :formData="showFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
      <div class="table-header">
        <h2>客户积分明细</h2>
        <el-button size="small" @click="exportExcel" type="primary" plain>导出</el-button>
      </div>

      <!-- 表格区域 开始 -->
      <GLTable ref="pointRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn" @setTableFinishFun="setTableFinishFun"></GLTable>
      <!-- 表格区域 end -->
    </div>
  </div>
</template>

<script>
import url from '@/assets/empty.png'
export default {
  data() {
    //这里存放数据
    return {
      size: 'small',
      url: url,
      routeInfo: {},
      searchForm: {
        ruleType: ''
      },
      showFormData: [
        {
          label: '消费类型',
          name: 'ruleType',
          type: 'select',
          optionList: [],
          optionId: 'ruleType',
          optionLabel: 'ruleDesc'
        }
      ],
      detailData: {},
      detailFormData: [
        {
          title: '当前积分',
          name: 'availableIntegral'
        },
        {
          title: '积分累计收入',
          name: 'totalIntegral'
        },
        {
          title: '积分累计支出',
          name: 'usedIntegral'
        }
      ],
      // 表格
      getListApi: this.$apis.points.getIntegralDetailList,
      tableParams: {
        listName: 'list',
        tableOption: false,
        tableColumns: [
          {
            label: '类型',
            prop: 'direct',
            formatter: cellValue => {
              const obj = {
                ADD: '收入',
                DEDUCT: '支出'
              }
              return obj[cellValue.direct]
            }
          },
          {
            label: '数量',
            prop: 'integralValue'
          },
          {
            label: '消费类型',
            prop: 'ruleDesc'
          },
          {
            label: '消费名称',
            prop: 'bizRelName'
          },
          {
            label: '消费时间',
            prop: 'createdDate'
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
      ruleTypeList: []
    }
  },
  created() {
    this.routeInfo = this.$route.query
    this.getTypeList()
  },
  mounted() {
    this.$utils.getOptionsList(this, 'showFormData')
    this.customerDetail()
  },
  methods: {
    getTypeList() {
      this.$apis.points.getTypeListApi({}).then(res => {
        if (res?.length) {
          this.ruleTypeList = res
          const target = this.showFormData.find(item => item.name == 'ruleType')
          target.optionList = res
        }
      })
    },
    customerDetail() {
      const params = {
        customerId: this.routeInfo.id
      }
      this.$apis.points.customerDetail(params).then(res => {
        this.detailData = res || {}
      })
    },
    dealParams() {
      this.searchForm.customerId = this.routeInfo.id
      return this.searchForm
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchForm = this.dealParams()
        resolve()
      })
    },
    handleSearch() {
      this.$refs.pointRef.refreshTable()
    },
    handleReset() {
      this.searchForm = {
        ruleType: ''
      }
      this.handleSearch()
    },
    exportExcel() {
      var params = this.dealParams()
      this.$apis.points.getIntegralDetailExport(params).then(res => {
        this.$utils.aToExport(res)
      })
    }
  }
}
</script>
<style scoped>
.top .icon {
  width: 44px;
  height: 44px;
  margin-right: 16px;
}
.top .box {
  padding: 20px 20px 0;
}
.top .block {
  box-sizing: border-box;
  width: 271px;
  height: 100px;
  font-size: 14px;
  color: #333333;
  background: #f9fafc;
  margin-right: 20px;
  padding: 24px 16px 20px;
}
.top .num {
  font-weight: 700;
  font-size: 26px;
  color: #333333;
  margin-top: 10px;
}
</style>