invoiceRedManage.vue 8.49 KB
<!-- 发票查询 - 列表 -->
<template>
  <div>
    <d2-container>
      <div class="header" slot="header" style="padding: 20px 20px;">
        <d2-search ref="showSearch" class="show-search" :search-form="searchForm" :label-width="labelWidth" :form-data="showFormData"></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="redTable" :get-list-api="getListApi" :search-form="searchFormSearch" :table-params="tableParams" :before-search-fn="beforeSearchFn">
          <div slot="auth-button" slot-scope="scope">
            <span style="margin-right: 10px" v-if="scope.scope.blueInvoiceDownloadUrl">
              <auth-button :data="scope.scope" :show-btn-ids="['9170302']" />
            </span>
            <span style="margin-right: 10px" v-if="scope.scope.redInvoiceDownloadUrl">
              <auth-button :data="scope.scope" :show-btn-ids="['9170303']" />
            </span>
            <span style="margin-right: 10px" v-if="scope.scope.code == '9999'">
              <auth-button :data="scope.scope" :show-btn-ids="['9170304']" />
            </span>
          </div>
        </d2-table>
      </div>
    </d2-container>
    <!-- 冲红 -->
    <RedDialog :redVisible="redVisible" v-if="redVisible" :redInfo="redInfo" @handleRedClose="handleRedClose"></RedDialog>
  </div>
</template>

<script>
import { Util, deepClone } from '@/common/util'
import { mapActions, mapState } from 'vuex'
import { redCodeOpt } from "@/common/constants.js"
import {
  getInvoiceRedList,
  downloadZip,
  mergePdf
} from "@api/invoiceManage"
import RedDialog from './components/RedDialog'
import reportTrackFunMixin from '@/mixins/reportTrackFunMixin'
export default {
  name: 'invoiceRedManage',
  mixins: [reportTrackFunMixin], // 导入混入
  components: {
    RedDialog
  },
  data() {
    return {
      userInfo: this.$store.state.d2admin.user.info,
      labelWidth: '120px',
      searchForm: {
        electronicInvoiceNo: '',
        pushData: [],
        code: '',
        tradeNo: '',
        buyerName: ''
      },
      searchFormSearch: {},
      showFormData: [{
        label: '数电票号码',
        name: 'electronicInvoiceNo',
        type: 'input',
        maxlength: '50',
        isClear: true
      }, {
        label: '填开日期',
        name: 'pushData',
        type: 'datePicker',
        isClear: true,
        pickerOptions: 'rangePickerOptions'
      }, {
        label: "状态",
        name: "code",
        type: "select",
        isClear: true,
        optionList: [],
        optionId: "confId",
        optionLabel: "confValue",
        optionsName: "redCodeOpt"
      }, {
        label: '主订单号',
        name: 'tradeNo',
        type: 'input',
        maxlength: '50',
        isClear: true
      }, {
        label: '购买方名称',
        name: 'buyerName',
        type: 'input',
        maxlength: '50',
        isClear: true
      }],
      getListApi: getInvoiceRedList,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        mutiSelectUniqueKey: 'id',
        mutiSelectName: 'transferAccounts',
        tableOption: { width: '200px' },
        tableColumns: [{
          label: '状态',
          prop: 'code',
          width: '120px',
          formatter: (cellValue) => {
            return this.baseData.redCodeOpt.find(item => item.confId === cellValue.code)?.confValue
          },
          className: (cellValue) => {
            return {
              '9999': 'redSpot',
              '0000': 'greenSpot',
              '7777': "yellowSpot",
              '4999': "ashSpot",
              '5999': "deepBlueSpot"
            }[cellValue.code]
          }
        }, {
          label: '数电票号码',
          prop: 'electronicInvoiceNo',
          width: '200px'
        }, {
          label: '填开日期',
          prop: 'pushDate',
          width: '180px'
        }, {
          label: '购买方名称',
          prop: 'buyerName'
        },
        {
          label: "主订单号",
          prop: "tradeNo",
          width: "200"
        }, {
          label: "失败原因",
          prop: "failReason"
        }]
      },
      baseData: {
        redCodeOpt: deepClone(redCodeOpt),
      },
      recordInfo: null,
      redVisible: false,
      redInfo: {}
    }
  },
  computed: {
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList
    })
  },
  mounted() {
    this.getBaseData()
    this.onPageShow()
  },
  beforeDestroy() {
    this.onPageHide()
  },

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

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

    getParams() {
      var params = deepClone(this.searchForm)
      const dateFormatList = [{
        attr: 'pushData',
        startAttr: 'pushDateStart',
        endAttr: 'pushDateEnd',
      }]
      dateFormatList.forEach(item => {
        if (params[item.attr] && params[item.attr].length) {
          params[item.startAttr] = Util.dateFormate(params[item.attr][0], 'YYYY-MM-DD 00:00:00')
          params[item.endAttr] = Util.dateFormate(params[item.attr][1], 'YYYY-MM-DD 23:59:59')
          delete params[item.attr]
        }
      })
      return params
    },

    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchFormSearch = this.getParams()
        resolve()
      })
    },

    getOptionsList() {
      this.showFormData.forEach((item, index) => {
        if (item.type === 'select') {
          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.redTable.refreshTable(false, true)
    },
    handleReset() {
      this.searchForm = {
        electronicInvoiceNo: '',
        pushData: [],
        code: '',
        tradeNo: '',
        buyerName: ''
      }
      this.$refs.redTable.refreshTable(false, true)
    },

    handleExport() {
      var params = this.getParams()
      // 去除为null的值
      for (const key in params) {
        if (params[key] === null || params[key] === '' || params[key].length == 0) {
          delete params[key]
        }
      }
      params.method = 'dj.smartcarlife.api.vpt.invoiceInfo.red.export.async'
      const list = [
        ...this.dowloadList,
        {
          name: '发票冲红查询导出',
          exportParam: JSON.stringify(params),
          status: 'waiting',
          timeid: new Date().getTime()
        }
      ]
      this.actionSetDownloadList({ list, type: 'dowloadList' })
    },

    handleRedClose() {
      this.redVisible = !this.redVisible
    },

    // 冲红
    handleRed(row) {
      console.log(row)
      this.redInfo = row
      this.handleRedClose()
    },

    // 查看蓝票
    handleDetailBlue(row) {
      if (row.blueInvoiceDownloadUrl) {
        window.open(row.blueInvoiceDownloadUrl)
      }
    },

    // 查看红票
    handleDetailRed(row) {
      if (row.redInvoiceDownloadUrl) {
        window.open(row.redInvoiceDownloadUrl)
      }
    }

  }
}

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

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

.tableHeaderBtn {
  margin-left: 10px;
}
.importResult-1 {
  width: 100%;
  height: 40px;
  background: #fff3e8;
  color: #ff8d1a;
  font-size: 14px;
  display: flex;
  align-items: center; /* 垂直居中 */
  .importResult-1-font {
    margin-left: 20px;
  }
}
.importResult-2 {
  width: 100%;
  height: 40px;
  background: #d4deef;
  color: #2a58ad;
  font-size: 14px;
  display: flex;
  align-items: center; /* 垂直居中 */
  .importResult-2-font {
    margin-left: 20px;
  }
}
</style>