<!-- 会议纪要 -->
<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>
					<view class="label-title" v-if="model.MEETINGTYPE!='40'&&model.MEETINGTYPE!='50'">会议内容</view>
					<u-form-item prop="Nav_Meeting.CONTENT" v-if="model.MEETINGTYPE!='40'&&model.MEETINGTYPE!='50'"
						borderBottom>
						<u--textarea autoHeight disabled maxlength='1500' v-model="model.Nav_Meeting.CONTENT"
							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" /> <!-- +'('+ i.Nav_User.CODE+')' -->
					</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-icon style="margin-left: 4px;" slot="right" name="arrow-down"></u-icon>
					</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-icon style="margin-left: 4px;" slot="right" name="arrow-down"></u-icon>
					</u-form-item>

					<!-- @click='handleChange("Absence")' -->
					<!-- <u-form-item label="评审人员" v-if="model.MEETINGTYPE=='30'" prop="Nav_ListPReview" borderBottom>
						<u--input disabledColor="#fff" v-model="model.Nav_ListPReview" border="none"
							inputAlign="right"></u--input>
						<u-icon style="margin-left: 4px;" slot="right" name="arrow-down"></u-icon>
					</u-form-item> -->

					<view class="label-title" v-if="model.MEETINGTYPE=='30'">评审人员</view>
					<u-form-item prop="Nav_ListPReviewSHOW" v-if="model.MEETINGTYPE=='30'" borderBottom>
						<u--textarea autoHeight disabled maxlength='1500' v-model="model.Nav_ListPReviewSHOW"
							placeholder="会议内容" border="surround"></u--textarea>
					</u-form-item>

					<!--<view v-if="model.MEETINGTYPE!='40'&&model.MEETINGTYPE!='50'" class="label-title">会议决议</view>
					<u-form-item v-if="model.MEETINGTYPE!='40'&&model.MEETINGTYPE!='50'" prop="RESOLUTION" borderBottom>
						<u--textarea autoHeight maxlength='500' v-model="model.RESOLUTION" placeholder="请输入会议决议"
							border="surround"></u--textarea>
					</u-form-item> -->

					<view v-if="model.MEETINGTYPE=='10'||model.MEETINGTYPE=='20'||model.MEETINGTYPE=='30'"
						class="label-title">
						{{model.MEETINGTYPE=='10'?'会议决议':(model.MEETINGTYPE=='20'?'审核意见':'评审意见') }}
					</view>

					<!-- <view v-if="model.MEETINGTYPE=='10'" class="label-title">会议决议</view> -->
					<u-form-item v-if="model.MEETINGTYPE=='10'||model.MEETINGTYPE=='20'||model.MEETINGTYPE=='30'"
						prop="RESOLUTION" borderBottom>
						<u--textarea v-if="model.MEETINGTYPE=='10'" autoHeight maxlength='500'
							v-model="model.RESOLUTION" placeholder="请输入会议决议" border="surround"></u--textarea>
						<u--textarea v-if="model.MEETINGTYPE=='20'" autoHeight maxlength='500'
							v-model="model.RESOLUTION" placeholder="请输入审核意见" border="surround"></u--textarea>
						<u--textarea v-if="model.MEETINGTYPE=='30'" autoHeight maxlength='500'
							v-model="model.RESOLUTION" placeholder="请输入评审意见" border="surround"></u--textarea>
					</u-form-item>

					<view class="label-title">会议记录</view>
					<u-form-item prop="MEETINGRECORD" borderBottom>
						<u--textarea 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='true' :listProp='listPropUpload'
						:listPropVal='listPropValUpload'></full-upload>

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

		<u-sticky offset-top="20" v-if="model.MEETINGTYPE=='40'||model.MEETINGTYPE=='50'">
			<view class="sub-form">
				<view class="sub-form-wrap">
					<view class="sub-form-btns">
						<view class="sub-form-btn" @click="handleAdd">
							<u-icon class="icon" name="plus" color="#2979ff" size="14"></u-icon>
							<u--text type="primary" text="新增决议"></u--text>
						</view>
					</view>
					<u--form labelPosition="left" labelWidth="auto" labelAlign="center" errorType="border-bottom"
						ref="sForm"><!-- :model="subDataModel" -->
						<u-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">
								<u-collapse-item :title="index + 1 + '. ' + item.RESOLUTION">
									<view class="label-title">会议决议</view>
									<u-form-item prop="RESOLUTION" borderBottom>
										<u--textarea autoHeight v-model="item.RESOLUTION" placeholder="会议决议"
											border="surround"></u--textarea>
									</u-form-item>

									<u-form-item label="是否需要落实" prop="ISNEEDDEAL" borderBottom>
										<u-switch v-model="item.ISNEEDDEAL" slot="right"></u-switch>
										<!-- @change="change" -->
										<!-- <u--input disabledColor="#fff" v-model="item.ISNEEDDEAL" border="none"
											inputAlign="right"></u--input> -->
									</u-form-item>

									<u-form-item label="落实部门" style="margin-left: 8px;" prop="Nav_DepartmentDeal.NAME"
										borderBottom @click="handleChange('Nav_DepartmentDeal',item)">
										<u--input 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="落实责任人" style="margin-left: 8px;" prop="Nav_UserDeal.NAME"
										borderBottom @click="handleChange('Nav_UserDeal',item)">
										<u--input 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>

									<u-form-item label="落实期限" prop="LIMITDATETIME" borderBottom
										@click="showCheckDate(item)">
										<u--input disabledColor="#fff" v-model="item.LIMITDATETIME"
											placeholder="请选择落实期限" border="none" inputAlign="right"></u--input>
										<u-icon style="margin-left: 4px;" slot="right" name="arrow-down"></u-icon>
									</u-form-item>

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

		<u-sticky offset-top="20" v-else>
			<view class="sub-form">
				<view class="sub-form-wrap">
					<u--form labelPosition="left" labelWidth="auto" labelAlign="center" errorType="border-bottom"
						ref="sForm">
						<u-collapse :border="false" accordion>
							<uni-card style="margin-bottom: 16px;" margin="0" spacing="0" :is-shadow="false"
								v-for="(item, index) in model.Nav_ListContent">
								<u-collapse-item :title="index + 1 + '. ' + item.ContentNAME">
									<view class="label-title">{{item.Nav_Content.TITLE}}</view>
									<u-form-item prop="Nav_ListContentDeal" borderBottom>
										<view v-if="item.Nav_Content.CHECKTYPE==20">
											<!-- 多选 -->
											<!-- v-for="(itemD, index) in item.Nav_Content.Nav_ListContentDeal" -->
											<checkbox-group @change="checkboxChange(itemD)"
												v-for="(itemD, index) in item.Nav_ListContentDeal"
												style="margin-top: 5px;">
												<label>
													<checkbox value="{itemD.ID}" />
													{{itemD.Nav_ContentDeal.CONTENTDETAIL}}
													<!-- {{itemD.CONTENTDETAIL}} -->
													<!-- checked="true" -->
												</label>
											</checkbox-group>
										</view>
										<view v-else>

											<!-- <u-radio-group v-model="radiovalue1" placement="column"
												@change="groupChange">
												<u-radio :customStyle="{marginBottom: '8px'}"
													v-for="(item, index) in radiolist1" :key="index" :label="item.name"
													:name="item.name" @change="radioChange">
												</u-radio>
											</u-radio-group> -->
											<!-- :key="index" placement="column"-->

											<!-- OK 但是第一个会默认选中 保存又提示第一个没选 -->
											<!-- 	<u-radio-group>
												<u-radio v-model="itemD.ISCHECK" :customStyle="{marginBottom:'2px',marginLeft:'10px' }"
													v-for="(itemD, index) in item.Nav_ListContentDeal" :key="index"
													:label="itemD.Nav_ContentDeal.CONTENTDETAIL"
													:name="itemD.Nav_ContentDeal.CONTENTDETAIL"
													@change="radioChange(itemD,item.Nav_ListContentDeal)">
												</u-radio>
											</u-radio-group> -->

											<!-- 单选 -->
											<u-radio-group>
												<u-radio :customStyle="{marginBottom:'2px',marginLeft:'10px' }"
													v-for="(itemD, index) in item.Nav_Content.Nav_ListContentDeal"
													value="{itemD.ID}" :key="index" :label="itemD.CONTENTDETAIL"
													:name="itemD.CONTENTDETAIL"
													@change="radioChange(itemD,item.Nav_ListContentDeal)" />
											</u-radio-group>

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

		<query-selector :multiple="selectorInfo.isMultiple" :show="selectorInfo.showPopup"
			:defaultChecked="selectorInfo.defaultChecked" :defaultValue='selectorInfo.defaultValue'
			:title="selectorInfo.title" :lists="selectorInfo.dataLists" @search="handleSearch" @select="handleSelected"
			@close="selectorInfo.showPopup=false" />

		<u-datetime-picker :show="dateTimePickerInfo.showCheckDate" mode="date"
			v-model='dateTimePickerInfo.defaultDateTime' @confirm="handleCheckDate"
			@close="dateTimePickerInfo.showCheckDate = false"
			@cancel="dateTimePickerInfo.showCheckDate = false"></u-datetime-picker>

		<people-selector :defaultChecked="peopleSelectOption.defaultChecked" :show="peopleSelectOption.showSelector"
			@select="handleSelectorPeople" @close="peopleSelectOption.showSelector = false">
		</people-selector>

		<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 {

		GetMinutes,
		GetMinutes034,
		GetMeetingPAll,
		FullUpdateMinutes

		// Get,
		// GetPAll,
		// GetAPP,
		// OrderPagedMeetingTheme,

		// FullUpdate
	} from '../../../../services/apply/subPages/SCMT/meeting'

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

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

	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: {
			UButton
		},
		data() {
			return {
				tableKey: '0',
				FORMCODE: '',
				TaskID: '',
				listPropUpload: ['MEETING_MINUTES_ID'],
				listPropValUpload: [],
				AUDIT_OPINION: '',
				isAudit: true,
				isLoadOK: false,
				listRVal: [],
				model: {
					ID: '',
					TaskID: '',
					Nav_Files: [],
					Nav_Meeting: {
						THEME: '',
						CONTENT: '',
						BEGIN_TIME: '',
						ADDRESS: '',
						MEETINGTYPE: '',
						Nav_Department: {
							NAME: ''
						},
						Nav_UserHost: {
							NAME: ''
						},
						Nav_UserRecorder: {
							NAME: '',
						},
						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: ''
						}
					}],
					MEETINGTYPE: '',
					Nav_ListPReview: [],
					Nav_ListPReviewSHOW: '',
					RESOLUTION: '',
					MEETINGRECORD: '',
					Nav_Files: [],
					Nav_ListPAskForLeave: [],
					ListPAskForLeaveSHOW: '',
					Nav_ListPAbsence: [],
					ListPAbsenceShow: '',
					Nav_ListMinutesDetail: [{ //安委会 会议纪要
						MEETING_MINUTES_ID: '',
						RESOLUTION: '',
						ISNEEDDEAL: false,
						DEAL_DEPARTMENT_ID: '',
						Nav_DepartmentDeal: {
							NAME: ''
						},
						DEAL_USER_ID: '',
						Nav_UserDeal: {
							NAME: ''
						},
						LIMITDATETIME: ''
					}],
					Nav_ListContent: [{ //普通会议 会议题目
						MEETING_MINUTES_ID: '',
						CONTENT_ID: '',
						ContentNAME: '',
						TITLE: '',
						Nav_Content: {
							TITLE: '',
							CHECKTYPE: ''
						},
						Nav_ListContentDeal: [{
							Nav_ContentDeal: {
								CONTENTDETAIL: ''
							},
							CONTENT_ID: '',
							CONTENT_DEAL_ID: '',
							ISCHECK: false
						}]
					}]
				},
				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']
					// }
				},


				selectorInfo: {
					showPopup: false,
					title: '人员选择',
					isMultiple: false,
					name: '',
					itemData: {},
					index: 0,
					dataLists: [],
					defaultText: '',
					defaultValue: '',
					defaultChecked: []
				},

				dateTimePickerInfo: {
					showCheckDate: false,
					itemData: {},
					dataIndex: undefined,
					defaultDateTime: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss'),
					value: ''
				},
				peopleSelectOption: {
					showSelector: false,
					value: null,
					index: 0,
					defaultChecked: []
				},
			}
		},
		onLoad(option) {
			this.model.ID = option.ID
			this.model.TaskID = option.taskID
			this.TaskID = option.taskID
			this.tableKey = option.tableKey
			this.FORMCODE = option.FORMCODE
			this.loadData(this.FORMCODE)

		},
		methods: {

			handleAdd() {
				// this.model.Nav_ListMinutesDetail.unshift(this.subDataModel)
				this.model.Nav_ListMinutesDetail.unshift({
					ID: guid(),
					ORG_ID: this.model.ORG_ID,
					MEETING_MINUTES_ID: this.model.ID,
					RESOLUTION: '',
					ISNEEDDEAL: false,
					DEAL_DEPARTMENT_ID: null,
					Nav_DepartmentDeal: {
						NAME: ''
					},
					DEAL_USER_ID: null,
					Nav_UserDeal: {
						NAME: ''
					},
					LIMITDATETIME: null
				})
			},

			//显示时间控件
			showCheckDate(itemData) {
				if (itemData.LIMITDATETIME == null) {
					itemData.LIMITDATETIME = uni.$u.timeFormat(new Date(),
						'yyyy-mm-dd')
				}
				this.dateTimePickerInfo = {
					showCheckDate: true,
					itemData: itemData,
					defaultDateTime: itemData.LIMITDATETIME
				}
			},
			//隐藏控件 显示时间
			handleCheckDate(e) {
				let v = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss')
				const {
					name,
					dataIndex
				} = this.dateTimePickerInfo

				this.dateTimePickerInfo.showCheckDate = false
				this.dateTimePickerInfo.itemData.LIMITDATETIME = uni.$u.timeFormat(e.value,
					'yyyy-mm-dd')
			},


			//人员多选start
			handleShowUserSelector() {
				this.peopleSelectOption = {
					showSelector: true,
					value: this.model,
					defaultChecked: this.model.Nav_ListPAll.map(i => {
						return {
							...i,
							NAME: i.Nav_User.NAME,
							USER_ID: i.Nav_User.ID,
						}
					})
				}
			},

			//显示信息
			handleSelectorPeople(e) {
				this.model.Nav_ListPAll = e.map(i => {
					return {
						USER_ID: i.USER_ID,
						ID: i.ID || guid(),
						MEETING_ID: this.model.ID,
						PERSONTYPE: 10,
						ORG_ID: this.model.ORG_ID,
						IS_DELETED: i.IS_DELETED,
						NAME: i.NAME,
						Nav_User: {
							NAME: i.NAME,
							ID: i.USER_ID
						}
					}
				})
			},


			FullUpdate() {

				// const ele = this.$refs
				// ele['wForm'].validate().then(res => {
				const orgId = uni.getStorageSync('orgId')
				this.model.TaskID = this.TaskID
				this.model.STATUS = 10;
				// 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
				//安委会
				if (this.model.Nav_ListMinutesDetail != null && this.model.Nav_ListMinutesDetail != undefined) {
					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
				// })

				FullUpdateMinutes(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(code) {
				const orgId = uni.getStorageSync('orgId')
				if (this.listPropValUpload.length == 0) {
					this.listPropValUpload.push(this.model.ID)
				}

				const json = initFilter(orgId, "", "", 1)
				extendRule(json, 'ID', 1, this.model.ID);

				extendInclude(json, "Nav_ListContent.Nav_ListContentDeal");
				extendInclude(json, "Nav_ListContent.Nav_Content.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.Nav_User");
				extendInclude(json, "Nav_ListPJoin");
				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");


				if (code == 'SC030') {
					// 安委会 基层安全
					extendInclude(json, "Nav_ListMinutesDetail");
					extendInclude(json, "Nav_ListMinutesDetail.Nav_DepartmentDeal");
					extendInclude(json, "Nav_ListMinutesDetail.Nav_UserDeal");
				} else if (code == 'SC034') {
					//普通会议
					extendInclude(json, "Nav_Meeting.Nav_ListMeetingContent.Nav_ContentName");
					extendInclude(json, "Nav_Meeting.Nav_ListMeetingContent");
					extendInclude(json, "Nav_ListPReview");
					extendInclude(json, "Nav_ListPReview.Nav_User");
					extendInclude(json, "Nav_ListContent");
					extendInclude(json, "Nav_ListContent.Nav_Content.Nav_ContentName");
					extendInclude(json, "Nav_ListContent.Nav_Content");
				}

				json.IgnoreDataRule = true
				if (code == 'SC030') {
					GetMinutes(json).then(res => {

						if (res.Nav_ListPJoin != null && res.Nav_ListPJoin.length > 0) {
							res.Nav_ListPJoin.forEach(e => e.NAME = e.Nav_User.NAME)
						}
						// if (res.Nav_ListPAll != null && res.Nav_ListPAll.length > 0) {
						// 	var k = res.Nav_ListPAll.map(i => {
						// 		return {
						// 			...i,
						// 			NAME: i.Nav_User.NAME,
						// 		}
						// 	})
						// 	res.Nav_ListPAll = k
						// }


						if (res.MEETINGTYPE != '40' && res.MEETINGTYPE != '50') {
							//普通会议  题库相关显示
							var listContentName = []
							if (res.Nav_Meeting.Nav_ListMeetingContent != null && res.Nav_Meeting
								.Nav_ListMeetingContent
								.length > 0) {
								res.Nav_Meeting.Nav_ListMeetingContent.forEach(e => {
									listContentName.push(e.Nav_ContentName)
								})
							}
							if (res.Nav_ListContent != null && res.Nav_ListContent.length > 0) {
								if (listContentName.length > 0) {
									res.Nav_ListContent.forEach(e => {
										listContentName.forEach(en => {
											if ((e.ContentNAME == null || e.ContentNAME ==
													undefined || e.ContentNAME == '') && en
												.ID == e
												.Nav_Content.CONTENTNAME_ID) {
												e.ContentNAME = en.NAME
											}
										})
									})
								} else {
									res.Nav_ListContent.forEach(e => {
										e.ContentNAME = ''
									})
								}
							}
						}


						if (res.Nav_ListPReview != null && res.Nav_ListPReview.length > 0) {
							var Nav_ListPReviewSHOW = ''
							res.Nav_ListPReview.forEach(e => {
								Nav_ListPReviewSHOW += (Nav_ListPReviewSHOW.length > 0 ? ' ' : '') + e
									.Nav_User.NAME
							})
							res.Nav_ListPReviewSHOW = Nav_ListPReviewSHOW
						}

						if (res.Nav_ListPAskForLeave != null && res.Nav_ListPAskForLeave.length > 0) {
							var ListPAskForLeaveSHOW = ''
							res.Nav_ListPAskForLeave.forEach(e => {
								ListPAskForLeaveSHOW += (ListPAskForLeaveSHOW.length > 0 ? ' ' : '') +
									e.Nav_User.NAME
							})
							res.ListPAskForLeaveSHOW = ListPAskForLeaveSHOW
						}
						this.model = res
						this.isLoadOK = true
					})
				} else if (code == 'SC034') {
					GetMinutes034(json).then(res => {
						if (res.Nav_ListPJoin != null && res.Nav_ListPJoin.length > 0) {
							res.Nav_ListPJoin.forEach(e => e.NAME = e.Nav_User.NAME)
						}
						// if (res.Nav_ListPAll != null && res.Nav_ListPAll.length > 0) {
						// 	var k = res.Nav_ListPAll.map(i => {
						// 		return {
						// 			...i,
						// 			NAME: i.Nav_User.NAME,
						// 		}
						// 	})
						// 	res.Nav_ListPAll = k
						// }

						if (res.MEETINGTYPE != '40' && res.MEETINGTYPE != '50') {
							//普通会议  题库相关显示
							var listContentName = []
							if (res.Nav_Meeting.Nav_ListMeetingContent != null && res.Nav_Meeting
								.Nav_ListMeetingContent
								.length > 0) {
								res.Nav_Meeting.Nav_ListMeetingContent.forEach(e => {
									listContentName.push(e.Nav_ContentName)
								})
							}
							if (res.Nav_ListContent != null && res.Nav_ListContent.length > 0) {
								if (listContentName.length > 0) {
									res.Nav_ListContent.forEach(e => {
										listContentName.forEach(en => {
											if ((e.ContentNAME == null || e.ContentNAME ==
													undefined || e.ContentNAME == '') && en
												.ID == e
												.Nav_Content.CONTENTNAME_ID) {
												e.ContentNAME = en.NAME
											}
										})
									})
								} else {
									res.Nav_ListContent.forEach(e => {
										e.ContentNAME = ''
									})
								}
							}
						}


						if (res.Nav_ListPReview != null && res.Nav_ListPReview.length > 0) {
							var Nav_ListPReviewSHOW = ''
							res.Nav_ListPReview.forEach(e => {
								Nav_ListPReviewSHOW += (Nav_ListPReviewSHOW.length > 0 ? ' ' : '') + e
									.Nav_User.NAME
							})
							res.Nav_ListPReviewSHOW = Nav_ListPReviewSHOW
						}

						if (res.Nav_ListPAskForLeave != null && res.Nav_ListPAskForLeave.length > 0) {
							var ListPAskForLeaveSHOW = ''
							res.Nav_ListPAskForLeave.forEach(e => {
								ListPAskForLeaveSHOW += (ListPAskForLeaveSHOW.length > 0 ? ' ' : '') +
									e.Nav_User.NAME
							})
							res.ListPAskForLeaveSHOW = ListPAskForLeaveSHOW
						}
						this.model = res
						this.isLoadOK = true
					})
				}


			},

			//显示组件
			handleChange(name, date) {
				this.selectorInfo.name = name
				switch (name) {
					case 'AskForLeave':
						this.selectorInfo.title = '请假人员选择'
						this.selectorInfo.isMultiple = true
						if (this.model.Nav_ListPAskForLeave && this.model.Nav_ListPAskForLeave.length >
							0) {
							let defCheck = []
							for (let i = 0; i < this.model.Nav_ListPAskForLeave.length; i++) {

								if (this.model.Nav_ListPAskForLeave[i].Nav_User) {
									defCheck.push(this.model.Nav_ListPAskForLeave[i].Nav_User)
								} else {
									defCheck.push(this.model.Nav_ListPAskForLeave[i])
								}
							}

							this.selectorInfo.defaultChecked = defCheck
						} else {
							this.selectorInfo.defaultChecked = []
						}
						break;
					case 'Absence':
						this.selectorInfo.title = '缺席人员选择'
						this.selectorInfo.isMultiple = true
						if (this.model.Nav_ListPAbsence && this.model.Nav_ListPAbsence.length > 0) {
							let defCheck = []
							for (let i = 0; i < this.model.Nav_ListPAbsence.length; i++) {
								if (this.model.Nav_ListPAbsence[i].Nav_User) {
									defCheck.push(this.model.Nav_ListPAbsence[i].Nav_User)
								} else {
									defCheck.push(this.model.Nav_ListPAbsence[i])
								}
							}
							this.selectorInfo.defaultChecked = defCheck
						} else {
							this.selectorInfo.defaultChecked = []
						}
						break;
					case 'Nav_UserDeal': //落实责任人选择
						this.selectorInfo.title = '落实责任人选择'
						if (date.Nav_DepartmentDeal.NAME == null || date.Nav_DepartmentDeal.NAME == '') {
							this.selectorInfo.showPopup = false
							uni.$showErrorInfo('请先选择落实部门！')
							return
						} else {
							this.selectorInfo.isMultiple = false
							this.selectorInfo.itemData = date
							// Nav_DepartmentDeal   Nav_UserDeal
							if (this.selectorInfo.itemData.Nav_UserDeal != null && this.selectorInfo
								.itemData.Nav_UserDeal
								.NAME != '') {
								this.selectorInfo.defaultValue = this.selectorInfo.itemData.Nav_UserDeal
									.NAME
							} else {
								this.selectorInfo.defaultValue = null
							}

						}
						break;
					case 'Nav_DepartmentDeal': //落实部门选择
						this.selectorInfo.title = '落实部门选择'
						this.selectorInfo.isMultiple = false
						this.selectorInfo.itemData = date
						if (this.selectorInfo.itemData.Nav_DepartmentDeal != null && this.selectorInfo
							.itemData
							.Nav_DepartmentDeal.NAME != '') {
							this.selectorInfo.defaultValue = this.selectorInfo.itemData.Nav_DepartmentDeal
								.NAME
						} else {
							this.selectorInfo.defaultValue = null
						}
						break;
				}

				this.selectorInfo.showPopup = true
				this.handleSearch()
			},

			//数据加载
			handleSearch(val) {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "", 0)
				switch (this.selectorInfo.name) {
					case 'Nav_UserDeal': //落实责任人选择
						if (this.selectorInfo.itemData.DEAL_DEPARTMENT_ID == null || this.selectorInfo
							.itemData
							.DEAL_DEPARTMENT_ID == '') {
							uni.$showErrorInfo('请先选择落实部门！')
						} else {
							if (val)
								extendRule(json, 'NAME', 9, val);
							extendRule(json, 'DEPARTMENT_ID', 1, this.selectorInfo.itemData
								.DEAL_DEPARTMENT_ID);
							OrderPagedUseful2(json).then(res => {
								if (res.IsSuccessful) {
									this.selectorInfo.dataLists = res.Data.map(i => {
										return {
											...i,
											name: i.NAME,
											code: i.CODE
										}
									})
								}
							})
						}
						break;
					case 'Nav_DepartmentDeal': //落实部门选择
						if (val)
							extendRule(json, 'NAME', 9, val);
						getDepartmentLists(json).then(res => {
							if (res.IsSuccessful) {
								this.selectorInfo.dataLists = res.Data.map(i => {
									return {
										...i,
										name: i.NAME,
										code: i.CODE
									}
								})
							}
						})

						break;
					default:
						extendRule(json, 'MEETING_ID', 1, this.model.MEETING_ID);
						extendRule(json, 'Nav_ListPJoin', 1, this.model.Nav_ListPJoin);
						GetMeetingPAll(json).then(res => {
							//人员去除
							if (this.selectorInfo.name == 'Absence') {
								//缺席人员 去除 请假人员 Nav_ListPAskForLeave
								if (this.model.Nav_ListPAskForLeave != null && this.model
									.Nav_ListPAskForLeave
									.length >
									0) {
									this.model.Nav_ListPAskForLeave.forEach(e => {
										for (let i = 0; i < res.length; i++) {
											if (e.USER_ID == res[i].ID) {
												res = res.filter(it => it != res[i])
												// delete res[i]
												i--
												break;
											}
										}
									})
								}
							} else {
								//请假人员 去除  缺席人员  Nav_ListPAbsence
								if (this.model.Nav_ListPAbsence != null && this.model
									.Nav_ListPAbsence.length >
									0) {
									this.model.Nav_ListPAbsence.forEach(e => {
										for (let i = 0; i < res.length; i++) {
											if (e.USER_ID == res[i].ID) {
												// delete res[i]
												res = res.filter(it => it != res[i])
												i--
												break;
											}
										}
									})
								}
							}
							this.selectorInfo.dataLists = res.map(i => {
								return {
									...i,
									name: i.NAME,
									code: i.CODE
								}
							})
						})
						break;
				}
			},

			//选择信息
			handleSelected(e) {
				this.selectorInfo.showPopup = false
				// 参会人 删除
				if (e != null && e.length > 0 && this.model.Nav_ListPJoin != null && this.model
					.Nav_ListPJoin.length > 0) {
					this.model.Nav_ListPJoin.forEach(j => {
						if (j.IS_DELETED == null || !j.IS_DELETED) {
							e.forEach(C => {
								if (j.USER_ID == C.ID) {
									j.IS_DELETED = true
								}
							})
						}
					})
				}

				switch (this.selectorInfo.name) {
					case 'AskForLeave':
						var ListPAskForLeaveSHOW = ''
						this.model.Nav_ListPAskForLeave = []
						this.model.Nav_ListPAskForLeave = e.map(i => {
							ListPAskForLeaveSHOW += (ListPAskForLeaveSHOW.length > 0 ? ' ' : '') +
								i.NAME
							return {
								...i,
								MEETING_MINUTES_ID: this.model.ID,
								USER_ID: i.ID,
								ORG_ID: this.model.ORG_ID,
								ID: guid(),
								Nav_User: i,
								PERSONTYPE: 20 //请假
							}
						})
						this.model.ListPAskForLeaveSHOW = ListPAskForLeaveSHOW
						break;
					case 'Absence':
						var ListPAbsenceShow = ''
						this.model.Nav_ListPAbsence = []
						this.model.Nav_ListPAbsence = e.map(i => {
							ListPAbsenceShow += (ListPAbsenceShow.length > 0 ? ' ' : '') + i.NAME
							return {
								...i,
								MEETING_MINUTES_ID: this.model.ID,
								USER_ID: i.ID,
								ORG_ID: this.model.ORG_ID,
								ID: guid(),
								Nav_User: i,
								PERSONTYPE: 30 //缺席
							}
						})
						this.model.ListPAbsenceShow = ListPAbsenceShow
						break;
						// 'Nav_UserDeal':   'Nav_DepartmentDeal': 
					case 'Nav_UserDeal':
						this.selectorInfo.itemData.Nav_UserDeal = e
						this.selectorInfo.itemData.DEAL_USER_ID = e.ID
						break;
					case 'Nav_DepartmentDeal':
						this.selectorInfo.itemData.Nav_DepartmentDeal = e
						this.selectorInfo.itemData.DEAL_DEPARTMENT_ID = e.ID
						break;
				}
				let isDel = false
				this.model.Nav_ListPJoin.forEach(pj => {
					if (pj.IS_DELETED) {
						isDel = false
						this.model.Nav_ListPAbsence.forEach(pa => {
							if (pj.USER_ID == pa.USER_ID)
								isDel = true
						})
						if (isDel != true) {
							this.model.Nav_ListPAskForLeave.forEach(pa => {
								if (pj.USER_ID == pa.USER_ID)
									isDel = true
							})
						}
						if (isDel != true)
							pj.IS_DELETED = false
					}
				})
			},




			checkboxChange(itemD) {
				if (itemD.ISCHECK == undefined || itemD.ISCHECK == null || itemD.ISCHECK == false) {
					itemD.ISCHECK = true
				} else {
					itemD.ISCHECK = false
				}
			},
			radioChange(itemD, itemDP) {
				// 会默认选中 取消此种做法 
				// var checkID = ''
				// if (itemD.ISCHECK == undefined || itemD.ISCHECK == null || itemD.ISCHECK == false) {
				// 	itemD.ISCHECK = true
				// 	checkID = itemD.ID
				// }
				// itemDP.forEach(e => {
				// 	if (e.ID != checkID) {
				// 		e.ISCHECK = false
				// 	}
				// })


				// item.Nav_Content.Nav_ListContentDeal => item.Nav_ListContentDeal
				itemDP.forEach(e => {
					if (e.CONTENT_DEAL_ID == itemD.ID) {
						e.ISCHECK = true
					} else {
						e.ISCHECK = false
					}
				})
			}
		},
		computed: {},
	}
</script>


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