<!-- 手动隐患上报-指定责任单位-->
<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"
					errorType="border-bottom" ref="wForm">

					<u-form-item label="提交人" prop="Nav_User.NAME" borderBottom>
						<u--input disabled disabledColor="#ffffff" v-model="model.Nav_Submit.Nav_User.NAME"
							border="none" slot="right" inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="检查时间" prop="CHECKTIME" borderBottom>
						<u--input disabled disabledColor="#ffffff" v-model="model.Nav_Submit.CHECKTIME" border="none"
							slot="right" inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="检查区域" prop="Nav_RiskArea.NAME" borderBottom>
						<u--input disabled disabledColor="#ffffff" v-model="model.Nav_RiskArea.NAME" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="隐患地点" prop="ADDRESS" borderBottom>
						<u--input disabled disabledColor="#ffffff" v-model="model.ADDRESS" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<view class="label-title">上报描述</view>
					<u-form-item prop="DESCRIBE" borderBottom>
						<u--textarea disabled autoHeight v-model="model.DESCRIBE" border="surround"></u--textarea>
					</u-form-item>
					<view class="upload-title">附件</view>
					<full-upload :value="model.Nav_Files" :isShowBtn='false' :listProp='listPropUpload'
						:listPropVal='listPropValUpload'></full-upload>


					<u-form-item v-if="tableKey==1" required label="检查范围" prop="CHECKOBJECT" borderBottom
						@click="handleChange( 'CHECKOBJECT')">
						<u--input disabledColor="#fff" v-model="model.CHECKOBJECT_DESCRIPTION" 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="CHECKOBJECT" borderBottom>
						<u--input disabledColor="#fff" v-model="model.CHECKOBJECT_DESCRIPTION" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item v-if="tableKey==1" label="检查类型" required prop="Nav_Submit.Nav_CheckType.NAME"
						@click="handleChange('checkType')" borderBottom>
						<u--input disabled disabledColor="#ffffff" v-model="model.Nav_Submit.Nav_CheckType.NAME"
							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_Submit.Nav_CheckType.NAME" borderBottom>
						<u--input disabled disabledColor="#ffffff" v-model="model.Nav_Submit.Nav_CheckType.NAME"
							border="none" inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item v-if="tableKey==1" label="检查层级" required
						prop="Nav_Submit.Nav_CheckTypeLevel.Nav_Enums.NAME" @click="handleChange('checkTypeLevel')"
						borderBottom>
						<u--input disabled disabledColor="#ffffff"
							v-model="model.Nav_Submit.Nav_CheckTypeLevel.Nav_Enums.NAME" 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_Submit.Nav_CheckTypeLevel.Nav_Enums.NAME" borderBottom>
						<u--input disabled disabledColor="#ffffff"
							v-model="model.Nav_Submit.Nav_CheckTypeLevel.Nav_Enums.NAME" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item v-if="tableKey==1" label="检查内容" required prop="CHECKCONTENT"
						@click="handleChange('CHECKCONTENT')" borderBottom>
						<u--input disabled disabledColor="#ffffff" v-model="model.CHECKCONTENT" 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="CHECKCONTENT" borderBottom>
						<u--input disabled disabledColor="#ffffff" v-model="model.CHECKCONTENT" border="none"
							inputAlign="right"></u--input>
					</u-form-item>

					<u-form-item v-if="tableKey==1" label="检查项目" required prop="Nav_CheckProject.NAME" borderBottom
						@click="handleChange('project')">
						<u--input disabledColor="#fff" v-model="model.Nav_CheckProject.NAME" 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_CheckProject.NAME" borderBottom>
						<u--input disabledColor="#fff" v-model="model.Nav_CheckProject.NAME" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item v-if="tableKey==1" label="检查项目分类" required prop="Nav_CheckProjectCategory.NAME"
						borderBottom @click="handleChange('projectCate')">
						<u--input disabledColor="#fff" v-model="model.Nav_CheckProjectCategory.NAME" 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_CheckProjectCategory.NAME" borderBottom>
						<u--input disabledColor="#fff" v-model="model.Nav_CheckProjectCategory.NAME" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item v-if="tableKey==1" label="检查问题" required prop="DESCREPTION"
						@click="handleChange('DESCREPTION')" borderBottom>
						<u--input disabled disabledColor="#ffffff" v-model="model.DESCREPTION" 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="DESCREPTION" borderBottom>
						<u--input disabled disabledColor="#ffffff" v-model="model.DESCREPTION" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="问题等级" prop="QUESTION_LEVEL_SHOW" borderBottom>
						<u--input disabled disabledColor="#ffffff" v-model="model.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="model.DEMAND" placeholder="整改建议与措施"
							border="surround"></u--textarea>
					</u-form-item>
					<u-form-item label="系统整改期限" prop="LastDateSystem" borderBottom>
						<u--input disabledColor="#fff" v-model="model.LastDateSystem" border="none"
							inputAlign="right"></u--input><!-- :value="$u.timeFormat(model.LastDateSystem, 'yyyy-mm-dd')" -->
					</u-form-item>
					<u-form-item v-if="tableKey==1" label="整改期限" required prop="LastDateUser" borderBottom
						@click="showCheckDate(0)">
						<u--input disabled disabledColor="#fff" placeholder="请选择整改期限" border="none"
							v-model="model.LastDateUser" 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 @click="showCheckDate(0)">
						<u--input disabled disabledColor="#fff" placeholder="请选择整改期限" border="none"
							v-model="model.LastDateUser" inputAlign="right"></u--input>
					</u-form-item>

					<u-form-item label="隐患原因" v-if="tableKey==1" required prop="Nav_ListRiskQuestionReasonShow"
						@click="handleChange('Nav_ListRiskQuestionReason')" borderBottom>
						<u--input disabled disabledColor="#ffffff" v-model="model.Nav_ListRiskQuestionReasonShow"
							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 label="隐患原因" v-else prop="Nav_ListRiskQuestionReasonShow" borderBottom>
						<u--input disabled disabledColor="#ffffff" v-model="model.Nav_ListRiskQuestionReasonShow"
							border="none" inputAlign="right"></u--input>
					</u-form-item>
				</u--form>
			</uni-card>
		</view>

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

		<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"
				style="background-color: #f7f7f7;color: black;width: 43%;float: left; margin-right: 10px;"
				v-if='(isLoadOK && tableKey === "1")' @click="FullUpdateNewQuestion">新问题</button>
			<button type="primary" style="width: 43%; float: left;" 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,
		FullUpdateBS006,
		CheckProjectOrderPaged,
		CheckProjectCategoryOrderPaged,
		GetInfoAdapt,
		// CheckContentsOrderPaged,
		OrderPagedObjectMain,
		QuestionOrderPaged,
		GetDpartMentMasterInfo,
		FullUpdateNew
	} from '../../../../services/apply/subPages/BS/riskSubmit'

	import {
		orderPagedRiskReason,
		CheckTypeOrderPaged,
		CheckTypeLevelOrderPaged
	} from '../../../../services/apply/subPages/BS/safeCheck'

	import {
		data
	} from '../../../../uni_modules/uview-ui/libs/mixin/mixin'

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

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

	import wViewRequire from '@/components/custom/w-view-require.vue'
	export default {
		components: {
			wViewRequire
		},
		data() {
			return {
				tableKey: '0',
				TaskID: '',
				listPropUpload: ['RISK_SUBMIT_ID'],
				listPropValUpload: [],
				listPropSubUpload: ['RISK_SUBMIT_ID', 'RISK_SUBMIT_CONTENT_ID'],
				AUDIT_OPINION: '',
				model: {
					SUBMIT_STATUS: '',
					CHECKOBJECT: '',
					CHECKOBJECT_DESCRIPTION: '',
					isShowProj: true,
					isShowProjCate: true,
					Nav_Submit: {
						ID: '',
						TaskID: '',
						Nav_User: {
							NAME: ''
						},
						Nav_CheckType: {
							NAME: ''
						},
						Nav_CheckTypeLevel: {
							Nav_Enums: {
								NAME: ''
							}
						},
					},
					ID: '',
					CHECK_PROJECT_ID: '',
					CHECK_PROJECT_CATEGORY_ID: '',
					Nav_CheckProject: {
						NAME: ''
					},
					Nav_CheckProjectCategory: {
						NAME: ''
					},

					Nav_Department: {
						NAME: ''
					},
					Nav_DepartmentDeal: {
						NAME: ''
					},
					Nav_UserCheck: {
						NAME: ''
					},
					Nav_UserDeal: {
						NAME: ''
					},
					Nav_RiskArea: {
						NAME: ''
					},
					LastDateUser: null,
					departmentName: '',
					userChecker: '',
					userDetailer: '',
					listPropValSubUpload: [],
					Nav_Files: [],
					Nav_ListRiskQuestionReason: [],
					Nav_ListRiskQuestionReasonShow: ''
				},
				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: {
					showPopup: false,
					isMultiple: false,
					totalCount: 0,
					title: '人员选择',
					index: 0,
					dataLists: [],
					defaultText: '',
					defaultValue: '',
					name: ''
				},

				rules: {
					'Nav_Submit.Nav_CheckType.NAME': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change'],
						message: '检查类型不能为空'
					},
					'Nav_Submit.Nav_CheckTypeLevel.Nav_Enums.NAME': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change'],
						message: '检查层级不能为空'
					},
					'CHECKCONTENT': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change'],
						message: '检查内容不能为空'
					},
					'Nav_CheckProject.NAME': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change'],
						message: '检查项目不能为空'
					},
					'Nav_CheckProjectCategory.NAME': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change'],
						message: '检查项目分类不能为空'
					},
					'DESCREPTION': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change'],
						message: '检查问题不能为空'
					},
					'LastDateUser': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change'],
						message: '整改期限不能为空'
					},
					'Nav_ListRiskQuestionReasonShow': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change'],
						message: '隐患原因不能为空'
					},
					// 'Nav_DepartmentDeal.NAME': {
					// 	type: 'string',
					// 	required: true,
					// 	trigger: ['blur', 'change']
					// },
					// 'Nav_UserDeal.NAME': {
					// 	type: 'string',
					// 	required: true,
					// 	trigger: ['blur', 'change']
					// },
					// 'Nav_UserCheck.NAME': {
					// 	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() {
				if (this.model.LastDateUser == null) {
					this.model.LastDateUser = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd')
				}

				this.dateTimePickerInfo = {
					showCheckDate: true,
					// dataIndex: dataIndex,
					defaultDateTime: this.model.LastDateUser
				}
			},

			//隐藏控件 显示时间
			handleCheckDate(e) {
				let v = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
				const {
					name,
					dataIndex
				} = this.dateTimePickerInfo
				this.dateTimePickerInfo.showCheckDate = false
				this.model.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.modelEdit = JSON.parse(JSON.stringify(this.model))
					this.modelEdit.SUBMIT_STATUS = 20
					this.modelEdit.Nav_Submit.SUBMIT_STATUS = 20
					this.modelEdit.TaskID = this.TaskID

					this.modelEdit.ORG_ID = orgId
					this.modelEdit.Nav_Check = null
					this.modelEdit.Nav_Submit.Nav_CheckType = null
					this.modelEdit.Nav_Submit.Nav_User = null
					this.modelEdit.Nav_Submit.Nav_CheckTypeLevel = null
					this.modelEdit.Nav_UserCheck = null
					this.modelEdit.Nav_UserDeal = null
					this.modelEdit.Nav_User = null
					this.modelEdit.Nav_Department = null
					this.modelEdit.Nav_DepartmentDeal = null
					this.modelEdit.Nav_SafeCheckDetail = null
					this.modelEdit.Nav_CheckMain = null
					this.modelEdit.Nav_Question = null
					this.modelEdit.Nav_RiskArea = null
					this.modelEdit.RISK_SUBMIT_NOTICE_ID = null //重新触发通知
					this.modelEdit.Nav_CheckProject = null //重新触发通知
					this.modelEdit.Nav_CheckProjectCategory = null //重新触发通知

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

			//新问题
			FullUpdateNewQuestion() {
				var that = this
				uni.showModal({
					title: '提示',
					content: '确定新问题？',
					success: function(res) {
						if (res.confirm) {
							that.model.TaskID = that.TaskID
							that.model.SUBMIT_STATUS = 12
							FullUpdateNew(that.model).then(res => { //FullUpdateBS006
								uni.$showMsgFunc('操作成功!', () => {
									// if (this.tableKey == null || this.tableKey == 0) {
									// 	uni.navigateTo({
									// 		url: 'safeCheckIndex'
									// 	})
									// } else {
									uni.navigateBack()
									// }
								}, 'success', 1000)
							})
						}
					}
				})


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

				// 	this.modelEdit.ORG_ID = orgId
				// 	this.modelEdit.Nav_Check = null
				// 	this.modelEdit.Nav_Submit.Nav_CheckType = null
				// 	this.modelEdit.Nav_Submit.Nav_User = null
				// 	this.modelEdit.Nav_Submit.Nav_CheckTypeLevel = null
				// 	this.modelEdit.Nav_UserCheck = null
				// 	this.modelEdit.Nav_UserDeal = null
				// 	this.modelEdit.Nav_User = null
				// 	this.modelEdit.Nav_Department = null
				// 	this.modelEdit.Nav_DepartmentDeal = null
				// 	this.modelEdit.Nav_SafeCheckDetail = null
				// 	this.modelEdit.Nav_CheckMain = null
				// 	this.modelEdit.Nav_Question = null
				// 	this.modelEdit.Nav_RiskArea = null
				// 	this.modelEdit.RISK_SUBMIT_NOTICE_ID = null //重新触发通知
				// 	this.modelEdit.Nav_CheckProject = null //重新触发通知
				// 	this.modelEdit.Nav_CheckProjectCategory = null //重新触发通知

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

			loadData() {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId)
				extendRule(json, 'ID', 1, this.model.ID);
				extendInclude(json, "Nav_Submit.Nav_CheckType")
				extendInclude(json, "Nav_Submit.Nav_CheckTypeLevel.Nav_Enums")
				extendInclude(json, "Nav_Submit.Nav_User")
				extendInclude(json, "Nav_Submit")
				extendInclude(json, "Nav_Files.Nav_ImgFile")
				extendInclude(json, "Nav_CheckProject")
				extendInclude(json, "Nav_CheckProjectCategory")
				extendInclude(json, "Nav_RiskArea")
				extendInclude(json, "Nav_ListRiskQuestionReason.Nav_RiskReason")
				extendInclude(json, "Nav_ListRiskQuestionReason")
				extendInclude(json, "Nav_DepartmentDeal")
				extendInclude(json, "Nav_UserDeal")
				extendInclude(json, "Nav_UserCheck")
				GetInfoAdapt(json).then(res => {
					this.listPropValUpload.push(res.ID)

					if (res.Nav_Submit.Nav_CheckType == null) {
						res.Nav_Submit.Nav_CheckType = {
							NAME: ''
						}
					}
					if (res.Nav_Submit.Nav_CheckTypeLevel == null) {
						res.Nav_Submit.Nav_CheckTypeLevel = {
							Nav_Enums: {
								NAME: ''
							}
						}
					}
					if (res.Nav_DepartmentDeal == null) {
						res.Nav_DepartmentDeal = {
							NAME: ''
						}
					}
					if (res.Nav_UserDeal == null) {
						res.Nav_UserDeal = {
							NAME: ''
						}
					}
					if (res.Nav_UserCheck == null) {
						res.Nav_UserCheck = {
							NAME: ''
						}
					}
					if (res.Nav_CheckProject == null) {
						res.Nav_CheckProject = {
							NAME: ''
						}
					}
					if (res.Nav_CheckProjectCategory == null) {
						res.Nav_CheckProjectCategory = {
							NAME: ''
						}
					}
					this.model = res
					this.model.Nav_ListRiskQuestionReasonShow = ''
					if (res.Nav_ListRiskQuestionReason && res.Nav_ListRiskQuestionReason.length > 0) {
						res.Nav_ListRiskQuestionReason.forEach(e => {
							if (e.Nav_RiskReason != null) {
								this.model.Nav_ListRiskQuestionReasonShow += " " + e.Nav_RiskReason.NAME
							}
						})
					}
					this.isLoadOK = true
				})
			},

			//下拉数据加载
			async handleShowSheet(p) {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "", 0)
				let dataSelect = []
				if (p.name === 'CHECKOBJECT') {

					this.selectorInfo.isMultiple = false
					var dataParm = {
						'name': "BSMineTypeEnum"
					}
					dataSelect = await getEnum(dataParm).then(res => {
						if (res != undefined && res.length > 0) {
							for (let i = 0; i < res.length; i++) {
								res[i].name = res[i].NAME
								// res[i].code = res[i].ID
							}
						}
						return res
					})


					// // 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 == 'listCheckDetailReason') {
					this.model.Nav_ListRiskSubmitContent[dataIndex].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_ListRiskSubmitContent[dataIndex].ID;
					if (this.model.Nav_ListRiskSubmitContent[dataIndex].Nav_ListCheckDetailReason == undefined) {
						this.model.Nav_ListRiskSubmitContent[dataIndex].Nav_ListCheckDetailReason = []
						this.model.Nav_ListRiskSubmitContent[dataIndex].Nav_ListCheckDetailReason.push(selectReason)
					} else {
						this.model.Nav_ListRiskSubmitContent[dataIndex].Nav_ListCheckDetailReason[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
				} 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(name) {
				this.selectorInfo.isMultiple = false
				if (name == 'depDeal') {
					this.selectorInfo.title = '整改实施单位选择'
				} else if (name == 'project') {
					this.selectorInfo.title = '检查项目'
				} else if (name == 'projectCate') {
					this.selectorInfo.title = '检查项目分类'
				} else if (name == 'checkType') {
					this.selectorInfo.title = '检查类型'
				} else if (name == 'checkTypeLevel') {
					this.selectorInfo.title = '检查层级'
				} else if (name == 'CHECKCONTENT') {
					this.selectorInfo.title = '检查内容'
				} else if (name == 'DESCREPTION') {
					this.selectorInfo.title = '检查问题'
				} else if (name == 'Nav_ListRiskQuestionReason') {
					this.selectorInfo.title = '隐患原因'
					this.selectorInfo.isMultiple = true
				} else if (name == 'CHECKOBJECT') {
					this.selectorInfo.title = '检查范围'
				} else {
					this.selectorInfo.title = '人员选择'
				}

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

			//数据加载
			handleSearch(val) {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "NAME")
				if (val) {
					if (this.selectorInfo.name == 'checkTypeLevel') {
						extendRule(json, 'Nav_Enums.NAME', 9, val);
					} else if (this.selectorInfo.name == 'CHECKCONTENT') {
						extendRule(json, 'CHECKCONTENT', 9, val);
					} else if (this.selectorInfo.name == 'DESCREPTION') {
						extendRule(json, 'DEMAND', 9, val);
					} else {
						extendRule(json, 'NAME', 9, val);
					}
				}

				if (this.selectorInfo.name == 'depDeal') {
					GetDpartMentMasterInfo(json).then(res => {
						this.selectorInfo.dataLists = res.map(i => {
							return {
								...i,
								name: i.NAME,
								code: i.CODE
							}
						})
					})
				} else if (this.selectorInfo.name == 'project') {
					CheckProjectOrderPaged(json).then(res => {
						this.selectorInfo.dataLists = res.map(i => {
							return {
								...i,
								name: i.NAME,
								code: i.CODE
							}
						})
					})
				} else if (this.selectorInfo.name == 'projectCate') {
					// extendRule(json, 'RISK_SUBMIT_ID', 1, this.model.ID);
					if (this.model.Nav_Submit.CHECK_TYPE_ID == null || this.model.Nav_Submit.CHECK_TYPE_ID == '') {
						uni.$showErrorInfo('请先选择检查类型！')
						this.selectorInfo.showPopup = false
						return;
					}
					extendRule(json, 'Nav_ListCategoryType.CHECK_TYPE_ID', 1, this.model.Nav_Submit.CHECK_TYPE_ID);
					CheckProjectCategoryOrderPaged(json).then(res => {
						this.selectorInfo.dataLists = res.map(i => {
							return {
								...i,
								name: i.NAME,
								code: i.CODE
							}
						})
					})

				} else if (this.selectorInfo.name == 'checkType') {
					if (this.model.CHECKOBJECT != undefined) {
						json.Parameter1 = this.model.CHECKOBJECT
					}
					CheckTypeOrderPaged(json).then(res => {
						this.selectorInfo.dataLists = res.map(i => {
							return {
								...i,
								name: i.NAME,
								code: i.CODE
							}
						})
					})
				} else if (this.selectorInfo.name == 'checkTypeLevel') {
					json.Sort = ''
					extendRule(json, 'CHECK_TYPE_ID', 1, this.model.Nav_Submit.CHECK_TYPE_ID);
					json.Include = ['Nav_Enums']
					CheckTypeLevelOrderPaged(json).then(res => {
						this.selectorInfo.dataLists = res.map(i => {
							return {
								...i,
								name: i.Nav_Enums.NAME
							}
						})
					})
				} else if (this.selectorInfo.name == 'CHECKCONTENT') {
					json.Sort = 'CHECKCONTENT'
					extendRule(json, 'CHECK_TYPE_LEVEL_ID', 1, this.model.Nav_Submit.CHECK_TYPE_LEVEL_ID);
					extendRule(json, 'CHECK_TYPE_ID', 1, this.model.Nav_Submit.CHECK_TYPE_ID);
					extendRule(json, 'RISK_AREA_ID', 1, this.model.RISK_AREA_ID);
					extendRule(json, 'CHECKOBJECT', 1, this.model.CHECKOBJECT);
					OrderPagedObjectMain(json).then(res => { //CheckContentsOrderPaged
						this.selectorInfo.dataLists = res.map(i => {
							return {
								...i,
								name: i.CHECKCONTENT,
							}
						})
					})
				} else if (this.selectorInfo.name == 'DESCREPTION') {
					json.Sort = 'DESCREPTION'

					extendRule(json, 'CHECK_PROJECT_CATEGORY_ID', 1, this.model.CHECK_PROJECT_CATEGORY_ID);
					extendRule(json, 'CHECK_PROJECT_ID', 1, this.model.CHECK_PROJECT_ID);
					extendRule(json, 'CHECKOBJECT', 1, this.model.CHECKOBJECT);
					extendRule(json, 'RISK_AREA_ID', 1, this.model.RISK_AREA_ID);
					extendRule(json, 'CHECK_TYPE_ID', 1, this.model.Nav_Submit.CHECK_TYPE_ID);
					extendRule(json, 'CHECK_TYPE_LEVEL_ID', 1, this.model.Nav_Submit.CHECK_TYPE_LEVEL_ID);
					extendRule(json, 'CHECK_CONTENTS_ID', 1, this.model.CHECK_CONTENTS_ID);

					QuestionOrderPaged(json).then(res => {
						this.selectorInfo.dataLists = res.map(i => {
							return {
								...i,
								name: i.DESCREPTION,
								code: i.CODE
							}
						})
					})
				} else if (this.selectorInfo.name == 'Nav_ListRiskQuestionReason') {
					orderPagedRiskReason(json).then(res => {
						this.selectorInfo.dataLists = res.map(i => {
							return {
								...i,
								name: i.NAME
								// code: i.CODE
							}
						})
					})
				} else if (this.selectorInfo.name == 'CHECKOBJECT') {
					var dataParm = {
						'name': "BSMineTypeEnum"
					}
					getEnum(dataParm).then(res => {
						this.selectorInfo.dataLists = res.map(i => {
							return {
								...i,
								name: i.NAME
								// code: i.CODE
							}
						})
					})

				} else if (this.selectorInfo.name == 'usercheck') {
					json.PageIndex = pageIndex ?? 1
					json.Limit = 20
					json.Sort = 'NAME'
					if (pageIndex) {
						json.Start = (pageIndex - 1) * json.Limit;
					}

					UserPagedAll(json).then(res => {
						this.selectorInfo.totalCount = res.TotalCount
						// if (res.IsSuccessful) {
						this.selectorInfo.dataLists = res.Data.map(i => {
							return {
								...i,
								name: i.NAME,
								code: i.CODE
							}
						})
						// }
					})
				} else {
					json.PageIndex = pageIndex ?? 1
					json.Limit = 20
					json.Sort = 'NAME'
					if (pageIndex) {
						json.Start = (pageIndex - 1) * json.Limit;
					}
					UserPagedLimit(json).then(res => {
						this.selectorInfo.totalCount = res.TotalCount
						if (res.IsSuccessful) {
							this.selectorInfo.dataLists = res.Data.map(i => {
								return {
									...i,
									name: i.NAME,
									code: i.CODE
								}
							})
						}
					})
				}
			},

			//选择信息
			handleSelected(e) {
				this.selectorInfo.showPopup = false
				if (this.selectorInfo.name === 'usercheck') {
					this.model.Nav_UserCheck = e
					this.model.userChecker = e.NAME
					this.model.CHECK_USER_ID = e.ID
				} else if (this.selectorInfo.name === 'userDetailer') {
					this.model.Nav_UserDeal = e
					this.model.userDetailer = e.NAME
					this.model.DEAL_USER_ID = e.ID
				} else if (this.selectorInfo.name === 'depDeal') {
					this.model.DEAL_DEPARTMENT_ID = e.ID
					this.model.Nav_DepartmentDeal = e
					this.model.departmentName = e.NAME
					if (e.Nav_User != null) {
						this.model.DEAL_USER_ID = e.Nav_User.ID
						this.model.Nav_UserDeal = e.Nav_User
					} else {
						this.model.DEAL_USER_ID = ''
						this.model.Nav_UserDeal = {}
					}
					if (e.Nav_Parent != null && e.Nav_Parent.Nav_User != null) {
						this.model.CHECK_USER_ID = e.Nav_Parent.Nav_User.ID
						this.model.Nav_UserCheck = e.Nav_Parent.Nav_User
					} else {
						this.model.CHECK_USER_ID = ''
						this.model.Nav_UserCheck = {}
					}
				} else if (this.selectorInfo.name === 'project') {
					this.model.Nav_CheckProject = e
					this.model.CHECK_PROJECT_ID = e.ID
				} else if (this.selectorInfo.name === 'projectCate') {
					this.model.Nav_CheckProjectCategory = e
					this.model.CHECK_PROJECT_CATEGORY_ID = e.ID
				} else if (this.selectorInfo.name === 'checkType') {
					this.model.Nav_Submit.Nav_CheckType = e
					this.model.Nav_Submit.CHECK_TYPE_ID = e.ID
				} else if (this.selectorInfo.name === 'checkTypeLevel') {
					this.model.Nav_Submit.Nav_CheckTypeLevel = e
					this.model.Nav_Submit.CHECK_TYPE_LEVEL_ID = e.ID
				} else if (this.selectorInfo.name === 'CHECKCONTENT') {
					this.model.CHECK_CONTENTS_ID = e.CHECK_CONTENTS_ID
					this.model.CHECKCONTENT = e.CHECKCONTENT
					this.model.CHECK_PROJECT_ID = e.CHECK_PROJECT_ID
					this.model.Nav_CheckProject = e.Nav_CheckProject
					this.model.CHECK_PROJECT_CATEGORY_ID = e.CHECK_PROJECT_CATEGORY_ID
					this.model.Nav_CheckProjectCategory = e.Nav_CheckProjectCategory
				} else if (this.selectorInfo.name === 'DESCREPTION') {
					this.model.CHECK_QUESTION_ID = e.ID
					this.model.DESCREPTION = e.DESCREPTION
					this.model.DEMAND = e.DEMAND
					this.model.LastDateSystem = e.LastDateSystem.split(' ')[0]
					this.model.QUESTION_LEVEL = e.QUESTION_LEVEL
					this.model.QUESTION_LEVEL_SHOW = e.QUESTION_LEVEL_SHOW
					// this.model.Nav_CheckQuestion.DESCREPTION = e.DESCREPTION
					this.model.CHECK_MAIN_ID = e.Nav_Main.ID

				} else if (this.selectorInfo.name === 'Nav_ListRiskQuestionReason') {
					this.model.Nav_ListRiskQuestionReasonShow = ''
					e.forEach(item => {
						this.model.Nav_ListRiskQuestionReasonShow += " " + item.NAME
						this.model.Nav_ListRiskQuestionReason.push({
							RISK_SUBMIT_CONTENT_ID: this.model.ID,
							RISK_REASON_ID: item.ID,
							ORG_ID: item.ORG_ID
						})
					})
				} else if (this.selectorInfo.name === 'CHECKOBJECT') {
					this.model.CHECKOBJECT_DESCRIPTION = e.NAME
					this.model.CHECKOBJECT = e.ID
				}
			}
		},
		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>