<!-- 会议纪要 签到 -->
<template>
	<view class="page-wrap" v-bind:style="{paddingBottom:paddingBottom+'px'}">
		<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.CODE" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.Nav_Meeting.CODE" border="none"
							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>

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


					<view v-if="model.Nav_Meeting.MEETINGTYPE == 20" class="label-title">审核意见</view>
					<view v-if="model.Nav_Meeting.MEETINGTYPE == 30" class="label-title">评审意见</view>
					<view v-if="model.Nav_Meeting.MEETINGTYPE == 10" class="label-title">会议决议</view>
					<u-form-item v-if="model.Nav_Meeting.MEETINGTYPE < 40" prop="RESOLUTION" borderBottom>
						<u--textarea disabled 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 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-item label="请假人员" prop="ListPAskForLeaveSHOW" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.ListPAskForLeaveSHOW" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="缺席人员" prop="ListPAbsenceShow" borderBottom>
						<u--input disabled disabledColor="#fff" v-model="model.ListPAbsenceShow" border="none"
							inputAlign="right"></u--input>
					</u-form-item>

					<u-form-item label="参会人员" prop="ListPAskForLeaveSHOW" borderBottom>
						<rich-text autoHeight disabled disabledColor="#fff" v-html="model.ListPJoinHtml" border="none"
							slot="right"></rich-text>
					</u-form-item>

					<view v-if="model.Nav_ListPReview!=null&& model.Nav_ListPReview.length>0" class="label-title">评审人员
					</view>
					<view v-show="model.Nav_ListPReview!=null&& model.Nav_ListPReview.length>0" class="tag-view">
						<uni-tag class="tag" v-for="(i, k) in model.Nav_ListPReview.filter(i => !i.IS_DELETED)" :key="k"
							:inverted="true" :text="i.NAME" type="primary" />
					</view>

					<!-- <view class="label-title">会议签到</view>
					<u-form-item prop="MEETINGRECORD" borderBottom>
					</u-form-item> -->

					<view v-if=" this.TaskID===''" class="label-title">审阅意见</view>
					<u-form-item v-if=" this.TaskID===''" prop="MEETINGRECORD" borderBottom>
					</u-form-item>
				</u--form>
			</uni-card>
		</view>

		<u-sticky offset-top="20" v-if="model.Nav_Meeting.MEETINGTYPE == 40||model.Nav_Meeting.MEETINGTYPE == 50">
			<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_ListMinutesDetail">
								<u-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="ISNEEDDEAL" borderBottom>
										<u--input disabled disabledColor="#fff" v-model="item.ISNEEDDEALSHOW"
											border="none" inputAlign="right"></u--input>
									</u-form-item>

									<u-form-item v-if="item.ISNEEDDEAL" label="落实部门" prop="Nav_DepartmentDeal.NAME"
										borderBottom>
										<u--input disabled disabledColor="#fff" v-model="item.Nav_DepartmentDeal.NAME"
											border="none" inputAlign="right"></u--input>
									</u-form-item>
									<u-form-item v-if="item.ISNEEDDEAL" label="落实责任人" prop="Nav_UserDeal.NAME"
										borderBottom>
										<u--input disabled disabledColor="#fff" v-model="item.Nav_UserDeal.NAME"
											border="none" inputAlign="right"></u--input>
									</u-form-item>

									<u-form-item v-if="item.ISNEEDDEAL" label="责任人意见" prop="OPINION" borderBottom>
										<u--input disabled disabledColor="#fff" v-model="item.OPINION" border="none"
											inputAlign="right"></u--input>
									</u-form-item>

									<u-form-item v-if="item.ISNEEDDEAL" label="落实情况反馈" prop="DEALBACK" borderBottom>
										<u--input disabled disabledColor="#fff" v-model="item.DEALBACK" border="none"
											inputAlign="right"></u--input>
									</u-form-item>

									<u-form-item v-if="item.ISNEEDDEAL" label="落实期限" prop="LIMITDATETIME" borderBottom>
										<u--input disabled disabledColor="#fff" v-model="item.LIMITDATETIME"
											border="none" inputAlign="right"></u--input>
									</u-form-item>

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

									<u-form-item v-if="item.ISNEEDDEAL" label="落实效果" prop="DEALEFFECTSHOW" borderBottom>
										<u--input disabled disabledColor="#fff" v-model="item.DEALEFFECTSHOW"
											border="none" inputAlign="right"></u--input>
									</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.Nav_Content.Nav_ContentName.NAME">
									<view class="label-title">{{item.Nav_Content.TITLE}}</view>


									<u-form-item prop="Nav_ListContentDeal" borderBottom>
										<view v-if="item.Nav_Content.CHECKTYPE==20">
											<checkbox-group v-for="(itemD, index) in item.Nav_ListContentDeal"
												style="margin-top: 5px;">
												<checkbox v-if="itemD.ISCHECK" checked value="itemD.ID" disabled />
												<checkbox v-else value="itemD.ID" disabled />
												{{itemD.Nav_ContentDeal.CONTENTDETAIL}}
											</checkbox-group>
										</view>
										<view v-else>
											<!-- <u-form-item label="会议意见" prop="{{item.CHECKED_CONTENTDETAIL}}" borderBottom>
													<u--input disabled disabledColor="#fff" v-model="item.CHECKED_CONTENTDETAIL"
														border="none" inputAlign="right"></u--input>
												</u-form-item> -->

											<!-- 	<u-radio-group v-model="item.CHECKED_CONTENTDETAIL" disabled>
												<u-radio :customStyle="{marginBottom: '2px',marginLeft:'10px'}"
													v-for="(itemD, index) in item.Nav_ListContentDeal"
													:label="itemD.Nav_ContentDeal.CONTENTDETAIL"
													:name="itemD.Nav_ContentDeal.ID">
												</u-radio>
											</u-radio-group> -->

											<!-- <u-radio-group v-model="item.CHECKED_CONTENTDETAIL" disabled>
												<u-radio :customStyle="{marginBottom: '2px',marginLeft:'10px'}"
													v-for="(itemD) in item.Nav_ListContentDeal"
													:label="itemD.Nav_ContentDeal.CONTENTDETAIL"
													:name="itemD.Nav_ContentDeal.ID">
												</u-radio>
											</u-radio-group> -->

											<!-- 第一个结果不显示 修改组件 -->
											<radio-group disabled>
												<label style="float: left; margin-left: 30px;"
													v-for="(itemD) in item.Nav_ListContentDeal"
													:key="itemD.Nav_ContentDeal.CONTENTDETAIL">
													<view style="float: left;">
														<radio :value="itemD.Nav_ContentDeal.CONTENTDETAIL"
															style="border-color: #d1d1d1;" disabled
															:checked="itemD.ISCHECK" />
													</view>
													<view style="float: left;" disabled>
														{{itemD.Nav_ContentDeal.CONTENTDETAIL}}
													</view>
												</label>
											</radio-group>

										</view>
									</u-form-item>

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

		<view v-if="isAudit != 'true'" class="bottom-button">
			<button type="primary" v-if='isLoadOK && isTaskSign &&tableKey === "1"' @click="sign">签到</button>
		</view>

		<check-action v-if="isLoadOK&& tableKey === '1' && isAudit == 'true'" :okApi="okApi" :refuseApi="refuseApi"
			:dataSource="$store.state.auditModel"></check-action>

	</view>
</template>

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

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

	import {
		GetMinutesSign,
		MeetingMinutesSign
	} from '../../../../services/apply/subPages/SCMT/meeting'

	export default {
		data() {
			return {
				tableKey: '0',
				TaskID: '',
				isAudit: true,
				okApi: '',
				refuseApi: '',
				isLoadOK: false,
				isTaskSign: false,
				isHasOpinion: false,
				isMinutesDetail: false,
				paddingBottom: '160',
				// listSign: [], //会议签到
				model: {
					ID: '',
					TaskID: '',
					Nav_Files: [],
					Nav_Meeting: {
						THEME: '',
						CONTENT: '',
						BEGIN_TIME: '',
						ADDRESS: '',
						MEETINGTYPE: '',
						Nav_Department: {
							NAME: ''
						},
						Nav_UserHost: {
							NAME: ''
						},
						Nav_UserRecorder: {
							NAME: '',
						},
						Nav_ListThemes: [],
					},
					ListPJoinHtml: '', //参会人员
					Nav_ListPJoin: [{
						USER_ID: '',
						NAME: '',
						Nav_User: {
							NAME: ''
						}
					}],

					MEETINGTYPE: '',
					Nav_ListPReview: [{
						NAME: ''
					}],
					Nav_ListPReviewSHOW: '',
					RESOLUTION: '',
					MEETINGRECORD: '',
					Nav_Files: [],
					Nav_ListPAskForLeave: [],
					ListPAskForLeaveSHOW: '',
					Nav_ListPAbsence: [],
					ListPAbsenceShow: '',

					// 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: '',
					// 	CHECKED_CONTENTDETAIL: '', //单选 选中
					// 	Nav_ListContentDeal: [{
					// 		CONTENT_ID: '',
					// 		CONTENT_DEAL_ID: '',
					// 		ISCHECK: false
					// 	}]
					// }],
					Nav_ListContent: [{ //普通会议 会议题目
						CHECKED_CONTENTDETAIL: '',
						MEETING_MINUTES_ID: '',
						CONTENT_ID: '',
						ContentNAME: '',
						TITLE: '',
						Nav_Content: {
							TITLE: '',
							CHECKTYPE: '',
							Nav_ContentName: {
								NAME: ''
							}
						},
						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.isAudit = option.isAudit
			this.ApproveID = option.ApproveID
			this.okApi = option.okApi
			this.refuseApi = option.refuseApi
			if (!this.tableKey || this.tableKey != '1' || this.isAudit == 'false')
				this.paddingBottom = 10

			this.loadData()
		},


		methods: {
			sign() {
				let json = initFilter(this.model.ORG_ID, this.model.ID, null, null, null, this.TaskID);
				MeetingMinutesSign(json).then(res => {
					uni.$showMsgFunc('操作成功!', () => {
						uni.navigateBack()
					}, 'success', 1000)
				})
			},
			loadData() {
				// let adsad = config.uni_app_web_api_url
				// debugger

				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "", 1)
				extendRule(json, 'ID', 1, this.model.ID);
				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_ListMinutesDetail.Nav_UserDeal');
				extendInclude(json, 'Nav_ListMinutesDetail.Nav_DepartmentDeal');
				extendInclude(json, 'Nav_ListMinutesDetail.Nav_Files.Nav_ImgFile.Nav_File');
				extendInclude(json, 'Nav_Files.Nav_ImgFile.Nav_File');

				// extendInclude(json, 'Nav_ListPReview.Nav_User');
				// extendInclude(json, 'Nav_ListPAskForLeave.Nav_User');
				// extendInclude(json, 'Nav_ListPAbsence.Nav_User');
				// extendInclude(json, 'Nav_ListPJoin.Nav_User');

				extendInclude(json, 'Nav_Approve.Nav_ApproveDetails.Nav_ApproveUser');

				// extendInclude(json, 'Nav_ListPJoin.Nav_User.Nav_UserSignFiles.Nav_ImgFile.Nav_File');
				// extendInclude(json,'Nav_Approve.Nav_ApproveDetails.Nav_ApproveUser.Nav_UserSignFiles.Nav_ImgFile.Nav_File');

				extendInclude(json, 'Nav_ListContent.Nav_Content.Nav_ContentName');
				extendInclude(json, 'Nav_ListContent.Nav_Content.Nav_ListContentDeal');
				extendInclude(json, 'Nav_ListContent.Nav_ListContentDeal');


				json.IgnoreDataRule = true
				GetMinutesSign(json).then(res => {
					const loginID = uni.getStorageSync('appInfo').User.ID
					var isTaskSign = false
					var isHasOpinion = false
					var isMinutesDetail = false
					if (this.tableKey != undefined && this.tableKey != "2") {
						isTaskSign = true
					}
					if (res.STATUS == 10 && this.TaskID != undefined && this.TaskID.length > 0) {
						for (let i = 0; i < res.Nav_ListPJoin.length; i++) {
							if (res.Nav_ListPJoin[i].USER_ID == loginID && res.Nav_ListPJoin[i].ISRECORDRED ==
								false) {
								isTaskSign = true
								break
							}
						}
						if (!isTaskSign && res.Nav_ListPReview != null && res.Nav_ListPReview.length > 0) {
							for (let i = 0; i < res.Nav_ListPReview.length; i++) {
								if (res.Nav_ListPReview[i].USER_ID == loginID && res.Nav_ListPReview[i]
									.ISRECORDRED == false) {
									isTaskSign = true
									break
								}
							}
						}
					}

					if (res.Nav_ListPReview != null && res.Nav_ListPReview.length > 0) {
						res.Nav_ListPReview.forEach(e => {
							e.NAME = e.Nav_User.NAME
						})
					}

					if (res.Nav_ListContent != null && res.Nav_ListContent.length > 0) {
						for (let j = 0; j < res.Nav_ListContent.length; j++) {
							if (!isHasOpinion && res.Nav_ListContent[j].Nav_Content.Nav_ListContentDeal !=
								null && res.Nav_ListContent[j].Nav_Content.Nav_ListContentDeal.length > 0) {
								isHasOpinion = true
							}
						}
					}
					if (res.Nav_ListMinutesDetail != null && res.Nav_ListMinutesDetail.length > 0) {
						isMinutesDetail = true
						res.Nav_ListMinutesDetail.forEach(e => {
							if (e.ISNEEDDEAL != null) {
								if (e.ISNEEDDEAL) {
									e.ISNEEDDEALSHOW = '是'
								} else {
									e.ISNEEDDEALSHOW = '否'
								}
							}

							if (e.LIMITDATETIME != null) {
								e.LIMITDATETIME = e.LIMITDATETIME.split(' ')[0]
							}

							if (e.Nav_UserDeal == null) {
								e.Nav_UserDeal = {
									NAME: ''
								}
							}
							if (e.Nav_DepartmentDeal == null) {
								e.Nav_DepartmentDeal = {
									NAME: ''
								}
							}
						})
					}
					//会议签到（图片） 不显示了
					// if (res.Nav_ListPJoin != undefined && res.Nav_ListPJoin.length > 0) {
					// 	res.Nav_ListPJoin.forEach(element => {
					// 		if (element.ISRECORDRED != undefined && element.ISRECORDRED == true) {
					// 			this.listSign.push(element) //element.Nav_User
					// 		}
					// 	});
					// }

					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
						});
					}
					// ListPJoinHtml Nav_ListPJoin
					var ListPJoinHtml = ''
					if (res.Nav_ListPJoin != null && res.Nav_ListPJoin.length > 0) {
						res.Nav_ListPJoin.forEach((e, i) => {
							if (i > 0) {
								if (i % 5 == 0) {
									ListPJoinHtml += '<br/>'
								} else {
									ListPJoinHtml += ' '
								}
							}

							if (e.ISRECORDRED) {
								ListPJoinHtml += '<a style="color:rgba(0, 0, 0, 0.65)"> ' + e.Nav_User
									.NAME + '</a>'
							} else {
								ListPJoinHtml += '<a style="color: red"> ' + e.Nav_User.NAME + '</a>'
							}
						})
					}


					// //单选 默认选中项   组件修改 不需要这个
					// res.Nav_ListContent.forEach(e => {
					// 	e.CHECKED_CONTENTDETAIL = ''
					// 	e.Nav_ListContentDeal.forEach(ed => {
					// 		if (ed.ISCHECK) {
					// 			// e.CHECKED_CONTENTDETAIL = ed.Nav_ContentDeal.CONTENTDETAIL
					// 			e.CHECKED_CONTENTDETAIL = ed.Nav_ContentDeal.ID
					// 			return false
					// 		}
					// 	})
					// })

					// debugger
					this.model = res
					this.model.ListPJoinHtml = ListPJoinHtml //参会人
					this.model.ListPAskForLeaveSHOW = ListPAskForLeaveSHOW
					this.model.ListPAbsenceShow = ListPAbsenceShow

					this.isTaskSign = isTaskSign
					this.isHasOpinion = isHasOpinion
					this.isMinutesDetail = isMinutesDetail

					this.isLoadOK = true

				})
			},


		},
		computed: {},
	}
</script>


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