<template>
	<view>
		<view class="nav-bar"></view>
		<view class="form-area" v-if="formStatus == 1">
			<uni-forms ref="infoForm" :modelValue="formDetail" label-position="top">
				<uni-forms-item style="display: none;" name="meetintTime">
					<uni-easyinput :disabled="true" style="display: none;" v-model="formDetail.meetintTime"></uni-easyinput>
				</uni-forms-item>
				<uni-forms-item  name="unitName" label="单位名称" label-width="150">
					<uni-easyinput :disabled="true" placeholder="请输入" v-model="formDetail.unitName"></uni-easyinput>
				</uni-forms-item>
				<uni-forms-item  name="projectName" label="项目名称" label-width="150">
					<uni-easyinput :disabled="true" placeholder="请输入" v-model="formDetail.projectName"></uni-easyinput>
				</uni-forms-item>
				<uni-forms-item  name="meetingTheme" label="例会主题" label-width="150">
					<uni-easyinput :disabled="true" placeholder="请输入" v-model="formDetail.meetingTheme"></uni-easyinput>
				</uni-forms-item>
				<uni-forms-item  name="emcee" label="会议主持人" label-width="150">
					<uni-easyinput :disabled="true" placeholder="请输入" v-model="formDetail.emcee"></uni-easyinput>
				</uni-forms-item>
				<uni-forms-item  name="noteTaker" label="会议记录人" label-width="150">
					<uni-easyinput :disabled="true" placeholder="请输入" v-model="formDetail.noteTaker"></uni-easyinput>
				</uni-forms-item>
				<uni-forms-item  name="startTime" label="例会开始时间" label-width="150">
					<uni-datetime-picker :disabled="true" type="datetime" v-model="formDetail.startTime"/>
				</uni-forms-item>
				<uni-forms-item  name="endTime" label="例会结束时间" label-width="150">
					<uni-datetime-picker :disabled="true" type="datetime" v-model="formDetail.endTime"/>
				</uni-forms-item>
				<uni-forms-item  name="meetingContent" label="例会内容" label-width="150">
					<uni-easyinput type="textarea" :disabled="true" v-model="formDetail.meetingContent" placeholder="请输入"></uni-easyinput>
				</uni-forms-item>
				<uni-forms-item  name="meetingRecord" label="会议记录" label-width="150">
					<uni-easyinput type="textarea" :disabled="true" v-model="formDetail.meetingRecord" placeholder="请输入"></uni-easyinput>
				</uni-forms-item>
				<uni-forms-item  name="userArr" label="参会人员" label-width="150">
					<span 
						v-for="(man, index) in formDetail.comeArr"
						:key="index"
						style="padding-right: 10rpx;"
					>
						{{ man }}
					</span>
				</uni-forms-item>
				<uni-forms-item  name="absentArr" label="缺席人员" label-width="150">
					<span 
						v-for="(absent, index) in formDetail.abArr"
						:key="index"
						style="padding-right: 10rpx;"
					>
						{{ absent }}
					</span>
				</uni-forms-item>
				<uni-forms-item label="参会人数" label-width="150">
					<uni-easyinput :disabled="true" v-model="formDetail.peopleCount"></uni-easyinput>
				</uni-forms-item>
				<uni-forms-item  name="pictureAddress" label="现场照片" label-width="150">
					<view
						v-for="(item, index) in formDetail.pictureAddress"
						:key="index"
					>
						<image :src="formDetail.pictureAddress[index]" mode=""></image>
					</view>
				</uni-forms-item>
				<uni-forms-item  name="meetingType" label="例会类型" label-width="150">
					<uni-data-checkbox :disabled="true" v-model="formDetail.meetingType" :localdata="typeRange"></uni-data-checkbox>
				</uni-forms-item>
			</uni-forms>
		</view>
	</view>
</template>

<script>
import { publicPath } from '../../public';
	export default {
		data() {
			return {
				formDetail: {},
				typeRange: [
					{ value: '1', text: '月例会' },
					{ value: '2', text: '周例会' },
					{ value: '3', text: '安全例会' }
				],
				formStatus: 0
			}
		},
		methods: {
			
		},
		onLoad(params) {
			let that = this
			console.log(params);
			// 初始化获取例会详情
			uni.request({
				url: publicPath + '/backstage/app/getById',
				method: 'POST',
				header: {
					'content-type':'application/x-www-form-urlencoded; charset=UTF-8'
				},
				data: {
					id: params.id
				},
				success: (res) => {
					console.log(res);
					if (res.data.code == 200) {
						let dataList = res.data.data
						dataList.comeArr = []
						dataList.abArr = []
						for (let i = 0; i < dataList.userList.length; i++) {
							if (dataList.userList[i].ifAbsence == 1) {
								dataList.comeArr.push(dataList.userList[i].userName)
							} else if (dataList.userList[i].ifAbsence == 0) {
								dataList.abArr.push(dataList.userList[i].userName)
							}
						}
						dataList.peopleCount = dataList.comeArr.length
						dataList.pictureAddress = dataList.pictureAddress.split(',')
						that.formDetail = dataList
						console.log(that.formDetail);
						that.formStatus = 1
					} else {
						uni.showToast({
							icon: 'none',
							title: '获取例会详情失败，请稍后再试！'
						})
					}
				}
			})
		}
	}
</script>

<style lang="scss" scoped>
	.nav-bar{
		width: 100%;
		height: var(--status-bar-height);
		padding-top: var(--status-bar-height);
	}
	.form-area{
		width: 90%;
		margin: 20rpx auto;
	}
</style>
