<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
  <div>
    <el-row>
      <el-col :span="24">

        <el-form :model="inputForm" ref="inputForm2" v-loading="loading" :class="method === 'view' ? 'readonly' : ''"
           label-width="170px" @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 @focus="openContractForm()" :disabled="true" v-model="inputForm.projectName" placeholder="请选择项目名称">
                  <el-button slot="append" icon="el-icon-search" :disabled="true" @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" :disabled="true" :props="{
                  value: 'id',             // ID字段名
                  label: 'name',         // 显示名称
                  children: 'children'    // 子级字段名
                }" size="default" :url="`/system-server/sys/office/treeData?type=2`" :value="inputForm.officeId"
                  :accordion="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="[
              ]">
                <el-select v-model="inputForm.signatureType" :disabled="true" 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="[
              ]">
                <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="[
              ]">
                <UserSelect style="width: 100%" ref="userSelect1"
                   :disabled="true" :readonly="true" :limit='1'
                  :modelValue="inputForm.signatureAnnotator1">
                </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="[
              ]">
                <UserSelect2 style="width: 100%" ref="userSelect2"
                   :disabled="true" :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="[
              ]">
                <UserSelect style="width: 100%" ref="userSelect1"
							:disabled="true" :readonly="true" :limit='1'
                  :modelValue="inputForm.signatureAnnotator1">
                </UserSelect>
              </el-form-item>
            </el-col>

            <el-col v-if="inputForm.signatureType === '2'" :span="12">
              <el-form-item label="签字注师2" prop="signatureAnnotator2" :rules="[
              ]">
                <UserSelect2 style="width: 100%" ref="userSelect2"
                   :disabled="true" :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 v-model="inputForm.opinionType" :disabled="true" 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 v-model="inputForm.auditFees" :disabled="true" 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="[
              ]">
                <el-input @focus="openUserDia3" :disabled="true" v-model="inputForm.realCreateName" placeholder="请选择报告实际制作人">
                  <template #suffix>
                    <el-button :disabled="true" style="background-color: white;color: #1b1e25;border-color: white;" type="primary"
                      slot="append" icon="el-icon-search" @click="openUserDia3">
                    </el-button>
                  </template>
                </el-input>
              </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-col :span="24">

				  <el-form-item label="代归档情况说明" prop="remarks" :rules="[
					{ required: true, message: '代归档情况说明不能为空', trigger: 'blur' }
				  ]">
					  <el-input v-model="inputForm.remarks"
								:disabled="status === 'audit' || status === 'taskFormDetail'"
								type="textarea"
								:rows="5"
								maxlength="500"
								placeholder="请输入代归档情况说明"
								show-word-limit>
					  </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="24">
              <el-form-item label="报告名称" prop="reportName" :rules="[
              ]">
                <el-input v-model="inputForm.reportName" :disabled="true" placeholder="请填写报告名称" clearable></el-input>
              </el-form-item>
            </el-col>
<!--            <el-col :span="12">
              <el-form-item label="被服务单位" prop="servedUnitName" :rules="[
              ]">
                <el-input @focus="openWorkClient()" :disabled="true" v-model="inputForm.servedUnitName" placeholder="请填写被服务单位" clearable>
                  <el-button slot="append" icon="el-icon-search" :disabled="true" @click="openWorkClient()"></el-button>
                </el-input>
              </el-form-item>
            </el-col>-->
            <el-col :span="12">
              <el-form-item label="报告类型" prop="reportType" :rules="[
              ]">
                <el-select v-model="inputForm.reportType" :disabled="true" 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" v-if="inputForm.reportType === '1'">
              <el-form-item label="审定金额(不含税/元)" prop="approvedNoIncludingTax" :rules="[
              ]">
                <el-input v-model="inputForm.approvedNoIncludingTax" :disabled="true" placeholder="请填写审定金额（不含税/元）" v-on:input="inputForm.approvedNoIncludingTax = inputForm.approvedNoIncludingTax.replace(/[^\d.]/g, '')
                  .replace(/^\./g, '')
                  .replace(/\.{2,}/g, '.')
                  .replace('.', '$#$').replace(/\./g, '').replace('$#$', '.')
                  .replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3').replace(/^0+/, '0')" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12" v-if="inputForm.reportType === '1'">
              <el-form-item label="审定金额(含税/元)" prop="approvedIncludingTax" :rules="[

              ]">
                <el-input v-model="inputForm.approvedIncludingTax" :disabled="true" placeholder="请填写审定金额（含税/元）" v-on:input="inputForm.approvedIncludingTax = inputForm.approvedIncludingTax.replace(/[^\d.]/g, '')
                  .replace(/^\./g, '')
                  .replace(/\.{2,}/g, '.')
                  .replace('.', '$#$').replace(/\./g, '').replace('$#$', '.')
                  .replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3').replace(/^0+/, '0')" clearable></el-input>
              </el-form-item>
            </el-col>
<!--            <el-col :span="12">
              <el-form-item label="银行函证发出数量(单位:份)" prop="bankLettersCount" :rules="[
              ]">
                <el-input v-model="inputForm.bankLettersCount" :disabled="true" placeholder="请填写银行函证发出数量(单位:份)" v-on:input="inputForm.bankLettersCount = inputForm.bankLettersCount
                  .replace(/[^\d]/g, '')
                  .replace(/^0+(?=\d)/, '')" clearable></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="其中采用数字函证发函数量(单位:份)" prop="digitalLetterCount" :rules="[
              ]">
                <el-input v-model="inputForm.digitalLetterCount" :disabled="true" placeholder="请填写其中采用数字函证发函数量(单位:份)" v-on:input="inputForm.xxx = inputForm.xxx
                  .replace(/[^\d]/g, '')
                  .replace(/^0+(?=\d)/, '')" clearable></el-input>
              </el-form-item>
            </el-col>-->
<!--            <el-col :span="12">
              <el-form-item label="所属行业" prop="industry" :rules="[
              ]">
                <el-select v-model="inputForm.industry" :disabled="true" 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="[
              ]">
                <el-select v-model="inputForm.businessObjects" :disabled="true" 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 @change="changeBusinessType" :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 v-model="inputForm.auditBusinessType" :disabled="true" 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 v-model="inputForm.auditBusinessType" :disabled="true" 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 v-model="inputForm.auditBusinessType" :disabled="true" 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 v-model="inputForm.auditBusinessType" :disabled="true" 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 v-model="inputForm.auditBusinessType" :disabled="true" 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 v-model="inputForm.auditBusinessType" :disabled="true" 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="[
              ]">
                <el-date-picker placement="bottom-start" :disabled="true" value-format="YYYY-MM-DD" v-model="inputForm.reportDate"
                  style="width: 100%" placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>-->
          </el-row>

        </el-form>

      </el-col>
    </el-row>
  </div>
</template>

<script>
import ProjectRecoredChooseCom from '../projectRecords/ProjectRecordsChooseCom'
import ReportServiceUnitForm from '../reportManagement/ReportServiceUnitForm'
import UpLoadComponent from '@/views/common/UpLoadComponent'
import UpLoadComponent2 from '@/views/common/UpLoadComponentV2.1'
import SelectTree from '@/components/treeSelect/treeSelect.vue'
import UserSelect from '../workClientInfo/clientUserSelect/AccountantUserIndex'
import UserSelect2 from '../workClientInfo/clientUserSelect/AccountantUserIndex2'
import UserSelectAll from '@/components/userSelect'
import ReportCancellApplyService from '@/api/cw/reportCancellApply/ReportCancellApplyService'
import ReportReviewService from '@/api/cw/reportManagement/ReportReviewService'
import projectReportService from '@/api/cw/reportManagement/ProjectReportService'
import EnterpriseSearchService from '@/api/cw/common/EnterpriseSearchService'
import CommonApi from '@/api/cw/common/CommonApi'
import UserSelect1 from '@/views/utils/UserTreeSelect'
import UserSelect3 from '@/views/utils/UserTreeSelect'
import ProjectReportArchiveService from '@/api/cw/projectRecords/ProjectReportArchiveService'
export default {
  props: {
    businessId: {
      type: String,
      default: ''
    },
    formReadOnly: {
      type: Boolean,
      default: false
    },
    status: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      title: '',
      method: '',
      loading: false,
      reviewBys: [],
      inputForm: {
        cwFileInfoList2: [],
        sealType: '',
        reviewBy: '', // 下一个节点审核人
        reportNumber: '',
        reportType: '',
        businessType: '',
        auditBusinessType: '',
        reportDate: '',
        reportName: '',
        servedUnitName: '', // 被服务单位
        registerAddress: '',
        securityBusiness: '',
        businessLocation: '',
        auditFees: '',
        documentNo: '',
        projectName: '',
        projectNumber: '',
        officeId: '',
        signatureAnnotator1: '',
        signatureAnnotator1Name: '',
        signatureAnnotator2: '',
        signatureAnnotator2Name: '',
        signatureType: '',
        projectMasterName: '',
        cwProjectInfoList: [],
        status: '',
        realCreate: '',
        realCreateName: '',
        userName: '',
        detailFor1010: [],
        detailFor1020: [],
        detailFor1030: [],
        details: [],
        projectId: '',
        reportNewLineId: '',
        id: '',
        createDate: '',
        createBy: {
          id: '',
          name: ''
        },
        remarks: '',
        reportNo: '',
        reportId: '',
        reportReviewNo: '',
        allPrintNum: '',
        issueNum: '',
        placeOnFileNum: '',
        printedBy: '',
        checkAutograph: '',
        computerNo: '',
        reportTitleType: '',
        needUpdate1: '',
        needUpdate2: '',
        needUpdate3: '',
        remark1: '',
        remark2: '',
        remark3: '',
        opinionType: '',
        cwFileInfoList: [],
        servedUnitId: '',
        reviewStatus: '',
        applyStatus: '',
        repetitionReviewFlag: '',
        taskName: '',
        realHeaderName: '',
        projectMasterId1: '',
        projectMasterId2: '',
        industry: '',
        businessObjects: '',
        reviewComments0: '',
        reviewComments1: '',
        reviewComments2: '',
        sid1: '',
        sid2: '',
		applyProcInsId: '',
        status1: '',
        status2: '',
        status3: '',
        approvedIncludingTax: '',
        approvedNoIncludingTax: '',
        bankLettersCount: "",
        digitalLetterCount: "",
        takeNumberType: '',
		applyAuditById: '',
	    procInsId: ''
      },
      keyWatch: '',
      activeName: 'enclosure',
      signatureName: 'archiveFile',
      tableKey: '',
      tableKeyClient: '1',
      tableKeyClient2: '1',
      tableKeyClient3: '1',
      created: ''
    }
  },
  ReportCancellApplyService: null,
  ProjectReportArchiveService: null,
  ReportReviewService: null,
  enterpriseSearchService: null,
  commonApi: null,
  created() {
    this.enterpriseSearchService = new EnterpriseSearchService()
    this.reportCancellApplyService = new ReportCancellApplyService()
    this.projectReportArchiveService = new ProjectReportArchiveService()
    this.reportReviewService = new ReportReviewService()
    this.commonApi = new CommonApi()
    this.detail = this.$route.query.detail;
  },
  computed: {
    bus: {
      get() {
        return this.businessId
      },
      set(val) {
        this.businessId = val
      }
    }
  },
  watch: {
    'keyWatch': {
      handler(newVal) {
        if (this.commonJS.isNotEmpty(this.bus)) {
			console.log("进入到了handler方法")
          this.init('', this.bus)
        } else {
          this.$nextTick(() => {
            // this.$refs.inputForm.resetFields()
          })
        }
      }
    },
    'loading': {
      handler(newVal) {
        this.$emit('changeLoading', newVal)
      }
    }
  },
  components: {
    ReportServiceUnitForm,
    ProjectRecoredChooseCom,
    UpLoadComponent,
    UpLoadComponent2,
    SelectTree,
    UserSelect,
    UserSelect2,
    UserSelectAll,
    UserSelect1,
    UserSelect3
    // ReportCancellApplyChooseCom
  },
  methods: {
    getKeyWatch(keyWatch) {
      this.keyWatch = keyWatch
    },
    init(method, id, detail) {
      this.activeName = 'enclosure'
      this.signatureName = 'archiveFile'
      this.reportCancellApplyService = new ReportCancellApplyService()
      this.projectReportArchiveService = new ProjectReportArchiveService()
      this.reportReviewService = new ReportReviewService()
      this.method = method
      this.inputForm = {
        reviewBy: '', // 下一个节点审核人
        sealType: '',
        reportNumber: '',
        reportType: '',
        businessType: '',
        auditBusinessType: '',
        reportDate: '',
        reportName: '',
        servedUnitName: '', // 被服务单位
        registerAddress: '',
        securityBusiness: '',
        businessLocation: '',
        auditFees: '',
        documentNo: '',
        projectName: '',
        projectNumber: '',
        officeId: '',
        signatureAnnotator1: '',
        signatureAnnotator1Name: '',
        signatureAnnotator2: '',
        signatureAnnotator2Name: '',
        signatureType: '',
        projectMasterName: '',
        cwProjectInfoList: [],
        status: '',
        realCreate: '',
        realCreateName: '',
        userName: '',
        detailFor1010: [],
        detailFor1020: [],
        detailFor1030: [],
        details: [],
        projectId: '',
        reportNewLineId: '',
        id: '',
        createDate: '',
        createBy: {
          id: '',
          name: ''
        },
        remarks: '',
        reportNo: '',
        reportId: '',
        reportReviewNo: '',
        allPrintNum: '',
        issueNum: '',
        placeOnFileNum: '',
        printedBy: '',
        checkAutograph: '',
        computerNo: '',
        reportTitleType: '',
        needUpdate1: '',
        needUpdate2: '',
        needUpdate3: '',
        remark1: '',
        remark2: '',
        remark3: '',
        opinionType: '',
        cwFileInfoList: [],
        cwFileInfoList2: [],
        servedUnitId: '',
        reviewStatus: '',
        repetitionReviewFlag: '',
        taskName: '',
        realHeaderName: '',
        projectMasterId1: '',
        projectMasterId2: '',
        industry: '',
        businessObjects: '',
        sid1: '',
        sid2: '',
		applyProcInsId: '',
        status1: '',
        status2: '',
        status3: '',
        approvedIncludingTax: '',
        approvedNoIncludingTax: '',
        bankLettersCount: "",
        digitalLetterCount: "",
        takeNumberType: '',
      },
        this.inputForm.reportId = id
      this.loading = false
      this.reviewBys = []
      this.$nextTick(() => {
        this.loading = true
		  this.projectReportArchiveService.queryReportById(this.inputForm.reportId).then((data) => {
          this.inputForm = this.recover(this.inputForm, data)
          console.log(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')
          }
          if (this.inputForm.approvedIncludingTax == "0") {
            this.inputForm.approvedIncludingTax = ""
          }
          if (this.inputForm.approvedNoIncludingTax == "0") {
            this.inputForm.approvedNoIncludingTax = ""
          }

          //当前登录人是苏州报告签字盖章代办且签章附件不为空的时候,进入页面展示已签章附件
          if (this.commonJS.isNotEmpty(data.signatureFileList) && data.isXs === '1') {
            this.signatureName = 'signatureFile'
          }
          if (data.applyAuditById) {
			  this.inputForm.applyAuditById = data.applyAuditById
          }
          if (data.procInsId) {
			  this.inputForm.procInsId = data.procInsId
          }
          if (this.status === 'taskFormDetail' || this.status === 'audit') {
            this.method = 'view'
          } else {
            this.method = 'false'
          }
          if (this.commonJS.isEmpty(this.inputForm.signatureType) && this.method !== 'view') {
            this.inputForm.signatureType = '1'
          }


          this.loading = false
        })
      })
    },

    clearClientList() {
      // 项目直接对接联系人列表清除
      this.inputForm.clientList = []
      this.$forceUpdate()
    },
    saveForm(callback) {
      this.doSubmit('save', callback)
    },
    startForm(callback) {
      this.loading = true
      if (this.commonJS.isNotEmpty(this.inputForm.id)) {
        projectReportService.queryById(this.inputForm.id).then((data) => {
          if (this.commonJS.isNotEmpty(data.reviewStatus) && data.reviewStatus !== '0' && data.reviewStatus !== '1' && data.reviewStatus !== '3') { // 审核状态不是“未发起”或“暂存”或“撤回”，就弹出提示
            if (data.reviewStatus === '5' && data.repetitionReviewFlag) {
              this.doSubmit('start', callback)
            } else {
              this.loading = false
              this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
              throw new Error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
            }
          } else {
            this.doSubmit('start', callback)
          }
        })
      } else {
        this.doSubmit('start', callback)
      }
    },
    async agreeForm(callback) {
      this.loading = true
      await projectReportService.queryById(this.inputForm.id).then((data) => {
        if (data.status !== '2') { // 审核状态不是“待审核”，就弹出提示
          // this.loading = false
          // this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
          // throw new Error()
          this.doSubmit('agree', callback)
        } else {
          this.doSubmit('agree', callback)
        }
      })
    },
    reapplyForm(callback) {
		console.log("进入reapplyForm方法")
      this.loading = true
		this.projectReportArchiveService.queryReportById(this.inputForm.id).then((data) => {
        if (data.status !== '4') { // 审核状态不是“驳回”，就弹出提示
          this.loading = false
          this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
          throw new Error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
        } else {
          this.doSubmit('reapply', callback)
        }
      })
    },
    // 表单提交
	  async doSubmit(status, callback) {
      if (status === 'save') {
        // 暂存
        this.inputForm.status = '1'
        this.loading = true
        this.inputForm.createDate = this.moment(new Date()).format('YYYY-MM-DD')
        // 验证报告 日期报告 类型是否出具报告 意见类型 是否为空
        // eslint-disable-next-line no-unused-expressions
        // 列表处理
        this.inputForm.details = []
        //保存到代归档申请记录表中
		  this.projectReportArchiveService.applySave(this.inputForm).then((data) => {
			  callback(data.businessTable, data.businessId, this.inputForm)
			  this.loading = false
		  }).catch(() => {
			  this.loading = false
		  })
        return
      } else if (status === 'start') {
        // 送审  待审核
        this.inputForm.status = '2'
        this.inputForm.assignee = this.inputForm.applyAuditById

		  if(!this.inputForm.assignee){
			  this.loading = false
			  this.$message.error('该报告对应的项目的项目经理存在问题，无法发起代归档申请')
			  throw new Error()
		  }

	  } else if (status === 'agree') {
		  console.log("进入审核同意节点")
        // 审核同意
        this.inputForm.agreeUserId = this.$store.state.user.id
		  console.log(this.inputForm.agreeUserId)
		  console.log(this.inputForm.procInsId)

		  await this.commonApi.getTaskNameByProcInsId(this.inputForm.procInsId).then((da) => {
			  console.log(da)
			  if (da === '项目分管领导审核') {
				  this.inputForm.status = '5'
			  }
		  })
		  console.log(this.inputForm.status)

        // this.inputForm.status = '5'
      } else if (status === 'reapply') {
		  console.log('reapply')
        this.inputForm.status = '2'
        this.inputForm.assignee = this.inputForm.applyAuditById
      }

      this.$refs['inputForm2'].validate((valid) => {
        if (valid) {
          	this.loading = true
			this.projectReportArchiveService.applySave(this.inputForm).then((data) => {
				console.log("data",data)
				callback(data.businessTable, data.businessId, this.inputForm)
				this.loading = false
			}).catch(() => {
				this.loading = false
			})
        } else {
          this.loading = false
        }
      })
    },
    async updateStatusById(type, callback) {
		console.log("进入updateStatusById方法")
		this.loading = true
      if (type === 'reject' || type === 'reback') {
        await this.projectReportArchiveService.queryReportById(this.inputForm.id).then((data) => {
          if (data.status !== '2') { // status的值不等于“审核中”就弹出提示
            this.loading = false
            this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
            throw new Error()
          } else {
            if (type === 'reject') {
              this.projectReportArchiveService.queryReportById(this.inputForm.id).then((review) => {
                console.log('review', review)
				  this.rejectOn(callback)
              })
            }
            if (type === 'reback') {
              // 撤回
              let param = { status: '3', id: this.inputForm.id }
              this.projectReportArchiveService.updateApplyStatusById(param)
            }
          }
        })
      } else if (type === 'hold') {
		  this.projectReportArchiveService.queryReportById(this.inputForm.id).then((data) => {
          if (data.status !== '4') { // status的值不等于“驳回”就弹出提示
            this.loading = false
            this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
            throw new Error()
          } else {
            // 终止
            let param = { status: '1', id: this.inputForm.id }
            this.projectReportArchiveService.updateApplyStatusById(param).then(() => {
              callback()
              this.loading = false
            })
          }
        })
      }
    },
    // 这个方法是这个之前这个页面的驳回方法，现在粘出来复用
    rejectOn(callback) {
      // 驳回
      let param
      this.inputForm.status = '4'
      // 列表处理
      this.inputForm.details = []
      param = {
		  status: this.inputForm.status,
        id: this.inputForm.id
      }
      this.projectReportArchiveService.updateApplyStatusById(param).then(() => {
        this.loading = false
        callback()
      })
    },
    close() {
      this.inputForm = {
        id: '',
        createDate: '',
        createBy: {
          id: '',
          name: this.$store.state.user.name
        },
        remarks: '',
        reportNo: '',
        reportReviewNo: '',
        allPrintNum: '',
        issueNum: '',
        placeOnFileNum: '',
        printedBy: '',
        checkAutograph: '',
        computerNo: '',
        reportTitleType: '',
        needUpdate1: '',
        remark1: '',
        opinionType: '',
        reportSponsor: '',
        projectMasterName: '',
        tableKeyClient: '1',
        realHeaderName: '',
        projectMasterId1: '',
        projectMasterId2: '',
        industry: '',
        businessObjects: ''
      }
      this.detail = ''
      this.reviewBys = []
    },
    tabHandleClick(event) {
      // console.log(event)
    },
    // 删除
    removeEvent(row, rowIndex, type) {
      if (type === 'client') {
        this.$refs.clientTable.remove(row)
      }
    },
    openContractForm() {
      if (!this.commonJS.isEmpty(this.inputForm.contractId)) {
        this.$refs.projectRecoredChooseCom.init(this.inputForm.contractId)
      } else {
        this.$refs.projectRecoredChooseCom.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 = []
    },
    openWorkClient() {
      this.$refs.reportServiceUnitForm.init(this.inputForm.projectId)
    },
    changeBusinessType() {
      // 切换业务类型的时候，审计业务类型清空
      this.inputForm.auditBusinessType = ''
    },

    openUserDia3() {
      this.$refs.userSelect3.init()
    },


  }
}
</script>
<style scoped>
/deep/ .el-input-number .el-input__inner {
  text-align: left;
}

/deep/ .vxe-select-option {
  padding: 0 .6em;
  max-width: 600px;
  overflow: visible;
  text-overflow: ellipsis;
  white-space: nowrap;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none
}
</style>
