<template>
	<view class="page-wrap" v-bind:style="{paddingBottom:paddingBottom+'px'}">
		<view class="background"></view>
		<view class="card">
			<!-- <uni-card margin="0" :is-shadow="true"> -->
			<u--form labelPosition="left" labelWidth="auto" labelAlign="center" :model="model" class="demo-ruleForm">
				<view style="position: relative;">
					<view style="position: absolute;left: -10px;color: #3d4b70;top: -3px;">*</view>
				</view>

				<view style="font-size: 15px; font-weight: bold;color: #3d4b70;margin-bottom: 10px;">基本信息</view>

				<u-form-item label="项目名称：" prop="Nav_Project.NAME" borderBottom>
					<u--input v-if="model.Nav_Project" v-model="model.Nav_Project.NAME" border="none" inputAlign="right" disabled disabledColor="#ffffff" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="外包单位名称：" prop="Nav_Project.UNIT_NAME" borderBottom>
					<u--input v-if="model.Nav_Project" v-model="model.Nav_Project.UNIT_NAME" border="none" inputAlign="right" disabled disabledColor="#ffffff" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="作业类别：" prop="Nav_Type.NAME" borderBottom>
					<u--input v-if="model.Nav_Type" v-model="model.Nav_Type.NAME" border="none" inputAlign="right" disabled disabledColor="#ffffff" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="危险作业名称：" prop="DANGEROUS_JOB_NAME" borderBottom>
					<u--input autoHeight v-model="model.DANGEROUS_JOB_NAME" border="none" inputAlign="right" disabled disabledColor="#ffffff" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="危险作业具体事项：" prop="DANGEROUS_JOB_ITEM" borderBottom>
					<u--input autoHeight v-model="model.DANGEROUS_JOB_ITEM" border="none" inputAlign="right" disabled disabledColor="#ffffff" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="作业风险辨识：" prop="JOB_RISK_IDENTIFY" borderBottom>
					<u--input autoHeight v-model="model.JOB_RISK_IDENTIFY" border="none" inputAlign="right" disabled disabledColor="#ffffff" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="作业开始时间：" prop="START_TIME" borderBottom>
					<u--input autoHeight v-model="model.START_TIME" border="none" inputAlign="right" disabled disabledColor="#ffffff" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="作业结束时间：" prop="END_TIME" borderBottom>
					<u--input autoHeight v-model="model.END_TIME" border="none" inputAlign="right" disabled disabledColor="#ffffff" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="作业地点：" prop="JOB_ADDRESS" borderBottom>
					<u--input autoHeight v-model="model.JOB_ADDRESS" border="none" inputAlign="right" disabled disabledColor="#ffffff" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="作业人员:" >
				</u-form-item>
				<u-textarea v-model="model.UsersName" disabled autoHeight ></u-textarea>

				<u-form-item label="现场监护人：" prop="Nav_User.NAME" borderBottom>
					<u--input v-if="model.Nav_User" v-model="model.Nav_User.NAME" border="none" inputAlign="right" disabled disabledColor="#ffffff" fontSize="14px"></u--input>
				</u-form-item>
				<view class="upload-title">附件:</view>
				<full-upload v-model="model.Nav_DisCloseFiles" :listProp='listPropUpload' :listPropVal='listPropValUpload' :isShowBtn="false"></full-upload>
			</u--form>
			<u--form labelPosition="left" labelWidth="auto" labelAlign="center" errorType="border-bottom" ref="sForm" class="sub-form" style="margin-top: 10px;">
				<view style="position: relative;">
					<view style="position: absolute;left: -10px;color: #3d4b70;top: -3px;">*</view>
				</view>

				<view style="font-size: 15px; font-weight: bold;color: #3d4b70;margin-bottom: 10px;">配置信息</view>

				<uni-collapse :border="false" accordion>
					<view v-for="(item, index) in model.Nav_MointerRecordDetails" :key="index">
						<uni-collapse-item title-border="none" :border="false">
							<template v-slot:title>
								<view class="uni-collapse-item__title-box">
									<view class="uni-collapse-item__title-text">
										{{index+1+'.'+item.Nav_MointerDepartment.NAME+'-'+item.Nav_MointerUser.NAME}}
									</view>

								</view>
							</template>
							<view class="content" style="margin: 0px 10px;">
								<u-form-item label="开始时间" borderBottom>
									<u--input disabledColor="#fff" disabled v-model="item.START_TIME" border="none" inputAlign="right" fontSize="14px"></u--input>

								</u-form-item>
								<u-form-item label="结束时间" borderBottom>
									<u--input disabledColor="#fff" disabled v-model="item.END_TIME" border="none" inputAlign="right" fontSize="14px"></u--input>

								</u-form-item>
								<u-form-item label="监查部门:" borderBottom>
									<u--input disabledColor="#fff" disabled v-model="item.Nav_MointerDepartment.NAME" border="none" inputAlign="right" fontSize="14px"></u--input>

								</u-form-item>
								<u-form-item label="监查人:" borderBottom>
									<u--input disabledColor="#fff" disabled v-model="item.Nav_MointerUser.NAME" border="none" inputAlign="right" fontSize="14px"></u--input>

								</u-form-item>
								<u-form-item label="监查情况说明" borderBottom>
									<u--input disabledColor="#fff" disabled v-model="item.REMARK" border="none" inputAlign="right" fontSize="14px"></u--input>
								</u-form-item>
								<view class="upload-title">监查照片</view>
								<full-upload v-model="item.Nav_Files" :isShowBtn='false' :listProp='listPropUpload' :listPropVal='listPropValUpload'></full-upload>

							</view>


						</uni-collapse-item>
						<!-- <u-collapse-item :title="item.ROW_NUM + '. ' + item.MEASURE+' - '+transLevel(item.ISORNOT)+' - '+item.REMARK">
						</u-collapse-item> -->
					</view>
				</uni-collapse>
			</u--form>
			<!-- <check-action v-if="isLoadOK&&tableKey==1&&isAudit" :okApi="okApi" :refuseApi="refuseApi" :dataSource="auditModel"></check-action> -->
		</view>
		<view class="bottom-button" style="padding: 10px 16px;" v-if="isLoadOK&&(tableKey==1||tableKey==4)&&this.isSign">
			<u-button type="primary" @click="onTableBtnAgree" color="#3d4b70">审阅</u-button>
		</view>

	</view>
</template>

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

	import {
		WBRecordSign,
		GetDangerousJob
	} from '../../../../services/apply/subPages/scWB';
	import '../../../../utils/showMsg.js'
	import color from '../../../../uni_modules/uview-ui/libs/config/color'
	import config from '../../../../config/common'

	export default {
		data() {
			return {
				model: {},
				listPropUpload: ['PARENT_ID'],
				listPropValUpload: [],
				paddingBottom: '150',
				TaskID: "",
				tableKey: '0',
				isLoadOK: false,
				isSign: true,
				isAudit: true,
				DEALOPINION: "",
				ORG_ID: uni.getStorageSync('orgId'),
			}
		},
		onLoad(option) {
			this.model.ID = option.ID;
			this.TaskID = option.taskID;
			this.tableKey = option.tableKey ? option.tableKey : '0'
			this.okApi = option.okApi
			this.refuseApi = option.refuseApi
			this.auditModel = {
				...this.$store.state.auditModel,
				TaskID: option.taskID ? option.taskID : ''
			}
			this.loadData()
		},
		methods: {
			transLevel(level) {
				if (level == 0) {
					return '否';
				}
				if (level == 1) {
					return '是 ';
				}
			},
			loadData() {
				const json = initFilter(this.ORG_ID)
				extendRule(json, 'ID', 1, this.model.ID);
				extendInclude(json, 'Nav_Project')
				extendInclude(json, 'Nav_Type')
				extendInclude(json, 'Nav_User')
				extendInclude(json, 'Nav_Users')
				extendInclude(json, 'Nav_Users.Nav_User')
				extendInclude(json, 'Nav_DisCloseUsers.Nav_User')
				extendInclude(json, 'Nav_MointerRecordDetails.Nav_Files.Nav_ImgFile')
				extendInclude(json, 'Nav_MointerRecordDetails.Nav_MointerDepartment')
				extendInclude(json, 'Nav_MointerRecordDetails.Nav_MointerUser')
				extendInclude(json, 'Nav_DisCloseFiles.Nav_ImgFile')
				json.IgnoreDataRule = true;
				GetDangerousJob(json).then(res => {
					this.model = res
					let UsersName = ''
					if (this.model.Nav_Users&&this.model.Nav_Users.length > 0) {
						this.model.Nav_Users.forEach((item, i) => {
							if (item.Nav_User.NAME != null) {
								if (i > 0) {
									UsersName += ' '
								}
								UsersName += item.Nav_User.NAME
							}
						})
					}
					this.model.UsersName = UsersName

					// if (this.model.STATUS == 30) {
					// 	this.isSign = true;
					// 	this.isAudit = false;
					// } else if (this.model.STATUS == 20) {
					// 	this.isSign = false;
					// 	this.isAudit = true;
					// }
					this.isLoadOK = true
				})
			},
			onTableBtnAgree() {
				const json = initFilter(this.ORG_ID)
				json.Parameter1 = this.model.ID;
				json.Parameter2 = this.TaskID;
				json.Parameter3 = uni.getStorageSync('appInfo')?.User?.ID || ''
				WBRecordSign(json).then(res => {
					if (res) {
						uni.$showMsgFunc('操作成功!', () => {
							uni.navigateBack()
						}, 'success', 1000)
					}
				})
			},

		}
	}
</script>

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