index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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 } 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. import { useUserStore } from '@/store/user'
  22. const { t } = useI18n()
  23. const userStore = useUserStore()
  24. const overlay = ref(false)
  25. const CtFormRef = ref()
  26. const items = ref({
  27. options: [
  28. {
  29. type: 'autocomplete',
  30. key: 'schoolId',
  31. value: null,
  32. default: null,
  33. label: '就读学校 *',
  34. outlined: true,
  35. itemText: 'schoolName',
  36. itemValue: 'schoolId',
  37. rules: [v => !!v || '请选择就读学校'],
  38. items: [],
  39. change: e => getDepartmentList(e),
  40. },
  41. {
  42. type: 'autocomplete',
  43. key: 'schoolDepartmentName',
  44. value: null,
  45. default: null,
  46. label: '所在院系 *',
  47. outlined: true,
  48. itemText: 'departmentTitle',
  49. itemValue: 'schoolDepartmentId',
  50. rules: [v => !!v || '请选择所在院系'],
  51. items: []
  52. },
  53. {
  54. type: 'text',
  55. key: 'majorName',
  56. value: '',
  57. default: null,
  58. label: '所学专业 *',
  59. outlined: true,
  60. rules: [v => !!v || '请输入所学专业']
  61. },
  62. {
  63. type: 'text',
  64. key: 'schoolClassName',
  65. value: '',
  66. default: null,
  67. label: '所在班级 *',
  68. outlined: true,
  69. rules: [v => !!v || '请填写所在班级']
  70. },
  71. {
  72. type: 'text',
  73. key: 'studentNo',
  74. value: '',
  75. default: null,
  76. label: '学号 *',
  77. outlined: true,
  78. rules: [v => !!v || '请填写学号']
  79. },
  80. {
  81. type: 'text',
  82. key: 'idCardNo',
  83. value: '',
  84. label: '身份证号码 *',
  85. rules: [
  86. value => {
  87. if (!value) {
  88. return '请输入您的身份证号码'
  89. }
  90. return true
  91. },
  92. value => {
  93. if (!isValidIdCard18(value)) {
  94. return '请输入正确的身份证号码'
  95. }
  96. return true
  97. }
  98. ]
  99. },
  100. {
  101. type: 'text',
  102. key: 'emergencyContactName',
  103. value: '',
  104. default: null,
  105. label: '紧急联系人姓名 *',
  106. outlined: true,
  107. rules: [v => !!v || '请填写紧急联系人姓名']
  108. },
  109. {
  110. type: 'phoneNumber',
  111. key: 'emergencyContactPhone',
  112. value: '',
  113. clearable: true,
  114. label: '紧急联系人手机号 *',
  115. rules: [v => !!v || '请填写紧急联系人手机号']
  116. },
  117. ]
  118. })
  119. // 左侧加mr
  120. items.value.options.forEach((e, index) => {
  121. e.col = 6
  122. if ((index + 2) % 2 === 0) e.flexStyle = 'mr-3'
  123. })
  124. // // 学校下拉列表
  125. const getSchoolListData = async () => {
  126. const item = items.value.options.find(e => e.key === 'schoolId')
  127. if (!item) return
  128. const { records } = await schoolList({current: 1,size: 9999})
  129. item.items = records || []
  130. }
  131. getSchoolListData()
  132. const getDepartmentList = async (e) => {
  133. const item = items.value.options.find(e => e.key === 'schoolDepartmentName')
  134. if (!item) return
  135. const query = {
  136. page: { size: 9999, current: 1 },
  137. entity: { schoolId: e }
  138. }
  139. const res = await departmentList(query)
  140. const list = res?.records?.length ? res.records : []
  141. item.items = list.map(e => e.entity)
  142. }
  143. // 获取学生基本信息
  144. const studentInfoFun = async () => {
  145. const data = JSON.parse(localStorage.getItem('studentInfo') || '{}')
  146. if (data.schoolId) getDepartmentList(data.schoolId)
  147. // 回显
  148. items.value.options.forEach(e => {
  149. if (data[e.key]) e.value = data[e.key]
  150. })
  151. }
  152. studentInfoFun()
  153. // 提交
  154. const handleSubmit = async () => {
  155. const { valid } = await CtFormRef.value.formRef.validate()
  156. if (!valid) return
  157. overlay.value = true
  158. const params = {}
  159. items.value.options.forEach(item => {
  160. params[item.key] = item.value
  161. })
  162. await saveStudentSimpleInfo(params)
  163. setTimeout(async () => {
  164. await userStore.getStudentInformation()
  165. Snackbar.success(t('common.submittedSuccessfully'))
  166. overlay.value = false
  167. }, 1000)
  168. }
  169. </script>
  170. <style scoped lang="scss">
  171. </style>