<!-- 检查库查看 -->
<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">

					<u-form-item label="检查范围" prop="CHECKOBJECT_DESCRIPTION" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.CHECKOBJECT_DESCRIPTION" border="none"
							slot="right" inputAlign="right"></u--input>
					</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="Nav_RiskArea.NAME" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.Nav_RiskArea.NAME" border="none"
							slot="right" inputAlign="right"></u--input>
					</u-form-item>

					<u-form-item label="检查项目" prop="Nav_CheckProject.NAME" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.Nav_CheckProject.NAME" border="none"
							slot="right" inputAlign="right"></u--input>
					</u-form-item>
					<view class="label-title">检查项目分类</view>
					<u-form-item prop="Nav_CheckProjectCategory.NAME" borderBottom>
						<u--textarea disabled autoHeight v-model="model.Nav_CheckProjectCategory.NAME"
							placeholder="请输入检查内容" border="surround"></u--textarea>
					</u-form-item>

					<view class="label-title">检查内容</view>
					<u-form-item prop="CHECKCONTENT" borderBottom>
						<u--textarea disabled autoHeight v-model="model.CHECKCONTENT" placeholder="请输入检查内容"
							border="surround"></u--textarea>
					</u-form-item>
					<!-- <view class="label-title">检查依据</view>
					<u-form-item prop="CHECKPROOF" borderBottom>
						<u--textarea disabled autoHeight v-model="model.CHECKPROOF" placeholder="请输入检查内容"
							border="surround"></u--textarea>
					</u-form-item> -->

					<view class="label-title">检查问题描述</view>
					<u-form-item prop="Nav_CheckQuestion.DESCREPTION" borderBottom>
						<u--textarea disabled autoHeight v-model="model.Nav_CheckQuestion.DESCREPTION"
							placeholder="请输入检查内容" border="surround"></u--textarea>
					</u-form-item>

					<view class="label-title">整改建议与措施</view>
					<u-form-item prop="Nav_CheckQuestion.DEMAND" borderBottom>
						<u--textarea disabled autoHeight v-model="model.Nav_CheckQuestion.DEMAND" placeholder="请输入检查内容"
							border="surround"></u--textarea>
					</u-form-item>

					<u-form-item label="问题等级" prop="QUESTION_LEVE_DESCRIPTION" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.QUESTION_LEVE_DESCRIPTION" border="none"
							slot="right" inputAlign="right"></u--input>
					</u-form-item>

					<u-form-item label="是否重大隐患" prop="SERIOUS_RISK_DESCRIPTION" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.SERIOUS_RISK_DESCRIPTION" border="none"
							slot="right" inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="责任部门" prop="departments" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.departments" border="none" slot="right"
							inputAlign="right"></u--input>
					</u-form-item>

				</u--form>
			</uni-card>
		</view>
	</view>
</template>

<script>
	import {
		initFilter,
		extendRule,
		extendInclude
	} from '../../../../utils/common'

	// import {
	// 	GetUserCheckInfoBS034,
	// 	FullCheckUpdateBS034
	// } from '../../../../services/apply/subPages/BS/safeCheck'
	// import '@/utils/showMsg.js'

	import {
		Get
	} from '../../../../services/apply/subPages/BS/lib'


	export default {
		data() {
			return {
				tableKey: '0',
				TaskID: '',
				model: {
					ID: '',
					TaskID: '',
					Nav_Files: [],
					Nav_CheckType: {
						NAME: ''
					},
					departments: '',
					Nav_CheckTypeLevel: {
						Nav_Enums: {
							NAME: ''
						}
					},

					Nav_ListCheckRiskArea: [{
						Nav_RiskArea: {
							NAME: ''
						}
					}],
					Nav_ListCheckProjectCategory: [{
						Nav_CheckProjectCategory: {
							NAME: ''
						}
					}],
					Nav_CheckQuestion: {
						DESCREPTION: '',
						DEMAND: ''
					},
					// Nav_ListSafeCheckDetail: {
					// 	ID: '',
					// 	SAFE_CHECK_ID: '',
					// 	Nav_Files: [],
					// 	Nav_CheckArea: {
					// 		NAME: ''
					// 	},
					// 	Nav_CheckProject: {
					// 		NAME: ''
					// 	},
					// 	checkerNames: '',
					// 	CHECKCONTENT: '',
					// 	CHECKRESULT_DESCRIPTION: '',
					// 	QUESTION_LEVEL_DESCRIPTION: '',
					// 	DEMAND: '',
					// 	ADDRESS: '',
					// 	Nav_ListCheckDetailUser: [{
					// 		NAME: '',
					// 		ISSAMEMAINCHECKOK: Boolean,
					// 		ISCHECK: Boolean
					// 	}]

					// } //子表
				},
				isLoadOK: false,
				lists: [],
				comPickerInfo: {
					showSheet: false,
					columns: [],
					title: '',
					dataIndex: undefined,
					formIndex: undefined,
					name: ''
				},
				showCheckDate: false,
				showPopup: false,

				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()
		},

		//页面加载 退回 反过来 都要加载信息
		onShow() {
			this.loadData()
		},
		methods: {
			handleTab(t) {
				this.currentTab = t
			},
			loadData() {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId)
				extendRule(json, 'ID', 1, this.model.ID);

				extendInclude(json, "Nav_CheckProject")
				extendInclude(json, "Nav_CheckProjectCategory")
				extendInclude(json, "Nav_CheckQuestion")
				extendInclude(json, "Nav_CheckType")
				extendInclude(json, "Nav_CheckTypeLevel.Nav_Enums")
				extendInclude(json, "Nav_RiskArea")
				extendInclude(json, "Nav_ListMainDep.Nav_Department")

				// 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_Files.Nav_ImgFile.Nav_File");
				json.IgnoreDataRule = true

				Get(json).then(res => {

					// this.model.RiskAreaNAME = strRiskAreaNAME
					// this.model.CheckProjectCategoryNAME = CheckProjectCategoryNAME

					if (res.Nav_CheckQuestion == null) {
						res.Nav_CheckQuestion = {
							DESCREPTION: '',
							DEMAND: ''
						}
					}
					
					this.model = res
					this.model.departments = ''
					if (res.Nav_ListMainDep != null && res.Nav_ListMainDep.length > 0) {
						res.Nav_ListMainDep.forEach(e => {
							if (e.Nav_Department != null && e.Nav_Department.NAME != null) {
								this.model.departments += (' ' + e.Nav_Department.NAME)
							}
						})
					}

					this.isLoadOK = true
				})
			},

			// FullCheckUpdate() {
			// 	const ele = this.$refs
			// 	ele['wForm'].validate().then(res => {
			// 		const orgId = uni.getStorageSync('orgId')
			// 		this.model.TaskID = this.TaskID
			// 		this.model.Nav_ListSafeCheckDetail[0].Nav_ListCheckDetailUser[0].SAFECHECKSTATE = 80
			// 		FullCheckUpdateBS034(this.model).then(res => {
			// 			uni.$showMsgFunc('操作成功!', () => {
			// 				if (this.tableKey == null || this.tableKey == 0) {
			// 					uni.navigateTo({
			// 						url: 'safeCheckIndex'
			// 					})
			// 				} else {
			// 					uni.navigateBack()
			// 				}
			// 			}, 'success', 1000)
			// 			// if (res) {
			// 			//   message.success('提交成功', 2000)
			// 			// }
			// 		})
			// 	}).catch(err => {
			// 		console.log('校验失败', err)
			// 	})
			// },

			// //确认
			// subCheckOK(detail) {
			// 	if (detail.Nav_ListCheckDetailUser.length > 0) {
			// 		detail.Nav_ListCheckDetailUser[0].ISCHECK = true;
			// 		detail.Nav_ListCheckDetailUser[0].ISSAMEMAINCHECKOK = true;
			// 	}
			// },
			// handleCheck() {
			// 	this.model.Nav_ListSafeCheckDetail.forEach(item => {

			// 		if (item.Nav_ListCheckDetailQuestion != null && item.Nav_ListCheckDetailQuestion.length > 0) {
			// 			for (let j = 0; j < item.Nav_ListCheckDetailQuestion.length; j++) {
			// 				if (item.Nav_ListCheckDetailQuestion[j].IS_DELETED != undefined && item
			// 					.Nav_ListCheckDetailQuestion[j].IS_DELETED != null && !item
			// 					.Nav_ListCheckDetailQuestion[j].IS_DELETED) {
			// 					if (item.Nav_ListCheckDetailQuestion[j].Nav_Question?.ID.indexOf(
			// 							"5555-555555555555") > 0) {
			// 						item.Nav_ListCheckDetailUser[0].ISCHECK = true
			// 						item.Nav_ListCheckDetailUser[0].ISSAMEMAINCHECKOK = true
			// 						break
			// 					}
			// 				}
			// 			}
			// 		}

			// 	})
			// },
			// //退回
			// handleback(detail) {
			// 	uni.navigateTo({
			// 		url: 'safeCheckCheckBackInfo?ID=' + detail.ID + '&SAFE_CHECK_ID=' + detail.SAFE_CHECK_ID
			// 	})
			// }
		},
		computed: {

		}
	}
</script>


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