<!-- 检查记录确认-->
<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" ref="wForm"
					errorType="border-bottom"> <!-- :rules="rules" -->

					<u-form-item label="检查任务" prop="NAME" borderBottom>
						<u--input disabled disabledColor="#ffffff" v-model="model.NAME" border="none" slot="right"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="检查类型" prop="Nav_CheckType.NAME" borderBottom>
						<u--input disabled disabledColor="#ffffff" 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="#ffffff" v-model="model.Nav_CheckTypeLevel.Nav_Enums.NAME"
							border="none" slot="right" inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="检查时间" prop="CREATE_TIME" borderBottom>
						<u--input disabled disabledColor="#ffffff" v-model="model.CREATE_TIME" border="none"
							slot="right" inputAlign="right"></u--input>
					</u-form-item>
					<!-- <u-form-item label="检查区域" prop="RiskAreaNAME" borderBottom>
						<u--input v-model="model.RiskAreaNAME" border="none" slot="right" inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="检查项目分类" prop="CheckProjectCategoryNAME" borderBottom>
						<u--input v-model="model.CheckProjectCategoryNAME" border="none" slot="right"
							inputAlign="right"></u--input>
					</u-form-item> -->

					<view class="upload-title">附件</view>
					<full-upload v-model="model.Nav_Files" :isShowBtn='tableKey==1?true:false'
						: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>
			</uni-card>
		</view>

		<u-sticky offset-top="20">
			<view class="sub-form">
				<view class="sub-form-wrap">
					<u--form labelPosition="left" labelWidth="auto" labelAlign="center" errorType="border-bottom"
						ref="sForm">
						<uni-collapse :border="false" accordion> <!-- :value='1' -->
							<uni-card style="margin-bottom: 16px;" margin="0" spacing="0" :is-shadow="false"
								v-for="(item, index) in model.Nav_ListRiskSubmitContent" :name="index">
								<uni-collapse-item :title="index + 1 + '. ' + item.CHECKCONTENT"> <!-- name="1" -->


									<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="QUESTION_LEVEL_SHOW" borderBottom>
										<u--input disabled disabledColor="#ffffff" v-model="item.QUESTION_LEVEL_SHOW"
											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>


									<view class="label-title">检查依据</view>
									<u-form-item prop="PROOF" borderBottom>
										<u--textarea disabled autoHeight v-model="item.PROOF" placeholder="检查依据"
											border="surround"></u--textarea>
									</u-form-item>

									<u-form-item v-if="tableKey==1" label="隐患原因" class="subRequired" required
										prop="listRiskQuestionReason" borderBottom
										@click="handleChange(index,'reason')">
										<u--input disabledColor="#fff" v-model="item.listRiskQuestionReason"
											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="listRiskQuestionReason" borderBottom>
										<u--input disabledColor="#fff" v-model="item.listRiskQuestionReason"
											border="none" inputAlign="right"></u--input>
									</u-form-item>

									<u-form-item v-if="tableKey==1" label="隐患地点" class="subRequired" required
										prop="ADDRESS" borderBottom>
										<u--input disabledColor="#ffffff" v-model="item.ADDRESS" border="none"
											inputAlign="right"></u--input>
									</u-form-item>
									<u-form-item v-else label="隐患地点" required prop="ADDRESS" borderBottom>
										<u--input disabledColor="#ffffff" v-model="item.ADDRESS" border="none"
											inputAlign="right"></u--input>
									</u-form-item>
									<!-- <u-form-item label="附件" prop="DEMAND" borderBottom>
									</u-form-item> -->

									<view class="upload-title">附件</view>
									<full-upload v-model="item.Nav_Files" :isShowBtn='tableKey==1?true:false'
										:listProp='listPropSubUpload'
										:listPropVal='item.listPropValSubUpload'></full-upload>

									<u-form-item label="系统整改期限" prop="LastDateSystemShow" borderBottom>
										<u--input disabled disabledColor="#fff" v-model="item.LastDateSystemShow"
											border="none" inputAlign="right"></u--input>
									</u-form-item>

									<u-form-item v-if="tableKey==1" class="subRequired" required label="整改期限"
										prop="LastDateUser" borderBottom @click="showCheckDate(index)">
										<u--input v-model="item.LastDateUser" disabledColor="#fff" placeholder="请选择整改期限"
											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="LastDateUser"
										borderBottom>
										<u--input v-model="item.LastDateUser" disabledColor="#fff" placeholder="请选择整改期限"
											border="none" inputAlign="right"></u--input>
									</u-form-item>
									<u-form-item v-if="tableKey==1" class="subRequired" required label="整改实施单位"
										prop="Nav_DepartmentDeal.NAME" borderBottom
										@click="handleShowSheet({title: '整改实施单位', name: 'departmentName', dataIndex: index})">
										<u--input disabledColor="#fff" v-model="item.departmentName" 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="Nav_DepartmentDeal.NAME" borderBottom>
										<u--input disabledColor="#fff" v-model="item.Nav_DepartmentDeal.NAME" border="none"
											inputAlign="right"></u--input>
									</u-form-item>

									<u-form-item v-if="tableKey==1" class="subRequired" required label="整改责任人"
										prop="Nav_UserDeal.NAME" borderBottom
										@click="handleChange( index,'userDetailer')">
										<u--input disabledColor="#fff" v-model="item.userDetailer" 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="Nav_UserDeal.NAME" borderBottom>
										<u--input disabledColor="#fff" v-model="item.userDetailer" border="none"
											inputAlign="right"></u--input>
									</u-form-item>
									<u-form-item v-if="tableKey==1" class="subRequired" required label="验收人"
										prop="Nav_UserCheck.NAME" borderBottom @click="handleChange(index,'user')">
										<!-- @click="handleShowSheet({title: '验收人', name: 'userChecker', dataIndex: index})" -->
										<!-- Nav_UserCheck.NAME -->
										<u--input disabledColor="#fff" v-model="item.userChecker" 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="Nav_UserCheck.NAME" borderBottom>
										<u--input disabledColor="#fff" v-model="item.Nav_UserCheck.NAME" border="none"
											inputAlign="right"></u--input>
									</u-form-item>
								</uni-collapse-item>
							</uni-card>
						</uni-collapse>
					</u--form>
				</view>
			</view>
		</u-sticky>

		<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" />

		<!-- <query-selector :show="comPickerInfo.showSheet" :lists="userLists" :defaultValue="currentOperateUser.NAME"
			@close="closePicker" @search="handleSearchUser" @select="onConfirmPicker" /> -->

		<u-picker :show="comPickerInfo.showSheet" :columns="comPickerInfo.columns" @confirm="onConfirmPicker"
			@close="closePicker" @cancel="closePicker" keyName="NAME"></u-picker>

		<u-datetime-picker :show="dateTimePickerInfo.showCheckDate" mode="date"
			v-model='dateTimePickerInfo.defaultDateTime' @confirm="handleCheckDate"
			@close="dateTimePickerInfo.showCheckDate = false;"
			@cancel="dateTimePickerInfo.showCheckDate = false;"></u-datetime-picker>

		<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 {
		GetBS006,
		GetSubmitContent,
		FullUpdateBS006
	} from '../../../../services/apply/subPages/BS/riskSubmit'

	import {
		orderPagedRiskReason,
	} from '../../../../services/apply/subPages/BS/safeCheck'
	// import '@/utils/showMsg.js'
	import {
		data
	} from '../../../../uni_modules/uview-ui/libs/mixin/mixin'

	import {
		UserPagedLimit,
		UserPagedAll,
		GetDpartMentNameHeader
	} from '../../../../services/common'

	export default {
		data() {
			return {
				tableKey: '0',
				TaskID: '',
				listPropUpload: ['RISK_SUBMIT_ID'],
				listPropValUpload: [],
				listPropSubUpload: ['RISK_SUBMIT_ID', 'RISK_SUBMIT_CONTENT_ID'],

				model: {
					ID: '',
					TaskID: '',
					Nav_CheckType: {},
					Nav_CheckTypeLevel: {
						Nav_Enums: {}
					},
					Nav_Files: [],
					Nav_ListRiskSubmitContent: [{
						Nav_Department: {},
						Nav_UserCheck: {},
						Nav_UserDeal: {},
						LastDateUser: null,
						departmentName: '',
						userChecker: '',
						userDetailer: '',
						listPropValSubUpload: [],
						Nav_Files: []
					}]
				},
				isLoadOK: false,
				lists: [],
				comPickerInfo: {
					showSheet: false,
					columns: [],
					title: '',
					dataIndex: undefined,
					formIndex: undefined,
					name: ''
				},
				dateTimePickerInfo: {
					showCheckDate: false,
					dataIndex: undefined,
					defaultDateTime: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd'),
					value: ''
				},

				selectorInfo: {
					name: 'user',
					isMultiple: false,
					showPopup: false,
					totalCount: 0,
					title: '人员选择',
					index: 0,
					dataLists: [],
					defaultText: '',
					defaultChecked: []
				},

				// 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: {
			handleTab(t) {
				this.currentTab = t
			},

			//显示时间控件
			showCheckDate(dataIndex) {
				if (this.model.Nav_ListRiskSubmitContent[dataIndex].LastDateUser == null) {
					this.model.Nav_ListRiskSubmitContent[dataIndex].LastDateUser = uni.$u.timeFormat(new Date(),
						'yyyy-mm-dd')
				}

				this.dateTimePickerInfo = {
					showCheckDate: true,
					dataIndex: dataIndex,
					defaultDateTime: this.model.Nav_ListRiskSubmitContent[dataIndex].LastDateUser
				}
			},

			//隐藏控件 显示时间
			handleCheckDate(e) {
				let v = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
				const {
					name,
					dataIndex
				} = this.dateTimePickerInfo
				this.dateTimePickerInfo.showCheckDate = false
				this.model.Nav_ListRiskSubmitContent[dataIndex].LastDateUser = uni.$u.timeFormat(e.value,
					'yyyy-mm-dd')
			},

			FullCheckUpdate() {
				// const ele = this.$refs
				// ele['wForm'].validate().then(res => {
				// const orgId = uni.getStorageSync('orgId')
				this.model.SUBMIT_STATUS = 20
				this.model.TaskID = this.TaskID
				const orgId = uni.getStorageSync('orgId')

				this.model.Nav_Check = null
				this.model.Nav_CheckType = null
				this.model.Nav_CheckTypeLevel = null

				if (!this.model.Nav_ListRiskSubmitContent)
					uni.$showErrorInfo('上报明细不能为空！')
				// debugger
				for (let i = 0; i < this.model.Nav_ListRiskSubmitContent.length; i++) {
					this.model.Nav_ListRiskSubmitContent[i].Nav_UserCheck = null
					this.model.Nav_ListRiskSubmitContent[i].Nav_UserDeal = null
					this.model.Nav_ListRiskSubmitContent[i].Nav_User = null
					this.model.Nav_ListRiskSubmitContent[i].Nav_Department = null
					this.model.Nav_ListRiskSubmitContent[i].Nav_DepartmentDeal = null

					this.model.Nav_ListRiskSubmitContent[i].Nav_SafeCheckDetail = null
					this.model.Nav_ListRiskSubmitContent[i].Nav_CheckMain = null
					this.model.Nav_ListRiskSubmitContent[i].Nav_Question = null

					if (this.model.Nav_ListRiskSubmitContent[i].Nav_ListRiskQuestionReason == null || this.model
						.Nav_ListRiskSubmitContent[i].Nav_ListRiskQuestionReason.length < 1) {
						uni.$showErrorInfo('子表【' + (i + 1) + '】隐患原因不能为空！')
					}
					for (let j = 0; j < this.model.Nav_ListRiskSubmitContent[i].Nav_ListRiskQuestionReason
						.length; j++) {
						this.model.Nav_ListRiskSubmitContent[i].Nav_ListRiskQuestionReason[j].Nav_RiskReason =
							null;
					}
					this.model.Nav_ListRiskSubmitContent[i].ORG_ID = orgId
					if (this.model.Nav_ListRiskSubmitContent[i].LastDateUser != null)
						this.model.Nav_ListRiskSubmitContent[i].LastDateUser = this.model
						.Nav_ListRiskSubmitContent[i].LastDateUser + ' 23:59:59'
				}


				FullUpdateBS006(this.model).then(res => {
					uni.$showMsgFunc('操作成功!', () => {
						if (this.tableKey == null || this.tableKey == 0) {
							uni.navigateTo({
								url: 'safeCheckIndex'
							})
						} else {
							uni.navigateBack()
						}
					}, 'success', 1000)
				})
				// }).catch(err => {
				// 	// console.log('校验失败', err)
				// 	uni.$showErrorInfo('校验失败！')
				// })
			},

			async loadData() {
				var that = this
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "CODE", 1)
				// let that = this
				// this.listPropValUpload.push(orgId)
				// this.listPropValUpload.push(this.model.ID) //ID不对

				extendRule(json, 'ID', 1, this.model.ID);
				extendInclude(json, "Nav_Check");
				extendInclude(json, "Nav_CheckType");
				extendInclude(json, "Nav_CheckTypeLevel.Nav_Enums");
				extendInclude(json, "Nav_Files.Nav_ImgFile");
				extendInclude(json, "Nav_ListRiskSubmitContent");
				extendInclude(json, "Nav_ListRiskSubmitContent.Nav_CheckMain");
				extendInclude(json, "Nav_ListRiskSubmitContent.Nav_SafeCheckDetail");
				extendInclude(json, "Nav_ListRiskSubmitContent.Nav_ListRiskQuestionReason.Nav_RiskReason");
				extendInclude(json, "Nav_ListRiskSubmitContent.Nav_User");
				extendInclude(json, "Nav_ListRiskSubmitContent.Nav_Department");
				extendInclude(json, "Nav_ListRiskSubmitContent.Nav_Files.Nav_ImgFile");
				extendInclude(json, "Nav_ListRiskSubmitContent.Nav_DepartmentDeal");
				extendInclude(json, "Nav_ListRiskSubmitContent.Nav_UserDeal");
				extendInclude(json, "Nav_ListRiskSubmitContent.Nav_UserCheck");


				json.IgnoreDataRule = true
				GetBS006(json).then(async res => {
					// if (!res.Nav_Files)
					// 	res.Nav_Files = []//null 时 数据加载有问题
					this.model = res
					this.listPropValUpload.push(this.model.ID)
					let jsonSub = initFilter(orgId, res.ID, null, null, null, res.CHECK_ID);
					let reasons = ''

					if (this.model.Nav_ListRiskSubmitContent == null || this.model
						.Nav_ListRiskSubmitContent.length < 1) {
						//适配原有的 没有数据就去异步查找
						this.model.Nav_ListRiskSubmitContent = await GetSubmitContent(jsonSub).then(
							res2 => {
								return res2
							})
					}

					if (this.model.Nav_ListRiskSubmitContent != null && this.model
						.Nav_ListRiskSubmitContent
						.length > 0) {

						for (let i = 0; i < this.model.Nav_ListRiskSubmitContent.length; i++) {
							this.model.Nav_ListRiskSubmitContent[i].departmentName = this.model
								.Nav_ListRiskSubmitContent[i].Nav_Department?.NAME
							this.model.Nav_ListRiskSubmitContent[i].userChecker = this.model
								.Nav_ListRiskSubmitContent[i].Nav_UserCheck?.NAME
							this.model.Nav_ListRiskSubmitContent[i].userDetailer = this.model
								.Nav_ListRiskSubmitContent[i].Nav_UserDeal?.NAME

							if (this.model.Nav_ListRiskSubmitContent[i].LastDateSystem) //显示日期
								this.model.Nav_ListRiskSubmitContent[i].LastDateSystemShow = this.model
								.Nav_ListRiskSubmitContent[i].LastDateSystem.split(' ')[0]

							if (this.model.Nav_ListRiskSubmitContent[i].Nav_ListRiskQuestionReason !=
								null &&
								this.model.Nav_ListRiskSubmitContent[i]
								.Nav_ListRiskQuestionReason.length > 0) {
								reasons = ''
								for (let j = 0; j < this.model.Nav_ListRiskSubmitContent[i]
									.Nav_ListRiskQuestionReason
									.length; j++) {
									reasons += (reasons.length > 0 ? '，' : '') + this.model
										.Nav_ListRiskSubmitContent[i]
										.Nav_ListRiskQuestionReason[j].Nav_RiskReason.NAME
								}
								this.model.Nav_ListRiskSubmitContent[i].listRiskQuestionReason = reasons
							}

							this.model.Nav_ListRiskSubmitContent[i].listPropValSubUpload = []
							// this.model.Nav_ListRiskSubmitContent[i].listPropValSubUpload.push(orgId)
							this.model.Nav_ListRiskSubmitContent[i].listPropValSubUpload.push(this.model
								.ID)
							this.model.Nav_ListRiskSubmitContent[i].listPropValSubUpload.push(this.model
								.Nav_ListRiskSubmitContent[i].ID)
						}
					}
					this.isLoadOK = true

				})
			},

			//下拉数据加载
			async handleShowSheet(p) {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "", 0)
				let dataSelect = []
				if (p.name === 'listRiskQuestionReason') {
					// extendOrder(json, "NUM", "0")
					// NAME
					dataSelect = await orderPagedRiskReason(json).then(res => {
						return res
					})
				} else if (p.name === 'departmentName') {
					extendInclude(json, "Nav_User")
					dataSelect = await GetDpartMentNameHeader(json).then(res => {
						return res
					})
				} else if (p.name === 'userDetailer' || p.name === 'userChecker') {
					dataSelect = await OrderPagedUseful(json).then(res => {
						return res
					})
				}

				if (dataSelect.length) {
					this.comPickerInfo = {
						showSheet: true,
						title: p.title,
						name: p.name,
						dataIndex: p.dataIndex,
						columns: [dataSelect]
					}
				} else {
					// 暂无数据
				}
			},
			// 整改实施单位 departmentName Nav_DepartmentDeal  整改责任人 Nav_UserDeal  userDetailer  验收人Nav_UserCheck userChecker

			onConfirmPicker(e) {
				const {
					name,
					dataIndex
				} = this.comPickerInfo

				if (name == 'listRiskQuestionReason') {
					// this.model.Nav_ListRiskSubmitContent[i].Nav_ListRiskQuestionReason  Nav_ListRiskQuestionReason

					this.model.Nav_ListRiskSubmitContent[dataIndex].listRiskQuestionReason = e.value[0].NAME
					let selectReason = e.value[0]
					selectReason.RISK_REASON_ID = selectReason.ID
					selectReason.ID = guid()
					selectReason.ORG_ID = uni.getStorageSync('orgId')
					// selectReason.CHECK_DETAIL_ID = this.model.Nav_ListRiskSubmitContent[dataIndex].ID;
					selectReason.RISK_SUBMIT_CONTENT_ID = this.model.Nav_ListRiskSubmitContent[dataIndex].ID;
					if (this.model.Nav_ListRiskSubmitContent[dataIndex].Nav_ListRiskQuestionReason == undefined) {
						this.model.Nav_ListRiskSubmitContent[dataIndex].Nav_ListRiskQuestionReason = []
					}
					this.model.Nav_ListRiskSubmitContent[dataIndex].Nav_ListRiskQuestionReason[0] = selectReason


				} else if (name == 'userChecker') {
					//验收人
					this.model.Nav_ListRiskSubmitContent[dataIndex].Nav_UserCheck = e.value[0]
					this.model.Nav_ListRiskSubmitContent[dataIndex].userChecker = e.value[0].NAME
					this.model.Nav_ListRiskSubmitContent[dataIndex].CHECK_USER_ID = e.value[0].ID
				} else if (name == 'userDetailer') {
					//整改责任人
					this.model.Nav_ListRiskSubmitContent[dataIndex].Nav_UserDeal = e.value[0]
					this.model.Nav_ListRiskSubmitContent[dataIndex].userDetailer = e.value[0].NAME
					this.model.Nav_ListRiskSubmitContent[dataIndex].DEAL_USER_ID = e.value[0].ID
				} else if (name == 'departmentName') {
					//整改实施单位
					this.model.Nav_ListRiskSubmitContent[dataIndex].Nav_DepartmentDeal = e.value[0]
					this.model.Nav_ListRiskSubmitContent[dataIndex].departmentName = e.value[0].NAME
					this.model.Nav_ListRiskSubmitContent[dataIndex].DEAL_DEPARTMENT_ID = e.value[0].ID
				}

				this.comPickerInfo.showSheet = false
			},


			closePicker() {
				this.comPickerInfo = {
					showSheet: false,
					columns: [],
					title: '',
					name: '',
					formIndex: undefined
				}
			},


			//显示组件
			handleChange(val, name) {
				if (name == 'user' || name == 'userDetailer') {
					this.selectorInfo.isMultiple = false
					this.selectorInfo.title = '人员选择'
					this.selectorInfo.defaultChecked = []
				} else {
					this.selectorInfo.isMultiple = true
					this.selectorInfo.title = '隐患原因'
					if (this.model.Nav_ListRiskSubmitContent[val].Nav_ListRiskQuestionReason == null || this.model
						.Nav_ListRiskSubmitContent[val].Nav_ListRiskQuestionReason.length < 1) {
						this.selectorInfo.defaultChecked = []
					} else {
						let def = []
						for (let i = 0; i < this.model.Nav_ListRiskSubmitContent[val].Nav_ListRiskQuestionReason
							.length; i++) {
							def.push(this.model.Nav_ListRiskSubmitContent[val].Nav_ListRiskQuestionReason[i]
								.Nav_RiskReason)
						}
						this.selectorInfo.defaultChecked = def
					}

				}
				this.selectorInfo.name = name
				this.selectorInfo.showPopup = true
				this.selectorInfo.index = val
				this.handleSearch()
			},

			//数据加载
			handleSearch(val, pageIndex) {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "NAME")
				if (val) {
					extendRule(json, 'NAME', 9, val);
				}
				if (this.selectorInfo.name == 'user') {
					//验收人
					json.Limit = 20
					json.Sort = 'NAME'
					json.PageIndex = pageIndex ?? 1
					if (pageIndex) {
						json.Start = (pageIndex - 1) * json.Limit;
					}

					UserPagedAll(json).then(res => {
						this.selectorInfo.totalCount = res.TotalCount
						this.selectorInfo.dataLists = res.Data.map(i => {
							return {
								...i,
								name: i.NAME,
								code: i.CODE
							}
						})
					})
				} else if (this.selectorInfo.name == 'userDetailer') {
					//整改责任人
					// if (val) {
					// 	extendRule(json, 'NAME', 9, val);
					// }
					json.Limit = 20
					json.Sort = 'NAME'
					json.PageIndex = pageIndex ?? 1
					if (pageIndex) {
						json.Start = (pageIndex - 1) * json.Limit;
					}
					UserPagedLimit(json).then(res => {
						if (res.IsSuccessful) {
							// this.selectorInfo.totalCount = res.TotalCount
							// if (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.Data[i].code = res.Data[i].CODE
							// 	}
							// }
							// return res.Data
							this.selectorInfo.totalCount = res.TotalCount
							this.selectorInfo.dataLists = res.Data.map(i => {
								return {
									...i,
									name: i.NAME,
									code: i.CODE
								}
							})
						}
					})
				} else {
					orderPagedRiskReason(json).then(res => {
						this.selectorInfo.dataLists = res.map(i => {
							return {
								...i,
								name: i.NAME,
								code: i.CODE
							}
						})
					})
				}
			},

			//选择信息
			handleSelected(e) {
				this.selectorInfo.showPopup = false
				if (this.selectorInfo.name == 'user') {
					//验收人
					this.model.Nav_ListRiskSubmitContent[this.selectorInfo.index].Nav_UserCheck = e
					this.model.Nav_ListRiskSubmitContent[this.selectorInfo.index].userChecker = e.NAME
					this.model.Nav_ListRiskSubmitContent[this.selectorInfo.index].CHECK_USER_ID = e.ID
				} else if (this.selectorInfo.name == 'userDetailer') {
					//整改责任人
					this.model.Nav_ListRiskSubmitContent[this.selectorInfo.index].Nav_UserDeal = e
					this.model.Nav_ListRiskSubmitContent[this.selectorInfo.index].userDetailer = e.NAME
					this.model.Nav_ListRiskSubmitContent[this.selectorInfo.index].DEAL_USER_ID = e.ID
				} else {
					//隐患原因
					let listReason = []
					let reasonShow = ''
					if (e.length > 0) {
						e.forEach((item, i) => {
							if (i > 0) {
								reasonShow += ' '
							}
							//CHECK_DETAIL_ID => RISK_SUBMIT_CONTENT_ID
							listReason.push({
								ID: guid(),
								RISK_SUBMIT_CONTENT_ID: this.model.Nav_ListRiskSubmitContent[this
									.selectorInfo
									.index].ID,
								RISK_REASON_ID: item.ID,
								ORG_ID: item.ORG_ID,
								Nav_RiskReason: e[i]
							})
							reasonShow += item.NAME
						})
					}
					this.model.Nav_ListRiskSubmitContent[this.selectorInfo.index].Nav_ListRiskQuestionReason = listReason
					this.model.Nav_ListRiskSubmitContent[this.selectorInfo.index].listRiskQuestionReason = reasonShow
					this.selectorInfo.defaultValue = null
				}
			}
		},
		computed: {},
	}
</script>


<style scoped>
	@import url("../../../../style/css/editTemplate.css");
	/* 
	.page-wrap {
		padding: 16px;
	}

	.card {
		margin-bottom: 18px;
	}

	.sub-form {
		margin-bottom: 16px;
	}

	.upload-title {
		color: #303133;
		font-size: 15px;
		line-height: 22px;
		padding: 8px 0;
	}

	.page-wrap>>>.u-upload__button {
		margin-bottom: 0;
	}

	.btnEnable {
		background: #E6E6E6;
		color: #303133;
	}

	.label-title {
		color: #303133;
		font-size: 15px;
		line-height: 22px;
		padding-top: 8px;
	} */
</style>