<template>
	<view class="todo-page">
		<step-title :stepPage="stepsPage" :stepText="stepsText"></step-title>
		<view class="allview">
			<view class="card">
				<u--form labelWidth="auto" :model="dataModel" 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="STATUS==40">
					</u-form-item>
					<u--textarea v-html="dataModel.CONTEXT" border="surround" v-if="STATUS==40" disabled></u--textarea>
					<u-form-item label="生产单元：" prop="Product_Unit" @click="handleChangeUnit()">
						<u--input v-model="dataModel.Product_Unit" 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>
					<u-form-item label="检查区域:" @click="handleChangeArea">
						<u--input v-model="dataModel.Nav_RiskArea.NAME" placeholder="请选择检查区域" suffixIcon="arrow-down" suffixIconStyle="font-size: 12px" disabled disabledColor="#ffffff" border="none" inputAlign="right"
							fontSize="14px">
						</u--input>
					</u-form-item>
					<u-form-item label="隐患地点:" prop="HIDDEN_PLACE">
						<u--input v-model="dataModel.HIDDEN_PLACE" placeholder="请填写隐患地点" disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<u-form-item label="隐患描述:" prop="HIDDEN_DESCRIPTION">
						<u--input v-model="dataModel.HIDDEN_DESCRIPTION" placeholder="请填写隐患描述" disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<view class="upload-title">隐患照片：</view>
					<full-upload v-model="dataModel.Nav_Photos" :isShowBtn='true' :listProp='listPropUpload' :listPropVal='listPropValUpload' v-if="dataModel.Nav_Photos"></full-upload>

				</u--form>
				<u--form labelWidth="auto" :model="dataModel" ref="wForm" class="demo-ruleForm" style="margin-top: 20px;">
					<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="检查内容：" @click="handleChangeStep('Content')">
						<u--input v-model="dataModel.Nav_Contents.CHECKCONTENT" 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>
					<!-- <u-form-item label="检查依据:" @click="handleChangeStep('Inspection')" >  
						<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12">
						</u-icon>
					</u-form-item>
					<u--textarea v-model="dataModel.Nav_BasicsName" disabled maxlength="-1"></u--textarea>
					<u-form-item label="判定标准:">
						<u--input v-model="dataModel.CHECKSTANDARD" disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>
					</u-form-item> -->
					<u-form-item label="隐患描述:" prop="HIDDEN_DESCRIPTION" @click="handleChangeStep('Description')">
						<u-icon style="margin-left: 4px;" slot="right" name="arrow-down" size="12">
						</u-icon>
					</u-form-item>
					<u--textarea v-model="dataModel.Nav_Question.DESCREPTION" disabled placeholder="请选择隐患描述" maxlength="-1"></u--textarea>
					<u-form-item label="隐患等级" prop="HIDDEN_LEVEL" @click="handleChangeRiskLevel">
						<u--input v-model="dataModel.HIDDEN_LEVEL" 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="整改措施:">
						<u--input v-model="dataModel.RECTIFICATION_MEASURES" disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>
					</u-form-item>
					<u-form-item label="检查层级：" prop="Check_Level" @click="handleChangeLevel()">
						<u--input v-model="dataModel.DEPARTMENT_TYPE" 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>
					<u-form-item label="检查类型：" prop="Check_Type" @click="handleChangeType()">
						<u--input v-model="dataModel.Nav_CheckType.NAME" 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>
					<u-form-item label="检查周期：" prop="Check_Period" @click="handleChangePeriod()">
						<u--input v-model="dataModel.PLANCHECKFREQUENCY" 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="HIDDEN_PLACE" @click="handleChangeMonitor">
						<u--input v-model="dataModel.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 label="整改期限" prop="HIDDEN_PLACE" @click="handleChangeRecitify()">
						<u--input v-model="dataModel.RECITIFY_TIME" placeholder="请选择整改期限" 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>
					<view class="upload-title">附件：</view>
					<full-upload v-model="dataModel.Nav_Files" :isShowBtn='true' :listProp='listPropUpload' :listPropVal='listPropValUpload'></full-upload>

				</u--form>
			</view>
			<view style="padding: 10px 16px;" class="bottom-button">
				<u-button type="primary" @click="submit" :loading="stepLoad" color="#3d4b70">提交</u-button>
			</view>
			<u-picker :show="showPopupUnit" :columns="UnitLists" @confirm="confirmUnit" @cancel="cancelUnit" :defaultIndex="UnitDefaultIndex"></u-picker>
			<u-picker :show="showPopupRiskLevel" :columns="RiskLevel" @confirm="confirmRiskLevel" @cancel="cancelRiskLevel" :defaultIndex="RiskLevelDefaultIndex"></u-picker>
			<u-picker :show="showPopupType" :columns="TypeLists" @confirm="confirmType" @cancel="cancelType" :defaultIndex="TypeDefaultIndex"></u-picker>
			<u-picker :show="showPopupPeriod" :columns="PeriodLists" @confirm="confirmPeriod" @cancel="cancelPeriod" :defaultIndex="PeriodDefaultIndex"></u-picker>
			<u-picker :show="showPopupLevel" :columns="LevelLists" @confirm="confirmLevel" @cancel="cancelLevel" :defaultIndex="LevelDefaultIndex"></u-picker>
			<u-modal :show="showDelModalIndex >= 0" @confirm="confirmDel" @cancel="cacelDel" :showCancelButton="true" title="确认删除？"></u-modal>
			<u-datetime-picker :show="showPopupRecitifyDate" v-model="dateRecitifyTime" mode="date" @confirm="confirmRecitifyDate" @cancel="cancelRecitifyDate"></u-datetime-picker>
			<people-selector :defaultChecked="peopleSelectOption.defaultChecked" :show="peopleSelectOption.showSelector" @select="handleSelectorPeople" @close="peopleSelectOption.showSelector = false">
			</people-selector>
			<query-selector :multiple="isMultiple" :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="showPopupArea" :total="curTotalArea" :lists="areaLists" :defaultValue="currentOperateArea.NAME" @close="handleClosePopupArea" @search="handleSearchArea" @select="handleSelectedArea" />
		</view>
	</view>
</template>

<script>
	import {
		extendFilterGroup,
		extendGroupRule,
		extendInclude,
		extendOrder,
		extendRule,
		extendIgnoreDataRule,
		guid,
		initFilter,
		initFilterGroup
	} from '../../../../utils/common'
	import {
		FMProductionUnit,
		CheckPeriods,
		CheckLevels,
		MineTypeIndex,
		MineTypeName
	} from '../../../../utils/enums.js'
	import {
		GetCheckContentsInfo,
		GetRiskVerifyReport,
		HiddenVerifyFullUpdate,
		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';
	export default {
		components: {
			stepTitle,
		},
		data() {
			return {
					isMultiple: false,
				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: [],
				stepLoad: true,
				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'),
				dataModel: {
					Product_Unit: '',
					Nav_RiskArea: {
						NAME: ''
					},
					HIDDEN_PLACE: '',
					HIDDEN_DESCRIPTION: '',
					Nav_Photos: [],
					Nav_Contents: {
						CHECKCONTENT: ''
					},
					Nav_Question: {
						DESCREPTION: ''
					},
					CHECKPROOF: '',
					CHECKSTANDARD: '',
					HIDDEN_DESCRIPTION_DETAIL: '',
					HIDDEN_LEVEL: '',
					RECTIFICATION_MEASURES: '',
					DEPARTMENT_TYPE: '',
					Nav_CheckType: {
						NAME: ''
					},
					PLANCHECKFREQUENCY: '',
					Nav_RecitifyUser: {
						NAME: ''
					},
					RECITIFY_TIME: '',
					IS_STORE: '',
					Nav_Files: []

				},
				model: {
					ORG_ID: '',
					MineType: '',
					Nav_RiskArea: {
						NAME: ''
					},
					HIDDEN_PLACE: '',
					HIDDEN_DESCRIPTION: '',
					Nav_Photos: [],
					Nav_Contents: {
						CHECKCONTENT: ''
					},
					CHECKPROOF: '',
					CHECKSTANDARD: '',
					HIDDEN_DESCRIPTION_DETAIL: '',
					HIDDEN_LEVEL: '',
					RECTIFICATION_MEASURES: '',
					DEPARTMENT_TYPE: '',
					Nav_CheckType: {
						NAME: ''
					},
					PLANCHECKFREQUENCY: '',
					Nav_RecitifyUser: {
						NAME: ''
					},
					RECITIFY_TIME: '',
					IS_STORE: '',
					Nav_Files: []

				},
				peopleSelectOption: {
					showSelector: false,
					value: null,
					index: 0,
					defaultChecked: []
				},
				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: '',
				STATUS: 0,

			}
		},
		onLoad(option) {
			this.TaskID = option.taskID ? option.taskID : '';
			this.ID = option.ID ? option.ID : '';
			this.loadData()
		},
		methods: {
			loadData() {
				// const json = {}
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "")
				extendRule(json, 'ID', 1, this.ID);
				extendInclude(json, 'Nav_Basics');
				extendInclude(json, 'Nav_Question');
				extendInclude(json, 'Nav_ApplyUser');
				extendInclude(json, 'Nav_Basics.Nav_Law');
				extendInclude(json, 'Nav_RiskArea');
				extendInclude(json, 'Nav_Contents');
				extendInclude(json, 'Nav_CheckType');
				extendInclude(json, 'Nav_RecitifyUser');
				extendInclude(json, 'Nav_Photos');
				extendInclude(json, 'Nav_Files');
				extendInclude(json, 'Nav_Files.Nav_ImgFile');
				extendInclude(json, 'Nav_Photos.Nav_ImgFile');
				extendIgnoreDataRule(json)

				// extendRule(json, 'TASK_ID', 1, this.TaskID);
				GetRiskVerifyReport(json).then(res => {
					this.stepLoad = false
					// this.dataModel = res;
					this.STATUS = res.STATUS
					this.dataModel.CONTEXT = res.CONTEXT ? res.CONTEXT : ''
					this.dataModel.RECITIFY_TIME = uni.$u.timeFormat(res.RECITIFY_TIME,
						'yyyy-mm-dd')
					this.Check_Type_ID = res.CHECK_TYPE_ID
					this.dataModel.RISK_AREA_ID = res.RISK_AREA_ID
					this.dataModel.Nav_Photos = res.Nav_Photos ? res.Nav_Photos : [],
						this.dataModel.Nav_Files = res.Nav_Files ? res.Nav_Files : [],
						this.dataModel.Nav_Contents = res.Nav_Contents ? res.Nav_Contents : {
							CHECKCONTENT: ''
						},
						this.dataModel.Nav_RiskArea = res.Nav_RiskArea ? res.Nav_RiskArea : {
							NAME: ''
						},
						this.dataModel.HIDDEN_PLACE = res.HIDDEN_PLACE
					this.dataModel.HIDDEN_DESCRIPTION = res.HIDDEN_DESCRIPTION
					this.dataModel.Nav_Question = res.Nav_Question ? res.Nav_Question : {
							DESCREPTION: ''
						},
						this.stepsPage = res.STATUS == 0 ? 0 : res.STATUS == 20 ? 1 : res.STATUS == 10 ? 2 : 3
					this.dataModel.PLANCHECKFREQUENCY = res.PLANCHECKFREQUENCY == 0 ? '无' : res.PLANCHECKFREQUENCY == 10 ? '每天' : res.PLANCHECKFREQUENCY == 20 ? '每周' : res.PLANCHECKFREQUENCY == 30 ? '每月' : res
						.PLANCHECKFREQUENCY == 40 ? '每季度' : res.PLANCHECKFREQUENCY == 50 ? '每半年' : res.PLANCHECKFREQUENCY == 60 ? '每年' : '每班'
					this.dataModel.DEPARTMENT_TYPE = res.DEPARTMENT_TYPE == 0 ? '部门' : res.DEPARTMENT_TYPE == 1 ? '车间' : res.DEPARTMENT_TYPE == 2 ? '班组' : res.DEPARTMENT_TYPE == 3 ? '公司' : '岗位'
					this.dataModel.HIDDEN_LEVEL = this.dataModel.HIDDEN_LEVEL == 0 ? '一般' : '重大'
					this.dataModel.Product_Unit = MineTypeName[res.MineType]
					this.dataModel.Nav_Basics = res.Nav_Basics
					if (res.Nav_Basics && res.Nav_Basics.length > 0) {
						let areaShow = ''
						this.dataModel.Nav_Basics.map(o => {
							if (o.Nav_Law && o.Nav_Law.NAME) {
								areaShow += o.Nav_Law.NAME + ' 、'
							}

						})
						this.dataModel.Nav_BasicsName = areaShow
					} else {
						this.dataModel.Nav_BasicsName = ''
					}
					this.dataModel.CHECKSTANDARD = res.CHECKSTANDARD
					this.dataModel.RECTIFICATION_MEASURES = res.RECTIFICATION_MEASURES
					this.dataModel.Nav_CheckType = res.Nav_CheckType ? res.Nav_CheckType : {
							NAME: ''
						},
						this.dataModel.Nav_RecitifyUser = res.Nav_RecitifyUser ? res.Nav_RecitifyUser : {
							NAME: ''
						}

				})
				this.getCheckType()
			},
			cancelRecitifyDate() {
				this.showPopupRecitifyDate = false
			},
			handleChangeRecitify() {
				this.showPopupRecitifyDate = true
			},
			confirmRecitifyDate(e) {
				this.dataModel.RECITIFY_TIME = uni.$u.timeFormat(e.value,
					'yyyy-mm-dd ')
				this.dateRecitifyTime = uni.$u.timeFormat(e.value,
					'yyyy-mm-dd ')

				this.showPopupRecitifyDate = false
			},
			handleClosePopupMonitor() {
				this.showPopupMonitor = false
				// this.showPopupCertificate = false
			},
			handleChangeMonitor(user) {
				this.currentOperateMonitor = {}
				this.chooseCheckMonitor = 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.dataModel.Nav_RecitifyUser = val
				this.dataModel.RECITIFY_USER_ID = val.ID
				this.showPopupMonitor = false

			},
			cancelPeriod() {
				this.showPopupPeriod = false
			},
			handleChangePeriod() {
				this.PeriodLists = [CheckPeriods]
				this.showPopupPeriod = true
			},
			confirmPeriod(e) {
				this.dataModel.PLANCHECKFREQUENCY = e.value[0]
				this.showPopupPeriod = false
			},
			getCheckType() {
				const json = initFilter(this.orgId, "", "CODE", 1)
				const TypeList = []
				json.Limit = 100
				CheckTypeNewOrderPaged(json).then(res => {
					 (res.Data || res).map((item, index) => {
						TypeList.push(item.NAME)
						if (item.NAME == this.dataModel.Check_Type) {
							this.TypeDefaultIndex = [index]
						}
					})
					this.TypeListres = res.Data

				})
				this.TypeLists = [TypeList]
			},
			cancelType() {
				this.showPopupType = false
			},
			handleChangeType() {
				// this.TypeLists = [FMProductionUnit]

				this.showPopupType = true
			},
			confirmType(e) {
				this.dataModel.Nav_CheckType.NAME = e.value[0]
				this.TypeListres.map(item => {
					if (item.NAME == e.value[0]) {
						this.Check_Type_ID = item.ID
					}
				})

				this.showPopupType = false
			},
			cancelLevel() {
				this.showPopupLevel = false

			},
			handleChangeLevel() {
				this.LevelLists = [CheckLevels]
				CheckLevels.map((item, index) => {
					if (item == this.dataModel.Check_Level) {
						this.LevelDefaultIndex = [index]
					}
				})
				this.showPopupLevel = true
			},
			confirmLevel(e) {
				this.dataModel.DEPARTMENT_TYPE = e.value[0]
				this.showPopupLevel = false
			},

			cancelUnit() {
				this.showPopupUnit = false
			},
			handleChangeUnit() {
				this.UnitLists = [FMProductionUnit]
				this.showPopupUnit = true
			},
			confirmUnit(e) {
				this.dataModel.Product_Unit = e.value[0]
				this.showPopupUnit = false
			},

			handleClosePopupArea() {
				this.showPopupArea = false
				// this.showPopupCertificate = false
			},
			handleChangeArea() {
				this.currentOperateArea = {}
				this.showPopupArea = true
				this.handleSearchArea()
			},
			handleSearchArea(val, pageIndex) {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "",0, pageIndex ?? 1)
				if (val) {
					extendRule(json, 'NAME', 9, val);
				}
				
				
				json.Limit = 20
				if (pageIndex) {
					json.Start = (pageIndex - 1) * json.Limit;
				}
				GetRiskAreaInfo(json).then(res => {
					// if (res.IsSuccessful) {
					this.areaLists = (res.Data || res).map(i => {
						return {
							...i,
							id: i.ID,
							name: i.NAME,
						}
					})
					this.curTotalArea = res.TotalCount
					// }
				})
			},
			handleSelectedArea(val) {
				this.dataModel.RISK_AREA_ID = val.ID
				this.dataModel.Nav_RiskArea = val
				this.showPopupArea = false

			},
			cancelRiskLevel() {
				this.showPopupRiskLevel = false
			},
			handleChangeRiskLevel() {
				this.RiskLevel = [
					['一般', '重大']
				]
				this.showPopupRiskLevel = true
			},
			confirmRiskLevel(e) {
				this.dataModel.HIDDEN_LEVEL = e.value[0]
				this.showPopupRiskLevel = false
			},
			handleChangeStep(name) {
				this.nowName = name
				this.currentOperateStep = {}
				this.showPopupStep = true
				this.handleSearchStep()
			},
			handleClosePopupStep() {
				this.showPopupStep = false
				// this.showPopupCertificate = false
			},
			handleSearchStep(val, pageIndex) {
				let requestInfo = this.nowName == 'Content' ? GetCheckContentsInfo :
					this.nowName == 'Inspection' ? GetCheckInspection : GetHiddenScripList
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "",0, pageIndex ?? 1)
				if (val) {
					if(this.nowName == 'Content')
					{extendRule(json, 'CHECKCONTENT', 9, val);}
					else if(this.nowName == 'Inspection')
					{extendRule(json, 'NAME', 9, val);}
					else
					{extendRule(json, 'DESCREPTION', 9, val);}
				}
				
				
				json.Limit = 20
				if (pageIndex) {
					json.Start = (pageIndex - 1) * json.Limit;
				}
				if (this.nowName == 'Inspection') {
					this.isMultiple = true

					if (this.dataModel.Nav_Basics && this.dataModel.Nav_Basics.length > 0) {

						this.dataModel.Nav_Basics.map(item => {
							let newId = item.LAW_ID;
							// 创建一个新对象，ID 为 item.LAW_ID，其他属性和 item 相同
							let newItem = {
								...item,
								ID: newId
							};
							// 将新对象添加到 this.defaultChecked 数组中
							this.defaultChecked.push(newItem);
						})
					} else {
						this.defaultChecked = []
					}
				} else {
					this.isMultiple = false
				}
				if (this.nowName == 'Description' && this.dataModel.CHECK_CONTENTS_ID) {
					extendRule(json, 'CHECK_CONTENTS_ID', 1, this.dataModel.CHECK_CONTENTS_ID);
				}
				requestInfo(json).then(res => {
					// if (res.IsSuccessful) {
					this.stepLists = (res.Data || res).map(i => {
						return {
							...i,
							id: i.ID,
							name: i.NAME || i.CHECKCONTENT || i.DESCREPTION,
						}
					})
					this.curTotalStep = res.TotalCount
					// }
				})
			},

			handleSelectedStep(val) {
				if (this.nowName == 'Content') {
					this.dataModel.Nav_Contents = val
					this.dataModel.CHECK_CONTENTS_ID = val.ID
				} else if (this.nowName == 'Inspection') {
					let listArea = []
					let areaShow = ''
					if (val.length > 0) {
						val.forEach((item, i) => {
							if (i > 0) {
								areaShow += ' '
							}
							let newItem = {
								...item,
								LAW_ID: item.ID,
								HIDDEN_DANGER_CONFIRM_ID: item.ID,
								NAME: item.NAME || item.Nav_Law.NAME,
							};
							listArea.push(newItem)
							if (item.NAME && item.NAME != null) {
								areaShow += item.NAME
							} else if (item.Nav_Law && item.Nav_Law.NAME != null) {
								areaShow += item.Nav_Law.NAME
							}
						})
					}
					this.dataModel.Nav_Basics = listArea
					this.dataModel.Nav_BasicsName = areaShow
				} else if (this.nowName == 'Description') {
					this.dataModel.Nav_Question = val
					this.dataModel.CHECK_QUESTION_ID = val.ID
					this.dataModel.RECTIFICATION_MEASURES = val.DEMAND
				}

				this.showPopupStep = false

			},

			submit() {
				if (!this.dataModel.Product_Unit) {
					uni.showToast({
						title: '请选择生产单元',
						icon: 'none'
					})
					return
				}
				if (!this.dataModel.Nav_RiskArea.NAME) {
					uni.showToast({
						title: '请选择检查区域',
						icon: 'none'
					})
					return
				}
				if (this.dataModel.Nav_Photos.length == 0) {
					uni.showToast({
						title: '请上传隐患照片',
						icon: 'none'
					})
					return
				}
				if (!this.dataModel.Nav_Contents.CHECKCONTENT) {
					uni.showToast({
						title: '请选择检查内容',
						icon: 'none'
					})
					return
				}
				if (!this.dataModel.HIDDEN_LEVEL) {
					uni.showToast({
						title: '请选择隐患等级',
						icon: 'none'
					})
					return
				}
				if (!this.dataModel.DEPARTMENT_TYPE) {
					uni.showToast({
						title: '请选择检查层级',
						icon: 'none'
					})
					return
				}
				if (!this.dataModel.Nav_CheckType.NAME) {
					uni.showToast({
						title: '请选择检查类型',
						icon: 'none'
					})
					return
				}
				if (!this.dataModel.PLANCHECKFREQUENCY) {
					uni.showToast({
						title: '请选择检查周期',
						icon: 'none'
					})
					return
				}
				if (!this.dataModel.Nav_RecitifyUser.NAME) {
					uni.showToast({
						title: '请选择整改责任人',
						icon: 'none'
					})
					return
				}
				if (!this.dataModel.RECITIFY_TIME) {
					uni.showToast({
						title: '请选择整改期限',
						icon: 'none'
					})
					return
				}
				// this.model = this.dataModel

				this.model = {
					MineType: MineTypeIndex[this.dataModel.Product_Unit],
					RISK_AREA_ID: this.dataModel.RISK_AREA_ID,
					// Nav_RiskArea: this.dataModel.Nav_RiskArea,
					HIDDEN_PLACE: this.dataModel.HIDDEN_PLACE,
					HIDDEN_DESCRIPTION: this.dataModel.HIDDEN_DESCRIPTION,
					// Nav_Contents: this.dataModel.Nav_Contents,
					CHECK_CONTENTS_ID: this.dataModel.CHECK_CONTENTS_ID,
					Nav_Basics:this.dataModel.Nav_Basics,
					CHECKSTANDARD: this.dataModel.CHECKSTANDARD,
					CHECK_QUESTION_ID:this.dataModel.CHECK_QUESTION_ID,
					HIDDEN_LEVEL: this.dataModel.HIDDEN_LEVEL == '一般' ? 0 : 10,
					RECTIFICATION_MEASURES: this.dataModel.RECTIFICATION_MEASURES,
					DEPARTMENT_TYPE: this.dataModel.DEPARTMENT_TYPE == '部门' ? 0 : this.dataModel.DEPARTMENT_TYPE == '车间' ? 1 : this.dataModel.DEPARTMENT_TYPE == '班组' ? 2 : this.dataModel.DEPARTMENT_TYPE == '公司' ? 3 : 4,
					CHECK_TYPE_ID: this.Check_Type_ID,
					// Nav_CheckType: this.dataModel.Nav_CheckType,
					PLANCHECKFREQUENCY: this.dataModel.PLANCHECKFREQUENCY == '无' ? 0 : this.dataModel.PLANCHECKFREQUENCY == '每天' ? 10 : this.dataModel.PLANCHECKFREQUENCY == '每周' ? 20 : this.dataModel
						.PLANCHECKFREQUENCY == '每月' ? 30 : this.dataModel.PLANCHECKFREQUENCY == '每季' ? 40 : this.dataModel.PLANCHECKFREQUENCY == '每半年' ? 50 : this.dataModel.PLANCHECKFREQUENCY == '每年' ? 60 : 70,
					// Nav_RecitifyUser: this.dataModel.Nav_RecitifyUser,
					RECITIFY_USER_ID: this.dataModel.RECITIFY_USER_ID,
					RECITIFY_TIME: this.dataModel.RECITIFY_TIME,
					Nav_Photos: this.dataModel.Nav_Photos.map((obj) => {
						return Object.assign({}, obj, {
							IMG_FILE_ID: obj.IMG_FILE_ID,
						})
						return obj
					}),
					Nav_Files: this.dataModel.Nav_Files.map((obj) => {
						return Object.assign({}, obj, {
							IMG_FILE_ID: obj.IMG_FILE_ID,
						})
						return obj
					}),
					ORG_ID: this.ORG_ID
				}
				this.model.ID = this.ID
				this.model.TaskID = this.TaskID
				this.model.PUBLISH = "SaveAndNotify";
				HiddenVerifyFullUpdate(this.model).then(res => {
					if (res) {
						uni.$showMsgFunc('操作成功!', () => {
							uni.navigateBack()
						}, 'success', 1000)
					}
				})


			}

		}



	}
</script>

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