<template>
	<div class="page">
		<el-form :inline="true" class="query-form m-b-10" v-if="searchVisible" ref="searchForm" :model="searchForm"
			@keyup.enter.native="refreshList()" @submit.native.prevent>
			<!-- 搜索框-->
			<el-form-item label="项目编号" prop="projectNumber">
				<el-input v-model="searchForm.projectNumber" placeholder="请输入项目编号" clearable :style="styles"></el-input>
			</el-form-item>
			<el-form-item label="项目名称" prop="projectName">
				<el-input v-model="searchForm.projectName" placeholder="请输入项目名称" clearable :style="styles"></el-input>
			</el-form-item>
			<el-form-item label="报告名称" prop="reportName">
				<el-input v-model="searchForm.reportName" placeholder="请输入报告名称" clearable :style="styles"></el-input>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="项目经理1" prop="projectMasterName">
				<!--        <UserSelect :limit='1' :modelValue="searchForm.projectMasterName" @update:modelValue='(value, label) => {searchForm.projectMasterName = value}'></UserSelect>-->
				<el-input v-model="searchForm.projectMasterName" clearable placeholder="请选择项目经理1">
					<template #suffix>
						<el-button style="background-color: white;color: #1b1e25;border-color: white;" type="primary"
							slot="append" icon="el-icon-search" @click="openUserDia1">
						</el-button>
					</template>
				</el-input>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="项目经理2" prop="realHeaderName">
				<!--        <UserSelect :limit='1' :modelValue="searchForm.realHeaderName" @update:modelValue='(value, label) => {searchForm.realHeaderName = value}'></UserSelect>-->
				<el-input v-model="searchForm.realHeaderName" clearable placeholder="请选择项目经理2">
					<template #suffix>
						<el-button style="background-color: white;color: #1b1e25;border-color: white;" type="primary"
							slot="append" icon="el-icon-search" @click="openUserDia2">
						</el-button>
					</template>
				</el-input>
			</el-form-item>

			<el-form-item v-if="showHideItem" label="创建人" prop="createBy">
				<!--        <SelectUserTree-->
				<!--          ref="companyTree"-->
				<!--          :props="{-->
				<!--                  value: 'id',             // ID字段名-->
				<!--                  label: 'name',         // 显示名称-->
				<!--                  children: 'children'    // 子级字段名-->
				<!--                }"-->
				<!--          :url="`/system-server/sys/user/treeUserDataAllOffice?type=2`"-->
				<!--          :value="searchForm.createBy"-->
				<!--          :clearable="true"-->
				<!--		  size="default"-->
				<!--          :accordion="true"-->
				<!--          @getValue="(value) => {searchForm.createBy=value}"/>-->
				<el-input v-model="searchForm.createBy" placeholder="请选择创建人">
					<template #suffix>
						<el-button style="background-color: white;color: #1b1e25;border-color: white;" type="primary"
							slot="append" icon="el-icon-search" @click="openUserDia3">
						</el-button>
					</template>
				</el-input>
			</el-form-item>

			<!--<el-form-item label="创建人" prop="createBy">
			<el-input  v-model="searchForm.createBy" placeholder="创建人">
				<template #suffix>
					<el-button style="background-color: white;color: #1b1e25;border-color: white;" type="primary" slot="append" icon="el-icon-search" @click="openUserDia">
						&lt;!&ndash;						<UserSelect2  :modelValue="searchForm.assigneeId" :limit='1' @update:modelValue='(value, label) => {searchForm.assigneeId = value}'></UserSelect2>&ndash;&gt;
					</el-button>
				</template>
			</el-input>
		</el-form-item>-->


			<el-form-item v-if="showHideItem" label="报告文号" prop="reportNo">
				<el-input v-model="searchForm.reportNo" placeholder="请输入报告文号" clearable :style="styles"></el-input>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="审计收费(税前、元)" prop="contractAmounts">
				<InputNumber :disabled="false" :precision="num" :value="searchForm.contractAmounts"
					@changefrom="(val) => { searchForm.contractAmounts[0] = val }"
					@changeto="(val) => { searchForm.contractAmounts[1] = val }">
				</InputNumber>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="报备类型" prop="filingType">
				<el-select v-model="searchForm.filingType" placeholder="请选择" style="width:100%;">
					<el-option v-for="item in $dictUtils.getDictList('cw_work_client_report_type')" :key="item.value"
						:label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="报告号申请" prop="applyStatus">
				<el-select v-model="searchForm.applyStatus" placeholder="请选择" style="width:100%;">
					<el-option v-for="item in $dictUtils.getDictList('cw_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%;">
					<el-option v-for="item in $dictUtils.getDictList('cw_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="status1">
				<el-select v-model="searchForm.status1" placeholder="请选择" style="width:100%;">
					<el-option v-for="item in $dictUtils.getDictList('cw_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="contractDates">
				<el-date-picker placement="bottom-start" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss"
					v-model="searchForm.contractDates" type="datetimerange" range-separator="至" start-placeholder="开始日期"
					end-placeholder="结束日期">
				</el-date-picker>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="报告日期" prop="reportDates">
				<el-date-picker clearable placement="bottom-start" format="YYYY-MM-DD HH:mm:ss"
					value-format="YYYY-MM-DD HH:mm:ss" v-model="searchForm.reportDates" type="datetimerange"
					range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
				</el-date-picker>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="报告类型" prop="reportType">
				<el-select v-model="searchForm.reportType" placeholder="请选择" style="width:100%;" clearable>
					<el-option v-for="item in $dictUtils.getDictList('cw_report_title_type')" :key="item.value"
						:label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="项目分类" prop="projectClassification">
				<el-select v-model="searchForm.projectClassification" placeholder="请选择" style="width:100%;" clearable>
					<el-option v-for="item in $dictUtils.getDictList('project_classification')" :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 top" style="">
			<vxe-toolbar :refresh="{ query: refreshList }" ref="toolbarRef" export custom>
				<template #buttons>
					<el-button v-if="hasPermission('cw_work_client:info:add')" type="primary" icon="el-icon-plus"
						@click="start()">新建</el-button>
					<el-button type="warning" icon="el-icon-download" @click="exportAllSignatureFile()"
						:disabled="$refs.clientTable && $refs.clientTable.getCheckboxRecords().length === 0"
						plain>已盖章文件下载</el-button>
					<el-button v-if="hasPermission('cw_report_number:replace')" type="primary"
						@click="importReplaceNumber()" plain>报告号替换</el-button>
				</template>
				<template #tools>
					<vxe-button text type="primary" :title="searchVisible ? '收起检索' : '展开检索'" icon="vxe-icon-search"
						class="tool-btn" @click="searchVisible = !searchVisible"></vxe-button>
				</template>
			</vxe-toolbar>
			<div style="height: calc(100% - 90px)">
				<vxe-table border="inner" auto-resize resizable height="auto" :loading="loading" ref="clientTable"
					show-header-overflow show-overflow highlight-hover-row :print-config="{}" :export-config="{
						remote: true,
						filename: `报告信息${moment(new Date()).format('YYYY-MM-DD')}`,
						sheetName: '报告信息',
						exportMethod: exportMethod,
						types: ['xlsx'],
						modes: ['current', 'selected', 'all']
					}" :menu-config="{}" @sort-change="sortChangeHandle" :sort-config="{ remote: true }" :data="dataList"
					:checkbox-config="{}">
					<vxe-column type="seq" width="60" title="序号"></vxe-column>
					<vxe-column type="checkbox" width="60"></vxe-column>
					<vxe-column width="100" align="center" title="单据编号" field="documentNo">
						<template #default="scope">
							<el-link type="primary" :underline="false" v-if="hasPermission('cwProjectReport:list')"
								@click="view(scope.row.id)">{{ scope.row.documentNo }}</el-link>
							<el-link type="primary" :underline="false" v-else-if="hasPermission('cwProjectReport:list')"
								@click="view(scope.row.id,)">{{ scope.row.documentNo }}</el-link>
							<span v-else>{{ scope.row.documentNo }}</span>
						</template>
					</vxe-column>
					<vxe-column width="200" align="center" title="报告名称" field="reportName"></vxe-column>
					<vxe-column width="150" align="center" title="项目编号" field="projectNumber"></vxe-column>
					<vxe-column min-width="220" align="center" title="项目名称" field="projectName"></vxe-column>
					<vxe-column width="170" align="center" title="报告文号" field="reportNo"></vxe-column>
					<vxe-column width="80" align="center" title="创建人" field="userName"></vxe-column>
					<vxe-column width="120" align="center" title="报告所属部门" field="departmentName"></vxe-column>
					<vxe-column width="100" align="center" title="项目经理1" field="projectMasterName"></vxe-column>
					<vxe-column width="100" align="center" title="项目经理2" field="projectMaster2Name"></vxe-column>
					<vxe-column min-width="160" align="center" title="客户名称" field="servedUnitName"></vxe-column>
					<!--          <vxe-column min-width="160" align="center" title="报告主办人" field="reportSponsor"></vxe-column>-->
					<vxe-column width="110" align="center" title="创建时间" field="createTime"></vxe-column>
					<vxe-column min-width="100px" align="center" fixed="right" title="报告号申请" field="applyStatus">
						<template #default="scope">
							<el-button @click="detailApply(scope.row)" effect="dark"
								v-if="scope.row.applyStatus !== '0'"
								:type="$dictUtils.getDictLabel('cw_status_flag', scope.row.applyStatus, '-')">
								{{ $dictUtils.getDictLabel("cw_status", scope.row.applyStatus, '-') }}
							</el-button>
							<el-button v-else-if="scope.row.reviewStatus === '0'" effect="dark">
								未发起
							</el-button>

							<el-button @click="detailApplyReview(scope.row)" effect="dark"
								v-if="scope.row.improperTakeCause"
								:type="$dictUtils.getDictLabel('cw_status_flag', scope.row.applyReviewStatus, '-')">
								{{ $dictUtils.getDictLabel("cw_status", scope.row.applyReviewStatus, '-') }}
							</el-button>
						</template>
					</vxe-column>
					<vxe-column min-width="230px" align="center" fixed="right" title="复核签章状态" field="reviewStatus">
						<template #default="scope">
							<el-button @click="detail(scope.row)" effect="dark"
								:type="$dictUtils.getDictLabel('cw_status_flag', scope.row.reviewStatus, '-')">
								{{ $dictUtils.getDictLabel("cw_status", scope.row.reviewStatus, '-') }}
							</el-button>

							<el-button v-if="scope.row.signatureType === '1' && scope.row.newType === '0'"
								@click="detailS(scope.row)" effect="dark"
								:type="$dictUtils.getDictLabel('cw_status_flag', scope.row.status1, '-')">
								{{ scope.row.status1 === '5' ? '电子章已完成' : $dictUtils.getDictLabel("cw_status",
									scope.row.status1, '-') }}
							</el-button>
							<el-button v-else-if="scope.row.signatureType === '2' && scope.row.newType === '0'"
								@click="detailS2(scope.row)" effect="dark"
								:type="$dictUtils.getDictLabel('cw_project_report_sign_status_flag', scope.row.status2, '-')">
								{{ $dictUtils.getDictLabel("cw_project_report_sign_status", scope.row.status2, '-') }}
							</el-button>
							<el-button v-else-if="scope.row.signatureType === '3' && scope.row.newType === '0'"
								@click="detailS3(scope.row)" effect="dark"
								:type="$dictUtils.getDictLabel('cw_status_flag', scope.row.status3, '-')">
								{{ scope.row.status3 === '5' ? '实体章已完成' : $dictUtils.getDictLabel("cw_status",
									scope.row.status3, '-') }}
							</el-button>
							<el-button v-else-if="scope.row.newType === '0'" effect="dark">
								未发起
							</el-button>

						</template>
					</vxe-column>
					<!--<vxe-column  min-width="150px" align="center" fixed="right" title="签章状态" >
            <template #default="scope">

            </template>
          </vxe-column>-->
					<vxe-column min-width="100px" align="center" title="修改注师" field="signatureAnnotatorStatus">
						<template #default="scope">
							<el-button @click="detailSig(scope.row)" effect="dark"
								v-if="scope.row.signatureAnnotatorStatus !== '0'"
								:type="$dictUtils.getDictLabel('cw_status_flag', scope.row.signatureAnnotatorStatus, '-')">
								{{ $dictUtils.getDictLabel("cw_status", scope.row.signatureAnnotatorStatus, '-') }}
							</el-button>
							<el-button v-else effect="dark">
								未发起
							</el-button>
						</template>
					</vxe-column>
					<vxe-column min-width="100px" align="center" title="撤回签章" field="rebackStatus">
						<template #default="scope">
							<el-button @click="detailRevocation(scope.row)" effect="dark"
								v-if="scope.row.rebackStatus !== '0'"
								:type="$dictUtils.getDictLabel('cw_status_flag', scope.row.rebackStatus, '-')">
								{{ $dictUtils.getDictLabel("cw_status", scope.row.rebackStatus, '未发起') }}
							</el-button>
							<el-button v-else effect="dark">
								未发起
							</el-button>
						</template>
					</vxe-column>

					<vxe-column title="操作" width="300px" fixed="right" align="center">
						<template #default="scope">
							<div v-if="isAdmin">
								<el-button v-if="
									scope.row.reviewStatus === '5' && (
										(scope.row.signatureType === '1' && (scope.row.status1 === '0' || scope.row.status1 === '1' || scope.row.status1 === '3')) ||
										(scope.row.signatureType === '2' && (scope.row.status2 === '0' || scope.row.status2 === '1' || scope.row.status2 === '3')) ||
										(scope.row.signatureType === '3' && (scope.row.status3 === '0' || scope.row.status3 === '1' || scope.row.status3 === '3'))
									)" text type="primary" @click="edit(scope.row.id)">修改</el-button>
								<el-button v-if="
									scope.row.reviewStatus === '5' && (
										(scope.row.signatureType === '1' && (scope.row.status1 === '0' || scope.row.status1 === '1' || scope.row.status1 === '3')) ||
										(scope.row.signatureType === '2' && (scope.row.status2 === '0' || scope.row.status2 === '1' || scope.row.status2 === '3')) ||
										(scope.row.signatureType === '3' && (scope.row.status3 === '0' || scope.row.status3 === '1' || scope.row.status3 === '3'))
									)" text type="primary" @click="del(scope.row.id)">删除</el-button>
								<!-- 签章撤回 (只有管理员在签章完成后可使用此功能)-->
								<el-button v-if="((
									(scope.row.signatureType === '1' && scope.row.status1 === '5') ||
									(scope.row.signatureType === '2' && scope.row.status2 === '5') ||
									(scope.row.signatureType === '3' && scope.row.status3 === '5'))
									&& scope.row.newType === '0')" text type="primary" @click="rebackSign(scope.row)">撤回签章</el-button>
								<el-button v-if="((
									(scope.row.signatureType === '1' && scope.row.status1 === '5') ||
									(scope.row.signatureType === '2' && scope.row.status2 === '5') ||
									(scope.row.signatureType === '3' && scope.row.status3 === '5'))
									&& scope.row.newType !== '0')" text type="primary" @click="rebackReviewSign(scope.row)">撤回复核签章</el-button>
								<el-button
									v-if="(scope.row.applyStatus === '0' || scope.row.applyStatus === '1' || scope.row.applyStatus === '3' || commonJS.isEmpty(scope.row.applyStatus))"
									text type="primary" @click="del(scope.row.id)">删除</el-button>
								<!-- 撤回报告号申请及其后续所有流程 -->
								<el-button v-if="scope.row.applyStatus == '5'" text type="primary"
									@click="rebackApplyAndAll(scope.row)">撤回报告号申请</el-button>
							</div>
							<div v-else>
								<el-button v-if="$dictUtils.getDictValue('report_edit_flag', 'open', '0') == 1" text
									type="primary" @click="editApprovedAmount(scope.row.id)">审定金额修改</el-button>
								<el-button
									v-if="hasPermission('cwProjectReport:edit') &&
										(scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) &&
										scope.row.status === '5' &&
										(scope.row.reviewStatus === '0' || scope.row.reviewStatus === '1' || scope.row.reviewStatus === '3' || commonJS.isEmpty(scope.row.reviewStatus))"
									text type="primary" @click="edit(scope.row.id)">修改</el-button>

								<el-button
									v-else-if="hasPermission('cwProjectReport:del') &&
										(scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) &&
										scope.row.status === '5' &&
										(scope.row.reviewStatus === '0' || scope.row.reviewStatus === '1' || scope.row.reviewStatus === '3' || commonJS.isEmpty(scope.row.reviewStatus))"
									text type="primary" @click="del(scope.row.id)">删除</el-button>

								<el-button
									v-if="hasPermission('cwProjectReport:del') &&
										(scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) &&
										scope.row.status === '5' &&
										(scope.row.applyStatus === '0' || scope.row.applyStatus === '1' || scope.row.applyStatus === '3' || commonJS.isEmpty(scope.row.applyStatus))"
									text type="primary" @click="del(scope.row.id)">删除</el-button>

								<!--              审核-->
								<el-button v-if="scope.row.reviewStatus === '2' && checkIsAuditReview(scope.row)" text
									type="primary" @click="examineReview(scope.row)">审核</el-button>
								<!--              被驳回后当前申请人重新调整-->
								<el-button
									v-if="hasPermission('cw:workContract:filed') && scope.row.createById === $store.state.user.id && scope.row.reviewStatus === '4'"
									text type="primary" @click="adjustReview(scope.row)">驳回调整</el-button>
								<!--              复核流程-->
								<el-button
									v-if="hasPermission('cw:workContract:filed') && (scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) && scope.row.status === '5' && (scope.row.reviewStatus === undefined || scope.row.takeNumberType === '' || scope.row.reviewStatus === '0') && (scope.row.applyStatus === '0' || scope.row.applyStatus === '1' || scope.row.applyStatus === '3' || scope.row.applyStatus === undefined || scope.row.applyStatus === '')"
									text type="primary" @click="pushTakeNumber(scope.row)">报告号申请</el-button>
								<el-button
									v-if="hasPermission('cw:workContract:filed') && (scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) && scope.row.status === '5' && scope.row.applyStatus === '2'"
									text type="primary" @click="rebackApply(scope.row)">撤回报告号申请</el-button>
								<el-button
									v-if="hasPermission('cw:workContract:filed') && (scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) && scope.row.status === '5' && scope.row.applyStatus === '4'"
									text type="primary" @click="applyReview(scope.row)">报告号申请驳回调整</el-button>
								<el-button
									v-if="hasPermission('cw:workContract:filed') && (scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) && scope.row.status === '5' && (scope.row.takeNumberType === '2' || scope.row.takeNumberType === '0' || scope.row.applyReviewStatus === '5') && (scope.row.applyStatus === '5' || scope.row.reviewStatus !== '0') && (scope.row.reviewStatus === '0' || scope.row.reviewStatus === '1' || scope.row.reviewStatus === '3' || scope.row.reviewStatus === undefined || scope.row.reviewStatus === '')"
									text type="primary" @click="pushF(scope.row)">复核</el-button>
								<!-- 非正常取号 处理 -->
								<el-button
									v-if="hasPermission('cw:workContract:filed') && (scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) && scope.row.status === '5' && scope.row.takeNumberType !== '2' && scope.row.takeNumberType !== '0' && scope.row.applyStatus === '5' && (scope.row.applyReviewStatus === '0' || scope.row.applyReviewStatus === '1' || scope.row.applyReviewStatus === '3' || scope.row.applyReviewStatus === undefined || scope.row.applyReviewStatus === '')"
									text type="primary" @click="pushTakeNumberReview(scope.row)">取号复核</el-button>
								<el-button
									v-if="hasPermission('cw:workContract:filed') && (scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) && scope.row.status === '5' && scope.row.applyStatus === '5' && scope.row.applyReviewStatus === '2'"
									text type="primary" @click="rebackApplyReview(scope.row)">撤回报告号复核</el-button>
								<el-button
									v-if="hasPermission('cw:workContract:filed') && (scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) && scope.row.status === '5' && scope.row.applyStatus === '5' && scope.row.applyReviewStatus === '4'"
									text type="primary" @click="applyReviewAdjust(scope.row)">报告号复核驳回调整</el-button>

								<el-button
									v-if="hasPermission('cw:workContract:filed') && (scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) && scope.row.status === '5' && scope.row.reviewStatus === '2'"
									text type="primary" @click="rebackF(scope.row)">撤回复核申请</el-button>
								<!--              未选择盖章类型点击签章操作-->
								<el-button
									v-if="hasPermission('cw:workContract:filed') && (scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) && scope.row.status === '5' && scope.row.reviewStatus === '5' && !scope.row.signatureType && (this.commonJS.isEmpty(scope.row.newType) || scope.row.newType !== '1')"
									text type="primary" @click="pushS(scope.row)">签章</el-button>
								<!--公章流程-->
								<el-button
									v-if="hasPermission('cw:workContract:filed') && (scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) && scope.row.status === '5' && scope.row.reviewStatus === '5' && scope.row.signatureType === '1' && (this.commonJS.isEmpty(scope.row.newType) || scope.row.newType !== '1') && (scope.row.status1 === '0' || scope.row.status1 === '3')"
									text type="primary" @click="pushS(scope.row)">签章</el-button>
								<el-button
									v-if="hasPermission('cw:workContract:filed') && (scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) && scope.row.status === '5' && scope.row.reviewStatus === '5' && scope.row.signatureType === '1' && scope.row.status1 === '2' && (this.commonJS.isEmpty(scope.row.newType) || scope.row.newType !== '1')"
									text type="primary" @click="rebackS(scope.row)">撤回签章申请</el-button>
								<!--              实体章流程-->
								<el-button
									v-if="hasPermission('cw:workContract:filed') && (scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) && scope.row.status === '5' && scope.row.reviewStatus === '5' && scope.row.signatureType === '3' && (scope.row.status3 === '0' || scope.row.status3 === '3') && (this.commonJS.isEmpty(scope.row.newType) || scope.row.newType !== '1')"
									text type="primary" @click="pushS3(scope.row)">签章</el-button>
								<el-button
									v-if="hasPermission('cw:workContract:filed') && (scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) && scope.row.status === '5' && scope.row.reviewStatus === '5' && scope.row.signatureType === '3' && (scope.row.status3 === '2' || scope.row.status3 === '6' || scope.row.status3 === '7') && (this.commonJS.isEmpty(scope.row.newType) || scope.row.newType !== '1')"
									text type="primary" @click="rebackS3(scope.row)">撤回签章申请</el-button>
								<!--              公章+执业章流程-->
								<el-button
									v-if="hasPermission('cw:workContract:filed') && (scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) && scope.row.status === '5' && scope.row.reviewStatus === '5' && scope.row.signatureType === '2' && (scope.row.status2 === '0' || scope.row.status2 === '3') && (this.commonJS.isEmpty(scope.row.newType) || scope.row.newType !== '1')"
									text type="primary" @click="pushS2(scope.row)">公章+执业章</el-button>
								<el-button
									v-if="hasPermission('cw:workContract:filed') && (scope.row.createById === $store.state.user.id || haveProjectIds.includes(scope.row.projectId)) && scope.row.status === '5' && scope.row.reviewStatus === '5' && scope.row.signatureType === '2' && (scope.row.status2 === '2' || scope.row.status2 === '6' || scope.row.status2 === '7') && (this.commonJS.isEmpty(scope.row.newType) || scope.row.newType !== '1')"
									text type="primary" @click="rebackS2(scope.row)">撤回签章申请</el-button>
								<!--              签章  审核-->
								<el-button v-if="(
									(scope.row.signatureType === '1' && scope.row.status1 === '2') ||
									(scope.row.signatureType === '2' && scope.row.status2 === '2') ||
									(scope.row.signatureType === '3' && scope.row.status3 === '2')
								)
									&& checkIsAuditSign(scope.row) && (this.commonJS.isEmpty(scope.row.newType) || scope.row.newType !== '1')"
									@click="examineSign(scope.row)" text type="primary">审核</el-button>
								<!--              签章  被驳回后当前申请人重新调整-->
								<el-button
									v-if="(
										(scope.row.signatureType === '1' && scope.row.status1 === '4') ||
										(scope.row.signatureType === '2' && scope.row.status2 === '4') ||
										(scope.row.signatureType === '3' && scope.row.status3 === '4')
									)
										&& scope.row.createById === $store.state.user.id && (this.commonJS.isEmpty(scope.row.newType) || scope.row.newType !== '1')"
									@click="adjustSign(scope.row)" text type="primary">驳回调整</el-button>

								<!--			   	重新复核流程-->
								<el-button
									v-if="scope.row.reviewStatus === '5' && (scope.row.status1 === '5' || scope.row.status3 === '5') && (scope.row.signatureAnnotatorStatus === '5' || scope.row.signatureAnnotatorStatus === '0') && scope.row.createById === $store.state.user.id && scope.row.repetitionReviewFlag"
									text type="primary" @click="repetitionPushF(scope.row)">重新复核</el-button>

								<!--			   	修改签字注师流程-->
								<el-button
									v-if="scope.row.reviewStatus === '5' && (scope.row.status1 === '5' || scope.row.status3 === '5') && (scope.row.signatureAnnotatorStatus === '5' || scope.row.signatureAnnotatorStatus === '0') && scope.row.createById === $store.state.user.id"
									text type="primary" @click="updateSignatureAnnotator(scope.row)">修改签字注师</el-button>
								<!--				  审核-->
								<el-button
									v-if="scope.row.signatureAnnotatorStatus === '2' && checkIsAuditSign(scope.row) && scope.row.reviewStatus === '5' && (scope.row.status1 === '5' || scope.row.status3 === '5')"
									text type="primary" @click="pushSig(scope.row)">签字注师审核</el-button>
								<!--				  被驳回后当前申请人重新调整-->
								<el-button
									v-if="scope.row.signatureAnnotatorStatus === '4' && scope.row.createById === $store.state.user.id"
									text type="primary" @click="adjustSig(scope.row)">签字注师驳回调整</el-button>
								<!--				  签字注师撤回-->
								<el-button
									v-if="scope.row.signatureAnnotatorStatus === '2' && scope.row.createById === $store.state.user.id"
									text type="primary" @click="rebackSig(scope.row)">签字注师撤回</el-button>
								<!--				  撤回签章  发起-->
								<el-button
									v-if="((
										(scope.row.signatureType === '1' && scope.row.status1 === '5') ||
										(scope.row.signatureType === '2' && scope.row.status2 === '5') ||
										(scope.row.signatureType === '3' && scope.row.status3 === '5'))
										&& scope.row.newType !== '0' && scope.row.reviewStatus === '5' && scope.row.createById === $store.state.user.id && scope.row.repetitionReviewFlag === false && (scope.row.rebackStatus === '5' || scope.row.rebackStatus === '3' || scope.row.rebackStatus === '1' || scope.row.rebackStatus === '0' || scope.row.rebackStatus === null || scope.row.rebackStatus === '' || scope.row.rebackStatus === undefined))"
									text type="primary" @click="revocationEdit(scope.row)">撤回签章</el-button>
								<!--              审核-->
								<el-button v-if="scope.row.rebackStatus === '2' && checkIsAuditReview(scope.row)" text
									type="primary" @click="examineRevocation(scope.row)">审核</el-button>
								<!--              被驳回后当前申请人重新调整-->
								<el-button
									v-if="hasPermission('cw:workContract:filed') && scope.row.createById === $store.state.user.id && scope.row.rebackStatus === '4'"
									text type="primary" @click="adjustRevocation(scope.row)">驳回调整</el-button>
								<el-button
									v-if="hasPermission('cw:workContract:filed') && scope.row.createById === $store.state.user.id && scope.row.rebackStatus === '2'"
									text type="primary" @click="revocation(scope.row)">撤回</el-button>



							</div>
						</template>
					</vxe-column>
				</vxe-table>
				<vxe-pager background :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>
		</div>
		<ReportManagementForm ref="reportManagementForm" @refreshList="refreshList"></ReportManagementForm>
		<ReportApprovedAmountForm ref="reportApprovedAmountForm" @refreshList="refreshList"></ReportApprovedAmountForm>
		<ReportManagementAddForm ref="reportManagementAddForm" @refreshList="refreshList"></ReportManagementAddForm>

		<!--	  <user-select-->
		<!--		  ref="userSelect"-->
		<!--		  :limit="1"-->
		<!--		  @doSubmit="selectUsersToTransferTask"-->
		<!--	  ></user-select>-->
		<!--	  <user-select2-->
		<!--		  ref="userSelect2"-->
		<!--		  @doSubmit="selectUser">-->
		<!--	  </user-select2>-->
		<user-select1 ref="userSelect1" @doSubmit="selectUser1"></user-select1>
		<user-select2 ref="userSelect2" @doSubmit="selectUser2"></user-select2>
		<user-select3 ref="userSelect3" @doSubmit="selectUser3"></user-select3>
		<NumberReplace ref="numberReplace" @refreshList="refreshList"></NumberReplace>
	</div>
</template>

<script>
import InputNumber from '@/views/cw/workContract/InputNumber.vue'
import projectReportService from '@/api/cw/reportManagement/ProjectReportService'
import ReportReviewService from '@/api/cw/reportManagement/ReportReviewService'
import ReportNumberApplyService from '@/api/cw/reportManagement/ReportNumberApplyService'
import ProjectReportArchiveService from '@/api/cw/projectRecords/ProjectReportArchiveService'
import taskService from '@/api/flowable/TaskService'
import processService from '@/api/flowable/ProcessService'
import ReportManagementForm from './ReportManagementForm'
import ReportApprovedAmountForm from './ReportApprovedAmountForm'
import ReportManagementAddForm from './ReportManagementAddForm'
import pick from 'lodash.pick'
import userService from '@/api/sys/UserService'
import SelectUserTree from '@/views/utils/treeUserSelect'
import projectRecordsService from '@/api/cw/projectRecords/ProjectRecordsService'
import UserSelect from '@/views/cw/workClientInfo/clientUserSelect'
// import UserSelect2 from '@/components/userSelect2/UserSelectDialog';
import UserSelect1 from '@/views/utils/UserTreeSelectBySignatureScribe'
import UserSelect2 from '@/views/utils/UserTreeSelectBySignatureScribe'
import UserSelect3 from '@/views/utils/UserTreeSelect'
import NumberReplace from "./NumberReplace";
export default {
	data() {
		return {
			styles: {
				width: '200px !important'
			},
			searchVisible: true,
			showHideItem: false,
			showHideIcon: 'el-icon-arrow-down',
			showHideName: '展示',
			num: 0,
			searchForm: {
				contractAmounts: [],
				reportNo: '',
				reviewStatus: '',
				status1: '',
				applyStatus: '',	//报告号申请
				projectNumber: '',
				projectName: '',
				projectMasterId: '',
				projectMaster2Id: '',
				createBy: '',
				contractDates: [],
				projectMasterName: '', // 项目经理1
				realHeaderName: '', // 项目经理2
				filingType: '',
				cwReportType: '', //报告类型
				cwReportDates: [], // 报告日期
				projectClassification: '' //项目分类
			},
			dataList: [],
			tablePage: {
				total: 0,
				currentPage: 1,
				pageSize: 10,
				orders: []
			},
			tableKey: '',
			loading: false,
			processDefinitionAuditId: '',
			procDefAuditKey: '',
			processDefinitionAuditIdAndSId: '',
			procDefAuditKeyAndSId: '',
			isAdmin: false,
			create: '',
			processDefinitionSId: '',
			procDefSKey: '',
			processDefinitionSId2: '',
			procDefSKey2: '',
			processDefinitionSId3: '',
			procDefSKey3: '',
			haveProjectIds: '',
			processDefinitionSigId: '',
			procDefSigKey: '',
			processDefinitionTakeNumberAuditId: '',
			procDefTakeNumberAuditKey: '',
			processDefinitionTakeNumberSId: '',
			procDefSTakeNumberKey: '',
			processDefinitionTakeNumberReviewAuditId: '',
			procDefTakeNumberReviewAuditKey: '',
			processDefinitionReId: '',
			procDefReKey: '',
		}
	},
	reportReviewService: null,
	reportNumberApplyService: null,
	projectReportArchiveService: null,
	created() {
		this.projectReportArchiveService = new ProjectReportArchiveService()
		this.reportReviewService = new ReportReviewService()
		this.reportNumberApplyService = new ReportNumberApplyService()
	},
	components: {
		ReportManagementForm,
		ReportApprovedAmountForm,
		ReportManagementAddForm,
		SelectUserTree,
		InputNumber,
		UserSelect,
		UserSelect2,
		UserSelect1,
		UserSelect3,
		NumberReplace
	},
	computed: {
		userName() {
			return this.$store.state.user.name
		},
		user() {
			this.createName = this.$store.state.user.name
			return this.$store.state.user
		}
	},
	mounted() {
		this.$nextTick(() => {
			//将表格和工具栏进行关联
			const $table = this.$refs.clientTable;
			const $toolbar = this.$refs.toolbarRef;
			$table.connect($toolbar);
		})
		this.refreshList()
	},
	activated() {
		this.refreshList()
	},
	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.workClientForm.init('add', '')
			// this.$refs.reportManagementTaskForm.init('add', '')
			this.$refs.reportManagementForm.init('add', '', '')
		},
		// 修改
		edit(id) {
			id = id || this.$refs.clientTable.getCheckboxRecords().map(item => {
				return item.id
			})[0]
			// this.$refs.workClientForm.init('edit', id)
			// this.$refs.reportManagementTaskForm.init('edit', id)
			this.$refs.reportManagementForm.init('edit', id, '')
		},
		// 审定金额修改
		editApprovedAmount(id) {
			id = id || this.$refs.clientTable.getCheckboxRecords().map(item => {
				return item.id
			})[0]
			// this.$refs.workClientForm.init('edit', id)
			// this.$refs.reportManagementTaskForm.init('edit', id)
			this.$refs.reportApprovedAmountForm.init('edit', id, '')
		},

		// 查看
		view(id) {
			// this.$refs.workClientForm.init('view', id)
			// this.$refs.reportManagementTaskForm.init('view', id)
			this.$refs.reportManagementForm.init('view', id, '报告审核单下载')
		},
		// 查询当前用户是否是管理员用户
		checkIsAdmin() {
			userService.is().then((data) => {
				this.isAdmin = data
			})
		},
		// 获取数据列表
		refreshList() {
			this.loading = true
			projectReportService.list({
				'current': this.tablePage.currentPage,
				'size': this.tablePage.pageSize,
				'orders': this.tablePage.orders,
				...this.searchForm
			}).then((data) => {
				projectRecordsService.getHaveProjectIds().then((data) => {
					if (this.commonJS.isNotEmpty(data)) {
						this.haveProjectIds = data.map(i => {
							if (this.commonJS.isNotEmpty(i)) {
								return i
							}
						}).join(',')
					}
				})
				this.dataList = data.records
				this.tablePage.total = data.total
				this.tableKey = Math.random()
				this.loading = false
			})
			this.checkIsAdmin()
			processService.getByName('会计-报告复核').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionAuditId = data.id
					this.procDefAuditKey = data.key
				}
			})
			processService.getByName('会计-报告号申请').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionTakeNumberAuditId = data.id
					this.procDefTakeNumberAuditKey = data.key
				}
			})
			processService.getByName('会计-报告签章复核').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionTakeNumberSId = data.id
					this.procDefSTakeNumberKey = data.key
				}
			})
			processService.getByName('会计-报告号复核').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionTakeNumberReviewAuditId = data.id
					this.procDefTakeNumberReviewAuditKey = data.key
				}
			})
			processService.getByName('会计-复核及签章').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionAuditIdAndSId = data.id
					this.procDefAuditKeyAndSId = data.key
				}
			})
			processService.getByName('会计-报告签章-电子公章').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionSId = data.id
					this.procDefSKey = data.key
				}
			})
			processService.getByName('财务-报告签章-公章+执业章').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionSId2 = data.id
					this.procDefSKey2 = data.key
				}
			})
			processService.getByName('会计-报告签章-实体公章').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionSId3 = data.id
					this.procDefSKey3 = data.key
				}
			})
			processService.getByName('报告-修改签字注师').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionSigId = data.id
					this.procDefSigKey = data.key
				}
			})
			processService.getByName('会计-撤回签章').then((data) => {
				if (!this.commonJS.isEmpty(data.id)) {
					this.processDefinitionReId = data.id
					this.procDefReKey = 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()
		},
		// 删除
		del(id) {
			let ids = id || this.$refs.clientTable.getCheckboxRecords().map(item => {
				return item.id
			}).join(',')
			this.$confirm(`确定删除所选项吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.loading = true
				projectReportService.delete(ids).then((data) => {
					this.$message.success(data)
					this.refreshList()
					this.loading = false
				})
			})
		},
		resetSearch() {
			this.$refs.searchForm.resetFields()
			this.refreshList()
		},
		start() {
			this.$refs.reportManagementAddForm.init('add')
			// 读取流程表单
			/* let tabTitle = `发起流程【报告质控审核】`
			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了 [报告质控审核]`
			this.taskService.getTaskDef({ procDefId: this.processDefinitionAuditId,
			  status: 'startAndHold'}).then((data) => {
				this.$router.push({
				  path: '/flowable/task/TaskForm',
				  query: {
					...pick(data.data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
					procDefId: this.processDefinitionAuditId,
					procDefKey: this.procDefAuditKey,
					status: 'startAndHold',
					title: tabTitle,
					formType: data.data.formType,
					formUrl: data.data.formUrl,
					formTitle: processTitle,
					businessId: 'false',
					isShow: false,
					routePath: '/cw/reportManagement/ReportManagementList'
				  }
				})
			  }) */
		},
		// 发起客户登记
		/*push (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.processDefinitionAuditId,
			businessId: row.id,
			businessTable: 'cw_project_report'}).then((data) => {
			  this.$router.push({
				path: '/flowable/task/TaskForm',
				query: {
				  ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
				  procDefId: this.processDefinitionAuditId,
				  procDefKey: this.procDefAuditKey,
				  title: title,
				  formType: data.formType,
				  formUrl: data.formUrl,
				  formTitle: processTitle,
				  businessTable: 'cw_work_client_base',
				  businessId: row.id,
				  isShow: 'false',
				  status: status,
				  routePath: '/cw/reportManagement/ReportManagementList'
				}
			  })
			})
		},*/
		// 查看报告复核流程结果
		detail(row) {
			if (row.reviewStatus !== '0' && row.reviewStatus !== '1') {

				if (this.commonJS.isNotEmpty(row.newType) && row.newType === '1') {
					// eslint-disable-next-line eqeqeq
					taskService.getTaskDef({
						procInsId: row.procInsId3,
						procDefId: this.processDefinitionAuditIdAndSId
					}).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',
								detail: 'view'
							}
						})
					})
				} else if (this.commonJS.isNotEmpty(row.newType) && row.newType === '0') {
					// eslint-disable-next-line eqeqeq
					taskService.getTaskDef({
						procInsId: row.procInsId3,
						procDefId: this.processDefinitionAuditId
					}).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'
							}
						})
					})
				} else if (this.commonJS.isNotEmpty(row.newType) && row.newType === '2') {
					// eslint-disable-next-line eqeqeq
					taskService.getTaskDef({
						procInsId: row.procInsId3,
						procDefId: this.processDefinitionTakeNumberAuditId
					}).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'
							}
						})
					})
				}

			}
		},
		pushF(row) {
			// console.log('row', row)
			console.log('this.processDefinitionAuditIdAndSId', this.processDefinitionAuditIdAndSId)
			console.log('this.procDefAuditKeyAndSId', this.procDefAuditKeyAndSId)
			// 读取流程表单
			let title = ' '
			if (!row.documentNo) {
				title = ' ' + row.projectName
			} else {
				title = ' ' + row.documentNo + ' - ' + row.projectName
			}
			console.log('row', row)

			if (this.commonJS.isEmpty(row.newType) || row.newType !== '1') {

				let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了` + title + '[会计-报告复核]'
				let status = 'startAndClose'
				if (row.reviewStatus === '3') {
					status = 'startAndClose'
				} else if (row.reviewStatus === '4') {
					status = 'reapplyFlag'
				}

				taskService.getTaskDef({
					procDefId: this.processDefinitionAuditId,
					businessId: row.id,
					businessTable: 'cw_project_report_review'
				}).then((data) => {
					this.$router.push({
						path: '/flowable/task/TaskForm',
						query: {
							...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
							procDefId: this.processDefinitionAuditId,
							procDefKey: this.procDefAuditKey,
							title: title,
							formType: data.formType,
							formUrl: data.formUrl,
							formTitle: processTitle,
							businessTable: 'cw_project_report_review',
							businessId: row.id,
							isShow: 'false',
							status: status,
							routePath: '/cw/reportManagement/ReportManagementList'
						}
					})
				})
			} else if (row.newType === '1') {
				let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了` + title + '[会计-复核及签章]'
				let status = 'startAndClose'
				if (row.reviewStatus === '3') {
					status = 'startAndClose'
				} else if (row.reviewStatus === '4') {
					status = 'reapplyFlag'
				}

				taskService.getTaskDef({
					procDefId: this.processDefinitionAuditIdAndSId,
					businessId: row.id,
					businessTable: 'cw_project_report_review'
				}).then((data) => {
					this.$router.push({
						path: '/flowable/task/TaskForm',
						query: {
							...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
							procDefId: this.processDefinitionAuditIdAndSId,
							procDefKey: this.procDefAuditKeyAndSId,
							title: title,
							formType: data.formType,
							formUrl: data.formUrl,
							formTitle: processTitle,
							businessTable: 'cw_project_report_review',
							businessId: row.id,
							isShow: 'false',
							status: status,
							routePath: '/cw/reportManagement/ReportManagementList'
						}
					})
				})
			}
		},
		repetitionPushF(row) {
			this.$confirm(`是否确定对该报告重新复核?确定后原已盖章文件将被删除，已归档数据将被清除！`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				projectReportService.rebackReviewSign(row.id).then(() => {
					// 读取流程表单
					let title = ' '
					if (!row.documentNo) {
						title = ' ' + row.projectName
					} else {
						title = ' ' + row.documentNo + ' - ' + row.projectName
					}
					console.log('row', row)

					if (this.commonJS.isEmpty(row.newType) || row.newType !== '1') {

						let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了` + title + '[会计-报告复核]'
						let status = 'startAndClose'
						if (row.reviewStatus === '3') {
							status = 'startAndClose'
						} else if (row.reviewStatus === '4') {
							status = 'reapplyFlag'
						}

						taskService.getTaskDef({
							procDefId: this.processDefinitionAuditId,
							businessId: row.id,
							businessTable: 'cw_project_report_review'
						}).then((data) => {
							this.$router.push({
								path: '/flowable/task/TaskForm',
								query: {
									...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
									procDefId: this.processDefinitionAuditId,
									procDefKey: this.procDefAuditKey,
									title: title,
									formType: data.formType,
									formUrl: data.formUrl,
									formTitle: processTitle,
									businessTable: 'cw_project_report_review',
									businessId: row.id,
									isShow: 'false',
									status: status,
									routePath: '/cw/reportManagement/ReportManagementList'
								}
							})
						})
					} else if (row.newType === '1') {
						let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了` + title + '[会计-复核及签章]'
						let status = 'startAndClose'
						if (row.reviewStatus === '3') {
							status = 'startAndClose'
						} else if (row.reviewStatus === '4') {
							status = 'reapplyFlag'
						}

						taskService.getTaskDef({
							procDefId: this.processDefinitionAuditIdAndSId,
							businessId: row.id,
							businessTable: 'cw_project_report_review'
						}).then((data) => {
							this.$router.push({
								path: '/flowable/task/TaskForm',
								query: {
									...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
									procDefId: this.processDefinitionAuditIdAndSId,
									procDefKey: this.procDefAuditKeyAndSId,
									title: title,
									formType: data.formType,
									formUrl: data.formUrl,
									formTitle: processTitle,
									businessTable: 'cw_project_report_review',
									businessId: row.id,
									isShow: 'false',
									status: status,
									routePath: '/cw/reportManagement/ReportManagementList'
								}
							})
						})
					}
				}).catch(() => {
					this.refreshList()
					this.$message.error('签章已撤回')
				})
			})

		},
		pushTakeNumber(row) {
			// 读取流程表单
			let title = ' '
			if (!row.documentNo) {
				title = ' ' + row.projectName
			} else {
				title = ' ' + row.documentNo + ' - ' + row.projectName
			}

			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了` + title + '[会计-报告号申请]'
			let status = 'startAndClose'
			if (row.reviewStatus === '3') {
				status = 'startAndClose'
			} else if (row.reviewStatus === '4') {
				status = 'reapplyFlag'
			}
			taskService.getTaskDef({
				procDefId: this.processDefinitionTakeNumberAuditId,
				businessId: row.id,
				businessTable: 'cw_project_report_review'
			}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionTakeNumberAuditId,
						procDefKey: this.procDefTakeNumberAuditKey,
						title: title,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessTable: 'cw_project_report_review',
						businessId: row.id,
						isShow: 'false',
						status: status,
						routePath: '/cw/reportManagement/ReportManagementList'
					}
				})
			})
		},
		pushTakeNumberReview(row) {
			// 读取流程表单
			let title = ' '
			if (!row.documentNo) {
				title = ' ' + row.projectName
			} else {
				title = ' ' + row.documentNo + ' - ' + row.projectName
			}

			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了` + title + '[会计-报告号非正常取号复核]'
			let status = 'startAndClose'
			if (row.reviewStatus === '3') {
				status = 'startAndClose'
			} else if (row.reviewStatus === '4') {
				status = 'reapplyFlag'
			}
			taskService.getTaskDef({
				procDefId: this.processDefinitionTakeNumberReviewAuditId,
				businessId: row.id,
				businessTable: 'cw_project_report_review'
			}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionTakeNumberReviewAuditId,
						procDefKey: this.procDefTakeNumberReviewAuditKey,
						title: title,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessTable: 'cw_project_report_review',
						businessId: row.id,
						isShow: 'false',
						status: status,
						routePath: '/cw/reportManagement/ReportManagementList'
					}
				})
			})
		},
		pushS(row) {
			// 读取流程表单
			let title = `发起流程【会计-报告签章-电子公章】`
			let describe = `[会计-报告签章-电子公章`
			if (row.signatureType) {
				if (row.signatureType === 1) {
					title = `发起流程【会计-报告签章-电子公章】`
					describe = `[会计-报告签章-电子公章]`
				} else if (row.signatureType === 2) {
					title = `发起流程【会计-报告签章-电子公章+执业章】`
					describe = `[会计-报告签章-电子公章+执业章]`
				} else if (row.signatureType === 3) {
					title = `发起流程【会计-报告签章-实体公章】`
					describe = `[会计-报告签章-实体公章]`
				}
			} else {
				title = `发起流程【会计-报告签章】`
				describe = `[会计-报告签章]`
			}
			let processTitle = `${this.userName} 发起了 ${row.reportNo} - ${row.projectName} ` + describe
			let status = 'startAndClose'
			if (row.status1 === '3') {
				status = 'startAndClose'
			} else if (row.status1 === '4') {
				status = 'reapplyFlag'
			}
			if (row.newType === '2') {
				taskService.getTaskDef({
					procDefId: this.processDefinitionTakeNumberSId,
					businessId: row.id,
					businessTable: 'cw_project_report_signature'
				}).then((data) => {
					this.$router.push({
						path: '/flowable/task/TaskForm',
						query: {
							...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
							procDefId: this.processDefinitionTakeNumberSId,
							procDefKey: this.procDefSTakeNumberKey,
							title: title,
							formType: data.formType,
							formUrl: data.formUrl,
							formTitle: processTitle,
							businessTable: 'cw_project_report_signature',
							businessId: row.id,
							isShow: 'false',
							status: status,
							routePath: '/cw/reportManagement/ReportManagementList'
						}
					})
				})
			} else if (row.newType === '0') {
				taskService.getTaskDef({
					procDefId: this.processDefinitionSId,
					businessId: row.sid1,
					businessTable: 'cw_project_report_signature'
				}).then((data) => {
					this.$router.push({
						path: '/flowable/task/TaskForm',
						query: {
							...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
							procDefId: this.processDefinitionSId,
							procDefKey: this.procDefSKey,
							title: title,
							formType: data.formType,
							formUrl: data.formUrl,
							formTitle: processTitle,
							businessTable: 'cw_project_report_signature',
							businessId: row.sid1,
							isShow: 'false',
							status: status,
							routePath: '/cw/reportManagement/ReportManagementList'
						}
					})
				})
			}
		},
		pushS3(row) {
			// 读取流程表单
			let title = `发起流程【会计-报告签章-实体公章】`
			let processTitle = `${this.userName} 发起了 ${row.reportNo} - ${row.projectName} [会计-报告签章-实体公章]`
			let status = 'startAndClose'
			if (row.status3 === '3') {
				status = 'startAndClose'
			} else if (row.status3 === '4') {
				status = 'reapplyFlag'
			}
			taskService.getTaskDef({
				procDefId: this.processDefinitionSId3,
				businessId: row.sid3,
				businessTable: 'cw_project_report_signature'
			}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionSId3,
						procDefKey: this.procDefSKey3,
						title: title,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessTable: 'cw_project_report_signature',
						businessId: row.sid3,
						isShow: 'false',
						status: status,
						routePath: '/cw/reportManagement/ReportManagementList'
					}
				})
			})
		},
		// 查看报告签章-公章流程结果
		detailS(row) {
			if (row.status1 !== '0' && row.status1 !== '1') {
				// eslint-disable-next-line eqeqeq
				taskService.getTaskDef({
					procInsId: row.procInsId1,
					procDefId: this.processDefinitionSId
				}).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.sid1,
							status: 'reback'
						}
					})
				})
			}
		},
		// 查看报告签章-实体章流程结果
		detailS3(row) {
			if (row.status3 !== '0' && row.status3 !== '1') {
				// eslint-disable-next-line eqeqeq
				taskService.getTaskDef({
					procInsId: row.procInsIds3,
					procDefId: this.processDefinitionSId3
				}).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.sid3,
							status: 'reback'
						}
					})
				})
			}
		},
		// 撤回报告号申请
		rebackApply(row) {
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => { // 需要修改row.sid1
				await this.reportNumberApplyService.queryByReportId(row.id).then((data) => {
					if (data.reviewStatus !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.applyProcId).then((data) => {
							let form = { applyStatus: '3', id: row.id }
							this.reportNumberApplyService.updateReviewStatysByReportId(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},

		// 撤回报告号申请
		rebackApplyReview(row) {
			this.$confirm(`确定要撤回该报告号复核申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => { // 需要修改row.sid1
				await this.reportNumberApplyService.queryReviewByReportId(row.id).then((data) => {
					if (data.reviewStatus !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.applyReviewProcId).then((data) => {
							let form = { applyReviewStatus: '3', id: row.id }
							this.reportNumberApplyService.updateStatysReviewByReportId(form)
							this.$message.success(data)
							this.refreshList()
						})

					}
				})
			})
		},
		// 撤回报告号申请 包括 复核签章，归档 一并终止
		rebackApplyAndAll(row) {
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => {
				this.loading = true
				await this.reportNumberApplyService.queryByReportId(row.id).then((data) => {
					// 撤回归档，查询当前报告号的归档数据是否存在（归档数据可以通过报告数据的状态判断是否存在，但是严谨点，再查一次）
					this.projectReportArchiveService.list({
						size: 10,
						current: 1,
						cwProjectRecordsDTO: {
							projectName: '',
							projectMasterName: '',
							realHeaderName: '',
						},
						reportNo: data.reportNo
					}).then(async res => {
						if (res.records.length > 0) {
							// 若数据存在则进行终止流程，删除归档数据操作
							if (res.records[0].procInsId != '' && res.records[0].procInsId && res.records[0].procInsId != null) {
								processService.stop(res.records[0].procInsId, "撤回报告号自动终止")
							}
							// 若当前归档没有发起流程则删除归档数据即可
							this.projectReportArchiveService.deleteById(res.records[0].id)
						}
						// 复核签章的流程终止 和状态修改
						await projectReportService.rebackReviewSign(row.id)
						// 报告号申请的流程终止
						await processService.revokeProcIns(row.applyProcId)
						// 修改报告号申请流程状态
						let form = { applyReviewStatus: '3', id: row.id }
						await this.reportNumberApplyService.updateReviewStatysByReportId(form)
						// 撤回签章 的撤回
						// await projectReportService.queryByReId(row.revocationId)
						// await processService.stop(row.procInsReId)
						// // 修改 “撤回签章”状态
						// let form1 = { rebackStatus: '0', revocationId: row.revocationId }
						// await projectReportService.updateStatusByIdRe(form1)
						this.$message.success('撤回报告号申请成功')
						this.refreshList()
					})
				})
			})
		},
		// 撤回报告复核
		rebackF(row) {
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => { // 需要修改row.sid1
				await this.reportReviewService.queryByReportId(row.id).then((data) => {
					if (data.reviewStatus !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.procInsId3).then((data) => {
							let form = { reviewStatus: '3', id: row.id }
							this.reportReviewService.updateReviewStatysByReportId(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},
		// 撤回报告签章-公章的申请流程
		rebackS(row) {
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => {
				await projectReportService.findBySignatureId(row.sid1).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.sid1 }
							projectReportService.updateSignatureStatusById(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},
		// 撤回报告签章-实体章的申请流程
		rebackS3(row) {
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => {
				await projectReportService.findBySignatureId(row.sid3).then((data) => {
					if (data.status !== row.status3) { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.procInsIds3).then((data) => {
							let form = { status: '3', id: row.sid3 }
							projectReportService.updateSignatureStatusById(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},
		// 发起报告签章-公章+执业章流程
		pushS2(row) {
			// 读取流程表单
			let title = `发起流程【报告签章-公章+执业章】`
			let processTitle = `${this.userName} 发起了 ${row.reportNo} - ${row.projectName} [报告签章-公章+执业章]`
			let status = 'startAndClose'
			if (row.status2 === '3') {
				status = 'startAndClose'
			} else if (row.status2 === '4') {
				status = 'reapplyFlag'
			}
			taskService.getTaskDef({
				procDefId: this.processDefinitionSId2,
				businessId: row.sid2,
				businessTable: 'cw_project_report_signature'
			}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionSId2,
						procDefKey: this.procDefSKey2,
						title: title,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessTable: 'cw_project_report_signature',
						businessId: row.sid2,
						isShow: 'false',
						status: status,
						routePath: '/cw/reportManagement/ReportManagementList'
					}
				})
			})
		},
		// 查看报告签章-公章+执业章流程结果
		detailS2(row) {
			if (row.status2 !== '0' && row.status2 !== '1') {
				// eslint-disable-next-line eqeqeq
				taskService.getTaskDef({
					procInsId: row.procInsId2,
					procDefId: this.processDefinitionSId2
				}).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.sid2,
							status: 'reback'
						}
					})
				})
			}
		},
		// 撤回报告签章-公章+执业章的申请流程
		rebackS2(row) {
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(async () => {
				await projectReportService.findBySignatureId(row.sid2).then((data) => {
					if (data.status !== row.status2) { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.procInsId2).then((data) => {
							let form = { status: '3', id: row.sid2 }
							projectReportService.updateSignatureStatusById(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},
		// 自定义服务端导出
		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.data.map(item => item.id) : [],
				exportFields: options.columns.map(column => column.property)
			}
			return projectReportService.exportExcel(params).then((res) => {
				// 将二进制流文件写入excel表，以下为重要步骤
				this.$utils.downloadExcel(res, options.filename)
			}).catch(function (err) {
				if (err.response) {
					// console.log(err.response)
				}
			})
		},
		// 撤回签章
		rebackSign(row) {
			this.$confirm(`确定要撤回已完成的签章吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				projectReportService.rebackSign(row.id).then(() => {
					this.refreshList()
					this.$message.success('签章已撤回')
				}).catch(() => {
					this.refreshList()
					this.$message.error('签章已撤回')
				})
			})
		},
		// 撤回复核签章
		rebackReviewSign(row) {
			this.$confirm(`确定要撤回已完成的复核并重新签章吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				projectReportService.rebackReviewSign(row.id).then(() => {
					this.refreshList()
					this.$message.success('签章已撤回')
				}).catch(() => {
					this.refreshList()
					this.$message.error('签章已撤回')
				})
			})
		},
		// 驳回后调整
		adjustReview(row) {
			projectReportService.queryById(row.id).then((data) => {
				if (data.reviewStatus !== '4') { // status的值不等于“驳回”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoReview(row)
				}
			})
		},
		// 报告号申请 驳回后调整
		applyReview(row) {
			this.reportNumberApplyService.queryByReportId(row.id).then((data) => {
				if (data.reviewStatus !== '4') { // status的值不等于“驳回”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.applyTodoReview(row)
				}
			})
		},
		// 报告号申请 驳回后调整
		applyReviewAdjust(row) {
			this.reportNumberApplyService.queryReviewByReportId(row.id).then((data) => {
				if (data.reviewStatus !== '4') { // status的值不等于“驳回”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.applyTodoReviewAdjust(row)
				}
			})
		},
		// 审核或重新调整跳转
		applyTodoReview(row) {
			let cUser = false
			taskService.getTaskDefInfo({
				taskId: row.revTaskId2
			}).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: '/cw/reportManagement/ReportManagementList'   // 数据处理后需要跳转的页面路径
					}
				})
			})
		},
		// 审核或重新调整跳转
		applyTodoReviewAdjust(row) {
			let cUser = false
			taskService.getTaskDefInfo({
				taskId: row.reviewTaskNumberId
			}).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: '/cw/reportManagement/ReportManagementList'   // 数据处理后需要跳转的页面路径
					}
				})
			})
		},
		// 审核
		examineReview(row) {
			projectReportService.queryById(row.id).then((data) => {
				if (data.reviewStatus !== '2') { // status的值不等于“审核中”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoReview(row)
				}
			})
		},
		// 审核或重新调整跳转
		todoReview(row) {
			let cUser = false
			taskService.getTaskDefInfo({
				taskId: row.revTaskId
			}).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: '/cw/reportManagement/ReportManagementList'   // 数据处理后需要跳转的页面路径
					}
				})
			})
		},
		// 查询当前登录人是否是数据的审核人
		checkIsAuditReview(row) {
			let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
			if (this.commonJS.isNotEmpty(row.auditUserIdsRev)) {
				for (const userId of row.auditUserIdsRev) {
					if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
						return true
					}
				}
			}
			return false
		},
		// 驳回后调整
		adjustSign(row) {
			projectReportService.queryById(row.id).then((data) => {
				if (
					(data.signatureType === '1' && data.status1 !== '4') ||
					(data.signatureType === '2' && data.status2 !== '4') ||
					(data.signatureType === '3' && data.status3 !== '4')
				) { // status的值不等于“驳回”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoSign(row)
				}
			})
		},
		// 审核
		examineSign(row) {
			projectReportService.queryById(row.id).then((data) => {
				if (
					(data.signatureType === '1' && data.status1 !== '2') ||
					(data.signatureType === '2' && data.status2 !== '2') ||
					(data.signatureType === '3' && data.status3 !== '2')
				) { // status的值不等于“审核中”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoSign(row)
				}
			})
		},
		// 审核或重新调整跳转
		todoSign(row) {
			let cUser = false
			let taskId = row.signatureType === '1' ? row.signTaskId1
				: row.signatureType === '2' ? row.signTaskId2
					: row.signatureType === '3' ? row.signTaskId3
						: 'error'
			taskService.getTaskDefInfo({
				taskId: 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: '/cw/reportManagement/ReportManagementList'   // 数据处理后需要跳转的页面路径
					}
				})
			})
		},
		// 查询当前登录人是否是数据的审核人
		checkIsAuditSign(row) {
			let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
			if (row.signatureType === '1') {
				if (this.commonJS.isNotEmpty(row.auditUserIdsSign1)) {
					for (const userId of row.auditUserIdsSign1) {
						if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
							return true
						}
					}
				}
			}
			if (row.signatureType === '2') {
				if (this.commonJS.isNotEmpty(row.auditUserIdsSign2)) {
					for (const userId of row.auditUserIdsSign2) {
						if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
							return true
						}
					}
				}
			}
			if (row.signatureType === '3') {
				if (this.commonJS.isNotEmpty(row.auditUserIdsSign3)) {
					for (const userId of row.auditUserIdsSign3) {
						if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
							return true
						}
					}
				}
			}
			return false
		},
		//发起修改签字注师流程
		updateSignatureAnnotator(row) {
			// 读取流程表单
			let title = `发起流程【报告-修改签字注师】`
			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[报告-修改签字注师]`
			let status = 'startAndClose'
			if (row.signatureAnnotatorStatus === '2') {
				status = 'startAndClose'
			} else if (row.signatureAnnotatorStatus === '4') {
				status = 'reapplyFlag'
			}
			taskService.getTaskDef({
				procDefId: this.processDefinitionSigId,
				businessId: row.id,
				businessTable: 'cw_project_report_signature_annotator'
			}).then((data) => {
				console.log('qqq', data)
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionSigId,
						procDefKey: this.procDefSigKey,
						title: title,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessTable: 'cw_project_report_signature_annotator',
						businessId: row.id,
						isShow: 'false',
						status: status,
						routePath: '/cw/reportManagement/ReportManagementList'
					}
				})
			})
		},
		//查看报告-修改签字注师流程信息
		detailApply(row) {
			console.log('sigrow', row)
			if (row.applyStatus !== '0' && row.applyStatus !== '1') {
				// eslint-disable-next-line eqeqeq
				taskService.getTaskDef({
					procInsId: row.applyProcId,
					procDefId: this.processDefinitionTakeNumberAuditId
				}).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',
							sigId: row.id
						}
					})
				})
			}
		},
		//查看报告-修改签字注师流程信息
		detailApplyReview(row) {
			console.log('sigrow', row)
			if (row.applyReviewStatus !== '0' && row.applyReviewStatus !== '1') {
				// eslint-disable-next-line eqeqeq
				taskService.getTaskDef({
					procInsId: row.applyReviewProcId,
					procDefId: this.processDefinitionTakeNumberReviewAuditId
				}).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',
							sigId: row.id
						}
					})
				})
			}
		},
		//查看报告-修改签字注师流程信息
		detailSig(row) {
			console.log('sigrow', row)
			if (row.signatureAnnotatorStatus !== '0' && row.signatureAnnotatorStatus !== '1') {
				// eslint-disable-next-line eqeqeq
				taskService.getTaskDef({
					procInsId: row.procInsSigId,
					procDefId: this.processDefinitionSigId
				}).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',
							sigId: row.id
						}
					})
				})
			}
		},
		//审核报告-修改签字注师
		pushSig(row) {
			let title = ' '
			if (!row.documentNo) {
				title = ' ' + row.projectName
			} else {
				title = ' ' + row.documentNo + ' - ' + row.projectName
			}
			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了` + title + '[报告-修改签字注师]'
			let status = 'startAndClose'
			if (row.signatureAnnotatorStatus === '3') {
				status = 'approve'
			} else if (row.signatureAnnotatorStatus === '4') {
				status = 'reapplyFlag'
			}
			taskService.getTaskDef({
				procDefId: this.processDefinitionSigId,
				businessId: row.id,
				businessTable: 'cw_project_report_signature_annotator'
			}).then((data) => {
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionSigId,
						procDefKey: this.procDefSigKey,
						title: title,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessTable: 'cw_project_report_signature_annotator',
						businessId: row.id,
						isShow: 'false',
						status: status,
						routePath: '/cw/reportManagement/ReportManagementList'
					}
				})
			})
		},
		//修改签字注师驳回后调整
		adjustSig(row) {
			console.log('gg', row)
			projectReportService.queryById(row.id).then((data) => {
				if (data.signatureAnnotatorStatus !== '4') { // status的值不等于“驳回”，就弹出提示
					this.$message.error('数据已发生改变或不存在，请刷新数据')
					this.refreshList()
				} else {
					this.todoSig(row)
				}
			})
		},
		//驳回后重新调整
		todoSig(row) {
			console.log('XXX', row)
			let cUser = false
			taskService.getTaskDefInfo({
				taskId: row.taskSigId
			}).then((data) => {
				console.log('data', 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: '/cw/reportManagement/ReportManagementList'   // 数据处理后需要跳转的页面路径
					}
				})
			})
		},
		openUserDia() {
			this.$refs.userSelect2.init()
		},
		/**
		 * 签字注师撤回
		 * @param row
		 */
		rebackSig(row) {
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				projectReportService.queryById(row.id).then((data) => {
					if (data.signatureAnnotatorStatus !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.procInsSigId).then((data) => {
							let form = { signatureAnnotatorStatus: '0', id: row.id }
							projectReportService.updateStatusByIdSig(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},
		// 删除
		exportAllSignatureFile(id) {
			let ids = id || this.$refs.clientTable.getCheckboxRecords().map(item => {
				return item.id
			}).join(',')
			this.$confirm(`确定下载所选项的已盖章文件吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.loading = true
				projectReportService.exportAllSignatureFile(ids).then((res) => {
					// 将二进制流文件写入excel表，以下为重要步骤
					this.$utils.downloadZip(res, '已签章文件')
					this.loading = false
				}).catch(function (err) {
					this.loading = false
					if (err.response) {
						console.log(err.response)
					}
				})
			})
		},
		//撤回签章 发起
		revocationEdit(row) {
			// 读取流程表单
			let title = `发起流程【会计-撤回签章】`
			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[会计-撤回签章]`
			let status = 'startAndHold'
			if (row.rebackStatus === '3') {
				status = 'startAndClose'
			} else if (row.rebackStatus === '4') {
				status = 'reapplyFlag'
			}
			taskService.getTaskDef({
				procDefId: this.processDefinitionReId,
				businessId: row.revocationId,
				businessTable: 'cw_revocation_signature'
			}).then((data) => {
				console.log('qqq', data)
				this.$router.push({
					path: '/flowable/task/TaskForm',
					query: {
						...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
						procDefId: this.processDefinitionReId,
						procDefKey: this.procDefReKey,
						title: title,
						formType: data.formType,
						formUrl: data.formUrl,
						formTitle: processTitle,
						businessTable: 'cw_revocation_signature',
						businessId: row.id,
						isShow: 'false',
						status: status,
						routePath: '/cw/reportManagement/ReportManagementList'
					}
				})
			})
		},
		//撤回签章  撤回
		revocation(row) {
			console.log('row', row)
			this.$confirm(`确定要撤回该申请吗?`, '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				projectReportService.queryByReId(row.revocationId).then((data) => {
					if (data.rebackStatus !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						processService.revokeProcIns(row.procInsReId).then((data) => {
							let form = { rebackStatus: '3', revocationId: row.revocationId }
							projectReportService.updateStatusByIdRe(form)
							this.$message.success(data)
							this.refreshList()
						})
					}
				})
			})
		},
		// 撤回签章 审核或重新调整跳转
		examineRevocation(row) {
			let cUser = false
			taskService.getTaskDefInfo({
				taskId: row.revocationTaskId
			}).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: '/cw/reportManagement/ReportManagementList'   // 数据处理后需要跳转的页面路径
					}
				})
			})
		},
		//驳回后重新调整
		adjustRevocation(row) {
			console.log('XXX', row)
			let cUser = false
			taskService.getTaskDefInfo({
				taskId: row.revocationTaskId
			}).then((data) => {
				console.log('data', 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: '/cw/reportManagement/ReportManagementList'   // 数据处理后需要跳转的页面路径
					}
				})
			})
		},
		//查看报告-修改签字注师流程信息
		detailRevocation(row) {
			console.log('sigrow', row)
			if (row.rebackStatus !== '0' && row.rebackStatus !== '1') {
				// eslint-disable-next-line eqeqeq
				taskService.getTaskDef({
					procInsId: row.procInsReId,
					procDefId: this.processDefinitionReId
				}).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.revocationId,
							status: 'reback',
						}
					})
				})
			}
		},

		openUserDia1() {
			this.$refs.userSelect1.init()
		},
		selectUser1(user) {
			console.log(user[0].name)
			this.searchForm.projectMasterName = user[0].name
		},
		openUserDia2() {
			this.$refs.userSelect2.init()
		},
		selectUser2(user) {
			console.log(user[0].name)
			this.searchForm.realHeaderName = user[0].name
		},
		openUserDia3() {
			this.$refs.userSelect3.init()
		},
		selectUser3(user) {
			console.log(user[0].name)
			this.searchForm.createBy = user[0].name
		},
		//报告号替换
		importReplaceNumber() {
			this.$refs.numberReplace.init()
		}
	}
}
</script>
