Selaa lähdekoodia

弹窗补充学生信息调整

Xiao_123 2 kuukautta sitten
vanhempi
commit
58efa9a73e

+ 62 - 35
src/plugins/dialogExtend/components/studentInfoForm.vue

@@ -27,12 +27,12 @@
 import { getDict } from '@/hooks/web/useDictionaries'
 import { getDict } from '@/hooks/web/useDictionaries'
 defineOptions({name: 'dialogExtend-InfoForm'})
 defineOptions({name: 'dialogExtend-InfoForm'})
 import { reactive, ref } from 'vue'
 import { reactive, ref } from 'vue'
-import { schoolList, departmentList } from '@/api/recruit/personal/resume'
 import { getUserAvatar } from '@/utils/avatar'
 import { getUserAvatar } from '@/utils/avatar'
 import { uploadFile } from '@/api/common'
 import { uploadFile } from '@/api/common'
 import Snackbar from '@/plugins/snackbar'
 import Snackbar from '@/plugins/snackbar'
 import { useI18n } from '@/hooks/web/useI18n'; const { t } = useI18n()
 import { useI18n } from '@/hooks/web/useI18n'; const { t } = useI18n()
 import { isValidIdCard18 } from '@/utils/validate'
 import { isValidIdCard18 } from '@/utils/validate'
+import { getSchoolList, getDepartmentListBySchoolId, getMajorList } from '@/api/recruit/personal/student'
 
 
 const props = defineProps({
 const props = defineProps({
   option: {
   option: {
@@ -50,6 +50,20 @@ const isShowCopper = ref(false)
 
 
 const male = ref('1')
 const male = ref('1')
 const showIcon = ref(false)
 const showIcon = ref(false)
+
+// 专业名称下拉列表
+let majorName = null
+const getMajorData = async (name) => {
+  const item = items.value.options.find(e => e.key === 'majorId')
+  if (!item) return
+  if (item.items?.length && (majorName === name)) return // 防抖
+  majorName = name
+  if (name) {
+    const data = await getMajorList({ name })
+    item.items = data
+  }
+}
+
 const items = ref({
 const items = ref({
   options: [
   options: [
     {
     {
@@ -137,41 +151,50 @@ const items = ref({
       default: null,
       default: null,
       label: '就读学校 *',
       label: '就读学校 *',
       outlined: true,
       outlined: true,
-      itemText: 'schoolName',
+      itemText: 'name',
       itemValue: 'schoolId',
       itemValue: 'schoolId',
       rules: [v => !!v || '请选择就读学校'],
       rules: [v => !!v || '请选择就读学校'],
       items: [],
       items: [],
-      change: e => getDepartmentList(e),
+      change: e => getDepartmentList(e, 'schoolDeptId', 0),
     },
     },
     {
     {
       type: 'autocomplete',
       type: 'autocomplete',
-      key: 'schoolDepartmentName',
+      key: 'schoolDeptId',
       value: null,
       value: null,
       default: null,
       default: null,
       label: '所在院系 *',
       label: '所在院系 *',
       outlined: true,
       outlined: true,
-      itemText: 'departmentTitle',
-      itemValue: 'departmentTitle',
+      itemText: 'name',
+      itemValue: 'id',
       rules: [v => !!v || '请选择所在院系'],
       rules: [v => !!v || '请选择所在院系'],
+      change: e => getDepartmentList(e, 'schoolClassId', 2),
       items: []
       items: []
     },
     },
     {
     {
-      type: 'text',
-      key: 'majorName',
-      value: '',
-      default: null,
-      label: '所学专业 *',
+      type: 'combobox',
+      key: 'schoolClassId',
+      value: null,
+      label: '所在班级 *',
       outlined: true,
       outlined: true,
-      rules: [v => !!v || '请输入所学专业']
+      clearable: true,
+      canBeInputted: true,
+      itemTextName: 'schoolClassName',
+      itemText: 'name',
+      itemValue: 'id',
+      rules: [v => !!v || '请选择所在班级'],
+      items: []
     },
     },
     {
     {
-      type: 'text',
-      key: 'schoolClassName',
-      value: '',
-      default: null,
-      label: '所在班级 *',
+      type: 'autocomplete',
+      key: 'majorId',
+      value: null,
+      label: '所学专业 *',
       outlined: true,
       outlined: true,
-      rules: [v => !!v || '请填写所在班级']
+      itemText: 'nameCn',
+      itemValue: 'id',
+      rules: [v => !!v || '请选择所学专业'],
+      search: e => getMajorData(e),
+      items: []
     },
     },
     {
     {
       type: 'text',
       type: 'text',
@@ -202,29 +225,27 @@ const items = ref({
   ]
   ]
 })
 })
 
 
-if (import.meta.env.VITE_NODE_ENV === 'production') {
-  items.value.options = items.value.options.filter(e => e.slotName !== 'analysis')
-}
-
-// // 学校下拉列表
+// 学校下拉列表
 const getSchoolListData = async () => {
 const getSchoolListData = async () => {
   const item = items.value.options.find(e => e.key === 'schoolId')
   const item = items.value.options.find(e => e.key === 'schoolId')
   if (!item) return
   if (!item) return
-  const { records } = await schoolList({current: 1,size: 9999})
-  item.items = records || []
+  const data = await getSchoolList()
+  item.items = data || []
 }
 }
 getSchoolListData()
 getSchoolListData()
 
 
-const getDepartmentList = async (e) => {
-  const item = items.value.options.find(e => e.key === 'schoolDepartmentName')
+// 根据学校id获取院系、班级列表
+const getDepartmentList = async (id, key, type) => {
+  const item = items.value.options.find(e => e.key === key)
   if (!item) return
   if (!item) return
-  const query = {
-    page: { size: 9999,	current: 1	},
-    entity: { schoolId: e }
-  }
-  const res = await departmentList(query)
-  const list = res?.records?.length ? res.records : []
-  item.items = list.map(e => e.entity)
+
+  let params = { type } // type: 0院系|1专业|2班级
+  // 查院系用schoolId,查班级用parentId
+  if (key === 'schoolDeptId') params.schoolId = id
+  else params.parentId = id
+
+  const data = await getDepartmentListBySchoolId(params)
+  item.items = data || []
 }
 }
 
 
 // 选择文件
 // 选择文件
@@ -306,7 +327,13 @@ const getQuery = async () => {
   const obj = {}
   const obj = {}
   items.value.options.forEach(e => {
   items.value.options.forEach(e => {
     if (Object.prototype.hasOwnProperty.call(e, 'data')) return obj[e.key] = e.data
     if (Object.prototype.hasOwnProperty.call(e, 'data')) return obj[e.key] = e.data
-    obj[e.key] = e.value === '' ? null : e.value
+    if (e.key === 'schoolClassId') {
+      const classObj = e.items.find(k => k[e.itemValue] === e.value)
+      if (!classObj) {
+        obj[e.key] = null
+        obj[e.itemTextName] = e.value
+      } else obj[e.key] = e.value
+    } else obj[e.key] = e.value === '' ? null : e.value
   })
   })
   if (!obj.avatar) obj.avatar = getUserAvatar(null, obj.sex)
   if (!obj.avatar) obj.avatar = getUserAvatar(null, obj.sex)
   query = Object.assign(query, obj)
   query = Object.assign(query, obj)

+ 3 - 7
src/store/user.js

@@ -266,13 +266,9 @@ export const useUserStore = defineStore('user',
 
 
       // 获取学生信息
       // 获取学生信息
       async getStudentInformation () {
       async getStudentInformation () {
-        try {
-          const data = await getStudentInfo()
-          this.studentInfo = data
-          localStorage.setItem('studentInfo', data ? JSON.stringify(data) : '{}')
-        } catch (error) {
-          Snackbar.error(error.msg)
-        }
+        const data = await getStudentInfo()
+        this.studentInfo = data
+        localStorage.setItem('studentInfo', data ? JSON.stringify(data) : '{}')
       },
       },
 
 
       // 获取学校基本信息
       // 获取学校基本信息

+ 7 - 6
src/views/recruit/personal/PersonalCenter/student/information/index.vue

@@ -35,8 +35,7 @@ const getMajorData = async (name) => {
   if (!item) return
   if (!item) return
   if (item.items?.length && (majorName === name)) return // 防抖
   if (item.items?.length && (majorName === name)) return // 防抖
   majorName = name
   majorName = name
-  if (name === null || name === '') { item.items = [] }
-  else {
+  if (name) {
     const data = await getMajorList({ name })
     const data = await getMajorList({ name })
     item.items = data
     item.items = data
   }
   }
@@ -93,6 +92,7 @@ const items = ref({
       itemText: 'nameCn',
       itemText: 'nameCn',
       itemValue: 'id',
       itemValue: 'id',
       rules: [v => !!v || '请选择所学专业'],
       rules: [v => !!v || '请选择所学专业'],
+      search: e => getMajorData(e),
       items: []
       items: []
     },
     },
     {
     {
@@ -181,7 +181,9 @@ const studentInfoFun = async () => {
   const data = JSON.parse(localStorage.getItem('studentInfo') || '{}')
   const data = JSON.parse(localStorage.getItem('studentInfo') || '{}')
   if (data.schoolId) getDepartmentList(data.schoolId, 'schoolDeptId', 0)
   if (data.schoolId) getDepartmentList(data.schoolId, 'schoolDeptId', 0)
   if (data?.schoolClassId) getDepartmentList(data.schoolDeptId, 'schoolClassId', 2)
   if (data?.schoolClassId) getDepartmentList(data.schoolDeptId, 'schoolClassId', 2)
-  if (data?.majorId) getMajorData(data?.major?.nameCn)
+  if (data?.majorId) {
+    getMajorData(data?.major?.nameCn)
+  }
   // 回显
   // 回显
   items.value.options.forEach(e => {
   items.value.options.forEach(e => {
     if (data[e.key]) {
     if (data[e.key]) {
@@ -196,7 +198,6 @@ onMounted(() => {
   studentInfoFun()
   studentInfoFun()
 })
 })
 
 
-
 // 提交
 // 提交
 const handleSubmit = async () => {
 const handleSubmit = async () => {
   const { valid } = await CtFormRef.value.formRef.validate()
   const { valid } = await CtFormRef.value.formRef.validate()
@@ -206,7 +207,7 @@ const handleSubmit = async () => {
   items.value.options.forEach(item => {
   items.value.options.forEach(item => {
     // 班级有下拉选择的,需要根据选择的值赋值
     // 班级有下拉选择的,需要根据选择的值赋值
     if (item.key === 'schoolClassId') {
     if (item.key === 'schoolClassId') {
-      const classObj = item.items.find(e => item.itemValue === e.value)
+      const classObj = item.items.find(e => e[item.itemValue] === item.value)
       if (!classObj) {
       if (!classObj) {
         params[item.key] = null
         params[item.key] = null
         params[item.itemTextName] = item.value
         params[item.itemTextName] = item.value
@@ -216,7 +217,7 @@ const handleSubmit = async () => {
 
 
   await saveStudentSimpleInfo(params)
   await saveStudentSimpleInfo(params)
   setTimeout(async () => {
   setTimeout(async () => {
-    await userStore.getStudentInformation()
+    studentInfoFun()
     Snackbar.success(t('common.submittedSuccessfully'))
     Snackbar.success(t('common.submittedSuccessfully'))
     overlay.value = false
     overlay.value = false
   }, 1000)
   }, 1000)

+ 2 - 1
src/views/recruit/teacher/organization/index.vue

@@ -75,7 +75,8 @@ const query = ref({
 })
 })
 const pageInfo = ref({
 const pageInfo = ref({
   pageNo: 1,
   pageNo: 1,
-  pageSize: 10
+  pageSize: 10,
+  type: 0
 })
 })
 
 
 const headers = [
 const headers = [