<template>
	<view class="todo-page">
		<step-title :stepPage="stepsPage" :stepText="stepsText"></step-title>
		<view class="allview">
			<view class="card" v-if="stepsPageList === 0">
				<u--form labelWidth="auto" :model="model" ref="wForm" class="demo-ruleForm">
					<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="Product_Unit">
						<u--input v-model="model.Product_Unit" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>
						<!-- 	<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12">
						</u-icon> -->
					</u-form-item>
					<u-form-item label="检查类型：" prop="Check_Type">
						<u--input v-if="model.Nav_CheckType" v-model="model.Nav_CheckType.NAME" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px"></u--input>
						<!-- <u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12">
						</u-icon> -->
					</u-form-item>
					<u-form-item label="检查周期：" prop="PLANCHECKFREQUENCYName">
						<u--input v-model="model.PLANCHECKFREQUENCYName" disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px"></u--input>
						<!-- 	<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12">
						</u-icon> -->
					</u-form-item>
					<u-form-item label="检查层级：" prop="DEPARTMENT_TYPEName">
						<u--input v-model="model.DEPARTMENT_TYPEName" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">

						</u--input>
						<!-- 	<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12">
						</u-icon> -->
					</u-form-item>
					<u-form-item required label="检查时间：" prop="CHECK_TIME" @click="showCheckDate(1)">
						<u--input v-model="model.CHECK_TIME" disabled disabledColor="#ffffff" placeholder="请选择检查时间" border="none" inputAlign="right" fontSize="14px">

						</u--input>
						<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12">
						</u-icon>
					</u-form-item>
					<view class="upload-title">附件：</view>
					<full-upload v-model="model.Nav_RectifyFiles" :isShowBtn='true' :listProp='listPropUpload' :listPropVal='listPropValUpload'></full-upload>

				</u--form>
			</view>
			<view style="padding: 10px 16px;" v-if="stepsPageList === 0" class="bottom-button">
				<u-button type="primary" @click="stepAdd" color="#3d4b70">下一步</u-button>
			</view>
			<view class="card" v-if="stepsPageList === 1">
				<u--form labelWidth="auto" :model="model" ref="wForm" class="sub-form" :rules="rules">


					<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;margin-top: 20px;">检查内容</view>
					<uni-collapse :border="false" accordion>
						<view v-for="(item, index) in model.Nav_RectifyDetails" :key="index">
							<uni-collapse-item title-border="none" :border="false">
								<template v-slot:title>
									<view class="uni-collapse-item__title-box">
										<view class="uni-collapse-item__title-text">
											{{item.Nav_RiskArea?index+1+'.'+item.Nav_RiskArea.NAME:index+1+'.'}}
											<!-- <span v-if="item.Nav_RecitifyUser && item.Nav_RecitifyUser.NAME">
												（{{ item.Nav_RecitifyUser.NAME}}）
											</span> -->
										</view>
										<view @click.stop>
											<u-icon @click="handleDelRowBefore(index)" name="trash" color="#ff4d4f" size="21" style="margin-right: 10px;"></u-icon>
										</view>
									</view>
								</template>
								<view class="content" style="padding-left:10px;">
									<u-form-item required label="检查区域：" prop="CHECK_TIME" @click="handleShowSheetForArea(item,{title: '检查区域', name: 'Nav_RiskArea'})">
										<u--input disabled v-model="(item.Nav_RiskArea||{}).NAME" disabledColor="#ffffff" placeholder="请选择检查区域" border="none" inputAlign="right" fontSize="14px">

										</u--input>
										<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12">
										</u-icon>
									</u-form-item>
									<u-form-item  label="隐患描述：" prop="CHECK_TIME" @click="handleShowSheetForArea(item,{title: '隐患描述', name: 'Nav_Question'})">
										<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12">
										</u-icon>
									</u-form-item>
									<u-textarea v-model="(item.Nav_Question||{}).DESCREPTION" disabled placeholder="请选择隐患描述">
									</u-textarea>
									<!-- <u--textarea v-model="item.Nav_Question.DESCREPTION" disabled placeholder="请选择隐患描述" maxlength="-1"></u--textarea> -->
									<u-form-item required label="隐患等级" prop="HIDDEN_LEVEL" @click="handleChange(item)" border-bottom>
										<u--input v-model="item.HIDDEN_LEVELName" disabled placeholder="请选择隐患等级" suffixIcon="arrow-down" suffixIconStyle="font-size: 12px" disabledColor="#ffffff" inputAlign="right"
											fontSize="14px" border="none">
										</u--input>
									</u-form-item>
									<u-form-item label="隐患地点" prop="HIDDEN_PLACE" border-bottom>
										<u--input v-model="item.HIDDEN_PLACE" placeholder="请填写隐患地点" disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
										</u--input>
									</u-form-item>
									<u-form-item label="整改措施" prop="HIDDEN_PLACE" border-bottom>
										<u--input v-model="item.RECTIFICATION_MEASURES" placeholder="请填写整改措施" disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
										</u--input>
									</u-form-item>

									<u-form-item  label="整改期限" prop="HIDDEN_PLACE" @click="showCheckDate(2,item)">
										<u--input v-model="item.RECITIFY_TIME" placeholder="请选择整改期限" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
										</u--input>
										<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12">
										</u-icon>
									</u-form-item>
									<u-form-item required label="整改落实人" prop="HIDDEN_PLACE" @click="handleShowSheetForArea(item,{title: '整改落实人', name: 'Nav_ImplementUser'})" border-bottom>
										<u--input v-model="(item.Nav_ImplementUser||{}).NAME" placeholder="请选择整改落实人" suffixIcon="arrow-down" suffixIconStyle="font-size: 12px" disabled disabledColor="#ffffff"
											inputAlign="right" fontSize="14px" border="none">
										</u--input>
									</u-form-item>
									<u-form-item required label="验收人" prop="HIDDEN_PLACE" @click="handleShowSheetForArea(item,{title: '验收人', name: 'Nav_AcceptUser'})" border-bottom>
										<u--input v-model="(item.Nav_AcceptUser||{}).NAME" placeholder="请选择验收人" suffixIcon="arrow-down" suffixIconStyle="font-size: 12px" disabled disabledColor="#ffffff"
											inputAlign="right" fontSize="14px" border="none">
										</u--input>
									</u-form-item>
									<u-form-item label="隐患照片" prop="CHECKSTANDARD">
									</u-form-item>
									<full-upload v-model="item.Nav_RectifyDetailFiles" :isShowBtn='true' :listProp='listPropUpload' :listPropVal='listPropValUpload'></full-upload>
								</view>


							</uni-collapse-item>
						</view>
					</uni-collapse>
					<u-form-item @click="handleNewCheckContent">
						<u-button text="新增检查区域" type="primary"></u-button>
					</u-form-item>
				</u--form>

			</view>

			<view style="padding: 10px 16px;display: flex;flex-direction: row;" v-if="stepsPageList === 1" class="bottom-button">
				<u-button type="primary" @click="stepReduce" color="#3d4b70" :plain="true" style="margin-right: 5px;">上一步</u-button>
				<u-button type="primary" @click="submit" color="#3d4b70" style="margin-left: 5px;">提交</u-button>
			</view>


			<people-selector :defaultChecked="peopleSelectOption.defaultChecked" :show="peopleSelectOption.showSelector" @select="handleSelectorPeople" @close="peopleSelectOption.showSelector = false">
			</people-selector>
			<query-selector :multiple="selectorInfo.isMultiple" :show="selectorInfo.showPopup" :title="selectorInfo.title" :lists="selectorInfo.dataLists" :defaultChecked="selectorInfo.defaultChecked"
				@search="handleSearch" @select="handleSelected" @close="selectorInfo.showPopup=false" :total="selectorInfo.totalCount" />
			<u-modal :show="showDelModalIndex >= 0" @confirm="confirmDel" @cancel="cacelDel" :showCancelButton="true" title="确认删除？"></u-modal>
			<u-datetime-picker :show="dateTimePickerInfo.showCheckDate" v-model='dateTimePickerInfo.defaultDateTime' @confirm="handleCheckDate" @close="dateTimePickerInfo.showCheckDate = false"
				@cancel="dateTimePickerInfo.showCheckDate = false" :mode="dateTimePickerInfo.mode"></u-datetime-picker>
			<u-picker :show="comPickerInfo.showSheet" :columns="comPickerInfo.columns" @confirm="onConfirmPicker" @close="comPickerInfo.showSheet=false" @cancel="comPickerInfo.showSheet=false" keyName="NAME"></u-picker>
		</view>
	</view>
</template>

<script>
	import {
		extendFilterGroup,
		extendGroupRule,
		extendInclude,
		extendOrder,
		extendRule,
		extendIgnoreDataRule,
		guid,
		initFilter,
		initFilterGroup,
		getRealIndex
	} from '../../../../utils/common'
	import {
		FMProductionUnit,
		CheckPeriods,
		CheckLevels,
		MineTypeIndex,
		MineTypeName
	} from '../../../../utils/enums.js'
	import {
		GetCheckContentsInfo,
		GetDangerRectifyReport,
		DangerRectifyFullUpdate,
		GetRiskAreaInfo,
		GetHiddenScripList,
		GetNewRiskAreaInfo,
		getUserLists,
		CheckTypeNewOrderPaged
	} from '../../../../services/apply/subPages/SK/SKServices.js'
	import {
		getRequest,
	} from '../../../../services/apply/FOServices/FOServices';
	import stepTitle from '@/components/custom/step-title.vue'
	import swipeActionItem from '../../../../uni_modules/uview-ui/libs/config/props/swipeActionItem';
	import {
		getEnum
	} from '../../../../services/common';
	export default {
		components: {
			stepTitle,
		},
		data() {
			return {
				showDelModalIndex: undefined,
				showDelModalIndex1: undefined,
				subsectionList: ['入库', '不入库', ],
				radiolist1: [{
					name: '是',
					disabled: false
				}, {
					name: '否',
					disabled: false
				}],
				curNow: 1,
				RiskLevel: ['一般', '重大'],
				showPopupUnit: false,
				UnitDefaultIndex: [0],
				showPopupRiskLevel: false,
				RiskLevelDefaultIndex: [0],
				UnitLists: [],
				TypeLists: [],
				showPopupType: false,
				TypeDefaultIndex: [0],
				PeriodLists: [],
				showPopupPeriod: false,
				PeriodDefaultIndex: [0],
				LevelLists: [],
				showPopupStep: false,
				showPopupArea: false,
				showPopupLevel: false,
				curTotalStep: 0,
				curTotalArea: 0,
				stepLists: [],
				areaLists: [],
				LevelDefaultIndex: [0],
				showPopupDate: false,
				showPopupRecitifyDate: false,
				listPropUpload: ['NOTIFY_ID'],
				listPropValUpload: [],
				ORG_ID: uni.getStorageSync('orgId'),
				rules: {
					'userInfo.name': {
						type: 'string',
						required: true,
						message: '请填写姓名',
						trigger: ['blur', 'change']
					},
					'userInfo.sex': {
						type: 'string',
						max: 1,
						required: true,
						message: '请选择男或女',
						trigger: ['blur', 'change']
					},
				},
				model: {
					Nav_RectifyFiles: [],
					Check_Type: '',
					Check_Period: '',
					Check_Level: '',
					Check_Date: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd'),
					Nav_RectifyDetails: [{
						Nav_RiskArea: {
							NAME: ''
						},
						Nav_Question: {
							DESCREPTION: ''
						},
						HIDDEN_LEVEL: '',
						HIDDEN_PLACE: '',
						RECTIFICATION_MEASURES: '',
						RECITIFY_TIME: '',
						Nav_AcceptUser: {
							NAME: ''
						},
						Nav_ImplementUser: {
							NAME: ''
						},
						Nav_RectifyDetailFiles: []

					}],
				},
				selectorInfo: {
					name: 'user',
					isMultiple: false,
					showPopup: false,
					totalCount: 0,
					title: '考核结果选择',
					dataItem: {},
					index: 0,
					columns: [],
					dataLists: [],
					defaultText: '',
					defaultChecked: []
				},
				peopleSelectOption: {
					showSelector: false,
					value: null,
					index: 0,
					defaultChecked: []
				},
				comPickerInfo: {
					showSheet: false,
					dataItem: {},
					columns: [],
					title: '',
					dataIndex: undefined,
					formIndex: undefined,
					name: ''
				},
				dateTimePickerInfo: {
					showCheckDate: false,
					dataIndex: undefined,
					defaultDateTime: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss'),
					value: '',
					name: '',
					mode: ''
				},
				dateTime: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd'),
				dateRecitifyTime: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd'),
				stepsText: ['发起', '确认', '归档'],
				stepsPage: 0,
				stepsPageList: 0,
				Pu: '',
				Check_Type_ID: '',
				TypeListres: {},
				TaskID: '',
				poparr: '',
				currentOperateStep: {},
				currentOperateArea: {},
				chooseCheckContent: '',
				chooseCheckArea: '',
				showPopupMonitor: false,
				currentOperateMonitor: {},
				monitorLists: [],
				curTotalMonitor: 0,
				chooseCheckMonitor: '',
				chooseRecitify: '',

				showPopupAccept: false,
				currentOperateAccept: {},
				AcceptLists: [],
				curTotalAccept: 0,
				chooseCheckAccept: '',
				nowIndex: 0,
				nowName: '',
				enumsData: {}, // 存储所有枚举数据（键：枚举名称，值：处理后的枚举列表）
				enumsText: {} // 存储枚举文本列表（用于下拉选择等场景）


			}
		},
		onLoad(option) {
			this.TaskID = option.taskID ? option.taskID : '';
			this.ID = option.ID ? option.ID : '';
			this.fetchEnums(['SKProductionUnit', 'SKPLANCHECKFREQUENCYEnum', 'SKDepartmentTypeEnum', 'SKHiddenLevel']);
		},
		methods: {
			async fetchEnums(enumNames) {
				try {
					// 存储所有枚举请求的Promise
					const enumPromises = enumNames.map(name => {
						return getEnum({
							name
						}).then(res => {
							// 统一处理枚举格式：添加name/code字段，便于后续映射
							return {
								enumName: name,
								data: res.map(item => ({
									...item,
									name: item.NAME, // 统一显示名称字段
									code: item.ID // 统一值字段
								}))
							};
						});
					});

					// 等待所有枚举请求完成
					const results = await Promise.all(enumPromises);
					// 存储枚举结果到data中（键为枚举名称，值为处理后的数据）
					results.forEach(({
						enumName,
						data
					}) => {
						this.enumsData[enumName] = data;
						// 生成文本列表（如需要）
						this.enumsText[enumName] = data.map(item => item.name);
					});
					// 所有枚举获取完成后，执行loadData
					this.loadData();
				} catch (error) {
					console.error('枚举请求失败:', error);
					uni.showToast({
						title: '枚举数据加载失败',
						icon: 'none'
					});
				}
			},
			loadData() {
				// this.getCheckType()
				// const json = {}
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "")
				extendRule(json, 'ID', 1, this.ID);
				extendInclude(json, 'Nav_CheckType');
				extendInclude(json, 'Nav_RectifyFiles.Nav_ImgFile');
				extendInclude(json, 'Nav_RectifyDetails');
				extendInclude(json, 'Nav_RectifyDetails.Nav_RiskArea');
				extendInclude(json, 'Nav_RectifyDetails.Nav_Contents');
				extendInclude(json, 'Nav_RectifyDetails.Nav_ImplementUser');
				extendInclude(json, 'Nav_RectifyDetails.Nav_AcceptUser');
				extendInclude(json, 'Nav_RectifyDetails.Nav_RectifyDetailFiles.Nav_ImgFile');
				// extendRule(json, 'TASK_ID', 1, this.TaskID);
				extendIgnoreDataRule(json)
				GetDangerRectifyReport(json).then(res => {
					this.model = res;
					this.model.ID = this.ID
					this.model.Product_Unit = res.MineType !== undefined ? this.enumsData['SKProductionUnit'].find(item => item.code === res.MineType).name : '';
					this.model.PLANCHECKFREQUENCYName = res.PLANCHECKFREQUENCY !== undefined ? this.enumsData['SKPLANCHECKFREQUENCYEnum'].find(item => item.code === res.PLANCHECKFREQUENCY).name : '';
					this.model.DEPARTMENT_TYPEName = res.DEPARTMENT_TYPE !== undefined ? this.enumsData['SKDepartmentTypeEnum'].find(item => item.code === res.DEPARTMENT_TYPE).name : '';
					if (this.model.Nav_RectifyDetails && this.model.Nav_RectifyDetails.length > 0) {
						this.model.Nav_RectifyDetails.map(item => {
							item.HIDDEN_LEVELName = item.HIDDEN_LEVEL !== undefined ? this.enumsData['SKHiddenLevel'].find(item1 => item1.code === item.HIDDEN_LEVEL).name : ''
							item.RECITIFY_TIME = item.RECITIFY_TIME ? uni.$u.timeFormat(item.RECITIFY_TIME,
								'yyyy-mm-dd') : ''
							// item.MARKName = this.enumsData['SKMarkEnum'].find(item1 => item1.code === item.MARK).name;
						})
					}
					this.stepsPage = res.STATUS == 0 ? 0 : res.STATUS == 10 ? 1 : 2
				})


			},
			stepAdd() {
				if (!this.model.CHECK_TIME) {
					uni.showToast({
						title: '请选择检查时间',
						icon: 'none'
					})
					return
				}
				this.stepsPageList = this.stepsPageList + 1
			},
			stepReduce() {
				this.stepsPageList = this.stepsPageList - 1
			},
			showCheckDate(dataIndex, item) {
				// let date = new Date()
				// this.dateTimePickerInfo.showCheckDate = true
				this.dateTimePickerInfo = {
					showCheckDate: true,
					defaultDateTime: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss'),
					dataIndex: dataIndex,
					item: item,
					mode: dataIndex == 1 ? 'datetime' : 'date'
				}
			},
			//隐藏控件 显示时间
			handleCheckDate(e) {

				if (this.dateTimePickerInfo.dataIndex == 1) {
					this.model.CHECK_TIME = uni.$u.timeFormat(e.value,
						'yyyy-mm-dd hh:MM:ss')
				} else if (this.dateTimePickerInfo.dataIndex == 2) {
					const realIndex = getRealIndex(this.dateTimePickerInfo.item, this.model.Nav_RectifyDetails)
					this.model.Nav_RectifyDetails[realIndex].RECITIFY_TIME = uni.$u.timeFormat(e.value,
						'yyyy-mm-dd')
				}
				this.dateTimePickerInfo.showCheckDate = false

			},
			handleShowSheetForArea(item, todo) {
				const validDetails = this.model.Nav_RectifyDetails.filter(i => !i.IS_DELETED);
				const index = validDetails.indexOf(item);
				this.handleShowSheet({
					title: todo.title,
					name: todo.name,
					index: index
				});
			},
			async handleShowSheet(p) {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "", 0, p.pageIndex ?? 1)
				// const json = initFilter(this.ORG_ID, "", "", 0, p.pageIndex ?? 1)
				let dataSelect = []
				var defaultChecked = []
				this.selectorInfo.isMultiple = false




				json.Limit = 20
				if (p.pageIndex) {
					json.Start = (p.pageIndex - 1) * json.Limit;
				}
				json.Sort = 'NAME'
				// json.SelectField = ["ID", "NAME", "NAME", "CODE"]
				// json.Sort = "NAME"
				// json.Order = 1
				if (p.name == 'Nav_RiskArea') {
					if (p.val) {
						extendRule(json, 'NAME', 9, p.val);
					}

					// extendRule(json, 'DEVICE_STATUS', 1, '1');
					dataSelect = await GetNewRiskAreaInfo(json).then(res => {
						this.selectorInfo.totalCount = res.TotalCount
						if (res != undefined && res.Data.length > 0) {
							for (let i = 0; i < res.Data.length; i++) {
								res.Data[i].name = res.Data[i].NAME
							}
						}
						return res.Data
					})
				} else if (p.name == 'Nav_Question') {
					if (p.val) {
						extendRule(json, 'DESCREPTION', 9, p.val);
					}

					let data = this.model.Nav_RectifyDetails[p.index]
					if (data.CHECK_CONTENTS_ID && data.CHECK_CONTENTS_ID !== '') {
						extendRule(json, 'CHECK_CONTENTS_ID', 1, data.CHECK_CONTENTS_ID);
					}
					json.Sort = 'DESCREPTION'
					dataSelect = await GetHiddenScripList(json).then(res => {
						this.selectorInfo.totalCount = res.TotalCount
						if (res != undefined && res.Data.length > 0) {
							for (let i = 0; i < res.Data.length; i++) {
								res.Data[i].name = res.Data[i].DESCREPTION
							}
						}
						return res.Data
					})
				} else if (p.name == 'Nav_ImplementUser' || p.name == 'Nav_AcceptUser') {
					if (p.val) {
						extendRule(json, 'NAME', 9, p.val);
					}


					dataSelect = await getUserLists(json).then(res => {
						this.selectorInfo.totalCount = res.TotalCount
						if (res != undefined && res.Data.length > 0) {
							for (let i = 0; i < res.Data.length; i++) {
								res.Data[i].name = res.Data[i].NAME
							}
						}
						return res.Data
					})
				}

				if (defaultChecked == null)
					defaultChecked = []
				if (dataSelect.length) {
					this.selectorInfo = {
						itemData: p.itemData != undefined ? p.itemData : this.selectorInfo
							.itemData, //itemData: p.itemData,  搜索的时候  p.itemData为空  赋值修改 为 她自己本身 this.selectorInfo.itemData
						isMultiple: this.selectorInfo.isMultiple,
						totalCount: this.selectorInfo.totalCount,
						showPopup: true,
						title: p.title,
						name: p.name,
						dataLists: dataSelect,
						defaultChecked: defaultChecked,
						index: p.index
					}
				} else {
					// 暂无数据
				}
			},
			//数据加载
			handleSearch(val, pageIndex) {
				var p = {
					name: this.selectorInfo.name,
					title: this.selectorInfo.title,
					val: val,
					pageIndex: pageIndex,
					index: this.selectorInfo.index
				}
				this.handleShowSheet(p)
			},

			handleSelected(e) {
				this.selectorInfo.showPopup = false
				const validDetails = this.model.Nav_RectifyDetails.filter(i => !i.IS_DELETED);
				const index = this.selectorInfo.index;
				const realIndex = this.model.Nav_RectifyDetails.findIndex(item => item === validDetails[index]);
				if (this.selectorInfo.name == 'Nav_RiskArea') {
					this.model.Nav_RectifyDetails[realIndex].Nav_RiskArea = e;
					this.model.Nav_RectifyDetails[realIndex].RISK_AREA_ID = e.ID;
				} else if (this.selectorInfo.name == 'Nav_ImplementUser') {
					this.model.Nav_RectifyDetails[realIndex].Nav_ImplementUser = e;
					this.model.Nav_RectifyDetails[realIndex].IMPLEMENT_USER_ID = e.ID;
				} else if (this.selectorInfo.name == 'Nav_Question') {
					this.model.Nav_RectifyDetails[realIndex].Nav_Question = e;
					this.model.Nav_RectifyDetails[realIndex].CHECK_QUESTION_ID = e.ID;
				} else if (this.selectorInfo.name == 'Nav_AcceptUser') {
					this.model.Nav_RectifyDetails[realIndex].Nav_AcceptUser = e;
					this.model.Nav_RectifyDetails[realIndex].ACCEPT_USER_ID = e.ID;
				}


			},
			handleChange(item) {
				this.comPickerInfo = {
					showSheet: true,
					columns: [this.enumsText['SKHiddenLevel']],
					dataItem: item,
					name: name
				}

			},
			onConfirmPicker(e) {
				this.comPickerInfo = {
					showSheet: false,
					dataItem: this.comPickerInfo.dataItem,
					columns: [],
					title: '',
					formIndex: undefined
				}
				this.comPickerInfo.dataItem.HIDDEN_LEVELName = e.value[0]
				this.comPickerInfo.dataItem.HIDDEN_LEVEL = this.enumsData['SKHiddenLevel'][e.indexs[0]].code


			},
			handleNewCheckContent() {
				this.model.Nav_RectifyDetails.unshift({
					ID: guid(),
					ORG_ID: this.ORG_ID,
					HIDDEN_DANGER_RECTIFY_NOTICE_ID: this.model.ID,
					HIDDEN_LEVEL: '',
					HIDDEN_LEVELName: '',
					HIDDEN_PLACE: '',
					RECTIFICATION_MEASURES: '',
					RECITIFY_TIME: '',
					Nav_RectifyDetailFiles: [],
					Nav_RiskArea: {
						NAME: ''
					},
					Nav_Question: {
						DESCREPTION: ''
					},
					Nav_ImplementUser: {
						NAME: ''
					},
					Nav_AcceptUser: {
						NAME: ''
					},
					RISK_AREA_ID: '',
					CHECK_QUESTION_ID:'',
					IMPLEMENT_USER_ID:'',
					ACCEPT_USER_ID:'',
				})
				this.model.Nav_RectifyDetails = [...this.model.Nav_RectifyDetails]
			},
			handleDelRowBefore(index) {
				this.nowIndex = index
				this.showDelModalIndex = index

			},
			confirmDel() {
				this.model.Nav_RectifyDetails.splice(this.nowIndex, 1)
				this.showDelModalIndex = undefined
			},
			cacelDel() {
				this.showDelModalIndex = undefined
			},
			submit() {
				for (let item of this.model.Nav_RectifyDetails) {
					if (!item.Nav_RiskArea||!item.Nav_RiskArea.NAME) {
						uni.showToast({
							title: '请选择检查区域',
							icon: 'none'
						})
						return
					}
					if (!item.Nav_ImplementUser||!item.Nav_ImplementUser.NAME) {
						uni.showToast({
							title: '请选择整改落实人',
							icon: 'none'
						})
						return
					}
					if (!item.Nav_AcceptUser||!item.Nav_AcceptUser.NAME) {
						uni.showToast({
							title: '请选择验收人',
							icon: 'none'
						})
						return
					}
					if (!item.HIDDEN_LEVELName) {
						uni.showToast({
							title: '请选择隐患等级',
							icon: 'none'
						})
						return
					}
	

				}

				
				this.modelEdit = JSON.parse(JSON.stringify(this.model))
				delete this.modelEdit.Nav_ApplyDepartment
				delete this.modelEdit.Nav_ApplyUser
				delete this.modelEdit.Nav_CheckType
				this.modelEdit.Nav_RectifyDetails.map(item => {
					item.PUBLISH = 'SaveAndNotify'
					delete item.Nav_AcceptUser
					delete item.Nav_RiskArea
					delete item.Nav_Contents
					delete item.Nav_ImplementUser
					delete item.Nav_RecitifyUser
					delete item.Nav_RectifyDetailBasics
					delete item.Nav_Question
				})
				if (this.TaskID == null || this.TaskID == '') {
					this.modelEdit.TaskID = '00000000-0000-0000-0000-000000000000'
				} else {
					this.modelEdit.TaskID = this.TaskID
				}
				if (this.modelEdit.ORG_ID == null || this.modelEdit.ORG_ID == '')
					this.modelEdit.ORG_ID = this.ORG_ID
				
				this.modelEdit.PUBLISH = 'SaveAndNotify'
				// console.log(this.modelEdit,'9999')
				DangerRectifyFullUpdate(this.modelEdit).then(res => {
					if (res) {
						uni.$showMsgFunc('操作成功!', () => {
							uni.navigateBack()
						}, 'success', 1000)
					}
				})


			}

		}



	}
</script>

<style scoped>
	@import url("../../../../style/css/newTemplate.css");
</style>