<template>
	<view class="page">
		<view class="form-sub">
			<u-form :model="dataModel" :rules="rules" ref="wForm" label-width="90px" class="demo-ruleForm" size="mini">
				<u-form-item label="作业名称" prop="Nav_OperationStep.NAME" required @click="handleChangeStep(dataModel.Nav_OperationStep,'Nav_OperationStep')">
					<!-- @click="handleShowSheet({title: '作业名称', name: 'stepName'})" -->
					<u--input disabledColor="#fff" v-model="dataModel.Nav_OperationStep.NAME" disabled placeholder="请选择作业名称" suffixIcon="arrow-down" suffixIconStyle="font-size:14px" fontSize="14px"
						customStyle="margin:0px;display:flex;padding:3px 9px">
					</u--input>

				</u-form-item>
				<u-form-item label="审批层级" prop="AUDIT_LEVEL_SHOW" required>
					<u--input disabledColor="#fff" v-model="dataModel.AUDIT_LEVEL_SHOW" disabled fontSize="14px" customStyle="margin:0px;display:flex;padding:3px 9px"></u--input>
				</u-form-item>
				<u-form-item label="监护人" prop="Nav_MonitorUser.NAME" required @click="handleChangeMonitor(dataModel.Nav_MonitorUser)">
					<!-- @click="handleShowSheet({title: '监护人', name: 'monitorUser'})" -->
					<u--input disabledColor="#fff" v-model="dataModel.Nav_MonitorUser.NAME" disabled placeholder="请选择监护人" suffixIcon="arrow-down" suffixIconStyle="font-size:14px" fontSize="14px"
						customStyle="margin:0px;display:flex;padding:3px 9px">
					</u--input>
				</u-form-item>
				<u-form-item label="作业申请人" prop="Nav_ApplyUser.NAME" required @click="handleShowSheet({title: '作业申请人', name: 'applyUser'})">
					<u--input disabledColor="#fff" v-model="dataModel.Nav_ApplyUser.NAME" disabled placeholder="请选择作业申请人" suffixIcon="arrow-down" suffixIconStyle="font-size:14px" fontSize="14px"
						customStyle="margin:0px;display:flex;padding:3px 9px">
					</u--input>
				</u-form-item>
				<u-form-item label="属地部门" prop="Nav_Department.NAME" @click="handleChangeStep(dataModel.Nav_Department,'Nav_Department')">
					<u--input disabledColor="#fff" v-model="(dataModel.Nav_Department||{}).NAME" disabled placeholder="请选择属地部门" suffixIcon="arrow-down" suffixIconStyle="font-size:14px" fontSize="14px"
						customStyle="margin:0px;display:flex;padding:3px 9px">
					</u--input>
				</u-form-item>
				<u-form-item label="开始时间" required prop="JOB_DATE" @click="showCheckDate({ name: 'jobDate'})">
					<u--input disabledColor="#fff" v-model="dataModel.JOB_DATE" disabled placeholder="请选择开始时间" suffixIcon="arrow-down" suffixIconStyle="font-size:14px" fontSize="14px"
						customStyle="margin:0px;display:flex;padding:3px 9px">
					</u--input>
				</u-form-item>
				<u-form-item label="结束时间" required 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-down" suffixIconStyle="font-size:14px" fontSize="14px"
						customStyle="margin:0px;display:flex;padding:3px 9px">
					</u--input>
				</u-form-item>
				<u-form-item label="作业区域" required prop="Nav_Area.NAME" @click="handleChangeStep(dataModel.Nav_Area,'Nav_Area')">
					<u--input disabledColor="#fff" v-model="(dataModel.Nav_Area||{}).NAME" disabled placeholder="请选择作业区域" suffixIcon="arrow-down" suffixIconStyle="font-size:14px" fontSize="14px"
						customStyle="margin:0px;display:flex;padding:3px 9px" >
					</u--input>
				</u-form-item>
				<u-form-item label="作业地点" prop="JOB_LOCATION" required>
					<u--textarea v-model="dataModel.JOB_LOCATION" placeholder="请输入内容" autoHeight count></u--textarea>
					<!-- <u--input v-model="dataModel.JOB_LOCATION" placeholder="请输入内容" fontSize="14px"></u--input> -->
				</u-form-item>
				<u-form-item label="作业原因" prop="JobCause" required>
					<u--textarea v-model="dataModel.JobCause" placeholder="请输入内容" autoHeight count></u--textarea>
					<!-- <u--input v-model="dataModel.JobCause" placeholder="请输入内容" fontSize="14px"></u--input> -->
				</u-form-item>
				<view v-if="OrgId=='d9871ba8-0eec-9e4a-bb87-7d5a540d8913'">
					<u-form-item label="可燃气体" prop="JOB_LOCATION" class="lkwandoa1">
						<u--input v-model="dataModel.FLAM_GAS" placeholder="请输入内容" fontSize="14px" border="none"></u--input>
					</u-form-item>
					<u-form-item label="氧气" prop="JOB_LOCATION" class="lkwandoa1">
						<u--input v-model="dataModel.OXYGEN" placeholder="请输入内容" fontSize="14px" border="none"></u--input>
					</u-form-item>
					<u-form-item label="一氧化碳" prop="JOB_LOCATION" class="lkwandoa1">
						<u--input v-model="dataModel.CARBON" placeholder="请输入内容" fontSize="14px" border="none"></u--input>
					</u-form-item>
					<u-form-item label="硫化氢" prop="JOB_LOCATION" class="lkwandoa1">
						<u--input v-model="dataModel.HYDROGEN" placeholder="请输入内容" fontSize="14px" border="none"></u--input>
					</u-form-item>
				</view>
			</u-form>
		</view>
		<!-- <u-sticky offset-top="0">
			<view class="tabs-title" id="tabs-title" :style="{margin:isTop==true?'0px':'16px'}">
				<view>
					<u-tabs ref="tabs" :activeStyle="{
		    fontWeight: 'bold',
		    transform: 'scale(1)',
			fontSize:'14px',
			color:'#005BEA'
		}" :inactiveStyle="{
		    transform: 'scale(1)',
			fontSize:'14px',
		}" :list="list" lineColor="#005BEA" :is-scroll="true" :current="currentIndex" @change="change">
						<view class="icon-tabs" slot="right" @tap="changeIndex">
							<u-icon size="14" name="arrow-right" bold></u-icon>
						</view>
					</u-tabs>
				</view>


			</view>
		</u-sticky> -->



		<view class="page-wrap">
			<view class="sub-form">
				<view>
					<view class="title-content">
						<view style="display: flex;flex-direction: row;">
							<view style="display: flex;flex-direction: row; justify-content: space-between;align-items: center;">
								<view style="display: flex;align-items: center;" v-if="thisUserShow===false" @click="handleUnfoldUser">
									<u-icon name="arrow-down"></u-icon>
								</view>
								<view style="display: flex;align-items: center;" v-if="thisUserShow===true" @click="handleUnfoldUser">
									<u-icon name="arrow-up"></u-icon>
								</view>
							</view>
							<view style="font-size: 16px;font-weight: bold;margin-left: 5px;">作业人员</view>
						</view>

						<view @click="handleAddUser">
							<u-button type="primary" text="新增" size="small"></u-button>
							<!-- <u--text text="新增作业人员" size='12' color="#fff"></u--text> -->
						</view>
					</view>
					<u--form labelPosition="left" labelWidth="80px" ref="sForm" class="demo-ruleForm" v-if="thisUserShow===true">
						<!-- <u-collapse @change="changeCollapse" @close="close" @open="open" :value="['1']"> -->
						<view class="form-sub-add" v-for="(item, index) in dataModel.Nav_CrucialLicensePerson" :key="index">
							<view>
								<view style="font-size: 14px;padding: 10px 10px;display: flex;flex-direction: row;justify-content: space-between;">
									<view style="display: flex;flex-direction: row; justify-content: space-between;align-items: center;">
										<view style="display: flex;flex-direction: row;align-items: center;">
											<view style="background-color: #3c9cff;padding:5px 10px;margin-right: 10px;border-radius: 5px;color: #fff;font-weight: bold;">
												{{index+1}}
											</view>
											<view>{{item['Nav_User'].NAME.slice(0,20)}}</view>
											<!-- {{index+1+'.'+item.NAME.slice(0,20)}} -->
										</view>
									</view>
									<view style="display: flex;flex-direction: row; justify-content: space-between;align-items: center;">
										<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 class="form-sub-content" v-if="thisUser.indexOf(index)!==-1">
									<!-- <view slot="value" class="row-action">
										</view> -->
									<u-form-item label="人员姓名" prop="personName" @click="handleChangeUser(item['Nav_User'])" required>
										<u--input disabled disabledColor="#fff" v-model="item['Nav_User'].NAME" placeholder="请选择人员姓名" suffixIcon="arrow-down" suffixIconStyle="font-size:14px" fontSize="14px"
											customStyle="margin:0px;display:flex;padding:3px 9px"></u--input>
										</u-icon>
									</u-form-item>
									<!-- <u-form-item label="部门" prop="job" required>
										<u--input disabled disabledColor="#fff"
											v-model="item['Nav_User']['Nav_Department'].NAME" fontSize="14px"
											customStyle="margin:0px;display:flex;padding:3px 9px"></u--input>
									</u-form-item> -->
									<u-form-item label="证件类型" prop="CERTIFICATE_TYPE_SHOW" required @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-down" suffixIconStyle="font-size:14px" fontSize="14px"
											customStyle="margin:0px;display:flex;padding:3px 9px"></u--input>
										</u-icon>
									</u-form-item>
									<u-form-item label="证件名称" prop="certificateName" required @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-down" suffixIconStyle="font-size:14px" fontSize="14px"
											customStyle="margin:0px;display:flex;padding:3px 9px"></u--input>
										</u-icon>
									</u-form-item>
									<u-form-item label="证件编号" prop="CertificateCode" required>
										<u--input disabled disabledColor="#fff" v-model="item['Nav_Train'].CERTIFICATE_CODE" inputAlign="right"></u--input>
									</u-form-item>
									<u-form-item label="身份证号" prop="JOB_DOCUMENT">
										<u--input disabledColor="#fff" v-model="item.JOB_DOCUMENT"></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>

							<!-- <u-collapse-item :name="1" :title="index + 1 + '. ' + item['Nav_User'].NAME"
									:clickable="false" :is-link="false"> -->
							<!-- <text slot="value">
										<u-button type="error"
											style="font-size:14px;margin-left: 5px;padding:8px;height: 30px;" i
											icon="trash" @click="handleDelRowBefore(index)">删除</u-button>
									</text> -->

							<!-- </u-collapse-item> -->
						</view>
						<!-- </u-collapse> -->
					</u--form>

				</view>
			</view>
			<view class="sub-form">
				<view>
					<view class="title-content">
						<!-- <view style="font-size: 16px;font-weight: bold;margin-right: 5px;">作业前确认</view> -->
						<view style="display: flex;flex-direction: row;">
							<view style="display: flex;flex-direction: row; justify-content: space-between;align-items: center;">
								<view style="display: flex;align-items: center;" v-if="thisDetailShow===false" @click="handleUnfoldDetail">
									<u-icon name="arrow-down"></u-icon>
								</view>
								<view style="display: flex;align-items: center;" v-if="thisDetailShow===true" @click="handleUnfoldDetail">
									<u-icon name="arrow-up"></u-icon>
								</view>
							</view>
							<view style="font-size: 16px;font-weight: bold;margin-left: 5px;">作业前确认</view>
						</view>
						<view @click="handleAddDetail">
							<u-button type="primary" text="新增" size="small"></u-button>
						</view>
					</view>
					<u--form labelPosition="left" labelWidth="50px" ref="sForm" class="demo-ruleForm" v-if="thisDetailShow===true">
						<view class="form-sub-add" v-for="(item, index) in dataModel.Nav_SafeConfirms" :key="index">
							<view>
								<view style="font-size: 14px;padding: 10px 10px;display: flex;flex-direction: row;justify-content: space-between;">
									<view style="display: flex;flex-direction: row; justify-content: space-between;align-items: center;">
										<view style="display: flex;flex-direction: row;align-items: center;">
											<view style="background-color: #3c9cff;padding:5px 10px;margin-right: 10px;border-radius: 5px;color: #fff;font-weight: bold;display: flex;">
												{{index+1}}
											</view>
											<view style="display: flex;overflow: hidden;width: 100%;table-layout: fixed;word-break: break-all;">{{item.NAME}}</view>
											<!-- {{index+1+'.'+item.NAME.slice(0,20)}} -->
										</view>
									</view>
									<view style="display: flex;flex-direction: row; justify-content: space-between;align-items: center;">
										<view style="display: flex;align-items: center;" v-if="thisIndex.indexOf(index)==-1" @click="handleAddDetailPush(index)">
											<u-icon name="arrow-down"></u-icon>
										</view>
										<view style="display: flex;align-items: center;" v-if="thisIndex.indexOf(index)!=-1" @click="handleAddDetailPush(index)">
											<u-icon name="arrow-up"></u-icon>
										</view>
									</view>
								</view>
								<view class="form-sub-content" v-if="thisIndex.indexOf(index)!==-1">
									<u-form-item label="顺序" prop="NUM" required>
										<u-number-box v-model="item.NUM" @change="valChangeDetail" :min="0" style="margin-left: auto;"></u-number-box>
									</u-form-item>
									<u-form-item label="名称" prop="NAME" required>
										<u--textarea disabledColor="#fff" v-model="item.NAME" autoHeight count></u--textarea>
										<!-- <u--input disabledColor="#fff" v-model="item.NAME"></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="handleDelRowBeforeDetail(index)">删除</u-button>
									</u-form-item>
								</view>
							</view>
						</view>
					</u--form>
				</view>
			</view>
			<view class="sub-form">
				<view>
					<view class="title-content">
						<!-- <view style="font-size: 16px;font-weight: bold;margin-right: 5px;">作业流程及安全措施</view> -->
						<view style="display: flex;flex-direction: row;">
							<view style="display: flex;flex-direction: row; justify-content: space-between;align-items: center;">
								<view style="display: flex;align-items: center;" v-if="thisFluceShow===false" @click="handleUnfoldFluce">
									<u-icon name="arrow-down"></u-icon>
								</view>
								<view style="display: flex;align-items: center;" v-if="thisFluceShow===true" @click="handleUnfoldFluce">
									<u-icon name="arrow-up"></u-icon>
								</view>
							</view>
							<view style="font-size: 16px;font-weight: bold;margin-left: 5px;">作业流程及安全措施</view>
						</view>

						<view @click="handleAddFlow">
							<u-button type="primary" text="新增" size="small"></u-button>
						</view>
					</view>
					<u--form labelPosition="left" labelWidth="50px" ref="sForm" class="demo-ruleForm" v-if="thisFluceShow===true">
						<view class="form-sub-add" v-for="(item, index) in dataModel.Nav_SafeMeasures" :key="index">
							<view>
								<view style="font-size: 14px;padding: 10px 10px;display: flex;flex-direction: row;justify-content: space-between;">
									<view style="display: flex;flex-direction: row; justify-content: space-between;align-items: center;">
										<view style="display: flex;flex-direction: row;align-items: center;">
											<view style="background-color: #3c9cff;padding:5px 10px;margin-right: 10px;border-radius: 5px;color: #fff;font-weight: bold;">
												{{index+1}}
											</view>
											<view style="display: flex;overflow: hidden;width: 100%;table-layout: fixed;word-break: break-all;">{{item.NAME.slice(0,20)}}</view>
											<!-- {{index+1+'.'+item.NAME.slice(0,20)}} -->
										</view>
									</view>
									<view style="display: flex;flex-direction: row; justify-content: space-between;align-items: center;">
										<view style="display: flex;align-items: center;" v-if="thisFluce.indexOf(index)==-1" @click="handleAddFlucePush(index)">
											<u-icon name="arrow-down"></u-icon>
										</view>
										<view style="display: flex;align-items: center;" v-if="thisFluce.indexOf(index)!=-1" @click="handleAddFlucePush(index)">
											<u-icon name="arrow-up"></u-icon>
										</view>
									</view>
								</view>
								<view class="form-sub-content" v-if="thisFluce.indexOf(index)!==-1">
									<u-form-item label="顺序" prop="NUM" required>
										<u-number-box v-model="item.NUM" @change="valChangeFlow" :min="0" style="margin-left: auto;"></u-number-box>
									</u-form-item>
									<u-form-item label="名称" prop="NAME" required>
										<u--textarea disabledColor="#fff" v-model="item.NAME" autoHeight count></u--textarea>
										<!-- <u--input disabledColor="#fff" v-model="item.NAME"></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="handleDelRowBeforeFlow(index)">删除</u-button>
									</u-form-item>
								</view>
							</view>
						</view>
					</u--form>
				</view>
			</view>
			<!-- <view class="sub-form">
				<view class="sub-form-wrap">
					<view class="sub-form-btns">
						<view class="sub-form-btn" @click="handleAddFlow">
							<u--text type="primary" text="新增作业流程及安全措施+"></u--text>
						</view>
					</view>
					<u--form labelPosition="left" labelWidth="auto" labelAlign="center" errorType="border-bottom"
						ref="sForm">
						<u-collapse :border="false" accordion>
							<uni-card style="margin-bottom: 16px;" margin="0" spacing="0" :is-shadow="false"
								v-for="(item, index) in dataModel.Nav_SafeMeasures">
								<u-collapse-item :title="index + 1 + '. ' + item.NAME">
									<view slot="value" class="row-action">
									</view>
									<u-form-item label="顺序" prop="NUM" borderBottom>
										<u-number-box v-model="item.NUM" @change="valChangeFlow" :min="0"
											style="margin-left: auto;"></u-number-box>
									</u-form-item>
									<u-form-item label="名称" prop="NAME" borderBottom>
										<u--input disabledColor="#fff" v-model="item.NAME" border="none"
											inputAlign="right"></u--input>
									</u-form-item>
									<u-form-item>
										<button type="primary"
											style="height: 100%;background-color: darkorange;width: 60%;font-size:14px"
											@click="handleDelRowBeforeFlow(index)">删除</button>
									</u-form-item>
								</u-collapse-item>
							</uni-card>
						</u-collapse>
					</u--form>
				</view>
			</view> -->
			<view class="sub-form">
				<view>
					<view class="title-content">
						<!-- <view style="font-size: 16px;font-weight: bold;margin-right: 5px;">作业后处理措施</view> -->
						<view style="display: flex;flex-direction: row;">
							<view style="display: flex;flex-direction: row; justify-content: space-between;align-items: center;">
								<view style="display: flex;align-items: center;" v-if="thisMeasureShow===false" @click="handleUnfoldMeasure">
									<u-icon name="arrow-down"></u-icon>
								</view>
								<view style="display: flex;align-items: center;" v-if="thisMeasureShow===true" @click="handleUnfoldMeasure">
									<u-icon name="arrow-up"></u-icon>
								</view>
							</view>
							<view style="font-size: 16px;font-weight: bold;margin-left: 5px;">作业后处理措施</view>
						</view>
						<view @click="handleAddDeal">
							<u-button type="primary" text="新增" size="small"></u-button>
						</view>
					</view>
					<u--form labelPosition="left" labelWidth="50px" ref="sForm" class="demo-ruleForm" v-if="thisMeasureShow===true">
						<view class="form-sub-add" v-for="(item, index) in dataModel.Nav_DealMeasures" :key="index">
							<view>
								<view style="font-size: 14px;padding: 10px 10px;display: flex;flex-direction: row;justify-content: space-between;">
									<view style="display: flex;flex-direction: row;align-items: center;">
										<view style="display: flex;flex-direction: row;align-items: center;">
											<view style="background-color: #3c9cff;padding:5px 10px;margin-right: 10px;border-radius: 5px;color: #fff;font-weight: bold;">
												{{index+1}}
											</view>
											<view style="display: flex;overflow: hidden;width: 100%;table-layout: fixed;word-break: break-all;">{{item.NAME}}</view>
											<!-- {{index+1+'.'+item.NAME.slice(0,20)}} -->
										</view>
									</view>
									<view style="display: flex;flex-direction: row;align-items: center;">
										<view style="display: flex;align-items: center;" v-if="thisMeasure.indexOf(index)==-1" @click="handleAddMeasurePush(index)">
											<u-icon name="arrow-down"></u-icon>
										</view>
										<view style="display: flex;align-items: center;" v-if="thisMeasure.indexOf(index)!=-1" @click="handleAddMeasurePush(index)">
											<u-icon name="arrow-up"></u-icon>
										</view>
									</view>
								</view>
								<view class="form-sub-content" v-if="thisMeasure.indexOf(index)!==-1">
									<u-form-item label="顺序" prop="NUM" required>
										<u-number-box v-model="item.NUM" @change="valChangeDeal" :min="0" style="margin-left: auto;"></u-number-box>
									</u-form-item>
									<u-form-item label="名称" prop="NAME" required>
										<u--textarea disabledColor="#fff" v-model="item.NAME" autoHeight count></u--textarea>
										<!-- <u--input disabledColor="#fff" v-model="item.NAME"></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="handleDelRowBeforeDeal(index)">删除</u-button>
									</u-form-item>
								</view>
							</view>
						</view>
					</u--form>
				</view>
			</view>
			<!-- <view class="sub-form">
				<view class="sub-form-wrap">
					<view class="sub-form-btns">
						<view class="sub-form-btn" @click="handleAddDeal">
							<u--text type="primary" text="新增作业后处理措施+"></u--text>
						</view>
					</view>
					<u--form labelPosition="left" labelWidth="auto" labelAlign="center" errorType="border-bottom"
						ref="sForm">
						<u-collapse :border="false" accordion>
							<uni-card style="margin-bottom: 16px;" margin="0" spacing="0" :is-shadow="false"
								v-for="(item, index) in dataModel.Nav_DealMeasures">
								<u-collapse-item :title="index + 1 + '. ' + item.NAME">
									<view slot="value" class="row-action">
									</view>
									<u-form-item label="顺序" prop="NUM" borderBottom>
										<u-number-box v-model="item.NUM" @change="valChangeDeal" :min="0"
											style="margin-left: auto;"></u-number-box>
									</u-form-item>
									<u-form-item label="名称" prop="NAME" borderBottom>
										<u--input disabledColor="#fff" v-model="item.NAME" border="none"
											inputAlign="right"></u--input>
									</u-form-item>
									<u-form-item>
										<button type="primary"
											style="height: 100%;background-color: darkorange;width: 60%;font-size:14px"
											@click="handleDelRowBeforeDeal(index)">删除</button>
									</u-form-item>
								</u-collapse-item>
							</uni-card>
						</u-collapse>
					</u--form>
				</view>
			</view> -->
			<u-modal :show="showDelModalIndex >= 0" @confirm="confirmDel" title="确认删除？"></u-modal>
			<u-modal :show="showDelModalDetail >= 0" @confirm="confirmDelDetail" title="确认删除？"></u-modal>
			<u-modal :show="showDelModalFlow >= 0" @confirm="confirmDelFlow" title="确认删除？"></u-modal>
			<u-modal :show="showDelModalDeal >= 0" @confirm="confirmDelDeal" 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,
		getRiskArea,
		getDepartmentLists,
		getDetailLists,
		getAllLists,
		getCertificateLists,
		saveJobRecord,
		getCancleJob
	} from '../../../../services/apply/FOServices/FOServices.js'
	import config from '../../../../config/common'
	import {
		OrderPagedUseful,
	} from '../../../../services/common'
	export default {
		data() {
			return {
				OrgId: uni.getStorageSync('orgId'),
				ID: null,
				TaskID: null,
				curTotal: 0,
				curTotalStep: 0,
				curTotalMonitor: 0,
				showDelModalIndex: undefined,
				showDelModalDetail: undefined,
				showDelModalFlow: undefined,
				showDelModalDeal: undefined,
				isLoadOK: false,
				userLists: [],
				stepLists: [],
				monitorLists: [],
				certificateLists: [],
				dataModel: {
					JOB_LOCATION: '',
					OPERATION_STEP_ID: null,
					Nav_OperationStep: {
						CODE: '',
						NAME: ''
					},
					// Nav_ApplyUser: {
					// 	NAME: ''
					// },
					Nav_ApplyUser: uni.getStorageSync('appInfo')?.User,
					Nav_Department: {
						NAME: ''
					},
					Nav_Area:{
						NAME: ''
					},
					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: {},
				nowName: '',
				currentOperateMonitor: {},
				showPopup: false,
				showPopupStep: false,
				showPopupMonitor: false,
				// currentCertificate: {},
				// showPopupCertificate: false,
				rules: {
					'JOB_LOCATION': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change'],
						message: '作业地点不能为空'
					},
					'JobCause': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change'],
						message: '作业原因不能为空'
					},
					'Nav_OperationStep.NAME': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change'],
						message: '作业名称不能为空'

					},
					'Nav_ApplyUser.NAME': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change'],
						message: '作业申请人不能为空'
					},
					'Nav_MonitorUser.NAME': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change'],
						message: '监护人不能为空'
					},
					'Nav_Area.NAME': {
						type: 'string',
						required: 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,
			}
		},
		onLoad(opt) {
			this.handleGetJobGet(opt)
		},
		mounted() {
			// this.handleAddUser()
		},
		methods: {
			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
			},
			changeCollapse(e) {
				console.log('changeCollapse', e)
				console.log(this.collapseIndex, 'index')
				console.log(this.collapseValue, '8888')
			},
			close(e) {
				console.log('close', e)
			},
			open(e) {
				console.log('open', e)
			},
			change(index) {
				this.currentIndex = index.index;
				console.log(this.currentIndex, 'this.currentIndexthis.currentIndex')
			},
			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 = {}
							}
							if (res.TERRITORY_DEPARTMENT_ID == null) {
								this.dataModel.Nav_Department = {}
							}
							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) {
								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) {
				console.log(this.thisUser.indexOf(index) == -1, '08978667')
				if (this.thisIndex.indexOf(index) == -1) {
					this.thisIndex.push(index)
				} else {
					this.thisIndex = this.thisIndex.filter(item => item != index)
				}
			},
			handleAddUserPush(index) {
				console.log(this.thisUser.indexOf(index) == -1, '08978667')
				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
				console.log(index, '2312321')
			},
			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
			},
			confirmDelDetail() {
				this.dataModel.Nav_SafeConfirms.splice(this.showDelModalDetail, 1)
				this.showDelModalDetail = undefined
			},
			confirmDelFlow() {
				this.dataModel.Nav_SafeMeasures.splice(this.showDelModalFlow, 1)
				this.showDelModalFlow = undefined
			},
			confirmDelDeal() {
				this.dataModel.Nav_DealMeasures.splice(this.showDelModalDeal, 1)
				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) {
				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, name) {
				this.currentOperateStep = step
				this.nowName = name
				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;
				}
				if (this.nowName == 'Nav_OperationStep') {
					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
						}
					})
				} else  if (this.nowName == 'Nav_Department') {
					getDepartmentLists(json).then(res => {
						if (res.IsSuccessful) {
							this.stepLists = res.Data.map(i => {
								return {
									...i,
									id: i.ID,
									name: i.NAME,
								}
							})
							this.curTotalStep = res.TotalCount
						}
					})
				} else if (this.nowName == 'Nav_Area') {
					getRiskArea(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
				if (this.nowName == 'Nav_OperationStep') {
					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
						}
					})
				} else if (this.nowName == 'Nav_Department') {
					this.dataModel.Nav_Department = val
					this.dataModel.TERRITORY_DEPARTMENT_ID = val.ID
				} else if (this.nowName == 'Nav_Area') {
					this.dataModel.Nav_Area = val
					this.dataModel.AREA_ID = val.ID
				}

			},
			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 === "stepName") {
				// 	this.dataModel.OPERATION_STEP_ID = e.value[0].ID
				// 	this.dataModel.Nav_OperationStep = e.value[0]
				// 	const orgId = uni.getStorageSync('orgId')
				// 	const json = initFilter(orgId, e.value[0].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
				// 			}
				// 			this.dataModel.AUDIT_LEVEL = res.Data.AUDIT_LEVEL
				// 		}
				// 	})
				// } else
				// if (name === "personName") {
				// 	this.dataModel.Nav_CrucialLicensePerson[dataIndex].Nav_User = e.value[0]
				// 	this.dataModel.Nav_CrucialLicensePerson[dataIndex].USER_ID = e.value[0].ID
				// } else
				//  if (name === 'applyUser') {
				// 	// this.dataModel.applyUser = e.value[0].NAME
				// 	this.dataModel.Nav_ApplyUser = e.value[0]
				// 	this.dataModel.APPLY_USER_ID = e.value[0].ID
				// } else
				//  if (name === 'monitorUser') {
				// 	// this.dataModel.monitorUser = e.value[0].NAME
				// 	this.dataModel.Nav_MonitorUser = e.value[0]
				// 	this.dataModel.MONITOR_USER_ID = e.value[0].ID
				// }
				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
				}
			},
			handleDelAction({
				name
			}) {
				uni.showModal({
					title: '是否删除数据？',
					success: (res) => {
						if (res.confirm) {

						}
					}
				})
			},
			submit() {
				const ele = this.$refs
				ele['wForm'].validate().then(res => {
					this.modelEdit = JSON.parse(JSON.stringify(this.dataModel))
					this.modelEdit.PUBLISH = "SaveAndNotify";
					if (this.TaskID !== null) {
						this.modelEdit.TaskID = this.TaskID;
					}
					this.modelEdit.ID = this.ID ? this.ID : guid();
					this.modelEdit.ORG_ID = uni.getStorageSync('orgId')
					if (this.modelEdit.Nav_CrucialLicensePerson && this.modelEdit.Nav_CrucialLicensePerson.length >
						0) {
						for (let i = 0; i < this.modelEdit.Nav_CrucialLicensePerson.length; i++) {
							if (this.modelEdit.Nav_CrucialLicensePerson[i].TRAIN_ID === null) {
								this.modelEdit.Nav_CrucialLicensePerson[i].Nav_Train = null
							}
						}
					}
					delete this.modelEdit.Nav_Department
					delete this.modelEdit.Nav_Area
					saveJobRecord(this.modelEdit).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('请检查必填项，必填项不能为空')
				})
			},
			cancleJob() {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, this.ID)
				json.TaskID = this.TaskID;
				getCancleJob(json).then(res => {
					uni.$showMsgFunc('操作成功!', () => {
						uni.navigateBack()
					}, 'success', 1000)
				})
			},
			async onNavigationBarButtonTap() {
				if (this.dataModel.IS_PUBLISH === 0) {
					uni.$showMsgFunc('操作成功!', () => {
						uni.navigateBack()
					}, 'success', 1000)
				} else if (this.dataModel.IS_PUBLISH === 9) {
					this.cancleJob();
				} else {
					uni.$showErrorInfo('非驳回状态的作业不可取消')
				}
			},
			uploadFilePromise(url) {
				const appInfoData = uni.getStorageSync('appInfo')
				const userId = appInfoData?.User?.ID || ''
				const orgId = uni.getStorageSync('orgId')
				const tenant = uni.getStorageSync('Tenant') || ''
				const remoteUrl = config.serviceHost('/PF/File/UploadFile')
				return new Promise((resolve, reject) => {
					uni.uploadFile({
						url: remoteUrl,
						filePath: url,
						fileList: url,
						name: 'file',
						formData: {
							OrgId: orgId
						},
						header: {
							Tenant: tenant,
							userid: userId
						},
						success: (res) => {
							if (res.statusCode === 200) {
								const uploadResult = JSON.parse(res.data)
								if (uploadResult.IsSuccessful) {
									resolve(uploadResult.Data)
								}
							}
						}
					});
				})
			},
		}
	}
</script>

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

	.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;
		}
	}

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

	.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;
	}


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

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

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

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

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


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

	.card {
		margin-bottom: 18px;
	}

	.sub-form {
		margin-bottom: 16px;
		border-radius: 4px;
		border: 1px solid #EBEEF5;
		padding: 10px 10px 0px 10px;
		box-shadow: rgba(0, 0, 0, 0.08) 0px 0px 3px 1px;
	}

	.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>