index.vue 8.01 KB
<!-- 额度监控 - 列表 -->
<template>
  <div>
    <d2-container>
      <div class="header"
           slot="header"
           style="padding: 10px 20px;">
        <d2-search ref="showSearch"
                   class="show-search"
                   :search-form="searchForm"
                   :label-width="labelWidth"
                   :form-data="showFormData">
          <div slot="yearChoose"
               slot-scope="scope">
            <el-date-picker v-model="searchForm.statYear"
                            type="year"
                            placeholder="选择年"
                            value-format="yyyy"
                            format="yyyy"
                            :clearable="false"
                            :picker-options="pickerOption"
                            :editable="false">
            </el-date-picker>
          </div>
        </d2-search>
        <div class="up-btns">
          <el-button @click="handleSearch"
                     size="small"
                     type="primary">
            查询
          </el-button>
          <el-button size="small"
                     @click="handleReset">
            重置
          </el-button>
        </div>
      </div>
      <div class="d2-container-content">
        <d2-table-header>
          <auth-button category="Button" />
        </d2-table-header>
        <d2-table ref="recordTable"
                  :get-list-api="getListApi"
                  :search-form="searchFormSearch"
                  :table-params="tableParams"
                  :before-search-fn="beforeSearchFn">
          <auth-button slot="auth-button"
                       slot-scope="scope"
                       :data="scope.scope" />
        </d2-table>
      </div>
    </d2-container>
    <!-- 编辑 -->
    <edit-dialog :edit-visible="editVisible"
                 v-if="editVisible"
                 :params-obj="recordInfo"
                 @dialogClose="editDialogClose" />
  </div>
</template>

<script>
import { Util, deepClone } from '@/common/util'
import { mapActions, mapState } from 'vuex'
import { rangePickerOptions_year_2023 } from '@/common/format'
import { transferQuotaMonitorConfigPage } from '@api/limitMonitor'
import editDialog from './components/editDialog'
export default {
  name: 'LimitMonitorList',
  components: {
    editDialog
  },
  data() {
    return {
      userInfo: this.$store.state.d2admin.user.info,
      pickerOption: rangePickerOptions_year_2023,
      labelWidth: '100px',
      searchForm: {
        statYear: '',
        merchantName: '',
        matchMerchantId: ''
      },
      searchFormSearch: {},
      showFormData: [{
        label: '统计年度',
        addHtml: 'yearChoose'
      }, {
        label: '商户名称',
        name: 'merchantName',
        type: 'input',
        maxlength: '50',
        isClear: true
      }, {
        label: '商户号',
        name: 'matchMerchantId',
        type: 'input',
        inputType: 'number',
        maxlength: '20',
        isClear: true
      }],
      getListApi: transferQuotaMonitorConfigPage,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        // mutiSelectUniqueKey: 'id',
        // mutiSelectName: 'transferAccounts',
        // tableOption: { width: '100px' },
        tableOption: true,
        tableColumns: [{
          label: '区域',
          prop: 'cityName',
          width: '100'
        }, {
          label: '商户名称',
          prop: 'merchantName',
          width: '300px'
        }, {
          label: '商户号',
          prop: 'merchantId',
          width: '120'
        }, {
          label: '联系方式',
          prop: 'phone',
          width: '120'
        }, {
          label: '开户行',
          prop: 'openAccBankName',
          width: '200px'
        }, {
          label: '账号',
          prop: 'bankAccountNo',
          width: '200px'
        }, {
          label: '日额度/元',
          prop: 'dayQuota',
          width: '120',
          formatter: (cellValue) => {
            return (cellValue.dayQuota || cellValue.dayQuota == 0) ? parseFloat(cellValue.dayQuota).toFixed(2) : '-'
          }
        }, {
          label: '月额度/元',
          prop: 'monthQuota',
          width: '120',
          formatter: (cellValue) => {
            return (cellValue.monthQuota || cellValue.monthQuota == 0) ? parseFloat(cellValue.monthQuota).toFixed(2) : '-'
          }
        }, {
          label: '年额度/元',
          prop: 'yearQuota',
          width: '120',
          formatter: (cellValue) => {
            return (cellValue.yearQuota || cellValue.yearQuota == 0) ? parseFloat(cellValue.yearQuota).toFixed(2) : '-'
          }
        }, {
          label: '本年已用额度',
          prop: 'usedYearQuota',
          width: '120',
          formatter: (cellValue) => {
            return (cellValue.usedYearQuota || cellValue.usedYearQuota == 0) ? parseFloat(cellValue.usedYearQuota).toFixed(2) : '-'
          }
        }, {
          label: '剩余额度',
          prop: 'remnantQuota',
          width: '120',
          formatter: (cellValue) => {
            return (cellValue.remnantQuota || cellValue.remnantQuota == 0) ? parseFloat(cellValue.remnantQuota).toFixed(2) : '-'
          }
        }
        ]
      },
      baseData: {

      },

      recordInfo: null,
      editVisible: false
    }
  },
  computed: {
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList
    })
  },
  mounted() {
    this.getBaseData()
  },

  methods: {
    ...mapActions({
      get: 'd2admin/base/get',
      close: 'd2admin/page/close'
    }),
    ...mapActions('d2admin/user', ['actionSetDownloadList']),

    async getBaseData() {
      this.getOptionsList()
    },

    beforeSearchFn() {
      if (!this.searchForm.statYear) {
        const nowDate = new Date()
        this.searchForm.statYear = nowDate.getFullYear().toString()
      }
      return new Promise(resolve => {
        this.searchFormSearch = deepClone(this.searchForm)
        resolve()
      })
    },

    getOptionsList() {
      this.showFormData.forEach((item, index) => {
        if (item.type === 'select') {
          console.log('this.baseData[item.optionsName]', item.optionsName)
          if (this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this.showFormData[index].optionLabel] !== '全部') {
            const temp = {}
            temp[this.showFormData[index].optionId] = ''
            temp[this.showFormData[index].optionLabel] = '全部'
            this.baseData[item.optionsName].unshift(temp)
          }
          this.$set(this.showFormData[index], 'optionList', this.baseData[item.optionsName])
        }
      })
    },

    handleSearch() {
      this.$refs.recordTable.refreshTable(false, true)
    },
    handleReset() {
      this.searchForm = {
        statYear: '',
        merchantName: '',
        matchMerchantId: ''
      }
      this.$refs.recordTable.refreshTable(false, true)
    },

    handleEdit(row) {
      this.recordInfo = row
      this.editVisible = !this.editVisible
    },

    editDialogClose(obj) {
      this[obj.attrName] = !this[obj.attrName]
      if (obj.flag) {
        this.$refs.recordTable.refreshTable()
      }
    },

    handleExport() {
      var params = this.searchFormSearch
      // 去除为null的值
      for (const key in params) {
        if (params[key] === null || params[key] === '' || params[key].length == 0) {
          delete params[key]
        }
      }
      params.method = 'dj.api.smartcarlife.transferQuotaMonitorConfig.exportAsync'
      const list = [
        ...this.dowloadList,
        {
          name: '额度监控',
          exportParam: JSON.stringify(params),
          status: 'waiting',
          timeid: new Date().getTime()
        }
      ]
      this.actionSetDownloadList({ list, type: 'dowloadList' })
    }

  }
}

</script>
<style scoped>
.count-txt {
  font-weight: 700;
  color: #2a58ad;
  margin: 0 2px;
}

.leftSpan {
  display: inline-block;
  box-sizing: border-box;
  margin-right: 10px;
}
</style>