index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <div style="padding: 20px 30px">
  3. <div class="resume-header mb-3">
  4. <div class="resume-title">学生信息认证</div>
  5. </div>
  6. <div class="d-flex flex-column align-center pt-5">
  7. <CtForm ref="CtFormRef" :items="items" style="width: 900px;"></CtForm>
  8. <v-btn class="buttons mt-5" color="primary" @click.stop="handleSubmit">{{ $t('common.save') }}</v-btn>
  9. </div>
  10. </div>
  11. <Loading :visible="overlay"></Loading>
  12. </template>
  13. <script setup>
  14. defineOptions({name: 'personal-personCenter-studentInformation-index'})
  15. import { ref } from 'vue'
  16. import { saveStudentSimpleInfo } from '@/api/recruit/personal/shareJob'
  17. import { schoolList, departmentList, getStudentInfo } from '@/api/recruit/personal/resume'
  18. import { useI18n } from '@/hooks/web/useI18n'
  19. import Snackbar from '@/plugins/snackbar'
  20. import { isValidIdCard18 } from '@/utils/validate'
  21. const { t } = useI18n()
  22. const overlay = ref(false)
  23. const CtFormRef = ref()
  24. const items = ref({
  25. options: [
  26. {
  27. type: 'autocomplete',
  28. key: 'schoolId',
  29. value: null,
  30. default: null,
  31. label: '就读学校 *',
  32. outlined: true,
  33. itemText: 'schoolName',
  34. itemValue: 'schoolId',
  35. rules: [v => !!v || '请选择就读学校'],
  36. items: [],
  37. change: e => getDepartmentList(e),
  38. },
  39. {
  40. type: 'autocomplete',
  41. key: 'schoolDepartmentName',
  42. value: null,
  43. default: null,
  44. label: '所在院系 *',
  45. outlined: true,
  46. itemText: 'departmentTitle',
  47. itemValue: 'schoolDepartmentId',
  48. rules: [v => !!v || '请选择所在院系'],
  49. items: []
  50. },
  51. {
  52. type: 'text',
  53. key: 'majorName',
  54. value: '',
  55. default: null,
  56. label: '所学专业 *',
  57. outlined: true,
  58. rules: [v => !!v || '请输入所学专业']
  59. },
  60. {
  61. type: 'text',
  62. key: 'schoolClassName',
  63. value: '',
  64. default: null,
  65. label: '所在班级 *',
  66. outlined: true,
  67. rules: [v => !!v || '请填写所在班级']
  68. },
  69. {
  70. type: 'text',
  71. key: 'studentNo',
  72. value: '',
  73. default: null,
  74. label: '学号',
  75. outlined: true
  76. },
  77. {
  78. type: 'text',
  79. key: 'emergencyContactName',
  80. value: '',
  81. default: null,
  82. label: '紧急联系人姓名',
  83. outlined: true
  84. },
  85. {
  86. type: 'phoneNumber',
  87. key: 'emergencyContactPhone',
  88. value: '',
  89. clearable: true,
  90. label: '紧急联系人手机号'
  91. },
  92. ]
  93. })
  94. // 左侧加mr
  95. items.value.options.forEach((e, index) => {
  96. e.col = 6
  97. if ((index + 2) % 2 === 0) e.flexStyle = 'mr-3'
  98. })
  99. // // 学校下拉列表
  100. const getSchoolListData = async () => {
  101. const item = items.value.options.find(e => e.key === 'schoolId')
  102. if (!item) return
  103. const { records } = await schoolList({current: 1,size: 9999})
  104. item.items = records || []
  105. }
  106. getSchoolListData()
  107. const getDepartmentList = async (e) => {
  108. const item = items.value.options.find(e => e.key === 'schoolDepartmentName')
  109. if (!item) return
  110. const query = {
  111. page: { size: 9999, current: 1 },
  112. entity: { schoolId: e }
  113. }
  114. const res = await departmentList(query)
  115. const list = res?.records?.length ? res.records : []
  116. item.items = list.map(e => e.entity)
  117. }
  118. // 获取学生基本信息
  119. const getStudentInfoFun = async () => {
  120. const data = await getStudentInfo()
  121. if (data.schoolId) getDepartmentList(data.schoolId)
  122. // 回显
  123. items.value.options.forEach(e => {
  124. if (data[e.key]) e.value = data[e.key]
  125. })
  126. }
  127. getStudentInfoFun()
  128. // 提交
  129. const handleSubmit = async () => {
  130. const { valid } = await CtFormRef.value.formRef.validate()
  131. if (!valid) return
  132. overlay.value = true
  133. const params = {}
  134. items.value.options.forEach(item => {
  135. params[item.key] = item.value
  136. })
  137. await saveStudentSimpleInfo(params)
  138. // getStudentInfoFun()
  139. setTimeout(async () => {
  140. Snackbar.success(t('common.submittedSuccessfully'))
  141. overlay.value = false
  142. }, 1000)
  143. }
  144. </script>
  145. <style scoped lang="scss">
  146. </style>