<template>
  <div>
    <ShrinkBox>
      <span slot="title">付款准备明细</span>
      <ul>
        <li
          v-for="(item, idk) in detailList"
          :key="item.payWay"
          style="margin: 15px 0 0;"
        >
          <div class="t-title">
            <Icon type="arrow-right-a"></Icon>
            <span>{{ item.payWayName }}</span>
          </div>
          <Tabs
            type="card"
            @on-click="changeTabs"
          >
            <TabPane
              v-for="(tabsItem,index) in item.tabs"
              :ref="item.payWay+'_'+tabsItem.key"
              :key="tabsItem.name+index"
              :name="item.payWay+'-'+tabsItem.key+':'+item.payWayName+tabsItem.name"
            >
              <EMSTable
                :ref="item.payWayName+tabsItem.name+'-'+item.payWay+'-'+tabsItem.key"
                :server="server"
                action="getPayLineDetailInfo"
                :initParam="applyParamsArr[idk]"
                :params="applyParamsArr[idk]"
                :columns="accounGroupColumns(item.payWayName,tabsItem.name)"
                :autoFirst="true"
                :autoFill="false"
                @on-selection-change="getSelections(item.payWayName,tabsItem.name,item.payWay,tabsItem.key)"
              >
                <!-- <div slot="footer-bar">
                  <Button :loading="false" :ref="item.payWayName+tabsItem.name+buttonItem.name" v-for="buttonItem in tabsItem.buttons" :key="buttonItem.key" @click="payDetailClick(item.payWayName,tabsItem.name,buttonItem.name,item.payWay,tabsItem.key)">{{buttonItem.name}}</Button>
                </div> -->
              </EMSTable>
            </TabPane>
          </Tabs>
        </li>
      </ul>
    </ShrinkBox>
  </div>
</template>
<script>
import accounting from 'accounting';
import { mapState } from 'vuex';
import Server from '../server.js';
import RefuseContent from './RefuseContent.vue';
import OperatorInfo from './OperatorInfo.vue';
import FileUpload from './file/File.vue';
import FailPayModel from './failPayModel/index.vue';
import { Cashier } from '@paymentPlatformComps/index.js';
import Popup from './popup/popup';
let vm;
const server = new Server();

export default {
  components: {
    // RefuseContent,
    // OperatorInfo,
    // FileUpload,
    // Popup,
    // FailPayModel
  },
  props: {
    batchId: {
      type: String,
      default() {
        return '';
      }
    }
  },
  data() {
    return {
      tabsNameArr: {},
      selectionData: {},
      server: server,
      activeTab: '',
      detailList: [],
      applyParams: {
        batchId: this.batchId,
        payWay: '',
        tab: '1'
      },
      applyParamsArr: [], // 与detailList一一对应
      infoData: {},
      isCanEdit: '0',
      isUploadLocal: {},
      params: {}
    };
  },
  computed: {
    ...mapState('createPaymentPreparation', {
      basicInfo: state => state.basicInfo,
      tableData: state => state.paymentPreparationInfo.preparationInfo,
      applyPayExpandList: state =>
        state.paymentPreparationInfo.preparationInfo.applyPayExpandList,
      selections: state => state.paymentSelects.selections,
      basicInfoComponent: state => state.basicInfoComponent,
      paymentApplyInfoComponent: state => state.paymentApplyInfoComponent,
      paymentPreparationInfoComponent: state =>
        state.paymentPreparationInfoComponent
    })
  },
  watch: {},
  created: function() {
    vm = this;
    vm.init();
    // vm.isDisable();
  },
  beforeMount: function() {},
  mounted: function() {
    window.bb = this;
    // vm = this;
  },
  beforeDestroy: function() {},
  destroyed: function() {},
  methods: {
    init() {
      vm.server.findPayWayConfigAll({ batchId: vm.batchId }).then(response => {
        if (response.data.code == '0') {
          vm.$Message.error(response.data.msg);
        } else {
          // vm.detailList = response.data;
          if (response.data.data.length > 0) {
            vm.applyParamsArr = response.data.data.map((val) => {
              const obj = {
                batchId: vm.batchId,
                payWay: val.payWay,
                tab: val.tabs[0].key
              };
              return obj;
            });
            vm.applyParams.payWay = response.data.data[0].payWay;
            vm.applyParams.tab = response.data.data[0].tabs[0].key;
          }
          // 放在applyParamsArr集成后
          vm.detailList = response.data.data;
          console.log('vm.detailList', vm.detailList);
          vm.isUploadLocal = vm.keyDealActive(response.data.data);

          vm.$nextTick(() => {
            for (let i = 0; i < response.data.data.length; i++) {
              vm.$refs[
                response.data.data[i].payWayName + response.data.data[i].tabs[0].name + '-' + response.data.data[i].payWay + '-' + response.data.data[i].tabs[0].key
              ][0].tableData =
                  response.data.data[i].tabs[0].datas;
              vm.$refs[
                response.data.data[i].payWayName + response.data.data[i].tabs[0].name + '-' + response.data.data[i].payWay + '-' + response.data.data[i].tabs[0].key
              ][0].total =
                  response.data.data[i].tabs[0].datas.length;

              for (let m = 0; m < response.data.data[i].tabs.length; m++) {
                vm.tabsNameArr[
                  response.data.data[i].payWay + '_' + response.data.data[i].tabs[m].key
                ] =
                    response.data.data[i].tabs[m].name;
              }
            }
            // 获取tab右上角数字
            vm.getTabCount(response.data.count);
          });
        }
      });
    },
    keyDealActive(data) {
      const obj = {};
      if (data.length === 0) {
        return {};
      }
      let i = 0;
      let j = 0;
      const len = data.length;
      for (; i < len; i++) {
        const arr = data[i].tabs || [];
        if (arr.length > 1) {
          for (; j < arr.length; j++) {
            if (arr[j].key === 6) {
              obj[data[i].payWay + '-' + arr[j].key] = false;
            }
          }
        } else {
          if (arr[0].key === 6) {
            obj[data[i].payWay + '-' + arr[0].key] = true;
          }
        }
      }
      return obj;
    },
    accounGroupColumns(payWayName, tabsName) {
      return [
        {
          type: 'selection',
          width: 60,
          align: 'center',
          fixed: 'left',
          disabled: 'true'
        },
        {
          title: '付款状态',
          align: 'left',
          width: 140,
          key: 'statusName',
          render: (h, params) => {
            return h(
              'span',
              {
                attrs: {
                  title: params.row.statusName
                }
              },
              params.row.statusName
            );
          }
        },
        {
          title: '付款方式',
          align: 'left',
          width: 120,
          key: 'paymentMethod',
          render: (h, params) => {
            const val = params.row.paymentMethod;
            const list = vm.$store.state.createPaymentPreparation.valueSet.PAYMENT_MODE || [];
            let text = '';
            list.forEach(function(item) {
              if (item.value == val) {
                text = item.label;
                return false;
              }
            });
            return h('div', {}, text);
          }
        },
        {
          title: '付款公司',
          align: 'left',
          width: 150,
          key: 'ouName'
        },
        {
          title: '银行账号名称',
          align: 'left',
          width: 150,
          key: 'payAccountName'
        },
        {
          title: '银行账号',
          align: 'left',
          width: 150,
          key: 'payAccountNo'
        },
        {
          title: '准备付款金额',
          align: 'right',
          width: 150,
          key: 'payAmount',
          render: (h, params) => {
            return h(
              'span',
              {
                attrs: {
                  title: accounting.formatNumber(params.row.payAmount, 2)
                }
              },
              accounting.formatNumber(params.row.payAmount, 2)
            );
          }
        },
        {
          title: '申请金额',
          align: 'right',
          width: 120,
          key: 'applyAmount',
          render: (h, params) => {
            return h(
              'span',
              {
                attrs: {
                  title: accounting.formatNumber(params.row.applyAmount, 2)
                }
              },
              accounting.formatNumber(params.row.applyAmount, 2)
            );
          }
        },
        {
          title: '币种',
          align: 'left',
          width: 120,
          key: 'currency',
          render: (h, params) => {
            const val = params.row.currency;
            const list = vm.$store.state.createPaymentPreparation.valueSet.currency || [];
            let text = '';
            list.forEach(function(item) {
              if (item.value == val) {
                text = item.label;
                return false;
              }
            });
            return h('div', {}, text);
          }
        },
        {
          title: '付款总账凭证批次号',
          align: 'left',
          key: 'payVoucherBatchNo',
          minWidth: 200,
          render: (h, params) => {
            return h(
              'div',
              {
                attrs: {
                  class: 'ivu-table-cell-ellipsis',
                  title: params.row.payVoucherBatchNo
                }
              },
              params.row.payVoucherBatchNo
            );
          }
        },
        {
          title: '付款申请单',
          align: 'left',
          width: 200,
          key: 'claimNo',
          render: (h, params) => {
            return h(
              'span',
              {
                attrs: {
                  title: params.row.claimNo
                }
              },
              params.row.claimNo
            );
          }
        },
        {
          title: '行号',
          align: 'left',
          width: 80,
          key: 'lineNumber',
          render: (h, params) => {
            return h(
              'span',
              {
                attrs: {
                  title: params.row.lineNumber
                }
              },
              params.row.lineNumber
            );
          }
        },
        {
          title: '供应商',
          align: 'left',
          width: 240,
          // key: "vendorName",
          key: 'receiVendorName',
          render: (h, params) => {
            return h(
              'span',
              {
                attrs: {
                  title: params.row.vendorName
                }
              },
              params.row.vendorName
            );
          }
        },
        {
          title: '收款方户名',
          align: 'left',
          width: 240,
          // key: "vendorName",
          key: 'receiVendorName',
          render: (h, params) => {
            return h(
              'span',
              {
                attrs: {
                  title: params.row.receiVendorName
                }
              },
              params.row.receiVendorName
            );
          }
        },
        {
          title: '收款账户',
          align: 'left',
          width: 200,
          // key: "vendorAccountNo",
          key: 'receiVendorAccountNo',
          render: (h, params) => {
            let url = ''; let popopen = {};
            if (params.row.vendorType == 'EMPLOYEE') {
              url = 'getActualEmpInfoByEmployeeId';
              popopen = {
                condition: [
                  {
                    label: '收款账户',
                    type: 'input',
                    name: 'accountEcId',
                    placeholder: '请输入收款账户号',
                    rules: []
                  },
                  {
                    label: '收款账户名称',
                    type: 'input',
                    name: 'accountName',
                    placeholder: '请输入收款账户名称',
                    rules: []
                  }
                ],
                grid: { // popup组件表格项对象
                  action: url, /* ajax url */
                  /* ajax 参数 */
                  params: {
                    // emplid:params.row.vendorCode,
                    emplid: params.row.receiVendorCode,
                    accountEcId: '',
                    accountName: '',
                    effStatus: 'A'
                  },
                  columns: [
                    {
                      type: 'selection',
                      width: 50,
                      align: 'center'
                    },
                    {
                      title: '收款账户',
                      minWidth: 180,
                      render: (h, params) => {
                        return h(
                          'div',
                          {
                            attrs: {
                              class: 'ivu-table-cell-ellipsis',
                              title: params.row.accountEcId
                            }
                          },
                          params.row.accountEcId
                        );
                      }
                    },
                    {
                      title: '收款开户行',
                      // key: "bankName",
                      key: 'crcBankNm',
                      minWidth: 100,
                      render: (h, params) => {
                        return h(
                          'div',
                          {
                            attrs: {
                              class: 'ivu-table-cell-ellipsis',
                              title: params.row.crcBankNm
                            }
                          },
                          params.row.crcBankNm
                        );
                      }
                    },
                    {
                      title: '收款账户名称',
                      key: 'accountName',
                      minWidth: 180
                    }
                  ]
                }
              };
            // }else if(params.row.vendorType=='PROVIDER'){
            } else {
              url = 'getVendors';
              popopen = {
                condition: [
                  {
                    label: '收款账户',
                    type: 'input',
                    name: 'vendorAccountNo',
                    placeholder: '请输入收款账户号',
                    rules: []
                  },
                  {
                    label: '收款账户名称',
                    type: 'input',
                    name: 'vendorAccountName',
                    placeholder: '请输入收款账户名称',
                    rules: []
                  }
                ],
                grid: { // popup组件表格项对象
                  action: url, /* ajax url */
                  /* ajax 参数 */
                  params: {
                    buCode: vm.basicInfo.buCode,
                    companyCode: vm.basicInfo.ouCode,
                    vendorType: params.row.vendorType,
                    vendorCode: params.row.receiVendorCode,
                    vendorAccountNo: '',
                    vendorAccountName: ''
                  },
                  columns: [
                    {
                      type: 'selection',
                      width: 50,
                      align: 'center'
                    },
                    {
                      title: '收款账户',
                      minWidth: 180,
                      render: (h, params) => {
                        return h(
                          'div',
                          {
                            attrs: {
                              class: 'ivu-table-cell-ellipsis',
                              title: params.row.vendorAccountNo
                            }
                          },
                          params.row.vendorAccountNo
                        );
                      }
                    },
                    {
                      title: '收款开户行',
                      key: 'bankName',
                      minWidth: 100,
                      render: (h, params) => {
                        return h(
                          'div',
                          {
                            attrs: {
                              class: 'ivu-table-cell-ellipsis',
                              title: params.row.bankName
                            }
                          },
                          params.row.bankName
                        );
                      }
                    },
                    {
                      title: '收款账户名称',
                      key: 'vendorAccountName',
                      minWidth: 180
                    }
                  ]
                }
              };
            }
            // else{
            //   url = "getThirdPartAccount";
            //   popopen = {
            //       "condition": [
            //       {
            //         "label": "收款账户",
            //         "type": "input",
            //         "name": "accountNo",
            //         "placeholder": "请输入收款账户号",
            //         "rules": []
            //       },
            //       {
            //         "label": "收款账户名称",
            //         "type": "input",
            //         "name": "accountName",
            //         "placeholder": "请输入收款账户名称",
            //         "rules": []
            //       }
            //     ],
            //      "grid": {//popup组件表格项对象
            //       "action": url, /*ajax url*/
            //       /*ajax 参数*/
            //       "params": {
            //           expertCode:params.row.receiVendorCode
            //       },
            //       "columns": [
            //         {
            //           type: "selection",
            //           width: 45,
            //           align: "left"
            //         },
            //         {
            //           title: "收款账户",
            //           minWidth: 180,
            //           render: (h, params) => {
            //             return h(
            //               "div",
            //               {
            //                 attrs: {
            //                   class: "ivu-table-cell-ellipsis",
            //                   title: params.row.accountNo
            //                 }
            //               },
            //               params.row.accountNo
            //             );
            //           }
            //         },
            //         {
            //           title: "收款开户行",
            //           key: "bankName",
            //           minWidth: 100,
            //           render: (h, params) => {
            //             return h(
            //               "div",
            //               {
            //                 attrs: {
            //                   class: "ivu-table-cell-ellipsis",
            //                   title: params.row.bankName
            //                 }
            //               },
            //               params.row.bankName
            //             );
            //           }
            //         },
            //         {
            //           title: "收款账户名称",
            //           key: "accountName",
            //           minWidth: 180
            //         },
            //       ]
            //     },
            //   }
            // }
            return h(Popup, {
              props: {
                server: vm.server,
                // "disabled": params.row.statusName =="准备付款"?false:true,
                disabled: true,
                'v-model': params.row.receiVendorAccountNo,
                popupName: params.row.receiVendorAccountNo,
                placeholder: '请选择收款账户',
                textField: 'receiVendorAccountNo',
                title: '选择收款账户'
              },
              on: {
                'on-focus': (popupthis) => {
                  popupthis.open(popopen);
                },
                selected: (data) => {
                  if (data.length > 0) {
                    var accountData = data[0];
                    let list = {};
                    list = {
                      payLineDetailId: params.row.payLineDetailId,
                      vendorSite: params.row.vendorSite,
                      vendorAccountNo: accountData.accountEcId ? accountData.accountEcId : (accountData.accountNo ? accountData.accountNo : accountData.vendorAccountNo),
                      vendorAccountName: accountData.accountEcId ? accountData.accountName : (accountData.accountNo ? accountData.accountName : accountData.vendorAccountName),
                      vendorAreaCode: accountData.crcAcntArCode ? accountData.crcAcntArCode : (accountData.areaCode ? accountData.areaCode : accountData.cityAreaCode),
                      // "vendorBankId":params.row.vendorBankId,
                      // "vendorCbankCode":params.row.vendorCbankCode,
                      // "vendorAccountType":params.row.vendorAccountType,
                      vendorBankId: accountData.bankId,
                      vendorCbankCode: accountData.cbankCode ? accountData.cbankCode : params.row.vendorCbankCode,
                      vendorAccountType: accountData.accountTypePye ? accountData.accountTypePye : accountData.bankType
                    };
                    vm.server.changeAccountNo(list).then(res => {
                      if (res.code == '0') {
                        vm.init();
                        vm.$Message.error(res.msg);
                      } else {
                        // 暂时屏蔽：因为vm.init()会更新其receiVendorAccountNo值，前面是无用
                        // vm.detailList[0].tabs[0].datas[params.index].receiVendorAccountNo = accountData.accountEcId?accountData.accountEcId:(accountData.accountNo?accountData.accountNo:accountData.vendorAccountNo);
                        vm.init();
                        vm.$Message.success({
                          content: '操作成功',
                          duration: 5
                        });
                      }
                    }).catch(error => {
                      vm.$Message.error({
                        content: `${error.msg}`,
                        duration: 5
                      });
                    });
                  }
                }
              }
            });
          }
        },
        {
          title: '补充单据号',
          align: 'left',
          width: 200,
          key: 'addClaimNo',
          render: (h, params) => {
            return h(
              'Input', {
                props: {
                  'v-model': '',
                  value: params.row.addClaimNo || '',
                  // disabled: vm.isCanEdit == '0' ? false : true,
                  disabled: true,
                  maxlength: 40
                },
                style: {
                  width: '80%',
                  'box-sizing': 'border-box',
                  border: '1px solid #aaa'
                },
                on: {
                  'on-blur': (val) => {
                    // 失去焦点时的发起请求
                    vm.server.supplyBillNumber(
                      {
                        addClaimNo: val.target.value,
                        payLineDetailId: params.row.payLineDetailId
                      }
                    ).then((res) => {
                      if (res.sucess) {
                        this.$Message.success({
                          content: res.msg || '补充单据号成功',
                          duration: 3
                        });
                      } else {
                        this.$Message.warning({
                          content: res.msg || '补充单据号失败',
                          duration: 3
                        });
                      }
                    });
                  }
                }
              }
            );
          }
        },
        {
          title: '供应商账号变更状态',
          align: 'left',
          width: 140,
          key: 'vendorChangeState',
          render: (h, params) => {
            return h(
              'span',
              {
                attrs: {
                  title: params.row.vendorChangeState == '1' ? '已变更' : '未变更'
                }
              },
              params.row.vendorChangeState == '1' ? '已变更' : '未变更'
            );
          }
        },
        {
          title: '初审会计',
          align: 'left',
          width: 120,
          key: 'accountantEmpName',
          render: (h, params) => {
            return h(
              'span',
              {
                attrs: {
                  title: params.row.accountantEmpName
                }
              },
              params.row.accountantEmpName
            );
          }
        },
        {
          title: '支付时间',
          align: 'left',
          width: 300,
          key: 'payTime',
          render: (h, params) => {
            let payTime = params.row.payTime;
            return h('DatePicker', {
              props: {
                value: params.row.payTime,
                transfer: true,
                type: 'datetime',
                confirm: true,
                disabled: true
              },
              on: {
                'on-change': data => {
                  payTime = data;
                },
                'on-ok': () => {
                  // vm.thisTableData[params.index].payTime = payTime;
                  vm.server
                    .updatePayTime({
                      payTime: payTime,
                      payLineDetailId: params.row.payLineDetailId
                    })
                    .then(response => {
                      if (response.code == 0) {
                        vm.$Message.warning({
                          content: `${response.msg}`,
                          duration: 5
                        });
                        // vm.thisTableData[params.index].payTime =
                        //   params.row.payTime;
                      } else {
                        vm.$Message.success({
                          content: '修改成功',
                          duration: 5
                        });
                        // vm.thisTableData[params.index].payTime = payTime;
                      }
                    });
                }
              }
            });
          }
        },

        {
          title: '申请人',
          align: 'left',
          width: 120,
          key: 'applyEmpName',
          render: (h, params) => {
            return h(
              'span',
              {
                attrs: {
                  title: params.row.applyEmpName
                }
              },
              params.row.applyEmpName
            );
          }
        },
        {
          title: '付款备注',
          align: 'left',
          width: 300,
          key: 'remark',
          render: (h, params) => {
            // return h(
            //   "span",
            //   {
            //     attrs: {
            //       title: params.row.remark
            //     }
            //   },
            //   params.row.remark
            // );
            const isBooleans = vm.isUploadLocal[params.row.payWay + '-' + 6];
            return h(
              'Input', {
                props: {
                  'v-model': '',
                  value: params.row.remark || '',
                  disabled: !isBooleans,
                  maxlength: 1000
                },
                style: {
                  width: '80%',
                  'box-sizing': 'border-box',
                  border: '1px solid #aaa'
                },
                on: {
                  'on-blur': (val) => {
                    // 失去焦点时的发起请求
                    vm.server.supplyBillNumber(
                      {
                        remark: val.target.value,
                        payLineDetailId: params.row.payLineDetailId
                      }
                    ).then((res) => {
                      if (res.sucess) {
                        this.$Message.success({
                          content: res.msg || '付款备注添加成功',
                          duration: 3
                        });
                      } else {
                        this.$Message.warning({
                          content: res.msg || '付款备注添加失败',
                          duration: 3
                        });
                      }
                    });
                  }
                }
              }
            );
          }
        },
        {
          title: '结算号',
          align: 'left',
          width: 120,
          key: 'settlementNum',
          render: (h, params) => {
            if (tabsName == '待支付(本地)') {
              return h('Input', {
                props: {
                  value: params.row.settlementNum
                },
                on: {
                  'on-blur': event => {
                    vm.server
                      .modifySettlementNum({
                        payLineDetailId: params.row.payLineDetailId,
                        settlementNum: event.target.value
                      })
                      .then(response => {
                        if (response.code == '0') {
                          vm.$Message.error({
                            content: `${response.msg}`,
                            duration: 5
                          });
                        } else {
                          vm.$Message.success({
                            content: '修改结算号成功',
                            duration: 5
                          });
                        }
                      });
                  }
                }
              });
            } else {
              return h(
                'span',
                {
                  attrs: {
                    title: params.row.settlementNum
                  }
                },
                params.row.settlementNum
              );
            }
          }
        },
        // {
        //   title: "项目名称",
        //   align: "left",
        //   width: 300,
        //   key: "projectName",
        //   render: (h, params) => {
        //     return h(
        //       "span",
        //       {
        //         attrs: {
        //           title: params.row.projectName
        //         }
        //       },
        //       params.row.projectName
        //     );
        //   }
        // },
        // {
        //   title: "项目编码",
        //   align: "left",
        //   width: 200,
        //   key: "projectCode",
        //   render: (h, params) => {
        //     return h(
        //       "span",
        //       {
        //         attrs: {
        //           title: params.row.projectCode
        //         }
        //       },
        //       params.row.projectCode
        //     );
        //   }
        // },

        {
          title: '供应商类型',
          align: 'left',
          width: 150,
          key: 'vendorType',
          render: (h, params) => {
            let text = '';
            if (params.row.vendorAccountType == '1') {
              text = '对私';
            } else if (params.row.vendorAccountType == '0') {
              text = '对公';
            }
            return h(
              'div',
              {
                attrs: {
                  class: 'ivu-table-cell-ellipsis',
                  title: text
                }
              },
              text
            );
          }
        },
        {
          title: 'EBS付款处理请求号',
          align: 'left',
          width: 200,
          key: 'checkId',
          render: (h, params) => {
            return h(
              'span',
              {
                attrs: {
                  title: params.row.checkId
                }
              },
              params.row.checkId
            );
          }
        },
        {
          title: '付款操作记录',
          align: 'left',
          width: 150,
          render: (h, params) => {
            return h('RowTools', {
              props: {
                data: [
                  {
                    type: 'button',
                    text: '付款操作记录',
                    handle: () => {
                      vm.showOperatorInfoWin(params.row);
                    }
                  }
                ]
              }
            });
          }
        },
        {
          title: '消息',
          align: 'left',
          width: 300,
          key: 'errorMessage',
          render: (h, params) => {
            return h(
              'span',
              {
                attrs: {
                  title: params.row.errorMessage
                }
              },
              params.row.errorMessage
            );
          }
        },
        {
          title: '查看附件',
          align: 'left',
          width: 150,
          render: (h, params) => {
            return h('RowTools', {
              props: {
                data: [
                  {
                    type: 'button',
                    text: '查看附件',
                    handle: () => {
                      this.showFileInfoWin(params.row);
                    }
                  }
                ]
              }
            });
          }
        }
      ];
    },
    getTabCount(data) {
      for (const j in data) {
        vm.$refs[j][0].label = h => {
          return h('div', [
            h('span', vm.tabsNameArr[j]),
            h('Badge', {
              props: {
                count: data[j]
              }
            })
          ]);
        };
      }
    },
    loadingBtn(payWayName, tabsName, buttonName) {
      vm.$refs[payWayName + tabsName + buttonName][0].loading = true;
    },
    reSetBtn(payWayName, tabsName, buttonName) {
      vm.$refs[payWayName + tabsName + buttonName][0].loading = false;
    },
    payDetailClick(payWayName, tabsName, buttonName, payWay, tab) {
      if (buttonName == '复核') {
        vm.audit(payWayName, tabsName, payWay, tab, buttonName);
      } else if (buttonName == '撤销复核') {
        vm.cannelAudit(payWayName, tabsName, payWay, tab, buttonName);
      } else if (buttonName == '撤销') {
        vm.cannelPrepPayment(payWayName, tabsName, payWay, tab, buttonName);
      } else if (buttonName == '重做付款准备') {
        vm.resetPaymentprepare(payWayName, tabsName, payWay, tab, buttonName);
      } else if (buttonName == '止付') {
        vm.stopPay(payWayName, tabsName, payWay, tab, buttonName);
      } else if (buttonName == '拒付') {
        vm.refusalPay(payWayName, tabsName, payWay, tab, buttonName);
      } else if (buttonName == '支付') {
        vm.payMent(payWayName, tabsName, payWay, tab, buttonName);
      } else if (buttonName == '通知本地出纳') {
        vm.noticeCashier(payWayName, tabsName, payWay, tab, buttonName);
      } else if (buttonName == '支付成功') {
        vm.paySuccess(payWayName, tabsName, payWay, tab, buttonName);
      } else if (buttonName == '支付失败') {
        vm.payFail(payWayName, tabsName, payWay, tab, buttonName);
      } else if (buttonName == '失败通知') {
        vm.failureToInform(payWayName, tabsName, payWay, tab, buttonName);
      }
    },
    getSelections(payWayName, tabsName, payWay, tab) {
      vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = vm.$refs.hasOwnProperty(payWayName + tabsName + '-' + payWay + '-' + tab)
        ? (vm.$refs[payWayName + tabsName + '-' + payWay + '-' + tab].length > 0 ? vm.$refs[payWayName + tabsName + '-' + payWay + '-' + tab][0].selection : []) : [];
    },
    // 复核
    audit(payWayName, tabsName, payWay, tab, buttonName) {
      const self = this;
      if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] != undefined) {
        if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length > 0) {
          new $confirm('你确定要复核吗？', this).then(() => {
            const payLineDetailIds = [];
            for (
              let i = 0;
              i < vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length;
              i++
            ) {
              payLineDetailIds.push(
                vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][i].payLineDetailId
              );
            }
            vm.loadingBtn(payWayName, tabsName, buttonName);
            vm.server
              .reviewPreparation({
                payLineDetailIds: payLineDetailIds,
                payBatchId: this.batchId
              })
              .then(response => {
                vm.getTabCount();
                vm.reSetBtn(payWayName, tabsName, buttonName);
                if (response.code == '0') {
                  self.$Message.info(response.msg);
                  vm.basicInfoComponent.init();
                  vm.paymentApplyInfoComponent.init();
                  vm.init();
                  self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                } else {
                  vm.basicInfoComponent.init();
                  vm.paymentApplyInfoComponent.init();
                  this.applyParams.payWay = payWay;
                  this.applyParams.tab = tab;
                  vm.searchTable(payWayName, tabsName, payWay, tab);
                  self.$Message.success('操作成功');
                  self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                }
              });
          });
        } else {
          self.$Message.info('至少选择一条付款准备明细行');
          vm.reSetBtn(payWayName, tabsName, buttonName);
        }
      } else {
        self.$Message.info('至少选择一条付款准备明细行');
        vm.reSetBtn(payWayName, tabsName, buttonName);
      }
    },
    // 撤销复核
    cannelAudit(payWayName, tabsName, payWay, tab, buttonName) {
      const self = this;
      if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] != undefined) {
        if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length > 0) {
          new $confirm('你确定要撤销复核吗？', this).then(() => {
            const payLineDetailIds = [];
            for (
              let i = 0;
              i < vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length;
              i++
            ) {
              payLineDetailIds.push(
                vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][i].payLineDetailId
              );
            }
            vm.loadingBtn(payWayName, tabsName, buttonName);
            vm.server
              .cancelReviewPreparation({
                payBatchId: this.batchId,
                payLineDetailIds: payLineDetailIds
              })
              .then(response => {
                vm.getTabCount();
                vm.reSetBtn(payWayName, tabsName, buttonName);
                if (response.code == '0') {
                  self.$Message.info(response.msg);
                  vm.basicInfoComponent.init();
                  vm.paymentApplyInfoComponent.init();
                  vm.init();
                  self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                } else {
                  vm.basicInfoComponent.init();
                  vm.paymentApplyInfoComponent.init();
                  this.applyParams.payWay = payWay;
                  this.applyParams.tab = tab;
                  vm.searchTable(payWayName, tabsName, payWay, tab);
                  self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                  self.$Message.success('操作成功');
                }
              });
          });
        } else {
          self.$Message.info('至少选择一条付款准备明细行');
          vm.reSetBtn(payWayName, tabsName, buttonName);
        }
      } else {
        self.$Message.info('至少选择一条付款准备明细行');
        vm.reSetBtn(payWayName, tabsName, buttonName);
      }
    },
    // 撤销准备付款
    cannelPrepPayment(payWayName, tabsName, payWay, tab, buttonName) {
      const self = this;
      if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] != undefined) {
        if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length > 0) {
          new $confirm('你确定要撤销吗？', this).then(() => {
            const payLineDetailIds = [];
            for (
              let i = 0;
              i < self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length;
              i++
            ) {
              payLineDetailIds.push(
                self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][i].payLineDetailId
              );
            }
            vm.loadingBtn(payWayName, tabsName, buttonName);
            self.server.cannelPaymentPreparation({
              payBatchId: self.batchId,
              payLineDetailIds: payLineDetailIds
            }).then(response => {
              vm.getTabCount();
              vm.reSetBtn(payWayName, tabsName, buttonName);
              if (response.code == '0') {
                self.$Message.info(response.msg);
                vm.basicInfoComponent.init();
                vm.paymentApplyInfoComponent.init();
                vm.init();
                self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
              } else {
                vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                vm.basicInfoComponent.init();
                vm.paymentApplyInfoComponent.init();
                this.applyParams.payWay = payWay;
                this.applyParams.tab = tab;
                vm.searchTable(payWayName, tabsName, payWay, tab);
                vm.$Message.success('操作成功');
                vm.init();
              }
            });
          });
        } else {
          self.$Message.info('至少选择一条付款准备明细行');
          vm.reSetBtn(payWayName, tabsName, buttonName);
        }
      } else {
        self.$Message.info('至少选择一条付款准备明细行');
        vm.reSetBtn(payWayName, tabsName, buttonName);
      }
    },
    // 重做付款准备
    resetPaymentprepare(payWayName, tabsName, payWay, tab, buttonName) {
      const self = this;
      if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] != undefined) {
        if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length > 0) {
          new $confirm('你确定要重做付款准备吗？', this).then(() => {
            const payLineDetailIds = [];
            for (
              let i = 0;
              i < self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length;
              i++
            ) {
              payLineDetailIds.push(
                self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][i].payLineDetailId
              );
            }
            vm.loadingBtn(payWayName, tabsName, buttonName);
            self.server.reDoPaymentPreparation(payLineDetailIds).then(response => {
              vm.getTabCount();
              vm.reSetBtn(payWayName, tabsName, buttonName);
              if (response.code == '0') {
                self.$Message.info(response.msg);
                vm.basicInfoComponent.init();
                vm.paymentApplyInfoComponent.init();
                this.applyParams.payWay = payWay;
                this.applyParams.tab = tab;
                vm.searchTable(payWayName, tabsName, payWay, tab);
                self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
              } else {
                vm.basicInfoComponent.init();
                vm.paymentApplyInfoComponent.init();
                this.applyParams.payWay = payWay;
                this.applyParams.tab = tab;
                vm.searchTable(payWayName, tabsName, payWay, tab);
                self.$Message.success('操作成功');
                self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
              }
            });
          });
        } else {
          self.$Message.info('至少选择一条付款准备明细行');
          vm.reSetBtn(payWayName, tabsName, buttonName);
        }
      } else {
        self.$Message.info('至少选择一条付款准备明细行');
        vm.reSetBtn(payWayName, tabsName, buttonName);
      }
    },
    // 拒付
    refusalPay(payWayName, tabsName, payWay, tab, buttonName) {
      const self = this;
      if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] != undefined) {
        if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length > 0) {
          let payLineDetailIds = '';
          for (
            let i = 0;
            i < vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length;
            i++
          ) {
            if (i == 0) {
              payLineDetailIds =
                vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][i].payLineDetailId;
            } else {
              payLineDetailIds +=
                '-' +
                vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][i].payLineDetailId;
            }
          }
          vm.loadingBtn(payWayName, tabsName, buttonName);
          new this.$pageModal(
            RefuseContent,
            {
              props: {
                payHeadId: self.batchId,
                payLineDetailIds: payLineDetailIds,
                refuseDescr: '',
                server: self.server
              }
            },
            data => {
              if (data) {
                vm.basicInfoComponent.init();
                vm.paymentApplyInfoComponent.init();
                this.applyParams.payWay = payWay;
                this.applyParams.tab = tab;
                vm.searchTable(payWayName, tabsName, payWay, tab);
                self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                vm.reSetBtn(payWayName, tabsName, buttonName);
                vm.getTabCount();
              }
            }
          );
          vm.reSetBtn(payWayName, tabsName, buttonName);
        } else {
          self.$Message.info('至少选择一条付款准备明细行');
          vm.reSetBtn(payWayName, tabsName, buttonName);
        }
      } else {
        self.$Message.info('至少选择一条付款准备明细行');
        vm.reSetBtn(payWayName, tabsName, buttonName);
      }
    },
    // 止付
    stopPay(payWayName, tabsName, payWay, tab, buttonName) {
      const self = this;
      if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] != undefined) {
        // if(self.selectionData[payWayName + tabsName + '-' + payWay + '-' +tab].length > 0){
        if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length > 0 && self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length == '1') {
          new this.$pageModal(
            FailPayModel, {
              props: {
                title: '止付',
                btnName: 'stopPayRewrite',
                server: self.server,
                commet: self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][0].errorMessage,
                payLineDetailIds: [self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][0].payLineDetailId]
              }
            }, data => {
              if (data) {
                vm.basicInfoComponent.init();
                vm.paymentApplyInfoComponent.init();
                this.applyParams.payWay = payWay;
                this.applyParams.tab = tab;
                vm.searchTable(payWayName, tabsName, payWay, tab);
                self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                vm.reSetBtn(payWayName, tabsName, buttonName);
                vm.getTabCount();
              }
            }
          );
        } else if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length > 0 && self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length > 1) {
          new $confirm('你确定要止付吗？', this).then(() => {
            const payLineDetailIds = [];
            for (
              let i = 0;
              i < vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length;
              i++
            ) {
              payLineDetailIds.push(
                vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][i].payLineDetailId
              );
            }
            vm.loadingBtn(payWayName, tabsName, buttonName);
            self.server
              .stopPayRewrite({
                errorMessage: '',
                payLineDetailIds: payLineDetailIds
              })
              .then(response => {
                vm.getTabCount();
                vm.reSetBtn(payWayName, tabsName, buttonName);
                if (response.code == '0') {
                  self.$Message.info(response.msg);
                  vm.basicInfoComponent.init();
                  vm.paymentApplyInfoComponent.init();
                  this.applyParams.payWay = payWay;
                  this.applyParams.tab = tab;
                  vm.searchTable(payWayName, tabsName, payWay, tab);
                  self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                } else {
                  vm.basicInfoComponent.init();
                  vm.paymentApplyInfoComponent.init();
                  this.applyParams.payWay = payWay;
                  this.applyParams.tab = tab;
                  vm.searchTable(payWayName, tabsName, payWay, tab);
                  self.$Message.success('操作成功');
                  self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                }
              });
          });
        } else {
          self.$Message.info('至少选择一条付款准备明细行');
          vm.reSetBtn(payWayName, tabsName, buttonName);
        }
      } else {
        self.$Message.info('至少选择一条付款准备明细行');
        vm.reSetBtn(payWayName, tabsName, buttonName);
      }
    },
    // 支付
    payMent(payWayName, tabsName, payWay, tab, buttonName) {
      const self = this;
      if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] != undefined) {
        if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length > 0) {
          new $confirm('你确定要支付吗？', this).then(() => {
            const payLineDetailIds = [];
            for (
              let i = 0;
              i < vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length;
              i++
            ) {
              payLineDetailIds.push(
                vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][i].payLineDetailId
              );
            }
            vm.loadingBtn(payWayName, tabsName, buttonName);
            self.server.payPreparation({
              payLineDetailIds: payLineDetailIds
            }).then(response => {
              vm.getTabCount();
              vm.reSetBtn(payWayName, tabsName, buttonName);
              if (response.code == '0') {
                self.$Message.info(response.msg);
                vm.basicInfoComponent.init();
                vm.paymentApplyInfoComponent.init();
                this.applyParams.payWay = payWay;
                this.applyParams.tab = tab;
                vm.searchTable(payWayName, tabsName, payWay, tab);
                self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
              } else {
                vm.basicInfoComponent.init();
                vm.paymentApplyInfoComponent.init();
                this.applyParams.payWay = payWay;
                this.applyParams.tab = tab;
                vm.searchTable(payWayName, tabsName, payWay, tab);
                self.$Message.success(response.msg);
                self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
              }
            });
          });
        } else {
          self.$Message.info('至少选择一条付款准备明细行');
          vm.reSetBtn(payWayName, tabsName, buttonName);
        }
      } else {
        self.$Message.info('至少选择一条付款准备明细行');
        vm.reSetBtn(payWayName, tabsName, buttonName);
      }
    },
    // 通知本地出纳
    noticeCashier(payWayName, tabsName, payWay, tab, buttonName) {
      const self = this;
      if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] != undefined) {
        if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length > 0) {
          new $confirm('你确定要通知本地出纳吗？', this).then(() => {
            const cashierParam = self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab];
            for (
              let i = 0;
              i < self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length;
              i++
            ) {
              if (
                self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][i].companyCode !=
                self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][0].companyCode
              ) {
                break;
              }
            }
            vm.loadingBtn(payWayName, tabsName, buttonName);
            new this.$pageModal(Cashier, {
              props: {
                title: '选择本地出纳',
                cashierParam: cashierParam
              },
              on: {
                handleSelect: () => {
                  vm.basicInfoComponent.init();
                  vm.paymentApplyInfoComponent.init();
                  this.applyParams.payWay = payWay;
                  this.applyParams.tab = tab;
                  vm.searchTable(payWayName, tabsName, payWay, tab);
                  self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                  vm.reSetBtn(payWayName, tabsName, buttonName);
                  vm.getTabCount();
                }
              }
            });
          });
          vm.reSetBtn(payWayName, tabsName, buttonName);
        } else {
          self.$Message.info('至少选择一条付款准备明细行');
        }
      } else {
        self.$Message.info('至少选择一条付款准备明细行');
      }
    },
    // 支付成功
    paySuccess(payWayName, tabsName, payWay, tab, buttonName) {
      const self = this;
      if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] != undefined) {
        if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length > 0) {
          new $confirm('你确定支付成功吗？', this).then(() => {
            const payLineDetailIds = [];
            for (
              let i = 0;
              i < vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length;
              i++
            ) {
              payLineDetailIds.push(
                self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][i].payLineDetailId
              );
            }
            vm.loadingBtn(payWayName, tabsName, buttonName);
            self.server
              .paySuccess({
                payLineDetailIds: payLineDetailIds
              })
              .then(response => {
                vm.getTabCount();
                vm.reSetBtn(payWayName, tabsName, buttonName);
                if (response.code == '0') {
                  self.$Message.info(response.msg);
                  vm.basicInfoComponent.init();
                  vm.paymentApplyInfoComponent.init();
                  this.applyParams.payWay = payWay;
                  this.applyParams.tab = tab;
                  vm.searchTable(payWayName, tabsName, payWay, tab);
                  self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                } else {
                  vm.basicInfoComponent.init();
                  vm.paymentApplyInfoComponent.init();
                  this.applyParams.payWay = payWay;
                  this.applyParams.tab = tab;
                  vm.searchTable(payWayName, tabsName, payWay, tab);
                  self.$Message.success(response.msg);
                  self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                }
              });
          });
        } else {
          self.$Message.info('至少选择一条付款准备明细行');
          vm.reSetBtn(payWayName, tabsName, buttonName);
        }
      } else {
        self.$Message.info('至少选择一条付款准备明细行');
        vm.reSetBtn(payWayName, tabsName, buttonName);
      }
    },
    // 支付失败
    payFail(payWayName, tabsName, payWay, tab, buttonName) {
      const self = this;
      if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] != undefined) {
        if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length > 0) {
          new $confirm('你确定支付失败吗？', this).then(() => {
            const payLineDetailIds = [];
            for (
              let i = 0;
              i < vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length;
              i++
            ) {
              payLineDetailIds.push(
                self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][i].payLineDetailId
              );
            }
            vm.loadingBtn(payWayName, tabsName, buttonName);
            self.server
              .payFail({
                payLineDetailIds: payLineDetailIds
              })
              .then(response => {
                vm.getTabCount();
                vm.reSetBtn(payWayName, tabsName, buttonName);
                if (response.code == '0') {
                  self.$Message.info(response.msg);
                  vm.basicInfoComponent.init();
                  vm.paymentApplyInfoComponent.init();
                  this.applyParams.payWay = payWay;
                  this.applyParams.tab = tab;
                  vm.searchTable(payWayName, tabsName, payWay, tab);
                  self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                } else {
                  vm.basicInfoComponent.init();
                  vm.paymentApplyInfoComponent.init();
                  this.applyParams.payWay = payWay;
                  this.applyParams.tab = tab;
                  vm.searchTable(payWayName, tabsName, payWay, tab);
                  self.$Message.success('操作成功');
                  self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                }
              });
          });
        } else {
          self.$Message.info('至少选择一条付款准备明细行');
          vm.reSetBtn(payWayName, tabsName, buttonName);
        }
      } else {
        self.$Message.info('至少选择一条付款准备明细行');
        vm.reSetBtn(payWayName, tabsName, buttonName);
      }
    },
    // 失败通知
    failureToInform(payWayName, tabsName, payWay, tab, buttonName) {
      const self = this;
      if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] != undefined) {
        // if(self.selectionData[payWayName + tabsName + '-' + payWay + '-' +tab].length > 0){
        if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length > 0 && self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length == '1') {
          new this.$pageModal(
            FailPayModel, {
              props: {
                title: '失败通知',
                btnName: 'failPayNotice',
                server: self.server,
                commet: self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][0].errorMessage,
                payLineDetailIds: [self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][0].payLineDetailId]
              }
            }, data => {
              if (data) {
                vm.basicInfoComponent.init();
                vm.paymentApplyInfoComponent.init();
                this.applyParams.payWay = payWay;
                this.applyParams.tab = tab;
                vm.searchTable(payWayName, tabsName, payWay, tab);
                self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                vm.reSetBtn(payWayName, tabsName, buttonName);
                vm.getTabCount();
              }
            }
          );
        } else if (self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length > 0 && self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length > 1) {
          new $confirm('你确定失败通知吗？', this).then(() => {
            const payLineDetailIds = [];
            for (
              let i = 0;
              i < vm.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab].length;
              i++
            ) {
              payLineDetailIds.push(
                self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab][i].payLineDetailId
              );
            }
            vm.loadingBtn(payWayName, tabsName, buttonName);
            self.server.failPayNotice({
              payLineDetailIds: payLineDetailIds,
              errorMessage: ''
            })
              .then(response => {
                vm.getTabCount();
                vm.reSetBtn(payWayName, tabsName, buttonName);
                if (response.code == '0') {
                  self.$Message.info(response.msg);
                  vm.basicInfoComponent.init();
                  vm.paymentApplyInfoComponent.init();
                  this.applyParams.payWay = payWay;
                  this.applyParams.tab = tab;
                  vm.searchTable(payWayName, tabsName, payWay, tab);
                  self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                } else {
                  vm.basicInfoComponent.init();
                  vm.paymentApplyInfoComponent.init();
                  this.applyParams.payWay = payWay;
                  this.applyParams.tab = tab;
                  vm.searchTable(payWayName, tabsName, payWay, tab);
                  self.$Message.success('操作成功');
                  self.selectionData[payWayName + tabsName + '-' + payWay + '-' + tab] = [];
                }
              });
          });
        } else {
          self.$Message.info('至少选择一条付款准备明细行');
          vm.reSetBtn(payWayName, tabsName, buttonName);
        }
      } else {
        self.$Message.info('至少选择一条付款准备明细行');
        vm.reSetBtn(payWayName, tabsName, buttonName);
      }
    },
    changeTabs(name) {
      this.isCanEdit = name.split(':')[0].split('-')[1] == '1' ? '0' : '1';
      this.applyParams.payWay = name.split(':')[0].split('-')[0];
      this.applyParams.tab = name.split(':')[0].split('-')[1];
      this.$refs[name.split(':')[1] + '-' + name.split(':')[0]][0].load(this.applyParams, 1, function(
        data
      ) {});
      vm.getTabCount();
      // 控制待支付的true or false
      const getActives = name.split(':')[0];
      const firstActives = getActives.split('-')[0];
      if (this.isUploadLocal.hasOwnProperty(getActives)) {
        this.isUploadLocal[getActives] = true;
      } else {
        this.isUploadLocal[firstActives + '-' + 6] = false;
      }
    },
    searchTable(payWayName, tabName, payWay, tab) {
      this.$refs[payWayName + tabName + '-' + payWay + '-' + tab][0].load(this.applyParams, 1, function(
        data
      ) {});
    },
    // 显示操作信息
    showOperatorInfoWin(row) {
      new this.$pageModal(OperatorInfo, {
        props: {
          title: '付款操作记录',
          payLineDetailId: row.payLineDetailId,
          server: vm.server
        }
      });
    },
    showFileInfoWin(row) {
      const first_p = row.payWay;

      new this.$pageModal(FileUpload, {
        props: {
          title: '附件上传',
          claimId: row.payRequestLineId,
          claimNo: this.basicInfo.batchNo,
          isShowUpload: this.isUploadLocal[first_p + '-' + 6]
        }
      });
    }
  },
  directives: {}
};
</script>
