ソースを参照

feat(用户管理): 添加学生信息相关字段和接口

- 在用户表单中添加学号、院系、专业、班级和学届字段
- 新增院系、专业和班级查询接口
- 修改资源预览逻辑,移除直接路由跳转
- 修复用户表单中positionJson循环缺少key的问题
tanshanming 7 ヶ月 前
コミット
df5c824561

+ 5 - 0
src/api/resourceAudit.js

@@ -87,7 +87,12 @@ export default {
 	orgUserTreeSelector(data = {}) {
 		return request('disk/college/orgUserTreeSelector', data, 'get')
 	},
+	// 学院接口
 	orgList(data = {}) {
 		return request('sys/org/queryList', data, 'get')
+	},
+	//根据学院id和专业id查询班级
+	gradeByZyAndOrgId(data = {}) {
+		return request('disk/grades/queryList', data, 'get')
 	}
 }

+ 6 - 9
src/views/myResources/myResources.vue

@@ -734,15 +734,12 @@
 		emit('handlerAudit', auditParams)
 	}
 	const handleView = (record) => {
-		// 使用store存储预览参数
-		auditStore.setAuditParams({
-			id: record.id,
-			state: 1,
-			audit: null
-		})
-		router.push({
-			path: '/portal/resourceDetails'
-		})
+		const auditParams = { id: record.id, state: 1, audit: null }
+		auditStore.setAuditParams(auditParams)
+		emit('handlerAudit', auditParams)
+		// router.push({
+		// 	path: '/portal/resourceDetails'
+		// })
 		// publishedData.value = record
 		// auditState.value = false
 		// auditModalVisible.value = true

+ 143 - 3
src/views/sys/user/form.vue

@@ -52,6 +52,60 @@
 								<a-date-picker v-model:value="formData.birthday" value-format="YYYY-MM-DD" style="width: 100%" />
 							</a-form-item>
 						</a-col>
+						<a-col :span="12">
+							<a-form-item label="学号:" name="studentNum">
+								<a-input v-model:value="formData.studentNum" placeholder="请输入学号" allow-clear />
+							</a-form-item>
+						</a-col>
+					</a-row>
+					<a-row :gutter="16">
+						<a-col :span="8">
+							<a-form-item label="所属院系:" name="collegeId">
+								<a-select
+									v-model:value="formData.collegeId"
+									placeholder="请选择所属院系"
+									:options="collegeList"
+									:field-names="{ label: 'name', value: 'id' }"
+									@change="handleCollegeChange"
+									allow-clear
+								/>
+							</a-form-item>
+						</a-col>
+						<a-col :span="8">
+							<a-form-item label="专业:" name="majorId">
+								<a-select
+									v-model:value="formData.majorId"
+									placeholder="请选择专业"
+									:options="majorList"
+									:field-names="{ label: 'majorName', value: 'id' }"
+									@change="handleMajorChange"
+									allow-clear
+								/>
+							</a-form-item>
+						</a-col>
+						<a-col :span="8">
+							<a-form-item label="班级:" name="gradesId">
+								<a-select
+									v-model:value="formData.gradesId"
+									placeholder="请选择班级"
+									:options="gradesList"
+									:field-names="{ label: 'gradesName', value: 'gradesId' }"
+									allow-clear
+								/>
+							</a-form-item>
+						</a-col>
+					</a-row>
+					<a-row :gutter="16">
+						<a-col :span="8">
+							<a-form-item label="学届:" name="fallDue">
+								<a-select
+									v-model:value="formData.fallDue"
+									placeholder="请选择学届"
+									:options="fallDueOptions"
+									allow-clear
+								/>
+							</a-form-item>
+						</a-col>
 					</a-row>
 					<a-row :gutter="16">
 						<a-col :span="8">
@@ -137,7 +191,7 @@
 							<a-col :span="7" class="form-row-con"> 主管 </a-col>
 							<a-col :span="3" class="form-row-con"> 操作 </a-col>
 						</a-row>
-						<div v-for="(positionInfo, index) in formData.positionJson" class="form-div">
+						<div v-for="(positionInfo, index) in formData.positionJson" :key="index" class="form-div">
 							<a-row :gutter="10">
 								<a-col :span="7">
 									<a-form-item
@@ -336,6 +390,7 @@
 <script setup>
 	import userApi from '@/api/sys/userApi'
 	import userCenterApi from '@/api/sys/userCenterApi'
+	import resourceAuditApi from '@/api/resourceAudit'
 	import { required } from '@/utils/formRules'
 	import tool from '@/utils/tool'
 	// 默认是关闭状态
@@ -347,6 +402,9 @@
 	const treeData = ref([])
 	const treeDefaultExpandedKeys = ref([])
 	const eduIdentityOptions = tool.dictList('SYS_USER_EDU_IDENTITY')
+	const collegeList = ref([])
+	const majorList = ref([])
+	const gradesList = ref([])
 	console.log(eduIdentityOptions, 'eduIdentityOptions')
 
 	// 分页select组件dom定义
@@ -356,14 +414,67 @@
 	const xnChildUserPageSelectRef = ref()
 	// 表单数据
 	const formData = ref({})
+	const fallDueOptions = tool.dictList('FALL_TYPE')
+	// 加载院系列表
+	const loadCollegeList = () => {
+		resourceAuditApi.orgList().then((res) => {
+			if (res) {
+				collegeList.value = res.data
+			}
+		})
+	}
+
+	// 处理院系变化
+	const handleCollegeChange = (value) => {
+		formData.value.majorId = undefined
+		formData.value.gradesId = undefined
+		majorList.value = []
+		gradesList.value = []
+
+		if (value) {
+			// 加载专业列表
+			resourceAuditApi.zyselect({ collegeId: value }).then((res) => {
+				if (res) {
+					majorList.value = res.data
+				}
+			})
+		}
+	}
+
+	// 处理专业变化
+	const handleMajorChange = (value) => {
+		formData.value.gradesId = undefined
+		gradesList.value = []
+		if (value && formData.value.collegeId) {
+			// 加载班级列表
+			resourceAuditApi
+				.gradeByZyAndOrgId({
+					collegeId: formData.value.collegeId,
+					majorId: value
+				})
+				.then((res) => {
+					if (res) {
+						gradesList.value = res.data
+					}
+				})
+		}
+	}
 
 	// 打开抽屉
 	const onOpen = (record, orgId) => {
 		visible.value = true
 		formData.value = {
 			gender: '男',
-			positionJson: []
+			positionJson: [],
+			collegeId: undefined,
+			majorId: undefined,
+			gradesId: undefined,
+			studentNum: '',
+			fallDue: undefined
 		}
+
+		// 加载院系列表
+		loadCollegeList()
 		if (orgId) {
 			formData.value.orgId = orgId
 			// 通过机构再查询职位、主管
@@ -423,6 +534,30 @@
 				})
 			}
 			selePositionData(formData.value.orgId)
+
+			// 如果有院系ID,加载专业列表并回显
+			if (formData.value.collegeId) {
+				resourceAuditApi.zyselect({ collegeId: formData.value.collegeId }).then((res) => {
+					if (res) {
+						majorList.value = res.data
+
+						// 如果有专业ID,加载班级列表并回显
+						if (formData.value.majorId) {
+							resourceAuditApi
+								.gradeByZyAndOrgId({
+									collegeId: formData.value.collegeId,
+									majorId: formData.value.majorId
+								})
+								.then((gradeRes) => {
+									if (gradeRes) {
+										formData.value.gradesId = Number(formData.value.gradesId)
+										gradesList.value = gradeRes.data
+									}
+								})
+						}
+					}
+				})
+			}
 		})
 	}
 
@@ -433,7 +568,12 @@
 		sex: [required('请选择性别')],
 		orgId: [required('请选择组织')],
 		positionId: [required('请选择职位')],
-		eduIdentity: [required('请选择教育身份')]
+		eduIdentity: [required('请选择教育身份')],
+		collegeId: [required('请选择所属院系')],
+		majorId: [required('请选择专业')],
+		gradesId: [required('请选择班级')],
+		studentNum: [required('请输入学号')],
+		fallDue: [required('请选择学届')]
 	}
 	// 机构选择后查询对应的职位
 	const selePositionData = (orgId, type) => {

+ 2 - 2
src/views/sys/user/index.vue

@@ -37,11 +37,11 @@
 						<a-col :span="8">
 							<a-button type="primary" @click="table.refresh(true)">
 								<template #icon><SearchOutlined /></template>
-								{{ $t('common.searchButton') }}
+								{{ $t('common.searchButton') }}1
 							</a-button>
 							<a-button class="snowy-buttom-left" @click="reset">
 								<template #icon><redo-outlined /></template>
-								{{ $t('common.resetButton') }}
+								{{ $t('common.resetButton') }}1
 							</a-button>
 						</a-col>
 					</a-row>