<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
  <div>
	  <el-dialog
		  :title="title"
		  :close-on-click-modal="false"
		  draggable
		  width="1300px"
		  @close="close"
		  @keyup.enter.native=""
		  v-model="visible">
		  <el-tabs v-model="activeName" type="border-card" @tab-click="tabHandleClick">
			  <el-tab-pane label="项目登记详情" name="programDetail">
				  <el-form size="large" :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="method === 'view'"
						   label-width="170px" @submit.native.prevent>
					  <el-row  :gutter="15">
						  <el-col :span="24">
							  <el-form-item label="合同情况:" prop="contractStatus"
											:rules="[
							   {required: true, message:'请选择合同情况', trigger:'blur'}
                 ]">
								  <el-radio-group v-model="inputForm.contractStatus" class="ml-4">
									  <el-radio label="1" size="large">有合同</el-radio> <el-radio label="0" size="large">无合同</el-radio>
								  </el-radio-group>
							  </el-form-item>
						  </el-col>
						  <el-row  :gutter="15" v-show="inputForm.contractStatus === '1'">
							  <el-col :span="24" >
								  <el-divider content-position="left"><i class="el-icon-document"></i> 选择合同</el-divider>
							  </el-col>
							  <el-col :span="12">
								  <el-form-item label="选择合同" prop="contractName"
												:rules="[
                          {required: true, message:'合同不能为空', trigger:'blur'},
                          {required: true, message:'合同不能为空', trigger:'change'}
                 ]">
									  <el-input size="large" :readonly="true" @focus="openContractForm()" v-model="inputForm.contractName" 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="amount"
												:rules="[
                 ]">
									  <!--              <el-input v-model="inputForm.amount" placeholder="请填写合同金额"></el-input>-->
									  <el-input-number
										  :disabled="true"
										  v-model="inputForm.amount"
										  controls-position="right"
										  :controls="false"
										  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="primaryLinkman"
												:rules="[
                 ]">
									  <el-input :disabled="true" v-model="inputForm.primaryLinkman" placeholder="请填写委托方"></el-input>
								  </el-form-item>
							  </el-col>
							  <el-col :span="12">
								  <el-form-item label="合同类型(大类)" prop="contractTypeFirst"
												:rules="[
                 ]">
									  <el-input :disabled="true" v-model="inputForm.contractTypeFirst" placeholder="请填写合同类型(大类)"></el-input>
								  </el-form-item>
							  </el-col>
							  <el-col :span="12">
								  <el-form-item label="合同类型(小类)" prop="contractType"
												:rules="[
                 ]">
									  <el-input :disabled="true" v-model="inputForm.contractType" placeholder="请填写合同类型(小类)"></el-input>
								  </el-form-item>
							  </el-col>
						  </el-row>

					  </el-row>
					  <el-divider content-position="left"><i class="el-icon-document"></i> 项目基本情况信息</el-divider>
					  <el-row  :gutter="15">
						  <el-col :span="12">
							  <el-form-item label="项目名称" prop="name"
											:rules="[
                          {required: true, message:'项目名称不能为空', trigger:'blur'}
                 ]">
								  <el-input maxlength="64" v-model="inputForm.name" placeholder="请输入项目名称" clearable></el-input>
							  </el-form-item>
						  </el-col>
						  <el-col :span="12">
							  <el-form-item label="项目所在地" prop="projectPlace"
											:rules="[
                          {required: true, message:'项目所在地不能为空', trigger:'change'}
                 ]">
								  <SelectTree
									  ref="areaTree"
									  :props="{
                      value: 'id',             // ID字段名
                      label: 'name',         // 显示名称
                      children: 'children'    // 子级字段名
                    }"
									  url="/system-server/sys/area/treeData"
									  :value="inputForm.projectPlace"
									  :clearable="true"
									  size="large"
									  :accordion="true"
									  @getValue="(value) => {inputForm.projectPlace=value}"
								  />
							  </el-form-item>
						  </el-col>
						  <el-col :span="12">
							  <el-form-item label="所在省份" prop="provience"
											:rules="[
                 ]">
								  <el-input :disabled="true" v-model="provience" placeholder="请输入所在省份" clearable></el-input>
							  </el-form-item>
						  </el-col>
						  <el-col :span="12">
							  <el-form-item label="所在地级市" prop="city"
											:rules="[
                 ]">
								  <el-input :disabled="true" v-model="city" placeholder="请输入所在地级市" clearable></el-input>
							  </el-form-item>
						  </el-col>
						  <el-col :span="12">
							  <el-form-item label="所在区县" prop="con"
											:rules="[
                 ]">
								  <el-input :disabled="true" v-model="con" placeholder="请输入所在区县" clearable></el-input>
							  </el-form-item>
						  </el-col>
						  <el-col :span="12">
							  <el-form-item label="建设地点" prop="buildPlace"
											:rules="[
                 ]">
								  <el-input  v-model="inputForm.buildPlace" placeholder="请输入建设地点" clearable></el-input>
							  </el-form-item>
						  </el-col>
						  <el-col :span="12">
							  <el-form-item label="项目负责人" prop="projectLeader"
											:rules="[
                          {required: true, message:'项目负责人不能为空', trigger:'change'}
                 ]">
								  <SelectUserTree
									  ref="companyTree"
									  size="large"
									  :props="{
                  value: 'id',             // ID字段名
                  label: 'name',         // 显示名称
                  children: 'children'    // 子级字段名
                }"
									  :url="`/system-server/sys/user/treeUserDataJyOffice?type=2`"
									  :value="inputForm.projectLeader"
									  :clearable="true"
									  :accordion="true"
									  @getValue="(value) => {inputForm.projectLeader=value}"/>
							  </el-form-item>
						  </el-col>
						  <el-col :span="12">
							  <el-form-item label="创建人" prop="createByName"
											:rules="[
                   ]">
								  <el-input :disabled="true" v-model="inputForm.createByName" placeholder="请填写创建人" clearable></el-input>
							  </el-form-item>
						  </el-col>
						  <el-col :span="12">
							  <el-form-item label="创建时间" prop="createDate"
											:rules="[
                   ]">
								  <el-input :disabled="true" v-model="inputForm.createDate" placeholder="请填写创建时间" clearable></el-input>
							  </el-form-item>
						  </el-col>

						  <el-col :span="24">
							  <el-form-item label="工程概况" prop="projectOverview"
											:rules="[
                 ]">
								  <el-input type="textarea" v-model="inputForm.projectOverview" maxlength="500" placeholder="请输入工程概况" show-word-limit></el-input>
							  </el-form-item>
						  </el-col>
						  <el-col :span="24">
							  <el-form-item label="特殊要求" prop="special"
											:rules="[
                 ]">
								  <el-input type="textarea" v-model="inputForm.special" maxlength="500" placeholder="请输入特殊要求" show-word-limit></el-input>
							  </el-form-item>
						  </el-col>
					  </el-row>
					  <el-divider content-position="left"><i class="el-icon-document"></i>
						  <span><span style="color: red;border-top: 20px">*</span>委托方联系人信息</span>
						  <el-button style="margin-left: 20px" type="primary" :disabled="this.inputForm.contractStatus === '1'" size="default" @click="openContactForm()" plain>
							  新增
						  </el-button>
					  </el-divider>
					  <el-row  :gutter="15" >
						  <el-col :span="24">
							  <vxe-table
								  border
								  show-overflow
								  ref="clientTable"
								  class="vxe-table-element"
								  :data="inputForm.clientList"
								  style="margin-left: 5em"
								  :key="clientTableKey"
								  :edit-rules="validRulesClient"
								  highlight-current-row
								  :edit-config="{trigger: 'click', mode: 'row', showStatus: true, autoClear: true, icon: '#'}"
							  >
								  <vxe-table-column field="clientName" title="联系人" :edit-render="{}"  align="center">
									  <template v-slot:edit="scope">
										  <el-input :disabled="true" v-model="scope.row.clientName" ></el-input>
									  </template>
								  </vxe-table-column>
								  <!--					<vxe-table-column  align="center" field="clientType" title="人员类型" :edit-render="{name: '$select', options: clientTypes}">-->
								  <!--						<template v-slot:edit="scope">-->
								  <!--							<vxe-select :disabled="status === 'audit' || status === 'taskFormDetail'" v-model="scope.row.clientType"  transfer>-->
								  <!--								<vxe-option-->
								  <!--									v-for="item in clientTypes"-->
								  <!--									:key="item.value"-->
								  <!--									:value="item.value"-->
								  <!--									:label="item.label">-->
								  <!--								</vxe-option>-->
								  <!--							</vxe-select>-->
								  <!--						</template>-->
								  <!--					</vxe-table-column>-->
								  <vxe-table-column  align="center" field="linkPhone" title="联系方式1" :edit-render="{}">
									  <template v-slot:edit="scope">
										  <el-input :disabled="true" v-model="scope.row.linkPhone" ></el-input>
									  </template>
								  </vxe-table-column>
								  <vxe-table-column  align="center" field="linkMobile" title="联系方式2" :edit-render="{}">
									  <template v-slot:edit="scope">
										  <el-input :disabled="true" v-model="scope.row.linkMobile" ></el-input>
									  </template>
								  </vxe-table-column>
								  <vxe-table-column  align="center" field="position" title="职位" :edit-render="{}">
									  <template v-slot:edit="scope">
										  <el-input :disabled="true" v-model="scope.row.position" ></el-input>
									  </template>
								  </vxe-table-column>
								  <vxe-table-column  align="center" title="操作" width="100">
									  <template v-slot="scope">
										  <el-button size="large" type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'client')">删除</el-button>
									  </template>
								  </vxe-table-column>
							  </vxe-table>
						  </el-col>
					  </el-row>
					  <el-row  :gutter="15" v-show=" method==='view' ">
						  <el-col :span="24">
							  <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-footer
										  show-overflow
										  :footer-method="footerMethod"
										  ref="memberTable"
										  class="vxe-table-element"
										  :key="memberKey"
										  :data="inputForm.members"
										  style="margin-left: 5em"
										  @cell-click=""
										  :edit-rules="validRulesMember"
										  @edit-closed=""
										  highlight-current-row
										  :edit-config="{trigger: 'click', mode: 'row', showStatus: false, autoClear:  status === 'audit' || status === 'taskFormDetail' ? true : false, icon: '#'}"
									  >
										  <vxe-table-column min-width="218" align="center" field="name" title="姓名"></vxe-table-column>
										  <vxe-table-column min-width="218" align="center" field="officeName" title="部门"></vxe-table-column>
										  <vxe-table-column min-width="218" align="center" field="roleName" title="角色"></vxe-table-column>
										  <vxe-table-column min-width="218" align="center" field="mobile" title="手机号"></vxe-table-column>
										  <vxe-table-column min-width="218" align="center" field="status" title="状态">
											  <template #default="scope">
												  <span v-if="scope.row.status === '0'" style="color: #67C23A">正常</span>
												  <span v-else>移除</span>
											  </template>
										  </vxe-table-column>
									  </vxe-table>
								  </el-col>
							  </el-row>
						  </el-col>
					  </el-row>
				  </el-form>
				  <!--        附件-->
				  <UpLoadComponent ref="uploadComponent"></UpLoadComponent>
			  </el-tab-pane>
			  <el-tab-pane label="一级校审" name="firstAudit">
				  <ProjectAuditForm ref="projectThreeAuditForm" :formReadOnly="true"></ProjectAuditForm>
			  </el-tab-pane>
			  <el-tab-pane label="二级校审" name="secondAudit" >
				  <ProjectAuditForm ref="secondAudit2" :formReadOnly="true"></ProjectAuditForm>
			  </el-tab-pane>
			  <el-tab-pane label="三级校审" name="thirdAudit" >
				  <ProjectAuditForm ref="thirdAudit3" :formReadOnly="true"></ProjectAuditForm>
			  </el-tab-pane>
			  <el-tab-pane label="报告签发" name="reportIssuance">
				  <SignetAddForm ref="signetAddForm" :formReadOnly="true"></SignetAddForm>
			  </el-tab-pane>
			  <el-tab-pane label="外审" name="outInstance">
				  <OutInstanceForm ref="outInstanceForm" :formReadOnly="true"></OutInstanceForm>
			  </el-tab-pane>
			  <el-tab-pane label="报批签发" name="reportsSubmit">
				  <ReportsInstanceForm ref="reportsInstanceForm" :formReadOnly="true"></ReportsInstanceForm>
			  </el-tab-pane>
			  <el-tab-pane label="归档" name="archive">
				  <ProjectArchiveForm ref="projectArchiveForm" :formReadOnly="true"></ProjectArchiveForm>
			  </el-tab-pane>
			  <el-tab-pane label="环评资质" name="eia" >
					  <ProjectEiaForm ref="projectEiaForm" :formReadOnly="true"></ProjectEiaForm>
			  </el-tab-pane>
		  </el-tabs>
		  <template #footer>
			<span class="dialog-footer">
			  <el-button  @click="close()" icon="el-icon-circle-close">关闭</el-button>
			  <el-button  type="primary" v-if="method != 'view'" @click="doSubmit()" icon="el-icon-circle-check" v-noMoreClick>确定</el-button>
			</span>
		  </template>
	  </el-dialog>

      <ContractForm  ref="contractForm" @getContract="getContract"></ContractForm>
      <ContactForm  ref="contactForm" @getContract="getContact"></ContactForm>

  </div>
</template>

<script>
	import ContractForm from './ContractForm'
	import ContactForm from './ContractForm'
	import SelectTree from '@/components/treeSelect/treeSelect.vue'
	import areaService from "@/api/sys/areaService";
	import SelectUserTree from '@/views/utils/treeUserSelect'
	import ProjectInfoService from "@/api/jy/ProjectInfoService";
	import UpLoadComponent from '@/views/common/UpLoadComponent'
	import userService from '@/api/sys/UserService'
	import ProjectAuditForm from './ProjectAuditForm'
	import SignetAddForm from '@/views/materialManagement/userSeal/SignetAddForm'
	import OutInstanceForm from './OutInstanceForm'
	import ReportsInstanceForm from './ReportsInstanceForm'
	import ProjectArchiveForm from './ProjectArchiveForm'
	import ProjectEiaForm from './ProjectEiaForm'
  export default {
    props: {
      businessId: {
        type: String,
        default: ''
      },
      formReadOnly: {
        type: Boolean,
        default: false
      },
      status: {
        type: String,
        default: ''
      }
    },
    data () {
      return {
		  title: '',
		  method: '',
		  visible: false,
		  loading: false,
		  typeDictList: [],
		  activeName: 'programDetail',
		  showReportIssuance:false,
		  inputForm: {
			  id: '', // 主键值（新增不传，修改必传）
			  no: '', // 编号（新增不传，修改必传）
			  contractId: '', // 合同id
			  contractName: '', // 合同名称
			  client: '', // 委托方
			  primaryLinkman: '', // 委托方名称
			  amount: '', // 合同金额
			  contractType: '', // 合同类别
			  name: '', // 项目名称
			  projectPlace: '', // 项目所在地
			  status: '', // 状态
			  procInsId: '', // 流程id
			  processDefinitionId: '', // 流程信息
			  members: [], // 成员列表
			  files: [], // 附件信息
			  contractStatus: '',//合同情况
			  contractType:'',//合同类型(小类)
			  contractTypeFirst:'', //合同类型(大类)
			  buildPlace:'', // 建设地点
			  createByName:this.$store.state.user.name, //创建人
			  createDate:this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss'), //创建时间
			  projectOverview:'', //工程概况
			  special:'', //特殊要求
			  projectLeader:'', //项目负责人
			  clientList:[], //委托方联系人
			  files: [], // 附件信息
		  },
		  clientTypes: [
			  {value: 1, label: '委托人'},
			  {value: 2, label: '项目对接人'}
		  ],
		  auditId1: '',
		  auditId2: '',
		  auditId3: '',
		  archiveId: '',
		  provience:'',
		  city:'',
		  con:'',
		  sealId:'',
		  outInstanceId:'',
		  reportsSubmitId:'',
		  archiveId:'',
		  eiaId:''
      }
    },
	  ProjectInfoService:null,
    created () {
		this.projectInfoService=new ProjectInfoService()
		this.getLocation()
    },
    computed: {
      bus: {
        get () {
          this.$refs.uploadComponent.setDividerName('附件')
          return this.businessId
        },
        set (val) {
          this.businessId = val
        }
      }
    },
    components: {
		ContractForm,
		ContactForm,
		SelectTree,
		SelectUserTree,
		UpLoadComponent,
		ProjectAuditForm,
		SignetAddForm,
		OutInstanceForm,
		ReportsInstanceForm,
		ProjectArchiveForm,
		ProjectEiaForm
    },
    methods: {
		getKeyWatch (keyWatch) {
			this.keyWatch = keyWatch
		},
		openContractForm () {
			if (!this.commonJS.isEmpty(this.inputForm.contractId)) {
				this.$refs.contractForm.init(this.inputForm.contractId)
			} else {
				this.$refs.contractForm.init()
			}
		},
		getContract (row) {
			console.log('row',row)
			let _this = this
			// eslint-disable-next-line no-unused-vars
			let _list = row
			let _num = 0
			if (this.commonJS.isEmpty(this.inputForm.clientList)) {
				this.inputForm.clientList = []
			}
			const waitForEach = function () {
				return new Promise(function (resolve, reject) {
					if (_this.commonJS.isEmpty(_this.inputForm.clientList)) {
						resolve()
					} else {
						_this.inputForm.clientList.forEach((client, index) => {
							if (_this.inputForm.customerNo === client.no) {
								_this.$refs.contactTable.remove(client)
								_this.inputForm.clientList.splice(index, 1)
							}
						})
						setTimeout(() => {
							resolve()
						}, 400)
					}
				})
			}
			waitForEach().then(() => {
				this.inputForm.contractId = row.id // 合同id
				this.inputForm.contractName = row.name // 合同名称
				this.inputForm.clientName = row.clientName // 委托方名称
				this.inputForm.contractType = row.contractType // 合同类型(小类)
				this.inputForm.contractTypeFirst = row.contractTypeFirst // 合同类型(大类)
				const wait = function () {
					return new Promise(function (resolve, reject) {
						_this.inputForm.clientList.forEach(client => {
							if (_list.no === client.no) {
								_num = 1
							}
						})
						setTimeout(() => {
							resolve()
						}, 100)
					})
				}
				wait().then(() => {
					if (_num === 0) {
						this.inputForm.clientList.push({ name: row.linkmanList[0].name,id: row.linkmanList[0].id})
						this.$refs.clientTable.insertAt({name: row.linkmanList[0].name,id: row.linkmanList[0].id,linkPhone:row.linkmanList[0].linkPhone,linkMobile:row.linkmanList[0].linkMobile,position:row.linkmanList[0].position})
						this.clientTableKey = Math.random()
					}
				})
			})
			this.$forceUpdate()
			console.log('list',this.inputForm.clientList)
		},
		//获取省市县
		getLocation(){
			var locationId=this.inputForm.projectPlace
			console.log('id',locationId)
			areaService.getParent(locationId).then((data)=>{
				if (!data){
					return
				}
				console.log('da',data)
				this.provience=data[2]
				this.city=data[3]
				this.con=data[4]

			})
		},
		//委托方联系人
		openContactForm(){
			if (this.commonJS.isEmpty(this.inputForm.clientList)) {
				this.$refs.contractForm.init()
			}
		},
		//添加委托方联系人
		getContact(row){
			this.inputForm.clientList.push({name: row.linkmanList[0].name,id: row.linkmanList[0].id})
			this.$refs.clientTable.insertAt({name: row.linkmanList[0].name,id: row.linkmanList[0].id,linkPhone:row.linkmanList[0].linkPhone,linkMobile:row.linkmanList[0].linkMobile,position:row.linkmanList[0].position})
			this.clientTableKey = Math.random()
		},
		// 删除
		removeEvent (row, rowIndex, type) {
			if (type === 'member') {
				this.$refs.memberTable.remove(row)
				this.inputForm.members.splice(rowIndex, 1)
			}
			if (type === 'client') {
				this.$refs.clientTable.remove(row)
				this.inputForm.clientList.splice(rowIndex, 1)
			}
		},
		init (method, id,auditId1, auditId2, auditId3,sealId,outInstanceId,reportsSubmitId,archiveId,eiaId) {
			console.log('this.reportsSubmitId',reportsSubmitId)
			this.auditIdfirst = auditId1
			this.auditIdsecond = auditId2
			this.auditIdthird = auditId3
			this.outInstanceId=outInstanceId
			this.sealId=sealId
			this.reportsSubmitId=reportsSubmitId
			this.archiveId=archiveId
			this.eiaId=eiaId
			this.method = method
			console.log('eiaId', eiaId)
			this.inputForm = {
				id: '', // 主键值（新增不传，修改必传）
				no: '', // 编号（新增不传，修改必传）
				contractId: '', // 合同id
				contractName: '', // 合同名称
				client: '', // 委托方
				primaryLinkman: '', // 委托方名称
				amount: '', // 合同金额
				contractType: '', // 合同类别
				name: '', // 项目名称
				projectPlace: '', // 项目所在地
				status: '', // 状态
				procInsId: '', // 流程id
				processDefinitionId: '', // 流程信息
				members: [], // 成员列表
				files: [], // 附件信息
				contractStatus: '',//合同情况
				contractType:'',//合同类型(小类)
				contractTypeFirst:'', //合同类型(大类)
				buildPlace:'', // 建设地点
				createByName:this.$store.state.user.name, //创建人
				createDate: this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss'), //创建时间
				projectOverview:'', //工程概况
				special:'', //特殊要求
				projectLeader:'', //项目负责人
				clientList:[], //委托方联系人
				files: [], // 附件信息
			}
			this.inputForm.id = id
			if (method === 'add') {
				// this.inputForm.id = 'add'
				this.title = `新建项目`
			} else if (method === 'edit') {
				this.title = '修改项目'
			} else if (method === 'view') {
				this.title = '查看项目详情'
			}
			this.visible = true
			this.loading = false
			this.$nextTick(() => {
				this.$refs.inputForm.resetFields()
				this.loading = true
				this.$refs.uploadComponent.clearUpload()
				// this.$refs.archiveFile.clearUpload()
				if (this.commonJS.isNotEmpty(this.inputForm.id)) {
					this.projectInfoService.findById(this.inputForm.id).then((data) => {
						this.inputForm = this.recover(this.inputForm, data)
						this.inputForm.members=data.projectMembers
						this.inputForm.clientList=data.clientList
						this.inputForm.createByName=data.createById
						this.inputForm.clientList=data.clientList
						this.inputForm.members=data.projectMembers
						this.inputForm.amount=data.contractAmount
						if (this.commonJS.isEmpty(this.inputForm.members)) {
							this.inputForm.cwProjectMembersDTOList = []
						} else {
							this.inputForm.members.forEach((member, index) => {
								userService.queryDetailById(member.userId).then((data) => {
									member.name = this.commonJS.isEmpty(data.name) ? '' : data.name
									member.mobile = this.commonJS.isEmpty(data.mobile) ? '' : data.mobile
									member.officeName = this.commonJS.isEmpty(data.officeDTO) ? '' : this.commonJS.isEmpty(data.officeDTO.name) ? '' : data.officeDTO.name
									member.roleName = this.commonJS.isEmpty(data.roleList) ? '' : data.roleList.map(role => { return this.commonJS.isEmpty(role.name) ? '' : role.name }).join(',')
									this.tableKeyMembers = Math.random()
								})
							})
						}
						this.getLocation()
						// this.inputForm.cwWorkClientContactDTOList=data.cwWorkClientContactDTOList
						console.log('data', data)
						if (this.commonJS.isEmpty(this.inputForm.createDate)) {
							this.inputForm.createDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
						}
						if (this.formReadOnly) {
							method = 'view'
						}
						this.$refs.uploadComponent.newUpload('view', this.inputForm.files, 'jyProject', null, null, null, null, null)
						// this.$refs.archiveFile.newUpload('view', [], 'cwWorkContract', null, null, null, null, false)
						this.loading = false
					})
				}
			})
		},
		reapplyForm (callback) {
			this.loading = true
			this.programProjectListInfoService.queryById(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.projectInfoService.queryById(this.inputForm.id).then((data) => {
					if (this.commonJS.isNotEmpty(data.status) && data.status !== '0' && data.status !== '1' && data.status !== '3') { // 审核状态不是“未发起”或“暂存”或“撤回”，就弹出提示
						this.loading = false
						this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
						throw new Error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
					} else {
						this.startFormTrue(callback)
					}
				})
			} else {
				this.startFormTrue(callback)
			}
		},
		startFormTrue (callback) {
			this.doSubmit('startAndHold', callback)
		},
		agreeForm (callback) {
			this.doSubmit('agree', callback)
		},
		// 表单提交
		doSubmit (status, callback) {
			this.loading = true
			if (status === 'save') {
				// 暂存
				this.inputForm.status = '1'
				this.loading = true
				if (this.$refs.uploadComponent.checkProgress()) {
					this.loading = false
					return
				}
				this.inputForm.files = this.$refs.uploadComponent.getDataList()
				this.projectInfoService.saveForm(this.inputForm).then((data) => {
					callback(data.businessTable, data.businessId, this.inputForm)
					this.loading = false
				}).catch(() => {
					this.loading = false
				})
				return
			} else if (status === 'startAndHold') {
				// 送审  待审核
				this.inputForm.status = '2'
			} else if (status === 'agree') {
				// 审核同意
				this.inputForm.status = '5'
			}
			if (this.commonJS.isEmpty(this.inputForm.clientList)) {
				this.loading = false
				this.$message.error('填写一条委托方联系人信息')
				return
			}
			if (this.commonJS.isEmpty(this.inputForm.contractStatus)) {
				this.loading = false
				this.$message.error('请选择合同情况')
				return
			}
			if (this.inputForm.contractStatus === '1' && this.inputForm.contractName === '') {
				this.loading = false
				this.$message.error('请选择合同')
				return
			}
			if (this.commonJS.isEmpty(this.inputForm.projectPlace)) {
				this.loading = false
				this.$message.error('请选择项目所在地')
				return
			}
			if (this.commonJS.isEmpty(this.inputForm.projectLeader)) {
				this.loading = false
				this.$message.error('请选择项目负责人')
				return
			}
			this.$refs['inputForm'].validate((valid) => {
				if (valid) {
					this.loading = true
					if (this.$refs.uploadComponent.checkProgress()) {
						this.loading = false
						return
					}
					console.log('this.inputForm', this.inputForm)
					this.inputForm.files = this.$refs.uploadComponent.getDataList()
					JSON
					this.projectInfoService.saveForm(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.uploadComponent.checkProgress()) {
				this.loading = false
				throw new Error()
			} else {
				if (type === 'reject' || type === 'reback') {
					this.programProjectListInfoService.queryById(this.inputForm.id).then((data) => {
						if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
							this.loading = false
							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 === 'reject' || type === 'reback') {
								let param = {status: this.inputForm.status, id: this.inputForm.id}
								this.programProjectListInfoService.updateStatusById(param).then(() => {
									this.loading = false
									callback()
								})
							}
						}
					})
				} else if (type === 'hold') {
					this.programProjectListInfoService.queryById(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.updateStatusById(param).then(() => {
								this.loading = false
								callback()
							})
						}
					})
				}
			}
		},
		close () {
			this.inputForm = {
				id: '', // 主键值（新增不传，修改必传）
				no: '', // 编号（新增不传，修改必传）
				contractId: '', // 合同id
				contractName: '', // 合同名称
				client: '', // 委托方
				clientName: '', // 委托方名称
				amount: 0, // 合同金额
				contractType: '', // 合同类型
				name: '', // 项目名称
				projectType: '', // 项目类别
				projectMould: '', // 项目类型
				company: '', // 执业机构
				propertyHolder: '', // 产权持有人
				propertyHolderName: '', // 产权持有人姓名
				location: '', // 项目所在地
				isFirst: '', // 是否首次承建
				yearNum: '', // 承做年数
				checkYear: '', // 评估费用核算年度
				projectManager: '', // 项目经理
				projectManagerName: '', // 项目经理名称
				reportType: '', // 报告类型
				industry: '', // 所属行业
				enterpriseType: '', // 企业类型
				riskLevel: '', // 风险等级
				generateReportNumber: '', // 是否生成报告号
				projectSource: '', // 项目来源
				estimate: 0, // 预估收入（元）
				planEndTime: '', // 计划完成时间
				useNum: 0, // 计划使用人数
				appointment: 0, // 约定书（份）
				workHours: 0, // 预算工时
				remarks: '', // 备注
				assessmentEnterprise: '', // 被评估企业
				assessmentEnterpriseName: '', // 被评估企业名称
				linkNum: '', // 联系人及电话
				relationship: '', // 委托人与被评估单位关系
				assessmentWay: '', // 评估方式
				assessmentObjective: '', // 评估目的
				assessmentDate: '', // 评估基准日
				num: '', // 评估服务收费总额
				projectDevelopment: '', // 项目开发人
				delegateProjectType: '', // 项目类型
				assessmentObject: '', // 评估对象
				assessmentRange: '', // 评估范围
				workBeginAndEndDate: [], // 预计现场工作起止时间
				workBeginDate: '', // 预计现场工作开始时间
				workEndDate: '', // 预计现场工作结束时间
				reportingDate: '', // 预计出报告日期
				isHave: '', // 本所是否具备承接胜任能力
				isInfluence: '', // 是否影响本所乘坐人员独立性
				mode: '', // 项目承接方式
				status: '', // 状态
				procInsId: '', // 流程id
				processDefinitionId: '', // 流程信息
				links: [], // 联系人列表
				members: [], // 成员列表
				files: [], // 附件信息
			}
			this.activeName = 'programDetail'
			this.$refs.uploadComponent.clearUpload()
			this.$refs.inputForm.resetFields()
			this.visible = false
		},
		uploadVideoProcess (event, file, fileList) {
			this.progressFlag = true // 显示进度条
			this.loadProgress = parseInt(event.percent) // 动态获取文件上传进度
			if (this.loadProgress >= 100) {
				this.loadProgress = 100
				setTimeout(() => { this.progressFlag = false }, 1000) // 一秒后关闭进度条
			}
		},
		tabHandleClick (event) {
			let paneName = event.props.name
			if (paneName === 'firstAudit') {
				if (this.commonJS.isNotEmpty(this.auditIdfirst)) {
					this.$refs.projectThreeAuditForm.init('view', this.auditIdfirst, '一级校审')
				}
			}
			if (paneName === 'secondAudit') {
				if (this.commonJS.isNotEmpty(this.auditIdsecond)) {
					this.$refs.secondAudit2.init('view', this.auditIdsecond, '二级校审')
				}
			}
			if (paneName === 'thirdAudit') {
				if (this.commonJS.isNotEmpty(this.auditIdthird)) {
					this.$refs.thirdAudit3.init('view', this.auditIdthird, '三级校审')
				}
			}
			if (paneName === 'reportIssuance') {
				if (this.commonJS.isNotEmpty(this.sealId)) {
					console.log('建立了')
					this.$refs.signetAddForm.init('view', this.sealId)
				}
			}
			if (paneName === 'outInstance') {
				if (this.commonJS.isNotEmpty(this.outInstanceId)) {
					this.$refs.outInstanceForm.init('view', this.outInstanceId)
				}
			}
			if (paneName === 'reportsSubmit') {
				console.log('this.reportsSubmitId',this.reportsSubmitId)
				if (this.commonJS.isNotEmpty(this.reportsSubmitId)) {

					this.$refs.reportsInstanceForm.init('view',this.reportsSubmitId)
				}
			}
			if (paneName === 'archive') {
				if (this.commonJS.isNotEmpty(this.archiveId)) {
					this.$refs.projectArchiveForm.init('view', this.archiveId)
				}
			}
			if (paneName === 'eia') {
				if (this.commonJS.isNotEmpty(this.eiaId)) {
					this.$refs.projectEiaForm.init('view', this.eiaId)
				}
			}
		}
    }
  }
</script>
<style lang="scss">
  .el-input-number .el-input__inner {
    text-align: left;
  }
  .el-divider__text {
    font-size: 16px;
    font-weight: bold;
  }

</style>
