<template>
	<view class="form-container">
		<view class="form-item">
			<label>01 严格执行学生请销假登记制度（5分）</label>
			<view class="bottom">
				<input @blur="onLimitInput($event,'stuLeaveMaterialsScoring',5)" v-model="formData.stuLeaveMaterialsScoring" type="number" placeholder="请输入分值"
					placeholder-class="input-placeholder" />
			</view>
		</view>
		<view class="form-item">
			<label>02 认真指导学生完成各项材料填报工作 （10分）</label>
			<view class="bottom">
				<input @blur="onLimitInput($event,'stuFillingMaterialsScoring',10)" v-model="formData.stuFillingMaterialsScoring" type="number" placeholder="请输入分值"
					placeholder-class="input-placeholder" />
			</view>
		</view>
		<view class="form-item">
			<label>03 按时按质完成学生基础数据上报工作（10分）</label>
			<view class="bottom">
				<input @blur="onLimitInput($event,'stuBasicDataScoring',10)" v-model="formData.stuBasicDataScoring" type="number" placeholder="请输入分值"
					placeholder-class="input-placeholder" />
			</view>
		</view>
		<view class="form-item">
			<label>04 按规定完成学生违纪处分材料（5分）</label>
			<view class="bottom">
				<input @blur="onLimitInput($event,'stuDisciplinaryViolationScoring',5)" v-model="formData.stuDisciplinaryViolationScoring" type="number" placeholder="请输入分值"
					placeholder-class="input-placeholder" />
			</view>
		</view>
		<view class="form-item">
			<label>05 按程序要求处理突发事件（10分）</label>
			<view class="bottom">
				<input @blur="onLimitInput($event,'handleEventsScoring',10)" v-model="formData.handleEventsScoring" type="number" placeholder="请输入分值"
					placeholder-class="input-placeholder" />
			</view>
		</view>
	</view>
</template>

<script>
	import {
		limitInput
	} from "@/utils/limitInput.js"
	import {
		kpiFillingBusinessWorkDetail
	} from "@/api/instructor/superintendent.js"
	export default {
		props: ["queryDetailParams"],
		data() {
			return {
				formData: {
					stuLeaveMaterialsScoring: "",
					stuFillingMaterialsScoring: "",
					stuBasicDataScoring: "",
					stuDisciplinaryViolationScoring: "",
					handleEventsScoring: "",
					id: ""
				}
			}
		},
		created() {
			kpiFillingBusinessWorkDetail(this.queryDetailParams).then(res => {
				if (res.rows.length > 0) {
					const {
						stuLeaveMaterialsScoring,
						stuFillingMaterialsScoring,
						stuBasicDataScoring,
						stuDisciplinaryViolationScoring,
						handleEventsScoring,
						id
					} = res.rows[0];
					this.formData = {
						...this.formData, // 保留 this.formData 中已有的其他属性  
						stuLeaveMaterialsScoring,
						stuFillingMaterialsScoring,
						stuBasicDataScoring,
						stuDisciplinaryViolationScoring,
						handleEventsScoring,
						id
					};
				} else {
					console.log("第一次");
				}
			})
		},
		methods: {
			onLimitInput(event,name,max) {
				let result = limitInput(event.detail.value,max);
				this.formData[name] = result;
			},
			getFormData() {
				return this.formData;
			}
		}
	}
</script>

<style scoped lang="scss">
	.form-container {
		.form-item {
			padding: 22rpx 40rpx 40rpx 40rpx;
			background-color: white;
			margin-bottom: 40rpx;
			border-radius: 16rpx;

			label {
				margin-bottom: 20rpx;
				display: inline-block;
				font-size: 26rpx;
			}

			.bottom {
				display: flex;
				align-items: center;

				input {
					flex: 1;
					border: 1px solid #E1E1E1;
					border-radius: 10rpx;
					height: 60rpx;
					padding-left: 30rpx;

					.input-placeholder {
						color: #b6b6b6;
					}
				}

				text {
					color: #1890FF;
					border-bottom: 2px solid #1890FF;
					margin-left: 40rpx;
					font-weight: bold;
					font-size: 26rpx;
				}
			}
		}
	}
</style>