<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
  <div>
    <el-dialog
      :title="title"
      :close-on-click-modal="false"
	  draggable
      width="1400px"
      height="500px"
      @close="close"
      append-to-body
      v-model="visible">
      <el-row>
        <el-row>
          <div v-if="tabName === '报告审核单下载'">
            <el-row type="flex" justify="end">
              <el-button @click="downloadCwReportAuditTpl">报告审核单下载</el-button>
            </el-row>
          </div>
          <el-form :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="method==='view'"
                   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="[
                              {required: true, message:'项目名称不能为空', trigger:'blur'},
                              {required: true, message:'项目名称不能为空', trigger:'change'}
                   ]">
                  <!--                <el-input v-model="inputForm.projectName" placeholder="请填写项目名称" clearable></el-input>-->
                  <el-input :readonly="true" @focus="openContractForm()" v-model="inputForm.projectName" placeholder="请选择项目名称">
                    <el-button slot="append" 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"
                    @getValue="(value) => {inputForm.officeId=value}"/>
                  <!--                <el-input v-model="inputForm.officeId" placeholder="请填写报告所属部门" clearable></el-input>-->
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="盖章类型" prop="signatureType"
                              :rules="[
                   ]">
                  <!--                <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 v-if="inputForm.signatureType === '1'|| inputForm.signatureType === '3' || commonJS.isEmpty(inputForm.signatureType)" :span="12">
                <el-form-item label="签字注师1" prop="signatureAnnotator1"
                              :rules="[
                   ]">
                  <!--                <el-input v-model="inputForm.signatureAnnotator1" placeholder="请填写签字注师1" clearable></el-input>-->
                  <UserSelect style="width: 100%" ref="userSelect1" :disabled="method === 'view'" :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="[
                   ]">
                  <!--                <el-input v-model="inputForm.signatureAnnotator2" placeholder="请填写签字注师2" clearable></el-input>-->
                  <UserSelect2 style="width: 100%" ref="userSelect2" :disabled="method === 'view'" :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:'blur'}
                   ]">
                  <!--                <el-input v-model="inputForm.signatureAnnotator1" placeholder="请填写签字注师1" clearable></el-input>-->
                  <UserSelect style="width: 100%" ref="userSelect1" :disabled="method === 'view'" :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:'blur'}
                   ]">
                  <!--                <el-input v-model="inputForm.signatureAnnotator2" placeholder="请填写签字注师2" clearable></el-input>-->
                  <UserSelect2 style="width: 100%" ref="userSelect2" :disabled="method === 'view'" :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" 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" 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="[
                              {required: true, message:'报告实际制作人不能为空', trigger:'blur'},
                          {required: true, message:'报告实际制作人不能为空', trigger:'change'}
                   ]">
                  <UserSelectAll :readonly="true" :disabled="method === 'view'" :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="24">
					<el-form-item label="报告名称" prop="reportName"
								  :rules="[
							  	{required: true, message:'报告名称不能为空', trigger:'blur'},
                   ]">
						<el-input v-model="inputForm.reportName" placeholder="请填写报告名称" clearable></el-input>
					</el-form-item>
				</el-col>
              <el-col :span="12">
                <el-form-item label="被服务单位" prop="servedUnitName"
                              :rules="[
                            {required: true, message:'被服务单位不能为空', trigger:'blur'}
                   ]">
                  <el-input :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="[
                            {required: true, message:'报告类型不能为空', trigger:'blur'}
                   ]">
                  <el-select 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="[
                            {required: true, message:'业务类型不能为空', trigger:'blur'}
                   ]">
                  <el-select v-model="inputForm.businessType" @change="changeBusinessType" 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="[
                            {required: true, message:'审计业务类型不能为空', trigger:'change'}
                   ]">
                  <el-select 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="[
                            {required: true, message:'审计业务类型不能为空', trigger:'change'}
                   ]">
                  <el-select 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="[
                            {required: true, message:'审计业务类型不能为空', trigger:'change'}
                   ]">
                  <el-select 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="[
                            {required: true, message:'审计业务类型不能为空', trigger:'change'}
                   ]">
                  <el-select 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="[
                            {required: true, message:'审计业务类型不能为空', trigger:'change'}
                   ]">
                  <el-select 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="[
                            {required: true, message:'审计业务类型不能为空', trigger:'change'}
                   ]">
                  <el-select 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="[
                   ]">
                  <el-date-picker
                    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-form :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="status !== 'audit' && status !== 'taskFormDetail'"
                       label-width="135px" @submit.native.prevent>
                <el-col :span="12">
                  <el-form-item label="意见类型" prop="opinionType"
                                :rules="[
                                  {required: true, message:'意见类型不能为空', trigger:'blur'}
                         ]">
                    <el-select 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-form>-->
<!--              <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 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 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 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>
&lt;!&ndash;                  <el-input v-model="inputForm.securityBusiness" placeholder="请填写是否数据证券业务" clearable>&ndash;&gt;
&lt;!&ndash;                  </el-input>&ndash;&gt;
                </el-form-item>
              </el-col>
            </el-row>
            <el-divider content-position="left"><i class="el-icon-document"></i> 报告审核信息</el-divider>
            <el-row  :gutter="15">
&lt;!&ndash;              <el-col :span="12">&ndash;&gt;
&lt;!&ndash;                <el-form-item label="报告类别" prop="reportTitleType"&ndash;&gt;
&lt;!&ndash;                              :rules="[&ndash;&gt;
&lt;!&ndash;                   ]">&ndash;&gt;
&lt;!&ndash;                  <el-select v-model="inputForm.reportTitleType" placeholder="请选择报告类别" style="width:100%;">&ndash;&gt;
&lt;!&ndash;                    <el-option&ndash;&gt;
&lt;!&ndash;                      v-for="item in $dictUtils.getDictList('cw_report_title_type')"&ndash;&gt;
&lt;!&ndash;                      :key="item.value"&ndash;&gt;
&lt;!&ndash;                      :label="item.label"&ndash;&gt;
&lt;!&ndash;                      :value="item.value">&ndash;&gt;
&lt;!&ndash;                    </el-option>&ndash;&gt;
&lt;!&ndash;                  </el-select>&ndash;&gt;
&lt;!&ndash;                  &lt;!&ndash;                <el-input v-model="inputForm.reportTitleType" placeholder="请填写报告类型及标题"></el-input>&ndash;&gt;&ndash;&gt;
&lt;!&ndash;                </el-form-item>&ndash;&gt;
&lt;!&ndash;              </el-col>&ndash;&gt;
&lt;!&ndash;              <el-col :span="12">&ndash;&gt;
&lt;!&ndash;                <el-form-item label="报告编号" prop="reportReviewNo"&ndash;&gt;
&lt;!&ndash;                              :rules="[&ndash;&gt;
&lt;!&ndash;                   ]">&ndash;&gt;
&lt;!&ndash;                  <el-input :disabled="true" v-model="inputForm.reportReviewNo" placeholder="自动生成">&ndash;&gt;
&lt;!&ndash;                    &lt;!&ndash;                  <el-button slot="append" icon="el-icon-search" @click="openContractForm()"></el-button>&ndash;&gt;&ndash;&gt;
&lt;!&ndash;                  </el-input>&ndash;&gt;
&lt;!&ndash;                </el-form-item>&ndash;&gt;
&lt;!&ndash;              </el-col>&ndash;&gt;

&lt;!&ndash;              <el-col :span="12">&ndash;&gt;
&lt;!&ndash;                <el-form-item label="创建人" prop="userName"&ndash;&gt;
&lt;!&ndash;                              :rules="[&ndash;&gt;
&lt;!&ndash;                   ]">&ndash;&gt;
&lt;!&ndash;                  <el-input :disabled="true" v-model="inputForm.userName" placeholder="请填写创建人" clearable></el-input>&ndash;&gt;
&lt;!&ndash;                </el-form-item>&ndash;&gt;
&lt;!&ndash;              </el-col>&ndash;&gt;
              <el-col :span="12">
                <el-form-item label="下一节点审核人" prop="reviewBy"
                              :rules="[
                   ]">
                  <el-select :disabled="true" 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="allPrintNum"
                              :rules="[
                   ]">
                  <el-input v-model="inputForm.allPrintNum" placeholder="请输入本报告共印份数">
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="发出份数（大写）" prop="issueNum"
                              :rules="[
                   ]">
                  <el-input v-model="inputForm.issueNum" placeholder="请输入发出份数">
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="存档份数（大写）" prop="placeOnFileNum"
                              :rules="[
                   ]">
                  <el-input 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 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 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 v-model="inputForm.computerNo" placeholder="请输入校对人签名">
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>-->
            <div v-if="method !== 'edit'">
              <el-divider content-position="left"><i class="el-icon-document"></i>一级复核</el-divider>
              <el-row :gutter="15" >
                <el-col :span="24">
					<vxe-table
						border
						show-overflow
						ref="details"
						class="vxe-table-element"
						:data="inputForm.detailFor1010"
						style="margin-left: 5em"
						keep-source
						highlight-current-row
						:key="tableKeyClient"
						:edit-config="{trigger: 'click', mode: 'cell', showStatus: true, autoClear: true}"
					>
						<vxe-table-column field="typeName" title="复核的主要内容" :edit-render="{}" show-overflow="title">
							<template #default="scope">
								<el-input :disabled="true"  v-model="scope.row.typeName" ></el-input>
							</template>
						</vxe-table-column>
						<vxe-table-column field="reviewComments" title="复核结果（是/否/不适用）" :edit-render="{name: '$select', options: $dictUtils.getDictList('yes_no_notApplicable')}">
							<template #default="scope">
								<vxe-select :disabled="method === 'view'" v-model="scope.row.reviewComments" transfer>
									<vxe-option
										v-for="item in $dictUtils.getDictList('yes_no_notApplicable')"
										:key="item.value"
										:value="item.value"
										:label="item.label">
									</vxe-option>
								</vxe-select>
							</template>
						</vxe-table-column>
					</vxe-table>
				</el-col>
                <el-col style="margin-top: 15px">
                  <el-form-item label="关注或修改的事项" prop="needUpdate1"
                                :rules="[
                   ]">
                    <el-input type="textarea" v-model="inputForm.needUpdate1" placeholder="请填写需提请关注或修改的事项"></el-input>
                  </el-form-item>
                </el-col>
                <el-col>
                  <el-form-item label="备注" prop="remark1"
                                :rules="[
                   ]">
                    <el-input type="textarea" v-model="inputForm.remark1" placeholder="请填写一级复核备注"></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="24">
					<vxe-table
						border
						show-overflow
						ref="details"
						class="vxe-table-element"
						:data="inputForm.detailFor1020"
						style="margin-left: 5em"
						keep-source
						highlight-current-row
						:key="tableKeyClient2"
						:edit-config="{trigger: 'click', mode: 'cell', showStatus: true, autoClear: true}"
					>
						<vxe-table-column field="typeName" title="复核的主要内容" :edit-render="{}" show-overflow="title">
							<template #default="scope">
								<el-input :disabled="true" v-model="scope.row.typeName" ></el-input>
							</template>
						</vxe-table-column>
						<vxe-table-column field="reviewComments" title="复核结果（是/否/不适用）" :edit-render="{name: '$select', options: $dictUtils.getDictList('yes_no_notApplicable')}">
							<template #default="scope">
								<vxe-select :disabled="method === 'view'" v-model="scope.row.reviewComments" transfer>
									<vxe-option
										v-for="item in $dictUtils.getDictList('yes_no_notApplicable')"
										:key="item.value"
										:value="item.value"
										:label="item.label">
									</vxe-option>
								</vxe-select>
							</template>
						</vxe-table-column>
					</vxe-table>
				</el-col>
                <el-col style="margin-top: 15px">
                  <el-form-item label="关注或修改的事项" prop="needUpdate2"
                                :rules="[
                   ]">
                    <el-input type="textarea" v-model="inputForm.needUpdate2" placeholder="请填写二级复核需提请关注或修改的事项"></el-input>
                  </el-form-item>
                </el-col>
                <el-col>
                  <el-form-item label="备注" prop="remark2"
                                :rules="[
                   ]">
                    <el-input type="textarea" v-model="inputForm.remark2" placeholder="请填写二级复核备注"></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="24">
					<vxe-table
						border
						show-overflow
						ref="details"
						class="vxe-table-element"
						:data="inputForm.detailFor1030"
						style="margin-left: 5em"
						keep-source
						highlight-current-row
						:key="tableKeyClient3"
						:edit-config="{trigger: 'click', mode: 'cell', showStatus: true, autoClear: true}"
					>
						<vxe-table-column field="typeName" title="复核的主要内容" :edit-render="{}" show-overflow="title">
							<template #default="scope">
								<el-input :disabled="true" v-model="scope.row.typeName" ></el-input>
							</template>
						</vxe-table-column>
						<vxe-table-column field="reviewComments" title="复核结果（是/否/不适用）" :edit-render="{name: '$select', options: $dictUtils.getDictList('yes_no_notApplicable')}">
							<template #default="scope">
								<vxe-select :disabled="method === 'view'" v-model="scope.row.reviewComments" transfer>
									<vxe-option
										v-for="item in $dictUtils.getDictList('yes_no_notApplicable')"
										:key="item.value"
										:value="item.value"
										:label="item.label">
									</vxe-option>
								</vxe-select>
							</template>
						</vxe-table-column>
					</vxe-table>
				</el-col>
                <el-col style="margin-top: 15px">
                  <el-form-item label="关注或修改的事项" prop="needUpdate3"
                                :rules="[
                   ]">
                    <el-input type="textarea" v-model="inputForm.needUpdate3" placeholder="请填写三级复核需提请关注或修改的事项"></el-input>
                  </el-form-item>
                </el-col>
                <el-col>
                  <el-form-item label="备注" prop="remark3"
                                :rules="[
                   ]">
                    <el-input type="textarea" v-model="inputForm.remark3" placeholder="三级复核备注"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </div>

          </el-form>
          <el-tabs v-model="activeName" style="width: 100%;" type="border-card" @tab-click="tabHandleClick">
            <!--<el-tab-pane label="报告信息列表" name="newRow">
              <el-button type="primary" style="margin-bottom: 15px" :disabled="method === 'view'" @click="openWorkClient"
                         v-if="inputForm.projectName !== '' & inputForm.projectName !== undefined"
              >
                新增行
              </el-button>
              &lt;!&ndash;            <el-button v-if="hasPermission('cw:reportManagement:del')" type="text" @click="del()">删除</el-button>&ndash;&gt;
              <el-row  :gutter="15">
                <el-form :disabled="method === 'view'">
                  <vxe-table
                    border
                    show-overflow
                    show-footer
                    :column-config="{resizable: true}"
                    ref="clientTable"
                    :key="tableKeyClient"
                    class="vxe-table-element"
                    :data="inputForm.cwProjectInfoList"
                    style=""
                    @cell-click=""
                    @edit-closed=""
                    highlight-current-row
                    :edit-config="{trigger: 'click', mode: 'row', showStatus: false, autoClear: false}"
                  >
                    <vxe-table-column type="seq" align="center" width="80" title="序号"></vxe-table-column>
                    <vxe-table-column align="center" field="servedUnitName" title="被服务单位" :edit-render="{}">
                      <template #default="scope">
                        <el-input :readonly="true" v-model="scope.row.servedUnitName" placeholder="被服务单位" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="reportDate" title="报告日期" :edit-render="{}">
                      <template #default="scope">
                        <el-date-picker
                          v-model="scope.row.reportDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="选择报告日期"
                          style="width:100%"
                          placement="bottom-start"
                          clearable>
                        </el-date-picker>
                        &lt;!&ndash;                      <el-input :readonly="true" v-model="scope.row.reportDate" placeholder="报告日期" clearable></el-input>&ndash;&gt;
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="reportType" title="报告类型" :edit-render="{name: '$select', options: $dictUtils.getDictList('cw_report_type')}">
                      <template #default="scope">
                        <el-select v-model="scope.row.reportType" placeholder="请选择报告类型" clearable style="width: 100%;">
                          <el-option
                            v-for="item in $dictUtils.getDictList('cw_report_type')"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                        </el-select>
                        &lt;!&ndash;                      <el-input v-model="scope.row.reportType" placeholder="报告类型" clearable></el-input>&ndash;&gt;
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="reportNumber" title="报告流水号" :edit-render="{}">
                      <template #default="scope">
                        <el-input :readonly="true" v-model="scope.row.reportNumber" placeholder="报告流水号" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="reportNo" title="报告文号" :edit-render="{}">
                      <template #default="scope">
                        <el-input :readonly="true" v-model="scope.row.reportNo" placeholder="报告文号" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="issueReport" title="是否出具报告" :edit-render="{}">
                      <template #default="scope">
                        <el-input :readonly="true" v-model="scope.row.issueReport" placeholder="是否出具报告" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="opinionType" title="意见类型" :edit-render="{name: '$select', options: $dictUtils.getDictList('cw_opinion_type')}">
                      <template #default="scope">
                        <el-select v-model="scope.row.opinionType" placeholder="请选择意见类型" clearable 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>
                        &lt;!&ndash;                      <el-input :readonly="true" v-model="scope.row.opinionType" placeholder="意见类型" clearable></el-input>&ndash;&gt;
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="sealType" title="盖章状态" :edit-render="{}">
                      <template #default="scope">
                        <el-input :readonly="true" v-model="scope.row.sealType" placeholder="盖章状态" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="fileNumber" title="文件数" :edit-render="{}">
                      <template #default="scope">
                        <el-input :readonly="true" v-model="scope.row.fileNumber" placeholder="文件数" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" title="操作" width="300">
                      <template v-slot="scope">
                        <el-button type="danger" :disabled="method === 'view'" @click="removeEvent(scope.row,scope.$rowIndex,'client')">删除</el-button>
                        <el-button type="primary" :disabled="method === 'view'" @click="sss(scope.$rowIndex)">上传附件</el-button>
                        <el-button :disabled="false" type="primary" @click="seeFileInfo(scope.$rowIndex)">查看文件详情</el-button>
                      </template>
                    </vxe-table-column>
                  </vxe-table>
                </el-form>
              </el-row>
            </el-tab-pane>-->
<!--            <el-tab-pane label="签章文件" name="archiveFile">-->
<!--              &lt;!&ndash;        签章文件&ndash;&gt;-->
<!--              <UpLoadComponent ref="archiveFile"></UpLoadComponent>-->
<!--            </el-tab-pane>-->
            <el-tab-pane label="附件" name="enclosure">
              <!--        附件-->
              <UpLoadComponent2 ref="enclosure"></UpLoadComponent2>
            </el-tab-pane>
            <el-tab-pane label="签章附件" name="archiveFile" :disabled="method === 'edit'">
              <!--        附件-->
              <UpLoadComponent ref="archiveFile" @clickSign="clickSign"></UpLoadComponent>
            </el-tab-pane>
            <el-tab-pane label="已签章附件" name="signatureFile" :disabled="method === 'edit'">
              <!--        附件-->
              <UpLoadComponent2 ref="signatureFile"></UpLoadComponent2>
            </el-tab-pane>
            <el-tab-pane label="历史报告列表" name="contact" :disabled="method === 'edit'">
              <el-row  :gutter="15">
                <el-col :span="24">
					<el-form :disabled="method==='view'" style="width: 100%;">
						<vxe-table
							border
							:column-config="{resizable: true}"
							show-overflow
							show-footer
							:key="tableKeyContact"
							ref="contactTable"
							class="vxe-table-element"
							:data="inputForm.cwWorkClientContactDTOList"
							style=""
							keep-source
							highlight-current-row
							:edit-config="{trigger: 'click', mode: 'row', showStatus: false, autoClear: false}"
						>
							<vxe-table-column type="seq" align="center" width="80" title="序号"></vxe-table-column>
							<vxe-table-column align="center" field="servedUnitName" title="被服务单位" :edit-render="{}" show-overflow="title">
								<template v-slot:edit="scope">
									<el-input v-model="scope.row.servedUnitName" placeholder="被服务单位" clearable></el-input>
								</template>
							</vxe-table-column>
							<vxe-table-column align="center" field="servedUnitName" title="被服务单位" :edit-render="{}" show-overflow="title">
								<template v-slot:edit="scope">
									<el-input v-model="scope.row.servedUnitName" placeholder="被服务单位" clearable></el-input>
								</template>
							</vxe-table-column>
							<vxe-table-column align="center" field="reportDate" title="报告日期" :edit-render="{}" show-overflow="title">
								<template v-slot:edit="scope">
									<el-input v-model="scope.row.reportDate" placeholder="报告日期" clearable></el-input>
								</template>
							</vxe-table-column>
							<vxe-table-column align="center" field="reportType" title="报告类型" :edit-render="{name: '$select', options: $dictUtils.getDictList('cw_report_type')}" show-overflow="title">
								<template v-slot:edit="scope">
									<el-select v-model="scope.row.reportType" placeholder="请选择报告类型" clearable style="width: 100%;">
										<el-option
											v-for="item in $dictUtils.getDictList('cw_report_type')"
											:key="item.value"
											:label="item.label"
											:value="item.value">
										</el-option>
									</el-select>
									<!--                      <el-input v-model="scope.row.reportType" placeholder="报告类型" clearable></el-input>-->
								</template>
							</vxe-table-column>
							<vxe-table-column align="center" field="reportNo" title="报告文号" :edit-render="{}" show-overflow="title">
								<template v-slot:edit="scope">
									<el-input v-model="scope.row.reportNo" placeholder="报告文号" clearable></el-input>
								</template>
							</vxe-table-column>
							<vxe-table-column align="center" field="sealType" title="盖章状态" :edit-render="{}" show-overflow="title">
								<template v-slot:edit="scope">
									<el-input v-model="scope.row.sealType" placeholder="盖章状态" clearable></el-input>
								</template>
							</vxe-table-column>
							<vxe-table-column align="center" field="documentStatus" title="单据状态" :edit-render="{}" show-overflow="title">
								<template v-slot:edit="scope">
									<el-input v-model="scope.row.documentStatus" placeholder="单据状态" clearable></el-input>
								</template>
							</vxe-table-column>
							<vxe-table-column align="center" title="操作" width="300">
								<template #default="scope">
									<vxe-button :disabled="true" size="small" status="danger" @click="removeEvent(scope.row,scope.$rowIndex,'client')">删除</vxe-button>
									<vxe-button :disabled="true" size="small" status="primary" @click="sss(scope.$rowIndex)">上传附件</vxe-button>
									<vxe-button :disabled="false" size="small" status="primary" @click="seeFileInfoTwo(scope.$rowIndex)">查看文件详情</vxe-button>
								</template>
							</vxe-table-column>
						</vxe-table>
					</el-form>
				</el-col>
              </el-row>
            </el-tab-pane>

          </el-tabs>
        </el-row>
      </el-row>
		<template #footer>
			<span class="dialog-footer">
			  <el-button @click="close()" icon="el-icon-circle-close">关闭</el-button>
			  <el-button  v-if="method === 'edit'" type="primary" icon="el-icon-circle-check" @click="doSubmit('save')">确定</el-button>
			</span>
		</template>
      <UpLoadComponentDialog ref="upLoadComponentDialog" @getUpload="getUpload"></UpLoadComponentDialog>
<!--      <WorkContractChooseCom ref="workContractChooseCom" @getContract="getContract"></WorkContractChooseCom>-->
<!--      <WorkClientChooseForm ref="workClientChooseForm" @getWorkClientChoose="getWorkClientChoose"></WorkClientChooseForm>-->
      <ProjectRecoredChooseCom  ref="projectRecoredChooseCom" @getProject="getContract"></ProjectRecoredChooseCom>
      <ReportServiceUnitForm ref="reportServiceUnitForm" @getWorkClientChoose="getWorkClientChoose"></ReportServiceUnitForm>
    </el-dialog>
  </div>
</template>

<script>
  import UpLoadComponent2 from '@/views/common/UpLoadComponent'
  import ReportReviewService from '@/api/cw/reportManagement/ReportReviewService'
  import UpLoadComponent from '@/views/common/UpLoadComponentV2.1'
  import SelectTree from '@/components/treeSelect/treeSelect.vue'
  // import UserSelect from '../workClientInfo/clientUserSelect'
  import UserSelect from '../workClientInfo/clientUserSelect/AccountantUserIndex'
  import UserSelect2 from '../workClientInfo/clientUserSelect/AccountantUserIndex2'
  import UserSelectAll from '@/components/userSelect'
  // import WorkClientChooseForm from '../workClientInfo/WorkClientChooseForm'
  // import WorkContractChooseCom from '../projectRecords/WorkContractChooseCom'
  import projectReportService from '@/api/cw/reportManagement/ProjectReportService'
  import UpLoadComponentDialog from '@/views/common/UpLoadComponentDialog'
  import ReportServiceUnitForm from './ReportServiceUnitForm'
  import ProjectRecoredChooseCom from '../projectRecords/ProjectRecordsChooseCom'
  import userService from "@/api/sys/userService";
  export default {
    props: {
      businessId: {
        type: String,
        default: ''
      },
      formReadOnly: {
        type: Boolean,
        default: false
      },
      status: {
        type: String,
        default: ''
      }
    },
    data () {
      return {
        title: '',
        method: '',
        loading: false,
        reviewBys: [],
        inputForm: {
          reviewBy: '', // 下一个节点审核人
          detailFor1010: [],
          detailFor1020: [],
          detailFor1030: [],
          details: [],
          reportNewLineId: '',
          allPrintNum: '',
          issueNum: '',
          placeOnFileNum: '',
          printedBy: '',
          checkAutograph: '',
          computerNo: '',
          reportTitleType: '',
          needUpdate1: '',
          needUpdate2: '',
          needUpdate3: '',
          remark1: '',
          remark2: '',
          remark3: '',
          projectMasterId1: '',
          reviewStatus: '',
          taskName: '',
          sealType: '',
          reportNumber: '',
          reportType: '',
          businessType: '',
          auditBusinessType: '',
          reportDate: '',
			reportName: '',
          servedUnitName: '', // 被服务单位
          registerAddress: '',
          securityBusiness: '',
          businessLocation: '',
          auditFees: '',
          userName: '',
          opinionType: '',
          reportNo: '',
          reportReviewNo: '',
          projectId: '',
          id: '',
          createDate: '',
          createBy: {
            id: '',
            name: this.$store.state.user.name
          },
          remarks: '',
          documentNo: '',
          projectName: '',
          projectNumber: '',
          officeId: '',
          signatureAnnotator1: '',
          signatureAnnotator2: '',
          signatureType: '',
          projectMasterName: '',
          cwProjectInfoList: [],
          cwFileInfoList: [],
          cwFileInfoList2: [],
          signatureFileList: [],
          servedUnitId: '',
          status: '',
          realCreate: '',
          realHeaderName: '',
          projectMasterId2: '',
          industry: '',
          businessObjects: ''
        },
        keyWatch: '',
        activeName: 'enclosure',
        tableKey: '',
        tableKeyClient: '1',
        tableKeyContact: '2',
        tableKeyClient2: '1',
        tableKeyClient3: '1',
        visible: false,
        tabName: ''
      }
    },
    ReportReviewService: null,
    created () {
      this.reportReviewService = new ReportReviewService()
    },
    computed: {
      bus: {
        get () {
          this.$refs.enclosure.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()
            })
          }
        }
      }
    },
    components: {
      UpLoadComponent2,
      UpLoadComponent,
      SelectTree,
      UserSelect,
	  UserSelect2,
      // WorkClientChooseForm,
      // WorkContractChooseCom,
      UpLoadComponentDialog,
      ReportServiceUnitForm,
      ProjectRecoredChooseCom,
      UserSelectAll
    },
    methods: {
      // seeFileInfo (index) {
      //   if (this.commonJS.isEmpty(this.inputForm.cwProjectInfoList[index].cwFileInfoList)) {
      //     this.inputForm.cwProjectInfoList[index].cwFileInfoList = []
      //   }
      //   this.$refs.upLoadComponentDialog.newUpload('view', this.inputForm.cwProjectInfoList[index].cwFileInfoList, null, null, null, null, null, false, index)
      //   this.$refs.upLoadComponentDialog.newUpload('view', this.inputForm.cwWorkClientContactDTOList[index].cwFileInfoList, null, null, null, null, null, false, index)
      // },
      seeFileInfoTwo (index) {
        if (this.commonJS.isEmpty(this.inputForm.cwWorkClientContactDTOList[index].cwFileInfoList)) {
          this.inputForm.cwWorkClientContactDTOList[index].cwFileInfoList = []
        }
        // this.$refs.upLoadComponentDialog.newUpload('view', this.inputForm.cwProjectInfoList[index].cwFileInfoList, null, null, null, null, null, false, index)
        this.$refs.upLoadComponentDialog.newUpload('view', this.inputForm.cwWorkClientContactDTOList[index].cwFileInfoList, null, null, null, null, null, false, index)
      },
      getKeyWatch (keyWatch) {
        this.keyWatch = keyWatch
      },
      init (method, id, tabName) {
        this.tabName = tabName
        this.visible = true
        if (method === 'edit') {
          this.title = '报告信息修改'
          this.method = method
        } else {
          this.title = '报告详情'
          this.method = 'view'
        }
        this.activeName = 'enclosure'
        this.reportReviewService = new ReportReviewService()
        this.method = method
        this.inputForm = {
          reviewBy: '', // 下一个节点审核人
          detailFor1010: [],
          detailFor1020: [],
          detailFor1030: [],
          details: [],
          reportNewLineId: '',
          allPrintNum: '',
          issueNum: '',
          placeOnFileNum: '',
          printedBy: '',
          checkAutograph: '',
          computerNo: '',
          reportTitleType: '',
          needUpdate1: '',
          needUpdate2: '',
          needUpdate3: '',
          remark1: '',
          remark2: '',
          remark3: '',
          projectMasterId1: '',
          reviewStatus: '',
          taskName: '',
          sealType: '',
          reportNumber: '',
          reportType: '',
          businessType: '',
          auditBusinessType: '',
          reportDate: '',
			reportName: '',
          servedUnitName: '', // 被服务单位
          registerAddress: '',
          securityBusiness: '',
          businessLocation: '',
          auditFees: '',
          userName: '',
          opinionType: '',
          reportNo: '',
          reportReviewNo: '',
          projectId: '',
          id: '',
          createDate: '',
          createBy: {
            id: '',
            name: this.$store.state.user.name
          },
          remarks: '',
          documentNo: '',
          projectName: '',
          projectNumber: '',
          officeId: '',
          signatureAnnotator1: '',
          signatureAnnotator2: '',
          signatureType: '',
          projectMasterName: '',
          cwProjectInfoList: [],
          cwFileInfoList: [],
          cwFileInfoList2: [],
          signatureFileList: [],
          servedUnitId: '',
          status: '',
          realCreate: '',
          realHeaderName: '',
          projectMasterId2: '',
          industry: '',
          businessObjects: ''
        }
        this.inputForm.id = id
        this.loading = false
        // this.$nextTick(() => {
        //   this.$refs.inputForm.resetFields()
        //   this.loading = true
        //   this.projectReportService.queryById(this.inputForm.id).then((data) => {
        //     // 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')
        //     }
        //     this.loading = false
        //   })
        //   // this.projectRecordsService.queryById(this.inputForm.id).then((data) => {
        //   //   // 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')
        //   //   }
        //   //   this.loading = false
        //   // })
        // })
        this.reviewBys = []
        this.$nextTick(() => {
          this.$refs.enclosure.clearUpload()
          this.$refs.archiveFile.clearUpload()
          this.$refs.signatureFile.clearUpload()
          this.$refs.inputForm.resetFields()
          this.loading = true
          projectReportService.queryById(this.inputForm.id).then((data) => {
            this.inputForm.status = data.status
            // console.log('this.inputForm.servedUnitName', data)
            // console.log('this.inputForm.status', this.inputForm.status)
            // this.$refs.uploadComponent.clearUpload()
            this.inputForm = this.recover(this.inputForm, data)
            this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
            // console.log('this.inputForm.cwWorkClientContactDTOList', data.cwWorkClientContactDTOList)
            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
            }
            if (data.reviewBys) {
              data.reviewBys.forEach(re => {
                let va = {
                  label: re.name,
                  value: re.sysUserId
                }
                this.reviewBys.push(va)
              })
            }
            if (this.formReadOnly) {
              method = 'view'
            }
            if (this.commonJS.isEmpty(this.inputForm.signatureType) && this.method !== 'view') {
              this.inputForm.signatureType = '1'
            }
            if (this.commonJS.isEmpty(data.details)) {
              this.reportReviewService.list('1').then((data) => { this.detailDivide(data) })
            } else {
              this.detailDivide(data.details)
            }
            this.$refs.enclosure.newUpload(method, data.cwFileInfoList2, 'cwWorkContract', null, null, null, null, false)
            this.inputForm.cwWorkClientContactDTOList = data.cwWorkClientContactDTOList
            // this.$refs.enclosure.newUpload(method, data.cwFileInfoList2, 'cwWorkContract', null, null, null, null, false)
            this.$refs.archiveFile.newUpload(method, data.cwFileInfoList, 'cwWorkContract', null, null, null, null, false)
            this.$refs.signatureFile.newUpload('view', data.signatureFileList, 'cwWorkContract', null, null, null, null, false)
            this.loading = false
          })
          // this.projectRecordsService.queryById(this.inputForm.id).then((data) => {
          //   // 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')
          //   }
          //   this.loading = false
          // })
        })
      },
      clickSign () {
        projectReportService.saveFlowableParam(this.inputForm).then((data) => {
          window.open(data, '_blank')
        })
      },
      detailDivide (details) {
        this.inputForm.detailFor1010 = []
        this.inputForm.detailFor1020 = []
        this.inputForm.detailFor1030 = []
        details.forEach(item => {
          if (item.sort.toString().startsWith('1010')) {
            this.inputForm.detailFor1010.push(item)
            this.tableKeyClient = Math.random()
          }
          if (item.sort.toString().startsWith('1020')) {
            this.inputForm.detailFor1020.push(item)
            this.tableKeyClient2 = Math.random()
          }
          if (item.sort.toString().startsWith('1030')) {
            this.inputForm.detailFor1030.push(item)
            this.tableKeyClient3 = Math.random()
          }
        })
      },
      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()
        }
      },
      saveForm (callback) {
        this.doSubmit('save', callback)
      },
      startForm (callback) {
        this.doSubmit('start', callback)
      },
      async agreeForm (callback) {
        await projectReportService.queryById(this.inputForm.id).then((data) => {
          if (this.inputForm.status !== '2') { // 审核状态不是“待审核”，就弹出提示
            this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
            throw new Error()
          } else {
            this.doSubmit('agree', callback)
          }
        })
      },
      // 表单提交
      doSubmit (status, callback) {
        if (this.$refs.enclosure.checkProgress()) {
          this.loading = false
          throw new Error()
        } else if (this.$refs.signatureFile.checkProgress()) {
          this.loading = false
          throw new Error()
        } else {
          if (status === 'save') {
            this.$refs['inputForm'].validate((valid) => {
              if (valid) {
                // 暂存
                this.loading = true
                this.inputForm.cwFileInfoList2 = this.$refs.enclosure.getDataList()
                this.inputForm.signatureFileList = this.$refs.signatureFile.getDataList()
                // 列表处理
                this.inputForm.details = []
                this.inputForm.detailFor1010.forEach(item => { this.inputForm.details.push(item) })
                this.inputForm.detailFor1020.forEach(item => { this.inputForm.details.push(item) })
                this.inputForm.detailFor1030.forEach(item => { this.inputForm.details.push(item) })
				  //根据签字注师1的人员id去查是否超过了100次
				  userService.getCount(this.inputForm.signatureAnnotator1).then((data) => {
					  if (data.accountantUserCount >= 100 && data.accountantUserFlag === 1) {
						  this.$message.error(`请选择被选次数小于100次的签字注师人员`)
						  this.loading = false
						  throw new Error()
					  } else {
						  this.reportReviewService.save(this.inputForm).then(() => {
							  projectReportService.saveForm(this.inputForm).then(() => {
								  this.$emit('refreshList')
								  this.close()
								  this.loading = false
							  }).catch(() => {
								  this.loading = false
							  })
						  })
					  }
				  });
              }
            })
            return
          } else if (status === 'start') {
            // 送审  待审核
            this.inputForm.status = '2'
          } else if (status === 'agree') {
            // 审核同意
            this.inputForm.agreeDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
            this.inputForm.agreeUserId = this.$store.state.user.id
            this.inputForm.status = '5'
          }
          this.$refs['inputForm'].validate((valid) => {
            if (valid) {
              this.loading = true
              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.reportDate)) {
                this.$message.error('报告日期不能为空')
                this.loading = false
                throw new Error('报告日期不能为空')
              }
              if (this.commonJS.isEmpty(this.inputForm.reportType)) {
                this.$message.error('报告类型不能为空')
                this.loading = false
                throw new Error('报告类型不能为空')
              }
              this.inputForm.cwFileInfoList2 = this.$refs.enclosure.getDataList()
              this.inputForm.signatureFileList = this.$refs.signatureFile.getDataList()
              projectReportService.saveForm(this.inputForm).then((data) => {
                callback(data.businessTable, data.businessId, this.inputForm)
                this.loading = false
              }).catch(() => {
                this.loading = false
              })
            }
          })
        }
      },
      async updateStatusById (type) {
        if (type === 'reject' || type === 'reback') {
          // if (await this.$refs.uploadComponent.checkProgress()) {
          //   this.loading = false
          //   throw new Error()
          // }
          await projectReportService.queryById(this.inputForm.id).then((data) => {
            if (data.status !== '2') { // status的值不等于“审核中”就弹出提示
              this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
              throw new Error()
            } else {
              if (type === 'reject') {
                // 驳回
                this.inputForm.status = '4'
                let param = {status: '4', id: this.inputForm.id}
                projectReportService.updateStatusById(param)
              }
              if (type === 'reback') {
                // 撤回
                let param = {status: '3', id: this.inputForm.id}
                projectReportService.updateStatusById(param)
              }
            }
          })
        }
      },
      close () {
        this.reviewBys = []
        this.inputForm = {
          id: '',
          createDate: '',
          createBy: {
            id: '',
            name: ''
          },
          remarks: '',
          projectNumber: '',
          projectName: '',
          officeId: '',
          projectMoney: '',
          auditYear: '',
          planStartDate: '',
          planEndDate: '',
          projectMasterName: '',
          projectLeaderId: '',
          procInsId: '',
          processDefinitionId: '',
          status: '',
          workAttachmentDtoList: [],
          cwProjectClientInfoDTOList: [],
          contractName: '',
          contractAmount: '',
          contractNum: '',
          payerSubject: '',
          paymentMethod: '',
          contractId: '',
          realCreate: '',
          realHeaderName: '',
          projectMasterId2: '',
          industry: '',
          businessObjects: ''
        }
        // this.$refs.uploadComponent.clearUpload()
        this.$refs.inputForm.resetFields()
        this.visible = false
      },
      tabHandleClick (event) {
        // console.log(event)
      },
      // 新增
      // eslint-disable-next-line no-dupe-keys
      // insertEvent (type) {
      //   if (type === 'client') {
      //     let d = {
      //       no: '',
      //       name: '',
      //       companyLevel: ''
      //     }
      //     if (this.commonJS.isEmpty(this.inputForm.cwProjectClientInfoDTOList)) {
      //       this.inputForm.cwProjectClientInfoDTOList = []
      //     }
      //     this.$refs.clientTable.insertAt(d)
      //     this.inputForm.cwProjectClientInfoDTOList.push(d)
      //     this.tableKeyClient = Math.random()
      //   }
      // },
      // 删除
      removeEvent (row, rowIndex, type) {
        if (type === 'client') {
          this.$refs.clientTable.remove(row)
          // this.inputForm.cwProjectClientInfoDTOList.splice(rowIndex, 1)
          // this.inputForm.cwProjectInfoList.splice(rowIndex, 1)
        }
      },
      openWorkClient () {
        // this.$refs.workClientChooseForm.init()
        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 => {
            this.inputForm.servedUnitName = item.name
            this.inputForm.servedUnitId = item.id
            this.inputForm.sealType = '未盖章'
            this.tableKeyClient = Math.random()
          })
        })
      },
      clearClientList () {
        // 项目直接对接联系人列表清除
        this.inputForm.clientList = []
        this.$forceUpdate()
      },
      getContract (row) {
        console.log('row', row)
        this.inputForm.projectName = row.projectName // 项目名称
        this.inputForm.projectId = row.id // 项目id
        this.inputForm.projectNumber = row.projectNumber // 项目编号
        this.inputForm.projectMasterName = row.projectMasterName // 项目经理
        this.inputForm.projectMasterId1 = row.projectMasterId // 项目经理1id
        this.inputForm.projectMasterId2 = row.realHeader // 项目经理2id
        this.inputForm.realHeaderName = row.realHeaderName // 项目经理2名称
        this.inputForm.signatureAnnotator1 = row.projectMasterId // 签字注师1id = 项目经理1id
        this.inputForm.signatureAnnotator2 = row.realHeader // 签字注师2id = 项目经理2id
        this.clearClientList()
        this.$forceUpdate()
        this.inputForm.cwProjectInfoList = []
      },
      // openContract () {
      //   this.$refs.workContractChooseCom.init()
      // },
      // 两位小数数字验证
      twoDecimalPlaces (num) {
        let str = num.toString()
        var len1 = str.substr(0, 1)
        var len2 = str.substr(1, 1)
        // eslint-disable-next-line eqeqeq
        if (str.length > 1 && len1 == 0 && len2 != '.') {
          str = str.substr(1, 1)
        }
        // eslint-disable-next-line eqeqeq
        if (len1 == '.') {
          str = ''
        }
        // eslint-disable-next-line eqeqeq
        if (str.indexOf('.') != -1) {
          var str_ = str.substr(str.indexOf('.') + 1)
          // eslint-disable-next-line eqeqeq
          if (str_.indexOf('.') != -1) {
            str = str.substr(0, str.indexOf('.') + str_.indexOf('.') + 1)
          }
          if (str_.length > 2) {
            this.$message.warning(`金额小数点后只能输入两位，请正确输入！`)
            return (str = '')
          }
        }
        // eslint-disable-next-line no-useless-escape
        str = str.replace(/[^\d^\.]+/g, '') // 保留数字和小数点
        return str
      },
      getUpload (p, index) {
        p.then((list) => {
          // list为返回数据
          this.inputForm.cwProjectInfoList[index].cwFileInfoList = list
          this.inputForm.cwProjectInfoList[index].fileNumber = list.length
          this.tableKeyClient = Math.random()
          this.tableKeyContact = Math.random()
          // console.log('this.inputForm.cwFileInfoList', this.inputForm.cwFileInfoList)
          // console.log('list.length', list.length)
          // console.log(list)
        })
      },
      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
        }
      },
      changeBusinessType () {
        // 切换业务类型的时候，审计业务类型清空
        this.inputForm.auditBusinessType = ''
      },
      // 下载报告审核单下载
      downloadCwReportAuditTpl () {
        // this.$utils.downloadExcel('/sys/project/import/template')
        this.loading = true
        projectReportService.downloadCwReportAuditTpl(this.inputForm.id).then((res) => {
          // 将二进制流文件写入excel表，以下为重要步骤
          this.$utils.downloadExcel(res, '报告审核单.xls')
          this.loading = false
        }).catch(function (err) {
          this.loading = false
          if (err.response) {
            console.log(err.response)
          }
        })
      }
    }
  }
</script>
<style scoped>
  /deep/ .el-input-number .el-input__inner {
    text-align: left;
  }
</style>
