<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="CONTEXT" borderBottom v-if="model.STATUS==40">
					</u-form-item>
					<u--textarea v-html="model.CONTEXT" border="surround" v-if="model.STATUS==40" disabled></u--textarea>

					<u-form-item label="生产单元：" prop="Product_Unit">
						<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-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_ReportFiles" :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" :loading="stepLoad" @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_ReportDetails" :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-if="item.Nav_RiskArea" 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 required label="检查内容：" prop="CHECK_TIME" @click="handleShowSheetForArea(item,{title: '检查内容', name: 'Nav_Contents'})">
										<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12">
										</u-icon>
									</u-form-item>
									<u-textarea v-model="(item.Nav_Contents||{}).CHECKCONTENT" disabled placeholder="请选择检查内容"></u-textarea>
									<u-form-item required label="隐患描述：" prop="CHECK_TIME" @click="handleShowSheetForArea(item,{title: '隐患描述', name: 'Nav_Question'})">
										<view @click.stop>
											<u-button text="新增隐患描述" type="primary" @click="handleNewRisk(item)" size="mini" style="margin: 0px 10px;width: 100px;"></u-button>
										</view>

										<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 required label="整改责任人" prop="HIDDEN_PLACE" @click="handleShowSheetForArea(item,{title: '整改责任人', name: 'Nav_RecitifyUser'})">
										<u--input v-model="(item.Nav_RecitifyUser||{}).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="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 label="隐患照片" prop="CHECKSTANDARD">
									</u-form-item>
									<full-upload v-model="item.Nav_ReportDetailFiles" :isShowBtn='true' :listProp='listPropUpload' :listPropVal='listPropValUpload'></full-upload>
								</view>


							</uni-collapse-item>
						</view>
					</uni-collapse>
					<u-button text="新增" type="primary" @click="handleNewCheckContent()"></u-button>
				</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>
			<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>
			<people-selector :defaultChecked="peopleSelectOption.defaultChecked" :show="peopleSelectOption.showSelector" @select="handleSelectorPeople" @close="peopleSelectOption.showSelector = false">
			</people-selector>

		</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,
		GetNewRiskAreaInfo,
		GetHDReport,
		DangerReportFullUpdate,
		DangerReportCancel,
		GetRiskAreaInfo,
		getUserLists,
		CheckTypeNewOrderPaged,
		GetCheckInspection,
		GetHiddenScripList
	} 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,
				showDelModalAreaIndex: undefined,
				subsectionList: ['入库', '不入库', ],
				isMultiple: false,
				defaultChecked: [],
				radiolist1: [{
					name: '是',
					disabled: false
				}, {
					name: '否',
					disabled: false
				}],
				curNow: 1,
				stepLoad: true,
				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_ReportFiles: [],
					Check_Type: '',
					Check_Period: '',
					Check_Level: '',
					Check_Date: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss'),
					Nav_ReportDetails: [{
						Nav_RiskArea: {
							NAME: ''
						},
						Nav_Users: [],
						Nav_Contents: {
							CHECKCONTENT: ''
						},
						Nav_RecitifyUser: {
							NAME: ''
						}

					}],
				},
				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 hh:MM'),
				dateRecitifyTime: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM'),
				stepsText: ['发起', '确认', '审批', '归档'],
				stepsPage: 0,
				stepsPageList: 0,
				Pu: '',
				Check_Type_ID: '',
				TypeListres: {},
				TaskID: '',
				poparr: '',
				currentOperateStep: {},
				currentOperateArea: {},
				chooseCheckContent: '',
				chooseCheckArea: '',
				showPopupMonitor: false,
				currentOperateMonitor: {},
				monitorLists: [],
				curTotalMonitor: 0,
				chooseCheckMonitor: '',
				chooseRecitify: '',
				nowIndex: 0,
				nowName: '',
				STATUS: 0,
				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() {
				// 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_ReportFiles.Nav_ImgFile');
				extendInclude(json, 'Nav_ReportDetails');
				extendInclude(json, 'Nav_ReportDetails.Nav_ReportDetailBasics.Nav_Law');
				extendInclude(json, 'Nav_ReportDetails.Nav_RiskArea');
				extendInclude(json, 'Nav_ReportDetails.Nav_Contents');
				extendInclude(json, 'Nav_ReportDetails.Nav_Question');
				extendInclude(json, 'Nav_ReportDetails.Nav_RecitifyUser');
				extendInclude(json, 'Nav_ReportDetails.Nav_ReportDetailFiles.Nav_ImgFile');

				extendIgnoreDataRule(json)
				GetHDReport(json).then(res => {
					this.stepLoad = false
					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_ReportDetails && this.model.Nav_ReportDetails.length > 0) {
						this.model.Nav_ReportDetails.map(item => {
							item.HIDDEN_LEVELName = item.HIDDEN_LEVEL !== undefined ? this.enumsData['SKHiddenLevel'].find(item1 => item1.code === item.HIDDEN_LEVEL).name : ''
							// item.MARKName = this.enumsData['SKMarkEnum'].find(item1 => item1.code === item.MARK).name;
						})
					}


					this.stepsPage = res.STATUS == 0 ? 0 : res.STATUS == 20 ? 1 : res.STATUS == 10 ? 2 : 3
				})
			},
			handleNewRisk(item) {
				uni.navigateTo({
					url: 'riskContentEdit?CHECK_CONTENTS_ID=' + item.CHECK_CONTENTS_ID
				})
			},
			stepAdd() {
				if (!this.model.CHECK_TIME) {
					uni.showToast({
						title: '请选择检查时间',
						icon: 'none'
					})
					return
				}
				this.stepsPageList = this.stepsPageList + 1
			},
			stepReduce() {
				this.stepsPageList = this.stepsPageList - 1
			},
			handleShowSheetForArea(item, todo) {
				const validDetails = this.model.Nav_ReportDetails.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_Contents') {
					if (p.val) {
						extendRule(json, 'CHECKCONTENT', 9, p.val);
					}

					json.Sort = 'CHECKCONTENT'
					dataSelect = await GetCheckContentsInfo(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].CHECKCONTENT
							}
						}
						return res.Data
					})
				} else if (p.name == 'Nav_Question') {
					if (p.val) {
						extendRule(json, 'DESCREPTION', 9, p.val);
					}

					let data = this.model.Nav_ReportDetails[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_RecitifyUser') {
					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_ReportDetails.filter(i => !i.IS_DELETED);
				const index = this.selectorInfo.index;
				const realIndex = this.model.Nav_ReportDetails.findIndex(item => item === validDetails[index]);
				if (this.selectorInfo.name == 'Nav_RiskArea') {
					this.model.Nav_ReportDetails[realIndex].Nav_RiskArea = e;
					this.model.Nav_ReportDetails[realIndex].RISK_AREA_ID = e.ID;
				} else if (this.selectorInfo.name == 'Nav_Contents') {
					this.model.Nav_ReportDetails[realIndex].Nav_Contents = e;
					this.model.Nav_ReportDetails[realIndex].CHECK_CONTENTS_ID = e.ID;
				} else if (this.selectorInfo.name == 'Nav_Question') {
					this.model.Nav_ReportDetails[realIndex].Nav_Question = e;
					this.model.Nav_ReportDetails[realIndex].CHECK_QUESTION_ID = e.ID;
					this.model.Nav_CheckRecordDetails[realIndex].HIDDEN_LEVEL = e.QUESTION_LEVEL
					this.model.Nav_CheckRecordDetails[realIndex].HIDDEN_LEVELName = this.enumsData['SKHiddenLevel'].find(item1 => item1.code === e.QUESTION_LEVEL).name;
				} else if (this.selectorInfo.name == 'Nav_RecitifyUser') {
					this.model.Nav_ReportDetails[realIndex].Nav_RecitifyUser = e;
					this.model.Nav_ReportDetails[realIndex].RECITIFY_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


			},
			showCheckDate(dataIndex, item) {
				// let date = new Date()
				// this.dateTimePickerInfo.showCheckDate = true
				this.dateTimePickerInfo = {
					showCheckDate: true,
					defaultDateTime: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd'),
					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_ReportDetails)
					this.model.Nav_ReportDetails[realIndex].RECITIFY_TIME = uni.$u.timeFormat(e.value,
						'yyyy-mm-dd')
				}
				this.dateTimePickerInfo.showCheckDate = false

			},

			handleNewCheckContent() {
				this.model.Nav_ReportDetails.push({
					ID: guid(),
					ORG_ID: this.ORG_ID,
					HIDDEN_DANGER_REPORT_ID: this.model.ID,
					Nav_Contents: {
						CHECKCONTENT: ''
					},
					Nav_RecitifyUser: {
						NAME: ''
					},
					Nav_Question: {
						DESCREPTION: ''
					},
					CHECK_CONTENTS_ID: '',
					RISK_AREA_ID: '',
					CHECK_QUESTION_ID: '',
					HIDDEN_LEVELName: '',
					HIDDEN_LEVEL: null,
					HIDDEN_PLACE: '',
					RECITIFY_TIME: '',
					Nav_ReportDetailFiles: [],
					Nav_RiskArea: {
						NAME: ''
					}

				})
				this.model.Nav_ReportDetails = [...this.model.Nav_ReportDetails]
			},
			handleDelRowBefore(index) {
				this.showDelModalIndex = index


			},
			confirmDel() {
				this.model.Nav_ReportDetails.splice(this.showDelModalIndex, 1)
				this.showDelModalIndex = undefined

			},
			cacelDel() {
				this.showDelModalIndex = undefined
			},
			async onNavigationBarButtonTap() {
				this.cancleJob()
			},
			cancleJob() {
				let json = {};
				json.ID = this.ID;
				json.TaskID = this.TaskID;
				DangerReportCancel(json).then(res => {
					uni.$showMsgFunc('操作成功!', () => {
						uni.navigateBack()
					}, 'success', 1000)
				})
			},
			submit() {
				for (let item of this.model.Nav_ReportDetails) {
					if (!item.Nav_RiskArea || !item.Nav_RiskArea.NAME) {
						uni.showToast({
							title: '请选择检查区域',
							icon: 'none'
						})
						return
					}
					if (!item.Nav_Contents || !item.Nav_Contents.CHECKCONTENT) {
						uni.showToast({
							title: '请选择检查内容',
							icon: 'none'
						})
						return
					}
					if (!item.Nav_Question || !item.Nav_Question.DESCREPTION) {
						uni.showToast({
							title: '请选择隐患描述',
							icon: 'none'
						})
						return
					}
					if (!item.HIDDEN_LEVELName) {
						uni.showToast({
							title: '请选择隐患等级',
							icon: 'none'
						})
						return
					}
					if (!item.Nav_RecitifyUser || !item.Nav_RecitifyUser.NAME) {
						uni.showToast({
							title: '请选择整改责任人',
							icon: 'none'
						})
						return
					}
					if (!item.RECITIFY_TIME) {
						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_ReportDetails.map(item => {
					item.PUBLISH = 'SaveAndNotify'
					delete item.Nav_Contents
					delete item.Nav_RiskArea
					delete item.Nav_Question
					delete item.Nav_RecitifyUser
					delete item.Nav_ReportDetailBasics
				})
				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'
				DangerReportFullUpdate(this.modelEdit).then(res => {
					if (res) {
						uni.$showMsgFunc('操作成功!', () => {
							uni.navigateBack()
						}, 'success', 1000)
					}
				})


			}

		}



	}
</script>

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