<template>
	<view>
		<step-title :stepPage="stepsPage" :stepText="stepsText"></step-title>
		<view class="form-sub" v-if="stepsPage === 0">
			<u-form :model="dataModel" ref="wForm" label-width="90px" class="demo-ruleForm" size="mini">
				<view style="position: relative;">
					<view style="position: absolute;left: -10px;color: #3d4b70;top: -3px;">*</view>
				</view>

				<view style="font-size: 15px; font-weight: bold;color: #3d4b70;margin-bottom: 10px;">基本信息填写</view>
				<u-form-item label="审核意见" prop="CONTEXT" v-if="dataModel.IS_PUBLISH == 9">
				</u-form-item>
				<u-textarea v-html="dataModel.CONTEXT" border="surround" v-if="dataModel.IS_PUBLISH == 9" disabled style="font-size: 14px;color: red;"></u-textarea>
				<u-form-item label="作业名称" prop="Nav_OperationStep.NAME" @click="handleChangeStep(dataModel.Nav_OperationStep)">
					<!-- @click="handleShowSheet({title: '作业名称', name: 'stepName'})" -->
					<u--input disabledColor="#fff" v-model="dataModel.Nav_OperationStep.NAME" disabled placeholder="请选择作业名称" suffixIcon="arrow-right" suffixIconStyle="font-size:12px" fontSize="14px"
						customStyle="margin:0px;display:flex;padding:3px 9px" border="none">
					</u--input>

				</u-form-item>
				<u-form-item label="审批层级" prop="AUDIT_LEVEL_SHOW">
					<u--input disabledColor="#fff" v-model="dataModel.AUDIT_LEVEL_SHOW" disabled fontSize="14px" placeholder="请先选择作业名称" customStyle="margin:0px;display:flex;padding:3px 9px" border="none"></u--input>
				</u-form-item>
				<u-form-item label="监护人" prop="Nav_MonitorUser.NAME" @click="handleChangeMonitor(dataModel.Nav_MonitorUser)">
					<!-- @click="handleShowSheet({title: '监护人', name: 'monitorUser'})" -->
					<u--input disabledColor="#fff" v-model="dataModel.Nav_MonitorUser.NAME" disabled placeholder="请选择监护人" suffixIcon="arrow-right" suffixIconStyle="font-size:12px" fontSize="14px"
						customStyle="margin:0px;display:flex;padding:3px 9px" border="none">
					</u--input>
				</u-form-item>
				<u-form-item label="作业申请人" prop="Nav_ApplyUser.NAME" @click="handleShowSheet({title: '作业申请人', name: 'applyUser'})">
					<u--input disabledColor="#fff" v-model="dataModel.Nav_ApplyUser.NAME" disabled placeholder="请选择作业申请人" suffixIcon="arrow-right" suffixIconStyle="font-size:12px" fontSize="14px"
						customStyle="margin:0px;display:flex;padding:3px 9px" border="none">
					</u--input>
				</u-form-item>
				<u-form-item label="开始时间" prop="JOB_DATE" @click="showCheckDate({ name: 'jobDate'})">
					<u--input disabledColor="#fff" v-model="dataModel.JOB_DATE" disabled placeholder="请选择开始时间" suffixIcon="arrow-right" suffixIconStyle="font-size:12px" fontSize="14px"
						customStyle="margin:0px;display:flex;padding:3px 9px" border="none">
					</u--input>
				</u-form-item>
				<u-form-item label="结束时间" prop="JOB_END_DATE" @click="showCheckDate({name: 'endDate'})">
					<!-- <el-col class="line" :span="2">-</el-col> -->
					<u--input disabledColor="#fff" v-model="dataModel.JOB_END_DATE" disabled placeholder="请选择结束时间" suffixIcon="arrow-right" suffixIconStyle="font-size:12px" fontSize="14px"
						customStyle="margin:0px;display:flex;padding:3px 9px" border="none">
					</u--input>
				</u-form-item>
				<u-form-item label="作业地点" prop="JOB_LOCATION" class="lkwandoa1">
					<u--textarea v-model="dataModel.JOB_LOCATION" placeholder="请输入内容" autoHeight border="none"></u--textarea>
					<!-- <u--input v-model="dataModel.JOB_LOCATION" placeholder="请输入内容" fontSize="14px"></u--input> -->
				</u-form-item>
				<u-form-item label="作业原因" prop="JobCause">
					<u--textarea v-model="dataModel.JobCause" placeholder="请输入内容" autoHeight border="none"></u--textarea>
					<!-- <u--input v-model="dataModel.JobCause" placeholder="请输入内容" fontSize="14px"></u--input> -->
				</u-form-item>
			</u-form>

		</view>
		<view style="padding: 20px 16px; margin-bottom: 120px; margin-top: 20px;" v-if="stepsPage === 0">
			<u-button type="primary" @click="stepAdd" color="#3d4b70">下一步</u-button>
		</view>
		<view>
			<view class="sub-form" v-if="stepsPage === 1">
				<u--form labelPosition="left" labelWidth="90px" ref="sForm" class="demo-ruleForm" size="mini">
					<view class="form-sub-add" v-for="(item, index) in dataModel.Nav_CrucialLicensePerson" :key="index">
						<view>
							<view style="position: relative;" v-if="index==0">
								<view style="position: absolute;left: -10px;color: #3d4b70;top: -3px;">*</view>
							</view>
							<view style="display: flex;flex-direction: row;align-items: center;justify-content: space-between;padding-bottom: 10px;" :style="index > 0?'border-top: #e7e6e4 1px solid;padding-top:10px':''">
								<view style="font-size: 15px; font-weight: bold;color: #3d4b70;display: flex;flex-direction: row;align-items: center;">
									作业人员信息
									<u-badge :value="index+1" bgColor="#3d4b70" style="margin-left: 5px;"></u-badge>
									<view v-if="index>0" style="margin-left: 10px;">
										<view style="display: flex;align-items: center;" v-if="thisUser.indexOf(index)!==-1" @click="handleAddUserPush(index)">
											<u-icon name="arrow-down"></u-icon>
										</view>
										<view style="display: flex;align-items: center;" v-if="thisUser.indexOf(index)==-1" @click="handleAddUserPush(index)">
											<u-icon name="arrow-up"></u-icon>
										</view>
									</view>
								</view>
								<view style="font-size: 15px;align-items: center;" v-if="thisUser.indexOf(index)!==-1">
									{{item['Nav_User'].NAME}}
								</view>
								<view v-if="index > 0" @click="handleDelRowBefore(index)" style="padding: 0px 0px 0px 20px;">
									<u-icon name="trash" size="24" color="#3d4b70"></u-icon>
								</view>
							</view>
							<view v-if="thisUser.indexOf(index)==-1">
								<u-form-item label="人员姓名" prop="personName" @click="handleChangeUser(item['Nav_User'])">
									<u--input disabled disabledColor="#fff" v-model="item['Nav_User'].NAME" placeholder="请选择人员姓名" suffixIcon="arrow-right" suffixIconStyle="font-size:12px" fontSize="14px"
										customStyle="margin:0px;display:flex;padding:3px 9px" border="none">
									</u--input>
									</u-icon>
								</u-form-item>
								<u-form-item label="证件类型" prop="CERTIFICATE_TYPE_SHOW" @click="handleShowSheet({title: '证件类型', name: 'certificateType', dataIndex: index,userId:item.USER_ID})">
									<u--input disabled disabledColor="#fff" v-model="item.CERTIFICATE_TYPE_SHOW" placeholder="请选择证件类型" suffixIcon="arrow-right" suffixIconStyle="font-size:12px" fontSize="14px"
										customStyle="margin:0px;display:flex;padding:3px 9px" border="none"></u--input>
									</u-icon>
								</u-form-item>
								<u-form-item label="身份证号" prop="JOB_DOCUMENT">
									<u--input disabledColor="#fff" placeholder="请选择证件类型" fontSize="14px" customStyle="margin:0px;display:flex;padding:3px 9px" v-model="item.JOB_DOCUMENT" border="none"></u--input>
								</u-form-item>
								<u-form-item label="证件名称" prop="certificateName" @click="handleShowSheet({title: '证件名称', name: 'certificateName', dataIndex: index,userId:item.USER_ID})">
									<u--input disabled disabledColor="#fff" v-model="item['Nav_Train'].CERTIFICATE_NAME" placeholder="请选择人员证件" suffixIcon="arrow-right" suffixIconStyle="font-size:12px" fontSize="14px"
										customStyle="margin:0px;display:flex;padding:3px 9px" border="none"></u--input>
									</u-icon>
								</u-form-item>
								<u-form-item label="证件编号" prop="CertificateCode" style="padding-bottom: 10px;">
									<u--input disabled disabledColor="#fff" placeholder="请选择人员证件" v-model="item['Nav_Train'].CERTIFICATE_CODE" fontSize="14px" border="none"
										customStyle="margin:0px;display:flex;padding:3px 9px;"></u--input>
								</u-form-item>
								<!-- 	<u-form-item>
											<u-button type="error"
												style="font-size:14px;padding:8px;height: 30px;width: 50%;margin-top: 20px;"
												icon="trash" @click="handleDelRowBefore(index)">删除</u-button>
										</u-form-item> -->
							</view>
						</view>
					</view>
					<view style="display: flex;align-items: center;justify-content: center;border-top: #e7e6e4 1px solid;" @click="handleAddUser">
						<view style="display: flex;align-items: center;justify-content: center;">
							<view style="font-size: 16px;color: #3d4b70;font-weight: bold;padding: 15px 0px;" v-if="this.dataModel.Nav_CrucialLicensePerson.length == 1">添加作业人员信息</view>
							<view style="font-size: 16px;color: #3d4b70;font-weight: bold;padding: 15px 0px;" v-if="this.dataModel.Nav_CrucialLicensePerson.length !== 1">继续添加作业人员信息</view>
						</view>
					</view>
				</u--form>
			</view>
			<view style="padding: 40px 16px;display: flex;flex-direction: row;" v-if="stepsPage === 1">
				<u-button type="primary" @click="stepReduce" color="#3d4b70" :plain="true" style="margin-right: 5px;">上一步</u-button>
				<u-button type="primary" @click="stepAddTwo" color="#3d4b70" style="margin-left: 5px;">下一步</u-button>
			</view>
			<view class="sub-form" v-if="stepsPage === 2">
				<view>
					<u--form labelPosition="left" labelWidth="90px" ref="sForm" class="demo-ruleForm-thr" size="mini">
						<view style="display: flex;flex-direction: column;">
							<view class="form-sub-add" v-for="(item, index) in dataModel.Nav_SafeConfirms" :key="index">
								<view style="position: relative;" v-if="index==0">
									<view style="position: absolute;left: -10px;color: #3d4b70;top: -3px;">*</view>
								</view>
								<view style="font-size: 15px; font-weight: bold;white-space: nowrap;color: #3d4b70;display: flex;flex-direction: row;align-items: center;margin-bottom: 10px;" v-if="index==0">
									作业前确认
								</view>
								<view v-if="thisIndex.indexOf(index)==-1">
									<u-form-item prop="NAME">
										<u-badge :value="index+1" bgColor="#3d4b70" style="margin-right: 20px;"></u-badge>
										<u--textarea disabledColor="#fff" v-model="item.NAME" autoHeight count></u--textarea>
										<view v-if="index == 0" style="padding: 0px 0px 0px 10px;">
											<u-icon name="trash" size="24" color="#c4c6c9"></u-icon>
										</view>
										<view v-if="index > 0" @click="handleDelRowBeforeDetail(index)" style="padding: 0px 0px 0px 10px;">
											<u-icon name="trash" size="24" color="#3d4b70"></u-icon>
										</view>
									</u-form-item>
								</view>
							</view>
							<view style="display: flex;align-items: center;justify-content: center;border-top: #e7e6e4 1px solid;" @click="handleAddDetail">
								<view style="display: flex;align-items: center;justify-content: center;">
									<view style="font-size: 16px;color: #3d4b70;font-weight: bold;padding: 15px 0px;" v-if="this.dataModel.Nav_SafeConfirms.length == 1">添加作业前确认</view>
									<view style="font-size: 16px;color: #3d4b70;font-weight: bold;padding: 15px 0px;" v-if="this.dataModel.Nav_SafeConfirms.length !== 1">继续添加作业前确认</view>
								</view>
							</view>
						</view>
					</u--form>
				</view>

			</view>
			<view style="padding: 40px 16px;display: flex;flex-direction: row;" v-if="stepsPage === 2">
				<button type="default" @click="stepReduce" :plain="true"
					style="margin-right: 5px;background-color: #fff;color: #3d4b70;width: 50%;height: 40px;display: flex;align-items: center;justify-content: center;font-size: 14px;">上一步</button>
				<button type="default" @click="stepAddThree"
					style="margin-left: 5px;background-color: #3d4b70;color: #fff;width: 50%;height: 40px;display: flex;align-items: center;justify-content: center;font-size: 14px;">下一步</button>
			</view>
			<view class="sub-form" v-if="stepsPage === 3">
				<u--form labelPosition="left" labelWidth="90px" ref="sForm" class="demo-ruleForm-thr" size="mini">
					<view style="display: flex;flex-direction: column;">
						<view class="form-sub-add" v-for="(item, index) in dataModel.Nav_SafeMeasures" :key="index">
							<view style="position: relative;" v-if="index==0">
								<view style="position: absolute;left: -10px;color: #3d4b70;top: -3px;">*</view>
							</view>
							<view style="font-size: 15px; font-weight: bold;color: #3d4b70;display: flex;flex-direction: row;align-items: center;white-space: nowrap;margin-bottom: 10px;" v-if="index==0">
								作业流程及安全措施
							</view>
							<view v-if="thisFluce.indexOf(index)==-1">
								<u-form-item prop="NAME">
									<u-badge :value="index+1" bgColor="#3d4b70" style="margin-right: 20px;"></u-badge>
									<u--textarea disabledColor="#fff" v-model="item.NAME" autoHeight count></u--textarea>
									<view v-if="index == 0" style="padding: 0px 0px 0px 10px;">
										<u-icon name="trash" size="24" color="#c4c6c9"></u-icon>
									</view>
									<view v-if="index > 0" @click="handleDelRowBeforeFlow(index)" style="padding: 0px 0px 0px 10px;">
										<u-icon name="trash" size="24" color="#3d4b70"></u-icon>
									</view>
								</u-form-item>
							</view>
						</view>
						<view style="display: flex;align-items: center;justify-content: center;border-top: #e7e6e4 1px solid;" @click="handleAddFlow">
							<view style="display: flex;align-items: center;justify-content: center;">
								<view style="font-size: 16px;color: #3d4b70;font-weight: bold;padding: 15px 0px;" v-if="this.dataModel.Nav_SafeMeasures.length == 1">添加作业流程及安全措施</view>
								<view style="font-size: 16px;color: #3d4b70;font-weight: bold;padding: 15px 0px;" v-if="this.dataModel.Nav_SafeMeasures.length !== 1">继续添加作业流程及安全措施</view>
							</view>
						</view>
					</view>

				</u--form>
			</view>
			<view style="padding: 40px 16px;display: flex;flex-direction: row;" v-if="stepsPage === 3">
				<button type="default" @click="stepReduce" :plain="true"
					style="margin-right: 5px;background-color: #fff;color: #3d4b70;width: 50%;height: 40px;display: flex;align-items: center;justify-content: center;font-size: 14px;">上一步</button>
				<button type="default" @click="stepAddFour"
					style="margin-left: 5px;background-color: #3d4b70;color: #fff;width: 50%;height: 40px;display: flex;align-items: center;justify-content: center;font-size: 14px;">下一步</button>
			</view>
			<view class="sub-form" v-if="stepsPage === 4">
				<view>
					<u--form labelPosition="left" labelWidth="90px" ref="sForm" class="demo-ruleForm-thr" size="mini">
						<view style="display: flex;flex-direction: column;">
							<view class="form-sub-add" v-for="(item, index) in dataModel.Nav_DealMeasures" :key="index">
								<view style="position: relative;" v-if="index==0">
									<view style="position: absolute;left: -10px;color: #3d4b70;top: -3px;">*</view>
								</view>
								<view style="font-size: 15px; font-weight: bold;color: #3d4b70;display: flex;flex-direction: row;align-items: center;white-space: nowrap;margin-bottom: 10px;" v-if="index==0">
									作业后处理措施
								</view>
								<view v-if="thisMeasure.indexOf(index)==-1">
									<u-form-item prop="NAME">
										<u-badge :value="index+1" bgColor="#3d4b70" style="margin-right: 20px;"></u-badge>
										<u--textarea disabledColor="#fff" v-model="item.NAME" autoHeight count></u--textarea>
										<view v-if="index == 0" style="padding: 0px 0px 0px 10px;">
											<u-icon name="trash" size="24" color="#c4c6c9"></u-icon>
										</view>
										<view v-if="index > 0" @click="handleDelRowBeforeDeal(index)" style="padding: 0px 0px 0px 10px;">
											<u-icon name="trash" size="24" color="#3d4b70"></u-icon>
										</view>
									</u-form-item>
								</view>
							</view>
							<view style="display: flex;align-items: center;justify-content: center;border-top: #e7e6e4 1px solid;" @click="handleAddDeal">
								<view style="display: flex;align-items: center;justify-content: center;">
									<view style="font-size: 16px;color: #3d4b70;font-weight: bold;padding: 15px 0px;" v-if="this.dataModel.Nav_DealMeasures.length == 1">添加作业后处理措施</view>
									<view style="font-size: 16px;color: #3d4b70;font-weight: bold;padding: 15px 0px;" v-if="this.dataModel.Nav_DealMeasures.length !== 1">继续添加作业后处理措施</view>
								</view>
							</view>
						</view>
					</u--form>
				</view>
			</view>
			<view style="padding: 40px 16px;display: flex;flex-direction: row;" v-if="stepsPage === 4">
				<button type="default" @click="stepReduceTwo" :plain="true"
					style="margin-right: 5px;background-color: #fff;color: #3d4b70;width: 50%;height: 40px;display: flex;align-items: center;justify-content: center;font-size: 14px;">上一步</button>
				<button type="default" @click="stepSubmit"
					style="margin-left: 5px;background-color: #3d4b70;color: #fff;width: 50%;height: 40px;display: flex;align-items: center;justify-content: center;font-size: 14px;">提交</button>
			</view>
			<u-modal :show="showDelModalIndex >= 0" @confirm="confirmDel" @cancel="cacelDel" :showCancelButton="true" title="确认删除？"></u-modal>
			<u-modal :show="showDelModalDetail >= 0" @confirm="confirmDelDetail" @cancel="cacelDelDetail" :showCancelButton="true" title="确认删除？"></u-modal>
			<u-modal :show="showDelModalFlow >= 0" @confirm="confirmDelFlow" @cancel="cacelDelFlow" :showCancelButton="true" title="确认删除？"></u-modal>
			<u-modal :show="showDelModalDeal >= 0" @confirm="confirmDelDeal" @cancel="cacelDelDeal" :showCancelButton="true" title="确认删除？"></u-modal>
			<query-selector :show="showPopup" :total="curTotal" :lists="userLists" :defaultValue="currentOperateUser.NAME" @close="handleClosePopup" @search="handleSearchUser" @select="handleSelectedUser" />
			<query-selector :show="showPopupStep" :total="curTotalStep" :lists="stepLists" :defaultValue="currentOperateStep.NAME" @close="handleClosePopupStep" @search="handleSearchStep" @select="handleSelectedStep" />
			<query-selector :show="showPopupMonitor" :total="curTotalMonitor" :lists="monitorLists" :defaultValue="currentOperateMonitor.NAME" @close="handleClosePopupMonitor" @search="handleSearchMonitor"
				@select="handleSelectedMonitor" />
			<!-- 	<query-selector :show="showPopupCertificate" :lists="certificateLists" :defaultValue="currentCertificate.NAME"
				@close="handleClosePopup" @search="handleSearchCertificate" @select="handleSelectedCertificate" /> -->
			<u-picker :show="comPickerInfo.showSheet" :columns="comPickerInfo.columns" @confirm="onConfirmPicker" @close="closePicker" @cancel="closePicker" keyName="NAME"></u-picker>
			<u-picker :show="comPickerInfoTrain.showSheet" :columns="comPickerInfoTrain.columns" @confirm="onConfirmPickerTrain" @close="closePicker" @cancel="closePicker" keyName="CERTIFICATE_NAME"></u-picker>
			<u-datetime-picker :show="dateTimePickerInfo.showCheckDate" mode="datetime" v-model='dateTimePickerInfo.defaultDateTime' :formatter="formatter" @confirm="handleCheckDate"
				@close="dateTimePickerInfo.showCheckDate = false;" @cancel="dateTimePickerInfo.showCheckDate = false;"></u-datetime-picker>
			<!-- <view class="bottom-button">
				<u-button type="primary" @click="submit">提交</u-button>
			</view> -->
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import {
		extendFilterGroup,
		extendGroupRule,
		extendInclude,
		extendOrder,
		extendRule,
		guid,
		initFilter,
		initFilterGroup,
		extendIgnoreDataRule,
	} from '../../../../utils/common'
	import {
		getRequest,
		getUserLists,
		getStepLists,
		getDetailLists,
		getAllLists,
		getCertificateLists,
		saveJobRecord
	} from '../../../../services/apply/FOServices/FOServices.js'
	import config from '../../../../config/common'
	import {
		OrderPagedUseful,
	} from '../../../../services/common'
	import stepTitle from '@/components/custom/step-title.vue'
	export default {
		components: {
			stepTitle,
		},
		data() {
			return {
				ID: null,
				TaskID: null,
				curTotal: 0,
				curTotalStep: 0,
				curTotalMonitor: 0,
				showDelModalIndex: undefined,
				showDelModalDetail: undefined,
				showDelModalFlow: undefined,
				showDelModalDeal: undefined,
				isLoadOK: false,
				userLists: [],
				stepLists: [],
				monitorLists: [],
				certificateLists: [],
				stepsPage: 0,
				showWorkPerson: true,
				stepsText: ['基本信息', '作业人员', '作业前', '作业中', '作业后'],
				dataModel: {
					JOB_LOCATION: '',
					OPERATION_STEP_ID: null,
					Nav_OperationStep: {
						CODE: '',
						NAME: ''
					},
					// Nav_ApplyUser: {
					// 	NAME: ''
					// },
					Nav_ApplyUser: uni.getStorageSync('appInfo')?.User,
					APPLY_USER_ID: uni.getStorageSync('appInfo')?.User?.ID, //null,
					Nav_MonitorUser: {
						NAME: ''
					},
					MONITOR_USER_ID: null,
					JobCause: '',
					// stepName:'',
					// applyUser:'',
					// monitorUser:'',
					Nav_SafeConfirms: [],
					Nav_SafeMeasures: [],
					Nav_DealMeasures: [],
					Nav_CrucialLicensePerson: [],
					AUDIT_LEVEL: 0,
					AUDIT_LEVEL_SHOW: '',
					// jobDate:'',
					// endDate:'',
					JOB_DATE: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM'),
					JOB_END_DATE: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM')
				},
				subDataModel: {
					Nav_CrucialLicensePerson: {
						Nav_User: {
							Nav_Department: {
								NAME: ''
							},
							NAME: '',
							CODE: '',
						},
						CERTIFICATE_TYPE: null,
						USER_ID: null,
						TRAIN_ID: null,
						Nav_Train: {
							CERTIFICATE_NAME: '',
							CERTIFICATE_CODE: '',
						},
					},
					Nav_SafeConfirms: {
						NUM: 0,
						NAME: ""
					},
					Nav_SafeMeasures: {
						NUM: 0,
						NAME: ""
					},
					Nav_DealMeasures: {
						NUM: 0,
						NAME: ""
					}
				},
				options: [{
					text: '删除',
					style: {
						backgroundColor: '#f56c6c'
					}
				}],
				comPickerInfo: {
					showSheet: false,
					columns: [],
					title: '',
					dataIndex: undefined,
					formIndex: undefined,
					name: ''
				},
				comPickerInfoTrain: {
					showSheet: false,
					columns: [],
					title: '',
					dataIndex: undefined,
					formIndex: undefined,
					name: ''
				},
				tableKey: 0,
				formatter: null,
				currentOperateUser: {},
				currentOperateStep: {},
				currentOperateMonitor: {},
				showPopup: false,
				showPopupStep: false,
				showPopupMonitor: false,
				// currentCertificate: {},
				// showPopupCertificate: false,
				// rules: {
				// 	'JOB_LOCATION': {
				// 		type: 'string',
				// 		: true,
				// 		trigger: ['blur', 'change'],
				// 		message: '作业地点不能为空'
				// 	},
				// 	'JobCause': {
				// 		type: 'string',
				// 		: true,
				// 		trigger: ['blur', 'change'],
				// 		message: '作业原因不能为空'
				// 	},
				// 	'Nav_OperationStep.NAME': {
				// 		type: 'string',
				// 		: true,
				// 		trigger: ['blur', 'change'],
				// 		message: '作业名称不能为空'

				// 	},
				// 	'Nav_ApplyUser.NAME': {
				// 		type: 'string',
				// 		: true,
				// 		trigger: ['blur', 'change'],
				// 		message: '作业申请人不能为空'
				// 	},
				// 	'Nav_MonitorUser.NAME': {
				// 		type: 'string',
				// 		: true,
				// 		trigger: ['blur', 'change'],
				// 		message: '监护人不能为空'
				// 	},
				// },
				dateTimePickerInfo: {
					showCheckDate: false,
					dataIndex: undefined,
					defaultDateTime: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM'),
					value: '',
					name: ''
				},
				list: [{
					name: '作业人员'
				}, {
					name: '作业前确认'
				}, {
					name: '作业流程及安全措施'
				}, {
					name: '作业后处理措施'
				}],
				currentIndex: 0,
				isTop: false,
				collapseValue: true,
				collapseIndex: 0,
				isShow: true,
				thisIndex: [],
				showDown: false,
				thisUser: [],
				thisFluce: [],
				thisMeasure: [],
				thisUserShow: false,
				thisDetailShow: false,
				thisFluceShow: false,
				thisMeasureShow: false,
				numY: 0,
				numA: 0,
				numB: 0,
				numC: 0,
			}
		},
		onLoad(opt) {
			this.handleGetJobGet(opt)
			this.handleAddUser()
		},
		mounted() {
			// this.handleAddUser()
		},
		onNavigationBarButtonTap(e) {
			this.stepSubmit()
		},
		methods: {
			handleWorkPerson() {
				this.showWorkPerson = !this.showWorkPerson
			},
			stepReduce() {
				this.stepsPage = this.stepsPage - 1
			},
			stepReduceTwo() {
				this.stepsPage = this.stepsPage - 1
			},
			stepAdd() {
				// this.stepsPage = this.stepsPage + 1
				if (this.dataModel.Nav_OperationStep.NAME !== '' &&
					this.dataModel.AUDIT_LEVEL_SHOW !== '' &&
					this.dataModel.Nav_MonitorUser.NAME !== '' &&
					this.dataModel.Nav_ApplyUser.NAME !== '' &&
					this.dataModel.JOB_DATE !== '' &&
					this.dataModel.JOB_END_DATE !== '' &&
					this.dataModel.JOB_LOCATION !== '' &&
					this.dataModel.JobCause !== '' &&

					this.dataModel.Nav_OperationStep.NAME !== null &&
					this.dataModel.AUDIT_LEVEL_SHOW !== null &&
					this.dataModel.Nav_MonitorUser.NAME !== null &&
					this.dataModel.Nav_ApplyUser.NAME !== null &&
					this.dataModel.JOB_DATE !== null &&
					this.dataModel.JOB_END_DATE !== null &&
					this.dataModel.JOB_LOCATION !== null &&
					this.dataModel.JobCause !== null &&

					this.dataModel.Nav_OperationStep.NAME !== undefined &&
					this.dataModel.AUDIT_LEVEL_SHOW !== undefined &&
					this.dataModel.Nav_MonitorUser.NAME !== undefined &&
					this.dataModel.Nav_ApplyUser.NAME !== undefined &&
					this.dataModel.JOB_DATE !== undefined &&
					this.dataModel.JOB_END_DATE !== undefined &&
					this.dataModel.JOB_LOCATION !== undefined &&
					this.dataModel.JobCause !== undefined) {
					if (new Date(this.dataModel.JOB_DATE.replace("-", "/")) >= new Date(this.dataModel.JOB_END_DATE.replace(
							"-", "/"))) {
						uni.$showErrorInfo('开始时间必须小于结束时间')
						return
					}
					this.stepsPage = this.stepsPage + 1
				} else {
					uni.$showErrorInfo('请检查基本信息，基本信息不能为空')
				}
			},
			stepAddTwo() {
				// this.stepsPage = this.stepsPage + 1
				this.numY = 0
				this.dataModel.Nav_CrucialLicensePerson.map((item) => {
					if (item['Nav_User'].NAME == '') {
						return
					}
					if (!item.JOB_DOCUMENT && item['Nav_Train'].length == 0) {
						return
					}
					if (!item.JOB_DOCUMENT && item['Nav_Train'].CERTIFICATE_CODE == '') {
						return
					}
					if (item.JOB_DOCUMENT == '' && item['Nav_Train'].length == 0) {
						return
					}
					if (item.JOB_DOCUMENT == '' && item['Nav_Train'].CERTIFICATE_CODE == '') {
						return
					}
					this.numY = this.numY + 1;

				})
				if (this.numY == this.dataModel.Nav_CrucialLicensePerson.length) {
					this.stepsPage = this.stepsPage + 1
				} else {
					uni.$showErrorInfo('作业人员及人员证件都不能为空')
				}
			},
			stepAddThree() {
				this.numA = 0;
				this.dataModel.Nav_SafeConfirms.map((item) => {
					if (item.NAME == '') {
						uni.$showErrorInfo('添加信息不能为空')
						return
					}
					this.numA = this.numA + 1
				})
				if (this.numA !== this.dataModel.Nav_SafeConfirms.length) {
					uni.$showErrorInfo('添加作业前确认信息不能为空')
				} else {
					this.stepsPage = this.stepsPage + 1
				}

			},
			stepAddFour() {
				this.numB = 0;
				this.dataModel.Nav_SafeMeasures.map((item) => {
					if (item.NAME == '') {
						uni.$showErrorInfo('添加信息不能为空')
						return
					}
					this.numB = this.numB + 1
				})
				if (this.numB !== this.dataModel.Nav_SafeMeasures.length) {
					uni.$showErrorInfo('添加作业流程及安全措施信息不能为空')
				} else {
					this.stepsPage = this.stepsPage + 1
				}
			},

			handleUnfoldUser() {
				this.thisUserShow = !this.thisUserShow
			},
			handleUnfoldDetail() {
				this.thisDetailShow = !this.thisDetailShow
			},
			handleUnfoldFluce() {
				this.thisFluceShow = !this.thisFluceShow
			},
			handleUnfoldMeasure() {
				this.thisMeasureShow = !this.thisMeasureShow
			},
			handlePushDown() {
				this.isShow = false
			},
			handlePushUp() {
				this.isShow = true
			},
			change(index) {
				this.currentIndex = index.index;
			},
			changeIndex() {
				this.show = true
				if (this.currentIndex + 1 < this.list.length) {
					this.currentIndex = this.currentIndex + 1
				}
			},
			submitForm(formName) {
				this.$refs[formName].validate((valid) => {
					if (valid) {
						alert('submit!');
					} else {
						console.log('error submit!!');
						return false;
					}
				});
			},
			resetForm(formName) {
				this.$refs[formName].resetFields();
			},
			handleGetJobGet(opt) {
				const orgId = uni.getStorageSync('orgId')
				if (opt.ID !== undefined) {
					this.TaskID = opt.taskID ? opt.taskID : '';
					this.ID = opt.ID ? opt.ID : '';
					const json = initFilter(orgId, "", "")
					extendRule(json, 'ID', 1, opt.ID)
					//  extendInclude(json, 'Nav_OperationStep');
					//   extendInclude(json, 'Nav_ApplyUser');
					//    extendInclude(json, 'Nav_MonitorUser');
					// extendInclude(json, 'Nav_CrucialLicensePerson.Nav_User.Nav_Department');
					// extendInclude(json, 'Nav_CrucialLicensePerson.Nav_Train');
					// extendInclude(json, 'Nav_JobScheme');
					// extendInclude(json, 'Nav_Meeting');
					//  extendInclude(json, 'Nav_SafeConfirms');
					//   extendInclude(json, 'Nav_SafeMeasures');
					// extendInclude(json, 'Nav_DealMeasures');
					//  extendInclude(json, 'Nav_Related');
					// extendIgnoreDataRule(json)
					// TODO: id 未获取
					getRequest(json, "/FO/FOCrucialLicenseJob/FullGet").then(res => {
						if (res) {
							this.dataModel = res
							if (res.OPERATION_STEP_ID == null) {
								this.dataModel.Nav_OperationStep = {}
							}
							if (res.AUDIT_LEVEL == 0) {
								this.dataModel.AUDIT_LEVEL_SHOW = "无审批层级"
							} else if (res.AUDIT_LEVEL == 1) {
								this.dataModel.AUDIT_LEVEL_SHOW = "一级审批"
							} else if (res.AUDIT_LEVEL == 2) {
								this.dataModel.AUDIT_LEVEL_SHOW = "二级审批"
							} else if (res.AUDIT_LEVEL == 3) {
								this.dataModel.AUDIT_LEVEL_SHOW = "三级审批"
							} else if (res.AUDIT_LEVEL == 4) {
								this.dataModel.AUDIT_LEVEL_SHOW = "四级审批"
							}
							if (res.APPLY_USER_ID == null) {
								// this.dataModel.Nav_ApplyUser = {}
								this.dataModel.Nav_ApplyUser = uni.getStorageSync('appInfo')?.User
								this.dataModel.APPLY_USER_ID = uni.getStorageSync('appInfo')?.User?.ID
							}
							if (res.MONITOR_USER_ID == null) {
								this.dataModel.Nav_MonitorUser = {}
							}
							if (res.JOB_DATE) {
								res.JOB_DATE = uni.$u.timeFormat(res.JOB_DATE, 'yyyy-mm-dd')
							}
							else
							{
								res.JOB_DATE = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM')
							}
							if (res.JOB_END_DATE) {
								res.JOB_END_DATE = uni.$u.timeFormat(res.JOB_END_DATE, 'yyyy-mm-dd')
							}
							else
							{
								res.JOB_END_DATE = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM')
							}
							if (res.Nav_CrucialLicensePerson && res.Nav_CrucialLicensePerson.length == 0) {
								this.handleAddUser()
							}
							if (res.Nav_CrucialLicensePerson && res.Nav_CrucialLicensePerson.length > 0) {
								for (let i = 0; i < res.Nav_CrucialLicensePerson.length; i++) {
									if (res.Nav_CrucialLicensePerson[i].TRAIN_ID === null) {
										res.Nav_CrucialLicensePerson[i].Nav_Train = []
									}
								}
							}
							if (res.Nav_SafeConfirms && res.Nav_SafeConfirms.length > 0) {
								for (let i = 0; i < res.Nav_SafeConfirms.length; i++) {
									res.Nav_SafeConfirms[i].NUM = i + 1;
								}
							}
							if (res.Nav_SafeMeasures && res.Nav_SafeMeasures.length > 0) {
								for (let i = 0; i < res.Nav_SafeMeasures.length; i++) {
									res.Nav_SafeMeasures[i].NUM = i + 1;
								}
							}
							if (res.Nav_DealMeasures && res.Nav_DealMeasures.length > 0) {
								for (let i = 0; i < res.Nav_DealMeasures.length; i++) {
									res.Nav_DealMeasures[i].NUM = i + 1;
								}
							}
							this.isLoadOK = true
						}
					})
				}
			},
			//显示时间控件
			showCheckDate(p) {
				if (p.name === 'jobDate') {
					if (this.dataModel.JOB_DATE == null) {
						this.dataModel.JOB_DATE = uni.$u.timeFormat(new Date(),
							'yyyy-mm-dd hh:MM')
					}
					this.dateTimePickerInfo = {
						showCheckDate: true,
						dataIndex: p.dataIndex,
						defaultDateTime: this.dataModel.JOB_DATE,
						name: p.name
					}
				} else if (p.name === 'endDate') {
					if (this.dataModel.JOB_END_DATE == null) {
						this.dataModel.JOB_END_DATE = uni.$u.timeFormat(new Date(),
							'yyyy-mm-dd hh:MM')
					}
					this.dateTimePickerInfo = {
						showCheckDate: true,
						dataIndex: p.dataIndex,
						defaultDateTime: this.dataModel.JOB_END_DATE,
						name: p.name
					}
				}

			},

			//隐藏控件 显示时间
			handleCheckDate(e) {
				// let v = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
				const {
					name,
					dataIndex
				} = this.dateTimePickerInfo
				if (name === 'jobDate') {
					// this.dataModel.jobDate = uni.$u.timeFormat(e.value,
					// 	'yyyy-mm-dd')
					this.dataModel.JOB_DATE = uni.$u.timeFormat(e.value,
						'yyyy-mm-dd hh:MM')
				}
				if (name === 'endDate') {
					// this.dataModel.endDate = uni.$u.timeFormat(e.value,
					// 		'yyyy-mm-dd')
					this.dataModel.JOB_END_DATE = uni.$u.timeFormat(e.value,
						'yyyy-mm-dd hh:MM')
				}
				this.dateTimePickerInfo.showCheckDate = false
			},
			valChangeDetail(e) {
				// this.dataModel.Nav_Details[index].NUM=e.value;
			},
			valChangeFlow(e) {
				// this.dataModel.Nav_Flow[index].NUM=e.value;
			},
			valChangeDeal(e) {
				// this.dataModel.Nav_Measure[index].NUM=e.value;
			},
			handleAddUser(index) {
				const persons = JSON.parse(JSON.stringify(this.subDataModel.Nav_CrucialLicensePerson))
				this.dataModel.Nav_CrucialLicensePerson.push(persons)
				this.thisUserShow = true;
			},
			handleAddDetailPush(index) {
				if (this.thisIndex.indexOf(index) == -1) {
					this.thisIndex.push(index)
				} else {
					this.thisIndex = this.thisIndex.filter(item => item != index)
				}
			},
			handleAddUserPush(index) {
				if (this.thisUser.indexOf(index) == -1) {
					this.thisUser.push(index)
				} else {
					this.thisUser = this.thisUser.filter(item => item != index)
				}
			},
			handleAddFlucePush(index) {
				if (this.thisFluce.indexOf(index) == -1) {
					this.thisFluce.push(index)
				} else {
					this.thisFluce = this.thisFluce.filter(item => item != index)
				}
			},
			handleAddMeasurePush(index) {
				if (this.thisMeasure.indexOf(index) == -1) {
					this.thisMeasure.push(index)
				} else {
					this.thisMeasure = this.thisMeasure.filter(item => item != index)
				}
			},
			handleAddDetailRetain() {
				this.isShow = false;
			},
			handleAddDetail() {
				const safeConfirms = JSON.parse(JSON.stringify(this.subDataModel.Nav_SafeConfirms))
				this.dataModel.Nav_SafeConfirms.push(safeConfirms)
				this.thisDetailShow = true
			},
			handleAddFlow() {
				const safeMeasures = JSON.parse(JSON.stringify(this.subDataModel.Nav_SafeMeasures))
				this.dataModel.Nav_SafeMeasures.push(safeMeasures)
				this.thisFluceShow = true
			},
			handleAddDeal() {
				const dealMeasures = JSON.parse(JSON.stringify(this.subDataModel.Nav_DealMeasures))
				this.dataModel.Nav_DealMeasures.push(dealMeasures)
				this.thisMeasureShow = true
			},
			handleDelRowBefore(index) {
				this.showDelModalIndex = index
			},
			handleDelRowBeforeDetail(index) {
				this.showDelModalDetail = index
			},
			handleDelRowBeforeFlow(index) {
				this.showDelModalFlow = index
			},
			handleDelRowBeforeDeal(index) {
				this.showDelModalDeal = index
			},
			confirmDel() {
				this.dataModel.Nav_CrucialLicensePerson.splice(this.showDelModalIndex, 1)
				this.showDelModalIndex = undefined
			},
			cacelDel() {
				this.showDelModalIndex = undefined
			},
			confirmDelDetail() {
				this.dataModel.Nav_SafeConfirms.splice(this.showDelModalDetail, 1)
				this.showDelModalDetail = undefined
			},
			cacelDelDetail() {
				this.showDelModalDetail = undefined
			},
			confirmDelFlow() {
				this.dataModel.Nav_SafeMeasures.splice(this.showDelModalFlow, 1)
				this.showDelModalFlow = undefined
			},
			cacelDelFlow() {
				this.showDelModalFlow = undefined
			},
			confirmDelDeal() {
				this.dataModel.Nav_DealMeasures.splice(this.showDelModalDeal, 1)
				this.showDelModalDeal = undefined
			},
			cacelDelDeal() {
				this.showDelModalDeal = undefined
			},
			//下拉数据加载
			async handleShowSheet(p) {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "", 0)
				let dataSelect = []
				if (p.name === 'certificateName' && p.userId === null) {
					uni.$showErrorInfo('请先选择人员')
					return;
				}
				if (p.name === 'certificateType' && p.userId === null) {
					uni.$showErrorInfo('请先选择人员')
					return;
				}
				if (p.name === 'certificateType' && p.userId !== null) {
					dataSelect = [{
							NAME: '身份证',
							ID: 0
						},
						{
							NAME: '特种作业证',
							ID: 1
						}
					]
				}
				// if (p.name === 'stepName') {
				// 	dataSelect = await getStepLists(json).then(res => {
				// 		return res.Data
				// 	})
				// } else
				// if (p.name === 'personName' || p.name === 'applyUser' || p.name === 'monitorUser') {
				// 	extendInclude(json, "Nav_Department")
				// 	dataSelect = await OrderPagedUseful(json).then(res => {
				// 		return res
				// 	})
				// } else
				if (p.name === 'certificateName' && p.userId !== null) {
					extendRule(json, 'USER_ID', 1, p.userId);
					dataSelect = await getCertificateLists(json).then(res => {
						return res.Data
					})
				}
				if (p.name === 'certificateName' && dataSelect.length) {
					this.comPickerInfoTrain = {
						showSheet: true,
						title: p.title,
						name: p.name,
						dataIndex: p.dataIndex,
						columns: [dataSelect]
					}
				} else if (p.name === 'certificateName' && !dataSelect.length) {
					uni.$showErrorInfo('缺少证件信息，请联系安环部进行信息维护')
				} else if (dataSelect.length) {
					this.comPickerInfo = {
						showSheet: true,
						title: p.title,
						name: p.name,
						dataIndex: p.dataIndex,
						columns: [dataSelect]
					}
				} else {
					uni.$showErrorInfo('无数据，请联系管理员维护')
				}
			},
			handleSearchUser(val, pageIndex) {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "NAME", '', pageIndex)
				extendInclude(json, "Nav_Department")
				extendRule(json, 'ENABLE_STATUS', 1, '0')
				if (val !== 'init') {
					const tempGroup = initFilterGroup(false);
					extendGroupRule(tempGroup, 'NAME', 9, val)
					extendFilterGroup(json, tempGroup);
				}
				json.Limit = 20
				if (pageIndex) {
					json.Start = (pageIndex - 1) * 20;
				}

				getUserLists(json).then(res => {
					if (res.IsSuccessful) {
						this.userLists = res.Data.map(i => {
							return {
								...i,
								name: i.NAME,
								code: i.CODE
							}
						})
						this.curTotal = res.TotalCount
					}
				})
			},
			handleSelectedUser(val) {
				let numc = 0;
				this.dataModel.Nav_CrucialLicensePerson.map((item) => {
					if (item.USER_ID == val.ID) {
						numc = numc + 1
						return
					}
				})
				if (numc == 1) {
					this.showPopup = false
					uni.$showErrorInfo('不能选择相同的作业人员')
					return
				}
				this.showPopup = false
				this.lists = []
				this.currentOperateUser.CODE = val.CODE
				const result = this.dataModel.Nav_CrucialLicensePerson.map((obj) => {
					const {
						Nav_User,
						USER_ID
					} = obj
					if (Nav_User.CODE === this.currentOperateUser.CODE) {
						return Object.assign({}, obj, {
							Nav_User: val,
							USER_ID: val.ID,
							JOB_DOCUMENT: '',
							CERTIFICATE_TYPE_SHOW: '',
							CERTIFICATE_TYPE: '',
							Nav_Train: [],
							// REAL_DEPARTMENT_POST_ID:val.Nav_Person.POST_ID
						})
					}
					return obj
				})
				this.USER_ID = val.ID;
				this.ID_CARD = val.ID_CARD;
				this.dataModel.Nav_CrucialLicensePerson = result
			},
			handleClosePopup() {
				this.showPopup = false
				// this.showPopupCertificate = false
			},
			handleClosePopupStep() {
				this.showPopupStep = false
				// this.showPopupCertificate = false
			},
			handleClosePopupMonitor() {
				this.showPopupMonitor = false
				// this.showPopupCertificate = false
			},
			handleChangeUser(user) {
				this.currentOperateUser = user
				this.showPopup = true
				this.handleSearchUser('init')
			},
			handleChangeStep(step) {
				this.currentOperateStep = step
				this.showPopupStep = true
				this.handleSearchStep('init')
			},
			handleSearchStep(val, pageIndex) {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "NAME", '', pageIndex)
				// extendInclude(json, "Nav_Department")
				// extendRule(json, 'ENABLE_STATUS', 1, '0')
				if (val !== 'init') {
					const tempGroup = initFilterGroup(false);
					extendGroupRule(tempGroup, 'NAME', 9, val)
					extendFilterGroup(json, tempGroup);
				}
				json.Limit = 20
				if (pageIndex) {
					json.Start = (pageIndex - 1) * 20;
				}
				getStepLists(json).then(res => {
					if (res.IsSuccessful) {
						this.stepLists = res.Data.map(i => {
							return {
								...i,
								id: i.ID,
								name: i.NAME,
							}
						})
						this.curTotalStep = res.TotalCount
					}
				})
			},
			handleSelectedStep(val) {
				this.showPopupStep = false
				this.currentOperateStep = val
				this.dataModel.Nav_OperationStep = val
				this.dataModel.OPERATION_STEP_ID = val.ID
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, val.ID)
				getDetailLists(json).then(res => {
					if (res.IsSuccessful) {
						let confirm = []
						if (res.Data.Nav_SafeConfirms) {
							confirm = res.Data.Nav_SafeConfirms?.map((item, i) => {
								item['NUM'] = i + 1;
								item['CREATE_TIME'] = '';
								return item;
							})
							this.dataModel.Nav_SafeConfirms = confirm
							this.thisDetailShow = true
						}
						let measures = []
						if (res.Data.Nav_SafeMeasures) {
							measures = res.Data.Nav_SafeMeasures?.map((item, i) => {
								item['NUM'] = i + 1;
								item['CREATE_TIME'] = '';
								return item;
							})
							this.dataModel.Nav_SafeMeasures = measures
							this.thisFluceShow = true
						}
						let deal = []
						if (res.Data.Nav_DealMeasures) {
							deal = res.Data.Nav_DealMeasures?.map((item, i) => {
								item['NUM'] = i + 1;
								item['CREATE_TIME'] = '';
								return item;
							})
							this.dataModel.Nav_DealMeasures = deal
							this.thisMeasureShow = true
						}
						if (res.Data.AUDIT_LEVEL == 0) {
							this.dataModel.AUDIT_LEVEL_SHOW = "无审批层级"
						} else if (res.Data.AUDIT_LEVEL == 1) {
							this.dataModel.AUDIT_LEVEL_SHOW = "一级审批"
						} else if (res.Data.AUDIT_LEVEL == 2) {
							this.dataModel.AUDIT_LEVEL_SHOW = "二级审批"
						} else if (res.Data.AUDIT_LEVEL == 3) {
							this.dataModel.AUDIT_LEVEL_SHOW = "三级审批"
						} else if (res.Data.AUDIT_LEVEL == 4) {
							this.dataModel.AUDIT_LEVEL_SHOW = "四级审批"
						}
						this.dataModel.AUDIT_LEVEL = res.Data.AUDIT_LEVEL
						this.$forceUpdate()
					}
				})
			},
			handleChangeMonitor(user) {
				this.currentOperateMonitor = user
				this.showPopupMonitor = true
				this.handleSearchMonitor('init')
			},
			handleSearchMonitor(val, pageIndex) {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "NAME", '', pageIndex)
				extendInclude(json, "Nav_Department")
				extendRule(json, 'ENABLE_STATUS', 1, '0')
				if (val !== 'init') {
					const tempGroup = initFilterGroup(false);
					extendGroupRule(tempGroup, 'NAME', 9, val)
					extendFilterGroup(json, tempGroup);
				}
				json.Limit = 20
				if (pageIndex) {
					json.Start = (pageIndex - 1) * 20;
				}

				getUserLists(json).then(res => {
					if (res.IsSuccessful) {
						this.monitorLists = res.Data.map(i => {
							return {
								...i,
								name: i.NAME,
								code: i.CODE
							}
						})
						this.curTotalMonitor = res.TotalCount
					}
				})
			},
			handleSelectedMonitor(val) {
				this.showPopupMonitor = false
				this.currentOperateMonitor = val
				this.dataModel.Nav_MonitorUser = val
				this.dataModel.MONITOR_USER_ID = val.ID
			},
			// handleChangeCertificate(Certificate) {
			// 	this.currentCertificate = Certificate
			// 	this.showPopupCertificate = true
			// },
			onConfirmPickerTrain(e) {
				const {
					name,
					dataIndex,
					formIndex
				} = this.comPickerInfoTrain
				if (name === 'certificateName') {
					this.dataModel.Nav_CrucialLicensePerson[dataIndex].Nav_Train = e.value[0]
					this.dataModel.Nav_CrucialLicensePerson[dataIndex].TRAIN_ID = e.value[0].ID
				}
				this.comPickerInfoTrain.showSheet = false
			},
			onConfirmPicker(e) {
				const {
					name,
					dataIndex,
					formIndex
				} = this.comPickerInfo
				if (name === 'certificateType') {
					if (e.value[0].ID === 0) {
						this.dataModel.Nav_CrucialLicensePerson[dataIndex].JOB_DOCUMENT = this.ID_CARD || ''
						this.dataModel.Nav_CrucialLicensePerson[dataIndex].Nav_Train = []
					} else {
						this.dataModel.Nav_CrucialLicensePerson[dataIndex].JOB_DOCUMENT = ''
					}
					this.dataModel.Nav_CrucialLicensePerson[dataIndex].CERTIFICATE_TYPE = e.value[0].ID
					this.dataModel.Nav_CrucialLicensePerson[dataIndex].CERTIFICATE_TYPE_SHOW = e.value[0].NAME
				}
				this.comPickerInfo.showSheet = false
			},
			closePicker() {
				this.comPickerInfo = {
					showSheet: false,
					columns: [],
					title: '',
					name: '',
					dataIndex: undefined,
					formIndex: undefined
				}
				this.comPickerInfoTrain = {
					showSheet: false,
					columns: [],
					title: '',
					name: '',
					dataIndex: undefined,
					formIndex: undefined
				}
			},
			stepSubmit() {
				this.numC = 0;
				this.dataModel.Nav_DealMeasures.map((item) => {
					if (item.NAME == '') {
						uni.$showErrorInfo('添加信息不能为空')
						return
					}
					this.numC = this.numC + 1
				})
				if (this.numC !== this.dataModel.Nav_DealMeasures.length) {
					uni.$showErrorInfo('添加作业后处理措施信息不能为空')
				} else {
					this.dataModel.PUBLISH = "SaveAndNotify";
					if (this.TaskID !== null) {
						this.dataModel.TaskID = this.TaskID;
					}
					this.dataModel.ID = this.ID ? this.ID : guid();
					this.dataModel.ORG_ID = uni.getStorageSync('orgId')
					if (this.dataModel.Nav_CrucialLicensePerson && this.dataModel.Nav_CrucialLicensePerson.length >
						0) {
						for (let i = 0; i < this.dataModel.Nav_CrucialLicensePerson.length; i++) {
							if (this.dataModel.Nav_CrucialLicensePerson[i].TRAIN_ID === null) {
								this.dataModel.Nav_CrucialLicensePerson[i].Nav_Train = null
							}
						}
					}
					saveJobRecord(this.dataModel).then(res => {
						uni.$showMsgFunc('操作成功!', () => {
							// if (this.tableKey == null || this.tableKey == 0) {
							// 	uni.navigateTo({
							// 		url: 'jobRecord'
							// 	})
							// } else {
							// uni.navigateBack()
							uni.switchTab({
								url: '/pages/index/index2'
							})
							// }
						}, 'success', 1000)
					})
				}


			},
			submit() {
				const ele = this.$refs
				ele['wForm'].validate().then(res => {
					this.dataModel.PUBLISH = "SaveAndNotify";
					if (this.TaskID !== null) {
						this.dataModel.TaskID = this.TaskID;
					}
					this.dataModel.ID = this.ID ? this.ID : guid();
					this.dataModel.ORG_ID = uni.getStorageSync('orgId')
					if (this.dataModel.Nav_CrucialLicensePerson && this.dataModel.Nav_CrucialLicensePerson.length >
						0) {
						for (let i = 0; i < this.dataModel.Nav_CrucialLicensePerson.length; i++) {
							if (this.dataModel.Nav_CrucialLicensePerson[i].TRAIN_ID === null) {
								this.dataModel.Nav_CrucialLicensePerson[i].Nav_Train = null
							}
						}
					}
					saveJobRecord(this.dataModel).then(res => {
						uni.$showMsgFunc('操作成功!', () => {
							// if (this.tableKey == null || this.tableKey == 0) {
							// 	uni.navigateTo({
							// 		url: 'jobRecord'
							// 	})
							// } else {
							uni.navigateBack()
							// }
						}, 'success', 1000)
					})
				}).catch(err => {
					// console.log('校验失败', err)
					uni.$showErrorInfo('请检查必填项，必填项不能为空')
				})
			},
		}
	}
</script>

<style scoped>
	.page-wrap {
		padding: 16px 16px 66px;
	}


	.background {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: #edf1fd;
		z-index: -1;
	}

	.tabs-title {
		/* //padding-top: 10px;
		// margin-bottom: 10px;
		// margin: 16px; */
		display: flex;
		flex-direction: row;
		align-items: center;
		background-color: rgba(255, 255, 255, 1);
		box-shadow: 0px 1px 0px 0px #eaedf4;

		.icon-tabs {
			padding-left: 5px;
			display: flex;
			align-items: center;
		}
	}

	.slot-icon-ed {
		width: 24px;
		height: 24px;
		background-color: #3d4b70;
		border-radius: 100px;
		font-size: 12px;
		color: #fff;
		line-height: 24px;
		text-align: center;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.slot-icon-ing {
		width: 24px;
		height: 24px;
		background-color: #cceaff;
		border-radius: 100px;
		font-size: 12px;
		color: #fff;
		line-height: 24px;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.slot-icon-no {
		width: 24px;
		height: 24px;
		background-color: #7785a2;
		border-radius: 100px;
		font-size: 12px;
		color: #fff;
		line-height: 24px;
		text-align: center;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.slot-icon-dot {
		width: 12px;
		height: 12px;
		background-color: #3695ff;
		border-radius: 100px;
		color: #fff;
		line-height: 10px;
	}

	.form-sub {
		margin: 20px 16px 10px 16px;
		/* border: 1px solid #EBEEF5; */
		padding: 20px 30px 10px 30px;
		/* box-shadow: rgba(0, 0, 0, 0.08) 0px 0px 3px 1px; */
		background-color: #ffffff;
		border-radius: 10px;
	}

	.form-sub-add {
		/* margin-top: 20px; */
		/* border-top: 1px solid #EBEEF5; */
		/* margin: 0px 16px 10px 16px; */
		/* border: 1px solid #EBEEF5;
		padding: 0px;
		box-shadow: rgba(0, 0, 0, 0.08) 0px 0px 3px 1px; */

	}

	.form-sub-content {
		padding: 10px 30px 10px 30px;
		border-top: 1px #EBEEF5 solid
	}

	.form-content {
		/* background-color: red; */
		border-radius: 4px;
		border: 1px solid #DCDFE6;
		height: 28px;
		line-height: 28px;
	}

	.step-load>>>.u-steps-item__wrapper {
		background-color: #edf1fd;
	}

	.step-load>>>.u-text__value--main {
		color: #3d4b70;
		font-weight: bold !important;
	}

	.step-load>>>.u-steps-item__line--row {
		height: 4px;
		width: 50px !important;
		left: 55px !important;
		border-radius: 500px;
	}

	.step-load>>>.u-steps-item__wrapper--row {
		width: 42px;
	}


	.demo-ruleForm>>>.u-form-item__body__left__content__label {
		font-size: 14px;
		color: #8e8b9c;
		/* justify-content: flex-start; */
	}

	.demo-ruleForm>>>.u-form-item__body__left__content__ {
		left: -11px;
		top: 0px
	}

	.demo-ruleForm>>>.u-textarea__field {
		font-size: 14px;
	}

	.demo-ruleForm>>>.u-cell__title-text {
		font-size: 14px;
	}

	.demo-ruleForm-thr>>>.u-textarea {
		padding: 9px 9px 25px 9px;
	}

	.demo-ruleForm-thr>>>.u-form-item__body__left__content__label {
		font-size: 14px;
		color: #8e8b9c;
		/* justify-content: flex-start; */
	}

	.demo-ruleForm-thr>>>.u-form-item__body__left__content__ {
		left: -11px;
		top: 0px
	}

	.demo-ruleForm-thr>>>.u-textarea__field {
		font-size: 14px;
	}

	.demo-ruleForm-thr>>>.u-cell__title-text {
		font-size: 14px;
	}


	/* .demo-ruleForm>>>.u-textarea {
		padding: 6px 9px;
	} */

	.card {
		margin-bottom: 18px;
	}

	.sub-form {
		margin: 20px 16px 10px 16px;
		padding: 20px 30px 10px 30px;
		background-color: #ffffff;
		border-radius: 10px;
	}

	.title-content {
		/* margin: 0px 90px 20px 90px; */
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		padding-bottom: 10px;
	}

	.add-top {
		display: flex;
		justify-content: flex-end;
	}

	.add-top-btn {
		/* position: absolute; */
		/* top: -50; */
	}

	.add-top-btn>>>.u-button--mini {
		min-width: 50px;
		height: 25px;
	}

	.add-top-btn>>>.u-button--square {
		border-bottom-left-radius: 0px;
		border-bottom-right-radius: 0px;
		border-top-left-radius: 0px;
		border-top-right-radius: 0px;
	}

	.btn-top {
		width: 10px;
		display: flex;
		/* justify-content: flex-end; */
	}

	.bottom-button {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		padding: 10px 16px;
		box-sizing: border-box;
		background: #fff;
		z-index: 999;
	}

	.upload-title {
		color: #303133;
		font-size: 15px;
		line-height: 22px;
		padding: 8px 0;
	}

	.page-wrap>>>.u-upload__button {
		margin-bottom: 0;
	}
</style>