rewardPoolList.vue 7.65 KB
<!-- 激励池 -->
<template>
  <d2-container class="rewardPool-list m-t-40">
    <div class="header"
         slot="header">
      <d2-search ref="showSearch"
                 class="show-search"
                 :search-form="searchForm"
                 :label-width="'100px'"
                 :form-data="copyShowFormData">
        <template>
          <div slot="monthSelect">
            <el-date-picker 
              class="month-class" 
              v-model="searchForm.month"
              :picker-options="rangePickerOptions"
              type="monthrange"
              range-separator="至"
              start-placeholder="开始月份"
              end-placeholder="结束月份"></el-date-picker>
          </div>
        </template>
      </d2-search>
      <div class="up-btns">
        <el-button size="small"
                   type="primary"
                   @click="handleSearch">
          查询
        </el-button>
        <el-button size="small"
                   @click="handleReset">
          重置
        </el-button>
      </div>
    </div>
    <div class="d2-container-content">
      <div class="static-text">截止至{{ staticData.date }},当前激励池余额{{ staticData.totalBalance }},上月存入{{ staticData.curMonthIncome }},上月支出{{ staticData.curMonthExpenses }}</div>
      <span style="position: absolute; right: 41px; top: 20px; z-index: 999">
        <auth-button :show-btn-ids="
                       activeName === 'expenseList' ? ['9121206'] : ['9121207']
                     "
                     category="Button" />
      </span>
      <el-tabs v-model="activeName"
               type="card"
               @tab-click="handleReset">
        <el-tab-pane label="存入"
                     name="depositList">
          <deposit-list v-if="activeName == 'depositList'"
                      ref="depositList"
                      :parent-search-form="searchForm" />
        </el-tab-pane>
        <el-tab-pane label="支出"
                     name="expenseList">
          <expense-list v-if="activeName == 'expenseList'"
                          ref="expenseList"
                          :parent-search-form="searchForm"
                          :static-data="staticData"
                          @refreshStatic="handleRefreshStatic" />
        </el-tab-pane>
      </el-tabs>
    </div>
  </d2-container>
</template>
<script>
import depositList from './depositList.vue'
import expenseList from './expenseList.vue'
import { mapActions, mapState } from 'vuex'
import { Util, deepClone } from '@/common/util'
import { staffLevelList } from '@/common/constants.js'
import { rangePickerOptions } from '@/common/format'
import { getIncentivePoolStatisticsApi } from '@api/resident'
export default {
  name: "RewardPoolList",
  components: {
    depositList,
    expenseList
  },
  data() {
    return {
      rangePickerOptions: rangePickerOptions,
      // 搜索框
      showFormData: [{
        label: '员工姓名',
        name: 'staffName',
        type: 'input',
        isClear: true,
        keyFn: this.handleSearch
      }, {
        label: '职级',
        name: 'jobType',
        type: 'select',
        isClear: true,
        optionsName: 'jobTypeList',
        optionId: 'confId',
        optionLabel: 'confValue',
        keyFn: this.handleSearch
      }],
      // 查询条件
      searchForm: {
        staffName: '',
        merchantName: '',
        merchantId: '',
        jobType: '',
        month: [],
        time: []
      },
      activeName: 'depositList',
      baseData: {
        jobTypeList: deepClone(staffLevelList)
      },
      copyShowFormData: [],
      staticData: {}
    }
  },

  watch: {
    activeName: {
      handler() {
        this.parentSearchForm = {
          staffName: ''
        }
        this.changeShowFormData()
      },
    }
  },

  computed: {
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList,
      updateList: (state) => state.d2admin.user.updateList,
      updateRefesh: (state) => state.d2admin.user.updateRefesh
    })
  },

  mounted() {
    this.getOptionsList()
    // 获取统计信息
    this.getIncentivePoolStatistics()
  },
  methods: {
    ...mapActions({
      get: 'd2admin/base/get',
      close: 'd2admin/page/close'
    }),
    ...mapActions('d2admin/user', ['actionSetDownloadList']),
    getIncentivePoolStatistics() {
      getIncentivePoolStatisticsApi({}).then(res => {
        this.staticData = res || {}
        this.staticData.date = Util.dateFormate(new Date(), 'YYYY年MM月DD日')
      })
    },
    handleRefreshStatic() {
      this.getIncentivePoolStatistics()
    },
    getOptionsList() {
      this.changeShowFormData()
    },
    changeShowFormData() {
      const copyShowFormData = deepClone(this.showFormData)
      switch (this.activeName) {
        case 'depositList':
          copyShowFormData.push({
            label: '门店',
            name: 'merchantName',
            type: 'input',
            keyFn: this.handleSearch
          }, {
            label: '月份',
            name: 'month',
            type: 'monthSelect',
            addHtml: 'monthSelect'
          })
          this.copyShowFormData = copyShowFormData
          break
        case 'expenseList':
          copyShowFormData.push({
            label: '时间',
            name: 'time',
            type: "datePicker",
            isClear: true,
            pickerOptions: "rangePickerOptions",
            keyFn: this.handleSearch
          })
          this.copyShowFormData = copyShowFormData
          break
      }
      copyShowFormData.forEach((item, index) => {
        if (item.type === 'select') {
          if (this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][copyShowFormData[index].optionLabel] !== '全部') {
            const temp = {}
            temp[copyShowFormData[index].optionId] = ''
            temp[copyShowFormData[index].optionLabel] = '全部'
            this.baseData[item.optionsName].unshift(temp)
          }
          this.$set(copyShowFormData[index], 'optionList', this.baseData[item.optionsName])
        }
      })
    },
    handleSearch() {
      this.$nextTick(() => {
        this.$refs[this.activeName].keyDowmGetList()
      })
    },
    // 重置
    handleReset() {
      this.searchForm = {
        staffName: '',
        merchantName: '',
        merchantId: '',
        jobType: '',
        month: []
      }
      this.handleSearch()
    },
    // 导出
    handleExport() {
      var params = {
        ...this.searchForm,
      }
      if (params.month && params.month?.length) {
        const startDate = params.month[0]
        const endDate = params.month[1]
        params.commissionMonthStart = Util.dateFormate(startDate, "YYYY-MM")
        params.commissionMonthEnd = Util.dateFormate(endDate, "YYYY-MM")
      }
      delete params.month
      params.method = 'dj.api.smartcarlife.incentivePool.exportIncome.async'
      const list = [
        ...this.dowloadList,
        {
          name: '激励池存入',
          exportParam: JSON.stringify(params),
          status: 'waiting',
          timeid: new Date().getTime()
        }
      ]
      this.actionSetDownloadList({ list, type: 'dowloadList' })
    },
    handleAddExpenditure() {
      this.$nextTick(() => {
        this.$refs[this.activeName].handleAddExpenditure()
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.month-class{
  width: 100% !important;
}
.m-t-40 {
  margin-top: 40px;
  ::v-deep .el-tabs__header {
    padding: 0 !important;
    margin: 0 0 15px !important
  }
}
.static-text{
  position: absolute;
  top: 30px;
  left: 200px;
  // margin-top: 20px;
  font-size: 14px;
  color: #666;
}
.d2-container-content{
  position: relative;
}
</style>