<template>
	<view class="todo-page">
		<step-title :stepPage="stepsPage" :stepText="stepsText"></step-title>
		<view class="allview">
			<view class="card">
				<u--form labelWidth="auto" :model="dataModel" ref="wForm" 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="Product_Unit">
						<u--input v-model="dataModel.CREATE_TIME" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>

					</u-form-item>
					<u-form-item label="发起部门：" prop="Product_Unit">
						<u--input v-model="dataModel.Nav_ApplyDepartment.NAME" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>

					</u-form-item>
					<u-form-item label="发起人员：" prop="Product_Unit">
						<u--input v-model="dataModel.Nav_ApplyUser.NAME" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>

					</u-form-item>
					<u-form-item label="辨识年度：" prop="YEAR">
						<u--input v-model="dataModel.YEAR" disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>
					</u-form-item>
					<u-form-item label="开始时间">
						<u--input v-model="dataModel.START_DATE" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<u-form-item label="结束时间">
						<u--input v-model="dataModel.END_DATE" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<u-form-item label="辨识要求">
					</u-form-item>
					<u--textarea v-model="dataModel.Nav_Require.NAME" disabled autoHeight></u--textarea>
					<view class="upload-title">附件：</view>
					<full-upload v-model="dataModel.Nav_Files" :isShowBtn='false' :listProp='listPropUpload' :listPropVal='listPropValUpload'></full-upload>
					<view style="margin-top: 20px;">
						<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>
						<view v-for="(item,index) in dataModel.Nav_Details" :key="index" style="border-bottom: #ceccca 1px solid;margin-bottom: 10px;padding-bottom: 10px;">
							<u-form-item prop="Nav_Contents">

								<view style="display: flex;flex-direction: row;justify-content: space-between;align-items: center;flex: 1;">
									<view style="flex: 1;">
										{{index+1+'.辨识区域：'+item.Nav_Area.NAME}}
									</view>
									<view class="action" style="display: flex;flex-direction: row;align-items: center;justify-content: space-around;">
										<u-icon name="arrow-up" size="12" v-if="item.showPack" @click="handlePack(index)"></u-icon>
										<u-icon name="arrow-down" size="12" v-if="!item.showPack" @click="handlePack(index)"></u-icon>
									</view>
								</view>
							</u-form-item>
							<view v-if="item.showPack==true">
								<u-form-item label="生产单元：" border-bottom>
									<u--input v-model="item.MineType" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
									</u--input>
								</u-form-item>
								<u-form-item label="风险名称" prop="CHECKSTANDARD" border-bottom>
									<u--input v-model="item.RISK_NAME" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
									</u--input>
								</u-form-item>
								<u-form-item label="风险描述" prop="HIDDEN_DESCRIPTION" border-bottom>
									<u--input v-model="item.RISK_DESCRIPTION" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
									</u--input>
								</u-form-item>
								<u-form-item label="风险类别" prop="HIDDEN_LEVEL" border-bottom>
									<u--input v-model="item.Nav_Type.NAME" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
									</u--input>
								</u-form-item>
								<u-form-item label="辨识层级" prop="HIDDEN_PLACE" border-bottom>
									<u--input v-model="item.DEPARTMENT_TYPE" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
									</u--input>
								</u-form-item>
								<u-form-item label="辨识部门" prop="HIDDEN_PLACE" border-bottom>
									<u--input v-model="item.IDENTIFY_DEPARTMENT" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
									</u--input>
								</u-form-item>
								<u-form-item label="辨识岗位" prop="HIDDEN_PLACE" border-bottom>
									<u--input v-model="item.IDENTIFY_POST" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
									</u--input>
								</u-form-item>
								<u-form-item label="管控措施" prop="HIDDEN_PLACE" border-bottom>
								</u-form-item>
								<u--textarea v-model="item.MEASURE" disabled placeholder="请填写管控措施" autoHeight maxlength="-1"></u--textarea>
								<u-form-item label="应急处置" prop="HIDDEN_PLACE" border-bottom>
								</u-form-item>
								<u--textarea v-model="item.EMERGENCY" disabled  autoHeight maxlength="-1"></u--textarea>
								<u-form-item label="状态" prop="HIDDEN_PLACE">
									<u--input v-model="item.ENABLE_STATUS" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
									</u--input>
								</u-form-item>
							</view>
						</view>
					</view>

				</u--form>

			</view>
			<check-action v-if="isLoadOK && tableKey === '1'&&isAudit==='true' " :okApi="okApi" :refuseApi="refuseApi" :dataSource="$store.state.auditModel"></check-action>
			<!-- <view style="padding: 10px 16px;display: flex;flex-direction: row;" class="bottom-button" v-if="isLoadOK&&tableKey==='1'&&!isAudit">
				<u-button type="primary" @click="submit" color="#3d4b70">确认</u-button>
			</view> -->
		</view>
	</view>
</template>

<script>
	import {
		extendInclude,
		extendRule,
		extendIgnoreDataRule,
		initFilter,
	} from '../../../../utils/common'
	import {
		MineTypeName
	} from '../../../../utils/enums.js'
	import {
		EvaIdentifyResGet,
	} from '../../../../services/apply/subPages/SK/SKServices.js'
	import stepTitle from '@/components/custom/step-title.vue'
	export default {
		components: {
			stepTitle,
		},
		data() {
			return {
				isAudit: false,
				isLoadOK: false,
				tableKey: 0,
				listPropUpload: ['NOTIFY_ID'],
				listPropValUpload: [],
				ORG_ID: uni.getStorageSync('orgId'),
				stepLoad: true,
				dataModel: {
					Nav_ApplyDepartment: {
						NAME: '',
					},
					Nav_ApplyUser: {
						NAME: ''
					},
					CREATE_TIME: '',
					YEAR: '',
					START_DATE: '',
					END_DATE: '',
					CONTENTS: '',
					Nav_Require: {
						NAME: ''
					},
					RequireName: '',
					Nav_Files: [],
					Nav_Details: [{
						showPack: false,
						MineType: '',
						Nav_Area: {
							NAME: ''
						},
						RISK_NAME: '',
						Nav_RiskName: {
							NAME: ''
						},
						RISK_DESCRIPTION: '',
						Nav_Type: {
							NAME: ''
						},
						DEPARTMENT_TYPE: '',
						IDENTIFY_DEPARTMENT: '',
						IDENTIFY_POST: '',
						MEASURE: '',
						EMERGENCY: '',
						ENABLE_STATUS: '',
					}]
				},
				model: {
					ORG_ID: '',
					YEAR: '',
					START_DATE: '',
					END_DATE: '',
					CONTENTS: '',
					Nav_Require: {
						NAME: ''
					},
					RequireName: '',
					Nav_Files: [],
					Nav_Details: [{
						MineType: '',
						Nav_Area: {
							NAME: ''
						},
						RISK_NAME: '',
						Nav_RiskName: {
							NAME: ''
						},
						RISK_DESCRIPTION: '',
						Nav_Type: {
							NAME: ''
						},
						MEASURE: '',
						EMERGENCY: '',
						ENABLE_STATUS: '',
					}]

				},
				dateRecitifyTime: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd'),
				stepsText: ['发起', '审批', '归档'],
				stepsPage: 0,
				stepsPageList: 0,
				TaskID: '',
				nowName: '',
				nowIndex: 0,

			}
		},
		onLoad(option) {
			this.TaskID = option.taskID ? option.taskID : '';
			this.ID = option.ID ? option.ID : ''
			this.model.ID = option.ID ? option.ID : '';
			this.tableKey = option.tableKey ? option.tableKey : '0'
			this.isAudit = option.isAudit
			this.okApi = option.okApi
			this.refuseApi = option.refuseApi
			this.auditModel = {
				...this.$store.state.auditModel,
				TaskID: option.taskID ? option.taskID : ''
			}
			this.loadData()
		},
		methods: {
			loadData() {
				// const json = {}
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "")
				extendRule(json, 'ID', 1, this.model.ID);
				extendInclude(json, 'Nav_ApplyUser');
				extendInclude(json, 'Nav_ApplyDepartment');
				extendInclude(json, 'Nav_Require');
				extendInclude(json, 'Nav_Details');
				extendInclude(json, 'Nav_Details.Nav_Area');
				extendInclude(json, 'Nav_Details.Nav_Type');
				extendInclude(json, 'Nav_Details.Nav_RiskName');
				extendInclude(json, 'Nav_Details.Nav_DetailMeasures');
				extendInclude(json, 'Nav_Details.Nav_DetailDeparts.Nav_Department');
				extendInclude(json, 'Nav_Details.Nav_DetailPosts.Nav_Post');
				extendInclude(json, 'Nav_Files');
				extendInclude(json, 'Nav_Files.Nav_ImgFile');
				extendIgnoreDataRule(json)
				// extendRule(json, 'TASK_ID', 1, this.TaskID);
				EvaIdentifyResGet(json).then(res => {
					this.dataModel = res;
					this.stepsPage = res.STATUS == 0 ? 0 : res.STATUS == 20 ? 1 : 2
					this.dataModel.CREATE_TIME = uni.$u.timeFormat(res.CREATE_TIME, 'yyyy-mm-dd')
					this.dataModel.START_DATE = uni.$u.timeFormat(res.START_DATE, 'yyyy-mm-dd')
					this.dataModel.END_DATE = uni.$u.timeFormat(res.END_DATE, 'yyyy-mm-dd')
					this.dataModel.RequireName = res.Nav_Require.NAME
					this.dataModel.Nav_Details.map(item => {
						item['showPack'] = false
						item.ENABLE_STATUS = item.ENABLE_STATUS == 0 ? '有效' : '无效'
						item.MineType = MineTypeName[item.MineType]
						item.Nav_RiskName = item.Nav_RiskName? item.Nav_RiskName: {
							NAME: ''}
					})
					this.stepLoad = false

				})
				this.isLoadOK = true
			},
			handlePack(index) {
				this.dataModel.Nav_Details[index].showPack = this.dataModel.Nav_Details[index].showPack == false ? true : false
				this.dataModel.Nav_Details = [...this.dataModel.Nav_Details]

			},
			submit() {
				let json = {};
				json.ID = this.ID;
				json.TaskID = this.TaskID;
				SKRectifyNoticeShow(json).then(res => {
					uni.$showMsgFunc('操作成功!', () => {
							uni.navigateBack()
						},
						'success', 1000)
				})
			}

		}



	}
</script>

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