<template>
	<view class="page-wrap">
		<uni-card margin="0" :is-shadow="true">
			<u--form labelPosition="left" labelWidth="auto" labelAlign="center" :model="model">
				<u-form-item label="活动主题：" prop="TITLE" borderBottom>
					<u--input v-model="model.TITLE" border="none" inputAlign="right" disabled disabledColor="#ffffff"></u--input>
				</u-form-item>
				<u-form-item label="活动日期：" prop="ACTIVITY_TIME" borderBottom>
					<u--input v-model="model.ACTIVITY_TIME" border="none" slot="right"
						inputAlign="right" disabled disabledColor="#ffffff"></u--input>
				</u-form-item>
				<u-form-item label="活动地点：" prop="ADDRESS" borderBottom>
					<u--input v-model="model.ADDRESS" border="none" slot="right" inputAlign="right" disabled disabledColor="#ffffff"></u--input>
				</u-form-item>
				<u-form-item label="班组名称：" prop="Nav_Taem.NAME" borderBottom>
					<u--input v-model="model.Nav_Taem.NAME" border="none" slot="right" inputAlign="right" disabled disabledColor="#ffffff"></u--input>
				</u-form-item>
				<u-form-item label="记录人：" prop="Nav_User.NAME" borderBottom>
					<u--input v-model="model.Nav_User.NAME" border="none" slot="right" inputAlign="right" disabled disabledColor="#ffffff"></u--input>
				</u-form-item>
				<u-form-item label="活动时长：" prop="DURATION" borderBottom>
					<u--input v-model="model.DURATION" border="none" slot="right" inputAlign="right" disabled disabledColor="#ffffff"></u--input>
				</u-form-item>
				<u-form-item label="参会人员：" prop="UserNames" borderBottom style="margin-bottom: 10px;">
				</u-form-item>
				<rich-text style="line-height: 30px;" autoHeight type="textarea" v-html="model.UserNames" border="none" 
					inputAlign="right" disabled></rich-text>
				<u-form-item label="活动记录：" prop="ACTIVITY_CONTENT" >
				</u-form-item>
				<u--textarea  autoHeight v-model="model.ACTIVITY_CONTENT" border="" inputAlign="right" disabled></u--textarea>
				<view class="upload-title">附件</view>
				<full-upload v-model="model.Nav_TeamActivityFile" :listProp='listPropUpload'
					:listPropVal='listPropValUpload' :isShowBtn="false"></full-upload>
			</u--form>
		</uni-card>
		<button type="primary" class="bottom" v-if='isLoadOK&&tableKey==1' @click="onTableBtnAgree">签到</button>
	</view>
</template>

<script>
	import {
		initFilter,
		extendRule,
		extendInclude
	} from '../../../../utils/common'

	import {
		getRequest,
	} from '../../../../services/apply/FOServices/FOServices'

	import '../../../../utils/showMsg.js'
	import color from '../../../../uni_modules/uview-ui/libs/config/color'
	import config from '../../../../config/common'

	export default {
		data() {
			return {
				model: {
					Nav_Taem:"",
					Nav_User:""
				},
				listPropUpload: ['TEAM_ACTIVITY_ID'],
				listPropValUpload: [],
				TaskID: "",
				tableKey: '0',
				isLoadOK: false,
			}
		},
		onLoad(option) {
			this.model.ID = option.ID;
			this.TaskID = option.taskID;
			this.tableKey = option.tableKey ? option.tableKey : '0'
			this.loadData()
		},
		methods: {
			loadData() {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "CODE", 1)
				extendRule(json, 'ID', 1, this.model.ID);
				extendInclude(json, "Nav_Taem")
				extendInclude(json, "Nav_User")
				extendInclude(json, 'Nav_TeamActivityUser.Nav_User.Nav_UserSignFiles.Nav_ImgFile.Nav_File');
				extendInclude(json, 'Nav_TeamActivityFile.Nav_ImgFile.Nav_File');
				getRequest(json,"/FO/TeamActivity/Get").then(res => {
					this.model = res
					//数据组装
					let strUserName = ''
					if (res.Nav_TeamActivityUser && res.Nav_TeamActivityUser.length > 0) {
						for (let i = 0; i < res.Nav_TeamActivityUser.length; i++) {
							if (res.Nav_TeamActivityUser[i].SIGN_IN_STATUS == 0) {
								strUserName += (strUserName.length > 0 ? "  " : "") + "<text style='color:red'>" +
									res.Nav_TeamActivityUser[i].Nav_User.NAME + "</text>";
							} else {
								strUserName += (strUserName.length > 0 ? "  " : "") + res.Nav_TeamActivityUser[
									i].Nav_User.NAME;
							}

						}
					}
					
					this.model.ACTIVITY_TIME = this.model.ACTIVITY_TIME.substring(0,10);
					this.model.UserNames = strUserName;
					this.isLoadOK = true
				})
			},
			onTableBtnAgree() {
				let json = {};
				json.ID = this.model.ID;
				json.TaskID = this.TaskID;
				getRequest(json,"/FO/FOTeamActivity/TeamActivityUserUpdate").then(res => {
					if (res) {
						uni.$showMsgFunc('操作成功!', () => {
							uni.navigateBack()
						}, 'success', 1000)
					}
				})

			}
		},
		computed: {

		}
	}
</script>

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