<!-- 导单管理 -->
<template>
  <div>
    <up-down-layout :header="$t('guideSheetManage.title1')" :handleFlag.sync="handleFlag">
      <search-form :formValue.sync="queryParas"
                   searchPerms="search"
                   @handleFilter="queryhandleFilter"
                   @clearParam="clearParam"
                   slot="query"
                   resetPerms="reset"
                   @selectChanged="selectChanged"
                   :componentList="componentList"></search-form>
      <template slot="table">
        <data-table :api="api" :deleteApi="api"
                    :headTitle = "$t('guideSheetManage.tableHead')"
                    :showSelection="true"
                    selectable="false"
                    :cellStyle="cellStyle"
                    :handleFlag.sync="handleFlag"
                    :sourceData.sync="sourceData"
                    :menuFlag="true"
                    :queryParas="queryParas"
                    @sort-change="sortChange"
                    :loadCount.sync="loadCount"
                    :columns="columns"
                    operateBtnLayout=""
                    :IsRight="false"
                    :pageAll="true"
                    v-bind="elHeightObj"
                    :operatWidth="'200'"
                    @selectRowChange="selectionData">
          <template slot="headButton">
              <div align="right">
                <auth-button icon="iconfont iconquxiao" size="medium"
                             type="primary" :label="$t('ladingManageList.cancelConfirmException')"
                             :menuCode="menuId" perms="cancelConfirmException" :openPerms="true" @click="cancelConfirmException"></auth-button>
                <auth-button size="medium" type="primary" icon="iconfont iconquerenyichang"
                             :menuCode="menuId" perms="confirmException" :openPerms="true"
                             :label="$t('guideSheetManage.confirmException')" @click="confirmException"></auth-button>
                <auth-button size="medium" type="primary" icon="iconfont icondaoru"
                             :menuCode="menuId" perms="showImport" :openPerms="true"
                             :label="$t('common.import')" @click="showImport"></auth-button>
                <auth-button size="medium" type="primary" icon="iconfont iconzhengshidaoru"
                             :menuCode="menuId" perms="formalIntroduc" :openPerms="true"
                             :label="$t('guideSheetManage.formalIntroduc')" @click="formalIntroduc"></auth-button>
                <auth-button size="medium" type="primary" icon="iconfont iconpiliangqueren"
                             :menuCode="menuId" perms="batchConfirm" :openPerms="true" :loading="patchOkloading"
                             :label="$t('guideSheetManage.batchConfirm')" @click="batchConfirm"></auth-button>
                <auth-button icon="iconfont icondaochu" size="medium" type="primary" :loading="loading"
                             :menuCode="menuId" perms="exportData" :openPerms="true"
                             :label="$t('common.export')" @click="exportData"></auth-button>
                <auth-button size="medium" type="primary" icon="iconfont iconpiliangjiance"
                             :menuCode="menuId" perms="resetbatchInspection" :openPerms="true"
                             :loading="batchInspectionLoading"
                             :label="$t('guideSheetManage.batchInspection')" @click="batchInspection"></auth-button>
                <auth-button size="medium" type="primary" icon="iconfont iconshezhibaolishenqingriqi"
                             :menuCode="menuId" perms="batchSetFactApplicationDate" :openPerms="true"
                             :label="$t('guideSheetManage.batchSetFactApplicationDate')" @click="batchSetFactApplicationDate"></auth-button>
              </div>
          </template>
          <!-- 操作 -->
          <el-table-column align="center" fixed="right"  :label="$t('common.operate')" width="240px">
            <template slot-scope="scope">
              <auth-button size="small" class="iconCircle" icon="iconfont iconjiance"
                           :menuCode="menuId" perms="testing" :openPerms="true" :loading="scope.row.batchInspectionLoading"
                           :title="$t('guideSheetManage.testing')" @click="handleClick(scope.row, 'T')"></auth-button>
              <auth-button v-if="scope.row.errorConfirmStatus === '0'" size="small" class="iconCircle" icon="iconfont iconbianji"
                           :menuCode="menuId" perms="edit" :openPerms="true"
                           :title="$t('common.edit')" @click="handleClick(scope.row, 'E')"></auth-button>
              <auth-button v-if="scope.row.errorConfirmStatus === '0'" size="small" class="iconCircle" icon="iconfont iconyichangshujutiaozheng"
                           :menuCode="menuId" perms="abnormalDataTrim" :openPerms="true"
                           :title="$t('guideSheetManage.abnormalDataTrim')" @click="handleClick(scope.row, 'ADT')"></auth-button>
              <auth-button size="small" class="iconCircle" icon="iconfont iconlvli"
                           :menuCode="menuId" perms="curriculumVitae" :openPerms="true"
                           :title="$t('guideSheetManage.curriculumVitae')" @click="handleClick(scope.row, 'CV')"></auth-button>
            </template>
          </el-table-column>
        </data-table>
      </template>
    </up-down-layout>
    <guide-sheet-manage-edit :visible.sync="gsmEditVisible" editModel="E" :form="gsmEditItem" @close="queryhandleFilter" :menuCode="menuId"></guide-sheet-manage-edit>
    <guide-sheet-manage-batchSet :visible.sync="gsmBatchSetVisible" editModel="E" :form="gsmBatchSetItem" @savefinish="queryhandleFilter" :menuCode="menuId"></guide-sheet-manage-batchSet>
    <abnormal-data-adjustment-edit :visible.sync="abnormalDataAdjustmentVisible" editModel="E" :form="item" @close="queryhandleFilter" :menuCode="menuId"></abnormal-data-adjustment-edit>
    <record-info-edit :visible.sync="recordInfoVisible" editModel="V" :form="item"></record-info-edit>
    <import-edit code="30" :menuCode="menuId" :visible.sync="importVisible" editModel="E" :form="item"></import-edit>
    <formal-import-result :visible.sync="importResultVisible" editModel="V" :form="item" :menuCode="menuId" @close="queryhandleFilter"></formal-import-result>
    <confirm-exception-result :visible.sync="singlePushResultVisible" :editModel="'V'" :form="item" @close="queryhandleFilter"></confirm-exception-result>
    <single-push-result :visible.sync="singlePushResultVisibleitem" :editModel="'V'" :form="item"></single-push-result>
  </div>
</template>
<script>
import { searchForm, upDownLayout, DataTable, btnExport, SelectPeriodsCascade,
  authButton, SelectAreaCode, SelectSmallArea, SelectSupplier,
  SelectCoreEnterpriseCascade, SelectProductName, SelectFinancialInstitutionsCascade,
  SelectAssetsServiceCascade, SelectPrimitiveRightsHolderCascade } from 'newepoch-components'
import BasePage from '@/pages/basePage'
import GuideSheetManageEdit from '@/pages/shouji/ladingManage/ladingManageEdit.vue'
import GuideSheetManageBatchSet from '@/pages/shouji/guideSheetManage/guideSheetManageBatchSet'
import ConfirmExceptionResult from '@/pages/shouji/guideSheetManage/confirmExceptionResult'
import guideSheetManageApi from '@/api/guideSheetManageApi'
import AbnormalDataAdjustmentEdit from '@/pages/shouji/guideSheetManage/abnormalDataAdjustmentEdit'
import RecordInfoEdit from '@/pages/shouji/guideSheetManage/recordInfoEdit'
import ImportEdit from '@/pages/shouji/guideSheetManage/importEdit'
import ladingManageApi from '@/api/ladingManageApi'
import fileApi from '@/api/fileApi.js'
import componentsApi from '@/api/componentsApi'
import { downFile } from '@/utils/devUtils'
import mixin from '@/pages/mixin'
import * as format from '@/filters/index'
import formalImportResult from '@/pages/shouji/guideSheetManage/formalImportResultModify'
import singlePushResult from '@/pages/shouji/ladingManage/batchConfirmationResult'

export default {
  extends: new BasePage('guideSheetManage'),
  mixins: [mixin],
  name: 'guideSheetManageList',
  components: {
    ConfirmExceptionResult,
    searchForm,
    upDownLayout,
    DataTable,
    btnExport,
    authButton,
    GuideSheetManageEdit,
    GuideSheetManageBatchSet,
    AbnormalDataAdjustmentEdit,
    RecordInfoEdit,
    ImportEdit,
    SelectAreaCode,
    formalImportResult,
    singlePushResult
  },
  mounted () {
    if (this.queryParas) {
      this.queryParas = Object.assign({}, { pageIndex: 1, officalLadingStatus: '0', pageSize: 10 })
    }
  },
  // activated () {
  //   if (this.queryParas) {
  //     this.queryParas = Object.assign({}, { pageIndex: 1, officalLadingStatus: '0', pageSize: 10 })
  //   }
  // },
  data () {
    const labelWidth = '165px' // 整体搜索文字大小
    return {
      patchOkloading: false,
      loading: false,
      singlePushResultVisibleitem: false,
      formatDict: format.formatDict,
      templateCode: 'shourang002',
      handleFlag: true,
      abnormalDataAdjustmentVisible: false,
      recordInfoVisible: false,
      importVisible: false,
      forceAllFiles: false,
      gsmEditVisible: false,
      gsmEditItem: {},
      batchInspectionLoading: false,
      gsmBatchSetVisible: false,
      importResultVisible: false,
      gsmBatchSetItem: {},
      loadCount: 0,
      singlePushResultVisible: false,
      queryParas: {
        fileBussType: '1',
        officalLadingStatus: '0',
        projectCompanyId: null
      },
      queryData: {},
      componentList: [
        {
          // 产品名称
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.productName,
          value: 'projectId',
          labelWidth: labelWidth,
          name: 'projectName',
          clearable: true,
          componentName: SelectProductName
        },
        {
          // 期数
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.specialPlanPeriods,
          value: 'specialPlanPeriodsId',
          name: 'specialPlanPeriodsId',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseInput,
          labelWidth: labelWidth,
          clearable: true,
          queryName: 'projectId',
          queryValue: 'projectId',
          componentName: SelectPeriodsCascade
        },
        {
          // 核心企业
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.coreEnterpriseName,
          disabled: false,
          value: 'coreEnterpriseId',
          name: 'coreEnterpriseId',
          queryName: 'projectId',
          queryValue: 'projectId',
          labelWidth: labelWidth,
          clearable: true,
          componentName: SelectCoreEnterpriseCascade
        },
        {
          // 计划管理人/再保理银行
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.planningManagerName,
          disabled: false,
          value: 'planningManagerId',
          labelWidth: labelWidth,
          queryName: 'projectId',
          queryValue: 'projectId',
          clearable: true,
          componentName: SelectFinancialInstitutionsCascade
        },
        {
          // 原始权益人
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.initialOwnersName,
          disabled: false,
          value: 'initialOwnersId',
          labelWidth: labelWidth,
          clearable: true,
          queryName: 'projectId',
          queryValue: 'projectId',
          componentName: SelectPrimitiveRightsHolderCascade
        },
        {
          // 资产服务机构
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.assetServiceOrgan,
          disabled: false,
          value: 'assetServiceId',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseSelect,
          queryName: 'projectId',
          queryValue: 'projectId',
          labelWidth: labelWidth,
          clearable: true,
          componentName: SelectAssetsServiceCascade
        },
        {
          // 区域编号
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.regionCode,
          disabled: false,
          value: 'regionCode',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseSelect,
          componentName: 'el-input',
          clearable: true,
          labelWidth: labelWidth
        },
        {
          // 区域
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.region,
          labelWidth: labelWidth,
          value: 'coreArea',
          name: 'coreArea',
          multiple: false,
          componentName: SelectSmallArea,
          queryName: 'coreCompanyId',
          queryValue: 'coreEnterpriseId',
          clearable: true,
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseSelect
        },
        {
          // 供应商名称
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.supplierName,
          value: 'creditorId',
          componentName: SelectSupplier,
          labelWidth: labelWidth,
          queryName: 'projectId',
          queryValue: 'projectId',
          clearable: true,
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseSelect
        },
        {
          // 收款人名称
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.payee,
          value: 'receiverName',
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseInput,
          labelWidth: labelWidth,
          clearable: true,
          componentName: 'el-input'
        },
        {
          // 正式导入状态
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.formalImportStatus,
          disabled: false,
          value: 'officalLadingStatus',
          labelWidth: labelWidth,
          clearable: false,
          componentName: 'SelectDictionary',
          dictTypeCode: 'ZD0104'
        },
        // 是否确认异常
        {
          label: this.$i18n.messages[this.$i18n.locale].ladingManageList.isHandleException,
          value: 'errorConfirmStatus',
          clearable: true,
          componentName: 'SelectDictionary',
          dictTypeCode: 'SJ010',
          labelWidth: labelWidth
        }
      ],
      columns: [
        {
          // 产品名称
          prop: 'projectName',
          align: 'left',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.productName,
          width: '200px'
        },
        {
          // 期数
          prop: 'specialPlanPeriods',
          align: 'left',
          width: '60px',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.specialPlanPeriods,
          format: (row) => {
            if (!row.specialPlanPeriods || row.specialPlanPeriods.toString() === '0') {
              return ''
            } else {
              return row.specialPlanPeriods
            }
          }
        },
        {
          // 核心企业
          prop: 'coreEnterpriseName',
          align: 'left',
          width: '200px',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.coreEnterpriseName
        },
        {
          // 应收账款金额
          prop: 'factoringMoney',
          align: 'right',
          width: '170px',
          sortable: true,
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.accountsReceivable,
          format: (row) => { return format.thousandFilter(row.factoringMoney) }
        },
        {
          // 项目公司名称
          prop: 'debtor',
          align: 'left',
          width: '200px',
          sortable: true,
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.projectCompanyName
        },
        {
          // 开户行
          prop: 'receiverBank',
          align: 'center',
          width: '200px',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.openingBank,
          format: (row) => { return format.formatDict(row.receiverBank, 'bank_id') }
        },
        {
          // 收款账号
          prop: 'receiverBankAccount',
          align: 'left',
          width: '200px',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.receivingAccount
        },
        {
          // 账号名称
          prop: 'receiverAccountName',
          align: 'left',
          width: '200px',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.accountName
        },
        {
          // 付款确认书编号
          prop: 'assetCode',
          align: 'left',
          width: '260px',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.payCode
        },
        {
          // 发票号码
          prop: 'invoiceNo',
          align: 'left',
          width: '200px',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.invoiceNum
        },
        {
          // 发票金额
          prop: 'taxExcludingAmount',
          align: 'right',
          width: '150px',
          sortable: true,
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.invoiceAmount,
          format: (row) => { return format.thousandFilter(row.taxExcludingAmount) }
        },
        {
          // 正式提单确认状态
          prop: 'officalLadingConfirmStatus',
          align: 'center',
          width: '150px',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.formalBillConfirmStatus,
          format: (row) => { return format.formatDict(row.officalLadingConfirmStatus, 'ZD0103') }
        },
        {
          // 区域编号
          prop: 'regionCode',
          align: 'left',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.regionCode,
          width: '160px'
        },
        {
          // 区域
          prop: 'coreAreaName',
          align: 'left',
          width: '120px',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.region
        },
        {
          // 供应商名称
          prop: 'creditor',
          align: 'left',
          width: '200px',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.suppliersName
        },
        {
          // 收款人名称
          prop: 'receiverName',
          align: 'left',
          width: '200px',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.payee
        },
        {
          // 保理申请日期
          prop: 'factoringApplyTime',
          align: 'center',
          width: '150px',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.factApplicationDate,
          format: (row) => { return format.formatDate(row.factoringApplyTime, 'yyyy-MM-dd hh:mm') }
        },
        {
          // 正式导入状态
          prop: 'officalLadingStatus',
          align: 'center',
          width: '120px',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.status,
          format: (row) => { return format.formatDict(row.officalLadingStatus, 'ZD0104') }
        },
        {
          // 检测结果
          prop: 'errorConfirmStatus',
          align: 'center',
          width: '90px',
          label: this.$i18n.messages[this.$i18n.locale].guideSheetManage.detectionResult,
          format: (row) => { return format.formatDict(row.errorConfirmStatus, 'SJ010') }
        }
      ],
      sourceData: [],
      selectRows: []
    }
  },
  computed: {
    api () {
      return guideSheetManageApi.guideSheetManage
    }
  },
  methods: {
    // 根据ID获取产品类别
    getTypeById () {
      componentsApi.productenterprise.getclassify({ projectId: this.queryParas.projectId }).then(res => {
        let disabled = res.data ? res.data.productType : '2'
        this.$set(this.componentList[1], 'disabled', disabled !== '1')
        this.$set(this.queryParas, 'specialPlanPeriodsId', '')
      })
    },
    selectChanged (obj) {
      if (obj.specialPlanPeriodsIdInfo) {
        this.queryParas.specialPlanPeriods = obj.specialPlanPeriodsIdInfo.specialPlanPeriods
      }
      if (obj.projectNameInfo) {
        this.getTypeById()
      }
      if (Object.keys(obj).some(it => it === 'projectNameInfo')) {
        this.clearInfoList()
      }
      // if (Object.keys(obj).some(it => it === 'coreEnterpriseIdInfo')) {
      //   if (obj.coreEnterpriseIdInfo) {
      //     console.log(JSON.stringify(obj.coreEnterpriseIdInfo), JSON.stringify(this.queryParas.coreEnterpriseId))
      //     if (!this.queryParas.coreEnterpriseId || obj.coreEnterpriseIdInfo.enterpriseId !== this.queryParas.coreEnterpriseId) {
      //       this.clearcoreAreaId()
      //     }
      //   } else {
      //     this.clearcoreAreaId()
      //   }
      // }
    },
    sortChange (columDate) {
      if (columDate.order) {
        let shenjiang = (columDate.order.indexOf('desc') > 0) ? '1' : '2'
        if (!this.queryParas.sortInfoList) {
          this.queryParas.sortInfoList = [
            {
              field: columDate.prop,
              sortType: shenjiang
            }
          ]
        } else {
          let isYou = false
          this.queryParas.sortInfoList.forEach(it => {
            if (it.field === columDate.prop) {
              it.sortType = shenjiang
              isYou = true
            }
          })
          if (!isYou) {
            this.queryParas.sortInfoList.push({ field: columDate.prop, sortType: shenjiang })
          }
        }
      } else {
        this.queryParas.sortInfoList = this.queryParas.sortInfoList.filter(it => it.field !== columDate.prop)
      }
      this.queryhandleFilter()
    },
    cellStyle ({ row, column, rowIndex, columnIndex }) {
      if (row.errorFields instanceof Array) {
        let flag = false
        row.errorFields.forEach(it => {
          if (it === column.property) {
            flag = true
          }
        })
        if (flag) {
          return 'color: red'
        } else {
          return ''
        }
      } else {
        return ''
      }
    },
    batchSetFactApplicationDate () {
      // 批量设置保理申请日期
      if (this.selectRows.length > 0) {
        this.gsmBatchSetItem = Object.assign({}, { data: this.selectRows })
        this.gsmBatchSetVisible = true
      } else {
        this.warning(this.$i18n.messages[this.$i18n.locale].guideSheetManage.pleaseData)
      }
    },
    // 确认异常
    confirmException () {
      // 确认异常
      if (this.selectRows.length > 0) {
        this.$confirm(this.$i18n.messages[this.$i18n.locale].guideSheetManage.whetherAbnormalData,
          this.$i18n.messages[this.$i18n.locale].common.tip, {
            confirmButtonText: this.$i18n.messages[this.$i18n.locale].okbtn,
            cancelButtonText: this.$i18n.messages[this.$i18n.locale].cancelbtn,
            type: 'warning'
          }).then(() => {
          let data = JSON.parse(JSON.stringify(this.selectRows))
          data.forEach(it => {
            it.errorConfirmStatus = '1'
          })
          ladingManageApi.ladingManageList.confirmException(data).then(res => {
            if (res.success && res.data) {
              // this.success('操作成功！')
              this.queryhandleFilter()
              this.item = Object.assign({ single: 0 }, { data: res.data })
              this.singlePushResultVisible = true
              // this.success(this.$i18n.messages[this.$i18n.locale].guideSheetManage.confirmExceptionOk)
            } else {
              this.error(this.$i18n.messages[this.$i18n.locale].guideSheetManage.confirmExceptionFailed)
            }
          })
        })
      } else {
        this.warning(this.$i18n.messages[this.$i18n.locale].guideSheetManage.pleaseData)
      }
    },
    // 取消确认
    cancelConfirmException () {
      // 取消确认
      if (this.selectRows.length > 0) {
        this.$confirm(this.$i18n.messages[this.$i18n.locale].guideSheetManage.cancelwhetherAbnormalData,
          this.$i18n.messages[this.$i18n.locale].common.tip, {
            confirmButtonText: this.$i18n.messages[this.$i18n.locale].okbtn,
            cancelButtonText: this.$i18n.messages[this.$i18n.locale].cancelbtn,
            type: 'warning'
          }).then(() => {
          let data = JSON.parse(JSON.stringify(this.selectRows))
          data.forEach(it => {
            it.errorConfirmStatus = '0'
          })
          ladingManageApi.ladingManageList.confirmException(data).then(res => {
            if (res.success && res.data) {
              // this.success('操作成功！')
              this.queryhandleFilter()
              this.item = Object.assign({ single: 1 }, { data: res.data })
              this.singlePushResultVisible = true
              // this.success(this.$i18n.messages[this.$i18n.locale].guideSheetManage.confirmExceptionOk)
            } else {
              this.error(this.$i18n.messages[this.$i18n.locale].guideSheetManage.cancelconfirmExceptionFailed)
            }
          })
        })
      } else {
        this.warning(this.$i18n.messages[this.$i18n.locale].guideSheetManage.pleaseselectcancelabnormalData)
      }
    },
    // 批量检测
    batchInspection () {
      if (this.selectRows.length > 0) {
        this.batchInspectionFun(this.selectRows, true)
      } else {
        this.warning('请选择数据')
      }
    },
    batchInspectionFun (data, isBatch) {
      // let flag = false
      let psot = data.filter(it => {
        return it.errorConfirmStatus !== '1'
      })
      // data.forEach(it => {
      //   if (it.errorConfirmStatus === '1') {
      //     flag = true
      //   }
      // })
      if (psot.length === 0) {
        this.warning(this.$i18n.messages[this.$i18n.locale].ladingManageList.pleaseCheckUnData)
        return false
      }
      if (!isBatch) {
        data.forEach(it => {
          this.$set(it, 'batchInspectionLoading', true)
        })
      } else {
        this.batchInspectionLoading = true
      }
      let $this = this
      ladingManageApi.ladingManageList.batchInspection(psot).then(res => {
        $this.success(this.$i18n.messages[this.$i18n.locale].ladingManageList.checkWanCheng)
        if (res.success) {
          if (res.data.length > 0) {
            data.forEach(it => {
              res.data.forEach(it1 => {
                if (it.keyId === it1.keyId) {
                  this.$set(it, 'errorFields', it1.errorFields)
                  this.$set(it, 'errorConfirmStatus', it1.errorConfirmStatus)
                }
              })
            })
          } else {
            $this.warning(this.$i18n.messages[this.$i18n.locale].ladingManageList.okdataNocheck)
          }
        } else {
          $this.error(this.$i18n.messages[this.$i18n.locale].ladingManageList.batchFaile)
        }
      }).finally((res) => {
        if (!isBatch) {
          data.forEach(it => {
            this.$set(it, 'batchInspectionLoading', false)
          })
        } else {
          this.batchInspectionLoading = false
        }
      })
    },
    // 导出
    exportData () {
      if (this.selectRows.length > 0) {
        let $this = this
        let arr = []
        this.selectRows.forEach(it => {
          arr.push(it.keyId)
        })
        $this.loading = true
        ladingManageApi.ladingManageList.export({ assetInfoIds: arr, type: '3' }).then(res => {
          if (res.success) {
            fileApi.file.download({ keyId: res.data }).then(res => {
              downFile(res)
              $this.loading = false
            }).catch(() => {
              $this.loading = false
            })
          } else {
            $this.loading = false
            $this.error('导出失败')
          }
        }).catch(() => {
          $this.loading = false
        })
      } else {
        this.warning('请选择数据')
      }
    },
    // 批量确认
    batchConfirm () {
      if (this.selectRows.length > 0) {
        this.patchOkloading = true
        guideSheetManageApi.confirmcheck.getConfirmBatch(this.selectRows).then(res => {
          this.success(this.$i18n.messages[this.$i18n.locale].guideSheetManage.confirmBatch)
          this.singlePushResultVisibleitem = true
          this.item = Object.assign({}, { data: res.data })
          this.queryhandleFilter()
        }).finally(() => {
          this.patchOkloading = false
        })
      } else {
        this.warning(this.$i18n.messages[this.$i18n.locale].guideSheetManage.pleaseData)
      }
    },
    formalIntroduc () {
      if (this.selectRows.length > 0) {
        this.importResultVisible = true
        this.item = Object.assign({}, { data: this.selectRows })
        // this.api.getFormalPayconfirm(this.selectRows).then(res => {
        //   if (res && res.data) {
        //     this.importResultVisible = true
        //     this.item = Object.assign({}, res.data)
        //   }
        // })
      } else {
        this.warning(this.$i18n.messages[this.$i18n.locale].guideSheetManage.pleaseData)
      }
    },
    clearParam () {
      this.queryParas = {
        pageIndex: 1,
        officalLadingStatus: '0',
        pageSize: 10
      }
    },
    // 弹出异常数据调整
    showAbnormalDataAdjustment (row) {
      this.item = Object.assign({}, row)
      this.abnormalDataAdjustmentVisible = true
    },
    selectionData (value) {
      this.selectRows = value
    },
    // 弹出履历
    showRecordInfo (row) {
      this.item = Object.assign({}, row)
      this.recordInfoVisible = true
    },
    // 弹出导入
    showImport () {
      this.item = {}
      this.importVisible = true
    },
    // T 检测 E 编辑 ADT异常数据调整 CV履历
    handleClick (row, emonType) {
      if (emonType === 'E') {
        this.gsmEditItem = Object.assign({}, row)
        this.gsmEditVisible = true
      } else if (emonType === 'CV') {
        this.showRecordInfo(row)
      } else if (emonType === 'ADT') {
        this.showAbnormalDataAdjustment(row)
      } else if (emonType === 'T') {
        this.batchInspectionFun([row], false)
      }
    },
    clearInfoList () {
      this.$set(this.componentList[1], 'disabled', false)
      delete this.queryParas.coreEnterpriseId
      delete this.queryParas.planningManagerId
      delete this.queryParas.initialOwnersId
      delete this.queryParas.assetServiceId
      delete this.queryParas.coreArea
      delete this.queryParas.specialPlanPeriodsId
      delete this.queryParas.specialPlanPeriods
      if (!this.queryParas.projectId) {
        delete this.queryParas.projectId
      }
    },
    clearcoreAreaId () {
      delete this.queryParas.coreArea
      if (!this.queryParas.coreEnterpriseId) {
        delete this.queryParas.coreEnterpriseId
      }
    },
    queryhandleFilter () {
      if (!this.UtilJs.isEmpty(this.queryParas.regionCode)) {
        this.queryParas.regionCode = this.queryParas.regionCode.trim()
      }
      if (!this.UtilJs.isEmpty(this.queryParas.receiverName)) {
        this.queryParas.receiverName = this.queryParas.receiverName.trim()
      }
      this.handleFilter()
    }
  },
  watch: {
    // 'queryParas.projectId' (n, o) {
    //   this.$set(this.componentList[1], 'disabled', false)
    //   delete this.queryParas.coreEnterpriseId
    //   delete this.queryParas.planningManagerId
    //   delete this.queryParas.initialOwnersId
    //   delete this.queryParas.assetServiceIdcoreAreaId
    //   delete this.queryParas.coreAreaId
    // },
    'queryParas.coreEnterpriseId' (n, o) {
      this.clearcoreAreaId()
    }
  }
}
</script>
<style scoped lang="scss">
  @import '~@/styles/sj/guideSheetManage/guideSheetManageList.scss';
</style>
