<!-- 检查记录确认 -->
<template>
	<view class="page-wrap">
		<view class="card">
			<uni-card margin="0" :is-shadow="true">
				<u--form labelPosition="left" labelWidth="auto" labelAlign="center" :model="model" :rules="rules"
					ref="wForm" errorType="border-bottom">

					<view v-if='AUDIT_OPINION' class="label-title-red">驳回信息</view>
					<u-form-item v-if='AUDIT_OPINION' borderBottom>
						<u--textarea disabled autoHeight style="color: red !important;" :value="AUDIT_OPINION"
							placeholder="请输入检查内容" border="surround"></u--textarea>
					</u-form-item>

					<u-form-item label="检查类型" prop="Nav_CheckType.NAME" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.Nav_CheckType.NAME" border="none"
							slot="right" inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="检查层级" prop="Nav_CheckTypeLevel.Nav_Enums.NAME" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.Nav_CheckTypeLevel.Nav_Enums.NAME"
							border="none" slot="right" inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="检查时间" prop="CHECKTIME" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.CHECKTIME" border="none" slot="right"
							inputAlign="right"></u--input>
					</u-form-item>
					<!-- <u-form-item label="检查区域" prop="RiskAreaNAME" borderBottom>
						<u--input disabled v-model="model.RiskAreaNAME" border="none" slot="right" inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="检查项目分类" prop="CheckProjectCategoryNAME" borderBottom>
						<u--input disabled v-model="model.CheckProjectCategoryNAME" border="none" slot="right"
							inputAlign="right"></u--input>
					</u-form-item> -->


					<view class="label-title">检查区域</view>
					<u-form-item prop="RiskAreaNAME" borderBottom>
						<u--textarea disabled autoHeight v-model="model.RiskAreaNAME" placeholder="请输入检查内容"
							border="surround"></u--textarea>
					</u-form-item>
					<!-- <view class="label-title">检查项目分类</view>
					<u-form-item prop="CheckProjectCategoryNAME" borderBottom>
						<u--textarea disabled autoHeight v-model="model.CheckProjectCategoryNAME" placeholder="请输入检查内容"
							border="surround"></u--textarea>
					</u-form-item> -->

					<!-- 
					<view class="upload-title">附件</view>
					<full-upload v-model="model.Nav_Files"></full-upload> -->

					<view class="upload-title">附件</view>
					<full-upload v-model="model.Nav_Files" :isShowBtn='true' :listProp='listPropUpload'
						:listPropVal='listPropValUpload'></full-upload>

					<!--
					<u-form-item label="附件" prop="NAME" borderBottom>
						<navigator slot="right" inputAlign="right"
											 url='blob:http://localhost:8080/c74abf3f-e581-4270-b1dc-c670633f3575'>12345.doc
						</navigator>
						<navigator slot="right" inputAlign="right"
											 url='blob:http://localhost:8080/c74abf3f-e581-4270-b1dc-c670633f3575'>12345.doc
						</navigator>
					</u-form-item> -->
				</u--form>
				<!-- <u-datetime-picker :show="showCheckDate" mode="datetime" v-model="dataModel.ACTIVITY_TIME"
					@confirm="handleCheckDate" @close="showCheckDate = false;"
					@cancel="showCheckDate = false;"></u-datetime-picker> -->
			</uni-card>
		</view>
		<u-sticky offset-top="20">
			<view class="sub-form">
				<view class="sub-form-wrap">
					<!-- wyw -->

					<view class="sub-form-btns" v-if='isLoadOK'>
						<view class="sub-form-btn" @click="handleAdd">
							<u-icon class="icon" name="plus" color="#2979ff" size="14"></u-icon>
							<u--text type="primary" text="检查登记"></u--text>
						</view>
					</view>

					<u--form labelPosition="left" labelWidth="auto" labelAlign="center" :model="subDataModel"
						errorType="border-bottom" ref="sForm">
						<uni-collapse :border="false" accordion>
							<uni-card style="margin-bottom: 16px;" margin="0" spacing="0" :is-shadow="false"
								v-for="(item, index) in model.Nav_ListSafeCheckDetail">
								<uni-collapse-item :title="index + 1 + '. ' + item.CHECKCONTENT">
									<u-form-item label="检查区域" prop="Nav_CheckArea.NAME" borderBottom>
										<u--input disabled disabledColor="#fff" v-model="item['Nav_CheckArea'].NAME"
											border="none" inputAlign="right"></u--input>
									</u-form-item>
									<view class="label-title">检查内容</view>
									<u-form-item prop="CHECKCONTENT" borderBottom>
										<u--textarea disabled autoHeight v-model="item.CHECKCONTENT" placeholder="检查内容"
											border="surround"></u--textarea>
									</u-form-item>

									<u-form-item label="检查项目" prop="Nav_CheckProject.NAME" borderBottom>
										<u--input disabled disabledColor="#fff" v-model="item['Nav_CheckProject'].NAME"
											border="none" inputAlign="right"></u--input>
									</u-form-item>
									<u-form-item v-if="item.ISAUTOLOAD" label="检查问题描述" class="subRequired" required
										prop="listCheckDetailQuestion" borderBottom
										@click="handleShowSheet({title: '检查问题描述', name: 'listCheckDetailQuestion', formIndex: index ,subData: item,data:model})">
										<!-- 下拉图标 -->
										<u--input disabledColor="#fff" v-model="item.listCheckDetailQuestion"
											border="none" inputAlign="right"></u--input>
										<u-icon style="margin-left: 4px;" slot="right" name="arrow-down"></u-icon>
									</u-form-item>
									<u-form-item v-else label="检查问题描述" class="subRequired" required
										prop="listCheckDetailQuestion" borderBottom>
										<!-- 下拉图标 -->
										<u--input disabledColor="#fff" v-model="item.listCheckDetailQuestion"
											border="none" inputAlign="right"></u--input>
									</u-form-item>
									<u-form-item label="问题等级" prop="QUESTION_LEVEL_DESCRIPTION" borderBottom>
										<u--input disabled disabledColor="#fff"
											v-model="item.QUESTION_LEVEL_DESCRIPTION" border="none"
											inputAlign="right"></u--input>
									</u-form-item>
									<view class="label-title">整改建议与措施</view>
									<u-form-item prop="DEMAND" borderBottom>
										<u--textarea disabled autoHeight v-model="item.DEMAND" placeholder="整改建议与措施"
											border="surround"></u--textarea>
									</u-form-item>
									<u-form-item label="检查人员" prop="checkerNames" borderBottom>
										<u--input disabled disabledColor="#fff" v-model="item.checkerNames"
											border="none" inputAlign="right"></u--input>
									</u-form-item>
									<u-form-item v-if="item.ISAUTOLOAD" label="隐患地点" prop="ADDRESS" borderBottom>
										<u--input disabledColor="#fff" placeholder='隐患地点' v-model="item.ADDRESS"
											inputAlign="right"></u--input>
									</u-form-item>
									<u-form-item v-else label="隐患地点" prop="ADDRESS" borderBottom>
										<u--input disabledColor="#fff" border="none" disabled placeholder='隐患地点'
											v-model="item.ADDRESS" inputAlign="right"></u--input>
									</u-form-item>
									<!-- <u-form-item label="隐患原因" prop="listCheckDetailReason" borderBottom
										@click="handleShowSheet({title: '隐患原因', name: 'listCheckDetailReason', formIndex: index})">
										<u--input disabledColor="#fff" v-model="item.listCheckDetailReason"
											border="none" inputAlign="right"></u--input>
										<u-icon style="margin-left: 4px;" slot="right" name="arrow-down"></u-icon>
									</u-form-item> -->
									<u-form-item v-if="item.ISAUTOLOAD" label="隐患原因" prop="listCheckDetailReason"
										borderBottom @click="handleChange(item)">
										<u--input disabledColor="#fff" v-model="item.listCheckDetailReason"
											border="none" inputAlign="right"></u--input>
										<u-icon style="margin-left: 4px;" slot="right" name="arrow-down"></u-icon>
									</u-form-item>
									<u-form-item v-else label="隐患原因" prop="listCheckDetailReason" borderBottom>
										<u--input disabledColor="#fff" v-model="item.listCheckDetailReason"
											border="none" inputAlign="right"></u--input>
									</u-form-item>
									<view class="upload-title">附件</view>
									<full-upload v-model="item.Nav_Files" :isShowBtn=item.ISAUTOLOAD
										:listProp='listPropSubUpload'
										:listPropVal='item.listPropValSubUpload'></full-upload>
								</uni-collapse-item>
							</uni-card>
						</uni-collapse>
					</u--form>
				</view>
			</view>
		</u-sticky>
		<u-modal :show="showDelModalIndex >= 0" @confirm="confirmDel" title="确认删除？"></u-modal>
		<u-picker :show="comPickerInfo.showSheet" :columns="comPickerInfo.columns" @confirm="onConfirmPicker"
			@close="closePicker" @cancel="closePicker" keyName="NAME"></u-picker>


		<query-selector multiple :show="selectorInfo.showPopup" :defaultChecked="selectorInfo.defaultChecked"
			:title="selectorInfo.title" :lists="selectorInfo.dataLists" @search="handleSearch" @select="handleSelected"
			@close="selectorInfo.showPopup=false" />

		<view class="bottom-button">
			<button type="primary" v-if='isLoadOK && tableKey === "1"' @click="FullCheckUpdate">提交</button>
		</view>

	</view>
</template>

<script>
	import {
		guid,
		initFilter,
		extendRule,
		extendInclude,
		extendGroupRule,
		initFilterGroup,
		extendFilterGroup,
		extendFilterGroupGroupRules
	} from '../../../../utils/common'

	import {
		GetUserCheckInfoBS057,
		FullCheckUpdateBS057,
		orderPagedRiskReason,
		GetCheckDetailDESCREPTION
	} from '../../../../services/apply/subPages/BS/safeCheck'

	import {
		auditOptionShow
	} from '../../../../services/common'

	// import '@/utils/showMsg.js'
	import UButton from '../../../../uni_modules/uview-ui/components/u-button/u-button.vue'

	export default {
		components: {
			UButton
		},
		data() {
			return {
				tableKey: '0',
				TaskID: '',
				listPropUpload: ['SAFE_CHECK_ID'],
				listPropSubUpload: ['SAFE_CHECK_ID', 'SAFE_CHECK_DETAIL_ID'],
				listPropValUpload: [],
				AUDIT_OPINION: '',
				model: {
					ID: '',
					TaskID: '',
					Nav_CheckType: {},
					Nav_CheckTypeLevel: {
						Nav_Enums: {}
					},
					Nav_Files: [],
					Nav_ListSafeCheckDetail: [{
						Nav_CheckArea: {},
						Nav_CheckProject: {},
						checkerNames: '',
						Nav_ListCheckDetailReason: [{}],
						listCheckDetailReason: '',
						CHECKCONTENT: '', // wyw '空',
						Nav_ListCheckDetailQuestion: [{
							Nav_Question: [],
						}],
						listCheckDetailQuestion: '',
						QUESTION_LEVEL_DESCRIPTION: '',
						listPropValSubUpload: [],
						Nav_Files: []
					}] //子表
				},
				isAudit: true,
				isLoadOK: false,
				lists: [],
				comPickerInfo: {
					showSheet: false,
					columns: [],
					title: '',
					dataIndex: undefined,
					formIndex: undefined,
					name: ''
				},

				selectorInfo: {
					showPopup: false,
					title: '隐患原因',
					itemData: {},
					index: 0,
					dataLists: [],
					defaultText: '',
					defaultValue: '',
					name: '',
					defaultChecked: []
				},

				// subForms: [{
				// 	title: '检查详情',
				// 	listCheckDetailReason: '',
				// 	// checkContent: '',
				// 	// checkProblem: '',
				// 	// problemLevel: '',
				// 	// riskPosition: ''
				// }],
				subDataModel: {
					Nav_CheckArea: {},
					Nav_CheckProject: {},
					checkerNames: '',
					Nav_ListCheckDetailReason: [{}],
					listCheckDetailReason: '',
					CHECKCONTENT: '空',
					Nav_ListCheckDetailQuestion: [{
						Nav_Question: [],
					}],
					listCheckDetailQuestion: '',
					QUESTION_LEVEL_DESCRIPTION: ''
				},
				showCheckDate: false,
				showPopup: false,
				showDelModalIndex: undefined,
				rules: {
					'activityTopic': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change']
					}
				},
			}
		},
		onLoad(option) {
			this.model.ID = option.ID
			this.model.TaskID = option.taskID
			this.TaskID = option.taskID
			this.tableKey = option.tableKey
			this.loadData()

		},
		methods: {
			handleOkRow() {
				console.log('ok row')
			},
			handleDelRowBefore(index) {
				this.showDelModalIndex = index
			},
			confirmDel() {
				this.model.Nav_ListSafeCheckDetail.splice(this.showDelModalIndex, 1)
				this.showDelModalIndex = undefined
			},
			handleAdd() {
				//页面跳转
				var linkToUrl = 'safeCheckSignDIY?tableKey=' + this.tableKey + '&ID=' + this.model.ID + '&taskID=' + this
					.TaskID //Url 传参

				// this.model.DEPARTMENT_ID = option.DEPARTMENT_ID
				// this.model.CHECK_TYPE_LEVEL_ID = option.CHECK_TYPE_LEVEL_ID
				//BS077 需要的传参
				linkToUrl += '&ROW_NO=' + this.model.Nav_ListSafeCheckDetail.length + '&SAFE_CHECK_ID=' + this.model.ID +
					'&CHECKOBJECT=' + this.model.CHECKOBJECT + '&CHECK_TYPE_ID=' + this.model.CHECK_TYPE_ID +
					'&DEPARTMENT_ID=' + this.model.DEPARTMENTID + '&CHECK_TYPE_LEVEL_ID=' + this.model
					.CHECK_TYPE_LEVEL_ID + '&Nav_ListUserCheck=' + encodeURIComponent(JSON.stringify(this.model
						.Nav_ListSafeCheckDetail[0]
						.Nav_ListCheckDetailUser))
				uni.navigateTo({
					url: linkToUrl
				})
			},
			handleTab(t) {
				this.currentTab = t
			},
			FullCheckUpdate() {
				const ele = this.$refs
				ele['wForm'].validate().then(res => {
					const orgId = uni.getStorageSync('orgId')
					this.model.Nav_ListSafeCheckDetail[0].Nav_ListCheckDetailUser[0].SAFECHECKSTATE = 80;
					this.model.TaskID = this.TaskID
					if (this.model.Nav_ListSafeCheckDetail != null && this.model.Nav_ListSafeCheckDetail.length >
						0) {
						this.model.Nav_ListSafeCheckDetail.forEach(e => {
							if (e.Nav_ListCheckDetailReason != null && e.Nav_ListCheckDetailReason.length >
								0) {
								e.Nav_ListCheckDetailReason.forEach(er => {
									if (er.Nav_RiskReason != null)
										er.Nav_RiskReason = null
								})
							}
						})
					}
					FullCheckUpdateBS057(this.model).then(res => {
						uni.$showMsgFunc('操作成功!', () => {
							if (this.tableKey == null || this.tableKey == 0) {
								uni.navigateTo({
									url: 'safeCheckIndex'
								})
							} else {
								// uni.navigateBack()// 如果有手动操作 跳转页面不对

								// uni.switchTab({
								// 	url: '../../../index/index2',
								// })
								uni.switchTab({
									url: '/pages/index/index2'
								})

							}
						}, 'success', 1000)
					})
				}).catch(err => {
					console.log('校验失败', err)
				})
			},

			async loadData() {
				const orgId = uni.getStorageSync('orgId')
				if (this.listPropValUpload.length == 0) {
					this.listPropValUpload.push(this.model.ID)
				}

				const json = initFilter(orgId, "", "CODE", 1)
				extendRule(json, 'ID', 1, this.model.ID);
				extendInclude(json, "Nav_CheckType");
				extendInclude(json, "Nav_CheckTypeLevel.Nav_Enums");
				extendInclude(json, "Nav_ListCheckRiskArea");
				extendInclude(json, "Nav_ListCheckRiskArea.Nav_RiskArea");
				extendInclude(json, "Nav_ListCheckProject");
				extendInclude(json, "Nav_ListCheckProject.Nav_CheckProject");
				// extendInclude(json, "Nav_ListCheckProjectCategory");
				// extendInclude(json, "Nav_ListCheckProjectCategory.Nav_CheckProjectCategory");
				extendInclude(json, "Nav_Files.Nav_ImgFile.Nav_File");
				extendInclude(json, "Nav_ListSafeCheckDetail");
				extendInclude(json, "Nav_ListSafeCheckDetail.Nav_CheckArea");
				extendInclude(json, "Nav_ListSafeCheckDetail.Nav_CheckProject");
				extendInclude(json, "Nav_ListSafeCheckDetail.Nav_CheckQuestion");
				extendInclude(json, "Nav_ListSafeCheckDetail.Nav_ListCheckDetailQuestion.Nav_Question");
				extendInclude(json, "Nav_ListSafeCheckDetail.Nav_ListCheckDetailReason.Nav_RiskReason");
				extendInclude(json, "Nav_ListSafeCheckDetail.Nav_Files.Nav_ImgFile.Nav_File");

				json.IgnoreDataRule = true
				GetUserCheckInfoBS057(json).then(res => {

					if (res.Nav_ListSafeCheckDetail != undefined && res.Nav_ListSafeCheckDetail.length > 0) {
						let checkerNames = ''
						for (let i = 0; i < res.Nav_ListSafeCheckDetail.length; i++) {

							//附件 处理
							res.Nav_ListSafeCheckDetail[i].listPropValSubUpload = []
							// res.Nav_ListSafeCheckDetail[i].listPropValSubUpload.push(res.Nav_ListSafeCheckDetail[i]
							// 	.ORG_ID)
							res.Nav_ListSafeCheckDetail[i].listPropValSubUpload.push(res
								.Nav_ListSafeCheckDetail[i]
								.SAFE_CHECK_ID)
							res.Nav_ListSafeCheckDetail[i].listPropValSubUpload.push(res
								.Nav_ListSafeCheckDetail[i]
								.ID)

							//检查人
							checkerNames = ''
							for (let j = 0; j < res.Nav_ListSafeCheckDetail[i].Nav_ListCheckDetailUser
								.length; j++) {
								checkerNames += ' ' + res.Nav_ListSafeCheckDetail[i].Nav_ListCheckDetailUser[j]
									.Nav_User.NAME
							}
							res.Nav_ListSafeCheckDetail[i].checkerNames = checkerNames.substring(1)

							res.Nav_ListSafeCheckDetail[i].QUESTION_LEVEL = null //问题等级

							//检查问题描述 显示 默认的 无 或者加载显示
							if (res.Nav_ListSafeCheckDetail[i].Nav_ListCheckDetailQuestion != null) {


								if (res.Nav_ListSafeCheckDetail[i].Nav_ListCheckDetailQuestion.length == 1) {
									if (res.Nav_ListSafeCheckDetail[i].Nav_ListCheckDetailQuestion[0]
										.Nav_Question != undefined) {
										res.Nav_ListSafeCheckDetail[i].listCheckDetailQuestion = res
											.Nav_ListSafeCheckDetail[i].Nav_ListCheckDetailQuestion[0]
											.Nav_Question.DESCREPTION


										res.Nav_ListSafeCheckDetail[i].DEMAND = res
											.Nav_ListSafeCheckDetail[i].Nav_ListCheckDetailQuestion[0]
											.Nav_Question.DEMAND
									}
								} else {
									let DESCREPTION = ''
									let DEMAND = ''
									for (let i = 0; i < res.Nav_ListSafeCheckDetail[i]
										.Nav_ListCheckDetailQuestion
										.length; i++) {
										if (res.Nav_ListSafeCheckDetail[i].Nav_ListCheckDetailQuestion[0]
											.Nav_Question != undefined) {
											DESCREPTION += '，' + res.Nav_ListSafeCheckDetail[i]
												.Nav_ListCheckDetailQuestion[i].Nav_Question
												.DESCREPTION
											DEMAND += '，' + res.Nav_ListSafeCheckDetail[i]
												.Nav_ListCheckDetailQuestion[i].Nav_Question
												.DEMAND
										}
									}

									res.Nav_ListSafeCheckDetail[i].listCheckDetailQuestion = DESCREPTION
										.substring(1)
									res.Nav_ListSafeCheckDetail[i].DEMAND = DEMAND.substring(1)
								}
							}

							if (!res.Nav_ListSafeCheckDetail[i].ISAUTOLOAD && res.Nav_ListSafeCheckDetail[i]
								.Nav_ListCheckDetailReason != null && res.Nav_ListSafeCheckDetail[i]
								.Nav_ListCheckDetailReason.length > 0) {
								var listCheckDetailReason = ''
								res.Nav_ListSafeCheckDetail[i].Nav_ListCheckDetailReason.forEach(e => {
									listCheckDetailReason += ' ' + e.Nav_RiskReason?.NAME
								})
								res.Nav_ListSafeCheckDetail[i].listCheckDetailReason = listCheckDetailReason
							}
						}
					}

					this.model = res
					auditOptionShow(this.model.STATECHECK, 40, this.model.APPROVE_CHECKAUDIT_ID).then(res => {
						this.AUDIT_OPINION = res
					})



					// this.AUDIT_OPINION = await auditOptionShow2(this.model.STATECHECK, 40, this.model
					// 	.APPROVE_CHECKAUDIT_ID) {

					// 	if (dataState == stateReject) {
					// 		return new Promise((resolve, reject) => {
					// 			request.get("/PF/PFApprove/GetRejectContentByAPPID", {
					// 				"ApproveID": dataId
					// 			}).then((result) => {
					// 				return result.Data
					// 			}).catch((error) => {
					// 				reject(error);
					// 			})
					// 		})
					// 	} else {
					// 		return ''
					// 	}
					// }



					this.Nav_Files = res.Nav_Files

					//数据组装
					let strRiskAreaNAME = ''
					if (res.Nav_ListCheckRiskArea && res.Nav_ListCheckRiskArea.length > 0) {
						for (let i = 0; i < res.Nav_ListCheckRiskArea.length; i++) {
							strRiskAreaNAME += (strRiskAreaNAME.length > 0 ? "," : "") + res
								.Nav_ListCheckRiskArea[
									i].Nav_RiskArea.NAME;
						}
					}

					// let CheckProjectCategoryNAME = ''
					// if (res.Nav_ListCheckProjectCategory && res.Nav_ListCheckProjectCategory.length > 0) {
					// 	for (let i = 0; i < res.Nav_ListCheckProjectCategory.length; i++) {
					// 		CheckProjectCategoryNAME += (CheckProjectCategoryNAME.length > 0 ? "," : "") + res
					// 			.Nav_ListCheckProjectCategory[i].Nav_CheckProjectCategory.NAME;
					// 	}
					// }
					this.model.RiskAreaNAME = strRiskAreaNAME
					// this.model.CheckProjectCategoryNAME = CheckProjectCategoryNAME
					this.isLoadOK = true
				})
			},

			//下拉数据加载
			async handleShowSheet(p) {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "", 0)
				let dataSelect = []
				if (p.name === 'listCheckDetailReason') {
					// extendOrder(json, "NUM", "0")
					// NAME
					dataSelect = await orderPagedRiskReason(json).then(res => {
						return res
					})
				} else if (p.name == 'listCheckDetailQuestion') {

					let theItems = p.subData
					extendInclude(json, "Nav_Main")
					extendFilterGroupGroupRules(json, 'SAFE_CHECK_ID', 1, p.subData.SAFE_CHECK_ID)
					extendFilterGroupGroupRules(json, 'CHECKCONTENT', 1, p.subData.CHECKCONTENT)
					extendFilterGroupGroupRules(json, 'DEPARTMENT_ID', 1, p.data.DEPARTMENTID)
					extendFilterGroupGroupRules(json, 'CHECK_PROJECT_ID', 1, p.subData.CHECK_PROJECT_ID)
					extendFilterGroupGroupRules(json, 'RISK_AREA_ID', 1, p.subData.RISK_AREA_ID)
					extendFilterGroupGroupRules(json, 'CHECK_PROJECT_CATEGORY_ID', 1, p.subData
						.CHECK_PROJECT_CATEGORY_ID)
					dataSelect = await GetCheckDetailDESCREPTION(json).then(res => {
						//数据组装
						if (res != undefined && res.length > 0) {
							for (let i = 0; i < res.length; i++) {
								res[i].NAME = res[i].DESCREPTION
							}
						}
						return res
					})
				}

				if (dataSelect.length) {
					this.comPickerInfo = {
						showSheet: true,
						title: p.title,
						name: p.name,
						formIndex: p.formIndex,
						columns: [dataSelect]
					}
				} else {
					// 暂无数据
				}
			},
			onConfirmPicker(e) {
				const {
					name,
					formIndex
				} = this.comPickerInfo
				if (name == 'listCheckDetailReason') {
					// listCheckDetailReason
					this.model.Nav_ListSafeCheckDetail[formIndex].listCheckDetailReason = e.value[0].NAME
					let selectReason = e.value[0]
					selectReason.RISK_REASON_ID = selectReason.ID
					selectReason.ID = guid()
					selectReason.CHECK_DETAIL_ID = this.model.Nav_ListSafeCheckDetail[formIndex].ID;
					if (this.model.Nav_ListSafeCheckDetail[formIndex].Nav_ListCheckDetailReason == undefined) {
						this.model.Nav_ListSafeCheckDetail[formIndex].Nav_ListCheckDetailReason = []
						this.model.Nav_ListSafeCheckDetail[formIndex].Nav_ListCheckDetailReason.push(selectReason)
					} else {
						this.model.Nav_ListSafeCheckDetail[formIndex].Nav_ListCheckDetailReason[0] = selectReason
					}
				} else if (name == 'listCheckDetailQuestion') {
					// 检查问题
					this.model.Nav_ListSafeCheckDetail[formIndex].listCheckDetailQuestion = e.value[0].NAME
					// if (this.model.Nav_ListSafeCheckDetail[formIndex].Nav_ListCheckDetailQuestion == undefined) {
					// 	this.model.Nav_ListSafeCheckDetail[formIndex].Nav_ListCheckDetailQuestion = []
					// 	this.model.Nav_ListSafeCheckDetail[formIndex].Nav_ListCheckDetailQuestion.push(e.value[0])
					// } else {
					// 	this.model.Nav_ListSafeCheckDetail[formIndex].Nav_ListCheckDetailQuestion[0] = e.value[0]
					// }

					// 数据处理
					let checkDetailChoose = e.value[0]
					checkDetailChoose.SAFE_CHECK_QUESTION_ID = checkDetailChoose.ID;
					checkDetailChoose.ID = guid()
					checkDetailChoose.SAFE_CHECK_ID = this.model.Nav_ListSafeCheckDetail[formIndex].SAFE_CHECK_ID;
					checkDetailChoose.SAFE_CHECK_DETAIL_ID = this.model.Nav_ListSafeCheckDetail[formIndex].ID;
					this.model.Nav_ListSafeCheckDetail[formIndex].Nav_ListCheckDetailQuestion[0] = checkDetailChoose


					if (e.value[0].ID != '55555555-5555-5555-5555-555555555555') {
						//问题等级		QUESTION_LEVELShow		QUESTION_LEVEL
						// this.model.Nav_ListSafeCheckDetail[formIndex].QUESTION_LEVELShow = '问题等级枚举' + e.value[0].Nav_Main.QUESTION_LEVEL
						this.model.Nav_ListSafeCheckDetail[formIndex].QUESTION_LEVEL_DESCRIPTION = e.value[0].Nav_Main
							.QUESTION_LEVE_DESCRIPTION
						this.model.Nav_ListSafeCheckDetail[formIndex].QUESTION_LEVEL = e.value[0].Nav_Main.QUESTION_LEVEL
						//整改建议与措施
						this.model.Nav_ListSafeCheckDetail[formIndex].DEMAND = e.value[0].DEMAND
					} else {
						//问题等级		QUESTION_LEVELShow		QUESTION_LEVEL
						this.model.Nav_ListSafeCheckDetail[formIndex].QUESTION_LEVEL_DESCRIPTION = ''
							.QUESTION_LEVEL
						this.model.Nav_ListSafeCheckDetail[formIndex].QUESTION_LEVEL = null
						//整改建议与措施
						this.model.Nav_ListSafeCheckDetail[formIndex].DEMAND = ''
					}
				}
				this.comPickerInfo.showSheet = false
			},
			closePicker() {
				this.comPickerInfo = {
					showSheet: false,
					columns: [],
					title: '',
					name: '',
					formIndex: undefined
				}
			},



			//显示组件
			handleChange(itemData) {
				this.selectorInfo.showPopup = true
				this.selectorInfo.title = '隐患原因'
				// this.selectorInfo.name = name
				// this.selectorInfo.index = val
				this.selectorInfo.itemData = itemData
				let defCheck = []

				if (itemData.Nav_ListCheckDetailReason != null && itemData.Nav_ListCheckDetailReason.length > 0) {
					for (let i = 0; i < itemData.Nav_ListCheckDetailReason.length; i++) {
						defCheck.push(itemData.Nav_ListCheckDetailReason[i].Nav_RiskReason)
					}
				}
				this.selectorInfo.defaultChecked = defCheck
				this.handleSearch()
			},

			//数据加载
			handleSearch(val) {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "", 0)
				if (val) {
					extendRule(json, 'NAME', 9, val);
				}

				orderPagedRiskReason(json).then(res => {
					// if (res.IsSuccessful) {
					this.selectorInfo.dataLists = res.map(i => {
						return {
							...i,
							name: i.NAME,
							code: i.CODE
						}
					})
					// }
				})
			},

			//选择信息
			handleSelected(e) {
				this.selectorInfo.showPopup = false
				let listReason = []
				let reasonShow = ''
				if (e.length > 0) {
					e.forEach((item, i) => {
						if (i > 0) {
							reasonShow += ' '
						}
						listReason.push({
							ID: guid(),
							CHECK_DETAIL_ID: this.selectorInfo.itemData.ID,
							RISK_REASON_ID: item.ID,
							ORG_ID: item.ORG_ID,
							Nav_RiskReason: e[i]
						})
						reasonShow += item.NAME
					})
				}
				this.selectorInfo.itemData.Nav_ListCheckDetailReason = listReason
				this.selectorInfo.itemData.listCheckDetailReason = reasonShow
			}
		},
		computed: {},
		// onNavigationBarButtonTap(e) {
		// 	this.subForms.push({
		// 		title: '检查详情' + (this.subForms.length + 1),
		// 		Nav_ListCheckDetailReason: '',
		// 	})
		// }
	}
</script>


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