<template>
  <div>
    <up-down-layout :headerVisible="false" :handleFlag.sync="handleFlag">
      <search-form @clearParam="clearParam" @handleFilter="handleFilter" :menuCode="menuId"
                   class="component-width" v-if="isRefresh"
                   searchPerms="search" resetPerms="reset" :formValue.sync="queryParas" @selectChanged="searchSelectChanged"
                   :componentList="componentList" slot="query">
      </search-form>
      <template slot="table">
        <el-row>
          <el-col :span="14">
            <el-form class="expressClass" label-width="55px" label-position="right" :inline="true" :show-message="false">
              <el-form-item label="扫描枪">
                <input-sweep-code @done="inputSweepChange"></input-sweep-code>
                <el-input style="display: none"></el-input>
              </el-form-item>
            </el-form>
          </el-col>
          <el-col :span="10" style="text-align: right">
            <!--导出-->
            <btn-export btnSize="medium" templateCode="express02" :openPerms="true" :queryParas="materialList" :menuCode="menuId" perms="btn1Export"></btn-export>
            <!--导入-->
            <btn-import v-if="formTableData.sourceData.length > 0" btnSize="medium"
                        :openPerms="true" :uploadApi="importApi" :btnDisplay="true"
                        :menuCode="menuId" perms="btn1Import"
                        style="margin-left: 10px;margin-right: 10px" @importSuccess="importSuccess"></btn-import>
            <!--新增-->
            <auth-button v-if="formTableData.sourceData.length > 0" size="medium" type="primary" icon="iconfont iconxinzeng"
                         :menuCode="menuId" perms="btn1Create" :openPerms="true" :loading="loading.createLoading"
                         :label="$t('common.create')" @click="addData"></auth-button>
            <!--删除-->
            <auth-button size="medium" type="danger" icon="iconfont iconshanchu"
                         :menuCode="menuId" perms="btn1Dels" :openPerms="true"
                         :label="$t('common.del')" @click="delData"></auth-button>
            <el-dropdown :hide-on-click="false" trigger="click" class="ycDataTableDropdown" style="margin-left: 10px">
              <el-button size="medium" icon="iconfont iconycmore" class="ycMoreCss"></el-button>
              <el-dropdown-menu slot="dropdown">
                <template v-for="(column, index) in diandianCol">
                  <el-dropdown-item  :key="index">
                    <el-checkbox v-model="column.visible" @change="checkboxChange"
                                 :disabled="columnDisable[column.property]">{{column.title}}</el-checkbox>
                  </el-dropdown-item>
                </template>
              </el-dropdown-menu>
            </el-dropdown>
          </el-col>
        </el-row>
        <el-form :model="formTableData" ref="formTableData" :show-message="false">
          <vxe-grid
            border
            show-overflow
            resizable
            ref="xTable"
            v-bind="elHeightObj"
            id="data-table"
            class="vxeTable"
            v-loading="vLoading"
            element-loading-text="拼命加载中"
            element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(255, 255, 255, 1)"
            :row-style="rowClassName"
            :columns="tableColumn"
            cell-class-name="common-table-cell"
            header-cell-class-name="common-table-header"
            :data="formTableData.sourceData"
            @checkbox-change="selectionData"
            @checkbox-all="selectionData">
          </vxe-grid>
        </el-form>
        <el-row style="margin-top: 10px">
          <el-col :span="24" style="text-align: center">
            <auth-button size="medium" type="primary" :label="$t('common.save')"
                         :menuCode="menuId" perms="btn1Save" :openPerms="true"
                         @click="save" :loading="loading.saveLoading"></auth-button>
            <auth-button size="medium" type="primary" :label="$t('common.submit')"
                           :menuCode="menuId" perms="btn1Submit" :openPerms="true"
                         @click="submit" :loading="loading.submitLoading"></auth-button>
          </el-col>
        </el-row>
      </template>
    </up-down-layout>
    <!--审核意见信息列表-->
    <audit-mind-edit :visible.sync="auditMindVisible" editModel="V" :form="item"></audit-mind-edit>
    <!--详情-->
    <factoring-info-detail :visible.sync="supplierVisible" :keyId="factoringitem" :contractShow="true"></factoring-info-detail>
    <delete-result :visible.sync="dialogVisible" :editModel="'V'" :form="deleteItem"></delete-result>
    <import-result :visible.sync="importDialogVisible" :editModel="'V'" :form="importResultData"></import-result>
  </div>
</template>

<script>
import BasePage from '@/pages/basePage'
import { upDownLayout, searchForm, DataTable, authButton,
  btnExport, btnImport, SelectProductName,
  SelectFinancialInstitutions, SelectSmallArea,
  SelectCoreEnterprise, factoringInfoDetail } from 'newepoch-components'
import SelectKdFileName from '@/components/element/shourang/SelectKdFileName'
import SelectDictionary from '@/components/element/shourang/SelectDictionary.vue'
import SelectPayCode from '@/components/element/shourang/SelectPayCode'
import AuditMindEdit from '@/pages/shourang/expressFileReceive/auditMindEdit'
import deleteResult from '@/pages/shourang/expressFileReceive/deleteResult'
import InputSweepCode from '@/components/element/shourang/inputSweepCode'
import SelectReceiver from '@/components/element/shourang/SelectReceiver'
import tipsDatePicker from '@/components/element/shourang/tipsDatePicker'
import importResult from '@/pages/shourang/expressFileReceive/importResult'
import * as format from '@/filters/index.js'
import { regExp } from '@/validator/index'
import expressApi from '@/api/expressApi'
import mixin from '@/pages/mixin.js'
import componentsApi from '@/api/componentsApi'
import { IMPORT_API } from '@/constant'
// import storage from '@/utils/storage'
//
// import sysApi from '@/api/sysApi'
export default {
  extends: new BasePage(),
  mixins: [mixin],
  components: {
    upDownLayout,
    searchForm,
    DataTable,
    authButton,
    btnExport,
    btnImport,
    SelectDictionary,
    factoringInfoDetail,
    SelectReceiver,
    SelectKdFileName,
    InputSweepCode,
    SelectPayCode,
    AuditMindEdit,
    deleteResult,
    importResult
  },
  data () {
    return {
      isRefresh: true,
      preQueryParas: {},
      queryParas: {},
      columnDisable: {},
      diandianCol: [],
      importDialogVisible: false,
      importResultData: {},
      importApi: IMPORT_API,
      auditMindVisible: false,
      supplierVisible: false,
      loading: {
        saveLoading: false,
        createLoading: false,
        submitLoading: false
      },
      // selectRowIndex: [],
      headReceiverCode: '1',
      isWrite: false,
      isHeadWrite: false,
      deleteItem: {},
      dialogVisible: false,
      factoringitem: '',
      vLoading: false,
      // 保存校验多行、提交检验一行标志
      checkFlag: false,
      headData: {
        // 本次接收份数
        receiveCopies: '',
        // 资料来源
        dataSource: '',
        // 来源人
        origin: '',
        // 来源人
        expressNumber: ''
      },
      // 导出
      materialList: {
        api: {
          sqlfig: []
        }
      },
      formTableData: {
        sourceData: []
      },
      fromDataRules: {
        // 本次接收份数
        receiveCopies: [
          { required: true, validator: this.numberCheck, trigger: 'change' }
        ],
        // 请选择付款确认书编号
        payCode: [
          { required: true, message: '', trigger: 'change' }
        ],
        // 请选择资料来源
        assetSource: [
          { required: true, message: '', trigger: 'change' }
        ],
        // 请输入文件名
        fileName: [
          { required: true, message: '请输入文件名', trigger: 'change' }
        ],
        expressNo: [
          { required: true, message: '', trigger: 'change' },
          { validator: this.expressNoCheck, trigger: 'change' }
        ],
        // 来源人
        coreAreaAttache: [
          { required: true, message: '', trigger: 'change' }
        ]
      },
      componentList: [
        // 任务类型
        {
          label: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.taskType,
          value: 'taskType',
          componentName: 'SelectDictionary',
          dictTypeCode: 'task_type',
          exclude: [{ dictId: '5' }],
          multiple: true,
          labelWidth: '165px'
        },
        // 关键字
        {
          label: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.keyword,
          value: 'keyWord',
          placeholder: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.inputKeyword,
          componentName: 'el-input',
          clearable: true,
          labelWidth: '165px'
        },
        // 供应商
        {
          label: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.supplierName,
          value: 'creditor',
          componentName: 'el-input',
          placeholder: '请输入',
          clearable: true,
          labelWidth: '165px'
        },
        // 项目公司
        {
          label: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.projectCompanyName,
          value: 'debtor',
          componentName: 'el-input',
          placeholder: '请输入',
          clearable: true,
          labelWidth: '165px'
        },
        // 文件名称
        {
          label: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.fileName,
          value: 'fileName',
          componentName: 'el-input',
          placeholder: '请输入',
          clearable: true,
          labelWidth: '165px'
        },
        // 接收人
        {
          label: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.receiver,
          value: 'receiverId',
          componentName: SelectReceiver,
          labelWidth: '160px',
          attrs: { isYongyou: true }
        },
        // 接收时间
        {
          label: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.receiveTime,
          value: 'receiveDate',
          componentName: tipsDatePicker,
          format: 'yyyy-MM-dd HH:mm:ss',
          startPlaceholder: '请选择',
          endPlaceholder: '请选择',
          type: 'datetimerange',
          labelWidth: '165px'
        },
        // 计划管理人/再保理银行
        {
          label: this.$i18n.messages[this.$i18n.locale].common.refactorBank,
          value: 'planningManagerId',
          componentName: SelectFinancialInstitutions,
          labelWidth: '165px'
        },
        // 完成情况
        {
          label: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.completion,
          value: 'accomplishSituation',
          componentName: 'SelectDictionary',
          dictTypeCode: 'receive_completion',
          labelWidth: '165px'
        },
        // 区域
        {
          label: this.$i18n.messages[this.$i18n.locale].common.area,
          value: 'coreArea',
          queryName: 'coreCompanyId',
          queryValue: 'coreEnterpriseId',
          allowCreate: true,
          filterable: true,
          componentName: SelectSmallArea,
          name: 'coreArea',
          labelWidth: '165px'
        },
        // 产品名称
        {
          label: this.$i18n.messages[this.$i18n.locale].common.productName,
          value: 'projectId',
          name: 'projectId',
          componentName: SelectProductName,
          labelWidth: '165px'
        },
        // 期数
        {
          label: this.$i18n.messages[this.$i18n.locale].common.periodsNum,
          value: 'specialPlanPeriods',
          placeholder: '请输入',
          maxlength: '3',
          componentName: 'el-input',
          labelWidth: '165px'
        },
        // 核心企业
        {
          label: this.$i18n.messages[this.$i18n.locale].common.coreEnterprises,
          value: 'coreEnterpriseId',
          componentName: SelectCoreEnterprise,
          name: 'coreEnterpriseId',
          labelWidth: '165px'
        }
      ],
      tableColumn: [
        { type: 'checkbox', align: 'center', width: 50, fixed: 'left' },
        // 付款确认书编号
        {
          field: 'assetCode',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.payCode,
          minWidth: '200px',
          align: 'left',
          headerAlign: 'center',
          slots: {
            default: ({ row, rowIndex }) => {
              if (rowIndex === -1) rowIndex = 0
              let query = this.payCodeQueryParas()
              return [
                <el-form-item prop= {'sourceData.' + rowIndex + '.assetCode'}
                  class="margin-bottom0" rules= {this.ifCheck(row) || !this.checkFlag ? this.fromDataRules.payCode : []}>
                  {row.status ? <select-pay-code queryParas= { query } v-model= { row.assetCode }
                    index= {rowIndex} onselectChanged= {this.payCodeChanged}></select-pay-code>:
                    <el-tooltip content= {row.assetCode} placement='top'><div class='diandianDivClass'><span>{row.assetCode}</span></div></el-tooltip>}
                </el-form-item>
              ]
            }
          }
        },
        // 保理金额
        {
          field: 'factoringMoney',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.factorAmount,
          minWidth: '200px',
          headerAlign: 'center',
          align: 'right'
        },
        // 核心企业名称
        {
          field: 'coreEnterpriseName',
          title: this.$i18n.messages[this.$i18n.locale].common.coreEnterprises,
          minWidth: '200px',
          headerAlign: 'center',
          align: 'left'
        },
        // 供应商名称
        {
          field: 'creditor',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.supplierName,
          minWidth: '200px',
          headerAlign: 'center',
          align: 'left'
        },
        // 项目公司名称
        {
          field: 'debtor',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.projectCompanyName,
          minWidth: '200px',
          headerAlign: 'center',
          align: 'left'
        },
        // 计划管理人
        {
          field: 'planningManagerName',
          title: this.$i18n.messages[this.$i18n.locale].common.refactorBank,
          minWidth: '200px',
          headerAlign: 'center',
          align: 'left'
        },
        // 客服
        {
          field: 'customerAccountName',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.customerService,
          minWidth: '100px',
          headerAlign: 'center',
          align: 'left'
        },
        // 线下单证审核
        {
          field: 'offlineAuditPersonName',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.offlineDocumentAudit,
          minWidth: '120px',
          headerAlign: 'center',
          align: 'left'
        },
        // 区域
        {
          field: 'coreAreaName',
          title: this.$i18n.messages[this.$i18n.locale].common.area,
          minWidth: '200px',
          headerAlign: 'center',
          align: 'left'
        },
        // // 文件名称
        {
          field: 'fileName',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.fileName,
          minWidth: '200px',
          align: 'left',
          headerAlign: 'center',
          slots: {
            default: ({ row, rowIndex }) => {
              if (rowIndex === -1) rowIndex = 0
              return [
                <div>
                  {row.status ? <el-form-item prop = {'sourceData.' +rowIndex + '.fileName'} class= "margin-bottom0"
                    rules = {this.ifCheck(row) || !this.checkFlag ? this.fromDataRules.fileName : []} >
                    <select-kd-file-name v-model={row.fileName} onselectChanged = {(...a)=>this.fileNameselectChanged(...a, rowIndex)}
                      option = {row.option} exPend = {row.exPend} name = "fileName" ref={'fileNameRef' +rowIndex} ></select-kd-file-name>
                  </el-form-item>:<el-tooltip content={row.fileName} placement='top'><div class='diandianDivClass'><span>{row.fileName}</span></div></el-tooltip>}
                </div>
              ]
            }
          }
        },
        // 所需份数
        {
          field: 'needCopies',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.requireCopies,
          minWidth: '100px',
          headerAlign: 'center',
          align: 'right'
        },
        // 有效份数
        {
          field: 'validCopies',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.effectiveCopies,
          minWidth: '100px',
          headerAlign: 'center',
          align: 'right'
        },
        // 本次接收份数
        {
          field: 'copiesReceived',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.receiveCopies,
          minWidth: '140px',
          headerAlign: 'center',
          align: 'right',
          slots: {
            default: ({ row, rowIndex }) => {
              if (rowIndex === -1) rowIndex = 0
              return [
                <el-form-item prop= {'sourceData.' + rowIndex + '.copiesReceived'} class="margin-bottom0"
                  rules= {this.ifCheck(row) || !this.checkFlag ? this.fromDataRules.receiveCopies : []}>
                  <el-input size="medium" v-model= {row.copiesReceived} maxlength="2" clearable={true} placeholder="请输入小于3位的正整数" oninput={(...a) => this.listenrInput(...a, rowIndex)}></el-input>
                </el-form-item>
              ]
            },
            header: ({ column }) => {
              return [
                <div style="text-align: center">
                  {this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.receiveCopies}
                  <div class="el-input el-input--mini el-input--suffix">
                    <input size = "mini" v-model={this.headData.receiveCopies} class="el-input__inner"
                      onchange={() => this.headDataBlur(this.headData.receiveCopies, 'copiesReceived')}
                      placeholder="请输入小于3位的正整数" clearable={true} maxlength = "2">
                    </input>
                  </div>
                </div>
              ]
            }
          }
        },
        // 任务类型
        {
          field: 'taskType',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.taskType,
          minWidth: '100px',
          headerAlign: 'center',
          align: 'center',
          formatter: ({ cellValue }) => {
            return format.formatDict(cellValue, 'task_type')
          }
        },
        // 完成情况
        {
          field: 'accomplishSituation',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.completion,
          headerAlign: 'center',
          minWidth: '100px',
          align: 'center',
          formatter: ({ cellValue }) => {
            return format.formatDict(cellValue, 'receive_completion')
          }
        },
        // 资料来源
        {
          field: 'receiveSource',
          align: 'cneter',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.dataSource,
          headerAlign: 'center',
          minWidth: '200px',
          slots: {
            default: ({ row, rowIndex }) => {
              if (rowIndex === -1) rowIndex = 0
              return [
                <el-form-item prop= {'sourceData.' + rowIndex + '.receiveSource'}
                  class="margin-bottom0" rules={this.ifCheck(row) || !this.checkFlag ? this.fromDataRules.assetSource : []}>
                  <select-dictionary name="receiveSource" v-model= {row.receiveSource}
                    dictTypeCode="receive_source"
                    onselectChanged= {(...aaa) => this.headDataChangeItem(...aaa, rowIndex)}>
                  </select-dictionary>
                </el-form-item>
              ]
            },
            header: ({ column }) => {
              return [
                <div style="text-align: center">
                  {this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.dataSource}
                  <select-dictionary size="mini" dictTypeCode="receive_source"
                    v-model={this.headData.dataSource} onselectChanged= {this.headDataChange} name="receiveSource">
                  </select-dictionary>
                </div>
              ]
            }
          }
        },
        // 来源人
        {
          field: 'coreAreaAttache',
          align: 'left',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.origin,
          headerAlign: 'center',
          minWidth: '200px',
          slots: {
            default: ({ row, rowIndex }) => {
              let check = (row.receiveSource === '2' || row.receiveSource === '3' || row.receiveSource === '4')
              return [
                <el-form-item prop= {'sourceData.' + rowIndex + '.receiverId'}
                  class="margin-bottom0" rules={(check && this.ifCheck(row)) || !this.checkFlag ? this.fromDataRules.coreAreaAttache : []}>
                  <select-receiver v-model= {row.receiverId} onselectChanged= {(...aaa) => this.headDataChangeItem(...aaa, rowIndex)}
                    filterable={true} allowCreate={row.isWrite} receiverCode={row.headReceiverCode} itemType="H" parQueryParas={row.assetInfoId}>
                  </select-receiver>
                </el-form-item>
              ]
            },
            header: ({ column }) => {
              return [
                <div style="text-align: center">
                  {this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.origin}
                  <select-receiver size="mini" v-model= {this.headData.origin} onselectChanged= {this.headDataChange}
                    receiverCode={this.headReceiverCode} name="receiverId" filterable= {true} allowCreate= {this.isHeadWrite}>
                  </select-receiver>
                </div>
              ]
            }
          }
        },
        // 快递单号
        {
          field: 'expressNo',
          align: 'cneter',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.expressNumber,
          headerAlign: 'center',
          minWidth: '150px',
          slots: {
            default: ({ row, rowIndex }) => {
              if (rowIndex === -1) rowIndex = 0
              return [
                <el-form-item prop={'sourceData.' + rowIndex + '.expressNo'} class="margin-bottom0"
                  rules={(this.ifCheck(row) || !this.checkFlag) ? (row.receiveSource === '1' ? this.fromDataRules.expressNo : [{ validator: this.expressNoCheck, trigger: 'change' }]) : []}>
                  <el-input size="medium" v-model= {row.expressNo} placeholder={row.receiveSource === '1' ? '输入快递单号(数字或字母)' : '快递单号格式数字或字母'} oninput={(...a) => this.listenrInput(...a, rowIndex)}></el-input>
                </el-form-item>
              ]
            },
            header: ({ column }) => {
              return [
                <div style="text-align: center">
                  {this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.expressNumber}
                  <div class="el-input el-input--mini el-input--suffix">
                    <input size="mini" v-model={this.headData.expressNumber}  class="el-input__inner"
                      onchange={() => this.headDataBlur(this.headData.expressNumber, 'expressNo')} clearable= {true}>
                    </input>
                  </div>
                </div>
              ]
            }
          }
        },
        // 备注
        {
          field: 'memo',
          align: 'left',
          title: this.$i18n.messages[this.$i18n.locale].expressFileReceiveList.memo,
          headerAlign: 'center',
          minWidth: '300px',
          slots: {
            default: ({ row, rowIndex }) => {
              return [
                <div>
                  <el-input v-model={row.memo} maxlength="50" size="medium" placeholder="输入备注" oninput={(...a) => this.listenrInput(...a, rowIndex)}></el-input>
                </div>
              ]
            }
          }
        },
        // 操作
        {
          field: 'operate',
          align: 'center',
          fixed: 'right',
          title: this.$i18n.messages[this.$i18n.locale].common.operate,
          headerAlign: 'center',
          minWidth: '150px',
          slots: {
            default: ({ row, rowIndex }) => {
              return [
                <div>
                  <auth-button disabled={row.status} size="small" class="iconCircle" icon="iconfont iconmore"
                    title= {this.$t('expressFileReceiveList.details')} onClick= {() => this.showSupplier(row)}>
                  </auth-button>
                  <auth-button disabled= {row.status} size="small" class="iconCircle" icon="iconfont iconyijian"
                    title= {this.$t('expressFileReceiveList.auditMind')} onclick={() => this.showAuditMind(row)}>
                  </auth-button>
                </div>
              ]
            }
          }
        }
      ]
    }
  },
  created () {
    this.$nextTick(() => {
      this.diandianCol = this.$refs.xTable.getColumns()
      this.diandianCol = this.diandianCol.slice(1, this.diandianCol.length)
      this.diandianCol.forEach(it => {
        this.$set(it, 'visible', true)
        this.$set(this.columnDisable, it.property, false)
      })
    })
  },
  methods: {
    checkboxChange () {
      let a = this.diandianCol.filter(it => it.visible)
      if (a.length === 1) {
        let field = a[0].property
        this.$set(this.columnDisable, field, true)
      } else {
        for (let key in this.columnDisable) {
          this.$set(this.columnDisable, key, false)
        }
      }
      this.$refs.xTable.refreshColumn()
    },
    // 行修改
    rowClassName ({ $rowIndex, column, columnIndex, $columnIndex }) {
      let a = this.formTableData.sourceData[$rowIndex]
      if (!this.UtilJs.isEmpty(a) && a.isModify) {
        return 'background: #FFDAB9; color: #000000'
      }
    },
    listenrInput (...arg) {
      this.formTableData.sourceData[arg[1]].isModify = true
    },
    // 离开更改
    headDataBlur (...arg) {
      // if (arg[0].keyCode === 13) {
      this.formTableData.sourceData.forEach(it => {
        this.$set(it, arg[1], arg[0])
        this.$set(it, 'isModify', true)
      })
      // }
    },
    selectionData ({ records }) {
      // this.selectRowIndex = []
      this.selectedRows = records
      // this.formTableData.sourceData.forEach((it, index) => {
      //   if (this.selectedRows.some(it1 => it1.assetPoolMaterialGroupId === it.assetPoolMaterialGroupId)) {
      //     this.selectRowIndex.push(index)
      //   }
      // })
    },
    headDataChange (key, name, items, buff) {
      if (name === 'receiveSource') {
        // 自送
        this.isHeadWrite = items && (items.dictId === '5' || items.dictId === '1')
        this.$nextTick(() => {
          if (items) {
            this.headReceiverCode = items.dictId
          } else {
            this.headReceiverCode = ''
          }
          this.headData.origin = ''
          this.formTableData.sourceData.forEach(it => {
            // it.headReceiverCode = this.headReceiverCode
            this.$set(it, 'headReceiverCode', this.headReceiverCode)
            this.$set(it, 'receiveSource', this.headReceiverCode)
            this.$set(it, 'receiver', '')
            this.$set(it, 'receiverId', '')
            this.$set(it, 'isModify', true)
            this.$set(it, 'expressNo', '')
          })
        })
        this.$refs['formTableData'].clearValidate()
      } else if (name === 'receiverId') {
        this.formTableData.sourceData.forEach(it => {
          if (it.receiveSource !== '1' || it.receiveSource !== '5') {
            if (key && !items) {
              this.$set(it, name, key)
              this.$set(it, 'receiver', key)
            } else {
              this.$set(it, name, key)
              this.$set(it, 'receiver', items ? items.nickName : '')
            }
          } else {
            this.$set(it, name, '')
            this.$set(it, 'receiver', '')
          }
          this.$set(it, 'isModify', true)
        })
      }
    },
    headDataChangeItem (...arg) {
      let val = arg
      let index = val[1] === 'receiveSource' ? val[4] : val[3]
      if (index !== -1) {
        if (val[1] === 'receiveSource') {
          this.$refs['formTableData'].clearValidate()
          if (!this.UtilJs.isEmpty(arg[2])) {
            this.$nextTick(() => {
              this.formTableData.sourceData[index].isWrite = val[2] && (val[2].dictId === '5' || val[2].dictId === '1')
              if (val[2]) {
                this.$set(this.formTableData.sourceData[index], 'headReceiverCode', val[2].dictId)
                // this.formTableData.sourceData[index].headReceiverCode = val[2].dictId
              } else {
                this.$set(this.formTableData.sourceData[index], 'headReceiverCode', '')
                // this.formTableData.sourceData[index].headReceiverCode = ''
              }
              if (!this.UtilJs.isEmpty(arg[0]) && !this.UtilJs.isEmpty(val[2])) {
                this.formTableData.sourceData[index].receiver = ''
                this.formTableData.sourceData[index].receiverId = ''
                this.formTableData.sourceData[index].isModify = true
                this.$set(this.formTableData.sourceData[index], 'expressNo', '')
              }
            })
          } else if (this.UtilJs.isEmpty(arg[0]) && this.UtilJs.isEmpty(val[2])) {
            this.formTableData.sourceData[index].receiver = ''
            this.formTableData.sourceData[index].receiverId = ''
            // this.formTableData.sourceData[index].headReceiverCode = ''
            this.$set(this.formTableData.sourceData[index], 'headReceiverCode', '')
            this.formTableData.sourceData[index].isModify = true
            this.$set(this.formTableData.sourceData[index], 'expressNo', '')
          }
        } else {
          if (!this.UtilJs.isEmpty(val[0]) && !this.UtilJs.isEmpty(val[2])) {
            this.formTableData.sourceData[index].isModify = true
            this.formTableData.sourceData[index].receiver = val[2].nickName
          } else if (!this.UtilJs.isEmpty(val[0]) && this.UtilJs.isEmpty(val[2])) {
            this.formTableData.sourceData[index].receiver = val[0]
          } else if (this.UtilJs.isEmpty(val[0]) && !this.UtilJs.isEmpty(val[2])) {
            this.formTableData.sourceData[index].receiver = val[2].nickName
          } else {
            this.formTableData.sourceData[index].isModify = true
            this.formTableData.sourceData[index].receiver = ''
          }
        }
      }
    },
    // 期数校验
    numberCheck (rule, value, callback) {
      if (this.UtilJs.isEmpty(value) || value === 0 || value === '0') {
        return callback(new Error(''))
      }
      if (regExp.number.test(value)) {
        if (Number(value) < 100) {
          return callback()
        } else {
          return callback(new Error(''))
        }
      }
      return callback(new Error(''))
    },
    expressNoCheck (rule, value, callback) {
      if (this.UtilJs.isEmpty(value) || regExp.numberAndEnglish.test(value)) {
        return callback()
      } else {
        return callback(new Error(''))
      }
    },
    showSupplier (row) {
      this.factoringitem = row.assetInfoId // Object.assign({}, row)
      this.supplierVisible = true
    },
    showAuditMind (row) {
      this.item = Object.assign({}, row)
      this.auditMindVisible = true
    },
    // 扫码完成
    inputSweepChange (val) {
      let $this = this
      if (!this.UtilJs.isEmpty(val)) {
        this.fullscreenLoading = this.$loading({
          lock: true,
          text: '匹配中',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        })
        expressApi.expressFileReceiveApi.scan({ qrCode: val }).then(res => {
          $this.fullscreenLoading.close()
          if (res.success) {
            if (!$this.UtilJs.isEmpty(res.data)) {
              let flag = false
              $this.formTableData.sourceData.forEach(it => {
                if (it.keyId === res.data.keyId) {
                  it.copiesReceived = it.copiesReceived + 1
                  flag = true
                }
              })
              if (flag) {
                $this.success('匹配成功')
                let tem = val.split('|')
                this.addFenFun(tem[3])
              } else {
                $this.warning('没有可匹配的数据')
              }
            } else {
              $this.warning('没有可匹配的数据')
            }
          } else {
            $this.error('匹配失败')
          }
        }).catch(function () {
          $this.fullscreenLoading.close()
        })
      }
    },
    payCodeQueryParas () {
      return this.queryParas
    },
    // 文件选择
    fileNameselectChanged (...arg) {
      let index = arg[arg.length - 1]
      let flag = false
      this.formTableData.sourceData.forEach((it, idx) => {
        if (it.materialGroupDetailId === arg[2].keyId && it.materialFileId === arg[2].materialFileId && idx !== index) {
          flag = true
        }
      })
      if (flag) return this.warning('文件和资料ID重复，请重新选择')
      if (arg[2]) {
        this.$set(this.formTableData.sourceData[index], 'fileCode', arg[2].fileCode)
        this.$set(this.formTableData.sourceData[index], 'fileName', arg[2].materialFileName)
        this.$set(this.formTableData.sourceData[index], 'materialGroupDetailId', arg[2].keyId)
        this.$set(this.formTableData.sourceData[index], 'materialFileId', arg[2].materialFileId)
        this.$set(this.formTableData.sourceData[index], 'fileSource', arg[2].fileSource)
      } else {
        this.$set(this.formTableData.sourceData[index], 'fileCode', '')
        this.$set(this.formTableData.sourceData[index], 'fileName', '')
        this.$set(this.formTableData.sourceData[index], 'materialGroupDetailId', '')
        this.$set(this.formTableData.sourceData[index], 'materialFileId', '')
        this.$set(this.formTableData.sourceData[index], 'fileSource', '')
      }
    },
    // 是否拥有校验
    ifCheck (index) {
      let as = this.selectedRows.length !== 0 && this.selectedRows.some(it => it === index)
      return as
    },
    clearHead () {
      this.headData = {
        // 本次接收份数
        receiveCopies: '',
        // 资料来源
        dataSource: '',
        // 来源人
        origin: '',
        // 来源人
        expressNumber: ''
      }
    },
    // 查询
    handleFilter (queryParas) {
      if (this.UtilJs.isEmpty(queryParas)) {
        this.preQueryParas = JSON.parse(JSON.stringify(this.queryParas))
      }
      let a = queryParas || this.queryParas
      if (!this.UtilJs.isEmpty(a.specialPlanPeriods) && !regExp.number.test(a.specialPlanPeriods)) {
        return this.warning(this.$i18n.messages[this.$i18n.locale].expressDataList.specialPlanPeriodsCheck)
      }
      let ismodify = this.formTableData.sourceData.some(it => {
        return it.isModify === true
      })
      if (ismodify) {
        this.$confirm(this.$i18n.messages[this.$i18n.locale].expressDataList.ismodifySave, '提示', { type: 'warning' }).then(res => {
          this.handleFilterFun(a)
        })
      } else {
        this.handleFilterFun(a)
      }
    },
    // 检查查询条件是否正确
    isQueryCheck (queryParasArg) {
      if (this.UtilJs.isEmpty(queryParasArg)) return true
      let t = queryParasArg.taskType && queryParasArg.taskType.length > 0 && !this.UtilJs.isEmpty(queryParasArg.projectId)
      let p = queryParasArg.keyWord && queryParasArg.keyWord.length > 0
      if (t || p) {
        return true
      } else {
        this.warning('关键字必填或者（任务类型和产品名称必填）')
        return false
      }
    },
    handleFilterFun (queryParasArg) {
      let $this = this
      if (!$this.isQueryCheck(queryParasArg)) {
        return
      }
      let queryParas = JSON.parse(JSON.stringify(queryParasArg))
      if (queryParas.receiveDate && queryParas.receiveDate !== '') {
        queryParas.receiveDateStart = new Date(queryParas.receiveDate[0]).getTime()
        queryParas.receiveDateEnd = new Date(queryParas.receiveDate[1]).getTime()
        if (isNaN(queryParas.receiveDateStart) || queryParas.receiveDateStart === 0) delete queryParas.receiveDateStart
        if (isNaN(queryParas.receiveDateEnd) || queryParas.receiveDateEnd === 0) delete queryParas.receiveDateEnd
      }
      this.clearHead()
      this.vLoading = true
      expressApi.expressFileReceiveApi.getList(queryParas).then(res => {
        if (res.success) {
          // this.selectRowIndex = []
          this.selectedRows = []
          let obj = {}
          obj.status = false
          // let arr = []
          let arr = this.copyData(res.data)
          arr.forEach(it => {
            // 快递单号
            if (!it.expressNo) {
              if (it.assetReceivingInfoDTOList && it.assetReceivingInfoDTOList.length > 0) {
                this.$set(it, 'expressNo', it.assetReceivingInfoDTOList[0].expressNo)
              } else {
                this.$set(it, 'expressNo', '')
              }
            }
            // 备注
            if (!it.memo) {
              if (it.assetReceivingInfoDTOList && it.assetReceivingInfoDTOList.length > 0) {
                this.$set(it, 'memo', it.assetReceivingInfoDTOList[0].memo)
              } else {
                this.$set(it, 'memo', '')
              }
            }
            // 接收份数
            if (!it.copiesReceived) {
              if (it.assetReceivingInfoDTOList && it.assetReceivingInfoDTOList.length > 0) {
                this.$set(it, 'copiesReceived', it.assetReceivingInfoDTOList[0].receiveCopies)
              } else {
                this.$set(it, 'copiesReceived', '')
              }
            }
            // 资料来源
            if (!it.receiveSource) {
              if (it.assetReceivingInfoDTOList && it.assetReceivingInfoDTOList.length > 0) {
                this.$set(it, 'receiveSource', it.assetReceivingInfoDTOList[0].receiveSource)
              } else {
                this.$set(it, 'receiveSource', '')
              }
            }
            if (!it.receiverId) {
              if (it.assetReceivingInfoDTOList && it.assetReceivingInfoDTOList.length > 0) {
                this.$set(it, 'receiverId', it.assetReceivingInfoDTOList[0].receiverId)
                this.$set(it, 'receiver', it.assetReceivingInfoDTOList[0].receiver)
              } else {
                this.$set(it, 'receiverId', '')
                this.$set(it, 'receiver', '')
              }
            }
            if (it.receiverId && it.receiverId.toString() === '-1') {
              it.receiverId = it.receiver
            }
            this.$set(it, 'headReceiverCode', it.receiveSource)
            it.isWrite = (it.receiveSource === '5' || it.receiveSource === '1')
            this.$set(it, 'isModify', false)
          })
          $this.$nextTick(function () {
            $this.formTableData.sourceData = arr
            $this.$refs['formTableData'].clearValidate()
          })
          this.materialList.api.sqlfig = this.copyData(arr)
          this.materialList.api.sqlfig.forEach(it => {
            it.sourcePerson = it.receiver
            it.taskType = format.formatDict(it.taskType, 'task_type')
            it.receiveSource = format.formatDict(it.receiveSource, 'receive_source')
            if (it.accomplishSituation.toString() === '-1') {
              it.accomplishSituation = ''
            } else {
              it.accomplishSituation = format.formatDict(it.accomplishSituation, 'receive_completion')
            }
          })
        } else {
          $this.error('获取列表失败')
        }
      }).finally(() => {
        this.vLoading = false
      })
    },
    // 深度拷贝
    copyData (data) {
      var obj = {}
      obj = JSON.parse(JSON.stringify(data))
      return obj
    },
    // 导入完成
    importSuccess (returnData) {
      let data = []
      returnData.forEach((item, index) => {
        let tempData = {
          assetCode: item[1],
          taskType: item[2],
          fileName: item[3],
          receiveCopies: item[4],
          fileSource: item[5],
          receiver: item[6],
          expressNo: item[7]
        }
        if (index < 2) return
        let datList = this.checkImport(tempData)
        data.push(datList)
      })
      data.forEach(item => {
        if (item.isOk) {
          let it = item.tempData
          let temp = []
          if (it.importType === '1') {
            temp = this.formTableData.sourceData.filter(it1 => it1.assetCode === it.assetCode)
          } else {
            // 文件名为空，只检查付款确认书编号和资料来源
            temp = this.formTableData.sourceData.filter(it1 => {
              return it1.assetCode === it.assetCode && format.formatDict(it1.taskType, 'task_type') === it.taskType
            })
          }
          temp.forEach(it1 => {
            let copiesReceived = 0
            // f = true
            if (it.importType === '1') {
              copiesReceived = Number(it1.copiesReceived) + Number(it.receiveCopies)
            } else {
              copiesReceived = Number(it1.needCopies) - Number(it1.validCopies)
            }
            it1.fileName = it.fileName
            it1.copiesReceived = copiesReceived
            it1.receiveSource = this.getDictId(it.fileSource)
            it1.expressNo = it.expressNo
            it1.isModify = true
          })
        }
      })
      if (data.length > 0) {
        this.importResultData = Object.assign({}, { data: data })
        this.importDialogVisible = true
      }
    },
    // 导入检查
    checkImport (tempData) {
      let flag = true
      tempData.importType = '1'
      if (this.UtilJs.isEmpty(tempData.assetCode)) {
        flag = false
        tempData.failureReason = '付款确认书编号不能为空'
      } else if (this.UtilJs.isEmpty(tempData.fileSource)) {
        flag = false
        tempData.failureReason = '资料来源不能为空'
      } else {
        // 文件名为空，只检查付款确认书编号和资料来源
        if (this.UtilJs.isEmpty(tempData.fileName)) {
          if (this.UtilJs.isEmpty(tempData.taskType)) {
            flag = false
            tempData.failureReason = '任务类型不能为空'
          } else if (this.UtilJs.isEmpty(tempData.fileSource)) {
            flag = false
            tempData.failureReason = '来源不能为空'
          } else if (!this.UtilJs.isEmpty(tempData.fileSource) && tempData.fileSource === '快递' && this.UtilJs.isEmpty(tempData.expressNo)) {
            flag = false
            tempData.failureReason = '来源为快递，则快递单号不能为空'
          } else {
            // tempData.importType = '2'
          }
        } else {
          tempData.importType = '2'
          if (this.UtilJs.isEmpty(tempData.receiveCopies) || !regExp.number.test(Number(tempData.receiveCopies)) || Number(tempData.receiveCopies) >= 100) {
            flag = false
            tempData.failureReason = '接收份数必填并且不能超过两位正整数'
          } else if (!this.UtilJs.isEmpty(tempData.fileSource) && tempData.fileSource === '快递' && this.UtilJs.isEmpty(tempData.expressNo)) {
            flag = false
            tempData.failureReason = '来源为快递，则快递单号不能为空'
          }
        }
      }
      if (flag) {
        if (this.formTableData.sourceData.some(it => it.assetCode === tempData.assetCode)) {
          tempData.isTable = true
        } else {
          flag = false
          tempData.isTable = false
          tempData.failureReason = '该付款确认书编号不在表格中'
        }
      }
      return { isOk: flag, tempData: tempData }
    },
    getDictId (data) {
      if (data === '快递') {
        return '1'
      } else if (data === '保理专员') {
        return '2'
      } else if (data === '区域专员') {
        return '3'
      } else if (data === '业务人员') {
        return '4'
      } else if (data === '自送') {
        return '5'
      }
    },
    // 删除
    delData () {
      let $this = this
      if (this.selectedRows.length > 0) {
        this.$confirm('是否删除数据', '提示', {
          confirmButtonText: '确认',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let dbData = []
          let notDbData = []
          $this.selectedRows.forEach(it => {
            if (it.isNoDBData === '1') {
              notDbData.push(it)
            } else {
              dbData.push(it)
            }
          })
          if (dbData.length === 0) {
            notDbData.forEach(it1 => {
              this.formTableData.sourceData.forEach((it2, index) => {
                if (it2.status) {
                  if (it2.index === it1.index) {
                    this.formTableData.sourceData.splice(index, 1)
                  }
                }
              })
            })
            this.success('删除成功')
          } else {
            let keyIds = []
            dbData.forEach(it => {
              keyIds.push(it.assetPoolMaterialGroupId)
            })
            expressApi.expressFileReceiveApi.dels(keyIds).then(res => {
              if (res.success && res.data) {
                this.deleteItem = Object.assign({}, { data: res.data })
                this.dialogVisible = true
                this.handleFilter(this.preQueryParas)
              } else {
                this.error('删除失败')
              }
            })
          }
        })
      } else {
        this.warning('请选择数据')
      }
    },
    // 新增
    addData () {
      // if (!this.UtilJs.isEmpty(this.queryParas.coreEnterpriseId) &&
      //   this.queryParas.taskType &&
      //   this.queryParas.taskType.length > 0 &&
      //   !this.UtilJs.isEmpty(this.queryParas.projectId)) {
      // } else {
      //   return this.warning('请选择任务类型,产品名称和核心企业')
      // }
      this.loading.createLoading = true
      let obj = {}
      obj.assetCode = ''
      obj.status = true
      obj.addStatus = '1'
      obj.index = this.index
      obj.fileName = ''
      obj.isNoDBData = '1'
      obj.isModify = true
      obj.copiesReceived = ''
      // 资料来源
      obj.receiveSource = ''
      // 来源人
      obj.receiverId = ''
      // 快递单号
      obj.expressNo = ''
      // 备注
      obj.memo = ''
      obj.headReceiverCode = 'noting'
      obj.addlocaltime = new Date().getTime()
      obj.option = []
      // this.formTableData.sourceData.push(obj)
      this.loading.createLoading = true
      this.formTableData.sourceData.push(obj)
      setTimeout(() => {
        this.$refs.xTable.setActiveCell(obj, 'assetCode').then(res => {
        }).finally(res => {
          this.loading.createLoading = false
        })
      }, 500)
    },
    // 保存
    save () {
      // this.$refs['formTableData'].clearValidate()
      this.checkFlag = true
      this.$nextTick(() => {
        this.saveData()
      })
    },
    // 提交
    submit () {
      let ismodify = this.formTableData.sourceData.some(it => {
        return it.isModify === true
      })
      if (ismodify) {
        this.$confirm(this.$i18n.messages[this.$i18n.locale].expressDataList.ismodifySave, '提示', { type: 'warning' }).then(res => {
          this.$refs['formTableData'].clearValidate()
          this.checkFlag = true
          this.$nextTick(() => {
            this.submitNext()
          })
        })
      } else {
        this.$refs['formTableData'].clearValidate()
        this.checkFlag = true
        this.$nextTick(() => {
          this.submitNext()
        })
      }
    },
    // 保存、提交拼接数据
    handData (data) {
      let postData = this.copyData(data)
      postData.forEach(it => {
        it.ifsAddStatus = it.status
        if (!it.receiverId || it.receiverId === '') it.receiverId = '-1'
        if (it.option) delete it.option
        if (!it.assetReceivingInfoDTOList && it.assetReceivingMainDTO) delete it.materialFileId
        if (!it.assetReceivingInfoDTOList) it.assetReceivingInfoDTOList = []
        if (!it.assetReceivingMainDTO) it.assetReceivingMainDTO = {}
        if (it.receiver === it.receiverId) it.receiverId = '-1'
        if (it.assetReceivingInfoDTOList.length === 0) {
          it.assetReceivingInfoDTOList.push({
            assetPoolId: it.assetPoolId,
            assetPoolMaterialGroupId: it.assetPoolMaterialGroupId,
            expressNo: it.expressNo,
            fileCode: it.fileCode,
            fileName: it.fileName,
            memo: it.memo,
            receiveCopies: it.receiveCopies,
            receiveDate: new Date().getTime(),
            receiveId: it.receiveId,
            receiveSource: it.receiveSource,
            receiver: it.receiver,
            receiverId: it.receiverId,
            submitTaskDate: new Date().getTime(),
            taskType: it.taskType
          })
        } else {
          it.assetReceivingInfoDTOList.forEach(it1 => {
            it1.assetPoolId = it.assetPoolId
            it1.assetPoolMaterialGroupId = it.assetPoolMaterialGroupId
            it1.expressNo = it.expressNo
            it1.fileCode = it.fileCode
            it1.fileName = it.fileName
            it1.memo = it.memo
            it1.receiveCopies = it.receiveCopies
            it1.receiveDate = new Date().getTime()
            it1.receiveSource = it.receiveSource
            it1.receiver = it.receiver
            it1.receiverId = it.receiverId
            it1.submitTaskDate = new Date().getTime()
            it1.taskType = it.taskType
          })
        }
      })
      return postData
    },
    // 2020-3-20 重构保存
    saveData () {
      let $this = this
      if (this.selectedRows.length > 0) {
        this.$refs['formTableData'].validate((valid) => {
          if (valid) {
            let postData = this.handData(this.selectedRows)
            this.loading.saveLoading = true
            expressApi.expressFileReceiveApi.batchSave(postData).then(res => {
              if (res.success && res.data) {
                $this.success('保存成功')
                $this.formTableData.sourceData.forEach(it => {
                  it.isModify = false
                })
                $this.$nextTick(() => {
                  this.handleFilter(this.preQueryParas)
                })
              } else {
                $this.error('保存失败')
              }
            }).finally(() => {
              this.loading.saveLoading = false
            })
          } else {
            this.warning('请检查表格标红的数据是否正确')
            return false
          }
        })
      } else {
        this.warning('请选择要保存的数据')
      }
    },
    // 提交
    submitNext () {
      let $this = this
      if (this.selectedRows.length > 0) {
        this.$refs['formTableData'].validate((valid) => {
          if (valid) {
            let arr = this.handData(this.selectedRows)
            this.loading.submitLoading = true
            expressApi.expressFileReceiveApi.batchSubmit(arr).then(res => {
              if (res.success && res.data) {
                $this.success('提交成功')
                this.formTableData.sourceData.forEach(it => { it.isModify = false })
                $this.$nextTick(() => {
                  $this.handleFilter(this.preQueryParas)
                })
              } else {
                $this.error('提交失败')
              }
            }).finally(() => {
              this.loading.submitLoading = false
            })
          } else {
            this.warning('请检查表格标红的数据是否正确')
            return false
          }
        })
      } else {
        this.warning('请选择要提交的数据')
      }
    },
    // 表格选择付款确认书
    payCodeChanged (val, name, selectItemts, index) {
      if (!this.UtilJs.isEmpty(val)) {
        if (this.$refs['fileNameRef' + index]) {
          this.$refs['fileNameRef' + index].setQueryParas({ keyId: selectItemts.assetInfoId, materialGroupId: selectItemts.materialGroupId })
        }
        this.formTableData.sourceData[index].coreEnterpriseName = selectItemts.coreEnterpriseName
        this.formTableData.sourceData[index].factoringMoney = selectItemts.factoringMoney
        this.formTableData.sourceData[index].creditor = selectItemts.creditor
        this.formTableData.sourceData[index].debtor = selectItemts.debtor
        this.formTableData.sourceData[index].planningManagerName = selectItemts.planningManagerName
        this.formTableData.sourceData[index].customerAccountId = selectItemts.customerAccountId
        this.formTableData.sourceData[index].customerAccountName = selectItemts.customerAccountName
        this.formTableData.sourceData[index].offlineAuditPersonName = selectItemts.offlineAuditPersonName
        this.formTableData.sourceData[index].coreAreaName = selectItemts.coreAreaName
        this.formTableData.sourceData[index].needCopies = 1
        this.formTableData.sourceData[index].validCopies = selectItemts.validCopies
        this.formTableData.sourceData[index].taskType = '4'// selectItemts.taskType
        this.formTableData.sourceData[index].accomplishSituation = '0'
        this.formTableData.sourceData[index].assetInfoId = selectItemts.assetInfoId
        this.formTableData.sourceData[index].assetPoolId = selectItemts.assetPoolId
      }
    },
    // 扫描添加份数
    addFenFun (data) {
      this.formTableData.sourceData.forEach(it => {
        if (it.assetCode === data) {
          if (it.copiesReceived.toString().length === 0 || it.copiesReceived.toString() === '0') it.copiesReceived = '1'
          it.copiesReceived = (Number(it.copiesReceived) + 1).toString()
        }
      })
    },
    searchSelectChanged (a) {
      let keys = Object.keys(a)
      if (keys.some(it => it === 'coreEnterpriseIdInfo')) {
        this.$set(this.queryParas, 'coreArea', '')
      }
      if (keys.some(it => it === 'projectIdInfo')) {
        if (!this.UtilJs.isEmpty(a.projectIdInfo)) {
          componentsApi.productenterprise.getclassify({ projectId: a.projectIdInfo.keyId }).then(res => {
            if (res.data && res.data.productType && res.data.productType === '2') {
              this.$set(this.componentList[this.componentList.length - 2], 'disabled', true)
              this.$set(this.componentList[this.componentList.length - 2], 'placeholder', ' ')
            } else {
              this.$set(this.componentList[this.componentList.length - 2], 'disabled', false)
              this.$set(this.componentList[this.componentList.length - 2], 'placeholder', '请输入')
            }
          })
        } else {
          this.$set(this.componentList[this.componentList.length - 2], 'disabled', false)
          this.$set(this.componentList[this.componentList.length - 2], 'placeholder', '请输入')
        }
      }
      // if (keys.some(it => it === 'coreAreaInfo')) {
      //   this.queryParas.coreAreaName = (a.coreAreaInfo && a.coreAreaInfo.areaName) || ''
      // }
    },
    clearParam () {
      this.queryParas = {
        pageIndex: 1,
        pageSize: 10
      }
      this.$set(this.componentList[this.componentList.length - 2], 'disabled', false)
      this.$set(this.componentList[this.componentList.length - 2], 'placeholder', ' ')
    }
  },
  watch: {
    elHeightObj: {
      deep: true,
      immediate: true,
      handler (n, o) {
        this.$nextTick(() => {
          this.$refs.xTable.updateData()
        })
      }
    },
    '$attrs.isRefresh': {
      deep: true,
      handler (n, o) {
        this.isRefresh = false
        this.$nextTick(() => { this.isRefresh = true })
      }
    }
  }
}
</script>

<style scoped lang="scss">
  @import '~@/styles/shourang/expressFileReceive/expressFileReceiveList.scss';
</style>
