<!-- 会议纪要落实 -->
<template>
	<view class="page-wrap">
		<view class="card">
			<uni-card margin="0" :is-shadow="true">
				<u--form labelPosition="left" labelWidth="auto" labelAlign="center" :model="model" :rules="rules"
					ref="wForm" errorType="border-bottom">

					<view class="label-title">会议主题</view>
					<u-form-item prop="Nav_Meeting.THEME" borderBottom>
						<u--textarea autoHeight disabled maxlength='1500' v-model="model.Nav_Meeting.THEME"
							placeholder="会议主题" border="surround"></u--textarea>
					</u-form-item>
					<u-form-item label="会议时间" prop="Nav_Meeting.BEGIN_TIME" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.Nav_Meeting.BEGIN_TIME" border="none"
							inputAlign="right"></u--input>
					</u-form-item>

					<u-form-item label="会议地点" prop="Nav_Meeting.ADDRESS" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.Nav_Meeting.ADDRESS" border="none"
							slot="right" inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="发起部门" prop="Nav_Meeting.Nav_Department.NAME" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.Nav_Meeting.Nav_Department.NAME"
							border="none" inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="主持人" prop="Nav_Meeting.Nav_UserHost.NAME" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.Nav_Meeting.Nav_UserHost.NAME"
							border="none" inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="记录人" prop="Nav_Meeting.Nav_UserRecorder.NAME" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.Nav_Meeting.Nav_UserRecorder.NAME"
							border="none" inputAlign="right"></u--input>
					</u-form-item>

					<view class="label-title">参会人员：</view>
					<view v-show="!!model.Nav_ListPJoin.length" class="tag-view">
						<uni-tag class="tag" v-for="(i, k) in model.Nav_ListPJoin.filter(i => !i.IS_DELETED)" :key="k"
							:inverted="true" :text="i.NAME" type="primary" />
					</view>

					<u-form-item label="请假人员" prop="ListPAskForLeaveSHOW" @click='handleChange("AskForLeave")'
						borderBottom>
						<u--input disabledColor="#fff" v-model="model.ListPAskForLeaveSHOW" border="none"
							inputAlign="right"></u--input>

					</u-form-item>
					<u-form-item label="缺席人员" prop="ListPAbsenceShow" @click='handleChange("Absence")' borderBottom>
						<u--input disabledColor="#fff" v-model="model.ListPAbsenceShow" border="none"
							inputAlign="right"></u--input>

					</u-form-item>

					<view class="label-title">会议记录</view>
					<u-form-item prop="MEETINGRECORD" borderBottom>
						<u--textarea disabled autoHeight maxlength='500' v-model="model.MEETINGRECORD"
							placeholder="请输入检查内容" border="surround"></u--textarea>
					</u-form-item>

					<view class="upload-title">附件</view>
					<full-upload v-model="model.Nav_Files" :isShowBtn='false'></full-upload>

				</u--form>
			</uni-card>
		</view>

		<u-sticky offset-top="20">
			<view class="sub-form">
				<view class="sub-form-wrap">
					<u--form labelPosition="left" labelWidth="auto" labelAlign="center" errorType="border-bottom"
						ref="sForm"> <!-- :model="model.Nav_ListMinutesDetail" :rules="rulesSub" -->
						<uni-collapse :border="false" accordion>
							<uni-card style="margin-bottom: 16px;" margin="0" spacing="0" :is-shadow="false"
								v-for="(item, index) in model.Nav_ListMinutesDetail">
								<uni-collapse-item :title="index + 1 + '. ' + item.RESOLUTION">
									<view class="label-title">会议决议</view>
									<u-form-item prop="RESOLUTION" borderBottom>
										<u--textarea disabled autoHeight v-model="item.RESOLUTION" placeholder="会议决议"
											border="surround"></u--textarea>
									</u-form-item>

									<u-form-item label="是否需要落实" prop="ISNEEDDEALSHOW" borderBottom>
										<u--input disabled disabledColor="#fff" v-model="item.ISNEEDDEALSHOW"
											border="none" inputAlign="right"></u--input>
									</u-form-item>

									<u-form-item label="落实部门" prop="Nav_DepartmentDeal.NAME" borderBottom>
										<u--input disabled disabledColor="#fff" v-model="item.Nav_DepartmentDeal.NAME"
											border="none" inputAlign="right"></u--input>
										<!-- <u-icon style="margin-left: 4px;" slot="right" name="arrow-down"></u-icon> -->
									</u-form-item>
									<u-form-item label="落实责任人" prop="Nav_UserDeal.NAME" borderBottom>
										<u--input disabled disabledColor="#fff" v-model="item.Nav_UserDeal.NAME"
											border="none" inputAlign="right"></u--input>
										<!-- <u-icon style="margin-left: 4px;" slot="right" name="arrow-down"></u-icon> -->
									</u-form-item>

									<w-view-require class="label-title" title='责任人意见'></w-view-require>
									<u-form-item prop="OPINION" borderBottom>
										<u--textarea autoHeight v-model="item.OPINION" placeholder="请输入责任人意见"
											border="surround"></u--textarea>
									</u-form-item>
									<w-view-require class="label-title" title='落实情况反馈'></w-view-require>
									<u-form-item prop="DEALBACK" borderBottom>
										<u--textarea autoHeight v-model="item.DEALBACK" placeholder="请输入落实情况反馈"
											border="surround"></u--textarea>
									</u-form-item>

									<u-form-item label="落实期限" prop="LIMITDATETIMESHOW" borderBottom
										@click="showCheckDate(item)">
										<u--input disabled disabledColor="#fff" v-model="item.LIMITDATETIMESHOW"
											placeholder="请选择落实期限" border="none" inputAlign="right"></u--input>
									</u-form-item>

									<view class="upload-title">附件</view>
									<full-upload v-model="item.Nav_Files" :isShowBtn='true'
										:listProp='listPropSubUpload'
										:listPropVal='item.listPropSubValUpload'></full-upload>

								</uni-collapse-item>
							</uni-card>
						</uni-collapse>
					</u--form>
				</view>
			</view>
		</u-sticky>

		<view class="bottom-button">
			<button type="primary" v-if='isLoadOK && tableKey === "1"' @click="FullUpdate">提交</button>
		</view>

	</view>
</template>

<script>
	import {
		guid,
		initFilter,
		extendRule,
		extendInclude,
		extendGroupRule,
		initFilterGroup,
		extendFilterGroup,
		extendFilterGroupGroupRules
	} from '../../../../utils/common'

	import {

		GetByDetailDeal,
		UpdateDeal
	} from '../../../../services/apply/subPages/SCMT/meeting'

	import {
		OrderPagedUseful2
	} from '../../../../services/common'

	import {
		getDepartmentLists
	} from '../../../../services/app'

	import wViewRequire from '@/components/custom/w-view-require.vue'
	// import WViewTequire from 'components/custom/w-view-require.vue'

	import UButton from '../../../../uni_modules/uview-ui/components/u-button/u-button.vue'
	import form from '../../../../uni_modules/uview-ui/libs/config/props/form'

	export default {
		components: {
			wViewRequire
			// UButton,
		},
		data() {
			return {
				tableKey: '0',
				TaskID: '',
				listPropSubUpload: ['MEETING_MINUTES_DETAIL_ID'],

				AUDIT_OPINION: '',
				isAudit: true,
				isLoadOK: false,

				model: {
					ID: '',
					TaskID: '',
					Nav_Files: [],
					Nav_Meeting: {

						Nav_UserHost: {
							NAME: ''
						},
						Nav_UserRecorder: {
							NAME: '',
						},
						THEME: '',
						Nav_ListThemes: [],

						// Nav_ListPAll: [{
						// 	USER_ID: '',
						// 	NAME: '',
						// 	Nav_User: {
						// 		NAME: ''
						// 	}
						// }]
					},
					// Nav_ListMeetingPJoin: [{ //初始的人员信息  不然请假人 缺席人 操作可能会导致 参会人丢失
					// 	USER_ID: '',
					// 	NAME: '',
					// 	Nav_User: {
					// 		NAME: ''
					// 	}
					// }],
					Nav_ListPJoin: [{
						USER_ID: '',
						NAME: '',
						Nav_User: {
							NAME: ''
						}
					}],
					Nav_ListPAskForLeave: [],
					ListPAskForLeaveSHOW: '',
					Nav_ListPAbsence: [],
					ListPAbsenceShow: '',
					Nav_ListMinutesDetail: [{
						listPropSubValUpload: [],
						MEETING_MINUTES_ID: '',
						RESOLUTION: '',
						ISNEEDDEAL: false,
						ISNEEDDEALSHOW: '',
						DEAL_DEPARTMENT_ID: '',
						Nav_DepartmentDeal: {
							NAME: ''
						},
						DEAL_USER_ID: '',
						Nav_UserDeal: {
							NAME: ''
						},
						LIMITDATETIME: '',
						LIMITDATETIMESHOW: ''
					}]
				},
				rulesSub: {
					'OPINION': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change']
					},
					'DEALBACK': {
						type: 'string',
						required: true,
						trigger: ['blur', 'change']
					},
				},

				rules: {
					// 'MEETINGTYPESHOW': {
					// 	type: 'string',
					// 	required: true,
					// 	trigger: ['blur', 'change']
					// },
					// 'THEME': {
					// 	type: 'string',
					// 	required: true,
					// 	trigger: ['blur', 'change']
					// },
					// 'Nav_UserHost.NAME': {
					// 	type: 'string',
					// 	required: true,
					// 	trigger: ['blur', 'change']
					// },
					// 'Nav_UserRecorder.NAME': {
					// 	type: 'string',
					// 	required: true,
					// 	trigger: ['blur', 'change']
					// },
					// 'BEGIN_TIME': {
					// 	type: 'string',
					// 	required: true,
					// 	trigger: ['blur', 'change']
					// },
					// 'ADDRESS': {
					// 	type: 'string',
					// 	required: true,
					// 	trigger: ['blur', 'change']
					// }
				},


			}
		},
		onLoad(option) {
			this.model.ID = option.ID
			this.model.TaskID = option.taskID
			this.TaskID = option.taskID
			this.tableKey = option.tableKey
			this.loadData()

		},
		methods: {

			FullUpdate() {

				// const ele = this.$refs
				// debugger
				// ele['sForm'].validate().then(res => {
				// 	debugger
				// }).catch(err => {
				// 	uni.$showErrorInfo('校验失败')
				// })
				// return false;

				// ele['wForm'].validate().then(res => {
				const orgId = uni.getStorageSync('orgId')
				this.model.TaskID = this.TaskID
				this.model.Nav_ListMinutesDetail[0].STATUS = 30;

				// if (!this.model.DEPARTMENT_ID || !this.model.USER_ID_ORIGINATOR) {
				// 	var loginInfo = uni.getStorageSync('appInfo')
				// 	this.model.DEPARTMENT_ID = loginInfo.User.DEPARTMENT_ID
				// 	this.model.USER_ID_ORIGINATOR = loginInfo.User.ID
				// }

				// this.model.Nav_UserHost = null
				// this.model.Nav_UserRecorder = null
				// this.model.Nav_ListPAll.forEach(e => e.Nav_User = null)

				// this.model.Nav_UserHost = null
				// this.model.Nav_UserRecorder = null
				// this.model.Nav_ListMinutesDetail.forEach(e => {
				// 	if (e.Nav_DepartmentDeal != null) {
				// 		e.Nav_DepartmentDeal = null
				// 	}
				// 	if (e.Nav_UserDeal != null) {
				// 		e.Nav_UserDeal = null
				// 	}
				// })
				// this.model.Nav_ListPJoin.forEach(e => {
				// 	e.Nav_User = null
				// })


				UpdateDeal(this.model).then(res => {
					uni.$showMsgFunc('操作成功!', () => {
						// if (this.tableKey == null || this.tableKey == 0) {
						// 	uni.navigateTo({
						// 		url: 'safeCheckIndex'
						// 	})
						// } else {
						uni.navigateBack()
						// }
					}, 'success', 1000)

				}).catch(err => {
					debugger
					uni.$showErrorInfo(err)
				})
				// }).catch(err => {
				// 	uni.$showErrorInfo('校验失败')
				// })
			},

			async loadData() {

				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "", 1)
				extendRule(json, 'ID', 1, this.model.ID);
				extendInclude(json, "Nav_ListContent.Nav_Content.Nav_ListContentDeal");
				extendInclude(json, "Nav_ListContent.Nav_ListContentDeal");
				extendInclude(json, "Nav_Meeting");
				extendInclude(json, "Nav_Meeting.Nav_Department");
				extendInclude(json, "Nav_Meeting.Nav_UserHost");
				extendInclude(json, "Nav_Meeting.Nav_UserRecorder");
				extendInclude(json, "Nav_ListPJoin");
				extendInclude(json, "Nav_ListPJoin.Nav_User");
				extendInclude(json, "Nav_ListPAskForLeave");
				extendInclude(json, "Nav_ListPAskForLeave.Nav_User");
				extendInclude(json, "Nav_ListPAbsence");
				extendInclude(json, "Nav_ListPAbsence.Nav_User");
				extendInclude(json, "Nav_Files.Nav_ImgFile.Nav_File");
				extendInclude(json, "Nav_ListMinutesDetail");
				extendInclude(json, "Nav_ListMinutesDetail.Nav_DepartmentDeal");
				extendInclude(json, "Nav_ListMinutesDetail.Nav_UserDeal");
				extendInclude(json, "Nav_ListMinutesDetail.Nav_Files.Nav_ImgFile.Nav_File");
				json.IgnoreDataRule = true
				GetByDetailDeal(json).then(res => {
					if (res.Nav_ListPJoin != null && res.Nav_ListPJoin.length > 0) {
						res.Nav_ListPJoin.forEach(e => e.NAME = e.Nav_User.NAME)
					}


					this.model = res
					let ListPAskForLeaveSHOW = ''
					let ListPAbsenceShow = ''

					if (res.Nav_ListPAskForLeave != undefined && res.Nav_ListPAskForLeave.length > 0) {
						res.Nav_ListPAskForLeave.forEach(e => {
							ListPAskForLeaveSHOW += (ListPAskForLeaveSHOW.length > 0 ? ' ' : '') + e
								.Nav_User.NAME
						});
					}

					if (res.Nav_ListPAbsence != undefined && res.Nav_ListPAbsence.length > 0) {
						res.Nav_ListPAbsence.forEach(e => {
							ListPAbsenceShow += (ListPAbsenceShow.length > 0 ? ' ' : '') + e.Nav_User
								.NAME
						});
					}

					this.model.ListPAskForLeaveSHOW = ListPAskForLeaveSHOW
					this.model.ListPAbsenceShow = ListPAbsenceShow

					if (this.model.Nav_ListMinutesDetail != null && this.model
						.Nav_ListMinutesDetail.length > 0) {
						this.model.Nav_ListMinutesDetail.forEach(e => {
							e.listPropSubValUpload = []
							e.listPropSubValUpload.push(e.ID)

							if (e.ISNEEDDEAL)
								e.ISNEEDDEALSHOW = '是'
							else
								e.ISNEEDDEALSHOW = '否'

							if (e.LIMITDATETIME != null && e.LIMITDATETIME.length > 0)
								e.LIMITDATETIMESHOW = e.LIMITDATETIME.split(' ')[0]
						})
					}
					this.isLoadOK = true
				})
			},
		},
		computed: {},
	}
</script>


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