<template>
	<view class="todo-page">
		<view class="card">
			<uni-card margin="0" :is-shadow="true">
				<u--form labelPosition="left" labelWidth="auto" labelAlign="center" :model="model" ref="wForm"
					errorType="border-bottom">
					<u-form-item label="培训名称：" prop="NAME" borderBottom>
						<u--input v-model="model.NAME" disabled disabledColor="#fff" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="调查截止时间：" prop="END_TIME" borderBottom>
						<u--input v-model="model.END_TIME" disabled disabledColor="#fff" border="none"
							inputAlign="right"></u--input>
					</u-form-item>
					<u-form-item label="培训改进意见：" prop="OPINION" borderBottom>
					</u-form-item>
					<u-textarea v-model="model.OPINION"></u-textarea>
				</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">
						<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_ResultList">
								<u-form-item :label="(index+1)+'. '+ item.Nav_Subject.NAME">
									<u-subsection activeColor="#0eacf5" mode="subsection" :list="list"
										:current="item.EVALUATION_RESULT"
										@change="sectionChange($event,item)"></u-subsection>
								</u-form-item>
							</uni-card>
						</u-collapse>
					</u--form>
				</view>
			</view>
		</u-sticky>
		<view class="bottom-button">
			<button type="primary" @click="submit">提交</button>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import {
		extendFilterGroup,
		extendGroupRule,
		extendInclude,
		extendOrder,
		extendRule,
		guid,
		initFilter,
		initFilterGroup
	} from '../../../../utils/common'
	import {
		getRequest,
	} from '../../../../services/apply/FOServices/FOServices';
	import config from '../../../../config/common'
	export default {
		data() {
			return {
				model: {
					ORG_ID: "",
				},
				list: ['好', '较好', '一般', '差'],
				TaskID: '',
				ORG_ID: uni.getStorageSync('orgId')
			}
		},
		onLoad(option) {
			this.TaskID = option.taskID ? option.taskID : '';
			this.model.ID = option.ID ? option.ID : '';
			this.loadData();
		},
		methods: {
			sectionChange(index, item) {
				item.EVALUATION_RESULT = index;
			},
			loadData() {
				const json = initFilter(this.ORG_ID, "", "")
				extendInclude(json, "Nav_User")
				extendInclude(json, "Nav_ResultList")
				extendInclude(json, "Nav_ResultList.Nav_Subject")
				// TODO: id 未获取
				extendRule(json, 'ID', 1, this.model.ID)
				getRequest(json, "/SE/TrainingEffectEvaluationSurvey/Get").then(res => {
					this.model = res
				})
			},
			submit() {
				this.model.PUBLISH = "SaveAndNotify";
				if (this.TaskID != "") {
					this.model.TaskID = this.TaskID;
				}
				if (this.model.ORG_ID == "") {
					this.model.ORG_ID = this.ORG_ID;
				}
				getRequest(this.model, "/SE/SETrainingEffectEvaluationSurvey/FullUpdate").then(res => {
					if (res) {
						uni.$showMsgFunc('操作成功!', () => {
							uni.navigateBack()
						}, 'success', 1000)
					}
				})
			},
		}
	}
</script>

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

	.todo-page {
		padding: 16px 16px 70px;
	}
</style>