<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" disabled border="none" inputAlign="right" fontSize="14px">
						</u--input>
					</u-form-item>

					<u-form-item label="辨识开始时间">
						<u--input v-model="dataModel.START_DATE" placeholder="请选择时间" 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" placeholder="请选择时间" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>

					</u-form-item>
					<u-form-item label="评估结束时间">
						<u--input v-model="dataModel.EVALUATION_END_DATE" placeholder="请选择时间" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input>

					</u-form-item>
					<u-form-item label="辨识与评估内容:">
						<!-- <u--input v-model="dataModel.CONTENTS" placeholder="请填写内容" disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
						</u--input> -->
					</u-form-item>
					<u--textarea v-model="dataModel.CONTENTS" disabled autoHeight></u--textarea>
					<u-form-item label="辨识要求" borderBottom>

					</u-form-item>
					<u-textarea v-model="dataModel.Nav_RequiresName" disabled autoHeight></u-textarea>
					<u-form-item label="评估要求" borderBottom>

					</u-form-item>
					<u-textarea v-model="dataModel.Nav_EvaluationsName" disabled autoHeight></u-textarea>
					<view class="upload-title">附件：</view>
					<full-upload v-model="dataModel.Nav_Files" :isShowBtn='false' :listProp='listPropUpload' :listPropVal='listPropValUpload'></full-upload>

				</u--form>
				<u--form labelWidth="auto" :model="dataModel" ref="wForm" class="demo-ruleForm" style="margin-top: 20px;border-top: #ceccca 1px solid;">
					<view v-for="(item,index) in dataModel.Nav_Details" :key="index" style="border-bottom: #ceccca 1px dashed;padding-bottom: 10px;">
						<u-form-item label="部门:">
							<u--input v-model="item.Nav_Department.NAME" disabled disabledColor="#ffffff" inputAlign="right" fontSize="14px" border="none">
							</u--input>
						</u-form-item>
						<u-form-item label="辨识人员">
							<!-- <u-icon name="man-add" size="24" color="#3d9cff" slot="right"></u-icon> -->
						</u-form-item>
						<view v-show="!!item.Nav_DetailUsers.length" class="tag-view">
							<u-textarea v-model="item.userlist" disabled></u-textarea>
						</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>
	</view>
</template>

<script>
	import {
		extendFilterGroup,
		extendGroupRule,
		extendInclude,
		extendOrder,
		extendRule,
		extendIgnoreDataRule,
		guid,
		initFilter,
		initFilterGroup,
		handleOriginalArray
	} from '../../../../utils/common'
	import {
		FMProductionUnit,
		CheckPeriods,
		CheckLevels
	} from '../../../../utils/enums.js'
	import {
		EvaluationPlanGet,
		EvaluationPlanFullUpdate,
		getUserLists,
		GetDepartmentInfo
	} from '../../../../services/apply/subPages/SK/SKServices.js'
	import {
		getRequest,
	} from '../../../../services/apply/FOServices/FOServices';
	import stepTitle from '@/components/custom/step-title.vue'
	import swipeActionItem from '../../../../uni_modules/uview-ui/libs/config/props/swipeActionItem';
	export default {
		components: {
			stepTitle,
		},
		data() {
			return {
				showDelModalIndex: undefined,
				showPopupDate: false,
				showPopupRecitifyDate: false,
				listPropUpload: ['NOTIFY_ID'],
				listPropValUpload: [],
				ORG_ID: uni.getStorageSync('orgId'),
				currentOperateStep: {},
				showPopupStep: false,
				stepLists: [],
				curTotalStep: 0,
				dataModel: {
					CREATE_TIME: '',
					Nav_ApplyDepartment: {
						NAME: ''
					},
					Nav_ApplyUser: {
						NAME: ''
					},
					YEAR: '',
					START_DATE: '',
					END_DATE: '',
					EVALUATION_END_DATE: '',
					CONTENTS: '',
					Nav_Files: [],

					Nav_Details: [{
						Nav_Department: {
							NAME: ''
						},
						Nav_DetailUsers: [{
							Nav_User: {
								NAME: ''
							}
						}],
						userlist: '',
					}]
				},
				model: {
					ORG_ID: '',
					YEAR: '',
					START_DATE: '',
					END_DATE: '',
					EVALUATION_END_DATE: '',
					CONTENTS: '',
					Nav_Files: [],
					Nav_Details: [{
						Nav_Department: {
							NAME: ''
						},
						Nav_DetailUsers: [{
							Nav_User: {
								NAME: ''
							}
						}]
					}]

				},
				peopleSelectOption: {
					showSelector: false,
					value: null,
					index: 0,
					depId: '',
					defaultChecked: []
				},
				dateRecitifyTime: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd'),
				stepsText: ['发起', '审批', '归档'],
				stepsPage: 0,
				stepsPageList: 0,
				TaskID: '',
				nowName: '',
				nowIndex: 0,
				isAudit: false,
				isLoadOK: false,
				tableKey: 0,
			}
		},
		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.loadData()
		},
		methods: {
			loadData() {
				// const json = {}
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "")
				extendRule(json, 'ID', 1, this.model.ID);
				extendInclude(json, 'Nav_Requires');
				extendInclude(json, 'Nav_Requires.Nav_Require');
				extendInclude(json, 'Nav_Evaluations');
				extendInclude(json, 'Nav_Evaluations.Nav_Evaluation');
				extendInclude(json, 'Nav_ApplyUser');
				extendInclude(json, 'Nav_ApplyDepartment');
				extendInclude(json, 'Nav_Details');
				extendInclude(json, 'Nav_Details.Nav_Department');
				extendInclude(json, 'Nav_Details.Nav_DetailUsers.Nav_User');
				extendInclude(json, 'Nav_Files');
				extendInclude(json, 'Nav_Files.Nav_ImgFile');
				extendIgnoreDataRule(json)
				// extendRule(json, 'TASK_ID', 1, this.TaskID);
				EvaluationPlanGet(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.EVALUATION_END_DATE = uni.$u.timeFormat(res.EVALUATION_END_DATE, 'yyyy-mm-dd')
					let Nav_RequiresName = ''
					if (this.dataModel.Nav_Requires && this.dataModel.Nav_Requires.length > 0) {
						this.dataModel.Nav_Requires.map(item => {
							if (item.Nav_Require.NAME !== null) {
								Nav_RequiresName += item.Nav_Require.NAME + ' ';
							}
						})
					}
					this.dataModel.Nav_RequiresName = Nav_RequiresName
					let Nav_EvaluationsName = ''
					if (this.dataModel.Nav_Evaluations && this.dataModel.Nav_Evaluations.length > 0) {
						this.dataModel.Nav_Evaluations.map(item => {
							if (item.Nav_Evaluation.NAME !== null) {
								Nav_EvaluationsName += item.Nav_Evaluation.NAME + ' ';
							}
						})
					}
					this.dataModel.Nav_EvaluationsName = Nav_EvaluationsName
					this.dataModel.Nav_Details.map((item, index) => {
						let arr = item.Nav_DetailUsers.map((item1, index1) => {
							if (!item1.Nav_User.IS_DELETED) {
								return '  ' + item1.Nav_User.NAME
							}

						})
						item['userlist'] = String(arr)
					})

				})
				this.isLoadOK = true
			},

		}



	}
</script>

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