<template>
	<div class="page">
		<el-form :inline="true" class="query-form" ref="searchForm" :model="searchForm" @keyup.enter.native="refreshList()" @submit.native.prevent>
			<!-- 搜索框-->
			<el-form-item label="客户名称" prop="primaryLinkman">
				<el-input v-model="searchForm.primaryLinkman" placeholder="请输入客户名称" clearable></el-input>
			</el-form-item>

			<el-form-item label="合同名称" prop="name">
				<el-input  v-model="searchForm.name" placeholder="请输入合同名称" clearable></el-input>
			</el-form-item>

			<el-form-item label="合同编号" prop="no">
				<el-input  v-model="searchForm.no" placeholder="请输入合同编号" clearable></el-input>
			</el-form-item>

			<el-form-item label="合同类型" prop="contractTypes">
				<el-cascader v-model="searchForm.contractTypes" :options="typeData" clearable  :props="{
					value: 'value',
					label: 'label', // 显示名称
					children: 'children', // 子级字段名
					multiple: false
					}"
				/>
			</el-form-item>

			<el-form-item v-if="showHideItem" label="签订日期" prop="contractDates">
				<el-date-picker
					placement="bottom-start"
					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="filedType">
				<el-select v-model="searchForm.filedType" placeholder="请选择" style="width:100%;">
					<el-option
						v-for="item in $dictUtils.getDictList('approval_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="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="createById">
				<UserSelectSignatory style="width: 100%" ref="userSelect2"
									 :readonly="true" :limit='1' :modelValue="searchForm.createById"
									 @update:modelValue='(value) => {searchForm.createById = value}'></UserSelectSignatory>			</el-form-item>

			<el-form-item v-if="showHideItem" label="登记时间" prop="createDates">
				<el-date-picker
					placement="bottom-start"
					v-model="searchForm.createDates"
					type="datetimerange"
					format="YYYY-MM-DD HH:mm:ss"
					value-format="YYYY-MM-DD HH:mm:ss"
					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">
			<vxe-toolbar ref="toolbarRef" :refresh="{query: refreshList}" export custom>
				<template #buttons>
					<el-button v-if="hasPermission('jy_work_contract:info:add')" :disabled="isAdmin" type="primary" icon="el-icon-plus" @click="add()">新建</el-button>
<!--					<el-button v-if="hasPermission('jy_work_contract:info:del')" type="danger"   icon="el-icon-delete" @click="del()" :disabled="$refs.workContractTable && $refs.workContractTable.getCheckboxRecords().length === 0" plain>删除</el-button>-->
				</template>
			</vxe-toolbar>
			<div class="jp-table-body">
				<vxe-table
					border="inner"
					auto-resize
					resizable
					height="auto"
					:loading="loading"
					size="small"
					ref="workContractTable"
					show-header-overflow
					show-overflow
					highlight-hover-row
					:menu-config="{}"
					:print-config="{}"
					@sort-change="sortChangeHandle"
					:export-config="{
									remote: true,
									filename: `嘉溢合同数据${moment(new Date()).format('YYYY-MM-DD')}`,
									sheetName: `嘉溢合同数据${moment(new Date()).format('YYYY-MM-DD')}`,
									exportMethod: exportMethod,
									types: ['xls'],
									modes: ['current', 'selected', 'all']
								  }"
					:sort-config="{remote:true}"
					:data="dataList"
					:checkbox-config="{}">
					<vxe-column type="seq" width="60" title="序号"></vxe-column>
<!--					<vxe-column type="checkbox" width="50px"></vxe-column>-->

					<vxe-column min-width="200px" title="合同编号" field="no" align="center"></vxe-column>
					<vxe-column min-width="200px" title="合同类型" field="contractType" align="center"></vxe-column>
					<vxe-column min-width="200px" title="合同名称" field="name" align="center">
						<template #default="scope">
							<el-link  type="primary" :underline="false" v-if="hasPermission('jy_work_contract:info:edit')" @click="view(scope.row.id)">{{scope.row.name}}</el-link>
							<el-link  type="primary" :underline="false" v-else-if="hasPermission('jy_work_contract:info:view')" @click="view(scope.row.id)">{{scope.row.name}}</el-link>
							<span v-else>{{scope.row.name}}</span>
						</template>
					</vxe-column>
					<vxe-column min-width="200px" title="客户名称" field="primaryLinkman" align="center"></vxe-column>
					<vxe-column min-width="100px" title="合同金额(元)" field="contractAmount" align="center"></vxe-column>
					<vxe-column min-width="100px" title="创建人" field="createName" align="center"></vxe-column>
					<vxe-column min-width="150px" title="创建时间" field="createTime" align="center"></vxe-column>
					<vxe-column min-width="100px"  title="状态" field="filedType" fixed="right" align="center">
						<template #default="scope">
							<el-button  @click="detailFiled(scope.row)" :type="$dictUtils.getDictLabel('approval_type_status', scope.row.filedType, '')" effect="dark">{{$dictUtils.getDictLabel("approval_type", scope.row.filedType, '未登记')}} </el-button>
						</template>
					</vxe-column>
					<!--                <vxe-column width="100px"  title="借用状态" field="borrowType" >-->
					<!--                  <template slot-scope="scope">-->
					<!--                    <el-button @click="detailBorrow(scope.row)" :type="$dictUtils.getDictLabel('borrow_type_status', scope.row.borrowType, '-')" effect="dark" size="small">{{$dictUtils.getDictLabel("borrow_type", scope.row.borrowType, '未借用')}} </el-button>-->
					<!--                  </template>-->
					<!--                </vxe-column>-->

					<vxe-column title="操作" width="200px" fixed="right" align="center">
						<template  #default="scope">
<!--							<div v-if="isAdmin">-->
<!--								<el-button  text type="primary"  @click="editForm(scope.row)">修改</el-button>-->
<!--								<el-button  text type="primary"  @click="deleteById(scope.row.id)">删除</el-button>-->
<!--							</div>-->
							<div>
								<!--归档暂存修改-->
								<el-button v-if="hasPermission('jy_work_contract:info:edit') && scope.row.createId === $store.state.user.id && (scope.row.filedType === '0' || scope.row.filedType === '1' ||scope.row.filedType === '3')" text type="primary"  @click="updateFiled(scope.row)">修改</el-button>
								<!--管理员修改-->
								<el-button v-if="hasPermission('admin:edit') && isJyAdmin" text type="primary"  @click="editForm(scope.row)">修改</el-button>
								<!--归档撤回-->
								<el-button v-if="hasPermission('jy_work_contract:info:back') && scope.row.filedType === '2'  && scope.row.createId === $store.state.user.id" text type="primary"   @click="rebackFiled(scope.row)">撤回</el-button>
								<!--              合同归档  审核-->
								<el-button v-if="scope.row.filedType==='2' && checkIsAudit(scope.row)" text type="primary"   @click="examineFiled(scope.row)">审核</el-button>
								<!--              合同归档  被驳回后当前申请人重新调整-->
								<el-button v-if="hasPermission('jy_work_contract:info:edit')&&scope.row.createId === $store.state.user.id&&scope.row.filedType === '4'" text type="primary"   @click="adjustFiled(scope.row)">驳回调整</el-button>
								<!--							删除-->
								<el-button v-if="hasPermission('jy_work_contract:info:del')&&(scope.row.filedType === '0' || scope.row.filedType === '1' || scope.row.filedType === '3') &&scope.row.createId === $store.state.user.id" text type="primary"  @click="deleteById(scope.row.id)">删除</el-button>
								<!--							管理员删除-->
								<el-button v-if="hasPermission('admin:del') && isJyAdmin" text type="primary"  @click="deleteById(scope.row.id)">删除</el-button>
							</div>
							</template>
					</vxe-column>
				</vxe-table>
				<vxe-pager
					background
					size="small"
					:current-page="tablePage.currentPage"
					:page-size="tablePage.pageSize"
					:total="tablePage.total"
					:page-sizes="[10, 20, 100, 1000, {label: '全量数据', value: 1000000}]"
					:layouts="['PrevPage', 'JumpNumber', 'NextPage', 'FullJump', 'Sizes', 'Total']"
					@page-change="currentChangeHandle">
				</vxe-pager>
			</div>
		</div>
		<!-- 弹窗, 新增 / 修改 -->
		<ContractAddForm ref="contractAddForm" @refreshDataList="refreshList"></ContractAddForm>
		<WorkClientForm ref="workClientForm" @refreshDataList="refreshList"></WorkClientForm>
	</div>
</template>

<script>
	import InputNumber from './InputNumber.vue'
	import WorkClientForm from '@/views/workClient/WorkClientForm'
	import WorkContractService from '@/api/jy/WorkContractService'
	import WorkContractFileService from '@/api/sys/WorkContractFileService'
	import SelectUserTree from '@/views/utils/treeUserSelect'
	import taskService from '@/api/flowable/taskService'
	import processService from '@/api/flowable/processService'
	import pick from 'lodash.pick'
	import userService from '@/api/sys/userService'
	import UserSelect from '@/components/userSelect'
	import ContractAddForm from './ContractAddForm'
	import dictService from "@/api/sys/dictService";
	import UserSelectSignatory from '../workClientInfo/clientUserSelect'
	export default {
		data () {
			return {
				typeData:[],
				showHideItem: false,
				showHideIcon: 'el-icon-arrow-down',
				showHideName: '展示',
				visible: false,
				num: 0,
				searchForm: {
					primaryLinkman: '',
					contractTypes: '',
					name: '',
					contractDates: [],
					filedType: '',
					contractAmounts: [],
					createById: '',
					procInsId: '',
					processDefinitionId: '',
					no:'',
					createDates:[]
				},
				dataList: [],
				tablePage: {
					total: 0,
					currentPage: 1,
					pageSize: 10,
					orders: []
				},
				processDefinitionId: '',
				procDefKey: '',
				loading: false,
				create: '',
				isAdmin: false,
				applyUserName: '',
				taskId:'',
				isJyAdmin:false
			}
		},
		workContractService: null,
		workContractFileService: null,
		// taskService: null,
		// processService: null,
		// userService: null,
		created () {
			this.workContractService = new WorkContractService()
			this.workContractFileService = new WorkContractFileService()
			// this.taskService = new TaskService()
			// this.processService = new ProcessService()
			// this.userService = new UserService()
		},
		components: {
			InputNumber,
			WorkClientForm,
			SelectUserTree,
			UserSelect,
			ContractAddForm,
			UserSelectSignatory
		},
		activated () {
			this.is()
			this.refreshList()
			this.getTypeList()
		},
		computed: {
			userName () {
				return this.$store.state.user.name
			},
			user () {
				this.create = this.$store.state.user.id
				return this.$store.state.user
			}
		},
		mounted() {
			this.$nextTick(() => {
				// 将表格和工具栏进行关联
				const $table = this.$refs.workContractTable;
				const $toolbar = this.$refs.toolbarRef;
				$table.connect($toolbar);
			});
			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 = '展示'
				}
			},
			// 获取数据列表
			refreshList () {
				this.loading = true
				this.workContractService.list({
					'current': this.tablePage.currentPage,
					'size': this.tablePage.pageSize,
					'orders': this.tablePage.orders,
					'itemType': '1',
					...this.searchForm
				}).then((data) => {
					this.dataList = data.records
					console.log('list',this.dataList)
					this.tablePage.total = data.total
					this.loading = false
				})
				this.checkIsJyAdmin()
				processService.getByName('嘉溢-合同归档').then((data) => {
					if (!this.commonJS.isEmpty(data.id)) {
						this.processDefinitionId = data.id
						this.procDefKey = data.key
					}
				})
			},
			//判断当前登陆人是否是admin
			checkIsJyAdmin(){
				userService.checkIsJyAdmin().then((data)=>{
					this.isJyAdmin = data
				})
			},
			// 当前页
			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()
			},
			//获取合同类型
			getTypeList(){
				dictService.getListData().then((data)=>{
					this.typeData=data
				})
			},
			// 新增
			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,
							formReadOnly: false,
							routePath: '/jy/workContractInfo/JyWorkContractList'
						}
					})
				})
			},
			// 管理员修改
			editForm (row) {
				this.$refs.contractAddForm.init('edit', row.id)
			},
			// 查看
			view (id) {
				this.$refs.contractAddForm.init('view', id)
			},
			// 客户信息查看
			viewInfo (id) {
				this.$refs.workClientForm.init('view', id)
			},
			// 删除
			del (id) {
				let ids = id || this.$refs.workContractTable.getCheckboxRecords().map(item => {
					return item.id
				}).join(',')
				this.$confirm(`确定删除所选项吗?`, '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.loading = true
					this.workContractService.remove(ids).then((data) => {
						this.$message.success(data)
						this.refreshList()
						this.loading = false
					})
				})
			},
			resetSearch () {
				this.applyUserName = ''
				this.searchForm.createById = ''
				this.$refs.searchForm.resetFields()
				this.refreshList()
			},
			// 归档撤回
			rebackFiled (row) {
				this.$confirm(`确定要撤回该申请吗?`, '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(async () => {
					await this.workContractService.findContractById(row.id).then((data) => {
						if (data.filedType !== '2') { // status的值不等于“审核中”，就弹出提示
							this.$message.error('数据已发生改变或不存在，请刷新数据')
							this.refreshList()
						} else {
							processService.revokeProcIns(data.procInsId).then(async (data) => {
								let form = {filedType: '3', id: row.id}
								await this.workContractService.updateStatusById(form)
								this.$message.success(data)
								this.refreshList()
							})
						}
					})
					// this.$confirm(`确定撤回流程吗?`, '提示', {
					//   confirmButtonText: '确定',
					//   cancelButtonText: '取消',
					//   taskId: row.taskFiledId,
					//   type: 'warning'
					// }).then(() => {
					//   console.log('datas', row.taskFiledId)
					//   this.taskService.backNodes(row.taskFiledId).then(({data}) => {
					//     let backNodes = data
					//     if (backNodes.length > 0) {
					//       let backTaskDefKey = backNodes[0].taskDefKey
					//       this.taskService.back({
					//         taskId: row.taskFiledId,
					//         backTaskDefKey: backTaskDefKey,
					//         isShow: false,
					//         ...this.auditForm
					//       }).then(({data}) => {
					//         this.updateStatusById(row, 'rebackFiled')
					//         this.$message.success('回退成功')
					//       })
					//     }
					//   })
				})
			},
			updateStatusById (row, type) {
				if (type === 'agree') {
					row.status = '5'
					this.workContractService.updateStatusById(row)
				}
				if (type === 'reject') {
					row.status = '4'
					this.workContractService.updateStatusById(row)
				}
				if (type === 'reback') {
					row.status = '3'
					this.workContractService.updateStatusById(row)
				}
				if (type === 'rebackFiled') {
					row.filedType = '3'
					this.workContractFileService.updateStatusById(row)
				}
				if (type === 'rebackBorrow') {
					row.borrowType = '0'
					this.workContractBorrowService.updateStatusByContractInfoId(row).then(() => {
						this.workContractBorrowService.deleteById(row.id)
					})
				}
				if (type === 'retureBorrow') {
					row.borrowType = '0'
					this.workContractBorrowService.updateStatusByContractInfoId(row).then(() => {
						row.type = 'reture'
						row.borrowType = '5'
						this.workContractBorrowService.updateMessageStatusById(row)
					})
				}
			},
			is () {
				userService.is().then((data) => {
					this.isAdmin = data
				})
			},
			// 归档
			// filed (id) {
			// 	processService.getByName('嘉溢-合同归档').then((data) => {
			// 		if (!this.commonJS.isEmpty(data.id)) {
			// 			// 读取流程表单
			// 			let tabTitle = `发起流程【嘉溢-合同归档】`
			// 			let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了 [嘉溢-合同归档]`
			// 			taskService.getTaskDef({ procDefId: data.id,
			// 				businessId: id,
			// 				businessTable: 'jy_work_contract_info',
			// 				status: 'audit',
			// 				method:'views'}).then((reture) => {
			// 				this.$router.push({
			// 					path: '/flowable/task/TaskForm',
			// 					query: {
			// 						...pick(data.data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
			// 						procDefId: data.id,
			// 						procDefKey: data.key,
			// 						status: 'startAndHoldFiled',
			// 						title: tabTitle,
			// 						formType: reture.formType,
			// 						formUrl: reture.formUrl,
			// 						formTitle: processTitle,
			// 						businessTable: 'jy_work_contract_info',
			// 						businessId: id,
			// 						isShow: false,
			// 						routePath: '/jy/workContractInfo/JyWorkContractList'
			// 					}
			// 				})
			// 			})
			// 			// 读取流程表单
			// 			// let tabTitle = `发起流程【合同登记归档】`
			// 			// let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了 [合同登记归档]`
			// 			// this.taskService.getTaskDef({ procDefId: data.id,
			// 			//   businessId: id,
			// 			//   businessTable: 'work_contract_file',
			// 			//   status: 'startAndHoldFiled'}).then((reture) => {
			// 			//     this.$router.push({
			// 			//       path: '/flowable/task/TaskForm',
			// 			//       query: {
			// 			//         procDefId: data.id,
			// 			//         procDefKey: data.key,
			// 			//         status: 'startAndHoldFiled',
			// 			//         title: tabTitle,
			// 			//         formType: reture.data.formType,
			// 			//         formUrl: reture.data.formUrl,
			// 			//         formTitle: processTitle,
			// 			//         businessTable: 'work_contract_file',
			// 			//         businessId: id,
			// 			//         isShow: false,
			// 			//         routePath: '/workContract/WorkContractList'
			// 			//       }
			// 			//     })
			// 			//   })
			// 		}
			// 	})
			// },
			//修改
			//暂存修改
			updateFiled(row){
				let tabTitle = `发起流程【嘉溢-合同登记】`
				let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[嘉溢-合同登记]`
				let status = 'startAndHold'
				if (row.filedType === '3') {
					status = 'startAndClose'
				} else if (row.filedType === '4') {
					status = 'reapplyFlag'
				}
				taskService.getTaskDef({ procDefId: this.processDefinitionId,
					businessId: row.id,
					businessTable: 'jy_work_contract_info'}).then((data) => {
					this.$router.push({
						path: '/flowable/task/TaskForm',
						query: {
							...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
							procDefId: this.processDefinitionId,
							procDefKey: this.procDefKey,
							title: tabTitle,
							formType: data.formType,
							formUrl: data.formUrl,
							formTitle: processTitle,
							businessTable: 'jy_work_contract_info',
							businessId: row.id,
							isShow: 'false',
							status: status,
							routePath: '/jy/workContractInfo/JyWorkContractList'
						}
					})
				})
			},
			// 归档详情
			detailFiled (row) {
				if (row.filedType !== '4') {
					this.workContractService.findContractById(row.id).then((data) => {
						if (!this.commonJS.isEmpty(data.id)) {
							taskService.getTaskDef({
								procInsId: data.procInsId,
								procDefId: data.processDefinitionId
							}).then((data) => {
								this.$router.push({
									path: '/flowable/task/TaskFormDetail',
									query: {
										...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
										readOnly: true,
										title: '合同登记流程详情',
										formTitle: '合同登记流程详情',
										businessId: row.id
									}
								})
							})
						}
					})
				}
			},
			// 审核或重新调整跳转
			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/workContractInfo/JyWorkContractList'   // 数据处理后需要跳转的页面路径
						}
					})
				})
			},
			// 查询当前登录人是否是数据的审核人
			checkIsAudit (row) {
				let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
				if (this.commonJS.isNotEmpty(row.auditUserIdsFiled)) {
					for (const userId of row.auditUserIdsFiled) {
						if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
							return true
						}
					}
				}
				return false
			},
			// 驳回后调整
			adjustFiled (row) {
				this.workContractService.findContractById(row.id).then((data) => {
					if (data.filedType !== '4') { // status的值不等于“驳回”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						this.todoFiled(row)
					}
				})
			},
			// 审核
			examineFiled (row) {
				this.workContractService.findContractById(row.id).then((data) => {
					if (data.filedType !== '2') { // status的值不等于“审核中”，就弹出提示
						this.$message.error('数据已发生改变或不存在，请刷新数据')
						this.refreshList()
					} else {
						this.todoFiled(data)
					}
				})
			},
			// 审核或重新调整跳转
			todoFiled (row) {
				console.log('row',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/workContractInfo/JyWorkContractList'   // 数据处理后需要跳转的页面路径
						}
					})
				})
			},
			// 查询当前登录人是否是数据的审核人
			checkIsAuditFiled (row) {
				let loginUserId = this.$store.state.user.id  // 获取当前登录用户id
				if (this.commonJS.isNotEmpty(row.auditUserIdsFiled)) {
					for (const userId of row.auditUserIdsFiled) {
						if (userId === loginUserId) {  // 当数据的审核人中包含当前登录人id时，返回true
							return true
						}
					}
				}
				return false
			},
			// 删除
			deleteById (id) {
				this.$confirm(`确定删除所选项吗?`, '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.loading = true
					this.workContractService.deleteById(id).then((data) => {
						this.$message.success(data)
						this.refreshList()
						this.loading = false
					})
				})
			},
			// 自定义服务端导出
			exportMethod ({ options }) {
				// 传给服务端的参数
				const params = {
					'current': this.tablePage.currentPage,
					'size': this.tablePage.pageSize,
					'orders': this.tablePage.orders,
					...this.searchForm,
					filename: options.filename,
					sheetName: options.sheetName,
					isHeader: options.isHeader,
					original: options.original,
					mode: options.mode,
					selectIds: options.mode === 'selected' ? options.map(item => item.id) : [],
					exportFields: options.columns.map(column => column.property)
				}
				return this.workContractService.exportFile(params).then((res) => {
					// 将二进制流文件写入excel表，以下为重要步骤
					this.$utils.downloadExcel(res, options.filename+ ".xls")
				}).catch(function (err) {
					if (err.response) {
						console.log(err.response)
					}
				})
			},
		}
	}
</script>
