<template>
	<div class="page">
		<el-form :inline="true"  v-if="searchVisible" class="query-form m-b-10" 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="mobilePhone">
				<el-input v-model="searchForm.mobilePhone" placeholder="请输入手机号" clearable></el-input>
			</el-form-item>
			<el-form-item label="员工类型" prop="onJobStatus">
				<el-select v-model="searchForm.onJobStatus" placeholder="请选择" style="width:100%;" clearable>
					<el-option
						v-for="item in $dictUtils.getDictList('on_job_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="loginFlag">
				<el-select v-model="searchForm.loginFlag" placeholder="请选择" style="width:100%;" clearable>
					<el-option value="1" label="正常"></el-option>
					<el-option value="0" label="冻结"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item v-if="showHideItem" label="创建人" prop="createById">
				<UserSelectSignatory style="width: 100%" ref="userSelect2" :limit="1"
									 :readonly="true" :modelValue="searchForm.createById"
									 @update:modelValue='(value) => {searchForm.createById = value}'></UserSelectSignatory>			</el-form-item>
			<el-form-item v-if="showHideItem"  prop="officeId" label="部门">
				<SelectTree
					ref="officeTree"
					:props="{
                  value: 'id',             // ID字段名
                  label: 'name',         // 显示名称
                  children: 'children'    // 子级字段名
                }"

					:url="`/system-server/sys/office/treeData?type=2`"
					:value="searchForm.officeId"
					size="default"
					:accordion="true"
					@getValue="(value) => {searchForm.officeId=value}"/>
			</el-form-item>

			<el-form-item v-if="showHideItem" label="创建时间" prop="createDates">
				<el-date-picker
					placement="bottom-start"
					format="YYYY-MM-DD"
					value-format="YYYY-MM-DD"
					v-model="searchForm.createDates"
					type="daterange"
					range-separator="至"
					start-placeholder="开始日期"
					end-placeholder="结束日期">
				</el-date-picker>
			</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 ref="userToolbar" :refresh="{query: refreshList}" resizable import export custom>
				<template #buttons>
					<el-button v-if="hasPermission('entry:add')" :disabled="isAdmin" type="primary" icon="el-icon-plus" @click="add()">新建</el-button>
				</template>
				<template #tools>
					<vxe-button
						text
						type="primary"
						:title="searchVisible ? '收起检索' : '展开检索'"
						icon="vxe-icon-search"
						class="tool-btn"
						@click="searchVisible = !searchVisible"
					></vxe-button>
					<vxe-button
						type="text"
						title="下载导入模板"
						icon="vxe-icon-copy"
						class="tool-btn m-l-0"
						@click="downloadTpl()"
					>
					</vxe-button>
				</template>
			</vxe-toolbar>
			<div style="height: calc(100% - 90px)">
				<vxe-table
					border="inner"
					auto-resize
					resizable
					height="auto"
					:loading="loading"
					ref="userTable"
					show-header-overflow
					show-overflow
					highlight-hover-row
					:menu-config="{}"
					@sort-change="sortChangeHandle"
					:sort-config="{remote:true}"
					:import-config="{
									importMethod: importMethod,
									types: ['csv', 'xls', 'xlsx'],
									remote: true,
								}"
					:export-config="{
									remote: true,
									filename: `用户数据${moment(
										new Date()
									).format('YYYY-MM-DD')}`,
									sheetName: '用户数据',
									exportMethod: exportMethod,
									types: ['xlsx'],
									modes: ['current', 'selected', 'all'],
								}"
					:data="dataList"
					:checkbox-config="{}">
					<vxe-column type="seq" width="60" title="序号"></vxe-column>
					<vxe-column min-width="160" align="center" title="姓名" field="name">
						<template  #default="scope">
							<el-link  type="primary" :underline="false"  @click="view(scope.row)">{{scope.row.name}}</el-link>
						</template>
					</vxe-column>
					<vxe-column min-width="160" align="center" title="手机号" field="mobilePhone"></vxe-column>
					<vxe-column min-width="160" align="center" title="部门" field="departmentName"></vxe-column>
					<vxe-column  min-width="150px" align="center" title="员工类型" field="onJobStatus" fixed="right">
						<template #default="scope">
							{{ $dictUtils.getDictLabel("on_job_status", scope.row.onJobStatus, '-') }}						</template>
					</vxe-column>
					<vxe-column min-width="160" align="center" title="角色" field="roleName"></vxe-column>
					<vxe-column min-width="150px" title="状态" field="loginFlag" sortable>
						<template #default="{ row }">
							<el-tag v-if="row.loginFlag === '1'" type="success">正常</el-tag>
							<el-tag v-else-if="row.loginFlag === '0'" type="danger">冻结</el-tag>
						</template>
					</vxe-column>
					<vxe-column min-width="160" align="center" title="创建人" field="createName"></vxe-column>
					<vxe-column min-width="160" align="center" title="创建时间" field="createTime"></vxe-column>
					<vxe-column  min-width="150px" align="center" title="申请状态" field="type" fixed="right">
						<template #default="scope">
							<el-button @click="detail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.type, '')" effect="dark" >{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.type, '未登记')}} </el-button>
						</template>
					</vxe-column>
					<vxe-column  min-width="150px" align="center" title="转正状态" field="type" fixed="right">
						<template #default="scope">
							<el-button @click="detailApply(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.applyStatus, '')" effect="dark" >{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.applyStatus, '未登记')}} </el-button>
						</template>
					</vxe-column>
					<vxe-column title="操作"  min-width="150" fixed="right" align="center">
						<template  #default="scope">
							<div v-if="isJyAdmin">
								<el-button v-if="hasPermission('admin:edit') && isJyAdmin"  size="small" text type="primary"  @click="adminEdit(scope.row)">修改</el-button>
								<el-button text type="primary" size="small" v-if="hasPermission('admin:del') && isJyAdmin" @click="del(scope.row.id)">删除</el-button>
							</div>
							<div v-else-if="isRsb">
								<el-button   size="small" text type="primary"  @click="adminEdit(scope.row)">修改</el-button>
								<el-button v-if="scope.row.loginFlag === '1'"   size="small" text type="primary"  @click="updateLoginFlag(scope.row)">冻结</el-button>
								<el-button v-if="scope.row.loginFlag === '0'"   size="small" text type="primary"  @click="updateLoginFlag1(scope.row)">激活</el-button>
							</div>
							<div v-else>
								<el-button v-if="hasPermission('entry:edit')&&(scope.row.type === '0'||scope.row.type === '1'|| scope.row.type === '3')&&scope.row.createById === $store.state.user.id" size="small" text type="primary"  @click="edit(scope.row)">修改</el-button>
								<el-button text type="primary" size="small" v-if="hasPermission('entry:del') && scope.row.type==='0' || scope.row.type==='1'|| scope.row.type==='3'&&scope.row.createById === $store.state.user.id" @click="del(scope.row.id)">删除</el-button>
								<!--              当前申请人撤回-->
								<el-button v-if="hasPermission('entry:edit') && scope.row.createById === $store.state.user.id && scope.row.type==='2'" text type="primary" size="small" @click="reback(scope.row)">撤回</el-button>

								<el-button v-if="hasPermission('entry:edit') && scope.row.type==='2' && checkIsAudit(scope.row)" text type="primary" size="small" @click="examine(scope.row)">审核</el-button>
								<el-button v-if="hasPermission('entry:edit') && scope.row.type === '4'&&scope.row.createById === $store.state.user.id" text type="primary" size="small" @click="adjust(scope.row)">驳回调整</el-button>
								<!--转正申请								-->
								<el-button v-if="hasPermission('entry:edit') && scope.row.userId === $store.state.user.id && scope.row.type === '5' && scope.row.onJobStatus === '1' &&(scope.row.applyStatus === '0'||scope.row.applyStatus === '1'|| scope.row.applyStatus === '3')" text type="primary" size="small" @click="apply(scope.row)">转正申请</el-button>
								<el-button v-if="hasPermission('entry:edit') && scope.row.applyStatus==='2'" text type="primary" size="small" @click="rebackApply(scope.row)">撤回</el-button>

								<el-button v-if="hasPermission('entry:edit') && scope.row.applyStatus==='2' && checkIsAudit(scope.row)" text type="primary" size="small" @click="examineApply(scope.row)">审核</el-button>
								<el-button v-if="hasPermission('entry:edit') && scope.row.applyStatus === '4'" text type="primary" size="small" @click="adjustApply(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>
	<EntryDia ref="entryDia" @refreshList="refreshList"></EntryDia>
	</div>

</template>

<script>
	import UserSelect from '@/components/userSelect'
	import SelectTree from '@/components/treeSelect/treeSelect.vue'
	import EntryService from '@/api/jy/EntryService'
	import taskService from '@/api/flowable/taskService'
	import processService from '@/api/flowable/processService'
	import userService from '@/api/sys/userService'
	import pick from 'lodash.pick'
	import SupplierChooseForm from '@/views/materialManagement/supplier/SupplierChooseForm'
	import UserSelectSignatory from '../workClientInfo/clientUserSelect'
	import EntryDia from './EntryDia'
	export default {
		data () {
			return {
				dialogTableVisible:false,
				searchVisible: true,
				showHideItem: false,
				showHideIcon: 'el-icon-arrow-down',
				showHideName: '展示',
				num: 0,
				searchForm: {
					officeId: '',
					createById: '',
					createDates:[],
					name:'',
					mobilePhone:'',
					onJobStatus:'',
					loginFlag:'',

				},
				dataList: [],
				tablePage: {
					total: 0,
					currentPage: 1,
					pageSize: 10,
					orders: []
				},
				tableKey: '',
				loading: false,
				processDefinitionId: '',
				processDefinitionIdApply:'',
				procDefKey: '',
				procDefKeyApply: '',
				isAdmin: false,
				isRsb: false,
				isJyAdmin:false,
				create: '',
				gridData:[],
				typeData:[]
			}
		},
		EntryService:null,
		created () {
			this.entryService=new EntryService()
		},
		components: {
			SelectTree,
			UserSelect,
			SupplierChooseForm,
			UserSelectSignatory,
			EntryDia,

		},
		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.userTable;
				const $toolbar = this.$refs.userToolbar;
				$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 () {
				// 读取流程表单
				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/humanResources/EntryList'
						}
					})
				})
			},
			// 修改
			edit (row) {
				let tabTitle = `发起流程【嘉溢-入职申请】`
				let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了 [嘉溢-入职申请]`
				taskService.getTaskDef({ procDefId: this.processDefinitionId,
					businessId: row.id,
					businessTable: 'staff_user_info',
					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: row.id,
							businessTable: 'staff_user_info',
							isShow: false,
							routePath: '/jy/humanResources/EntryList'
						}
					})
				})
			},
			// 查看
			view (row) {
				this.$refs.entryDia.init('view',row.id);

			},
			// 查询当前用户是否是管理员用户
			checkIsAdmin () {
				userService.is().then((data) => {
					this.isAdmin = data
				})
			},
			//查询当前登录人的岗位是否是人事部
			checkIsRsb(){
				userService.isRsb().then((data)=>{
					this.isRsb = data
				})
			},
			// 获取数据列表
			refreshList () {
				this.loading = true
				this.entryService.list({
					'current': this.tablePage.currentPage,
					'size': this.tablePage.pageSize,
					'orders': this.tablePage.orders,
					...this.searchForm
				}).then((data) => {
					console.log('x',data.records)
					this.dataList = data.records
					this.tablePage.total = data.total
					this.tableKey = Math.random()
					this.loading = false
				})
				this.checkIsAdmin()
				this.checkIsRsb()
				this.checkIsJyAdmin()
				processService.getByName('嘉溢-入职申请').then((data) => {
					console.log('data',data)
					if (!this.commonJS.isEmpty(data.id)) {
						this.processDefinitionId = data.id
						this.procDefKey = data.key
					}
				})
				processService.getByName('嘉溢-转正申请').then((data) => {
					console.log('data',data)
					if (!this.commonJS.isEmpty(data.id)) {
						this.processDefinitionIdApply = data.id
						this.procDefKeyApply = 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
					this.entryService.delete(ids).then((data) => {
						this.$message.success(data)
						this.refreshList()
						this.loading = false
					})
				})
			},
			resetSearch () {
				this.$refs.searchForm.resetFields()
				this.searchForm.projectId = '' // 重置时清空项目id
				this.refreshList()
			},

			// 查看修改流程结果
			detail (row) {
				if (row.status !== '0' && row.status !== '1') {
					this.entryService.queryById(row.id).then((da)=>{
						// eslint-disable-next-line eqeqeq
						taskService.getTaskDef({
							procInsId: row.procInsId,
							procDefId: this.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'
								}
							})
						})
					})
				}
			},
			// 撤回入库修改
			reback (row) {
				this.$confirm(`确定要撤回该申请吗?`, '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.entryService.queryById(row.id).then((data) => {
						if (data.type !== '2') { // status的值不等于“审核中”，就弹出提示
							this.$message.error('数据已发生改变或不存在，请刷新数据')
							this.refreshList()
						} else {
							processService.revokeProcIns(row.procInsId).then((data) => {
								let form = {type: '3', id: row.id}
								this.entryService.updateStatusById(form)
								this.$message.success(data)
								this.refreshList()
							})
						}
					})
				})
			},
			// 驳回后调整
			adjust (row) {
				this.entryService.queryById(row.id).then((data) => {
					if (data.type !== '4') { // status的值不等于“驳回”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						this.todo(row)
					}
				})
			},
			// 审核
			examine (row) {
				this.entryService.queryById(row.id).then((data) => {
					if (data.type !== '2') { // 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'),
							isShow: false,
							formReadOnly: true,
							formTitle: `${data.taskName}`,
							cUser: cUser,
							title: `审批【${data.taskName || ''}】`,
							routePath: '/jy/humanResources/EntryList',   // 数据处理后需要跳转的页面路径
						}
					})
				})
			},
			// 查询当前登录人是否是数据的审核人
			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
			},

			adminEdit(row){
				this.$refs.entryDia.init('edit',row.id);
			},

			// 下载模板
			downloadTpl() {
				// this.$utils.downloadExcel('/sys/user/import/template')
				this.entryService
					.exportTemplate()
					.then((data) => {
						// 将二进制流文件写入excel表，以下为重要步骤
						this.$utils.downloadExcel(data, "用户导入模板");
					})
					.catch(function (err) {
						if (err.response) {
							console.log(err.response);
						}
					});
			},
			// 自定义服务端导入
			importMethod({ file }) {
				// 处理表单
				const formBody = new FormData();
				formBody.append("file", file);
				this.entryService.importExcel(formBody).then((result) => {
					this.$message.success({
						dangerouslyUseHTMLString: true,
						message: result,
					});
					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 && column.property.split(".")[0]
					),
				};
				this.loading = true;
				return this.entryService
					.exportExcel(params)
					.then((data) => {
						// 将二进制流文件写入excel表，以下为重要步骤
						this.$utils.downloadExcel(data, options.filename);
						this.loading = false;
					})
					.catch(function (err) {
						if (err.response) {
							console.log(err.response);
						}
					});
			},
			updateLoginFlag(row){
				userService.updateLoginFlag(row.userId).then((data)=>{
					this.refreshList()
				})
			},
			updateLoginFlag1(row){
				userService.updateLoginFlag1(row.userId).then((data)=>{
					this.refreshList()
				})
			},
			checkIsJyAdmin(){
				userService.checkIsJyAdmin().then((data)=>{
					this.isJyAdmin = data
				})
			},
			// 修改
			apply (row) {
				let tabTitle = `发起流程【嘉溢-转正申请】`
				let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了 [嘉溢-转正申请]`
				taskService.getTaskDef({ procDefId: this.processDefinitionIdApply,
					businessId: row.applyId,
					businessTable: 'jy_regular_apply',
					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.processDefinitionIdApply,
							procDefKey: this.procDefKeyApply,
							status: 'startAndHold',
							title: tabTitle,
							formType: data.formType,
							formUrl: data.formUrl,
							formTitle: processTitle,
							businessId: row.applyId,
							businessTable: 'jy_regular_apply',
							isShow: false,
							routePath: '/jy/humanResources/EntryList'
						}
					})
				})
			},
			// 查看修改流程结果
			detailApply (row) {
				if (row.applyStatus !== '0' && row.applyStatus !== '1') {
					this.entryService.queryByApplyId(row.applyId).then((da)=>{
						// eslint-disable-next-line eqeqeq
						taskService.getTaskDef({
							procInsId: row.procInsIdApply,
							procDefId: this.processDefinitionIdApply
						}).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.applyId,
									status: 'reback',
									method: 'view'
								}
							})
						})
					})
				}
			},
			// 撤回入库修改
			rebackApply (row) {
				this.$confirm(`确定要撤回该申请吗?`, '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.entryService.queryByApplyId(row.applyId).then((data) => {
						if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
							this.$message.error('数据已发生改变或不存在，请刷新数据')
							this.refreshList()
						} else {
							processService.revokeProcIns(row.procInsIdApply).then((data) => {
								let form = {status: '3', id: row.applyId}
								this.entryService.updateStatusByApplyId(form)
								this.$message.success(data)
								this.refreshList()
							})
						}
					})
				})
			},
			// 驳回后调整
			adjustApply (row) {
				this.entryService.queryByApplyId(row.applyId).then((data) => {
					if (data.status !== '4') { // status的值不等于“驳回”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						this.todoApply(row)
					}
				})
			},
			// 审核
			examineApply (row) {
				this.entryService.queryByApplyId(row.applyId).then((data) => {
					if (data.status !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						this.todoApply(row)
					}
				})
			},
			// 审核或重新调整跳转
			todoApply (row) {
				let cUser = false
				taskService.getTaskDefInfo({
					taskId: row.taskIdApply
				}).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/humanResources/EntryList',   // 数据处理后需要跳转的页面路径
						}
					})
				})
			},





		}
	}
</script>
