<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" @click="handleChange('SKProductionUnit')">
						<u--input v-model="(model.Nav_ProductionUnit||{}).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="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-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-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-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.filter(i => !i.IS_DELETED)" :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(item)" 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="handleShowSheet({title: '检查区域', name: 'Nav_RiskArea',itemData:item})">
										<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="handleShowSheet({title: '隐患描述', name: 'Nav_Question',itemData:item})">
										<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-form-item label="隐患具体描述：" prop="CHECK_TIME">

									</u-form-item>
									<u-textarea v-model="item.HIDDEN_DESCRIPTION"  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('SKHiddenLevel',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="Nav_Reasons" @click="handleShowSheet({title: '隐患原因', name: 'Nav_Reasons',itemData:item})">
										<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12"></u-icon>
									</u-form-item>
									<u--textarea disabled autoHeight disabledColor="#fff" v-model="item.ReasonsNAME" placeholder="隐患原因" border="none"></u--textarea>



									<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="handleShowSheet({title: '整改落实人', name: 'Nav_ImplementUser',itemData:item})" 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="handleShowSheet({title: '验收人', name: 'Nav_AcceptUser',itemData:item})" 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>
									<u-form-item label="整改措施" prop="HIDDEN_PLACE">

									</u-form-item>
									<u--textarea disabled autoHeight disabledColor="#fff" v-model="(item.Nav_Question||{}).DEMAND" border="none"></u--textarea>
									<u-form-item label="整改措施具体描述" prop="HIDDEN_PLACE">
									</u-form-item>
									<u-textarea v-model="item.REMARK" placeholder="请填写整改措施具体描述">
									</u-textarea>
								</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,
		transformData
	} from '../../../../utils/common'
	import {
		FMProductionUnit,
		CheckPeriods,
		CheckLevels,
		MineTypeIndex,
		MineTypeName
	} from '../../../../utils/enums.js'
	import {
		GetCheckContentsInfo,
		GetDangerRectifyReport,
		DangerRectifyFullUpdate,
		GetRiskAreaInfo,
		GetHiddenScripList,
		GetNewRiskAreaInfo,
		getUserLists,
		CheckTypeNewOrderPaged,
		SKHiddenReason
	} 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,
		GetEnumAnyOrder
	} 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: {
			fetchEnums(enumNames) {
				var dataParm = {
					'name': enumNames.join('|')
				}
				GetEnumAnyOrder(dataParm).then(res => {
					let newd = transformData(res, enumNames)
					this.enumsData = newd[0];
					// 生成文本列表（如需要）
					this.enumsText = newd[1]
					this.loadData();
				})
			},
			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_ProductionUnit');
				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.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') : ''
							let ReasonsNAME = ''
							if (item.Nav_RectifyDetailReasons && item.Nav_RectifyDetailReasons.length > 0) {
								for (let i = 0; i < item.Nav_RectifyDetailReasons.length; i++) {
									ReasonsNAME += (ReasonsNAME.length > 0 ? "," : "") + item
										.Nav_RectifyDetailReasons[i].Nav_Reason.NAME;
								}
							}
							item.ReasonsNAME = ReasonsNAME
							// 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) {
				this.dateTimePickerInfo.item.RECITIFY_TIME = uni.$u.timeFormat(e.value,
						'yyyy-mm-dd')
				}
				this.dateTimePickerInfo.showCheckDate = false

			},
			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);
					}
					if (p.itemData.CHECK_CONTENTS_ID && p.itemData.CHECK_CONTENTS_ID !== '') {
						extendRule(json, 'CHECK_CONTENTS_ID', 1, p.itemData.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
					})
				}else if (p.name == 'Nav_Reasons') {
					if (p.val) {
						extendRule(json, 'NAME', 9, p.val);
					}

					this.selectorInfo.isMultiple = true
					json.Sort = 'NAME'
					json.Limit = 20
					if (p.pageIndex) {
						json.Start = (p.pageIndex - 1) * json.Limit;
					}
					// extendRule(json, 'CHECKOBJECT', 1, this.model.CHECKOBJECT);
					dataSelect = await SKHiddenReason(json).then(res => {
						this.selectorInfo.totalCount = res.TotalCount
						if (res != undefined && res.Data != undefined && res.Data.length > 0) {
							for (let i = 0; i < res.Data.length; i++) {
								res.Data[i].name = res.Data[i].NAME
								// res[i].code = res[i].CODE
							}
						}
						return res.Data
					})
					if (p.itemData.Nav_RectifyDetailReasons.length > 0 && p.itemData.Nav_RectifyDetailReasons[0]
						.Nav_Reason != null) {
						// this.selectorInfo.defaultChecked = []
						p.itemData.Nav_RectifyDetailReasons.forEach(e => {
							defaultChecked.push(e.Nav_Reason)
						})
					} else {
						defaultChecked = null
					}
				}

				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
				if (this.selectorInfo.name == 'Nav_RiskArea') {
					this.selectorInfo.itemData.Nav_RiskArea = e;
					this.selectorInfo.itemData.RISK_AREA_ID = e.ID;
				} else if (this.selectorInfo.name == 'Nav_ImplementUser') {
					this.selectorInfo.itemData.Nav_ImplementUser = e;
					this.selectorInfo.itemData.IMPLEMENT_USER_ID = e.ID;
				} else if (this.selectorInfo.name == 'Nav_Question') {
					this.selectorInfo.itemData.Nav_Question = e;
					this.selectorInfo.itemData.CHECK_QUESTION_ID = e.ID;
				} else if (this.selectorInfo.name == 'Nav_AcceptUser') {
					this.selectorInfo.itemData.Nav_AcceptUser = e;
					this.selectorInfo.itemData.ACCEPT_USER_ID = e.ID;
				}else if (this.selectorInfo.name == 'Nav_Reasons') {
					let listProject = []
					let projectShow = ''
					if (e.length > 0) {
						e.forEach((item, i) => {
							if (item.name != null || item.NAME != null) {
								if (i > 0) {
									projectShow += ' '
								}
								listProject.push({
									ID: guid(),
									HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_ID: this.selectorInfo.itemData.ID,
									REASON_ID: item.ID,
									ORG_ID: item.ORG_ID,
									Nav_Reason: item
								})
								projectShow += item.NAME
							}
						})
					}
					this.selectorInfo.itemData.Nav_RectifyDetailReasons = listProject
					this.selectorInfo.itemData.ReasonsNAME = projectShow
				}


			},
			handleChange(name, item) {
				if (name == 'SKProductionUnit') {
					const json = initFilter(this.ORG_ID)
					getRequest(json, "/FM/UserProductionUnitSet/OrderPaged").then(res => {
						this.comPickerInfo = {
							showSheet: true,
							columns: [res],
							name: name
						}
					})


				} else {
					this.comPickerInfo = {
						showSheet: true,
						columns: [this.enumsText[name]],
						name: name,
						dataItem: item,
					}
				}

			},
			onConfirmPicker(e) {
				if (this.comPickerInfo.name == 'SKProductionUnit') {
					this.model.Nav_ProductionUnit = e.value[0]
					this.model.PRODUCTION_UNIT_ID = e.value[0].ID
				} else {
					this.comPickerInfo.dataItem.HIDDEN_LEVELName = e.value[0]
					this.comPickerInfo.dataItem.HIDDEN_LEVEL = this.enumsData['SKHiddenLevel'][e.indexs[0]].code
				}
				this.comPickerInfo = {
					showSheet: false,
					columns: [],
					title: '',
					formIndex: undefined
				}
			},
			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: '',
						DEMAND:''
					},
					Nav_ImplementUser: {
						NAME: ''
					},
					Nav_AcceptUser: {
						NAME: ''
					},
					RISK_AREA_ID: '',
					CHECK_QUESTION_ID: '',
					IMPLEMENT_USER_ID: '',
					ACCEPT_USER_ID: '',
					Nav_RectifyDetailReasons:[],
					ReasonsNAME:'',
					
					
				})
				this.model.Nav_RectifyDetails = [...this.model.Nav_RectifyDetails]
			},
			handleDelRowBefore(item) {
				item.IS_DELETED = true
				this.$forceUpdate()

			},
			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.filter(i => !i.IS_DELETED)) {
					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_ProductionUnit
				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>