index.vue 5.0 KB

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