<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="隐患整改记录编号：">
						<u--input v-model="dataModel.Nav_RectifyRecord.CODE" disabled disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>

					</u-form-item>
					<u-form-item label="检查区域:">
						<u--input v-model="dataModel.Nav_RectifyRecord.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="dataModel.Nav_RectifyRecord.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="dataModel.Nav_RectifyRecord.HIDDEN_DESCRIPTION" 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="dataModel.Nav_RectifyRecord.HIDDEN_LEVEL" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<u-form-item label="整改期限:" prop="HIDDEN_PLACE">
						<u--input v-model="dataModel.Nav_RectifyRecord.RECITIFY_TIME" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<view class="upload-title">整改前照片：</view>
					<full-upload v-model="dataModel.Nav_RectifyRecord.Nav_RectifyPhotoas" :isShowBtn='false' :listProp='listPropUpload' :listPropVal='listPropValUpload'></full-upload>
					<u-form-item label="延期整改理由:" prop="HIDDEN_LEVEL">
						<u--input v-model="dataModel.DELAY_REASON" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<u-form-item label="延期整改期限" prop="HIDDEN_PLACE">
						<u--input v-model="dataModel.DELAY_RECITIFY_TIME" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>
					</u-form-item>
					<u-form-item label="整改前临时措施:">
						<u--input v-model="dataModel.RECITIFY_MEASURES_TEMP" disabledColor="#ffffff" border="none" inputAlign="right" fontSize="14px">
						</u--input>
					</u-form-item>

				</u--form>
				<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'">
					<u-button type="primary" @click="submit" color="#3d4b70">审阅</u-button>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		extendFilterGroup,
		extendGroupRule,
		extendInclude,
		extendOrder,
		extendRule,
		extendIgnoreDataRule,
		guid,
		initFilter,
		initFilterGroup
	} from '../../../../utils/common'
	import {
		GetRectifyDelayApplyReport,
		SKRectifyDelayApplyShow
	} 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'),
				dataModel: {
					Product_Unit: '',
					CREATE_TIME: '',
					Nav_ApplyDepartment: {
						NAME: ''
					},
					Nav_ApplyUser: {
						NAME: ''
					},
					Nav_RectifyRecord: {
						CODE: '',
						Nav_RiskArea: {
							NAME: ''
						},
						HIDDEN_PLACE: '',
						HIDDEN_DESCRIPTION: '',
						HIDDEN_LEVEL: '',
						RECITIFY_TIME: '',
						Nav_RectifyPhotoas: [],
					},
					DELAY_REASON: '',
					DELAY_RECITIFY_TIME: '',
					RECITIFY_MEASURES_TEMP: '',

				},
				model: {
					ORG_ID: '',
					CREATE_TIME: '',
					Nav_ApplyDepartment: {
						NAME: ''
					},
					Nav_ApplyUser: {
						NAME: ''
					},
					Nav_RectifyRecord: {
						CODE: '',
						Nav_RiskArea: {
							NAME: ''
						},
						HIDDEN_PLACE: '',
						HIDDEN_DESCRIPTION: '',
						HIDDEN_LEVEL: '',
						RECITIFY_TIME: '',
						Nav_RectifyPhotoas: [],
					},
					DELAY_REASON: '',
					DELAY_RECITIFY_TIME: '',
					RECITIFY_MEASURES_TEMP: '',

				},
				stepsText: ['发起', '审批', '审阅', '归档'],
				stepsPage: 0,
				stepsPageList: 0,
				TaskID: '',
				ID:'',
				isLoadOK: false,
				isAudit: false,
				tableKey: 0,


			}
		},
		onLoad(option) {
			this.TaskID = option.taskID ? option.taskID : '';
			this.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 orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "")
				extendRule(json, 'ID', 1, this.ID);
				// extendRule(json, 'TASK_ID', 1, this.TaskID);
				extendInclude(json, 'Nav_ApplyUser');
				extendInclude(json, 'Nav_ApplyDepartment');
				extendInclude(json, 'Nav_RectifyRecord');
				extendInclude(json, 'Nav_RectifyRecord.Nav_RiskArea');
				extendInclude(json, 'Nav_RectifyRecord.Nav_RectifyPhotoas.Nav_ImgFile');
				extendIgnoreDataRule(json)
				GetRectifyDelayApplyReport(json).then(res => {
					this.dataModel = res;
					this.dataModel.Nav_RectifyRecord.RECITIFY_TIME=uni.$u.timeFormat(res.Nav_RectifyRecord.RECITIFY_TIME,'yyyy-mm-dd'),
					this.dataModel.DELAY_RECITIFY_TIME=uni.$u.timeFormat(res.DELAY_RECITIFY_TIME,'yyyy-mm-dd'),
					this.dataModel.Nav_RectifyRecord.Nav_RectifyPhotoas = res.Nav_RectifyRecord.Nav_RectifyPhotoas ? res.Nav_RectifyRecord.Nav_RectifyPhotoas : [],
						this.stepsPage = res.STATUS == 0 ? 0 : res.STATUS == 20 ? 1 : res.STATUS == 21 ? 2 : 3
					this.dataModel.Nav_RectifyRecord.HIDDEN_LEVEL = res.Nav_RectifyRecord.HIDDEN_LEVEL == 0 ? '一般' : '重大'
				})
				this.isLoadOK = true

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

		}



	}
</script>

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