index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. rules: [v => !!v || '请填写学号']
  77. },
  78. {
  79. type: 'text',
  80. key: 'idCardNo',
  81. value: '',
  82. label: '身份证号码 *',
  83. rules: [
  84. value => {
  85. if (!value) {
  86. return '请输入您的身份证号码'
  87. }
  88. return true
  89. },
  90. value => {
  91. if (!isValidIdCard18(value)) {
  92. return '请输入正确的身份证号码'
  93. }
  94. return true
  95. }
  96. ]
  97. },
  98. {
  99. type: 'text',
  100. key: 'emergencyContactName',
  101. value: '',
  102. default: null,
  103. label: '紧急联系人姓名 *',
  104. outlined: true,
  105. rules: [v => !!v || '请填写紧急联系人姓名']
  106. },
  107. {
  108. type: 'phoneNumber',
  109. key: 'emergencyContactPhone',
  110. value: '',
  111. clearable: true,
  112. label: '紧急联系人手机号 *',
  113. rules: [v => !!v || '请填写紧急联系人手机号']
  114. },
  115. ]
  116. })
  117. // 左侧加mr
  118. items.value.options.forEach((e, index) => {
  119. e.col = 6
  120. if ((index + 2) % 2 === 0) e.flexStyle = 'mr-3'
  121. })
  122. // // 学校下拉列表
  123. const getSchoolListData = async () => {
  124. const item = items.value.options.find(e => e.key === 'schoolId')
  125. if (!item) return
  126. const { records } = await schoolList({current: 1,size: 9999})
  127. item.items = records || []
  128. }
  129. getSchoolListData()
  130. const getDepartmentList = async (e) => {
  131. const item = items.value.options.find(e => e.key === 'schoolDepartmentName')
  132. if (!item) return
  133. const query = {
  134. page: { size: 9999, current: 1 },
  135. entity: { schoolId: e }
  136. }
  137. const res = await departmentList(query)
  138. const list = res?.records?.length ? res.records : []
  139. item.items = list.map(e => e.entity)
  140. }
  141. // 获取学生基本信息
  142. const getStudentInfoFun = async () => {
  143. const data = await getStudentInfo()
  144. if (data.schoolId) getDepartmentList(data.schoolId)
  145. // 回显
  146. items.value.options.forEach(e => {
  147. if (data[e.key]) e.value = data[e.key]
  148. })
  149. }
  150. getStudentInfoFun()
  151. // 提交
  152. const handleSubmit = async () => {
  153. const { valid } = await CtFormRef.value.formRef.validate()
  154. if (!valid) return
  155. overlay.value = true
  156. const params = {}
  157. items.value.options.forEach(item => {
  158. params[item.key] = item.value
  159. })
  160. await saveStudentSimpleInfo(params)
  161. // getStudentInfoFun()
  162. setTimeout(async () => {
  163. Snackbar.success(t('common.submittedSuccessfully'))
  164. overlay.value = false
  165. }, 1000)
  166. }
  167. </script>
  168. <style scoped lang="scss">
  169. </style>