<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
  <div>
    <el-row>
      <el-form :model="inputForm" ref="inputForm" v-loading="loading" :class="method === 'view' ? 'readonly' : ''"
        :disabled="status === 'taskFormDetail' || status === 'audit'" label-width="135px" @submit.native.prevent>

        <el-divider content-position="left"><i class="el-icon-document"></i> 项目信息</el-divider>
        <el-row :gutter="0">
          <el-col :span="12">
            <el-form-item label="项目名称" prop="projectName" :rules="[
            ]">
              <!--                <el-input v-model="inputForm.projectName" placeholder="请填写项目名称" clearable></el-input>-->
              <el-input :disabled="true" :readonly="true" @focus="openContractForm()" v-model="inputForm.projectName"
                placeholder="请选择项目名称">
                <el-button slot="append" :disabled="true" icon="el-icon-search" @click="openContractForm()"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目编号" prop="projectNumber" :rules="[
            ]">
              <el-input :disabled="true" v-model="inputForm.projectNumber" placeholder="请填写项目编号" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目经理1" prop="projectMasterName" :rules="[
            ]">
              <el-input :disabled="true" v-model="inputForm.projectMasterName" placeholder="请填写项目经理1"
                clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目经理2" prop="realHeaderName" :rules="[
            ]">
              <el-input :disabled="true" v-model="inputForm.realHeaderName" placeholder="请填写项目经理2" clearable></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider content-position="left"><i class="el-icon-document"></i> 基础信息</el-divider>
        <el-row :gutter="0">
          <el-col :span="12">
            <el-form-item label="单据编号" prop="documentNo" :rules="[

            ]">
              <el-input :disabled="true" v-model="inputForm.documentNo" placeholder="自动生成" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报告所属部门" prop="officeId" :rules="[
            ]">
              <SelectTree ref="officeTree" :props="{
                value: 'id',             // ID字段名
                label: 'name',         // 显示名称
                children: 'children'    // 子级字段名
              }" :url="`/system-server/sys/office/treeData?type=2`" :value="inputForm.officeId" size="default"
                :accordion="true" :disabled="true" @getValue="(value) => { inputForm.officeId = value }" />
            </el-form-item>
          </el-col>
          <el-col :span="12"
            v-if="!inputForm.signatureType || (inputForm.signatureType === '1' && inputForm.status1 !== '4') || (inputForm.signatureType === '2' && inputForm.status2 !== '4') || (inputForm.signatureType === '3' && inputForm.status3 !== '4')">
            <el-form-item label="盖章类型" prop="signatureType" :rules="[
              { required: true, message: '盖章类型不能为空', trigger: 'change' }
            ]">
              <!--                <el-input v-model="inputForm.signatureType" placeholder="请填写盖章类型" clearable></el-input>-->
              <el-select v-model="inputForm.signatureType" placeholder="请选择盖章类型" clearable style="width: 100%;">
                <el-option v-for="item in $dictUtils.getDictList('cw_signature_type')" :key="item.value"
                  :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12"
            v-if="(inputForm.signatureType === '1' && inputForm.status1 === '4') || (inputForm.signatureType === '2' && inputForm.status2 === '4') || (inputForm.signatureType === '3' && inputForm.status3 === '4')">
            <el-form-item label="盖章类型" prop="signatureType" :rules="[
              { required: true, message: '盖章类型不能为空', trigger: 'change' }
            ]">
              <!--                <el-input v-model="inputForm.signatureType" placeholder="请填写盖章类型" clearable></el-input>-->
              <el-select :disabled="true" v-model="inputForm.signatureType" placeholder="请选择盖章类型" clearable
                style="width: 100%;">
                <el-option v-for="item in $dictUtils.getDictList('cw_signature_type')" :key="item.value"
                  :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col
            v-if="inputForm.signatureType === '1' || inputForm.signatureType === '3' || commonJS.isEmpty(inputForm.signatureType)"
            :span="12">
            <el-form-item label="签字注师1" prop="signatureAnnotator1" :rules="[
              { required: true, message: '签字注师1不能为空', trigger: 'change' },
              { required: true, message: '签字注师1不能为空', trigger: 'blur' }
            ]">
              <!--                <el-input v-model="inputForm.signatureAnnotator1" placeholder="请填写签字注师1" clearable></el-input>-->
              <UserSelect style="width: 100%" ref="userSelect1" :readonly="true" :limit='1'
                :modelValue="inputForm.signatureAnnotator1" @update:modelValue='(value) => { changeSignatory1(value) }'>
              </UserSelect>
            </el-form-item>
          </el-col>

          <el-col
            v-if="inputForm.signatureType === '1' || inputForm.signatureType === '3' || commonJS.isEmpty(inputForm.signatureType)"
            :span="12">
            <el-form-item label="签字注师2" prop="signatureAnnotator2" :rules="[
              // {required: true, message: '签字注师2不能为空', trigger: 'change'},
              // {required: true, message: '签字注师2不能为空', trigger: 'blur'}
            ]">
              <!--                <el-input v-model="inputForm.signatureAnnotator2" placeholder="请填写签字注师2" clearable></el-input>-->
              <UserSelect2 style="width: 100%" ref="userSelect2" :readonly="true" :limit='1'
                :modelValue="inputForm.signatureAnnotator2" @update:modelValue='(value) => { changeSignatory2(value) }'>
              </UserSelect2>
            </el-form-item>
          </el-col>

          <el-col v-if="inputForm.signatureType === '2'" :span="12">
            <el-form-item label="签字注师1" prop="signatureAnnotator1" :rules="[
              { required: true, message: '签字注师1不能为空', trigger: 'change' },
              { required: true, message: '签字注师1不能为空', trigger: 'blur' }
            ]">
              <!--                <el-input v-model="inputForm.signatureAnnotator1" placeholder="请填写签字注师1" clearable></el-input>-->
              <UserSelect style="width: 100%" ref="userSelect1" :readonly="true" :limit='1'
                :modelValue="inputForm.signatureAnnotator1" @update:modelValue='(value) => { changeSignatory1(value) }'>
              </UserSelect>
            </el-form-item>
          </el-col>

          <el-col v-if="inputForm.signatureType === '2'" :span="12">
            <el-form-item label="签字注师2" prop="signatureAnnotator2" :rules="[
              { required: true, message: '签字注师2不能为空', trigger: 'change' },
              { required: true, message: '签字注师2不能为空', trigger: 'blur' }
            ]">
              <!--                <el-input v-model="inputForm.signatureAnnotator2" placeholder="请填写签字注师2" clearable></el-input>-->
              <UserSelect2 style="width: 100%" ref="userSelect2" :readonly="true" :limit='1'
                :modelValue="inputForm.signatureAnnotator2" @update:modelValue='(value) => { changeSignatory2(value) }'>
              </UserSelect2>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审计意见类型" prop="opinionType" :rules="[
            ]">
              <el-select :disabled="true" v-model="inputForm.opinionType" placeholder="请选择审计意见类型" style="width:100%;">
                <el-option v-for="item in $dictUtils.getDictList('cw_opinion_type')" :key="item.value"
                  :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审计收费(税前、元)" prop="auditFees" :rules="[
            ]">
              <el-input :disabled="true" v-model="inputForm.auditFees" placeholder="请填写审计收费(税前、元)" clearable
                @keyup.native="inputForm.auditFees = twoDecimalPlaces(inputForm.auditFees)"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="报告实际制作人" prop="realCreate" :rules="[
            ]">
              <UserSelectAll :readonly="true" :disabled="true" :limit='1' :modelValue="inputForm.realCreate"
                @update:modelValue='(value) => { inputForm.realCreate = value }'></UserSelectAll>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="创建时间" prop="createDate" :rules="[
            ]">
              <el-input :disabled="true" v-model="inputForm.createDate" placeholder="请填写创建时间" clearable></el-input>
            </el-form-item>
          </el-col>

        </el-row>
        <el-divider content-position="left"><i class="el-icon-document"></i> 报告信息</el-divider>
        <el-row :gutter="0">
          <el-col :span="12">
            <el-form-item label="被服务单位" prop="servedUnitName" :rules="[
            ]">
              <el-input :disabled="true" :readonly="true" @focus="openWorkClient()" v-model="inputForm.servedUnitName"
                placeholder="请填写被服务单位" clearable>
                <el-button slot="append" icon="el-icon-search" @click="openWorkClient()"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报告类型" prop="reportType" :rules="[
            ]">
              <el-select :disabled="true" v-model="inputForm.reportType" placeholder="请选择报告类型" style="width:100%;">
                <el-option v-for="item in $dictUtils.getDictList('cw_report_title_type')" :key="item.value"
                  :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属行业" prop="industry" :rules="[
              { required: true, message: '所属行业不能为空', trigger: 'change' }
            ]">
              <el-select v-model="inputForm.industry" placeholder="请选择所属行业" style="width:100%;">
                <el-option v-for="item in $dictUtils.getDictList('cw_industry')" :key="item.value" :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="业务对象" prop="businessObjects" :rules="[
              { required: true, message: '业务对象不能为空', trigger: 'change' }
            ]">
              <el-select v-model="inputForm.businessObjects" placeholder="请选择业务对象" style="width:100%;">
                <el-option v-for="item in $dictUtils.getDictList('cw_business_objects')" :key="item.value"
                  :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="业务类型" prop="businessType" :rules="[
            ]">
              <el-select :disabled="true" v-model="inputForm.businessType" placeholder="请选择业务类型" style="width:100%;">
                <el-option v-for="item in $dictUtils.getDictList('cw_business_type')" :key="item.value"
                  :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="inputForm.businessType === '1'">
            <el-form-item label="审计业务类型" prop="auditBusinessType" :rules="[
            ]">
              <el-select :disabled="true" v-model="inputForm.auditBusinessType" placeholder="请选择审计业务类型"
                style="width:100%;">
                <el-option v-for="item in $dictUtils.getDictList('cw_audit_business_type1')" :key="item.value"
                  :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="inputForm.businessType === '2'">
            <el-form-item label="审计业务类型" prop="auditBusinessType" :rules="[
            ]">
              <el-select :disabled="true" v-model="inputForm.auditBusinessType" placeholder="请选择审计业务类型"
                style="width:100%;">
                <el-option v-for="item in $dictUtils.getDictList('cw_audit_business_type2')" :key="item.value"
                  :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="inputForm.businessType === '3'">
            <el-form-item label="审计业务类型" prop="auditBusinessType" :rules="[
            ]">
              <el-select :disabled="true" v-model="inputForm.auditBusinessType" placeholder="请选择审计业务类型"
                style="width:100%;">
                <el-option v-for="item in $dictUtils.getDictList('cw_audit_business_type3')" :key="item.value"
                  :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="inputForm.businessType === '4'">
            <el-form-item label="审计业务类型" prop="auditBusinessType" :rules="[
            ]">
              <el-select :disabled="true" v-model="inputForm.auditBusinessType" placeholder="请选择审计业务类型"
                style="width:100%;">
                <el-option v-for="item in $dictUtils.getDictList('cw_audit_business_type4')" :key="item.value"
                  :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="inputForm.businessType === '5'">
            <el-form-item label="审计业务类型" prop="auditBusinessType" :rules="[
            ]">
              <el-select :disabled="true" v-model="inputForm.auditBusinessType" placeholder="请选择审计业务类型"
                style="width:100%;">
                <el-option v-for="item in $dictUtils.getDictList('cw_audit_business_type5')" :key="item.value"
                  :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="inputForm.businessType === '6'">
            <el-form-item label="审计业务类型" prop="auditBusinessType" :rules="[
            ]">
              <el-select :disabled="true" v-model="inputForm.auditBusinessType" placeholder="请选择审计业务类型"
                style="width:100%;">
                <el-option v-for="item in $dictUtils.getDictList('cw_audit_business_type6')" :key="item.value"
                  :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报告流水号" prop="reportNumber" :rules="[
            ]">
              <el-input :disabled="true" v-model="inputForm.reportNumber" placeholder="自动生成" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报告文号" prop="reportNo" :rules="[
            ]">
              <el-input :disabled="true" v-model="inputForm.reportNo" placeholder="自动生成" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报告日期" prop="reportDate" :rules="[
              { required: true, message: '报告日期不能为空', trigger: 'blur' }
            ]">
              <el-date-picker :disabled="status === 'taskFormDetail' || status === 'audit'" placement="bottom-start"
                value-format="YYYY-MM-DD" v-model="inputForm.reportDate" style="width: 100%" placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <!--          <el-col :span="12">-->
          <!--            <el-form-item label="盖章状态" prop="sealType"-->
          <!--                          :rules="[-->
          <!--                   ]">-->
          <!--              <el-input :disabled="true" v-model="inputForm.sealType" placeholder="请填写盖章状态" clearable></el-input>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->

        </el-row>
        <el-divider content-position="left"><i class="el-icon-document"></i> 其他信息</el-divider>
        <el-row :gutter="0">
          <el-col :span="12">
            <el-form-item label="公司注册地址" prop="registerAddress" :rules="[
            ]">
              <el-input :disabled="status === 'taskFormDetail' || status === 'audit'"
                v-model="inputForm.registerAddress" placeholder="请填写公司注册地址" clearable>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="业务所在地" prop="businessLocation" :rules="[
            ]">
              <el-input :disabled="status === 'taskFormDetail' || status === 'audit'"
                v-model="inputForm.businessLocation" placeholder="请填写业务所在地" clearable>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否数据证券业务" prop="securityBusiness" :rules="[
            ]">
              <el-select :disabled="status === 'taskFormDetail' || status === 'audit'"
                v-model="inputForm.securityBusiness" placeholder="请选择是否数据证券业务" style="width:100%;">
                <el-option v-for="item in $dictUtils.getDictList('cw_report_negotiable')" :key="item.value"
                  :label="item.label" :value="item.value">
                </el-option>
              </el-select>
              <!--                <el-input :disabled="true" v-model="inputForm.securityBusiness" placeholder="请填写是否数据证券业务" clearable>-->
              <!--                </el-input>-->
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider content-position="left"><i class="el-icon-document"></i> 报告审核信息</el-divider>
        <el-row :gutter="15">
          <!--          <el-col :span="12">-->
          <!--            <el-form-item label="下一节点审核人" prop="reviewBy"-->
          <!--                          :rules="[-->
          <!--                   ]">-->
          <!--              <el-select v-model="inputForm.reviewBy" placeholder="请选择下一节点审核人" style="width:100%;">-->
          <!--                <el-option-->
          <!--                  v-for="item in reviewBys"-->
          <!--                  :key="item.index"-->
          <!--                  :label="item.label"-->
          <!--                  :value="item.value">-->
          <!--                </el-option>-->
          <!--              </el-select>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
          <!--<el-col :span="12">
            <el-form-item label="报告编号" prop="reportReviewNo"
                          :rules="[
                   ]">
              <el-input :disabled="true" v-model="inputForm.reportReviewNo" placeholder="自动生成">
                &lt;!&ndash;                  <el-button slot="append" icon="el-icon-search" @click="openContractForm()"></el-button>&ndash;&gt;
              </el-input>
            </el-form-item>
          </el-col>-->
          <el-col :span="12">
            <el-form-item label="共印份数（大写）" prop="allPrintNum" :rules="[
              { required: true, message: '共印份数不能为空', trigger: 'blur' }
            ]">
              <el-input :disabled="status === 'taskFormDetail' || status === 'audit'" v-model="inputForm.allPrintNum"
                placeholder="请输入本报告共印份数">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发出份数（大写）" prop="issueNum" :rules="[
              { required: true, message: '发出份数不能为空', trigger: 'blur' }
            ]">
              <el-input :disabled="status === 'taskFormDetail' || status === 'audit'" v-model="inputForm.issueNum"
                placeholder="请输入发出份数">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="存档份数（大写）" prop="placeOnFileNum" :rules="[
              { required: true, message: '存档份数不能为空', trigger: 'blur' }
            ]">
              <el-input :disabled="status === 'taskFormDetail' || status === 'audit'" v-model="inputForm.placeOnFileNum"
                placeholder="请输入存档份数">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="打印人签名" prop="printedBy" :rules="[
            ]">
              <el-input :disabled="status === 'taskFormDetail' || status === 'audit'" v-model="inputForm.printedBy"
                placeholder="请输入打印人签名">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="校对人签名" prop="checkAutograph" :rules="[
            ]">
              <el-input :disabled="status === 'taskFormDetail' || status === 'audit'" v-model="inputForm.checkAutograph"
                placeholder="请输入校对人签名">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计算机文号" prop="computerNo" :rules="[
            ]">
              <el-input :disabled="status === 'taskFormDetail' || status === 'audit'" v-model="inputForm.computerNo"
                placeholder="请输入计算机文号">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
      <el-tabs v-model="activeName" type="border-card" @tab-click="tabHandleClick" style="width: 100%;">
        <el-tab-pane label="附件" name="archiveFile">
          <!--        附件-->
          <UpLoadComponent ref="archiveFile" @clickSign="clickSign"></UpLoadComponent>
        </el-tab-pane>
        <el-tab-pane label="已签章附件" name="signatureFile">
          <!--        附件-->
          <UpLoadComponent ref="signatureFile"></UpLoadComponent>
        </el-tab-pane>
      </el-tabs>
    </el-row>
    <!--    <UpLoadComponentDialog ref="upLoadComponentDialog" @getUpload="getUpload"></UpLoadComponentDialog>-->
    <!--    <ProjectInfoForm  ref="projectInfoForm" @getContract="getContract"></ProjectInfoForm>-->
    <ProjectRecoredChooseCom ref="projectRecoredChooseCom" @getProject="getContract"></ProjectRecoredChooseCom>
    <ReportServiceUnitForm ref="reportServiceUnitForm" @getWorkClientChoose="getWorkClientChoose">
    </ReportServiceUnitForm>
  </div>
</template>

<script>
// import UpLoadComponent from '@/views/common/UpLoadComponent'
import UpLoadComponent from '@/views/common/UpLoadComponentV2.1'
import SelectTree from '@/components/treeSelect/treeSelect.vue'
import UserSelect from '@/views/cw/workClientInfo/clientUserSelect/AccountantUserIndex'
import UserSelect2 from '@/views/cw/workClientInfo/clientUserSelect/AccountantUserIndex2'
import projectReportService from '@/api/cw/reportManagement/ProjectReportService'
import EnterpriseSearchService from '@/api/cw/common/EnterpriseSearchService'
import userService from "@/api/sys/userService";
// import WorkClientChooseForm from '../workClientInfo/WorkClientChooseForm'
import ReportServiceUnitForm from './ReportServiceUnitForm'
import processService from '@/api/flowable/ProcessService'
import UserSelectAll from '@/components/userSelect'
// import UpLoadComponentDialog from '@/views/common/UpLoadComponentDialog'
// import ProjectInfoForm from './ProjectInfoForm'
import ProjectRecoredChooseCom from '../projectRecords/ProjectRecordsChooseCom'
import ReportReviewService from '@/api/cw/reportManagement/ReportReviewService'
export default {
  props: {
    businessId: {
      type: String,
      default: ''
    },
    formReadOnly: {
      type: Boolean,
      default: false
    },
    status: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      title: '',
      method: '',
      loading: false,
      inputForm: {
        servedUnitId: '',  // 被服务单位id
        opinionType: '',
        reportNo: '',
        reportNumber: '',
        reportType: '',
        reportDate: '',
        servedUnitName: '', // 被服务单位
        auditFees: '',
        projectId: '',
        id: '',
        createDate: '',
        createBy: {
          id: '',
          name: this.$store.state.user.name
        },
        remarks: '',
        documentNo: '',
        projectName: '',
        officeId: '',
        projectNumber: '',
        signatureAnnotator1: '',
        signatureAnnotator2: '',
        signatureType: '',
        projectMasterName: '',
        cwProjectInfoList: [],
        status: '',
        status1: '',
        status2: '',
        status3: '',
        realCreate: '',
        sid1: '',
        sid2: '',
        sid3: '',
        signatureContractId: '',
        sealType: '',
        reviewBy: '', // 下一个节点审核人
        businessType: '',
        auditBusinessType: '',
        registerAddress: '',
        securityBusiness: '',
        businessLocation: '',
        userName: '',
        detailFor1010: [],
        detailFor1020: [],
        detailFor1030: [],
        details: [],
        reportNewLineId: '',
        reportReviewNo: '',
        allPrintNum: '',
        issueNum: '',
        placeOnFileNum: '',
        printedBy: '',
        checkAutograph: '',
        computerNo: '',
        reportTitleType: '',
        needUpdate1: '',
        needUpdate2: '',
        needUpdate3: '',
        remark1: '',
        remark2: '',
        remark3: '',
        cwFileInfoList: [],
        cwFileInfoList2: [],
        reviewStatus: '',
        taskName: '',
        realHeaderName: '',
        procDefId: '',
        procDefKey: '',
        formTitle: '',
        title: '',
        industry: '',
        businessObjects: ''
      },
      keyWatch: '',
      activeName: '',
      tableKey: '',
      tableKeyClient: '1',
      interVal: ''
    }
  },
  enterpriseSearchService: null,
  reportReviewService: null,
  created() {
    this.reportReviewService = new ReportReviewService()
    this.enterpriseSearchService = new EnterpriseSearchService()
  },
  deactivated() {
    // 页面关闭（路由跳转）时清除定时器
    clearInterval(this.interVal)
  },
  destroy() {
    // 页面关闭（路由跳转）时清除定时器
    clearInterval(this.interVal)
  },
  computed: {
    userName() {
      return this.$store.state.user.name
    },
    bus: {
      get() {
        this.$refs.archiveFile.setDividerName('附件', false)
        // this.$refs.uploadComponent.setDividerName('附件', false)
        return this.businessId
      },
      set(val) {
        this.businessId = val
      }
    }
  },
  watch: {
    'keyWatch': {
      handler(newVal) {
        if (this.commonJS.isNotEmpty(this.bus)) {
          this.init('', this.bus)
        } else {
          this.$nextTick(() => {
            this.$refs.inputForm.resetFields()
          })
        }
      }
    },
    'loading': {
      handler(newVal) {
        this.$emit('changeLoading', newVal)
        this.$refs.archiveFile.changeLoading(newVal)
        this.$refs.signatureFile.changeLoading(newVal)
      }
    }
  },
  components: {
    UpLoadComponent,
    SelectTree,
    UserSelect,
    UserSelect2,
    ReportServiceUnitForm,
    // ProjectInfoForm,
    ProjectRecoredChooseCom,
    UserSelectAll
    // UpLoadComponentDialog
  },
  methods: {
    getKeyWatch(keyWatch) {
      this.keyWatch = keyWatch
    },
    changeSignatory1(value) {
      if (this.inputForm.signatureAnnotator2 === value && this.commonJS.isNotEmpty(value)) {
        this.$message.warning('首次发行签字注师1和首次发行签字注师2不可以相同')
        this.$nextTick(() => {
          this.inputForm.signatureAnnotator1 = ''
          this.$refs.userSelect1.changeNameValue('')
          this.$refs.userSelect1.clearSelectData()
          this.$forceUpdate()
        })
      } else if (this.commonJS.isNotEmpty(this.inputForm.signatureAnnotator2) &&
        this.inputForm.projectMasterId1 !== this.inputForm.signatureAnnotator2 &&
        this.inputForm.projectMasterId2 !== this.inputForm.signatureAnnotator2 &&
        this.inputForm.projectMasterId1 !== value &&
        this.inputForm.projectMasterId2 !== value &&
        this.commonJS.isNotEmpty(value)) {
        this.$message.warning('签字注师1和签字注师2至少有一个与项目经理相同')
        this.$nextTick(() => {
          this.inputForm.signatureAnnotator1 = ''
          this.$refs.userSelect1.changeNameValue('')
          this.$refs.userSelect1.clearSelectData()
          this.$forceUpdate()
        })
      } else {
        this.inputForm.signatureAnnotator1 = value
      }
    },
    changeSignatory2(value) {
      if (this.inputForm.signatureAnnotator1 === value && this.commonJS.isNotEmpty(value)) {
        this.$message.warning('首次发行签字注师1和首次发行签字注师2不可以相同')
        this.$nextTick(() => {
          this.inputForm.signatureAnnotator2 = ''
          this.$refs.userSelect2.changeNameValue('')
          this.$refs.userSelect2.clearSelectData()
          this.$forceUpdate()
        })
      } else if (this.commonJS.isNotEmpty(this.inputForm.signatureAnnotator1) &&
        this.inputForm.projectMasterId1 !== this.inputForm.signatureAnnotator1 &&
        this.inputForm.projectMasterId2 !== this.inputForm.signatureAnnotator1 &&
        this.inputForm.projectMasterId1 !== value && this.commonJS.isNotEmpty(value) &&
        this.inputForm.projectMasterId2 !== value) {
        this.$message.warning('签字注师1和签字注师2至少有一个与项目经理相同')
        this.$nextTick(() => {
          this.inputForm.signatureAnnotator2 = ''
          this.$refs.userSelect2.changeNameValue('')
          this.$refs.userSelect2.clearSelectData()
          this.$forceUpdate()
        })
      } else {
        this.inputForm.signatureAnnotator2 = value
      }
    },
    init(method, id) {
      this.activeName = ''
      this.method = method
      this.inputForm = {
        servedUnitId: '',  // 被服务单位id
        opinionType: '',
        reportNo: '',
        reportNumber: '',
        reportType: '',
        reportDate: '',
        servedUnitName: '', // 被服务单位
        auditFees: '',
        projectId: '',
        id: '',
        createDate: '',
        createBy: {
          id: '',
          name: this.$store.state.user.name
        },
        remarks: '',
        documentNo: '',
        projectName: '',
        officeId: '',
        projectNumber: '',
        signatureAnnotator1: '',
        signatureAnnotator2: '',
        signatureType: '',
        projectMasterName: '',
        cwProjectInfoList: [],
        status: '',
        status1: '',
        status2: '',
        status3: '',
        realCreate: '',
        sid1: '',
        sid2: '',
        sid3: '',
        signatureContractId: '',
        sealType: '',
        reviewBy: '', // 下一个节点审核人
        businessType: '',
        auditBusinessType: '',
        registerAddress: '',
        securityBusiness: '',
        businessLocation: '',
        userName: '',
        detailFor1010: [],
        detailFor1020: [],
        detailFor1030: [],
        details: [],
        reportNewLineId: '',
        reportReviewNo: '',
        allPrintNum: '',
        issueNum: '',
        placeOnFileNum: '',
        printedBy: '',
        checkAutograph: '',
        computerNo: '',
        reportTitleType: '',
        needUpdate1: '',
        needUpdate2: '',
        needUpdate3: '',
        remark1: '',
        remark2: '',
        remark3: '',
        cwFileInfoList: [],
        reviewStatus: '',
        taskName: '',
        realHeaderName: '',
        procDefId: '',
        procDefKey: '',
        formTitle: '',
        title: '',
        projectMasterId1: '',
        projectMasterId2: '',
        industry: '',
        businessObjects: ''
      }
      this.inputForm.id = id
      this.loading = false
      this.$nextTick(() => {
        this.$refs.archiveFile.clearUpload()
        this.$refs.signatureFile.clearUpload()
        this.$refs.inputForm.resetFields()
        this.loading = true
        projectReportService.queryBySignatureId(this.inputForm.id).then((data) => {
          this.inputForm.status = data.status
          // this.$refs.uploadComponent.clearUpload()
          this.inputForm = this.recover(this.inputForm, data)
          this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
          if (this.commonJS.isEmpty(this.inputForm.createDate)) {
            this.inputForm.createDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
          }
          if (this.commonJS.isEmpty(this.inputForm.officeId)) {
            this.inputForm.officeId = this.$store.state.user.office.id
          }
          if (this.commonJS.isEmpty(this.inputForm.realCreate)) {
            this.inputForm.realCreate = this.$store.state.user.id
          }
          let sFiles = ''
          if (this.commonJS.isNotEmpty(data.cwFileInfoList)) {
            sFiles = data.cwFileInfoList.map(file => {
              if (this.commonJS.isNotEmpty(file.sealType)) {
                if (file.sealType === '1') {
                  return file.sealType
                }
              }
            }).join(',')
          } else {
            this.inputForm.cwFileInfoList = []
          }
          if (this.status === 'taskFormDetail' || this.status === 'audit') {
            this.method = 'view'
          } else {
            this.method = 'false'
          }
          if (this.status === 'taskFormDetail') {
            this.activeName = 'signatureFile'
          } else {
            this.activeName = 'archiveFile'
          }
          if (this.commonJS.isEmpty(this.inputForm.signatureType) && this.method !== 'view') {
            this.inputForm.signatureType = '1'
          }
          if (this.commonJS.isNotEmpty(this.inputForm.signatureContractId) && this.status === 'audit' && this.commonJS.isNotEmpty(sFiles) && this.inputForm.signatureType !== '3') {
            // 签章按钮展示
            this.$refs.archiveFile.newUpload(this.method, data.cwFileInfoList, 'cwReportSignature', null, null, null, null, false, 'audit')
          } else {
            // 签章按钮隐藏
            this.$refs.archiveFile.newUpload(this.method, data.cwFileInfoList, 'cwWorkContract', null, null, null, null, false)
          }
          this.loading = false
          if (this.status === 'audit' && this.commonJS.isNotEmpty(sFiles) && this.inputForm.signatureType !== '3') {
            this.$emit('callBackFunc', 'hide')
            this.jobScheduler()
          }
          this.$refs.signatureFile.newUpload('view', data.signatureFileList, 'cwWorkContract', null, null, null, null, false)
        })
      })
    },
    openContractForm() {
      if (!this.commonJS.isEmpty(this.inputForm.contractId)) {
        // this.$refs.projectInfoForm.init(this.inputForm.contractId)
        this.$refs.projectRecoredChooseCom.init(this.inputForm.contractId)
      } else {
        this.$refs.projectRecoredChooseCom.init()
        // this.$refs.projectInfoForm.init()
      }
    },
    getContract(row) {
      this.inputForm.projectName = row.projectName // 项目名称
      this.inputForm.projectId = row.id // 项目id
      this.inputForm.projectNumber = row.projectNumber // 项目编号
      this.inputForm.projectMasterName = row.projectMasterName // 项目经理
      this.clearClientList()
      this.$forceUpdate()
      this.inputForm.cwProjectInfoList = []
    },
    clearClientList() {
      // 项目直接对接联系人列表清除
      this.inputForm.clientList = []
      this.$forceUpdate()
    },
    saveForm(callback) {
      this.doSubmit('save', callback)
    },
    startForm(callback) {
      this.loading = true
      if (this.inputForm.signatureType) {
        if (this.inputForm.signatureType === '1') {
          projectReportService.findBySignatureId(this.inputForm.sid1).then((data) => {
            if (data.status !== '0' && data.status !== '1' && data.status !== '3') { // 审核状态不是“未发起”或“暂存”或“撤回”，就弹出提示
              this.loading = false
              this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
              throw new Error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
            } else {
              this.startFormTrue(callback)
            }
          })
        }
        if (this.inputForm.signatureType === '2') {
          projectReportService.findBySignatureId(this.inputForm.sid2).then((data) => {
            if (data.status !== '0' && data.status !== '1' && data.status !== '3') { // 审核状态不是“未发起”或“暂存”或“撤回”，就弹出提示
              this.loading = false
              this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
              throw new Error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
            } else {
              this.startFormTrue(callback)
            }
          })
        }
        if (this.inputForm.signatureType === '3') {
          projectReportService.findBySignatureId(this.inputForm.sid3).then((data) => {
            if (data.status !== '0' && data.status !== '1' && data.status !== '3') { // 审核状态不是“未发起”或“暂存”或“撤回”，就弹出提示
              this.loading = false
              this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
              throw new Error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
            } else {
              this.startFormTrue(callback)
            }
          })
        }
      }
    },
    startFormTrue(callback) {
      this.loading = true
      if (this.$refs.archiveFile.checkProgress()) {
        this.loading = false
        throw new Error()
      } else {
        let title = `发起流程【会计-报告签章-电子公章】`
        let describe = `[会计-报告签章-电子公章`
        // 读取流程表单
        if (this.inputForm.signatureType) {
          if (this.inputForm.signatureType === '1') {
            processService.getByName('会计-报告签章-电子公章').then((data) => {
              if (!this.commonJS.isEmpty(data.id)) {
                this.inputForm.procDefId = data.id
                this.inputForm.procDefKey = data.key
              }
            })
            title = `发起流程【会计-报告签章-电子公章】`
            describe = `[会计-报告签章-电子公章]`
          } else if (this.inputForm.signatureType === '2') {
            processService.getByName('财务-报告签章-公章+执业章').then((data) => {
              if (!this.commonJS.isEmpty(data.id)) {
                this.inputForm.procDefId = data.id
                this.inputForm.procDefKey = data.key
              }
            })
            title = `发起流程【会计-报告签章-电子公章+执业章】`
            describe = `[会计-报告签章-电子公章+执业章]`
          } else if (this.inputForm.signatureType === '3') {
            processService.getByName('会计-报告签章-实体公章').then((data) => {
              if (!this.commonJS.isEmpty(data.id)) {
                this.inputForm.procDefId = data.id
                this.inputForm.procDefKey = data.key
              }
            })
            title = `发起流程【会计-报告签章-实体公章】`
            describe = `[会计-报告签章-实体公章]`
          }
        }
        let processTitle = `${this.userName} 发起了 ${this.inputForm.reportNo} - ${this.inputForm.projectName} ` + describe
        this.inputForm.formTitle = title
        this.inputForm.title = processTitle

        this.$refs['inputForm'].validate((valid) => {
          if (valid) {
            this.loading = true
            this.$refs.archiveFile.getDataList().then((list) => {
              if (this.commonJS.isNotEmpty(list)) {
                list.forEach((item, index) => {
                  if (this.commonJS.isEmpty(item.fileType)) {
                    this.loading = false
                    this.$message.error('第' + (index + 1) + '条附件信息没有填写文件类型')
                    this.loading = false
                    throw new Error('第' + (index + 1) + '条附件信息没有填写文件类型')
                  }
                  if (this.commonJS.isEmpty(item.sealType)) {
                    this.loading = false
                    this.$message.error('第' + (index + 1) + '条附件信息没有填写盖章类型')
                    this.loading = false
                    throw new Error('第' + (index + 1) + '条附件信息没有填写盖章类型')
                  }
                })
              }
              this.inputForm.cwFileInfoList = list
              //根据签字注师1的人员id去查是否超过了可选次数
              userService.findCountById(this.inputForm.signatureAnnotator1).then(res => {
                if (Number(res.accountantUserCount) >= Number(res.signatureCount)) {
                  this.$message.error(`签字注师1被选次数不可超过可选次数(${res.signatureCount}次)`)
                  this.loading = false
                } else {
                  this.reportReviewService.save(this.inputForm).then(() => {
                    let da = { cwFileInfoList: this.inputForm.cwFileInfoList, id: this.inputForm.id }
                    projectReportService.saveSignFiles(da).then(() => {
                      projectReportService.saveData(this.inputForm).then((data) => {
                        if (this.inputForm.signatureType === '2') {
                          this.inputForm.assignee = this.inputForm.signatureAnnotator1
                        }
                        callback(data.businessTable, data.businessId, this.inputForm)
                        this.loading = false
                        throw new Error()
                      }).catch(() => {
                        this.loading = false
                        throw new Error('流程发起失败')
                      })
                    }).catch(() => {
                      this.loading = false
                      throw new Error('流程发起失败')
                    })
                  })
                }
              })
            })
          } else {
            this.loading = false
          }
        })
      }
    },
    reapplyForm(callback) {
      this.loading = true
      projectReportService.queryById(this.inputForm.id).then((data) => {
        if (data.signatureType === '1') {
          projectReportService.findBySignatureId(this.inputForm.sid1).then((data) => {
            if (data.status !== '4') { // 审核状态不是“驳回”，就弹出提示
              this.loading = false
              this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
              throw new Error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
            } else {
              this.startFormTrue(callback)
            }
          })
        }
        if (data.signatureType === '2') {
          projectReportService.findBySignatureId(this.inputForm.sid2).then((data) => {
            if (data.status !== '4') { // 审核状态不是“驳回”，就弹出提示
              this.loading = false
              this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
              throw new Error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
            } else {
              this.startFormTrue(callback)
            }
          })
        }
        if (data.signatureType === '3') {
          projectReportService.findBySignatureId(this.inputForm.sid3).then((data) => {
            if (data.status !== '4') { // 审核状态不是“驳回”，就弹出提示
              this.loading = false
              this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
              throw new Error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
            } else {
              this.startFormTrue(callback)
            }
          })
        }
      })
    },
    async agreeForm(callback) {
      let describe = ''
      if (this.inputForm.signatureType) {
        if (this.inputForm.signatureType === '1') {
          describe = `[会计-报告签章-电子公章]`
        } else if (this.inputForm.signatureType === '2') {
          describe = `[会计-报告签章-电子公章+执业章]`
        } else if (this.inputForm.signatureType === '3') {
          describe = `[会计-报告签章-实体公章]`
        }
      }
      let processTitle = `${this.inputForm.userName} 发起了 ${this.inputForm.reportNo} - ${this.inputForm.projectName} ` + describe
      this.inputForm.title = processTitle
      if (this.inputForm.signatureType === '1') {
        projectReportService.findBySignatureId(this.inputForm.sid1).then((data) => {
          if (data.status !== '2') { // status的值不等于“审核中”就弹出提示
            this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
            throw new Error()
          } else {
            this.$refs['inputForm'].validate((valid) => {
              if (valid) {
                this.loading = true
                this.$refs.archiveFile.getDataList().then((list) => {
                  if (this.commonJS.isNotEmpty(list)) {
                    list.forEach((item, index) => {
                      if (this.commonJS.isEmpty(item.fileType)) {
                        this.$message.error('第' + (index + 1) + '条附件信息没有填写文件类型')
                        this.loading = false
                        throw new Error('第' + (index + 1) + '条附件信息没有填写文件类型')
                      }
                      if (this.commonJS.isEmpty(item.sealType)) {
                        this.$message.error('第' + (index + 1) + '条附件信息没有填写盖章类型')
                        this.loading = false
                        throw new Error('第' + (index + 1) + '条附件信息没有填写盖章类型')
                      }
                    })
                  }
                  this.inputForm.cwFileInfoList = list
                  this.reportReviewService.save(this.inputForm).then(() => {
                    let da = { cwFileInfoList: this.inputForm.cwFileInfoList, id: this.inputForm.id }
                    projectReportService.saveSignFiles(da).then(() => {
                      let param = { status: '5', id: this.inputForm.sid1 }
                      projectReportService.updateSignatureStatusById(param).then(() => {
                        projectReportService.saveReportArchive(this.inputForm.id).then(() => {
                          let table = 'cw_project_report_signature'
                          callback(table, this.inputForm.sid1, this.inputForm)
                          this.loading = false
                        })
                      })
                    })
                  })
                })
              } else {
                this.loading = false
              }
            })
          }
        })
      }
      if (this.inputForm.signatureType === '3') {
        projectReportService.findBySignatureId(this.inputForm.sid3).then((data) => {
          if (data.status !== this.inputForm.status3) { // status的值不等于“审核中”就弹出提示
            this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
            throw new Error()
          } else {
            this.$refs['inputForm'].validate((valid) => {
              if (valid) {
                this.loading = true
                this.$refs.archiveFile.getDataList().then((list) => {
                  if (this.commonJS.isNotEmpty(list)) {
                    list.forEach((item, index) => {
                      if (this.commonJS.isEmpty(item.fileType)) {
                        this.$message.error('第' + (index + 1) + '条附件信息没有填写文件类型')
                        this.loading = false
                        throw new Error('第' + (index + 1) + '条附件信息没有填写文件类型')
                      }
                      if (this.commonJS.isEmpty(item.sealType)) {
                        this.$message.error('第' + (index + 1) + '条附件信息没有填写盖章类型')
                        this.loading = false
                        throw new Error('第' + (index + 1) + '条附件信息没有填写盖章类型')
                      }
                    })
                  }
                  this.inputForm.cwFileInfoList = list
                  this.reportReviewService.save(this.inputForm).then(() => {
                    let da = { cwFileInfoList: this.inputForm.cwFileInfoList, id: this.inputForm.id }
                    projectReportService.saveSignFiles(da).then(() => {
                      projectReportService.getAuditNodeByReportId(this.inputForm.sid3).then((data) => {
                        let param = { status: '5', id: this.inputForm.sid3 }
                        projectReportService.updateSignatureStatusById(param).then(() => {
                          projectReportService.saveReportArchive(this.inputForm.id).then(() => {
                            let table = 'cw_project_report_signature'
                            callback(table, this.inputForm.sid3, this.inputForm)
                            this.loading = false
                          })
                        })
                      })
                    })
                  })
                })
              } else {
                this.loading = false
              }
            })
          }
        })
      }
      if (this.inputForm.signatureType === '2') {
        projectReportService.findBySignatureId(this.inputForm.sid2).then((data) => {
          if (data.status !== this.inputForm.status2) { // status的值不等于“审核中”就弹出提示
            this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
            throw new Error()
          } else {
            this.$refs['inputForm'].validate((valid) => {
              if (valid) {
                this.loading = true
                this.$refs.archiveFile.getDataList().then((list) => {
                  if (this.commonJS.isNotEmpty(list)) {
                    list.forEach((item, index) => {
                      if (this.commonJS.isEmpty(item.fileType)) {
                        this.$message.error('第' + (index + 1) + '条附件信息没有填写文件类型')
                        this.loading = false
                        throw new Error('第' + (index + 1) + '条附件信息没有填写文件类型')
                      }
                      if (this.commonJS.isEmpty(item.sealType)) {
                        this.$message.error('第' + (index + 1) + '条附件信息没有填写盖章类型')
                        this.loading = false
                        throw new Error('第' + (index + 1) + '条附件信息没有填写盖章类型')
                      }
                    })
                  }
                  this.inputForm.cwFileInfoList = list
                  this.reportReviewService.save(this.inputForm).then(() => {
                    let da = { cwFileInfoList: this.inputForm.cwFileInfoList, id: this.inputForm.id }
                    projectReportService.saveSignFiles(da).then(() => {
                      projectReportService.getAuditNodeByReportId(this.inputForm.sid2).then((data) => {
                        if (data.signatureType === '签字注师1审核') {
                          let param = { status: '6', id: this.inputForm.sid2 }
                          projectReportService.updateSignatureStatusById(param)
                          this.inputForm.assignee = this.inputForm.signatureAnnotator2
                          let table = 'cw_project_report_signature'
                          callback(table, this.inputForm.sid2, this.inputForm)
                          this.loading = false
                        }
                        if (data.signatureType === '签字注师2审核') {
                          let param = { status: '7', id: this.inputForm.sid2 }
                          projectReportService.updateSignatureStatusById(param)
                          callback()
                          this.loading = false
                        }
                        if (data.signatureType === '签章管理人审核') {
                          let param = { status: '5', id: this.inputForm.sid2 }
                          projectReportService.updateSignatureStatusById(param).then(() => {
                            projectReportService.saveReportArchive(this.inputForm.id).then(() => {
                              callback()
                              this.loading = false
                            })
                          })
                        }
                      })
                    })
                  })
                })
              } else {
                this.loading = false
              }
            })
          }
        })
      }
    },
    async updateStatusById(type, callback) {
      if (await this.$refs.archiveFile.checkProgress()) {
        this.loading = false
        throw new Error()
      } else {
        this.$refs['inputForm'].validate((valid) => {
          if (valid) {
            this.loading = true
            this.$refs.archiveFile.getDataList().then((list) => {
              if (this.commonJS.isNotEmpty(list)) {
                list.forEach((item, index) => {
                  if (this.commonJS.isEmpty(item.fileType)) {
                    this.$message.error('第' + (index + 1) + '条附件信息没有填写文件类型')
                    this.loading = false
                    throw new Error('第' + (index + 1) + '条附件信息没有填写文件类型')
                  }
                  if (this.commonJS.isEmpty(item.sealType)) {
                    this.$message.error('第' + (index + 1) + '条附件信息没有填写盖章类型')
                    this.loading = false
                    throw new Error('第' + (index + 1) + '条附件信息没有填写盖章类型')
                  }
                })
              }
              this.inputForm.cwFileInfoList = list
              this.reportReviewService.save(this.inputForm).then(() => {
                let da = { cwFileInfoList: this.inputForm.cwFileInfoList, id: this.inputForm.id }
                projectReportService.saveSignFiles(da).then(() => {
                  if (type === 'reject' || type === 'reback') {
                    if (this.inputForm.signatureType === '1') {
                      projectReportService.findBySignatureId(this.inputForm.sid1).then((data) => {
                        if (data.status !== this.inputForm.status1) { // status的值不等于“审核中”就弹出提示
                          this.loading = false
                          this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
                          throw new Error()
                        } else {
                          if (type === 'reject') {
                            // 驳回
                            let param = { status: '4', id: data.id }
                            projectReportService.updateSignatureStatusById(param).then(() => {
                              this.loading = false
                              callback()
                            })
                          }
                          if (type === 'reback') {
                            // 撤回
                            let param = { status: '3', id: data.id }
                            projectReportService.updateSignatureStatusById(param).then(() => {
                              callback()
                              this.loading = false
                            })
                          }
                        }
                      })
                    }
                    if (this.inputForm.signatureType === '3') {
                      projectReportService.findBySignatureId(this.inputForm.sid3).then((data) => {
                        if (data.status !== this.inputForm.status3) { // status的值不等于“审核中”就弹出提示
                          this.loading = false
                          this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
                          throw new Error()
                        } else {
                          if (type === 'reject') {
                            // 驳回
                            let param = { status: '4', id: data.id }
                            projectReportService.updateSignatureStatusById(param).then(() => {
                              this.loading = false
                              callback()
                            })
                          }
                          if (type === 'reback') {
                            // 撤回
                            let param = { status: '3', id: data.id }
                            projectReportService.updateSignatureStatusById(param).then(() => {
                              this.loading = false
                              callback()
                            })
                          }
                        }
                      })
                    }
                    if (this.inputForm.signatureType === '2') {
                      projectReportService.findBySignatureId(this.inputForm.sid2).then((data) => {
                        if (data.status !== this.inputForm.status2) { // status的值不等于“审核中”就弹出提示
                          this.loading = false
                          this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
                          throw new Error()
                        } else {
                          if (type === 'reject') {
                            // 驳回
                            let param = { status: '4', id: data.id }
                            projectReportService.updateSignatureStatusById(param).then(() => {
                              this.loading = false
                              callback()
                            })
                          }
                          if (type === 'reback') {
                            // 撤回
                            let param = { status: '3', id: data.id }
                            projectReportService.updateSignatureStatusById(param).then(() => {
                              this.loading = false
                              callback()
                            })
                          }
                        }
                      })
                    }
                  } else if (type === 'hold') {
                    if (this.inputForm.signatureType === '1') {
                      projectReportService.findBySignatureId(this.inputForm.sid1).then((data) => {
                        if (data.status !== '4') { // status的值不等于“驳回”就弹出提示
                          this.loading = false
                          this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
                          throw new Error()
                        } else {
                          // 终止
                          let param = { status: '0', id: data.id }
                          projectReportService.updateSignatureStatusById(param).then(() => {
                            callback()
                            this.loading = false
                          })
                        }
                      })
                    }
                    if (this.inputForm.signatureType === '3') {
                      projectReportService.findBySignatureId(this.inputForm.sid3).then((data) => {
                        if (data.status !== '4') { // status的值不等于“驳回”就弹出提示
                          this.loading = false
                          this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
                          throw new Error()
                        } else {
                          // 终止
                          let param = { status: '0', id: data.id }
                          projectReportService.updateSignatureStatusById(param).then(() => {
                            callback()
                            this.loading = false
                          })
                        }
                      })
                    }
                    if (this.inputForm.signatureType === '2') {
                      projectReportService.findBySignatureId(this.inputForm.sid2).then((data) => {
                        if (data.status !== '4') { // status的值不等于“驳回”就弹出提示
                          this.loading = false
                          this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
                          throw new Error()
                        } else {
                          // 终止
                          let param = { status: '0', id: data.id }
                          projectReportService.updateSignatureStatusById(param).then(() => {
                            callback()
                            this.loading = false
                          })
                        }
                      })
                    }
                  }
                })
              })
            })
          } else {
            this.loading = false
          }
        })
      }
    },
    close() {
      this.inputForm = {
        servedUnitId: '',  // 被服务单位id
        opinionType: '',
        reportNo: '',
        reportNumber: '',
        reportType: '',
        reportDate: '',
        servedUnitName: '', // 被服务单位
        auditFees: '',
        projectId: '',
        id: '',
        createDate: '',
        createBy: {
          id: '',
          name: this.$store.state.user.name
        },
        remarks: '',
        documentNo: '',
        projectName: '',
        officeId: '',
        projectNumber: '',
        signatureAnnotator1: '',
        signatureAnnotator2: '',
        signatureType: '',
        projectMasterName: '',
        cwProjectInfoList: [],
        status: '',
        status1: '',
        status2: '',
        status3: '',
        realCreate: '',
        sid1: '',
        sid2: '',
        sid3: '',
        signatureContractId: '',
        sealType: '',
        reviewBy: '', // 下一个节点审核人
        businessType: '',
        auditBusinessType: '',
        registerAddress: '',
        securityBusiness: '',
        businessLocation: '',
        userName: '',
        detailFor1010: [],
        detailFor1020: [],
        detailFor1030: [],
        details: [],
        reportNewLineId: '',
        reportReviewNo: '',
        allPrintNum: '',
        issueNum: '',
        placeOnFileNum: '',
        printedBy: '',
        checkAutograph: '',
        computerNo: '',
        reportTitleType: '',
        needUpdate1: '',
        needUpdate2: '',
        needUpdate3: '',
        remark1: '',
        remark2: '',
        remark3: '',
        cwFileInfoList: [],
        reviewStatus: '',
        taskName: '',
        realHeaderName: '',
        projectMasterId1: '',
        projectMasterId2: '',
        industry: '',
        businessObjects: ''
      }
      // this.$refs.uploadComponent.clearUpload()
      this.$refs.inputForm.resetFields()
    },
    tabHandleClick(event) {
      // console.log(event)
    },
    // 删除
    removeEvent(row, rowIndex, type) {
      if (type === 'client') {
        // this.$refs.clientTable.remove(row)
        // this.inputForm.cwProjectInfoList.splice(rowIndex, 1)
      }
    },
    openWorkClient() {
      this.$refs.reportServiceUnitForm.init(this.inputForm.projectId)
    },
    getWorkClientChoose(list) {
      // if (this.commonJS.isEmpty(this.inputForm.cwProjectInfoList)) {
      //   this.inputForm.cwProjectInfoList = []
      // }
      // eslint-disable-next-line no-unused-vars
      let _this = this
      let _list = list
      const waitForEach = function () {
        return new Promise(function (resolve, reject) {
          _list.forEach((item) => {
            // _this.inputForm.cwProjectInfoList.forEach(client => {
            //   if (item.id === client.servedUnitId) {
            //     // _this.$message.error('已存在客户 “' + client.servedUnitName + '”，请重新选择')
            //     // throw new Error('已存在客户 “' + client.servedUnitName + '”，请重新选择')
            //   }
            // })
          })
          resolve()
        })
      }
      waitForEach().then(() => {
        list.forEach(item => {
          // eslint-disable-next-line no-unused-vars
          // let d = {
          //   servedUnitName: item.name, // 被服务单位名称
          //   // reportNumber: this.inputForm.projectNumber + '-0' + (this.inputForm.cwProjectInfoList.length + 1), // 报告流水号
          //   issueReport: '是',
          //   sealType: '未盖章',
          //   id: this.uuid,
          //   servedUnitId: item.id
          // }
          // this.$refs.clientTable.insertAt(d)
          // this.inputForm.cwProjectInfoList.push(d)
          this.inputForm.servedUnitName = item.name
          this.inputForm.servedUnitId = item.id
          this.inputForm.sealType = '未盖章'
          this.tableKeyClient = Math.random()
        })
      })
    },
    clickSign() {
      projectReportService.saveFlowableParam(this.inputForm).then((data) => {
        window.open(data, '_blank')
      })
    },
    jobScheduler() {
      this.interVal = setInterval(() => {
        console.log('正在访问签章状态...')
        if (this.inputForm.signatureType === '1') {
          projectReportService.getAuditNodeByReportId(this.inputForm.sid1).then((data) => {
            console.log('进来了', data)
            if (data.success) {
              projectReportService.getSignatureTypeById(this.inputForm.sid1, data.signatureType).then((sign) => {
                if (sign.signatureType === '1') {
                  console.log('sign.signatureType', sign.signatureType)
                  console.log('签章已完成,展示‘同意’按钮')
                  this.$emit('callBackFunc', 'show')
                  this.$refs.archiveFile.hideSign() // 隐藏签章按钮
                  clearInterval(this.interVal)
                  this.showConfirm() // 提示签章操作已完成
                }
              })
            }
          })
        }
        if (this.inputForm.signatureType === '2') {
          projectReportService.getAuditNodeByReportId(this.inputForm.sid2).then((data) => {
            if (data.success) {
              projectReportService.getSignatureTypeById(this.inputForm.sid2, data.signatureType).then((sign) => {
                if (sign.signatureType === '1') {
                  console.log('签章已完成,展示‘同意’按钮')
                  this.$emit('callBackFunc', 'show')
                  this.$refs.archiveFile.hideSign() // 隐藏签章按钮
                  clearInterval(this.interVal)
                  this.showConfirm() // 提示签章操作已完成
                }
              })
            }
          })
        }
      }, 2000)
    },
    showConfirm() {
      this.$confirm(`签章操作已完成，请进行审核操作`, '提示', {
        confirmButtonText: '确定',
        type: 'warning'
      })
    }
  }
}
</script>
<style scoped>
/deep/ .el-input-number .el-input__inner {
  text-align: left;
}
</style>
