bind-teacher-profile.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <ie-page bg-color="#F6F8FA" :safeAreaInsetBottom="false">
  3. <ie-navbar title="完善信息" custom-back @left-click="handleBack" />
  4. <uv-form labelPosition="left" :model="examTypeForm" labelWidth="70px" ref="formRef">
  5. <content-card title="个人信息">
  6. <uv-form-item label="姓名" prop="name" borderBottom required>
  7. <uv-input v-model="form.nickName" border="none" placeholder="请输入姓名" placeholderClass="text-30"
  8. font-size="30rpx" :custom-style="customStyle">
  9. </uv-input>
  10. </uv-form-item>
  11. <uv-form-item label="所在省份" prop="location" borderBottom required>
  12. <ie-picker ref="pickerRef" v-model="examTypeForm.location" :list="provinceList"
  13. :placeholder="pickerPlaceholder" :custom-style="customStyle" key-label="areaName" key-value="shortName"
  14. :disabled="disabledEdit">
  15. <template v-if="disabledEdit" #right>
  16. <ie-image src="/static/image/icon-lock.png" custom-class="w-24 h-30" mode="aspectFill" />
  17. </template></ie-picker>
  18. </uv-form-item>
  19. <uv-form-item label="考生类别" prop="examType" borderBottom required>
  20. <ie-picker ref="pickerRef" v-model="examTypeForm.examType" :list="examTypeList"
  21. :disabled="!examTypeForm.location || disabledEdit" :placeholder="pickerPlaceholder"
  22. :custom-style="customStyle" key-label="dictLabel" key-value="dictValue" @change="handleExamTypeChange">
  23. <template v-if="disabledEdit" #right>
  24. <ie-image src="/static/image/icon-lock.png" custom-class="w-24 h-30" mode="aspectFill" />
  25. </template>
  26. </ie-picker>
  27. </uv-form-item>
  28. <uv-form-item v-if="examTypeForm.examType === 'VHS'" label="专业类别" prop="majorType" borderBottom required>
  29. <ie-picker ref="pickerRef" v-model="examTypeForm.majorType" :list="examMajorList"
  30. :disabled="!examTypeForm.examType || disabledEdit" :placeholder="pickerPlaceholder"
  31. :custom-style="customStyle" key-label="dictLabel" key-value="dictValue">
  32. <template v-if="disabledEdit" #right>
  33. <ie-image src="/static/image/icon-lock.png" custom-class="w-24 h-30" mode="aspectFill" />
  34. </template></ie-picker>
  35. </uv-form-item>
  36. <uv-form-item label="单招年份" prop="year" required>
  37. <ie-picker ref="pickerRef" v-model="examTypeForm.endYear" :list="endYearList"
  38. :disabled="!examTypeForm.examType || disabledEdit" :placeholder="pickerPlaceholder"
  39. :custom-style="customStyle" key-label="dictLabel" key-value="dictValue">
  40. <template v-if="disabledEdit" #right>
  41. <ie-image src="/static/image/icon-lock.png" custom-class="w-24 h-30" mode="aspectFill" />
  42. </template></ie-picker>
  43. </uv-form-item>
  44. </content-card>
  45. <content-card v-if="showCulture" title="文化素质">
  46. <uv-form-item label="语文" prop="form.scores.chinese" borderBottom :required="isScoreRequired">
  47. <uv-input v-model.number="scoresForm.chinese" border="none" type="number" :placeholder="inputPlaceholder"
  48. font-size="30rpx" :custom-style="customStyle" :readonly="disabledEdit">
  49. </uv-input>
  50. </uv-form-item>
  51. <uv-form-item label="数学" prop="form.score.mathematics" borderBottom :required="isScoreRequired">
  52. <uv-input v-model.number="scoresForm.mathematics" border="none" type="number" :placeholder="inputPlaceholder"
  53. font-size="30rpx" :custom-style="customStyle" :readonly="disabledEdit">
  54. </uv-input>
  55. <ie-image v-if="disabledEdit" slot="right" src="/static/image/icon-lock.png" custom-class="w-24 h-30"
  56. mode="aspectFill" />
  57. </uv-form-item>
  58. <uv-form-item label="外语" prop="form.scores.foreign" borderBottom :required="isScoreRequired">
  59. <uv-input v-model.number="scoresForm.foreign" border="none" type="number" :placeholder="inputPlaceholder"
  60. font-size="30rpx" :custom-style="customStyle" :readonly="disabledEdit">
  61. </uv-input>
  62. <ie-image v-if="disabledEdit" slot="right" src="/static/image/icon-lock.png" custom-class="w-24 h-30"
  63. mode="aspectFill" />
  64. </uv-form-item>
  65. <uv-form-item label="物理" prop="form.scores.physics" borderBottom :required="isScoreRequired">
  66. <uv-input v-model.number="scoresForm.physics" border="none" type="number" :placeholder="inputPlaceholder"
  67. font-size="30rpx" :custom-style="customStyle" :readonly="disabledEdit">
  68. </uv-input>
  69. <ie-image v-if="disabledEdit" slot="right" src="/static/image/icon-lock.png" custom-class="w-24 h-30"
  70. mode="aspectFill" />
  71. </uv-form-item>
  72. <uv-form-item label="政治" prop="form.scores.political" :required="isScoreRequired">
  73. <uv-input v-model.number="scoresForm.political" border="none" type="number" :placeholder="inputPlaceholder"
  74. font-size="30rpx" :custom-style="customStyle" :readonly="disabledEdit">
  75. </uv-input>
  76. <ie-image v-if="disabledEdit" slot="right" src="/static/image/icon-lock.png" custom-class="w-24 h-30"
  77. mode="aspectFill" />
  78. </uv-form-item>
  79. </content-card>
  80. <content-card v-if="showSchoolInfo" title="学校信息">
  81. <uv-form-item label="学校名称" prop="form.campusName" borderBottom>
  82. <uv-input v-model="form.campusName" border="none" placeholder="" placeholderClass="text-30" font-size="30rpx"
  83. :custom-style="customStyle" readonly>
  84. </uv-input>
  85. <ie-image slot="right" src="/static/image/icon-lock.png" custom-class="w-24 h-30" mode="aspectFill" />
  86. </uv-form-item>
  87. <uv-form-item label="所在班级" prop="form.campusClassName">
  88. <uv-input v-model="form.campusClassName" border="none" placeholder="" placeholderClass="text-30"
  89. font-size="30rpx" :custom-style="customStyle" readonly>
  90. </uv-input>
  91. <ie-image slot="right" src="/static/image/icon-lock.png" custom-class="w-24 h-30" mode="aspectFill" />
  92. </uv-form-item>
  93. </content-card>
  94. </uv-form>
  95. <ie-safe-toolbar :height="84" :shadow="false">
  96. <view class="px-30 py-16">
  97. <ie-button @click="handleSubmit">确认提交</ie-button>
  98. </view>
  99. </ie-safe-toolbar>
  100. </ie-page>
  101. </template>
  102. <script lang="ts" setup>
  103. import ContentCard from '@/pagesSystem/components/content-card.vue';
  104. import { useExamType } from '@/composables/useExamType';
  105. import { updateUserInfo } from '@/api/modules/login';
  106. import { useUserStore } from '@/store/userStore';
  107. import { ClassItem, Scores, UserInfo } from '@/types/user';
  108. import { useTransferPage } from '@/hooks/useTransferPage';
  109. import { EnumExamType, EnumUserType } from '@/common/enum';
  110. import { getClassList } from '@/api/modules/user';
  111. const { prevData, transferTo, transferBack } = useTransferPage();
  112. const { form: examTypeForm, examTypeList, examMajorList, provinceList, endYearList } = useExamType();
  113. const userStore = useUserStore();
  114. const userInfo = computed(() => userStore.userInfo);
  115. const classList = ref<ClassItem[]>([]);
  116. const customStyle = {
  117. paddingLeft: '26px'
  118. };
  119. const inputPlaceholder = computed(() => {
  120. return true ? '请输入(提交后不可修改)' : '请输入';
  121. });
  122. const pickerPlaceholder = computed(() => {
  123. return true ? '请选择(提交后不可修改)' : '请选择';
  124. });
  125. const form = ref<UserInfo>({
  126. ...userInfo.value,
  127. });
  128. const scoresForm = ref<Scores>({})
  129. examTypeForm.value.location = form.value.location;
  130. examTypeForm.value.examType = form.value.examType;
  131. examTypeForm.value.endYear = form.value.endYear;
  132. examTypeForm.value.majorType = form.value.majorType;
  133. scoresForm.value = form.value.scores || {}
  134. const disabledEdit = computed(() => {
  135. return !!userInfo.value.location;
  136. })
  137. // 普高-文化成绩必填,保存后锁定不可修改
  138. // 中职务-文化成绩不填,保存后可修改
  139. const isScoreRequired = computed(() => examTypeForm.value.examType === EnumExamType.OHS);
  140. const showCulture = computed(() => {
  141. return examTypeForm.value.examType === EnumExamType.OHS;
  142. });
  143. // 代理机构不显示学校
  144. const showSchoolInfo = computed(() => userStore.userInfo.userType !== EnumUserType.AGENT);
  145. const handleBack = () => {
  146. if (disabledEdit.value) {
  147. transferBack();
  148. return;
  149. }
  150. uni.$ie.showToast('请先完善信息');
  151. };
  152. const loginValidate = () => {
  153. form.value = {
  154. ...form.value,
  155. ...examTypeForm.value,
  156. }
  157. const { nickName, location, examType, endYear } = form.value;
  158. if (!nickName || nickName.trim() === '') {
  159. uni.$ie.showToast('请输入姓名');
  160. return false;
  161. }
  162. if (!location || location.trim() === '') {
  163. uni.$ie.showToast('请选择省份');
  164. return false;
  165. }
  166. if (!examType || examType.trim() === '') {
  167. uni.$ie.showToast('请选择考生类别');
  168. return false;
  169. }
  170. if (examType === 'VHS') {
  171. if (!form.value.majorType) {
  172. uni.$ie.showToast('请选择专业类别');
  173. return false;
  174. }
  175. }
  176. if (!endYear) {
  177. uni.$ie.showToast('请选择毕业年份');
  178. return false;
  179. }
  180. if (showCulture.value) {
  181. if (isScoreRequired.value) {
  182. if (!scoresForm.value.chinese) {
  183. uni.$ie.showToast('请输入语文成绩');
  184. return false;
  185. }
  186. }
  187. if (scoresForm.value?.chinese && (scoresForm.value.chinese < 0 || scoresForm.value.chinese > 100)) {
  188. uni.$ie.showToast('请输入正确的语文成绩');
  189. return false;
  190. }
  191. //
  192. if (isScoreRequired.value) {
  193. if (!scoresForm.value.mathematics) {
  194. uni.$ie.showToast('请输入数学成绩');
  195. return false;
  196. }
  197. }
  198. if (scoresForm.value?.mathematics && (scoresForm.value.mathematics < 0 || scoresForm.value.mathematics > 100)) {
  199. uni.$ie.showToast('请输入正确的数学成绩');
  200. return false;
  201. }
  202. //
  203. if (isScoreRequired.value) {
  204. if (!scoresForm.value.foreign) {
  205. uni.$ie.showToast('请输入外语成绩');
  206. return false;
  207. }
  208. }
  209. if (scoresForm.value?.foreign && (scoresForm.value.foreign < 0 || scoresForm.value.foreign > 100)) {
  210. uni.$ie.showToast('请输入正确的外语成绩');
  211. return false;
  212. }
  213. //
  214. if (isScoreRequired.value) {
  215. if (!scoresForm.value.physics) {
  216. uni.$ie.showToast('请输入物理成绩');
  217. return false;
  218. }
  219. }
  220. if (scoresForm.value?.physics && (scoresForm.value.physics < 0 || scoresForm.value.physics > 100)) {
  221. uni.$ie.showToast('请输入正确的物理成绩');
  222. return false;
  223. }
  224. //
  225. if (isScoreRequired.value) {
  226. if (!scoresForm.value.political) {
  227. uni.$ie.showToast('请输入政治成绩');
  228. return false;
  229. }
  230. }
  231. if (scoresForm.value?.political && (scoresForm.value.political < 0 || scoresForm.value.political > 100)) {
  232. uni.$ie.showToast('请输入正确的政治成绩');
  233. return false;
  234. }
  235. }
  236. return true;
  237. }
  238. const handleExamTypeChange = () => {
  239. scoresForm.value = {};
  240. }
  241. const handleSubmit = async () => {
  242. console.log('handleSubmit', examTypeForm.value)
  243. if (!loginValidate()) {
  244. return;
  245. }
  246. const params = {
  247. ...userStore.userInfo,
  248. ...form.value,
  249. scores: scoresForm.value,
  250. } as UserInfo;
  251. console.log(params)
  252. uni.$ie.showLoading();
  253. await updateUserInfo(params);
  254. await userStore.getUserInfo();
  255. uni.$ie.hideLoading();
  256. uni.$ie.showToast('保存成功');
  257. setTimeout(() => {
  258. transferTo('/pagesMain/pages/index/index', {
  259. type: 'reLaunch'
  260. });
  261. }, 800);
  262. };
  263. </script>
  264. <style></style>