|
@@ -1,306 +0,0 @@
|
|
-<!-- 校验是否完善人才必填信息 -->
|
|
|
|
-<template>
|
|
|
|
- <scroll-view class="scrollBox" scroll-y="true">
|
|
|
|
- <view class="content">
|
|
|
|
- <view class="text-center ss-m-b-50 font-size-20 color-primary">请完善学生信息</view>
|
|
|
|
- <uni-forms
|
|
|
|
- ref="baseInfoRef"
|
|
|
|
- v-model="formData"
|
|
|
|
- :rules="formRules"
|
|
|
|
- validateTrigger="bind"
|
|
|
|
- label-width="90px"
|
|
|
|
- labelAlign="center"
|
|
|
|
- >
|
|
|
|
- <uni-forms-item label="头像" name="avatar" class="f-straight" required>
|
|
|
|
- <view style="display: flex;flex-wrap: wrap;">
|
|
|
|
- <view class="upload-img" v-if="formData?.avatar">
|
|
|
|
- <uni-icons size="35" type="clear" color="#fe574a" style="position: absolute;right: -15px; top: -15px; z-index: 9" @click="formData.avatar = ''"></uni-icons>
|
|
|
|
- <image :src="formData?.avatar" mode="contain" style="width: 200rpx;height: 200rpx;" @click="handlePreviewImage"></image>
|
|
|
|
- </view>
|
|
|
|
- <view v-else class="upload-file" @click="uploadPhotos">
|
|
|
|
- <uni-icons type="plusempty" size="50" color="#f1f1f1"></uni-icons>
|
|
|
|
- </view>
|
|
|
|
- </view>
|
|
|
|
- </uni-forms-item>
|
|
|
|
- <uni-forms-item name="name" label="姓名" required>
|
|
|
|
- <uni-easyinput placeholder="请输入姓名" v-model="formData.name" :inputBorder="false" type="text"></uni-easyinput>
|
|
|
|
- </uni-forms-item>
|
|
|
|
- <uni-forms-item name="sex" label="性别" required>
|
|
|
|
- <uni-data-picker v-model="formData.sex" :localdata="dictObj.sex" :clear-icon="false" popup-title="请选择性别" :map="{ text: 'label', value: 'value' }"></uni-data-picker>
|
|
|
|
- </uni-forms-item>
|
|
|
|
- <uni-forms-item name="idCardNo" label="身份证号码" required>
|
|
|
|
- <uni-easyinput placeholder="请输入身份证号码" v-model="formData.idCardNo" :inputBorder="false" type="text"></uni-easyinput>
|
|
|
|
- </uni-forms-item>
|
|
|
|
- <uni-forms-item name="phone" label="联系电话" required>
|
|
|
|
- <uni-easyinput placeholder="请输入联系电话" v-model="formData.phone" :inputBorder="false" type="number"></uni-easyinput>
|
|
|
|
- </uni-forms-item>
|
|
|
|
- <uni-forms-item required label="出生日期" name="birthday">
|
|
|
|
- <uni-datetime-picker type="date" return-type="timestamp" v-model="formData.birthday" />
|
|
|
|
- </uni-forms-item>
|
|
|
|
- <uni-forms-item name="schoolId" label="就读学校" required>
|
|
|
|
- <uni-data-picker v-model="formData.schoolId" :localdata="selects?.schools" :clear-icon="false" popup-title="请选择就读学校" @change="getSelectData(0)" :map="{ text: 'name', value: 'schoolId' }"></uni-data-picker>
|
|
|
|
- </uni-forms-item>
|
|
|
|
- <uni-forms-item name="schoolDeptId" label="所在院系" required>
|
|
|
|
- <uni-data-picker v-model="formData.schoolDeptId" :localdata="selects?.dept" :clear-icon="false" popup-title="请选择所在院系" @change="getSelectData(2)" :map="{ text: 'name', value: 'id' }"></uni-data-picker>
|
|
|
|
- </uni-forms-item>
|
|
|
|
- <uni-forms-item name="majorId" label="所学专业" required>
|
|
|
|
- <uni-data-picker v-model="formData.majorId" :localdata="selects?.major" :clear-icon="false" popup-title="请选择所学专业" @change="getSelectData(2)" :map="{ text: 'nameCn', value: 'id' }"></uni-data-picker>
|
|
|
|
- </uni-forms-item>
|
|
|
|
- <uni-forms-item name="schoolClassId" label="所在班级" required>
|
|
|
|
- <searchComBox ref="schoolClassIdRef" v-model="formData.schoolClassId" :candidates="classList" itemTextName='schoolClassName' itemValueName='schoolClassId' labelKey='name' valueKey='id' placeholder="请选择所在班级"></searchComBox>
|
|
|
|
- </uni-forms-item>
|
|
|
|
- <uni-forms-item name="studentNo" label="学号" required>
|
|
|
|
- <uni-easyinput placeholder="请填写学号" v-model="formData.studentNo" :inputBorder="false" type="text"></uni-easyinput>
|
|
|
|
- </uni-forms-item>
|
|
|
|
- <uni-forms-item name="emergencyContactName" label="紧急联系人姓名" required>
|
|
|
|
- <uni-easyinput placeholder="请填写紧急联系人姓名" v-model="formData.emergencyContactName" :inputBorder="false" type="text"></uni-easyinput>
|
|
|
|
- </uni-forms-item>
|
|
|
|
- <uni-forms-item name="emergencyContactPhone" label="紧急联系人手机号" required>
|
|
|
|
- <uni-easyinput placeholder="请填写紧急联系人手机号" v-model="formData.emergencyContactPhone" :inputBorder="false" type="number"></uni-easyinput>
|
|
|
|
- </uni-forms-item>
|
|
|
|
- </uni-forms>
|
|
|
|
- <view class="f-horizon-center">
|
|
|
|
- <button type="primary" size="default" class="send-button" @click="submit">提 交</button>
|
|
|
|
- </view>
|
|
|
|
- <view class="f-horizon-center">
|
|
|
|
- <view class="changeRole" @tap="handleLogout">退出登录</view>
|
|
|
|
- </view>
|
|
|
|
- </view>
|
|
|
|
- <uni-popup ref="logoutPopup" type="dialog">
|
|
|
|
- <uni-popup-dialog type="warn" cancelText="取消" confirmText="确定" title="系统提示" content="确认退出账号?" @confirm="handleLogoutConfirm" @close="handleLogoutClose">
|
|
|
|
- </uni-popup-dialog>
|
|
|
|
- </uni-popup>
|
|
|
|
- </scroll-view>
|
|
|
|
-</template>
|
|
|
|
-<script setup>
|
|
|
|
-import { ref, unref, onMounted, nextTick } from 'vue'
|
|
|
|
-import { mobile, isValidIdCard18 } from '@/utils/validate'
|
|
|
|
-import { dictObj } from '@/utils/position.js'
|
|
|
|
-import { saveStudentSimpleInfo } from '@/api/user'
|
|
|
|
-import { showAuthModal } from '@/hooks/useModal'
|
|
|
|
-import { userStore } from '@/store/user'; const useUserStore = userStore()
|
|
|
|
-import { uploadFile } from '@/api/file'
|
|
|
|
-import { getSchoolList, getDepartmentListBySchoolId, getMajorList } from '@/api/student'
|
|
|
|
-import searchComBox from '@/components/searchCombox'
|
|
|
|
-
|
|
|
|
-const baseInfoRef = ref()
|
|
|
|
-const formData = ref({ // 必填项目
|
|
|
|
- name: null,
|
|
|
|
- sex: null,
|
|
|
|
- idCardNo: null,
|
|
|
|
- phone: null,
|
|
|
|
- birthday: '1990-01-01',
|
|
|
|
- schoolId: null,
|
|
|
|
- schoolDeptId: null,
|
|
|
|
- majorId: null,
|
|
|
|
- schoolClassId: null,
|
|
|
|
- schoolClassName: null,
|
|
|
|
- studentNo: null,
|
|
|
|
- idCardNo: null,
|
|
|
|
- emergencyContactName: null,
|
|
|
|
- emergencyContactPhone: null,
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
-onMounted(() => {
|
|
|
|
- nextTick(() => {
|
|
|
|
- const baseInfo = useUserStore?.baseInfo || null
|
|
|
|
- if (baseInfo && Object.keys(baseInfo).length) {
|
|
|
|
- Object.keys(formData.value).forEach(key => {
|
|
|
|
- formData.value[key] = baseInfo[key] || baseInfo[key] === 0 ? baseInfo[key] : formData.value[key] ? formData.value[key] : null
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- if (!formData.value.phone && useUserStore?.phone) formData.value.phone = useUserStore.phone
|
|
|
|
- })
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
-// // 下拉列表
|
|
|
|
-const selects = ref({})
|
|
|
|
-const classList = ref([])
|
|
|
|
-const getSelectData = async (type = 'default', init = false) => { // type: 0院系|1专业|2班级
|
|
|
|
- const params = { ...(type !== 'default' && { type }) }
|
|
|
|
- // 查院系用 schoolId 查班级用 parentId
|
|
|
|
- if (type === 0) {
|
|
|
|
- if (!formData.value?.schoolId) return
|
|
|
|
- params.schoolId = formData.value.schoolId
|
|
|
|
- }
|
|
|
|
- if (type === 2) {
|
|
|
|
- if (!formData.value?.schoolId && !formData.value?.schoolDeptId) return
|
|
|
|
- if (formData.value?.schoolId) params.schoolId = formData.value.schoolId
|
|
|
|
- if (formData.value?.schoolDeptId) params.parentId = formData.value.schoolDeptId
|
|
|
|
- }
|
|
|
|
- const api = {
|
|
|
|
- default: getSchoolList,
|
|
|
|
- 0: getDepartmentListBySchoolId,
|
|
|
|
- 1: getMajorList,
|
|
|
|
- 2: getDepartmentListBySchoolId,
|
|
|
|
- }
|
|
|
|
- const res = await api[type](params)
|
|
|
|
- if (type === 'default') {
|
|
|
|
- selects.value.schools = res?.data?.length ? res.data : []
|
|
|
|
- }
|
|
|
|
- if (type === 0) {
|
|
|
|
- if (!init) {
|
|
|
|
- formData.value.schoolDeptId = null
|
|
|
|
- formData.value.schoolClassId = null
|
|
|
|
- }
|
|
|
|
- selects.value.dept = res?.data?.length ? res.data : []
|
|
|
|
- }
|
|
|
|
- if (type === 1) {
|
|
|
|
- selects.value.major = res?.data?.length ? res.data : []
|
|
|
|
- }
|
|
|
|
- if (type === 2) {
|
|
|
|
- if (!init) formData.value.schoolClassId = null
|
|
|
|
- classList.value = res?.data?.length ? res.data : []
|
|
|
|
- schoolClassIdRef.value && schoolClassIdRef.value.setLabel()
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-const getSelection = async () => {
|
|
|
|
- await getSelectData('default', true)
|
|
|
|
- await getSelectData(0, true)
|
|
|
|
- await getSelectData(1, true)
|
|
|
|
- await getSelectData(2, true)
|
|
|
|
-}
|
|
|
|
-getSelection()
|
|
|
|
-
|
|
|
|
-const formRules = {
|
|
|
|
- avatar:{
|
|
|
|
- rules: [{required: true, errorMessage: '请上传头像' }]
|
|
|
|
- },
|
|
|
|
- name:{
|
|
|
|
- rules: [{required: true, errorMessage: '请输入姓名' }]
|
|
|
|
- },
|
|
|
|
- sex: {
|
|
|
|
- rules: [{required: true, errorMessage: '请选择您的性别' }]
|
|
|
|
- },
|
|
|
|
- idCardNo: isValidIdCard18,
|
|
|
|
- phone: mobile,
|
|
|
|
- birthday:{
|
|
|
|
- rules: [{required: true, errorMessage: '请选择出生日期' }]
|
|
|
|
- },
|
|
|
|
- schoolId:{
|
|
|
|
- rules: [{required: true, errorMessage: '请选择就读学校' }]
|
|
|
|
- },
|
|
|
|
- schoolDeptId:{
|
|
|
|
- rules: [{required: true, errorMessage: '请选择所在院系' }]
|
|
|
|
- },
|
|
|
|
- majorId: {
|
|
|
|
- rules: [{required: true, errorMessage: '请填写所在专业' }]
|
|
|
|
- },
|
|
|
|
- schoolClassId: {
|
|
|
|
- rules: [{required: true, errorMessage: '请填写所在班级' }]
|
|
|
|
- },
|
|
|
|
- studentNo: {
|
|
|
|
- rules: [{required: true, errorMessage: '请填写学号' }]
|
|
|
|
- },
|
|
|
|
- emergencyContactName: {
|
|
|
|
- rules: [{required: true, errorMessage: '请填写紧急联系人姓名' }]
|
|
|
|
- },
|
|
|
|
- emergencyContactPhone: mobile,
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-const logoutPopup = ref()
|
|
|
|
-// 退出登录
|
|
|
|
-const handleLogout = () => {
|
|
|
|
- logoutPopup.value.open()
|
|
|
|
-}
|
|
|
|
-const handleLogoutClose = () => {
|
|
|
|
- logoutPopup.value.close()
|
|
|
|
-}
|
|
|
|
-const handleLogoutConfirm = async () => {
|
|
|
|
- await useUserStore.handleLogout()
|
|
|
|
- showAuthModal()
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// 图片预览
|
|
|
|
-const handlePreviewImage = () => {
|
|
|
|
- uni.previewImage({
|
|
|
|
- current: 0,
|
|
|
|
- urls: [formData.value.avatar]
|
|
|
|
- })
|
|
|
|
-}
|
|
|
|
-// 选择头像
|
|
|
|
-const uploadPhotos = () => {
|
|
|
|
- wx.chooseImage({
|
|
|
|
- count: 1,
|
|
|
|
- sizeType: ['original', 'compressed'],
|
|
|
|
- sourceType: ['album', 'camera'],
|
|
|
|
- success: function(res){
|
|
|
|
- const size = res.tempFiles[0]?.size || 0
|
|
|
|
- if (size >= 31457280) {
|
|
|
|
- uni.showToast({
|
|
|
|
- icon: 'none',
|
|
|
|
- title: '头像上传大小不得超过 20MB !',
|
|
|
|
- duration: 2000
|
|
|
|
- })
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- const path = res.tempFilePaths[0]
|
|
|
|
- uploadFile(path, 'img').then(res => {
|
|
|
|
- formData.value.avatar = res.data
|
|
|
|
- }).catch(error => {
|
|
|
|
- uni.showToast({
|
|
|
|
- icon: 'error',
|
|
|
|
- title: '图片上传失败!',
|
|
|
|
- duration: 2000
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-const schoolClassIdRef = ref()
|
|
|
|
-const submit = async () => {
|
|
|
|
- const validate = await unref(baseInfoRef).validate()
|
|
|
|
- if (!validate) return uni.showToast({ title: '请将信息补充完整', icon: 'none' })
|
|
|
|
-
|
|
|
|
- let params = {...formData.value}
|
|
|
|
-
|
|
|
|
- const schoolClassObj = schoolClassIdRef.value?.getValue()
|
|
|
|
- params = {...params, ...schoolClassObj}
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- await saveStudentSimpleInfo(params)
|
|
|
|
- uni.showToast({ title: '保存成功', icon: 'none' })
|
|
|
|
- await useUserStore.getInfo()
|
|
|
|
- } catch (err) {
|
|
|
|
- uni.showToast({ title: err?.msg || '保存失败', icon: 'none' })
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-</script>
|
|
|
|
-<style lang="scss" scoped>
|
|
|
|
-.scrollBox {
|
|
|
|
- width: 100vw;
|
|
|
|
- // height: 100vh;
|
|
|
|
- height: calc(100vh - 30rpx);
|
|
|
|
- margin-bottom: 30rpx;
|
|
|
|
-}
|
|
|
|
-.content {
|
|
|
|
- padding: 30rpx;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-.changeRole {
|
|
|
|
- color: var(--color-666);
|
|
|
|
- font-size: 15px;
|
|
|
|
- line-height: 26px;
|
|
|
|
- margin-bottom: 40rpx;
|
|
|
|
-}
|
|
|
|
-.upload-img{
|
|
|
|
- position: relative;
|
|
|
|
- width: 200rpx;
|
|
|
|
- height: 200rpx;
|
|
|
|
- border: 1px solid #f1f1f1;
|
|
|
|
- margin: 10rpx;
|
|
|
|
-}
|
|
|
|
-.upload-file{
|
|
|
|
- width: 200rpx;
|
|
|
|
- height: 200rpx;
|
|
|
|
- border: 1px solid #f1f1f1;
|
|
|
|
- margin: 10rpx;
|
|
|
|
- display: flex;
|
|
|
|
- justify-content: center;
|
|
|
|
- align-items: center;
|
|
|
|
- border-radius: 10rpx;
|
|
|
|
-}
|
|
|
|
-</style>
|
|
|