|
@@ -14,64 +14,86 @@
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
defineOptions({name: 'personal-personCenter-studentInformation-index'})
|
|
defineOptions({name: 'personal-personCenter-studentInformation-index'})
|
|
-import { ref } from 'vue'
|
|
|
|
|
|
+import { ref, onMounted } from 'vue'
|
|
import { saveStudentSimpleInfo } from '@/api/recruit/personal/shareJob'
|
|
import { saveStudentSimpleInfo } from '@/api/recruit/personal/shareJob'
|
|
-import { schoolList, departmentList } from '@/api/recruit/personal/resume'
|
|
|
|
import { useI18n } from '@/hooks/web/useI18n'
|
|
import { useI18n } from '@/hooks/web/useI18n'
|
|
import Snackbar from '@/plugins/snackbar'
|
|
import Snackbar from '@/plugins/snackbar'
|
|
import { isValidIdCard18 } from '@/utils/validate'
|
|
import { isValidIdCard18 } from '@/utils/validate'
|
|
import { useUserStore } from '@/store/user'
|
|
import { useUserStore } from '@/store/user'
|
|
|
|
+import { getSchoolList, getDepartmentListBySchoolId, getMajorList } from '@/api/recruit/personal/student'
|
|
|
|
|
|
const { t } = useI18n()
|
|
const { t } = useI18n()
|
|
const userStore = useUserStore()
|
|
const userStore = useUserStore()
|
|
const overlay = ref(false)
|
|
const overlay = ref(false)
|
|
|
|
|
|
const CtFormRef = ref()
|
|
const CtFormRef = ref()
|
|
|
|
+
|
|
|
|
+// 专业名称下拉列表
|
|
|
|
+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 === null || name === '') { item.items = [] }
|
|
|
|
+ else {
|
|
|
|
+ const data = await getMajorList({ name })
|
|
|
|
+ item.items = data
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
const items = ref({
|
|
const items = ref({
|
|
options: [
|
|
options: [
|
|
{
|
|
{
|
|
type: 'autocomplete',
|
|
type: 'autocomplete',
|
|
key: 'schoolId',
|
|
key: 'schoolId',
|
|
- value: {},
|
|
|
|
|
|
+ value: null,
|
|
default: null,
|
|
default: null,
|
|
label: '就读学校 *',
|
|
label: '就读学校 *',
|
|
outlined: true,
|
|
outlined: true,
|
|
- returnObject: 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, true),
|
|
},
|
|
},
|
|
{
|
|
{
|
|
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, true),
|
|
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 || '请选择所学专业'],
|
|
|
|
+ items: []
|
|
},
|
|
},
|
|
{
|
|
{
|
|
type: 'text',
|
|
type: 'text',
|
|
@@ -115,10 +137,9 @@ const items = ref({
|
|
type: 'phoneNumber',
|
|
type: 'phoneNumber',
|
|
key: 'emergencyContactPhone',
|
|
key: 'emergencyContactPhone',
|
|
value: '',
|
|
value: '',
|
|
- clearable: true,
|
|
|
|
label: '紧急联系人手机号 *',
|
|
label: '紧急联系人手机号 *',
|
|
rules: [v => !!v || '请填写紧急联系人手机号']
|
|
rules: [v => !!v || '请填写紧急联系人手机号']
|
|
- },
|
|
|
|
|
|
+ }
|
|
]
|
|
]
|
|
})
|
|
})
|
|
|
|
|
|
@@ -129,47 +150,51 @@ items.value.options.forEach((e, index) => {
|
|
})
|
|
})
|
|
|
|
|
|
// 学校下拉列表
|
|
// 学校下拉列表
|
|
-const getSchoolListData = async (schoolId) => {
|
|
|
|
|
|
+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 || []
|
|
|
|
-
|
|
|
|
- if (schoolId) {
|
|
|
|
- item.value = records.find(e => e.schoolId === schoolId)
|
|
|
|
- }
|
|
|
|
|
|
+ const data = await getSchoolList()
|
|
|
|
+ item.items = data || []
|
|
}
|
|
}
|
|
-getSchoolListData()
|
|
|
|
|
|
|
|
-const getDepartmentList = async (e) => {
|
|
|
|
- const item = items.value.options.find(e => e.key === 'schoolDepartmentName')
|
|
|
|
|
|
+
|
|
|
|
+// 根据学校id获取院系、班级列表
|
|
|
|
+const getDepartmentList = async (id, key, type, isRefreshValue = false) => {
|
|
|
|
+ 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: typeof e === 'object' ? e.schoolId : e }
|
|
|
|
- }
|
|
|
|
- const res = await departmentList(query)
|
|
|
|
- const list = res?.records?.length ? res.records : []
|
|
|
|
- item.items = list.map(e => e.entity)
|
|
|
|
- if (typeof e === 'object') item.value = null
|
|
|
|
|
|
+
|
|
|
|
+ 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 || []
|
|
|
|
+
|
|
|
|
+ // 下拉框选择时需清空下级value
|
|
|
|
+ if (isRefreshValue) item.value = null
|
|
}
|
|
}
|
|
|
|
|
|
// 获取学生基本信息
|
|
// 获取学生基本信息
|
|
const studentInfoFun = async () => {
|
|
const studentInfoFun = async () => {
|
|
await userStore.getStudentInformation()
|
|
await userStore.getStudentInformation()
|
|
const data = JSON.parse(localStorage.getItem('studentInfo') || '{}')
|
|
const data = JSON.parse(localStorage.getItem('studentInfo') || '{}')
|
|
- if (data.schoolId) getDepartmentList(data.schoolId)
|
|
|
|
|
|
+ if (data.schoolId) getDepartmentList(data.schoolId, 'schoolDeptId', 0)
|
|
|
|
+ if (data?.schoolClassId) getDepartmentList(data.schoolDeptId, 'schoolClassId', 2)
|
|
|
|
+ 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]) {
|
|
- if (e.key === 'schoolId') {
|
|
|
|
- getSchoolListData(data[e.key])
|
|
|
|
- }
|
|
|
|
- else e.value = data[e.key]
|
|
|
|
|
|
+ e.value = data[e.key]
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
-studentInfoFun()
|
|
|
|
|
|
+onMounted(() => {
|
|
|
|
+ // 获取学校列表
|
|
|
|
+ getSchoolListData()
|
|
|
|
+ // 获取学生基本信息
|
|
|
|
+ studentInfoFun()
|
|
|
|
+})
|
|
|
|
|
|
|
|
|
|
// 提交
|
|
// 提交
|
|
@@ -179,14 +204,16 @@ const handleSubmit = async () => {
|
|
overlay.value = true
|
|
overlay.value = true
|
|
const params = {}
|
|
const params = {}
|
|
items.value.options.forEach(item => {
|
|
items.value.options.forEach(item => {
|
|
- params[item.key] = item.returnObject ? '' : item.value
|
|
|
|
- if (item.key === 'schoolId') {
|
|
|
|
- params.schoolName = item.value.schoolName
|
|
|
|
- params.schoolId = item.value.schoolId
|
|
|
|
|
|
+ // 班级有下拉选择的,需要根据选择的值赋值
|
|
|
|
+ if (item.key === 'schoolClassId') {
|
|
|
|
+ const classObj = item.items.find(e => item.itemValue === e.value)
|
|
|
|
+ if (!classObj) {
|
|
|
|
+ params[item.key] = null
|
|
|
|
+ params[item.itemTextName] = item.value
|
|
|
|
+ } else params[item.key] = item.value
|
|
} else params[item.key] = item.value
|
|
} else params[item.key] = item.value
|
|
})
|
|
})
|
|
|
|
|
|
-
|
|
|
|
await saveStudentSimpleInfo(params)
|
|
await saveStudentSimpleInfo(params)
|
|
setTimeout(async () => {
|
|
setTimeout(async () => {
|
|
await userStore.getStudentInformation()
|
|
await userStore.getStudentInformation()
|