<template>
	<div class="page" >
		<el-form :inline="true" class="query-form" ref="searchForm" :model="searchForm" @keyup.enter.native="refreshList()" @submit.native.prevent>
			<!-- 搜索框-->
			<el-form-item label="项目名称" prop="name">
				<el-input v-model="searchForm.name" placeholder="请输入项目名称" clearable></el-input>
			</el-form-item>
			<el-form-item label="项目编号" prop="no">
				<el-input v-model="searchForm.no" placeholder="请输入项目编号" clearable></el-input>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="登记人" prop="createById">
				<UserSelect :limit='1' :readonly="true" :modelValue="searchForm.createById" @update:modelValue='(value) => {searchForm.createById = value}'></UserSelect>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="项目负责人" prop="projectLeader">
				<UserSelect :limit='1' :readonly="true" :modelValue="searchForm.projectLeader" @update:modelValue='(value) => {searchForm.projectLeader = value}'></UserSelect>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="合同名称" prop="contractName">
				<el-input v-model="searchForm.contractName" placeholder="请输入合同名称" clearable></el-input>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="委托方" prop="primaryLinkman">
				<el-input v-model="searchForm.primaryLinkman" placeholder="请输入委托方" clearable></el-input>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="创建时间" prop="createDates">
				<el-date-picker
					placement="bottom-start"
					format="YYYY-MM-DD HH:mm:ss"
					value-format="YYYY-MM-DD HH:mm:ss"
					v-model="searchForm.createDates"
					type="datetimerange"
					range-separator="至"
					start-placeholder="开始日期"
					end-placeholder="结束日期">
				</el-date-picker>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="状态" prop="status">
				<el-select v-model="searchForm.status" placeholder="请选择" style="width:100%;" clearable>
					<el-option
						v-for="item in $dictUtils.getDictList('program_project_list_info_status')"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="一级校审状态" prop="firstInstanceStatus">
				<el-select v-model="searchForm.firstInstanceStatus" placeholder="请选择" style="width:100%;" clearable>
					<el-option
						v-for="item in $dictUtils.getDictList('program_project_list_info_status')"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="二级校审状态" prop="secondInstanceStatus">
				<el-select v-model="searchForm.secondInstanceStatus" placeholder="请选择" style="width:100%;" clearable>
					<el-option
						v-for="item in $dictUtils.getDictList('program_project_list_info_status')"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="三级校审状态" prop="thirdInstanceStatus">
				<el-select v-model="searchForm.thirdInstanceStatus" placeholder="请选择" style="width:100%;" clearable>
					<el-option
						v-for="item in $dictUtils.getDictList('program_project_list_info_status')"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="报告签发" prop="reportIssuance">
				<el-select v-model="searchForm.reportIssuance" placeholder="请选择" style="width:100%;" clearable>
					<el-option
						v-for="item in $dictUtils.getDictList('program_project_list_info_status')"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="外审" prop="outInstance">
				<el-select v-model="searchForm.outInstance" placeholder="请选择" style="width:100%;" clearable>
					<el-option
						v-for="item in $dictUtils.getDictList('program_project_list_info_status')"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="报批签发" prop="reportsSubmit">
				<el-select v-model="searchForm.reportsSubmit" placeholder="请选择" style="width:100%;" clearable>
					<el-option
						v-for="item in $dictUtils.getDictList('program_project_list_info_status')"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="归档状态" prop="reviewStatus">
				<el-select v-model="searchForm.reviewStatus" placeholder="请选择" style="width:100%;" clearable>
					<el-option
						v-for="item in $dictUtils.getDictList('program_project_archive_list_info_status')"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select>
			</el-form-item>

			<el-form-item>
				<el-button type="default" @click="showHide" :icon="showHideIcon">{{showHideName}}</el-button>
				<el-button type="primary" @click="refreshList()" icon="el-icon-search">查询</el-button>
				<el-button @click="resetSearch()" icon="el-icon-refresh-right">重置</el-button>
			</el-form-item>
		</el-form>

		<div class="jp-table" >
			<vxe-toolbar ref="toolbarRef" :refresh="{query: refreshList}" export custom>
				<template #buttons>
					<!--          <el-button v-if="hasPermission('program:registered:add')" type="primary" icon="el-icon-plus" @click="start()">新建</el-button>-->
					<el-button v-if="hasPermission('jy_project:info:add')" type="primary" icon="el-icon-plus" @click="start()">新建</el-button>
					<el-button v-if="hasPermission('jy_project:info:del')" type="danger"   icon="el-icon-delete" @click="deleteAll()" :disabled="$refs.typeDictTable && $refs.typeDictTable.getCheckboxRecords().length === 0" plain>删除</el-button>
				</template>
			</vxe-toolbar>
			<div class="jp-table-body">
				<vxe-table
					border="inner"
					auto-resize
					resizable
					height="auto"
					:loading="loading"
					size="small"
					ref="typeDictTable"
					show-header-overflow
					show-overflow
					highlight-hover-row
					:menu-config="{}"
					@sort-change="sortChangeHandle"
					:export-config="{
                    remote: true,
                    filename: `嘉溢项目数据${moment(new Date()).format('YYYY-MM-DD')}`,
                    sheetName: `嘉溢项目数据${moment(new Date()).format('YYYY-MM-DD')}`,
                    exportMethod: exportMethod,
                    types: ['xlsx'],
                    modes: ['current', 'selected', 'all']
                  }"
					:sort-config="{remote:true}"
					:data="dataList"
					:tree-config="{}"
					:checkbox-config="{}">
					<vxe-column type="seq" width="60" title="序号"></vxe-column>
					<vxe-column type="checkbox" width="50" ></vxe-column>
					<vxe-column min-width="170" align="center" title="项目名称" field="name" >
						<template #default="scope">
							<el-link  type="primary" :underline="false" v-if="hasPermission('jy_project:info:view')" @click="view(scope.row)">{{scope.row.name}}</el-link>
							<el-link  type="primary" :underline="false" v-else-if="hasPermission('jy_project:info:view')" @click="view(scope.row)">{{scope.row.name}}</el-link>
							<span v-else>{{scope.row.name}}</span>
						</template>
					</vxe-column>
					<vxe-column min-width="100" align="center" title="项目编号" field="no"></vxe-column>
					<vxe-column min-width="180" align="center" title="合同名称" field="contractName">
						<template #default="scope">
<!--							<el-link  type="primary" :underline="false" v-if="scope.row.contractStatus ==='1'" @click="viewContract(scope.row.contractId)">{{scope.row.contractName}}</el-link>-->
							<el-link  type="primary" :underline="false" v-if="commonJS.isNotEmpty(scope.row.contractId)&&commonJS.isNotEmpty(scope.row.contractName)" @click="viewContract(scope.row.contractId)">{{scope.row.contractName}}</el-link>
							<span v-else  style="color: red">暂无合同</span>
						</template>
					</vxe-column>
					<vxe-column min-width="100" align="center" title="负责人" field="projectLeader"></vxe-column>
					<vxe-column min-width="180" align="center" title="主委托方" field="primaryLinkman"></vxe-column>
					<vxe-column min-width="100" align="center" title="创建人" field="createById"></vxe-column>
					<vxe-column min-width="120" align="center" title="创建日期" field="createTime"></vxe-column>

					<vxe-column  min-width="150px" align="center" title="登记状态" field="status" >
						<template #default="scope">
							<el-button @click="registeredDetail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.status, '')" effect="dark" >{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.status, '未登记')}} </el-button>
						</template>
					</vxe-column>
					<vxe-column min-width="150" align="center" title="一级校审" field="firstInstanceStatus">
						<template #default="scope">
							<el-button  @click="firstAuditDetail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.firstInstanceStatus, '')" effect="dark" >{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.firstInstanceStatus, '未登记')}} </el-button>
						</template>
					</vxe-column>
					<vxe-column min-width="120" align="center" title="二级校审" field="secondInstanceStatus">
						<template #default="scope">
							<el-button  @click="secondAuditDetail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.secondInstanceStatus, '')" effect="dark" >{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.secondInstanceStatus, '未登记')}} </el-button>
						</template>
					</vxe-column>
					<vxe-column min-width="120" align="center" title="三级校审" field="thirdInstanceStatus">
						<template #default="scope">
							<el-button  @click="thirdAuditDetail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.thirdInstanceStatus, '')" effect="dark" >{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.thirdInstanceStatus, '未登记')}} </el-button>
						</template>
					</vxe-column>
					<vxe-column  min-width="150px" align="center" title="报告签发" field="reportIssuance" >
						<template #default="scope">
							<el-button  @click="issuedDetail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.reportIssuance, '')" effect="dark" >{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.reportIssuance, '未登记')}} </el-button>
						</template>
					</vxe-column>
					<vxe-column min-width="120" align="center" title="环评资质" field="eiaStatus">
						<template #default="scope">
							<!--							<el-link  type="primary" :underline="false" v-if="scope.row.contractStatus ==='1'" @click="viewContract(scope.row.contractId)">{{scope.row.contractName}}</el-link>-->
							<el-button effect="dark"  v-if="scope.row.contractTypeFirst === '2'" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.eiaStatus, '')" @click="eiaDetail(scope.row)">{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.eiaStatus, '未登记')}}</el-button>
							<span v-else  style="color: red">无需登记</span>
						</template>
					</vxe-column>
					<vxe-column min-width="120" align="center" title="外审" field="outInstance">
						<template #default="scope">
							<el-button @click="outInstanceDetail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.outInstance, '')" effect="dark" >{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.outInstance, '未登记')}} </el-button>
						</template>
					</vxe-column>
					<vxe-column min-width="120" align="center" title="报批签发" field="reportsSubmit">
						<template #default="scope">
							<el-button @click="reportsSubmitDetail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.reportsSubmit, '')" effect="dark" >{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.reportsSubmit, '未登记')}} </el-button>
						</template>
					</vxe-column>
					<vxe-column min-width="120" align="center" title="项目归档" field="reviewStatus">
						<template #default="scope">
							<el-button @click="archiveDetail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.reviewStatus, '')" effect="dark" >{{$dictUtils.getDictLabel("program_project_archive_list_info_status", scope.row.reviewStatus, '未登记')}} </el-button>
						</template>
					</vxe-column>
					<vxe-column title="操作" min-width="200px" fixed="right" align="center">
						<template  #default="scope">
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.status === '1' || scope.row.status === '3')&&scope.row.createBy === $store.state.user.id" text type="primary"  @click="registeredPush(scope.row)">修改</el-button>
							<!--管理员角色登记完成后可修改-->
							<el-button v-if="hasPermission('admin:edit') && isJyAdmin && scope.row.reviewStatus === '5'" text type="primary"  @click="adminEdit(scope.row)">修改</el-button>
							<!--项目负责人修改-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&scope.row.status === '5' && scope.row.reviewStatus !== '5' && (scope.row.projectLeader === $store.state.user.name || (haveProjectIds.includes(scope.row.id) && scope.row.createBy !== $store.state.user.id)) " text type="primary"  @click="adminEdit(scope.row)">修改</el-button>
							<el-button v-if="hasPermission('jy_project:info:edit')&&scope.row.status === '2'&&scope.row.createBy === $store.state.user.id" text type="primary"  @click="registeredReback(scope.row)">撤回</el-button>
							<!--项目登记  审核-->
							<el-button v-if="scope.row.status==='2' && checkIsAudit(scope.row)" text type="primary"   @click="examine(scope.row)">登记审核</el-button>
							<!--项目登记  被驳回后当前申请人重新调整-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id || haveProjectIds.includes(scope.row.id))&&scope.row.status === '4'" text type="primary"   @click="adjust(scope.row)">驳回调整</el-button>

							<el-button v-if="hasPermission('jy_project:info:del')&&(scope.row.status === '1' || scope.row.status === '3')&&(scope.row.createBy === $store.state.user.id  ||haveProjectIds.includes(scope.row.id))" text type="primary"  @click="del(scope.row.id)">删除</el-button>
							<!--管理员角色登记完成后可删除-->
							<el-button v-if="hasPermission('admin:del') && isJyAdmin" text type="primary"  @click="del(scope.row.id)">删除</el-button>

							<!--              <el-button v-if="hasPermission('program:registered:edit')&&scope.row.status === '5' && commonJS.isEmpty(scope.row.reportNo) && scope.row.createBy === $store.state.user.id" text type="primary"  @click="saveReportNo(scope.row.id)">生成报告号</el-button>-->

<!--							&lt;!&ndash; 一级校审  发起&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&& scope.row.status === '5' && (scope.row.firstInstanceStatus ==='0' || scope.row.firstInstanceStatus ==='3' ||scope.row.firstInstanceStatus ==='1'||scope.row.firstInstanceStatus ==='6') &&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id) )" text type="primary"  @click="firstAuditPush(scope.row)">一级校审</el-button>
<!--							&lt;!&ndash; 一级校审  撤回&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&scope.row.firstInstanceStatus === '2' &&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))" text type="primary"  @click="firstAuditReback(scope.row)">校审撤回</el-button>
<!--							&lt;!&ndash; 一级校审  审核&ndash;&gt;-->
							<el-button v-if="scope.row.firstInstanceStatus==='2' && checkIsAuditFirst(scope.row)" text type="primary"   @click="examineFirst(scope.row)">一级校审审核</el-button>
<!--							&lt;!&ndash; 一级校审  被驳回后当前申请人重新调整&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))&&scope.row.firstInstanceStatus === '4'" text type="primary"   @click="adjustFirst(scope.row)">驳回调整</el-button>

<!--							&lt;!&ndash; 二级校审  发起&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))&&(scope.row.firstInstanceStatus === '5' || scope.row.firstInstanceStatus === '7')&&(scope.row.secondInstanceStatus === '0'||scope.row.secondInstanceStatus === '1'||scope.row.secondInstanceStatus === '3')" text type="primary"  @click="secondAuditPush(scope.row)">二级校审</el-button>
<!--							&lt;!&ndash; 二级校审  撤回&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&scope.row.secondInstanceStatus === '2'&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))" type="text"  @click="secondAuditReback(scope.row)">校审撤回</el-button>
<!--							&lt;!&ndash; 二级校审  审核&ndash;&gt;-->
							<el-button v-if="scope.row.secondInstanceStatus==='2' && checkIsAuditSecond(scope.row)" text type="primary"  @click="examineSecond(scope.row)">二级校审审核</el-button>
<!--							&lt;!&ndash; 二级校审  被驳回后当前申请人重新调整&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))&&scope.row.secondInstanceStatus === '4'" text type="primary"  @click="adjustSecond(scope.row)">驳回调整</el-button>

<!--							&lt;!&ndash; 三级校审  发起&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))&&scope.row.secondInstanceStatus === '5' &&(scope.row.thirdInstanceStatus === '0'||scope.row.thirdInstanceStatus === '1'||scope.row.thirdInstanceStatus === '3')" text type="primary"  @click="thirdAuditPush(scope.row)">三级校审</el-button>
<!--							&lt;!&ndash; 三级校审  撤回&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id||haveProjectIds.includes(scope.row.id))&&scope.row.thirdInstanceStatus === '2'" text type="primary"  @click="thirdAuditReback(scope.row)">校审撤回</el-button>
<!--							&lt;!&ndash; 三级校审  审核&ndash;&gt;-->
							<el-button v-if="scope.row.thirdInstanceStatus==='2' && checkIsAuditThird(scope.row)" text type="primary"   @click="examineThird(scope.row)">三级校审审核</el-button>
<!--							&lt;!&ndash; 三级校审  被驳回后当前申请人重新调整&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))&&scope.row.thirdInstanceStatus === '4'" text type="primary"   @click="adjustThird(scope.row)">驳回调整</el-button>

							<!--							&lt;!&ndash;报告签发发起&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id)) &&scope.row.thirdInstanceStatus === '5' && (scope.row.reportIssuance === null ||scope.row.reportIssuance === undefined ||scope.row.reportIssuance === '' ||scope.row.reportIssuance === '0' || scope.row.reportIssuance === '1'|| scope.row.reportIssuance === '3')" text type="primary"  @click="reportIssuanceSubmit(scope.row)">报告签发</el-button>
							<!--							&lt;!&ndash;报告签发撤回&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id)) && scope.row.reportIssuance === '2'" text type="primary"  @click="reportIssuanceReback(scope.row)">报告签发撤回</el-button>
							<!--							<el-button v-if="scope.row.reportsSubmit === '1'|| scope.row.reportsSubmit === '3' &&(scope.row.createBy === $store.state.user.id|| haveProjectIds.includes(scope.row.id))" text type="primary"  @click="edit(scope.row)">报批签发修改</el-button>-->
							<!--							&lt;!&ndash; 报告签发  审核&ndash;&gt;-->
							<el-button v-if="scope.row.reportIssuance==='2' && checkIsAuditIssued(scope.row)" text type="primary"  @click="reportIssuanceCheck(scope.row)">报告签发审核</el-button>
							<!--							&lt;!&ndash; 报告签发  被驳回后当前申请人重新调整&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))&&scope.row.reportIssuance === '4'" text type="primary"  @click="adjustReportIssuance(scope.row)">报告驳回调整</el-button>

<!--							&lt;!&ndash;外审发起&ndash;&gt;-->
							<el-button :disabled="scope.row.eiaStatus !=='5' && scope.row.contractTypeFirst === '2'" v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id)) &&scope.row.reportIssuance === '5' && (scope.row.outInstance === null ||scope.row.outInstance === undefined ||scope.row.outInstance === '' ||scope.row.outInstance === '0' || scope.row.outInstance === '1' || scope.row.outInstance === '3')" text type="primary"  @click="issued(scope.row)">发起外审</el-button>
<!--							&lt;!&ndash;外审撤回&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id)) && scope.row.outInstance === '2'" text type="primary"  @click="issuedReback(scope.row)">外审撤回</el-button>
<!--							&lt;!&ndash; 外审  审核&ndash;&gt;-->
							<el-button v-if="scope.row.outInstance==='2' && checkIsAuditIssued(scope.row)" text type="primary"  @click="examineIssued(scope.row)">外审审核</el-button>
<!--							&lt;!&ndash; 外审  被驳回后当前申请人重新调整&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))&&scope.row.outInstance === '4'" text type="primary"  @click="adjustIssued(scope.row)">驳回调整</el-button>


							<!--							&lt;!&ndash;报批签发发起&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id)) &&scope.row.outInstance === '5' && (scope.row.reportsSubmit === null ||scope.row.reportsSubmit === undefined ||scope.row.reportsSubmit === '' ||scope.row.reportsSubmit === '0' || scope.row.reportsSubmit === '1'|| scope.row.reportsSubmit === '3')" text type="primary"  @click="reportsDoSubmit(scope.row)">报批签发</el-button>
							<!--							&lt;!&ndash;报批签发撤回&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id)) && scope.row.reportsSubmit === '2'" text type="primary"  @click="reportsSubmitReback(scope.row)">报批签发撤回</el-button>
<!--							<el-button v-if="scope.row.reportsSubmit === '1'|| scope.row.reportsSubmit === '3' &&(scope.row.createBy === $store.state.user.id|| haveProjectIds.includes(scope.row.id))" text type="primary"  @click="edit(scope.row)">报批签发修改</el-button>-->
							<!--							&lt;!&ndash; 报批签发  审核&ndash;&gt;-->
							<el-button v-if="scope.row.reportsSubmit==='2' && checkIsAuditIssued(scope.row)" text type="primary"  @click="reportsSubmitCheck(scope.row)">报批签发审核</el-button>
							<!--							&lt;!&ndash; 报批签发  被驳回后当前申请人重新调整&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))&&scope.row.reportsSubmit === '4'" text type="primary"  @click="adjustReportsSubmit(scope.row)">驳回调整</el-button>

<!--							&lt;!&ndash;评估报告装订后的审核&ndash;&gt;-->
<!--							<el-button v-if="hasPermission('program:registered:browse')&&(scope.row.createBy === $store.state.user.id||haveProjectIds.includes(scope.row.id))&&scope.row.issuedStatus === '5'&&scope.row.archiveStatus === '0'" text type="primary" @click="browse(scope.row.id)">装订自校</el-button>-->

<!--							&lt;!&ndash; 项目归档&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))&&(scope.row.reportsSubmit === '5' || scope.row.reportsSubmit === '7') &&(scope.row.reviewStatus === ''||scope.row.reviewStatus === undefined||scope.row.reviewStatus === null||scope.row.reviewStatus === '0'||scope.row.reviewStatus === '1'||scope.row.reviewStatus === '3')" text type="primary" @click="archivePush(scope.row)">项目归档</el-button>
<!--							&lt;!&ndash; 项目归档撤回&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))&&scope.row.reviewStatus === '2'" text type="primary" @click="archiveReback(scope.row)">项目归档撤回</el-button>
<!--							&lt;!&ndash; 项目归档  审核&ndash;&gt;-->
							<el-button v-if="scope.row.reviewStatus==='2' && checkIsAuditArchive(scope.row)" text type="primary"  @click="examineArchive(scope.row)">归档审核</el-button>
<!--							&lt;!&ndash; 项目归档  被驳回后当前申请人重新调整&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))&&scope.row.reviewStatus === '4'" text type="primary"  @click="adjustArchive(scope.row)">驳回调整</el-button>

							<!--							&lt;!&ndash; 环评资质&ndash;&gt;-->
							<el-button v-if="scope.row.contractTypeFirst==='2' && hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))&& scope.row.status === '5' && scope.row.contractTypeFirst === '2' && scope.row.outInstance ==='0'  &&(scope.row.eiaStatus === ''||scope.row.eiaStatus === undefined||scope.row.eiaStatus === null||scope.row.eiaStatus === '0'||scope.row.eiaStatus === '1'||scope.row.eiaStatus === '3')" text type="primary" @click="eiaPush(scope.row)">环评资质</el-button>
							<!--							&lt;!&ndash; 项目归档撤回&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))&&scope.row.eiaStatus === '2'" text type="primary" @click="eiaReback(scope.row)">环评资质撤回</el-button>
							<!--							&lt;!&ndash; 项目归档  审核&ndash;&gt;-->
							<el-button v-if="scope.row.eiaStatus==='2' && checkIsAuditEia(scope.row)" text type="primary"  @click="examineEia(scope.row)">资质审核</el-button>
							<!--							&lt;!&ndash; 项目归档  被驳回后当前申请人重新调整&ndash;&gt;-->
							<el-button v-if="hasPermission('jy_project:info:edit')&&(scope.row.createBy === $store.state.user.id ||haveProjectIds.includes(scope.row.id))&&scope.row.eiaStatus === '4'" text type="primary"  @click="adjustEia(scope.row)">资质驳回调整</el-button>

							<!--一级校审ftl文件下载-->
							<!--              <el-button v-if="hasPermission('program:registered:edit')" text type="primary"  icon="el-icon-circle-check"  @click="downloadFirstAuditTpl(scope.row)">一级校审下载</el-button>-->
							<!--              <el-button v-if="hasPermission('program:registered:edit')" text type="primary"  icon="el-icon-circle-check"  @click="downloadSecondAuditTpl(scope.row)">二级校审下载</el-button>-->
							<!--              <el-button v-if="hasPermission('program:registered:edit')" text type="primary"  icon="el-icon-circle-check"  @click="downloadThirdlyAuditTpl(scope.row)">三级校审下载</el-button>-->

							<!--自校功能ftl文件下载-->
							<!--              <el-button v-if="hasPermission('program:registered:edit')" text type="primary"  icon="el-icon-circle-check"  @click="downloadProofreadAuditTpl(scope.row)">校对审核</el-button>-->
							<!--              <el-button v-if="hasPermission('program:registered:edit')" text type="primary"  icon="el-icon-circle-check"  @click="downloadAuditRecordFormAfterBindingTpl(scope.row)">评估报告装订后</el-button>-->

							<!--报告签发单-->
							<!--              <el-button v-if="hasPermission('program:registered:edit')" text type="primary"  icon="el-icon-circle-check"  @click="downloadReportAusstellungTpl(scope.row)">报告签发单</el-button>-->

						</template>
					</vxe-column>
				</vxe-table>
				<vxe-pager
					background
					size="small"
					:current-page="tablePage.currentPage"
					:page-size="tablePage.pageSize"
					:total="tablePage.total"
					:page-sizes="[10, 20, 100, 1000, {label: '全量数据', value: 1000000}]"
					:layouts="['PrevPage', 'JumpNumber', 'NextPage', 'FullJump', 'Sizes', 'Total']"
					@page-change="currentChangeHandle">
				</vxe-pager>
			</div>
			<ProjectDia  ref="projectDia" @refreshDataList="refreshList"></ProjectDia>
		</div>

		<ProjectFormUpdate ref="projectFormUpdate" @refreshDataList="refreshList"></ProjectFormUpdate>
		<ProofreadForm  ref="proofreadForm" @refreshDataList="refreshList"></ProofreadForm>
		<ProofreadBrowseForm  ref="proofreadBrowseForm" @refreshDataList="refreshList"></ProofreadBrowseForm>
		<ContractAddForm ref="contractAddForm"></ContractAddForm>
		<ProjectEdit ref="projectEdit"></ProjectEdit>
	</div>
</template>

<script>
	import taskService from '@/api/flowable/taskService'
	import ProjectInfoService from "@/api/jy/ProjectInfoService";
	import userService from '@/api/sys/userService'
	import processService from '@/api/flowable/processService'
	import pick from 'lodash.pick'
	import ProjectDia from './ProjectDia'
	import ProjectEdit from './ProjectEdit'
	import ContractAddForm from '../workContractInfo/ContractAddForm'
	import UserSelect from '@/components/userSelect'
	import SignetService from "@/api/jy/SignetService"
export default {
	data(){
		return {
			applyUserName: '',
			showHideItem: false,
			showHideIcon: 'el-icon-arrow-down',
			showHideName: '展示',
			searchForm: {
				name: '',
				no: '',
				createById: '',
				primaryLinkman: '',//委托方
				contractName: '',
				projectLeader:'',//项目负责人
				createDates: [],
				status: '',
				firstInstanceStatus: '',  // 一级校审状态
				secondInstanceStatus: '',	// 二级校审状态
				thirdInstanceStatus: '',	// 三级校审状态
				reportIssuance: '',	// 报告签发
				outInstance:'',//外审
				reportsSubmit:'',//报批签发
				reviewStatus:'',//归档状态
			},
			dataList: [],
			tablePage: {
				total: 0,
				currentPage: 1,
				pageSize: 10,
				orders: []
			},
			createName: '',
			loading: false,
			isAdmin: false,
			processDefinitionId:'',
			procDefKey:'',
			haveProjectIds:'',
			processDefinitionId1:'',
			procDefKey1:'',
			processDefinitionId2:'',
			procDefKey2:'',
			processDefinitionId3:'',
			procDefKey3:'',
			processDefinitionIdOut:'',
			procDefKeyOut:'',
			processDefinitionReportsId:'',
			procDefKeyReports:'',
			processDefinitionIdArchive:'',
			procDefKeyArchive:'',
			processDefinitionIdEia:'',
			procDefKeyEia:'',
			isJyAdmin:false,
		}
	},
	ProjectInfoService:null,
	SignetService: null,
	created(){
		this.projectInfoService=new ProjectInfoService()
		this.signetService = new SignetService()
	},
	components:{
		ProjectDia,
		ContractAddForm,
		UserSelect,
		ProjectEdit
	},
	mounted(){
		this.$nextTick(() => {
			// 将表格和工具栏进行关联
			const $table = this.$refs.typeDictTable;
			const $toolbar = this.$refs.toolbarRef;
			$table.connect($toolbar);
		});
		this.refreshList();
	},
	activated(){
		// this.is()
		this.refreshList()
	},
	computed:{
		userName () {
			return this.$store.state.user.name
		},
		user () {
			this.createName = this.$store.state.user.name
			return this.$store.state.user
		}
	},
	methods:{
		showHide () {
			if (this.showHideItem === false) {
				this.showHideItem = true
				this.showHideIcon = 'el-icon-arrow-up'
				this.showHideName = '隐藏'
			} else {
				this.showHideItem = false
				this.showHideIcon = 'el-icon-arrow-down'
				this.showHideName = '展示'
			}
		},
		// 新增
		add () {
			this.$refs.projectForm.init('add', '')
		},
		// 修改
		adminEdit (row) {
			// id = row.id || this.$refs.typeDictTable.getCheckboxRecords().map(item => {
			// 	return item.id
			// })[0]
			this.$refs.projectEdit.init('edit', row.id)
		},
		// 查看
		view (row) {
			this.$refs.projectDia.init('view', row.id,row.auditId1, row.auditId2, row.auditId3,row.sealId,row.outInstanceId,row.reportsSubmitId,row.archiveId,row.eiaId)
		},
		//判断当前登陆人是否是admin
		checkIsJyAdmin(){
			userService.checkIsJyAdmin().then((data)=>{
				this.isJyAdmin = data
			})
		},
		// 获取数据列表
		refreshList () {
			this.loading = true
			this.createName = this.$store.state.user.name
			this.projectInfoService.list({
				'current': this.tablePage.currentPage,
				'size': this.tablePage.pageSize,
				'orders': this.tablePage.orders,
				...this.searchForm
			}).then((data) => {
				console.log('s',data.records)
				this.dataList = data.records
				this.tablePage.total = data.total
				this.loading = false
			})
			this.is()
			this.checkIsJyAdmin()
			// 获取当前登录人的所属项目id集合
			this.projectInfoService.getHaveProjectIds().then((data) => {
				if (this.commonJS.isNotEmpty(data)) {
					this.haveProjectIds = data.map(i => {
						if (this.commonJS.isNotEmpty(i)) {
							return i
						}
					}).join(',')
				}
			})
			processService.getByName('嘉溢-项目登记').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionId = data.id
					this.procDefKey = data.key
				}
			})
			processService.getByName('嘉溢-项目一级校审').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionId1 = data.id
					this.procDefKey1 = data.key
				}
			})
			processService.getByName('嘉溢-项目二级校审').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionId2 = data.id
					this.procDefKey2 = data.key
				}
			})
			processService.getByName('嘉溢-项目三级校审').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionId3 = data.id
					this.procDefKey3 = data.key
				}
			})
			processService.getByName('嘉溢-项目外审').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionIdOut = data.id
					this.procDefKeyOut = data.key
				}
			})
			processService.getByName('嘉溢-用印流程').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionReportsId = data.id
					this.procDefKeyReports = data.key
				}
			})
			processService.getByName('嘉溢-项目归档').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionIdArchive = data.id
					this.procDefKeyArchive = data.key
				}
			})

			processService.getByName('嘉溢-环评项目资质').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionIdEia = data.id
					this.procDefKeyEia = data.key
				}
			})

		},
		// 当前页
		currentChangeHandle ({ currentPage, pageSize }) {
			this.tablePage.currentPage = currentPage
			this.tablePage.pageSize = pageSize
			this.refreshList()
		},
		// 排序
		sortChangeHandle (column) {
			this.tablePage.orders = []
			if (column.order != null) {
				this.tablePage.orders.push({column: this.$utils.toLine(column.property), asc: column.order === 'asc'})
			}
			this.refreshList()
		},
		// 删除
		deleteAll (id) {
			let ids = id || this.$refs.typeDictTable.getCheckboxRecords().map(item => {
				return item.id
			}).join(',')
			this.$confirm(`确定删除所选项吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.loading = true
				this.projectInfoService.deleteAll(ids).then((data) => {
					this.$message.success(data)
					this.refreshList()
					this.loading = false
				})
			})
		},
		// 删除
		del (id) {
			let ids = id || this.$refs.typeDictTable.getCheckboxRecords().map(item => {
				return item.id
			}).join(',')
			this.$confirm(`确定删除所选项吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.loading = true
				this.projectInfoService.delete(ids).then((data) => {
					this.$message.success(data)
					this.refreshList()
					this.loading = false
				})
			})
		},
		resetSearch () {
			this.searchForm.createById = ''
			this.applyUserName = ''
			this.$refs.searchForm.resetFields()
			this.refreshList()
		},
		// 查询当前登录人是否是数据的审核人
		checkIsAudit (row) {
			let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
			if (this.commonJS.isNotEmpty(row.auditUserIds)) {
				for (const userId of row.auditUserIds) {
					if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
						return true
					}
				}
			}
			return false
		},
		is () {
			userService.is().then((data) => {
				this.isAdmin = data
			})
			console.log('is',this.isAdmin)
		},
		// 发起项目登记审批
		registeredPush (row) {
			// 读取流程表单
			let title = `发起流程【嘉溢-项目登记】`
			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[嘉溢-项目登记]`
			let status = 'startAndHold'
			if (row.status === '3') {
				status = 'startAndClose'
			} else if (row.status === '4') {
				status = 'reapplyFlag'
			}
			taskService.getTaskDef({ procDefId: this.processDefinitionId,
				businessId: row.id,
				businessTable: 'jy_project_record'}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionId,
						procDefKey: this.procDefKey,
						title: title,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessTable: 'jy_project_record',
						businessId: row.id,
						isShow: 'false',
						status: status,
						routePath: '/jy/project/ProjectList'
					}
				})
			})
		},
		// // 查看项目登记审批流程结果
		registeredDetail (row) {
			if (row.status !== '0' && row.status !== '1') {
				this.projectInfoService.findById(row.id).then((data)=>{
					console.log('data',data)
					// eslint-disable-next-line eqeqeq
					taskService.getTaskDef({
						procInsId: data.procInsId,
						procDefId: data.processDefinitionId
					}).then((data) => {
						this.$router.push({
							path: '/flowable/task/TaskFormDetail',
							query: {
								...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
								isShow: 'false',
								readOnly: true,
								title: '项目登记' + '流程详情',
								formTitle: '项目登记' + '流程详情',
								businessId: row.id,
								status: 'reback',
								method: 'view'
							}
						})
					})
				})

			}
		},
		// // 撤回项目登记审批
		registeredReback (row) {
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => {
				await this.projectInfoService.findById(row.id).then((data) => {
					if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.procInsId).then((data) => {
							let form = {status: '3', id: row.id}
							this.projectInfoService.updateStatusById(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},
		start () {
			// 读取流程表单
			let tabTitle = `发起流程【嘉溢-项目登记】`
			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了 [嘉溢-项目登记]`
			taskService.getTaskDef({ procDefId: this.processDefinitionId,
				status: 'startAndHold'}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionId,
						procDefKey: this.procDefKey,
						status: 'startAndHold',
						title: tabTitle,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessId: 'false',
						isShow: false,
						routePath: '/jy/project/ProjectList'
					}
				})
			})
		},
		// 审核
		examine (row) {
			this.projectInfoService.findById(row.id).then((data) => {
				if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todo(row)
				}
			})
		},
		// 驳回后调整
		adjust (row) {
			this.projectInfoService.findById(row.id).then((data) => {
				if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todo(row)
				}
			})
		},
		// 审核或重新调整跳转
		todo (row) {
			let cUser = false
			taskService.getTaskDefInfo({
				taskId: row.taskId
			}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId','method'),
						isShow: false,
						formReadOnly: true,
						formTitle: `${data.taskName}`,
						cUser: cUser,
						title: `审批【${data.taskName || ''}】`,
						routePath: '/jy/project/ProjectList' , // 数据处理后需要跳转的页面路径
						method:'view'
					}
				})
			})
		},
		viewContract (id) {
			this.$refs.contractAddForm.init('view', id)
		},
		// 发起一级校审
		firstAuditPush (row) {
			// 读取流程表单
			let title = `发起流程【嘉溢-项目一级校审】`
			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[嘉溢-项目一级校审]`
			let status = 'startAndHold'
			if (row.firstInstanceStatus === '3') {
				status = 'startAndClose'
			} else if (row.firstInstanceStatus === '4') {
				status = 'reapplyFlag'
			}
			taskService.getTaskDef({ procDefId: this.processDefinitionId1,
				businessId: row.auditId1,
				businessTable: 'jy_project_audit'}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionId1,
						procDefKey: this.procDefKey1,
						title: title,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessTable: 'jy_project_audit',
						businessId: row.auditId1,
						isShow: 'false',
						status: status,
						routePath: '/jy/project/ProjectList'
					}
				})
			})
		},
		checkIsAuditFirst (row) {
			let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
			if (this.commonJS.isNotEmpty(row.auditUserIds1)) {
				for (const userId of row.auditUserIds1) {
					if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
						return true
					}
				}
			}
			return false
		},
		// 驳回后调整  一级校审
		adjustFirst (row) {
			this.projectInfoService.findByIdAudit(row.auditId1).then((data) => {
				if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoFirst(row)
				}
			})
		},
		// 审核  一级校审
		examineFirst (row) {
			this.projectInfoService.findByIdAudit(row.auditId1).then((data) => {
				if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoFirst(row)
				}
			})
		},
		// 审核或重新调整跳转  一级校审
		todoFirst (row) {
			let cUser = false
			taskService.getTaskDefInfo({
				taskId: row.taskIdAudit1
			}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId'),
						isShow: false,
						formReadOnly: true,
						formTitle: `${data.taskName}`,
						cUser: cUser,
						title: `审批【${data.taskName || ''}】`,
						routePath: '/jy/project/ProjectList'   // 数据处理后需要跳转的页面路径
					}
				})
			})
		},
		// 查看一级校审审批流程结果
		firstAuditDetail (row) {
			if (row.firstInstanceStatus !== '0' && row.firstInstanceStatus !== '1') {
				// eslint-disable-next-line eqeqeq
				taskService.getTaskDef({
					procInsId: row.procInsId1,
					procDefId: this.processDefinitionId1
				}).then((data) => {
					this.$router.push({
						path: '/flowable/task/TaskFormDetail',
						query: {
							...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
							isShow: 'false',
							readOnly: true,
							title: '一级校审' + '流程详情',
							formTitle: '一级校审' + '流程详情',
							businessId: row.auditId1,
							status: 'reback'
						}
					})
				})
			}
		},
		// 撤回一级校审
		firstAuditReback (row) {
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => {
				await this.projectInfoService.findByIdAudit(row.auditId1).then((data) => {
					if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.procInsId1).then((data) => {
							let form = {status: '3', id: row.auditId1}
							this.projectInfoService.updateStatusByAuditId(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},
		// 查询当前登录人是否是数据的审核人  二级校审
		checkIsAuditSecond (row) {
			let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
			if (this.commonJS.isNotEmpty(row.auditUserIds2)) {
				for (const userId of row.auditUserIds2) {
					if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
						return true
					}
				}
			}
			return false
		},
		// 发起二级校审
		secondAuditPush (row) {
			// 读取流程表单
			let title = `发起流程【嘉溢-项目二级校审】`
			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[嘉溢-项目二级校审]`
			let status = 'startAndHold'
			if (row.secondInstanceStatus === '3') {
				status = 'startAndClose'
			} else if (row.secondInstanceStatus === '4') {
				status = 'reapplyFlag'
			}
			taskService.getTaskDef({ procDefId: this.processDefinitionId2,
				businessId: row.auditId2,
				businessTable: 'jy_project_audit'}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionId2,
						procDefKey: this.procDefKey2,
						title: title,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessTable: 'jy_project_audit',
						businessId: row.auditId2,
						isShow: 'false',
						status: status,
						routePath: '/jy/project/ProjectList'
					}
				})
			})
		},
		// 查看二级校审审批流程结果
		secondAuditDetail (row) {
			if (row.secondInstanceStatus !== '0' && row.secondInstanceStatus !== '1') {
				// eslint-disable-next-line eqeqeq
				taskService.getTaskDef({
					procInsId: row.procInsId2,
					procDefId: this.processDefinitionId2
				}).then((data) => {
					this.$router.push({
						path: '/flowable/task/TaskFormDetail',
						query: {
							...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
							isShow: 'false',
							readOnly: true,
							title: '二级校审' + '流程详情',
							formTitle: '二级校审' + '流程详情',
							businessId: row.auditId2,
							status: 'reback'
						}
					})
				})
			}
		},
		// 撤回二级校审
		secondAuditReback (row) {
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => {
				await this.projectInfoService.findByIdAudit(row.auditId2).then((data) => {
					if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.procInsId2).then((data) => {
							let form = {status: '3', id: row.auditId2}
							this.projectInfoService.updateStatusByAuditId(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},
		// 驳回后调整  二级校审
		adjustSecond (row) {
			this.projectInfoService.findByIdAudit(row.auditId2).then((data) => {
				if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoSecond(row)
				}
			})
		},
		// 审核  二级校审
		examineSecond (row) {
			this.projectInfoService.findByIdAudit(row.auditId2).then((data) => {
				if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoSecond(row)
				}
			})
		},
		// 审核或重新调整跳转  二级校审
		todoSecond (row) {
			let cUser = false
			taskService.getTaskDefInfo({
				taskId: row.taskIdAudit2
			}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId'),
						isShow: false,
						formReadOnly: true,
						formTitle: `${data.taskName}`,
						cUser: cUser,
						title: `审批【${data.taskName || ''}】`,
						routePath: '/jy/project/ProjectList'   // 数据处理后需要跳转的页面路径
					}
				})
			})
		},
		// 发起三级校审
		thirdAuditPush (row) {
			// 读取流程表单
			let title = `发起流程【嘉溢-项目三级校审】`
			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[嘉溢-项目三级校审]`
			let status = 'startAndHold'
			if (row.thirdInstanceStatus === '3') {
				status = 'startAndClose'
			} else if (row.thirdInstanceStatus === '4') {
				status = 'reapplyFlag'
			}
			taskService.getTaskDef({ procDefId: this.processDefinitionId3,
				businessId: row.auditId3,
				businessTable: 'jy_project_audit'}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionId3,
						procDefKey: this.procDefKey3,
						title: title,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessTable: 'jy_project_audit',
						businessId: row.auditId3,
						isShow: 'false',
						status: status,
						routePath: '/jy/project/ProjectList'
					}
				})
			})
		},
		// 查看三级校审审批流程结果
		thirdAuditDetail (row) {
			if (row.thirdInstanceStatus !== '0' && row.thirdInstanceStatus !== '1') {
				// eslint-disable-next-line eqeqeq
				taskService.getTaskDef({
					procInsId: row.procInsId3,
					procDefId: this.processDefinitionId3
				}).then((data) => {
					this.$router.push({
						path: '/flowable/task/TaskFormDetail',
						query: {
							...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
							isShow: 'false',
							readOnly: true,
							title: '三级校审' + '流程详情',
							formTitle: '三级校审' + '流程详情',
							businessId: row.auditId3,
							status: 'reback'
						}
					})
				})
			}
		},
		// 撤回三级校审
		thirdAuditReback (row) {
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => {
				await this.projectInfoService.findByIdAudit(row.auditId3).then((data) => {
					if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.procInsId3).then((data) => {
							let form = {status: '3', id: row.auditId3}
							this.projectInfoService.updateStatusByAuditId(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},
		// 驳回后调整  三级校审
		adjustThird (row) {
			this.projectInfoService.findByIdAudit(row.auditId3).then((data) => {
				if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoThird(row)
				}
			})
		},
		// 审核  三级校审
		examineThird (row) {
			this.projectInfoService.findByIdAudit(row.auditId3).then((data) => {
				if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoThird(row)
				}
			})
		},
		// 审核或重新调整跳转  三级校审
		todoThird (row) {
			let cUser = false
			taskService.getTaskDefInfo({
				taskId: row.taskIdAudit3
			}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId'),
						isShow: false,
						formReadOnly: true,
						formTitle: `${data.taskName}`,
						cUser: cUser,
						title: `审批【${data.taskName || ''}】`,
						routePath: '/jy/project/ProjectList'   // 数据处理后需要跳转的页面路径
					}
				})
			})
		},
		// 查询当前登录人是否是数据的审核人  三级校审
		checkIsAuditThird (row) {
			let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
			if (this.commonJS.isNotEmpty(row.auditUserIds3)) {
				for (const userId of row.auditUserIds3) {
					if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
						return true
					}
				}
			}
			return false
		},
		//查询用印信息
		issuedDetail(row){
			if (row.reportIssuance !== '0' && row.reportIssuance !== '1') {
				this.signetService.queryById(row.sealId).then((da)=>{
					// eslint-disable-next-line eqeqeq
					taskService.getTaskDef({
						procInsId: da.procInsId,
						procDefId: da.processDefinitionId
					}).then((data) => {
						this.$router.push({
							path: '/flowable/task/TaskFormDetail',
							query: {
								...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
								isShow: 'false',
								readOnly: true,
								title: '用印申请' + '流程详情',
								formTitle: '用印申请' + '流程详情',
								businessId: row.sealId,
								status: 'reback',
								method: 'view'
							}
						})
					})
				})
			}
		},
		//外审发起
		issued(row){
			// 读取流程表单
			let title = `发起流程【嘉溢-项目外审】`
			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[嘉溢-项目外审]`
			let status = 'startAndHold'
			if (row.outInstance === '3') {
				status = 'startAndClose'
			} else if (row.outInstance === '4') {
				status = 'reapplyFlag'
			}
			taskService.getTaskDef({ procDefId: this.processDefinitionIdOut,
				businessId: row.outInstanceId,
				businessTable: 'jy_project_outinstance'}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionIdOut,
						procDefKey: this.procDefKeyOut,
						title: title,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessTable: 'jy_project_outinstance',
						businessId: row.outInstanceId,
						isShow: 'false',
						status: status,
						routePath: '/jy/project/ProjectList'
					}
				})
			})
		},
		// 查询当前登录人是否是数据的审核人  外审
		checkIsAuditIssued (row) {
			let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
			if (this.commonJS.isNotEmpty(row.outInstanceId)) {
				for (const userId of row.outInstanceId) {
					if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
						return true
					}
				}
			}
			return false
		},
		//查看外审审批流程结果
		outInstanceDetail(row){
			if (row.outInstance !== '0' && row.outInstance !== '1') {
				// eslint-disable-next-line eqeqeq
				taskService.getTaskDef({
					procInsId: row.procInsIdOut,
					procDefId: this.processDefinitionIdOut
				}).then((data) => {
					this.$router.push({
						path: '/flowable/task/TaskFormDetail',
						query: {
							...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
							isShow: 'false',
							readOnly: true,
							title: '外审' + '流程详情',
							formTitle: '外审' + '流程详情',
							businessId: row.outInstanceId,
							status: 'reback'
						}
					})
				})
			}
		},
		//外审撤回
		issuedReback(row){
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => {
				await this.projectInfoService.findByIdOut(row.outInstanceId).then((data) => {
					if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.procInsIdOut).then((data) => {
							let form = {status: '3', id: row.outInstanceId}
							this.projectInfoService.updateStatusByOutId(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},
		//外审审核
		examineIssued(row){
			this.projectInfoService.findByIdOut(row.outInstanceId).then((data) => {
				if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoOut(row)
				}
			})
		},
		// 审核或重新调整跳转  外审
		todoOut (row) {
			let cUser = false
			taskService.getTaskDefInfo({
				taskId: row.taskIdOut
			}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId'),
						isShow: false,
						formReadOnly: true,
						formTitle: `${data.taskName}`,
						cUser: cUser,
						title: `审批【${data.taskName || ''}】`,
						routePath: '/jy/project/ProjectList'   // 数据处理后需要跳转的页面路径
					}
				})
			})
		},
		//外审驳回后重新调整
		adjustIssued(row){
			this.projectInfoService.findByIdOut(row.outInstanceId).then((data) => {
				if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoOut(row)
				}
			})
		},
		//发起报批签发
		reportsDoSubmit(row){
			// 读取流程表单
			let tabTitle = `发起流程【嘉溢-报批签发】`
			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了 [嘉溢-报批签发]`
			taskService.getTaskDef({ procDefId: this.processDefinitionReportsId,
				status: 'startAndHold'}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionReportsId,
						procDefKey: this.procDefKeyReports,
						status: 'startAndHold',
						title: tabTitle,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessId: row.reportsSubmitId,
						isShow: false,
						routePath: '/jy/project/ProjectList'
					}
				})
			})
		},
		//报批签发审核流程详情
		reportsSubmitDetail(row){
			if (row.reportsSubmit !== '0' && row.reportsSubmit !== '1') {
				// eslint-disable-next-line eqeqeq
				taskService.getTaskDef({
					procInsId: row.procInsIdReports,
					procDefId: this.processDefinitionReportsId
				}).then((data) => {
					this.$router.push({
						path: '/flowable/task/TaskFormDetail',
						query: {
							...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
							isShow: 'false',
							readOnly: true,
							title: '报批签发' + '流程详情',
							formTitle: '报批签发' + '流程详情',
							businessId: row.reportsSubmitId,
							status: 'reback'
						}
					})
				})
			}
		},
		//报批签发撤回
		reportsSubmitReback(row){
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => {
				await this.signetService.queryById(row.reportsSubmitId).then((data) => {
					if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.procInsIdReports).then((data) => {
							let form = {status: '3', id: row.reportsSubmitId}
							this.projectInfoService.updateReportsSubmitById(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},
		//报批签发审核
		reportsSubmitCheck(row){
			this.signetService.queryById(row.reportsSubmitId).then((data) => {
				if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoReports(row)
				}
			})
		},
		// 审核或重新调整跳转  报批签发
		todoReports (row) {
			let cUser = false
			this.signetService.queryById(row.reportsSubmitId).then((data) => {
				taskService.getTaskDefInfo({
					taskId: data.taskId
				}).then((data) => {
					this.$router.push({
						path: '/flowable/task/TaskForm',
						query: {
							...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId'),
							isShow: false,
							formReadOnly: true,
							formTitle: `${data.taskName}`,
							cUser: cUser,
							title: `审批【${data.taskName || ''}】`,
							routePath: '/jy/project/ProjectList'   // 数据处理后需要跳转的页面路径
						}
					})
				})
			})
		},
		//报批签发驳回后重新调整
		adjustReportsSubmit(row){
			this.signetService.queryById(row.reportsSubmitId).then((data) => {
				if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoReports(row)
				}
			})
		},
		//报批签发修改
		edit(row){
			// 读取流程表单
			let title = `发起流程【嘉溢-报批签发】`
			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[嘉溢-报批签发]`
			let status = 'startAndHold'
			if (row.reportsSubmit === '3') {
				status = 'startAndClose'
			} else if (row.reportsSubmit === '4') {
				status = 'reapplyFlag'
			}
			taskService.getTaskDef({ procDefId: this.processDefinitionReportsId,
				businessId: row.reportsSubmitId,
				businessTable: 'jy_user_signet'}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionReportsId,
						procDefKey: this.procDefKeyReports,
						title: title,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessTable: 'jy_user_signet',
						businessId: row.reportsSubmitId,
						isShow: 'false',
						status: status,
						routePath: '/jy/project/ProjectList'
					}
				})
			})
		},
		//项目归档
		archivePush(row){
			// 读取流程表单
			let title = `发起流程【嘉溢-项目归档】`
			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[嘉溢-项目归档]`
			let status = 'startAndHold'
			if (row.reviewStatus === '3') {
				status = 'startAndClose'
			} else if (row.reviewStatus === '4') {
				status = 'reapplyFlag'
			}
			taskService.getTaskDef({ procDefId: this.processDefinitionIdArchive,
				businessId: row.archiveId,
				businessTable: 'jy_project_archive'}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionIdArchive,
						procDefKey: this.procDefKeyArchive,
						title: title,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessTable: 'jy_project_archive',
						businessId: row.archiveId,
						isShow: 'false',
						status: status,
						routePath: '/jy/project/ProjectList'
					}
				})
			})
		},
		// 查询当前登录人是否是数据的审核人  归档
		checkIsAuditArchive (row) {
			let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
			if (this.commonJS.isNotEmpty(row.archiveId)) {
				for (const userId of row.archiveId) {
					if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
						return true
					}
				}
			}
			return false
		},
		//查看归档审批流程结果
		archiveDetail(row){
			if (row.reviewStatus !== '0' && row.reviewStatus !== '1') {
				// eslint-disable-next-line eqeqeq
				taskService.getTaskDef({
					procInsId: row.procInsIdArchive,
					procDefId: this.processDefinitionIdArchive
				}).then((data) => {
					this.$router.push({
						path: '/flowable/task/TaskFormDetail',
						query: {
							...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
							isShow: 'false',
							readOnly: true,
							title: '归档' + '流程详情',
							formTitle: '归档' + '流程详情',
							businessId: row.archiveId,
							status: 'reback'
						}
					})
				})
			}
		},
		//归档撤回
		archiveReback(row){
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => {
				await this.projectInfoService.findByIdArchive(row.archiveId).then((data) => {
					if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.procInsIdArchive).then((data) => {
							let form = {status: '3', id: row.archiveId}
							this.projectInfoService.updateStatusByArchiveId(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},
		//归档审核
		examineArchive(row){
			this.projectInfoService.findByIdArchive(row.archiveId).then((data) => {
				if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoArchive(row)
				}
			})
		},
		// 审核或重新调整跳转  归档
		todoArchive (row) {
			let cUser = false
			taskService.getTaskDefInfo({
				taskId: row.taskIdArchive
			}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId'),
						isShow: false,
						formReadOnly: true,
						formTitle: `${data.taskName}`,
						cUser: cUser,
						title: `审批【${data.taskName || ''}】`,
						routePath: '/jy/project/ProjectList'   // 数据处理后需要跳转的页面路径
					}
				})
			})
		},
		//归档驳回后重新调整
		adjustArchive(row){
			this.projectInfoService.findByIdArchive(row.archiveId).then((data) => {
				if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoArchive(row)
				}
			})
		},

		//环评资质
		eiaPush(row){
			// 读取流程表单
			let title = `发起流程【嘉溢-环评项目资质】`
			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[嘉溢-环评项目资质]`
			let status = 'startAndHold'
			if (row.eiaStatus === '3') {
				status = 'startAndClose'
			} else if (row.eiaStatus === '4') {
				status = 'reapplyFlag'
			}
			taskService.getTaskDef({ procDefId: this.processDefinitionIdEia,
				businessId: row.eiaId,
				businessTable: 'jy_project_eia_quelification'}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionIdEia,
						procDefKey: this.procDefKeyEia,
						title: title,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessTable: 'jy_project_eia_quelification',
						businessId: row.eiaId,
						isShow: 'false',
						status: status,
						routePath: '/jy/project/ProjectList'
					}
				})
			})
		},
		// 查询当前登录人是否是数据的审核人  环评资质
		checkIsAuditEia (row) {
			let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
			if (this.commonJS.isNotEmpty(row.eiaId)) {
				for (const userId of row.eiaId) {
					if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
						return true
					}
				}
			}
			return false
		},
		//查看环评资质审批流程结果
		eiaDetail(row){
			if (row.eiaStatus !== '0' && row.eiaStatus !== '1') {
				// eslint-disable-next-line eqeqeq
				taskService.getTaskDef({
					procInsId: row.procInsIdEia,
					procDefId: this.processDefinitionIdEia
				}).then((data) => {
					this.$router.push({
						path: '/flowable/task/TaskFormDetail',
						query: {
							...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
							isShow: 'false',
							readOnly: true,
							title: '环评资质' + '流程详情',
							formTitle: '环评资质' + '流程详情',
							businessId: row.eiaId,
							status: 'reback'
						}
					})
				})
			}
		},
		//环评资质撤回
		eiaReback(row){
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => {
				await this.projectInfoService.findByIdEia(row.eiaId).then((data) => {
					if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.procInsIdEia).then((data) => {
							let form = {status: '3', id: row.eiaId}
							this.projectInfoService.updateStatusByEiaId(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},
		//环评资质审核
		examineEia(row){
			this.projectInfoService.findByIdEia(row.eiaId).then((data) => {
				if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoEia(row)
				}
			})
		},
		// 审核或重新调整跳转  环评资质
		todoEia (row) {
			let cUser = false
			taskService.getTaskDefInfo({
				taskId: row.taskIdEia
			}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId'),
						isShow: false,
						formReadOnly: true,
						formTitle: `${data.taskName}`,
						cUser: cUser,
						title: `审批【${data.taskName || ''}】`,
						routePath: '/jy/project/ProjectList'   // 数据处理后需要跳转的页面路径
					}
				})
			})
		},
		//环评资质驳回后重新调整
		adjustEia(row){
			this.projectInfoService.findByIdEia(row.eiaId).then((data) => {
				if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoEia(row)
				}
			})
		},

		//发起报告签发
		reportIssuanceSubmit(row){
			// 读取流程表单
			let tabTitle = `发起流程【嘉溢-报告签发】`
			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了 [嘉溢-报告签发]`
			taskService.getTaskDef({ procDefId: this.processDefinitionReportsId,
				status: 'startAndHold'}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionReportsId,
						procDefKey: this.procDefKeyReports,
						status: 'startAndHold',
						title: tabTitle,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessId: row.sealId,
						isShow: false,
						routePath: '/jy/project/ProjectList'
					}
				})
			})
		},
		//报批报告撤回
		reportIssuanceReback(row){
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => {
				await this.signetService.queryById(row.sealId).then((data) => {
					if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.procInsReportIssuance).then((data) => {
							let form = {status: '3', id: row.sealId}
							this.projectInfoService.updateReportsSubmitById(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},
		//报告签发审核
		reportIssuanceCheck(row){
			this.signetService.queryById(row.sealId).then((data) => {
				if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoReportIssuance(row)
				}
			})
		},
		// 审核或重新调整跳转  报告签发
		todoReportIssuance (row) {
			let cUser = false
			this.signetService.queryById(row.sealId).then((data) => {
				taskService.getTaskDefInfo({
					taskId: data.taskId
				}).then((data) => {
					this.$router.push({
						path: '/flowable/task/TaskForm',
						query: {
							...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId'),
							isShow: false,
							formReadOnly: true,
							formTitle: `${data.taskName}`,
							cUser: cUser,
							title: `审批【${data.taskName || ''}】`,
							routePath: '/jy/project/ProjectList'   // 数据处理后需要跳转的页面路径
						}
					})
				})
			})
		},
		//报告签发驳回后重新调整
		adjustReportIssuance(row){
			this.signetService.queryById(row.sealId).then((data) => {
				if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoReportIssuance(row)
				}
			})
		},
		// 自定义服务端导出
		exportMethod ({ options }) {
			// 传给服务端的参数
			const params = {
				'current': this.tablePage.currentPage,
				'size': this.tablePage.pageSize,
				'orders': this.tablePage.orders,
				...this.searchForm,
				filename: options.filename,
				sheetName: options.sheetName,
				isHeader: options.isHeader,
				original: options.original,
				mode: options.mode,
				selectIds: options.mode === 'selected' ? options.map(item => item.id) : [],
				exportFields: options.columns.map(column => column.property)
			}
			return this.projectInfoService.exportFile(params).then((res) => {
				// 将二进制流文件写入excel表，以下为重要步骤
				this.$utils.downloadExcel(res, options.filename+ ".xls")
			}).catch(function (err) {
				if (err.response) {
					console.log(err.response)
				}
			})
		},

	}
}
</script>
