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

		<div>
			<el-form size="large" :model="inputForm" ref="inputForm" v-loading="loading"
				:class="method === 'view' ? 'readonly' : ''"
				:disabled="status === 'audit' || status === 'taskFormDetail' || method === 'view'" label-width="170px"
				@submit.native.prevent>
				<el-divider content-position="left"><i class="el-icon-document"></i> 项目归档</el-divider>
				<el-row :gutter="15">
					<el-col :span="12">
						<el-form-item label="项目名称" prop="programProjectListInfo.name">
							<el-input size="large" :disabled="true" v-model="inputForm.programProjectListInfo.name"
								placeholder="请输入项目名称" clearable></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="评估基准日" prop="programProjectListInfo.assessmentDate">
							<el-date-picker :disabled="true" v-model="inputForm.programProjectListInfo.assessmentDate"
								type="date" value-format="YYYY-MM-DD" placeholder="选择评估基准日" style="width:100%"
								placement="bottom-start" clearable>
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="报告号" prop="reportNo">
							<el-input size="large" :disabled="true" v-model="inputForm.reportNo" placeholder="请输入报告号"
								clearable></el-input>
						</el-form-item>
					</el-col>

					<el-col :span="12">
						<el-form-item label="项目负责人" prop="programProjectListInfo.projectManager">
							<SelectUserTree ref="companyTree" size="large" :props="{
								value: 'id',             // ID字段名
								label: 'name',         // 显示名称
								children: 'children'    // 子级字段名
							}" :url="`/system-server/sys/user/treeUserDataAllOffice?type=2`"
								:value="inputForm.programProjectListInfo.projectManager" :disabled="true"
								:clearable="true" :accordion="true"
								@getValue="(value) => { inputForm.programProjectListInfo.projectManager = value }" />
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="所属部门" prop="programProjectListInfo.officeId">
							<el-input size="large" :disabled="true" v-model="inputForm.programProjectListInfo.officeId"
								placeholder="请输入所属部门" clearable></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="年份" prop="year" :rules="[

						]">
							<el-input size="large" :disabled="true" v-model="inputForm.year" placeholder="请输入年份"
								clearable></el-input>
							<!--                <el-date-picker-->
							<!--                  v-model="inputForm.year"-->
							<!--                  type="year"-->
							<!--                  value-format="yyyy"-->
							<!--                  placeholder="选择评年份"-->
							<!--                  style="width:100%"-->
							<!--                  placement="bottom-start"-->
							<!--                  clearable>-->
							<!--                </el-date-picker>-->
						</el-form-item>
					</el-col>
					<!--            <el-col :span="12">-->
					<!--              <el-form-item label="项目类型" prop="programType"-->
					<!--                            :rules="[-->
					<!--                        {required: true, message:'项目类型不能为空', trigger:'blur'}-->
					<!--                 ]">-->
					<!--                <el-input v-model="inputForm.programType" maxlength="64" placeholder="请填写项目类型"    clearable ></el-input>-->
					<!--              </el-form-item>-->
					<!--            </el-col>-->
					<el-col :span="12">
						<el-form-item label="项目类型" prop="programProjectListInfo.projectMould" :rules="[
						]">
							<el-select v-model="inputForm.programProjectListInfo.projectMould" :disabled="true"
								placeholder="请选择项目类型" clearable style="width: 100%;">
								<el-option v-for="item in $dictUtils.getDictList('program_registered_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="programProjectListInfo.contractNo" :rules="[
						]">
							<el-input :disabled="true" v-model="inputForm.programProjectListInfo.contractNo"
								maxlength="64" placeholder="请填写合同编号" clearable></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="12" style="display: none;">
						<el-form-item label="项目id" prop="programProjectListInfo.id" :rules="[
						]">
							<el-input :disabled="true" v-model="inputForm.programProjectListInfo.id" maxlength="64"
								placeholder="项目id" clearable></el-input>
						</el-form-item>
					</el-col>


					<el-col :span="12" v-if="this.inputForm.reportType != 2">
						<el-form-item label="签字评估师1" prop="signatureEvaluatorFirst" :rules="[
							{ required: true, message: '签字评估师1不能为空', trigger: 'blur' }
						]">
							<!--                <UserSelect :disabled="status === 'audit' || status === 'taskFormDetail'|| method === 'view'" :readonly="true" :limit='1' :modelValue="inputForm.signatureEvaluatorFirst" @update:modelValue='(value) => {inputForm.signatureEvaluatorFirst = value}'></UserSelect>-->
							<el-input :disabled="status === 'audit' || status === 'taskFormDetail' || method === 'view'"
								:readonly="true" @focus="openUserDia1" v-model="inputForm.signatureEvaluatorFirstName"
								placeholder="请选择签字评估师1">
								<template #suffix>
									<el-button
										:disabled="status === 'audit' || status === 'taskFormDetail' || method === 'view'"
										:readonly="true"
										style="background-color: white;color: #1b1e25;border-color: white;"
										type="primary" slot="append" icon="el-icon-search" @click="openUserDia1">
									</el-button>
								</template>
							</el-input>
						</el-form-item>
					</el-col>


					<el-col :span="12" v-if="this.inputForm.reportType != 2">
						<el-form-item label="签字评估师2" prop="signatureEvaluatorSecond" :rules="[
							{ required: true, message: '签字评估师2不能为空', trigger: 'blur' }
						]">
							<!--                <UserSelect :disabled="status === 'audit' || status === 'taskFormDetail'|| method === 'view'" :readonly="true" :limit='1' :modelValue="inputForm.signatureEvaluatorSecond" @update:modelValue='(value) => {inputForm.signatureEvaluatorSecond = value}'></UserSelect>-->
							<el-input :disabled="status === 'audit' || status === 'taskFormDetail' || method === 'view'"
								:readonly="true" @focus="openUserDia2" v-model="inputForm.signatureEvaluatorSecondName"
								placeholder="请选择签字评估师2">
								<template #suffix>
									<el-button
										:disabled="status === 'audit' || status === 'taskFormDetail' || method === 'view'"
										:readonly="true"
										style="background-color: white;color: #1b1e25;border-color: white;"
										type="primary" slot="append" icon="el-icon-search" @click="openUserDia2">
									</el-button>
								</template>
							</el-input>
						</el-form-item>
					</el-col>

					<el-col :span="12">
						<el-form-item label="评估报告日" prop="evaluationReportDate" :rules="[
							{ required: true, message: '评估报告日不能为空', trigger: 'blur' }
						]">
							<el-date-picker style="width:100%;" v-model="inputForm.evaluationReportDate" type="date"
								placement="bottom-start" value-format="YYYY-MM-DD" placeholder="选择日期" clearable>
							</el-date-picker>
						</el-form-item>
					</el-col>

					<el-col :span="12">
						<el-form-item label="废旧物资评估值(万元)" prop="waystEvaluation" :rules="[
						]">
							<el-input-number v-model="inputForm.waystEvaluation" controls-position="right"
								:controls="false" :max="999999999999999" style="width:100%;" :precision="2"
								placeholder="请填写废旧物资评估" :step="0.01" :min="0" clearable>
							</el-input-number>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="固定资产评估值(万元)" prop="fixedAssetsEvaluation" :rules="[
						]">
							<el-input-number v-model="inputForm.fixedAssetsEvaluation" controls-position="right"
								:controls="false" :max="999999999999999" style="width:100%;" :precision="2"
								placeholder="请填写固定资产评估" :step="0.01" :min="0" clearable>
							</el-input-number>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="净资产评估值(万元)" prop="netAssetsEvaluation" :rules="[
						]">
							<el-input-number v-model="inputForm.netAssetsEvaluation" controls-position="right"
								:controls="false" :max="999999999999999" style="width:100%;" :precision="2"
								placeholder="请填写净资产评估" :step="0.01" :min="0" clearable>
							</el-input-number>
							<!--                <el-input v-model="inputForm.netAssetsEvaluation" maxlength="64" placeholder="请填写净资产评估" @keyup.native="inputForm.netAssetsEvaluation = twoDecimalPlaces(inputForm.netAssetsEvaluation)"clearable></el-input>-->
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="租金评估(万元)" prop="rentEvaluation" :rules="[
						]">
							<el-input-number v-model="inputForm.rentEvaluation" controls-position="right"
								:controls="false" :max="999999999999999" style="width:100%;" :precision="2"
								placeholder="请填写租金评估" :step="0.01" :min="0" clearable>
							</el-input-number>
						</el-form-item>
					</el-col>

					<el-col :span="12">
						<el-form-item label="合同金额（元）" prop="actualCharges" :rules="[
							{ required: true, message: '合同金额不能为空', trigger: 'blur' }
						]">
							<el-input-number v-model="inputForm.actualCharges" controls-position="right"
								:controls="false" :max="999999999999999" style="width:100%;" :precision="2"
								placeholder="请填写合同金额" :step="0.01" :min="0" clearable>
							</el-input-number>
						</el-form-item>
					</el-col>

					<el-col :span="12">
						<el-form :model="inputForm" :disabled="false" label-width="170px">
							<el-form-item label="实际开票金额（元）" prop="reportCharges" :rules="[
								{ required: true, message: '实际开票金额不能为空', trigger: 'blur' }
							]">
								<el-input-number v-model="inputForm.reportCharges" controls-position="right"
									:disabled="status == 'taskFormDetail'" :controls="false" :max="999999999999999"
									style="width:100%;" :precision="2" placeholder="请填写实际开票金额" :step="0.01" :min="0"
									clearable>
								</el-input-number>
							</el-form-item>
						</el-form>
					</el-col>

					<el-col :span="12" v-if="inputForm.programProjectListInfo.projectMould === '1'">
						<el-form-item label="租金类型" prop="rentType" :rules="[
							{ required: true, message: '租金类型不能为空', trigger: 'blur' }
						]">
							<el-input v-model="inputForm.rentType" maxlength="64" placeholder="请填写租金类型"
								clearable></el-input>
						</el-form-item>
					</el-col>

					<el-col :span="12" v-else>
						<el-form-item label="租金类型" prop="rentType" :rules="[
						]">
							<el-input v-model="inputForm.rentType" maxlength="64" placeholder="请填写租金类型"
								clearable></el-input>
						</el-form-item>
					</el-col>

					<el-form :model="inputForm" :disabled="false" label-width="170px">
						<el-row :gutter="15">
							<el-col :span="12">
								<el-form-item label="是否开票" prop="isInvoice" :rules="[
									{ required: true, message: '是否开票不能为空', trigger: 'blur' }
								]">
									<el-radio-group v-model="inputForm.isInvoice" @change="handleGetInvoiceInfo"
										:disabled="status == 'taskFormDetail'">
										<el-radio v-for="item in $dictUtils.getDictList('yes_no')" :label="item.value"
											:key="item.id">{{
												item.label
											}}</el-radio>
									</el-radio-group>
								</el-form-item>
							</el-col>
							<el-col :span="24">
								<el-form-item label="已开票发票号" prop="" v-if="inputForm.isInvoice == 1">
									<el-select v-model="invoiceList" multiple disabled style="width: 100%"
										suffix-icon="">
										<el-option v-for="item in invoiceList" :key="item" :label="item"
											:value="item" />
									</el-select>
								</el-form-item>
							</el-col>

							<el-col :span="12">
								<el-form-item label="开票日期" prop="invoiceDate" :rules="invoiceDateRule">
									<el-date-picker style="width:100%;" placement="bottom-start"
										v-model="inputForm.invoiceDate" :disabled="status == 'taskFormDetail'"
										type="date" value-format="YYYY-MM-DD" placeholder="选择日期时间" clearable>
									</el-date-picker>
								</el-form-item>
							</el-col>

							<el-col :span="12">
								<el-form-item label="合同是否存档" prop="isContractArchive" :rules="[
									{ required: true, message: '合同是否存档不能为空', trigger: 'blur' }
								]">
									<el-radio-group v-model="inputForm.isContractArchive"
										:disabled="status !== 'audit'">
										<el-radio v-for="item in $dictUtils.getDictList('yes_no')" :label="item.value"
											:key="item.id">{{
												item.label
											}}</el-radio>
									</el-radio-group>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="底稿是否完好" prop="isPapersIntact" :rules="[
									{ required: true, message: '底稿是否完好不能为空', trigger: 'blur' }
								]">
									<el-radio-group v-model="inputForm.isPapersIntact"
										:disabled="status == 'taskFormDetail'">
										<el-radio v-for="item in $dictUtils.getDictList('yes_no')" :label="item.value"
											:key="item.id">{{
												item.label
											}}</el-radio>
									</el-radio-group>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="底稿是否归档" prop="isPapersArchive" :rules="[
									{ required: true, message: '底稿是否归档不能为空', trigger: 'blur' }
								]">
									<el-radio-group v-model="inputForm.isPapersArchive"
										:disabled="status == 'taskFormDetail'">
										<el-radio v-for="item in $dictUtils.getDictList('yes_no')" :label="item.value"
											:key="item.id">{{
												item.label
											}}</el-radio>
									</el-radio-group>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="是否备案" prop="isBa" :rules="[
									{ required: true, message: '是否备案不能为空', trigger: 'blur' }
								]">
									<el-radio-group v-model="inputForm.isBa" :disabled="status == 'taskFormDetail'">
										<el-radio v-for="item in $dictUtils.getDictList('yes_no')" :label="item.value"
											:key="item.id">{{
												item.label
											}}</el-radio>
									</el-radio-group>
								</el-form-item>
							</el-col>
						</el-row>
					</el-form>
					<!-- <el-col :span="12">
            <el-form-item label="外勤是否已经报销" prop="isOpsReimbursement" :rules="[
              { required: true, message: '外勤是否已经报销不能为空', trigger: 'blur' }
            ]">
              <el-radio-group v-model="inputForm.isOpsReimbursement">
                <el-radio v-for="item in $dictUtils.getDictList('yes_no')" :label="item.value" :key="item.id">{{
                  item.label
                }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col> -->
					<!-- <el-col :span="12">
            <el-form-item label="报销外勤天数" prop="opsAmount" :rules="[
              { required: true, message: '报销外勤天数不能为空', trigger: 'blur' }
            ]">
              <el-input-number v-model="inputForm.opsAmount" controls-position="right" :controls="false" :max="999999"
                style="width:100%;" :precision="1" placeholder="请填写报销外勤天数" :step="0.1" :min="0" clearable>
              </el-input-number>
            </el-form-item>
          </el-col> -->
					<!-- <el-col :span="12">
            <el-form-item label="已报销金额" prop="reimbursementAmount" :rules="[
              { required: true, message: '已报销金额不能为空', trigger: 'blur' }
            ]">
              <el-input-number v-model="inputForm.reimbursementAmount" controls-position="right" :controls="false"
                :max="999999999999999" style="width:100%;" :precision="2" placeholder="请填写已报销金额" :step="0.01" :min="0"
                clearable>
              </el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="未报销金额" prop="unreimbursedAmount" :rules="[
              { required: true, message: '未报销金额不能为空', trigger: 'blur' }
            ]">
              <el-input-number v-model="inputForm.unreimbursedAmount" controls-position="right" :controls="false"
                :max="999999999999999" style="width:100%;" :precision="2" placeholder="请填写未报销金额" :step="0.01" :min="0"
                clearable>
              </el-input-number>
            </el-form-item>
          </el-col> -->
					<!-- <el-col :span="12">
            <el-form-item label="报销单号" prop="reimbursementNum" :rules="[
            ]">
              <el-input v-model="inputForm.reimbursementNum" maxlength="64" placeholder="请填写报销单号" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报销日期" prop="reimbursementDate" :rules="[
            ]">
              <el-date-picker placement="bottom-start" style="width:100%;" v-model="inputForm.reimbursementDate"
                type="date" value-format="YYYY-MM-DD" placeholder="选择日期时间" clearable>
              </el-date-picker>
            </el-form-item>
          </el-col> -->
					<el-col :span="12">
						<el-form-item label="当前处理人" prop="currentDisposePerson" :rules="[
							{ required: true, message: '当前处理人不能为空', trigger: 'blur' }
						]">
							<!--                <UserSelect :disabled="status === 'audit' || status === 'taskFormDetail'||method === 'view'" :readonly="true" :limit='1' :modelValue="inputForm.currentDisposePerson" @update:modelValue='(value) => {inputForm.currentDisposePerson = value}'></UserSelect>-->
							<el-input :disabled="status === 'audit' || status === 'taskFormDetail' || method === 'view'"
								:readonly="true" @focus="openUserDia3" v-model="inputForm.currentDisposePersonName"
								placeholder="请选择当前处理人">
								<template #suffix>
									<el-button
										:disabled="status === 'audit' || status === 'taskFormDetail' || method === 'view'"
										:readonly="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="forensics" :rules="[
						]">
							<el-input v-model="inputForm.forensics" maxlength="64" placeholder="请填写其他"
								clearable></el-input>
						</el-form-item>
					</el-col>

					<!--<el-col :span="12">
              <el-form-item label="签字评估师1" prop="signatureEvaluatorFirst"
              >
                <SelectUserTree
                  ref="companyTree"
                  size="medium"
                  :props="{
                  value: 'id',             // ID字段名
                  label: 'name',         // 显示名称
                  children: 'children'    // 子级字段名
                }"
                  :url="`/sys/user/treeUserDataAllOffice?type=2`"
                  :value="inputForm.signatureEvaluatorFirst"
                  :disabled="true"
                  :clearable="true"
                  :accordion="true"
                  @getValue="(value) => {inputForm.signatureEvaluatorFirst=value}"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="签字评估师2" prop="signatureEvaluatorSecond"
              >
                <SelectUserTree
                  ref="companyTree"
                  size="medium"
                  :props="{
                  value: 'id',             // ID字段名
                  label: 'name',         // 显示名称
                  children: 'children'    // 子级字段名
                }"
                  :url="`/sys/user/treeUserDataAllOffice?type=2`"
                  :value="inputForm.signatureEvaluatorSecond"
                  :disabled="true"
                  :clearable="true"
                  :accordion="true"
                  @getValue="(value) => {inputForm.signatureEvaluatorSecond=value}"/>
              </el-form-item>
            </el-col>-->
				</el-row>


			</el-form>
			<!--附件信息 - 开票文件-->
			<UpLoadComponent ref="uploadComponentDetail"></UpLoadComponent>
			<!--附件信息 - 评估报告-->
			<UpLoadComponent ref="uploadComponentReport"></UpLoadComponent>
			<!--附件信息 - 评估说明-->
			<UpLoadComponent ref="uploadComponentExplain"></UpLoadComponent>
			<!--附件信息 - 评估明细表-->
			<!--          <UpLoadComponent ref="uploadComponentDetail"></UpLoadComponent>-->
			<!--附件信息 - 评估操作计算底稿-->
			<UpLoadComponent ref="uploadComponentPapers"></UpLoadComponent>
			<!--附件信息 - 其他-->
			<UpLoadComponent ref="uploadComponentOther"></UpLoadComponent>
			<user-select1 ref="userSelect1" @doSubmit="selectUser1"></user-select1>
			<user-select2 ref="userSelect2" @doSubmit="selectUser2"></user-select2>
			<user-select3 ref="userSelect3" @doSubmit="selectUser3"></user-select3>

		</div>

	</div>
</template>

<script>
import UpLoadComponent from '@/views/common/UpLoadComponent'
import UserSelect from '@/components/userSelect'
import SelectUserTree from '@/views/utils/treeUserSelect'
import RosterSelectForm from '@/views/common/RosterSelectForm'
import ProgramProjectListInfoService from '@/api/program/ProgramProjectListInfoService'
import FinanceInvoiceService from '@/api/finance/invoice/FinanceInvoiceService'
import WangEditor from '@/components/editor/WangEditorNoMenu'
import UserSelect1 from '@/views/utils/UserTreeSelect'
import UserSelect2 from '@/views/utils/UserTreeSelect'
import UserSelect3 from '@/views/utils/UserTreeSelect'
export default {
	props: {
		businessId: {
			type: String,
			default: ''
		},
		formReadOnly: {
			type: Boolean,
			default: false
		},
		status: {
			type: String,
			default: ''
		}
	},
	data() {
		return {
			title: '',
			method: '',
			visible: false,
			loading: false,
			inputForm: {
				id: '',
				remarks: '',
				programId: '',
				year: '',
				programType: '',
				evaluationReportDate: '',
				protocolNum: '',
				waystEvaluation: 0,
				fixedAssetsEvaluation: 0,
				netAssetsEvaluation: 0,
				rentEvaluation: 0,
				forensics: '',
				reportCharges: 0,
				rentType: '',
				currentDisposePerson: '',
				currentDisposePersonName: '',
				isInvoice: '',
				invoiceDate: '',
				actualCharges: 0,
				isContractArchive: '',
				isPapersIntact: '',
				isPapersArchive: '',
				isBa: '',
				opsAmount: 0,
				isOpsReimbursement: '',
				reimbursementAmount: 0,
				unreimbursedAmount: 0,
				reimbursementNum: '',
				reimbursementDate: '',
				procInsId: '',
				processDefinitionId: '',
				status: '',
				programProjectListInfo: {},
				reportFileList: [],
				explainFileList: [],
				detailFileList: [],
				papersFileList: [],
				otherFileList: [],
				auditUserId: '',
				signatureEvaluatorFirst: '',
				signatureEvaluatorFirstName: '',
				signatureEvaluatorSecond: '',
				signatureEvaluatorSecondName: '',
				reportNo: '',
				contractNo: '',
				reportType: '',
				contractStatus: ''

			},
			programId: '',
			supervisorList: [],
			keyWatch: '',
			invoiceDateRule: [],//开票日期校验规则
			invoiceList: [],//发票号展示
		}
	},
	programProjectListInfoService: null,
	financeInvoiceService: null,
	created() {
		this.programProjectListInfoService = new ProgramProjectListInfoService()
		this.financeInvoiceService = new FinanceInvoiceService()
	},
	computed: {
		bus: {
			get() {
				this.$refs.uploadComponentReport.setDividerName('评估报告及评估明细表')
				this.$refs.uploadComponentExplain.setDividerName('评估说明')
				this.$refs.uploadComponentDetail.setDividerName('开票文件')
				this.$refs.uploadComponentPapers.setDividerName('评估操作计算底稿')
				this.$refs.uploadComponentOther.setDividerName('其他')
				return this.businessId
			},
			set(val) {
				this.businessId = val
			}
		}
	},
	watch: {
		'keyWatch': {
			handler(newVal) {
				if (this.bus) {
					if (this.bus !== 'false') {
						this.init('', this.bus)
					}
				} else {
					this.$nextTick(() => {
						this.$refs.inputForm.resetFields()
					})
				}
			}
		},
		'loading': {
			handler(newVal) {
				this.$emit('changeLoading', newVal)
				this.$refs.uploadComponentReport.changeLoading(newVal)
				this.$refs.uploadComponentExplain.changeLoading(newVal)
				this.$refs.uploadComponentDetail.changeLoading(newVal)
				this.$refs.uploadComponentPapers.changeLoading(newVal)
				this.$refs.uploadComponentOther.changeLoading(newVal)
			}
		}
	},
	components: {
		UpLoadComponent,
		RosterSelectForm,
		UserSelect,
		WangEditor,
		SelectUserTree,
		UserSelect1,
		UserSelect2,
		UserSelect3
	},
	methods: {
		getKeyWatch(keyWatch) {
			this.keyWatch = keyWatch
		},
		init(method, id) {
			if (method === 'formReadOnly') {
				method = 'view'
				this.formReadOnly = true
			}
			this.method = method
			this.inputForm = {
				id: '',
				remarks: '',
				programId: '',
				year: '',
				programType: '',
				evaluationReportDate: '',
				protocolNum: '',
				waystEvaluation: 0,
				fixedAssetsEvaluation: 0,
				netAssetsEvaluation: 0,
				rentEvaluation: 0,
				forensics: '',
				reportCharges: 0,
				rentType: '',
				currentDisposePerson: '',
				currentDisposePersonName: '',
				isInvoice: '',
				invoiceDate: '',
				actualCharges: 0,
				isContractArchive: '',
				isPapersIntact: '',
				isPapersArchive: '',
				isBa: '',
				opsAmount: 0,
				isOpsReimbursement: '',
				reimbursementAmount: 0,
				unreimbursedAmount: 0,
				reimbursementNum: '',
				reimbursementDate: '',
				procInsId: '',
				processDefinitionId: '',
				status: '',
				programProjectListInfo: {},
				reportFileList: [],
				explainFileList: [],
				detailFileList: [],
				papersFileList: [],
				otherFileList: [],
				auditUserId: '',
				signatureEvaluatorFirst: '',
				signatureEvaluatorFirstName: '',
				signatureEvaluatorSecond: '',
				signatureEvaluatorSecondName: '',
				reportNo: '',
				contractNo: '',
				contractStatus: ''
			}
			if (this.commonJS.isEmpty(id)) {
				this.inputForm = {
					id: '',
					remarks: '',
					programId: '',
					year: '',
					programType: '',
					evaluationReportDate: '',
					protocolNum: '',
					waystEvaluation: 0,
					fixedAssetsEvaluation: 0,
					netAssetsEvaluation: 0,
					rentEvaluation: 0,
					forensics: '',
					reportCharges: 0,
					rentType: '',
					currentDisposePerson: '',
					currentDisposePersonName: '',
					isInvoice: '',
					invoiceDate: '',
					actualCharges: 0,
					isContractArchive: '',
					isPapersIntact: '',
					isPapersArchive: '',
					isBa: '',
					opsAmount: 0,
					isOpsReimbursement: '',
					reimbursementAmount: 0,
					unreimbursedAmount: 0,
					reimbursementNum: '',
					reimbursementDate: '',
					procInsId: '',
					processDefinitionId: '',
					status: '',
					programProjectListInfo: {},
					reportFileList: [],
					explainFileList: [],
					detailFileList: [],
					papersFileList: [],
					otherFileList: [],
					auditUserId: '',
					signatureEvaluatorFirst: '',
					signatureEvaluatorFirstName: '',
					signatureEvaluatorSecond: '',
					signatureEvaluatorSecondName: '',
					reportNo: '',
					contractNo: '',
					contractStatus: ''
				}
				return
			}
			this.inputForm.id = id
			this.visible = true
			this.loading = false
			this.$nextTick(() => {
				this.$refs.inputForm.resetFields()
				this.loading = true
				this.programProjectListInfoService.findByIdArchive(this.inputForm.id).then((data) => {
					console.log("init中的数据", data)
					this.inputForm = this.recover(this.inputForm, data)
					if (data.programProjectListInfo) {
						if (data.programProjectListInfo.reportType) {
							this.inputForm.reportType = data.programProjectListInfo.reportType
						}
					}
					this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
					if (this.commonJS.isEmpty(this.inputForm.year)) {
						if (this.commonJS.isNotEmpty(this.inputForm.reportNo)) {
							let arr1 = this.inputForm.reportNo.split('【')
							let arr2 = arr1[1].split('】')
							this.inputForm.year = arr2[0]
						}
					}
					//   根据合同归档状态调整isContractArchive
					if (this.commonJS.isEmpty(this.inputForm.isContractArchive)) {
						if (this.inputForm.contractStatus === "5") {
							this.inputForm.isContractArchive = "1"
						} else {
							this.inputForm.isContractArchive = "0"
						}
					}
					this.$refs.uploadComponentReport.clearUpload()
					this.$refs.uploadComponentExplain.clearUpload()
					this.$refs.uploadComponentDetail.clearUpload()
					this.$refs.uploadComponentPapers.clearUpload()
					this.$refs.uploadComponentOther.clearUpload()
					if (this.status === 'audit' || this.status === 'taskFormDetail') {
						method = 'view'
					}
					if (this.commonJS.isEmpty(this.inputForm.reportFileList)) {
						this.inputForm.reportFileList = []
					}
					if (this.commonJS.isEmpty(this.inputForm.explainFileList)) {
						this.inputForm.explainFileList = []
					}
					if (this.commonJS.isEmpty(this.inputForm.detailFileList)) {
						this.inputForm.detailFileList = []
					}
					if (this.commonJS.isEmpty(this.inputForm.papersFileList)) {
						this.inputForm.papersFileList = []
					}
					if (this.commonJS.isEmpty(this.inputForm.otherFileList)) {
						this.inputForm.otherFileList = []
					}
					// 根据项目类型，判断开票日期是否填写
					/*if (this.inputForm.programProjectListInfo.projectMould != 2) {
					  this.invoiceDateRule.push({ required: true, message: '开票日期不能为空', trigger: 'blur' })
					}*/
					// 查询对应的项目发票数据
					this.handleGetInvoiceInfo(this.inputForm.isInvoice)
					this.$refs.uploadComponentReport.newUpload(method, this.inputForm.reportFileList, 'program', 2048, '评估报告及评估明细表')
					this.$refs.uploadComponentExplain.newUpload(method, this.inputForm.explainFileList, 'program', 2048, '评估说明')
					this.$refs.uploadComponentDetail.newUpload(method, this.inputForm.detailFileList, 'program', 2048, '开票文件')
					this.$refs.uploadComponentPapers.newUpload(method, this.inputForm.papersFileList, 'program', 2048, '评估操作计算底稿')
					this.$refs.uploadComponentOther.newUpload(method, this.inputForm.otherFileList, 'program', 2048, '其他')
					this.loading = false
				})
			})
		},
		reapplyForm(callback) {
			this.loading = true
			this.programProjectListInfoService.findByIdArchive(this.inputForm.id).then((data) => {
				if (data.status !== '4') { // 审核状态不是“驳回”，就弹出提示
					this.loading = false
					this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
					throw new Error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
				} else {
					this.startFormTrue(callback)
				}
			})
		},
		saveForm(callback) {
			this.doSubmit('save', callback)
		},
		startForm(callback) {
			this.loading = true
			if (this.commonJS.isNotEmpty(this.inputForm.id)) {
				this.programProjectListInfoService.findByIdArchive(this.inputForm.id).then((data) => {
					if (this.commonJS.isNotEmpty(data.status) && data.status !== '0' && data.status !== '1' && data.status !== '3' && data.status !== '6') { // 审核状态不是“未发起”或“暂存”或“撤回”，就弹出提示
						if ((data.status == "5" || data.status == "7") && !data.invoiceDate) {
							this.startFormTrue(callback)
						} else {
							this.loading = false
							this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
							throw new Error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
						}
					} else {
						this.startFormTrue(callback)
					}
				})
			} else {
				this.startFormTrue(callback)
			}
		},
		startFormTrue(callback) {
			this.doSubmit('start', callback)
		},
		async agreeForm(callback) {
			this.loading = true
			await this.programProjectListInfoService.findByIdArchive(this.inputForm.id).then((data) => {
				if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
					this.loading = false
					this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
					throw new Error()
				} else {
					this.doSubmit('agree', callback)
				}
			})
		},
		// 表单提交
		async doSubmit(status, callback) {
			this.loading = true
			if (await this.$refs.uploadComponentReport.checkProgress()) {
				this.loading = false
				throw new Error()
			}
			if (await this.$refs.uploadComponentExplain.checkProgress()) {
				this.loading = false
				throw new Error()
			}
			if (await this.$refs.uploadComponentDetail.checkProgress()) {
				this.loading = false
				throw new Error()
			}
			if (await this.$refs.uploadComponentPapers.checkProgress()) {
				this.loading = false
				throw new Error()
			}
			if (await this.$refs.uploadComponentOther.checkProgress()) {
				this.loading = false
				throw new Error()
			}
			if (status === 'save') {
				// 暂存
				this.loading = true
				this.inputForm.status = '1'
				this.inputForm.reportFileList = this.$refs.uploadComponentReport.getDataList()
				this.inputForm.explainFileList = this.$refs.uploadComponentExplain.getDataList()
				this.inputForm.detailFileList = this.$refs.uploadComponentDetail.getDataList()
				this.inputForm.papersFileList = this.$refs.uploadComponentPapers.getDataList()
				this.inputForm.otherFileList = this.$refs.uploadComponentOther.getDataList()
				this.programProjectListInfoService.saveFormArchive(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'
			} else if (status === 'agree') {
				// 审核同意
				this.inputForm.status = '5'
				this.inputForm.auditUserId = this.$store.state.user.id
				this.inputForm.auditDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
			}
			this.$refs['inputForm'].validate((valid) => {
				if (valid) {
					if (this.commonJS.isEmpty(this.inputForm.waystEvaluation) &&
						this.commonJS.isEmpty(this.inputForm.fixedAssetsEvaluation) &&
						this.commonJS.isEmpty(this.inputForm.rentEvaluation) &&
						this.commonJS.isEmpty(this.inputForm.netAssetsEvaluation)) {
						this.loading = false
						this.$message.error('废旧物资评估值(万元）、固定资产评估值(万元)、净资产评估值、租金评估，至少要填写一个！')
						throw new Error()
					}
					this.loading = true
					this.inputForm.reportFileList = this.$refs.uploadComponentReport.getDataList()
					this.inputForm.explainFileList = this.$refs.uploadComponentExplain.getDataList()
					this.inputForm.detailFileList = this.$refs.uploadComponentDetail.getDataList()
					this.inputForm.papersFileList = this.$refs.uploadComponentPapers.getDataList()
					this.inputForm.otherFileList = this.$refs.uploadComponentOther.getDataList()
					this.programProjectListInfoService.saveFormArchive(this.inputForm).then((data) => {
						this.inputForm.id = data.businessId
						callback(data.businessTable, data.businessId, this.inputForm)
						this.loading = false
					}).catch(() => {
						this.loading = false
					})
				} else {
					this.loading = false
				}
			})
		},
		async updateStatusById(type, callback) {
			this.loading = true
			if (await this.$refs.uploadComponentReport.checkProgress()) {
				this.loading = false
				throw new Error()
			}
			if (await this.$refs.uploadComponentExplain.checkProgress()) {
				this.loading = false
				throw new Error()
			}
			if (await this.$refs.uploadComponentDetail.checkProgress()) {
				this.loading = false
				throw new Error()
			}
			if (await this.$refs.uploadComponentPapers.checkProgress()) {
				this.loading = false
				throw new Error()
			}
			if (await this.$refs.uploadComponentOther.checkProgress()) {
				this.loading = false
				throw new Error()
			}
			if (type === 'reject' || type === 'reback') {
				await this.programProjectListInfoService.findByIdArchive(this.inputForm.id).then((data) => {
					if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
						this.loading = false
						this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
						throw new Error()
					} else {
						if (type === 'reject') {
							// 驳回
							this.inputForm.status = '4'
						}
						if (type === 'reback') {
							// 撤回
							this.inputForm.status = '3'
						}
						if (type === 'reback' || type === 'reject') {
							let param = { status: this.inputForm.status, id: this.inputForm.id }
							this.programProjectListInfoService.updateStatusByArchiveId(param).then(() => {
								this.loading = false
								callback()
							})
						}
					}
				})
			} else if (type === 'hold') {
				this.programProjectListInfoService.findByIdArchive(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.programProjectListInfoService.updateStatusByArchiveId(param).then(() => {
							this.loading = false
							callback()
						})
					}
				})
			}
		},
		// async updateStatusById (type) {
		//   if (await this.$refs.uploadComponentReport.checkProgress()) {
		//     this.loading = false
		//     throw new Error()
		//   }
		//   if (await this.$refs.uploadComponentExplain.checkProgress()) {
		//     this.loading = false
		//     throw new Error()
		//   }
		//   if (await this.$refs.uploadComponentDetail.checkProgress()) {
		//     this.loading = false
		//     throw new Error()
		//   }
		//   if (await this.$refs.uploadComponentPapers.checkProgress()) {
		//     this.loading = false
		//     throw new Error()
		//   }
		//   if (await this.$refs.uploadComponentOther.checkProgress()) {
		//     this.loading = false
		//     throw new Error()
		//   }
		//   await this.programProjectListInfoService.findByIdArchive(this.inputForm.id).then(({data}) => {
		//     if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
		//       this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
		//       throw new Error()
		//     } else {
		//       // if (type === 'agree') {
		//       //   // 同意
		//       //   this.inputForm.status = '5'
		//       // }
		//       if (type === 'reject') {
		//         // 驳回
		//         this.inputForm.status = '4'
		//       }
		//       if (type === 'reback') {
		//         // 撤回
		//         this.inputForm.status = '3'
		//       }
		//       if (type === 'reback' || type === 'reject') {
		//         let param = {status: this.inputForm.status, id: this.inputForm.id}
		//         this.programProjectListInfoService.updateStatusByArchiveId(param)
		//       }
		//     }
		//   })
		// },
		close() {
			this.$refs.uploadComponentReport.clearUpload()
			this.$refs.uploadComponentExplain.clearUpload()
			this.$refs.uploadComponentDetail.clearUpload()
			this.$refs.uploadComponentPapers.clearUpload()
			this.$refs.uploadComponentOther.clearUpload()
			this.inputForm = {
				id: '',
				remarks: '',
				programId: '',
				year: '',
				programType: '',
				evaluationReportDate: '',
				protocolNum: '',
				waystEvaluation: 0,
				fixedAssetsEvaluation: 0,
				netAssetsEvaluation: 0,
				rentEvaluation: 0,
				forensics: '',
				reportCharges: 0,
				rentType: '',
				currentDisposePerson: '',
				isInvoice: '',
				invoiceDate: '',
				actualCharges: 0,
				isContractArchive: '',
				isPapersIntact: '',
				isPapersArchive: '',
				isBa: '',
				opsAmount: 0,
				isOpsReimbursement: '',
				reimbursementAmount: 0,
				unreimbursedAmount: 0,
				reimbursementNum: '',
				reimbursementDate: '',
				procInsId: '',
				processDefinitionId: '',
				status: '',
				programProjectListInfo: {},
				reportFileList: [],
				explainFileList: [],
				detailFileList: [],
				papersFileList: [],
				otherFileList: [],
				auditUserId: '',
				signatureEvaluatorFirst: '',
				signatureEvaluatorSecond: '',
				reportNo: '',
				contractNo: ''
			}
			this.$refs.inputForm.resetFields()
			this.visible = false
		},
		openUserDia1() {
			this.$refs.userSelect1.init()
		},
		selectUser1(user) {
			console.log(user[0].name)
			this.inputForm.signatureEvaluatorFirstName = user[0].name
			this.inputForm.signatureEvaluatorFirst = user[0].id
		},
		openUserDia2() {
			this.$refs.userSelect2.init()
		},
		selectUser2(user) {
			console.log(user[0].name)
			this.inputForm.signatureEvaluatorSecondName = user[0].name
			this.inputForm.signatureEvaluatorSecond = user[0].id
		},
		openUserDia3() {
			this.$refs.userSelect3.init()
		},
		selectUser3(user) {
			console.log(user[0].name)
			this.inputForm.currentDisposePersonName = user[0].name
			this.inputForm.currentDisposePerson = user[0].id
		},
		// 选择是否开票后查询项目关联的发票信息
		handleGetInvoiceInfo(val) {
			console.log(this.inputForm.programProjectListInfo)
			if (val == 1) {
				if (this.inputForm.programProjectListInfo.id) {
					this.financeInvoiceService.findInvoiceByProjectName({
						programId: this.inputForm.programProjectListInfo.id
					}).then(res => {
						if (res.records && res.records.length > 0) {
							const { records } = res
							this.invoiceList = records.map(item => {
								return item.number
							})

							// ========================
							// 🔥 只新增这一段：取第一条 account>0 的 billingDate
							// ========================
							// 判定：如果 invoiceDate 已经有值，就不执行
							if (!this.inputForm.invoiceDate) {
								const firstItem = records.find(item => item.account > 0);
								this.billingDate = firstItem ? firstItem.billingDate : "";
								this.inputForm.invoiceDate = this.billingDate;
							}
						} else {
							this.invoiceList = ["暂未查询到发票信息"]
							this.billingDate = ""; // 无数据时清空
						}
					})
				}
			}
		}

	}
}
</script>
<style scoped>
/deep/ .w-e-text-container {
	z-index: 1 !important;
}

/deep/ .wtext {
	height: 200px
}

/deep/ .el-input-number .el-input__inner {
	text-align: left;
}

.el-divider__text {
	font-size: 16px;
	font-weight: bold;
}
</style>
