<template>
  <!-- 放款登记 -->
  <div>
    <dialog-edit width="95%"
      :visible.sync="dialogVisible"
      :form="submitForms"
      :autoSave="autoSave"
      :editModel="editModel"
      :api="api"
      :appendToBody="appendToBody"
      :title="$t('bankPay.addTitle')"
      @onSaved="handleSubmit"
      :saveLabel="$t('bankPay.confirmbtn')"
    >
      <div class="assetpkgmgr-box" v-loading="assetpkgmgrButtonLoading">
        <!-- 基础信息 -->
        <div class="viewForm">
          <dym-form :formValue.sync="forms" :componentList="baseInfo"></dym-form>
        </div>
        <dividerTitle :title="$t('bankPay.inputSelect')"></dividerTitle>
        <!-- 搜索栏 -->
        <div class="viewForm">
          <search-form
            :formValue.sync="queryParas"
            searchPerms="search"
            @handleFilter="handleFilter"
            @clearParam="clearParam"
            resetPerms="reset"
            :componentList="componentList"
            :isShowFoldBtn="false"
          ></search-form>
          <dividerTitle :title="$t('bankPay.payCodeList')"></dividerTitle>
        </div>
        <!-- 表格列表 -->
        <data-table
          ref="dataTable"
          :operateBtnLayout="operateBtnLayout"
          :selectable="false"
          :maxheight="200"
          :showSelection="true"
          :queryParas="queryParas"
          :sourceData="modifyData"
          :toolMenuFlag="toolMenuFlag"
          :columns="modifyColumns"
          :showPage="true"
          :loadCount.sync="loadCount"
          :menuFlag="menuFlag"
          @getTableData="getTableData"
          @selectRowChange="selectRowChange"
          @sizeChange="handleFilter"
          @currentChange="handleFilter"
        >
          <!-- 表格头部操作栏 -->
          <template slot="headButton">
            <div class="flex-spaceB" style="margin-bottom: 10px;">
              <!-- 提交表单 -->
              <dym-form
                :formValue.sync="submitForms"
                :componentList="submitForm"
                class="submitForm"
              ></dym-form>
              <!-- 批量上传回单 -->
              <btn-batch-upload
                :uploadApi="batchUploadApi"
                :btnDisplay="true"
                btnSize="medium"
                :openPerms="false"
                :batchUploadName="$t('bankPay.registersCreate')"
                @uploadSuccess="batchUploadSuccess"
              ></btn-batch-upload>
            </div>
          </template>
          <!-- 单行操作栏 -->
          <el-table-column
            align="center"
            min-width="150px"
            :label="$t('common.operate')"
            fixed="right"
          >
            <template slot-scope="scope">
              <!-- 上传回单 -->
              <el-upload
                style="display:inline-block;margin: 0 9px 0 1px;"
                :action="uploadApi"
                :accept="null"
                :show-file-list="false"
                :on-success="e => uploadSuccess(e,scope.row)"
                :before-upload="e => beforeUpload(e,scope.row)"
                :headers="headers"
                :data="sendData">
                <auth-button class="iconCircle" icon="iconfont iconshangchuan1" :title="scope.row.receiptStatus === '1' ? $t('bankPay.reCreate') : $t('bankPay.registerCreate')"></auth-button>
              </el-upload>
              <!-- 下载 -->
              <btn-batch-download :downloadFileName="scope.row.assetCode + '.zip'" v-if="scope.row.receiptFileIds && scope.row.receiptFileIds.length > 1 && computeFile(scope.row.receiptFileIds)" :fileID="scope.row.receiptFileIds" :title="$t('common.downLoad')"></btn-batch-download>
              <!-- <btn-download v-if="scope.row.receiptFileIds && scope.row.receiptFileIds.length === 1 && computeFile(scope.row.receiptFileIds)" :fileID="scope.row.receiptFileIds" :title="$t('common.downLoad')"></btn-download> -->
              <auth-button
                class="iconCircle"
                icon="iconfont iconxiazai"
                :title="$t('common.downLoad')"
                @click="downLoad(scope.row)"
                 v-if="scope.row.receiptFileIds && scope.row.receiptFileIds.length === 1 && computeFile(scope.row.receiptFileIds)"
              ></auth-button>
            </template>
          </el-table-column>
        </data-table>
      </div>
    </dialog-edit>
  </div>
</template>

<script>
import BaseEdit from '@/pages/baseEditPage'
import * as format from '@/filters/index.js'
import fileApi from '@/api/fileApi.js'
import { downFile, getPara } from '@/utils/devUtils'
import {
  DialogEdit,
  DataTable,
  authButton,
  dymForm,
  btnBatchUpload,
  btnUpload,
  BaseSelect,
  btnBatchDownload,
  btnDownload,
  searchForm
} from 'newepoch-components'
import { BATCH_UPLOAD_API, UPLOAD_API } from '@/constant'
import bankPay from '@/api/assetpkgmgr/bankPayApi.js'
// import external from '@/api/assetpkgmgr/externalApi.js'
import dividerTitle from '@/components/element/assetpkgmgr/dividerTitle'

export default {
  extends: new BaseEdit(),
  name: 'bankPayRegisterPop',
  components: {
    DialogEdit,
    DataTable,
    dividerTitle,
    dymForm,
    authButton,
    btnBatchUpload,
    btnUpload,
    btnBatchDownload,
    btnDownload,
    searchForm
  },
  props: {
    autoSave: {
      type: [Boolean],
      default: false
    },
    currentRow: {
      type: [Object],
      default () {
        return null
      }
    }
  },
  data () {
    let $this = this
    return {
      batchUploadApi: BATCH_UPLOAD_API, // 批量上传api
      uploadApi: UPLOAD_API, // 上传api
      isZip: /\.zip/, // 压缩文件正则
      showPage: false,
      appendToBody: true,
      toolMenuFlag: true,
      loadCount: 0,
      menuFlag: false,
      operateBtnLayout: '',
      queryParas: {},
      selectRows: [], // 选中项
      modifyData: [],
      contactData: [],
      forms: {},
      submitForms: {},
      componentList: [
        {
          // 付款确认书编号
          label: this.$i18n.messages[this.$i18n.locale].bankPay.payCode,
          disabled: false,
          value: 'assetCode',
          placeholder: this.$i18n.messages[this.$i18n.locale].common
            .pleaseInput,
          labelWidth: '120px',
          clearable: true,
          componentName: 'el-input'
        },
        {
          // 供应商
          label: this.$i18n.messages[this.$i18n.locale].bankPay.suppliersName,
          disabled: false,
          value: 'creditor',
          placeholder: this.$i18n.messages[this.$i18n.locale].common
            .pleaseInput,
          labelWidth: '120px',
          clearable: true,
          componentName: 'el-input'
        },
        {
          // 是否已放款登记
          label: this.$i18n.messages[this.$i18n.locale].bankPay.isRegister,
          disabled: false,
          value: 'packagePayStatus',
          placeholder: this.$i18n.messages[this.$i18n.locale].common
            .pleaseInput,
          labelWidth: '120px',
          clearable: true,
          options: [
            {
              id: '0',
              name: this.$t('common.no')
            },
            {
              id: '1',
              name: this.$t('common.yes')
            }
          ],
          componentName: BaseSelect
        },
        {
          // 是否已上传回单
          label: this.$i18n.messages[this.$i18n.locale].bankPay
            .receiptStatusText,
          disabled: false,
          value: 'receiptStatus',
          placeholder: this.$i18n.messages[this.$i18n.locale].common
            .pleaseInput,
          labelWidth: '120px',
          clearable: true,
          options: [
            {
              id: '0',
              name: this.$t('common.no')
            },
            {
              id: '1',
              name: this.$t('common.yes')
            }
          ],
          componentName: BaseSelect
        }
      ],
      // 上传请求头
      headers: {
        Authorization: 'Bearer ' + this.$store.getters.token,
        token: this.$store.getters.token,
        tenantId: this.$store.getters.tenantId,
        client: this.$store.getters.sysId
      },
      // 上传配置参数
      sendData: {
        belongCode: 'GYS',
        belongID: null
      },
      submitForm: [
        {
          // 实际放款日期(供应商)
          label: this.$i18n.messages[this.$i18n.locale].bankPay
            .factualDisbursementDateTwo,
          disabled: false,
          value: 'loanDateFactoring',
          prop: 'loanDateFactoring',
          placeholder: this.$i18n.messages[this.$i18n.locale].common
            .pleaseSelect,
          labelWidth: '150px',
          cols: [12, 12, 12, 10],
          clearable: true,
          pickerOptions: {
            disabledDate: function () {
              return true
            }
          },
          componentName: 'el-date-picker'
        },
        {
          // 实际放款日期(保理商)
          label: this.$i18n.messages[this.$i18n.locale].bankPay
            .factualDisbursementDate,
          disabled: false,
          value: 'loanDateBank',
          prop: 'loanDateBank',
          placeholder: this.$i18n.messages[this.$i18n.locale].common
            .pleaseSelect,
          labelWidth: '150px',
          cols: [12, 12, 12, 10],
          clearable: true,
          pickerOptions: {
            disabledDate: function () {
              return true
            }
          },
          componentName: 'el-date-picker'
        }
      ],
      baseInfo: [
        {
          // 产品名称
          label: this.$i18n.messages[this.$i18n.locale].bankPay.projectName,
          disabled: true,
          value: 'projectName',
          prop: 'projectName',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.noForm,
          labelWidth: '140px',
          cols: [12, 12, 12, 8],
          clearable: true,
          componentName: 'el-input'
        },
        {
          // 再保理银行
          label: this.$i18n.messages[this.$i18n.locale].bankPay.factorBankName,
          disabled: true,
          value: 'factorBankName',
          prop: 'factorBankName',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.noForm,
          labelWidth: '140px',
          cols: [12, 12, 12, 8],
          clearable: true,
          componentName: 'el-input'
        },
        {
          // 核心企业
          label: this.$i18n.messages[this.$i18n.locale].bankPay.importantFirm,
          disabled: true,
          value: 'coreEnterpriseName',
          prop: 'coreEnterpriseName',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.noForm,
          labelWidth: '140px',
          cols: [12, 12, 12, 8],
          clearable: true,
          componentName: 'el-input'
        },
        {
          // 再保理总金额
          label: this.$i18n.messages[this.$i18n.locale].bankPay
            .factoringMoneyTotal,
          disabled: true,
          value: 'factoringMoneyTotal',
          prop: 'factoringMoneyTotal',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.noForm,
          labelWidth: '140px',
          cols: [12, 12, 12, 8],
          clearable: true,
          componentName: 'el-input'
        },
        {
          // 资产包编码
          label: this.$i18n.messages[this.$i18n.locale].bankPay
            .assetPackageCode,
          disabled: true,
          value: 'assetPackageCode',
          prop: 'assetPackageCode',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.noForm,
          labelWidth: '140px',
          cols: [12, 12, 12, 8],
          clearable: true,
          componentName: 'el-input'
        },
        {
          // 到账日期
          label: this.$i18n.messages[this.$i18n.locale].bankPay.dueDate,
          disabled: true,
          value: 'dueDate',
          prop: 'dueDate',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.noForm,
          labelWidth: '140px',
          cols: [12, 12, 12, 8],
          clearable: true,
          componentName: 'el-input',
          format: row => {
            return format.formatDateTpcModify(row.dueDate)
          }
        }
      ],
      modifyColumns: [
        // 付款确认书编号
        {
          prop: 'assetCode',
          align: 'center',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].bankPay.payCode,
          width: '250px'
        },
        // 供应商
        {
          prop: 'creditor',
          headerAlign: 'center',
          align: 'left',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].bankPay.suppliersName,
          width: '200px'
        },
        // 区域
        {
          prop: 'coreAreaName',
          headerAlign: 'center',
          align: 'left',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].bankPay.district,
          width: '100px'
        },
        // 项目公司名称
        {
          prop: 'debtor',
          headerAlign: 'center',
          align: 'left',
          showOverflowTooltip: true,
          label: this.$i18n.messages[this.$i18n.locale].bankPay.enterpriseName,
          width: '200px'
        },
        {
          // 应收账款金额（元）
          prop: 'factoringMoney',
          headerAlign: 'center',
          align: 'right',
          showOverflowTooltip: true,
          width: '171px',
          label: this.$i18n.messages[this.$i18n.locale].bankPay.totalPrice,
          format: row => {
            return format.thousandFilter(row.factoringMoney)
          }
        },
        {
          // 账款到期日
          prop: 'dueDate',
          align: 'center',
          width: '115px',
          label: this.$i18n.messages[this.$i18n.locale].bankPay.dueDate,
          format: row => {
            return format.formatDateTpcModify(row.dueDate)
          }
        },
        {
          // 实际放款日期(供应商)
          prop: 'loanDateFactoring',
          align: 'center',
          width: '160px',
          label: this.$i18n.messages[this.$i18n.locale].bankPay
            .factualDisbursementDateTwo,
          format: row => {
            return format.formatDateTpcModify(row.loanDateFactoring)
          }
        },
        {
          // 实际放款日期(保理商)
          prop: 'loanDateBank',
          align: 'center',
          width: '160px',
          label: this.$i18n.messages[this.$i18n.locale].bankPay
            .factualDisbursementDate,
          format: row => {
            return format.formatDateTpcModify(row.loanDateBank)
          }
        },
        // 给供应商金额
        {
          prop: 'loanAmountFactoring',
          align: 'right',
          showOverflowTooltip: true,
          headerAlign: 'center',
          label: this.$i18n.messages[this.$i18n.locale].bankPay.suppliersPrice,
          width: '150px',
          format: row => {
            return format.thousandFilter(row.loanAmountFactoring)
          }
        },
        // 是否需自垫付
        {
          prop: 'selfPayFlag',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].bankPay.isPayInOwe,
          width: '130px',
          format (row) {
            return row.selfPayFlag === '1'
              ? $this.$t('common.yes')
              : row.selfPayFlag === '0' ? $this.$t('common.no') : ''
          }
        },
        // 是否已自垫付
        {
          prop: 'selfPaidFlag',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].bankPay.isPayedInOwe,
          width: '130px',
          format: row => {
            return row.selfPaidFlag === '1'
              ? $this.$t('common.yes')
              : row.selfPaidFlag === '0' ? $this.$t('common.no') : ''
          }
        },
        // 是否已放款登记
        {
          prop: 'packagePayStatus',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].bankPay.isRegister,
          width: '130px',
          format: row => {
            return row.packagePayStatus === '1'
              ? $this.$t('common.yes')
              : row.packagePayStatus === '0' ? $this.$t('common.no') : ''
          }
        },
        // 是否已上传回单
        {
          prop: 'receiptStatus',
          align: 'center',
          label: this.$i18n.messages[this.$i18n.locale].bankPay
            .receiptStatusText,
          width: '130px',
          format: row => {
            return row.receiptStatus === '1'
              ? $this.$t('common.yes')
              : row.receiptStatus === '0' ? $this.$t('common.no') : ''
          }
        }
      ],
      fileSize: 50,
      dueDate: 0, // 账款到期日
      pageSize: 10 // 页码
    }
  },
  computed: {
    api () {
      return bankPay.bankPay
    }
  },
  methods: {
    // 文件列表判空
    computeFile (e) {
      for (let index in e) {
        let item = e[index]
        if (item < 1) {
          return false
        }
      }
      return true
    },
    // 表格列表处理
    getTableData (e) {
      this.modifyData = e.datas
    },
    // 重置搜索表单
    clearParam () {
      this.queryParas = {
        keyId: this.currentRow.keyId,
        pageSize: this.pageSize,
        pageIndex: 1
      }
    },
    // 处理日期选择范围
    checkChange (e, t) {
      let dueDate = e
      // console.log(this.forms)
      // 使选择日期不能超过账款到期日
      if (dueDate) {
        this.submitForm[0].pickerOptions = {
          disabledDate: function (time) {
            return time.getTime() > dueDate
          }
        }
        this.submitForm[1].pickerOptions = {
          disabledDate: function (time) {
            return time.getTime() > dueDate
          }
        }
      } else {
        this.submitForm[0].pickerOptions = {
          disabledDate: function () {
            return true
          }
        }
        this.submitForm[1].pickerOptions = {
          disabledDate: function () {
            return true
          }
        }
      }
    },
    // 上传文件之前回调
    beforeUpload (file, row) {
      return new Promise((resolve, reject) => {
        this.$nextTick(() => {
          // let fileName = file.name.slice(0, file.name.indexOf('.')) // 文件名
          // 限制上传大小
          if (!this.UtilJs.isNull(this.fileSize) && file.size / 1024 > this.fileSize * 1024) {
            this.warning(`已超出上传文件最大限制${this.fileSize}M`)
            return false
          }
          // 文件名是否和付款确认书一致
          // if (fileName === row.assetCode) {
          const zip = /\.zip/
          let isZip = zip.test(file.name)
          // 判断上传的文件类型，若是压缩包则批量上传
          this.uploadApi = isZip ? BATCH_UPLOAD_API : UPLOAD_API
          resolve()
          // } else {
          //   this.warning(this.$t('bankPay.payCodePrompt'))
          //   reject(this.$t('bankPay.payCodePrompt'))
          // }
        })
      })
    },
    // 上传回单
    uploadSuccess (returnData, row) {
      // console.log(returnData.data)
      let $this = this
      // 配置请求参数
      let params = {
        assetCode: row.assetCode,
        assetPackageCode: $this.currentRow.assetPackageCode,
        fileDTO: returnData.data instanceof Array ? returnData.data.map(item => {
          return {
            fileName: item.fileName,
            keyId: item.keyId
          }
        }) : [{
          fileName: returnData.data.fileName,
          keyId: returnData.data.keyId
        }]
      }
      $this.api.upload(params).then(res => {
        if (res.success && res.data) {
          $this.success($this.$t('common.uploadSuccess'))
          $this.handleFilter()
          $this.$parent.loadCount++
        }
      })
    },
    // 批量上传回单
    batchUploadSuccess (returnData) {
      let $this = this
      let params = {
        assetPackageCode: $this.currentRow.assetPackageCode,
        fileDTO: returnData.fileList.map(item => {
          return {
            fileName: item.fileName,
            keyId: item.keyId
          }
        })
      }
      $this.api.batchUpload(params).then(res => {
        if (res.success && res.data) {
          $this.success($this.$t('common.uploadSuccess'))
          // 重置表格
          $this.handleFilter()
          $this.$parent.loadCount++
        }
      })
    },
    // 下载
    downLoad (b) {
      // 批量下载
      fileApi.file.download({ keyId: b.receiptFileIds[0] }).then(res => {
        let filename = getPara(res.headers['content-disposition'], 'filename')
        filename = filename.slice(filename.indexOf('.'))
        downFile(res, b.assetCode + filename)
      })
    },
    // 选中单行
    selectRowChange (selectRows) {
      this.selectRows = selectRows
    },
    // 提交表单
    handleSubmit (form) {
      let $this = this
      // 实际放款日期(供应商)，实际放款日期(保理商)必须输入一个
      if (form.loanDateFactoring || form.loanDateBank) {
        // 是否有选中资产
        if ($this.selectRows.length > 0) {
          const h = this.$createElement
          // 已开票资产
          let openInvoiceAssetCodes = []
          let openInvoiceAssetCode = []
          for (let index in $this.selectRows) {
            let item = $this.selectRows[index]
            // openInvoiceStatus:21 已开部分电子票;22 已开电子票;23 已开纸质票
            if (item.openInvoiceStatus === '21' || item.openInvoiceStatus === '22' || item.openInvoiceStatus === '23') {
              openInvoiceAssetCode.push(item.assetCode)
            }
          }
          // 若有开票资产
          if (openInvoiceAssetCode.length > 0) {
            openInvoiceAssetCodes.push(h('span', { style: 'word-break: break-all' }, `资产[${openInvoiceAssetCode.join('，')}]`))
            openInvoiceAssetCodes.push(h('span', { style: 'color: red' }, '已开票，不能进行放款登记！'))
            this.$msgbox({
              title: this.$t('common.tip'),
              message: h('p', null, openInvoiceAssetCodes),
              callback: action => {}
            })
            // $this.warning(`资产[${openInvoiceAssetCodes.join(',')}]已开票，不能进行放款登记！`)
            return
          }
          // 初始化提交表单
          let submitForm = {}
          // 添加付款确认书编号
          submitForm.assetPackageCode = $this.currentRow.assetPackageCode

          /* 放款金额（供应商）＝应收账款金额－（应收账款金额 * （账款到期日 - 实际放款日期（供应商））/ 360 *供应商利率）；
          放款金额（保理商）＝应收账款金额－（应收账款金额 * （账款到期日 - 实际放款日期（保理商））/ 360 *银行服务费率－（应收账款金额 * 银行管理费率）；
          保理商收益＝放款金额（保理商）－放款金额（供应商）； */

          // 应收账款金额
          // let total = $this.selectRows
          //   .map(item => {
          //     return Number(item.factoringMoney)
          //   })
          //   .reduce((t, num) => {
          //     return t + num
          //   })
          // 实际放款日期(保理商)
          let loanDateBank = form.loanDateBank
          // 实际放款日期(供应商)
          let loanDateFactoring = form.loanDateFactoring
          for (let index in $this.selectRows) {
            // 选中项
            let item = $this.selectRows[index]
            // 应收账款金额
            let total = item.factoringMoney
            // 账款到期日
            let dueDate = Number(item.dueDate)
            // 放款金额(保理商)
            let loanAmountBank = 0
            // 放款金额(供应商)
            let loanAmountFactoring = 0
            // 计算系数
            let day = $this.forms.day
            // 已选中实际放款日期(保理商),若没有则取本身放款日期
            loanDateBank = loanDateBank || new Date(Number(item.loanDateBank))
            if (loanDateBank) {
              // 放款金额(保理商)计算
              let date1 =
                total * ((dueDate - loanDateBank.getTime()) / (1000 * 60 * 60 * 24) / day * ($this.forms.serviceMoney / 100)) + total * ($this.forms.manageMoney / 100)
              // 放款金额(保理商)
              loanAmountBank = total - date1
              // 添加到表单里
              item.loanAmountBank = loanAmountBank.toFixed(2)
              // item.loanDateBank = loanDateBank.getTime().toString()
              submitForm.loanDateBank = loanDateBank.getTime().toString()
            } else if (item.loanDateBank && item.loanAmountBank) {
              loanAmountBank = item.loanAmountBank
            }
            // 已选中实际放款日期(供应商),若没有则取本身放款日期
            loanDateFactoring = loanDateFactoring || new Date(Number(item.loanDateFactoring))
            if (loanDateFactoring) {
              // 放款金额(供应商)计算
              let date2 =
                total *
                (dueDate - loanDateFactoring.getTime()) / (1000 * 60 * 60 * 24) / day * item.supplierInterestRate
              // 放款金额(供应商)
              loanAmountFactoring = total - date2
              // 添加到表单里
              item.loanAmountFactoring = loanAmountFactoring.toFixed(2)
              submitForm.loanDateFactoring = loanDateFactoring.getTime().toString()
            } else if (item.loanDateFactoring && item.loanAmountFactoring) {
              loanAmountFactoring = item.loanAmountFactoring
            }
            // 是否已上传放款金额(供应商)
            if (!loanAmountFactoring && item.loanAmountFactoring) {
              // 放款金额(供应商)
              loanAmountFactoring = item.loanAmountFactoring
            }
            // 是否已上传放款金额(保理商)
            if (!loanAmountBank && item.loanAmountBank) {
              // 放款金额(保理商)
              loanAmountBank = item.loanAmountBank
            }
            // 放款金额(保理商)和放款金额(供应商)都存在计算收益
            if (loanAmountBank && loanAmountFactoring) {
              item.factoringProfit = (loanAmountBank - loanAmountFactoring).toFixed(2)
            }
          }
          submitForm.datas = $this.selectRows
          // 提交表单
          $this.assetpkgmgrFullScreenLoading()
          $this.api.confirm(submitForm).then(res => {
            $this.assetpkgmgrFullScreenLoading().close()
            if (res.success) {
              $this.success(
                $this.$t('bankPay.register') + $this.$t('common.successfully')
              )
              $this.$parent.loadCount++
              $this.dialogVisible = false
            }
          }).catch(res => {
            $this.assetpkgmgrFullScreenLoading().close()
          })
        } else {
          $this.warning($this.$t('common.selectOperateTip'))
        }
      } else {
        $this.warning($this.$t('bankPay.comfirmPrompt'))
      }
    },
    handleFilter () {
      let $this = this
      $this.assetpkgmgrButtonLoading = true
      bankPay.detail.getPage($this.queryParas).then(res => {
        if (res.success && res.data) {
          $this.forms = res.data
          $this.dueDate = res.data.dueDate
          $this.checkChange(res.data.dueDate)
          $this.forms.dueDate = format.formatDateTpcModify(res.data.dueDate)
          $this.forms.factoringMoneyTotal = format.thousandFilter(res.data.factoringMoneyTotal)
          $this.$refs.dataTable.buildTableData(res.data.datas.datas, res.data.datas.totalRow)
        }
        $this.assetpkgmgrButtonLoading = false
      }).catch(res => {
        $this.assetpkgmgrButtonLoading = false
      })
    }
  },
  watch: {
    visible (val) {
      if (val) {
        let $this = this
        // 重置表单初始化
        $this.submitForms = {}
        $this.modifyData = []
        $this.forms = {}
        // 配置请求参数
        $this.clearParam()
        $this.handleFilter()
      }
    }
  }
}
</script>

<style lang="scss" scoped>
@import "~@/styles/assetpkgmgr/common.scss";
</style>
