<template>
	<view class="todo-page">
		<step-title :stepPage="stepsPage" :stepText="stepsText"></step-title>
		<view class="allview">
			<view class="card">
				<u--form labelWidth="auto" :model="model" 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="model.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="(model.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="(model.Nav_ApplyUser||{}).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="(model.Nav_ProductionUnit||{}).NAME" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>

					</u-form-item>
					<u-form-item label="发现区域:">
						<u--input v-model="(model.Nav_RiskArea||{}).NAME" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>
					</u-form-item>
					<u-form-item label="隐患地点:" prop="HIDDEN_PLACE">
						<u--input v-model="model.HIDDEN_PLACE" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<u-form-item label="隐患描述:" prop="HIDDEN_DESCRIPTION">
						<u--input v-model="(model.Nav_Question||{}).DESCREPTION" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<u-form-item label="隐患等级" prop="HIDDEN_LEVEL">
						<u--input v-model="model.HIDDEN_LEVELNAME" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<u-form-item label="整改措施:">
						<u--input v-model="model.RECTIFICATION_MEASURES" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>
					</u-form-item>
					<u-form-item label="整改期限:" prop="HIDDEN_PLACE">
						<u--input v-model="model.RECITIFY_TIME" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<u-form-item label="整改部门:">
						<u--input v-model="((model.Nav_RecitifyUser||{}).Nav_Department||{}).NAME" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>
					</u-form-item>
					<u-form-item label="整改责任人:">
						<u--input v-model="(model.Nav_RecitifyUser||{}).NAME" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>
					</u-form-item>
					<u-form-item label="整改落实人:">
						<u--input v-model="(model.Nav_ImplementUser||{}).NAME" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>
					</u-form-item>
					<u-form-item label="验收人:" prop="HIDDEN_PLACE">
						<u--input v-model="(model.Nav_AcceptUser||{}).NAME" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<u-form-item label="整改情况描述:">
						<u--input v-model="model.RECTIFICATION_DESCRIPTION" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>
					</u-form-item>
					<u-form-item label="整改资金(万元):">
						<u--input v-model="model.RECTIFICATION_MONEY" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>
					</u-form-item>
					<u-form-item label="整改完成时间:" prop="HIDDEN_PLACE">
						<u--input v-model="model.COMPLETE_DATE" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<view class="upload-title">整改前照片：</view>
					<full-upload v-model="model.Nav_RectifyPhotoas" :isShowBtn='false' :listProp='listPropUpload' :listPropVal='listPropValUpload' v-if="model.Nav_RectifyPhotoas"></full-upload>
					<view class="upload-title">整改后照片：</view>
					<full-upload v-model="model.Nav_RectifyPhotobs" :isShowBtn='false' :listProp='listPropUpload' :listPropVal='listPropValUpload' v-if="model.Nav_RectifyPhotobs"></full-upload>
					<view class="upload-title">预案或方案：</view>
					<full-upload v-model="model.Nav_RectifyFiles" :isShowBtn='false' :listProp='listPropUpload' :listPropVal='listPropValUpload' v-if="model.Nav_RectifyFiles"></full-upload>
					<u-form-item label="验收时间:" prop="HIDDEN_PLACE">
						<u--input v-model="model.ACCEPT_DATE" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<u-form-item label="验收结论:" prop="HIDDEN_LEVEL">
						<u--input v-model="model.ACCEPT_RESULTENAME" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<u-form-item label="验收意见:">
						<u--input v-model="model.ACCEPT_OPINION" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>
					</u-form-item>
					<u-form-item label="备注" prop="HIDDEN_PLACE" border-bottom>
					</u-form-item>
					<u-textarea v-model="item.REMARK" disabled placeholder="请填写备注">
					</u-textarea>
				</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 {
		extendFilterGroup,
		extendGroupRule,
		extendInclude,
		extendOrder,
		extendRule,
		extendIgnoreDataRule,
		guid,
		initFilter,
		initFilterGroup,
		transformData
	} from '../../../../utils/common'
	import {
		getEnum,
		GetEnumAnyOrder
	} from '../../../../services/common';
	import {
		MineTypeIndex,
		MineTypeName
	} from '../../../../utils/enums.js'
	import {
		GetRiskVerifyRecodrReport,
		HiddenDangerRectifyRecordShow
	} from '../../../../services/apply/subPages/SK/SKServices.js'
	import stepTitle from '@/components/custom/step-title.vue'
	export default {
		components: {
			stepTitle,
		},
		data() {
			return {
				listPropUpload: ['NOTIFY_ID'],
				listPropValUpload: [],
				ORG_ID: uni.getStorageSync('orgId'),
				model: {
					Product_Unit: '',
					CREATE_TIME: '',
					Nav_ApplyDepartment: {
						NAME: ''
					},
					Nav_ApplyUser: {
						NAME: ''
					},
					Nav_RiskArea: {
						NAME: ''
					},
					RISK_AREA_ID: '',
					HIDDEN_PLACE: '',
					HIDDEN_DESCRIPTION: '',
					HIDDEN_LEVEL: '',
					RECTIFICATION_MEASURES: '',
					RECITIFY_TIME: '',
					Nav_AcceptUser: {
						NAME: ''
					},
					ACCEPT_USER_ID: '',
					RECTIFICATION_DESCRIPTION: '',
					RECTIFICATION_MONEY: '',
					COMPLETE_DATE: '',
					Nav_RectifyPhotoas: [],
					Nav_RectifyPhotobs: [],
					Nav_RectifyFiles: [],
					ACCEPT_DATE: '',
					ACCEPT_RESULTE: '',
					ACCEPT_OPINION: '',
				},
				stepsText: ['发起', '确认', '审批', '归档'],
				stepsPage: 0,
				stepsPageList: 0,
				TaskID: '',
				isLoadOK: false,
				isAudit: false,
				tableKey: 0,
				enumsData: {}, // 存储所有枚举数据（键：枚举名称，值：处理后的枚举列表）
				enumsText: {} // 存储枚举文本列表（用于下拉选择等场景）


			}
		},
		onLoad(option) {
			this.TaskID = option.taskID ? option.taskID : '';
			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.fetchEnums(['SKProductionUnit', 'SKHiddenLevel', 'SKAcceptResultEnum']);
		},
		methods: {
			fetchEnums(enumNames) {
				var dataParm = {
					'name': enumNames.join('|')
				}
				GetEnumAnyOrder(dataParm).then(res => {
					let newd = transformData(res, enumNames)
					this.enumsData = newd[0];
					// 生成文本列表（如需要）
					this.enumsText = newd[1]
					this.loadData();
				})
			},
			loadData() {
				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_RiskArea');
				// extendInclude(json, 'Nav_Contents');
				// extendInclude(json, 'Nav_ImplementUser');
				// extendInclude(json, 'Nav_RecitifyUser');
				// extendInclude(json, 'Nav_AcceptUser');
				// extendInclude(json, 'Nav_RectifyPhotoas');
				// extendInclude(json, 'Nav_RectifyPhotoas.Nav_ImgFile');
				// extendInclude(json, 'Nav_RectifyPhotobs');
				// extendInclude(json, 'Nav_RectifyPhotobs.Nav_ImgFile');
				// extendInclude(json, 'Nav_RectifyFiles');
				// extendInclude(json, 'Nav_RectifyFiles.Nav_ImgFile');
				extendIgnoreDataRule(json)
				// extendRule(json, 'TASK_ID', 1, this.TaskID);
				GetRiskVerifyRecodrReport(json).then(res => {
					this.model = res;
					this.model = res
					this.model.RECITIFY_TIME = uni.$u.timeFormat(res.RECITIFY_TIME,
						'yyyy-mm-dd')
					this.model.COMPLETE_DATE = uni.$u.timeFormat(res.COMPLETE_DATE,
						'yyyy-mm-dd')
					this.model.ACCEPT_DATE = uni.$u.timeFormat(res.ACCEPT_DATE,
						'yyyy-mm-dd')
					this.model.HIDDEN_LEVELNAME = res.HIDDEN_LEVEL !== undefined ? this.enumsData['SKHiddenLevel'].find(item => item.code === res.HIDDEN_LEVEL).name : '';
					this.model.ACCEPT_RESULTENAME = res.ACCEPT_RESULTE !== undefined ? this.enumsData['SKAcceptResultEnum'].find(item => item.code === res.ACCEPT_RESULTE).name : '';
					this.stepsPage = res.STATUS == 0 ? 0 : res.STATUS == 10 ? 1 : res.STATUS == 20 ? 2 : 3
				})
				this.isLoadOK = true

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



	}
</script>

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