<template>
	<view class="form-container">
		<view class="form-item">
			<label>01 违反高校教师职业道德与行为规范的</label>
			<view class="bottom">
				<radio-group @change="handleRadioChange" data-group-name="moralityAndBehavior">
					<label>
						<radio value="1" :checked="formData.moralityAndBehavior === 1" active-background-color="#2a8f08"
							style="transform:scale(0.7)" />是
					</label>
					<label>
						<radio value="0" :checked="formData.moralityAndBehavior === 0" active-background-color="#2a8f08"
							style="transform:scale(0.7)" />否
					</label>
				</radio-group>
			</view>
		</view>
		<view class="form-item">
			<label>02 在学生中散布影响安定团结或违背国家相关法律法规言论</label>
			<view class="bottom">
				<radio-group @change="handleRadioChange" data-group-name="speech">
					<label>
						<radio value="1" :checked="formData.speech === 1" active-background-color="#2a8f08"
							style="transform:scale(0.7)" />是
					</label>
					<label>
						<radio value="0" :checked="formData.speech === 0" active-background-color="#2a8f08"
							style="transform:scale(0.7)" />否
					</label>
				</radio-group>
			</view>
		</view>
		<view class="form-item">
			<label>03 学生评价极差，书记、校长信箱投诉频繁</label>
			<view class="bottom">
				<radio-group @change="handleRadioChange" data-group-name="complaint">
					<label>
						<radio value="1" :checked="formData.complaint === 1" active-background-color="#2a8f08"
							style="transform:scale(0.7)" />是
					</label>
					<label>
						<radio value="0" :checked="formData.complaint === 0" active-background-color="#2a8f08"
							style="transform:scale(0.7)" />否
					</label>
				</radio-group>
			</view>
		</view>
		<view class="form-item">
			<label>04 认定为因疏于教育、管理导致学生发生违纪违法现象，造成恶劣影响</label>
			<view class="bottom">
				<radio-group @change="handleRadioChange" data-group-name="offense">
					<label>
						<radio value="1" :checked="formData.offense === 1" active-background-color="#2a8f08"
							style="transform:scale(0.7)" />是
					</label>
					<label>
						<radio value="0" :checked="formData.offense === 0" active-background-color="#2a8f08"
							style="transform:scale(0.7)" />否
					</label>
				</radio-group>
			</view>
		</view>
		<view class="form-item">
			<label>05 学生发生突发事件，在正常情况下未能及时到场处理，引起较大影响</label>
			<view class="bottom">
				<radio-group @change="handleRadioChange" data-group-name="emergency">
					<label>
						<radio value="1" :checked="formData.emergency === 1" active-background-color="#2a8f08"
							style="transform:scale(0.7)" />是
					</label>
					<label>
						<radio value="0" :checked="formData.emergency === 0" active-background-color="#2a8f08"
							style="transform:scale(0.7)" />否
					</label>
				</radio-group>
			</view>
		</view>
		<view class="form-item">
			<label>06 受到党纪、政纪处分及治安拘留或刑事处罚</label>
			<view class="bottom">
				<radio-group @change="handleRadioChange" data-group-name="punishment">
					<label>
						<radio value="1" :checked="formData.punishment === 1" active-background-color="#2a8f08"
							style="transform:scale(0.7)" />是
					</label>
					<label>
						<radio value="0" :checked="formData.punishment === 0" active-background-color="#2a8f08"
							style="transform:scale(0.7)" />否
					</label>
				</radio-group>
			</view>
		</view>
		<view class="form-item">
			<label>07 在开展评优评奖等工作中弄虚作假</label>
			<view class="bottom">
				<radio-group @change="handleRadioChange" data-group-name="practiceFraud">
					<label>
						<radio value="1" :checked="formData.practiceFraud === 1" active-background-color="#2a8f08"
							style="transform:scale(0.7)" />是
					</label>
					<label>
						<radio value="0" :checked="formData.practiceFraud === 0" active-background-color="#2a8f08"
							style="transform:scale(0.7)" />否
					</label>
				</radio-group>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		kpiFillingNegativeListDetail
	} from "@/api/instructor/superintendent.js"
	export default {
		props: ["queryDetailParams"],
		data() {
			return {
				formData: {
					moralityAndBehavior: "",
					speech: "",
					complaint: "",
					offense: "",
					emergency: "",
					punishment: "",
					practiceFraud: "",
					id: ""
				}
			}
		},
		created() {
			kpiFillingNegativeListDetail(this.queryDetailParams).then(res => {
				console.log(res);
				if (res.rows.length > 0) {
					// this.formData = res.rows[0];
					const {
						moralityAndBehavior,
						speech,
						complaint,
						offense,
						emergency,
						punishment,
						practiceFraud,
						id
					} = res.rows[0];
					this.formData = {
						...this.formData, // 保留 this.formData 中已有的其他属性  
						moralityAndBehavior,
						speech,
						complaint,
						offense,
						emergency,
						punishment,
						practiceFraud,
						id
					};

				} else {
					console.log("第一次");
				}
			})
		},
		methods: {
			handleRadioChange(e) {
				const groupName = e.target.dataset.groupName; // 获取data-group-name的值  
				this.formData[groupName] = e.detail.value; // 更新formData中对应的属性  
				// 可以在这里加入其他逻辑，比如数据校验、表单提交等  
			},
			getFormData() {
				return this.formData;
			}
		}
	}
</script>

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

			&>label {
				margin-bottom: 30rpx;
				display: inline-block;
				font-size: 26rpx;
			}

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

				radio-group {
					label {
						margin-top: 20rpx;

						&:first-child {
							margin-right: 50rpx;
						}
					}
				}
			}
		}
	}
</style>