请假功能内容修改
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view class="form-container">
|
||||
<view class="form-title">2025-2026学年学生宿舍入住收集表</view>
|
||||
<view class="form-title">学生宿舍入住收集表</view>
|
||||
<view class="form-desc">涉及住宿费核算,请同学们按照实际入住情况填写。</view>
|
||||
|
||||
<!-- 1. 校区 -->
|
||||
@@ -81,6 +81,16 @@
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<view class="item-label">中国农业银行卡号</view>
|
||||
<input class="input" v-model="form.xhk" placeholder="请输入中国农业银行卡号" />
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<view class="item-label">开户行</view>
|
||||
<input class="input" v-model="form.bankAddr" placeholder="请输入开户行" />
|
||||
</view>
|
||||
|
||||
<!-- 9. 本人证件照 -->
|
||||
<view class="form-item">
|
||||
<view class="item-label">
|
||||
@@ -103,408 +113,530 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
listAllCampus,
|
||||
listParkByCampus,
|
||||
listBuildingByPark,
|
||||
listFloorByBuilding,
|
||||
listAllRoomByFloor,
|
||||
addStudent,
|
||||
submitOwnInfo as submitExtraInfo
|
||||
} from "@/api/dms/studentDormInfo/index.js"
|
||||
import {
|
||||
getUserProfile
|
||||
} from '@/api/system/user'
|
||||
import {
|
||||
previewImg
|
||||
} from "@/utils/uploadImg.js"
|
||||
import {
|
||||
checkPic
|
||||
} from "@/utils/checkPic.js"
|
||||
import uploadFile from "@/plugins/upload.js";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
user: [],
|
||||
form: {
|
||||
campusName: '',
|
||||
parkName: '',
|
||||
buildingName: '',
|
||||
floorName: '',
|
||||
roomNo: '',
|
||||
stuNo: '',
|
||||
isDormitoryHead: '',
|
||||
isDormHead: '',
|
||||
checkinTime: '',
|
||||
photo: '',
|
||||
teacherName: '',
|
||||
className: '',
|
||||
deptName: '',
|
||||
stuName: '',
|
||||
displayText: '',
|
||||
isInStudentsleep: '是',
|
||||
photoData: ''
|
||||
},
|
||||
// 校区选项
|
||||
campusOptions: [],
|
||||
// 园区选项(按校区联动)
|
||||
parkOptions: [],
|
||||
// 楼栋选项(按园区联动)
|
||||
buildingOptions: [],
|
||||
// 楼层选项(下拉框)
|
||||
floorOptions: [],
|
||||
// 宿舍号选项(下拉框)
|
||||
dormOptions: [],
|
||||
// 宿舍长选项
|
||||
dormHeadOptions: ['否', '是'],
|
||||
// 当前选中项的id
|
||||
selectedCampus: null, // 选中的校区({id, name})
|
||||
selectedPark: null, // 选中的园区
|
||||
selectedBuilding: null, // 选中的楼栋
|
||||
selectedFloor: null, // 选中的楼层
|
||||
selectedDorm: null, //选中的宿舍
|
||||
};
|
||||
import {
|
||||
addStudent,
|
||||
listAllCampus,
|
||||
listAllRoomByFloor,
|
||||
listBuildingByPark,
|
||||
listFloorByBuilding,
|
||||
listParkByCampus,
|
||||
submitOwnInfo as submitExtraInfo,
|
||||
getStudentDetail,
|
||||
updateStudent
|
||||
} from "@/api/dms/studentDormInfo/index.js";
|
||||
import { alipayVali } from "@/api/helpFunc/bank.js";
|
||||
import {
|
||||
getUserProfile
|
||||
} from '@/api/system/user';
|
||||
import uploadFile from "@/plugins/upload.js";
|
||||
import config from '@/config'
|
||||
import {
|
||||
checkPic
|
||||
} from "@/utils/checkPic.js";
|
||||
import request from "@/utils/request";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
user: [],
|
||||
form: {
|
||||
campusName: '',
|
||||
parkName: '',
|
||||
buildingName: '',
|
||||
floorName: '',
|
||||
roomNo: '',
|
||||
stuNo: '',
|
||||
isDormitoryHead: '',
|
||||
isDormHead: '',
|
||||
checkinTime: '',
|
||||
photo: '',
|
||||
xhk: '',
|
||||
bankAddr: '',
|
||||
teacherName: '',
|
||||
className: '',
|
||||
deptName: '',
|
||||
stuName: '',
|
||||
displayText: '',
|
||||
isInStudentsleep: '是',
|
||||
photoData: ''
|
||||
},
|
||||
// 校区选项
|
||||
campusOptions: [],
|
||||
// 园区选项(按校区联动)
|
||||
parkOptions: [],
|
||||
// 楼栋选项(按园区联动)
|
||||
buildingOptions: [],
|
||||
// 楼层选项(下拉框)
|
||||
floorOptions: [],
|
||||
// 宿舍号选项(下拉框)
|
||||
dormOptions: [],
|
||||
// 宿舍长选项
|
||||
dormHeadOptions: ['否', '是'],
|
||||
// 当前选中项的id
|
||||
selectedCampus: null, // 选中的校区({id, name})
|
||||
selectedPark: null, // 选中的园区
|
||||
selectedBuilding: null, // 选中的楼栋
|
||||
selectedFloor: null, // 选中的楼层
|
||||
selectedDorm: null, //选中的宿舍
|
||||
mode: 'add',
|
||||
editId: null
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
this.getUserProfile()
|
||||
this.listAllCampus()
|
||||
if (options && options.mode === 'edit' && options.id) {
|
||||
this.mode = 'edit'
|
||||
this.editId = Number(options.id)
|
||||
this.initEdit(this.editId)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 获取用户信息
|
||||
async getUserProfile() {
|
||||
try {
|
||||
const res = await getUserProfile()
|
||||
this.user = res
|
||||
this.form.stuNo = this.user.data.userName
|
||||
console.log('当前用户信息:', res)
|
||||
} catch (err) {
|
||||
console.error('获取用户信息失败:', err)
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.getUserProfile()
|
||||
this.listAllCampus()
|
||||
// 获取校区数据
|
||||
async listAllCampus() {
|
||||
let res = await listAllCampus()
|
||||
if (res.code == 200) {
|
||||
this.campusOptions = [...res.data]
|
||||
}
|
||||
},
|
||||
// 编辑模式初始化
|
||||
async initEdit(id) {
|
||||
try {
|
||||
const res = await getStudentDetail(id)
|
||||
if (res.code !== 200) {
|
||||
uni.showToast({ title: '加载详情失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const d = res.data
|
||||
this.form.stuNo = d.stuNo || this.form.stuNo
|
||||
this.form.isDormHead = d.isDormitoryHead === 1 ? '是' : '否'
|
||||
this.form.checkinTime = d.checkinTime ? String(d.checkinTime).slice(0, 10) : ''
|
||||
this.form.isInStudentsleep = d.isInStudentsleep || this.form.isInStudentsleep
|
||||
|
||||
const own = await request({ url: '/system/student/getOwnInfo', method: 'get' })
|
||||
if (own && own.data) {
|
||||
this.form.xhk = own.data.xhk || ''
|
||||
this.form.bankAddr = own.data.bankAddr || ''
|
||||
}
|
||||
|
||||
const extra = await request({ url: '/comprehensive/extraInfo/getOwnInfo', method: 'get' })
|
||||
if (extra && extra.data) {
|
||||
this.form.photo = extra.data.whitePhoto || ''
|
||||
this.form.photoData = extra.data.whitePhoto ? (config.baseUrl + extra.data.whitePhoto) : ''
|
||||
}
|
||||
|
||||
const campusName = d.campusName
|
||||
const parkName = d.parkName
|
||||
const buildingName = d.buildingName
|
||||
const floorName = d.floorName
|
||||
const roomNo = d.roomNo
|
||||
|
||||
const campus = this.campusOptions.find(c => c.name === campusName)
|
||||
if (campus) {
|
||||
this.form.campusName = campus.name
|
||||
this.selectedCampus = campus.id
|
||||
await this.listParkByCampus(this.selectedCampus)
|
||||
const park = this.parkOptions.find(p => p.name === parkName)
|
||||
if (park) {
|
||||
this.form.parkName = park.name
|
||||
this.selectedPark = park.id
|
||||
await this.listBuildingByPark(this.selectedPark)
|
||||
const building = this.buildingOptions.find(b => b.name === buildingName)
|
||||
if (building) {
|
||||
this.form.buildingName = building.name
|
||||
this.selectedBuilding = building.id
|
||||
await this.listFloorByBuilding(this.selectedBuilding)
|
||||
let floor = this.floorOptions.find(f => String(f.floor) === String(floorName))
|
||||
if (!floor) {
|
||||
for (const f of this.floorOptions) {
|
||||
await this.listAllRoomByFloor(f.id)
|
||||
const dormTry = this.dormOptions.find(r => r.roomNo === roomNo)
|
||||
if (dormTry) {
|
||||
floor = f
|
||||
this.selectedDorm = dormTry.id
|
||||
this.form.roomNo = dormTry.roomNo
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if (floor) {
|
||||
this.form.floorName = floor.floor
|
||||
this.selectedFloor = floor.id
|
||||
if (!this.selectedDorm) {
|
||||
await this.listAllRoomByFloor(this.selectedFloor)
|
||||
const dorm = this.dormOptions.find(r => r.roomNo === roomNo)
|
||||
if (dorm) {
|
||||
this.form.roomNo = dorm.roomNo
|
||||
this.selectedDorm = dorm.id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
},
|
||||
// 根据校区id获取园区
|
||||
async listParkByCampus(id) {
|
||||
let res = await listParkByCampus(id)
|
||||
if (res.code == 200) {
|
||||
this.parkOptions = [...res.data]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 获取用户信息
|
||||
async getUserProfile() {
|
||||
try {
|
||||
const res = await getUserProfile()
|
||||
this.user = res
|
||||
this.form.stuNo = this.user.data.userName
|
||||
console.log('当前用户信息:', res)
|
||||
} catch (err) {
|
||||
console.error('获取用户信息失败:', err)
|
||||
}
|
||||
},
|
||||
// 获取校区数据
|
||||
async listAllCampus() {
|
||||
let res = await listAllCampus()
|
||||
if (res.code == 200) {
|
||||
this.campusOptions = [...res.data]
|
||||
}
|
||||
},
|
||||
// 根据校区id获取园区
|
||||
async listParkByCampus(id) {
|
||||
let res = await listParkByCampus(id)
|
||||
if (res.code == 200) {
|
||||
this.parkOptions = [...res.data]
|
||||
}
|
||||
},
|
||||
// 根据园区id获取楼栋
|
||||
async listBuildingByPark(id) {
|
||||
let res = await listBuildingByPark(id)
|
||||
if (res.code == 200) {
|
||||
this.buildingOptions = [...res.data]
|
||||
}
|
||||
},
|
||||
// 根据楼栋id获取楼层
|
||||
async listFloorByBuilding(id) {
|
||||
let res = await listFloorByBuilding(id)
|
||||
if (res.code == 200) {
|
||||
this.floorOptions = [...res.data]
|
||||
}
|
||||
},
|
||||
// 根据楼层id获取宿舍号
|
||||
async listAllRoomByFloor(id) {
|
||||
let res = await listAllRoomByFloor(id)
|
||||
if (res.code == 200) {
|
||||
this.dormOptions = [...res.data]
|
||||
// 遍历数据,为每个对象添加 displayText 属性
|
||||
this.dormOptions = res.data.map(v => ({
|
||||
...v, // 保留原对象所有属性
|
||||
// 新增拼接后的显示文本属性
|
||||
displayText: `${v.roomNo} -- ${v.gender} -- 床位 ${v.bedNum} -- 已住 ${v.occupancy}`,
|
||||
isFull: v.occupancy >= v.bedNum // 新增:判断是否满人
|
||||
}));
|
||||
}
|
||||
},
|
||||
// 校区选择变化
|
||||
handleCampusChange(e) {
|
||||
this.form.campusName = this.campusOptions[e.detail.value].name;
|
||||
this.form.parkName = ''; // 重置园区
|
||||
this.form.buildingName = ''; // 重置楼栋
|
||||
this.form.floorName = ''; // 重置楼层
|
||||
this.form.roomNo = ''; // 重置宿舍
|
||||
// 获取选中的校区id
|
||||
this.selectedCampus = this.campusOptions[e.detail.value].id;
|
||||
// 获取对应校区下面的园区
|
||||
this.listParkByCampus(this.selectedCampus)
|
||||
},
|
||||
// 园区选择变化
|
||||
handleParkChange(e) {
|
||||
this.form.parkName = this.parkOptions[e.detail.value].name;
|
||||
this.form.buildingName = ''; // 重置楼栋
|
||||
this.form.floorName = ''; // 重置楼层
|
||||
this.form.roomNo = ''; // 重置宿舍
|
||||
// 获取选中的园区的id
|
||||
this.selectedPark = this.parkOptions[e.detail.value].id;
|
||||
// 获取对应园区下面的楼栋
|
||||
this.listBuildingByPark(this.selectedPark)
|
||||
},
|
||||
// 楼栋选择变化
|
||||
handleBuildingChange(e) {
|
||||
this.form.buildingName = this.buildingOptions[e.detail.value].name;
|
||||
this.form.floorName = ''; // 重置楼层
|
||||
this.form.roomNo = ''; // 重置宿舍
|
||||
// 获取选中的楼栋的id
|
||||
this.selectedBuilding = this.buildingOptions[e.detail.value].id;
|
||||
// 获取选中的楼栋下面的楼层
|
||||
this.listFloorByBuilding(this.selectedBuilding)
|
||||
},
|
||||
// 楼层选择变化(下拉框)
|
||||
handleFloorChange(e) {
|
||||
this.form.floorName = this.floorOptions[e.detail.value].floor;
|
||||
this.form.roomNo = ''; // 重置宿舍
|
||||
// 获取选中的楼层的id
|
||||
this.selectedFloor = this.floorOptions[e.detail.value].id;
|
||||
// 获取选中的楼层下面的宿舍号
|
||||
this.listAllRoomByFloor(this.selectedFloor)
|
||||
},
|
||||
// 宿舍号选择变化(行拉框)
|
||||
handleDormChange(e) {
|
||||
const index = e.detail.value;
|
||||
const selectedDorm = this.dormOptions[index]; // 获取选中的宿舍对象
|
||||
// 根据园区id获取楼栋
|
||||
async listBuildingByPark(id) {
|
||||
let res = await listBuildingByPark(id)
|
||||
if (res.code == 200) {
|
||||
this.buildingOptions = [...res.data]
|
||||
}
|
||||
},
|
||||
// 根据楼栋id获取楼层
|
||||
async listFloorByBuilding(id) {
|
||||
let res = await listFloorByBuilding(id)
|
||||
if (res.code == 200) {
|
||||
this.floorOptions = [...res.data]
|
||||
}
|
||||
},
|
||||
// 根据楼层id获取宿舍号
|
||||
async listAllRoomByFloor(id) {
|
||||
let res = await listAllRoomByFloor(id)
|
||||
if (res.code == 200) {
|
||||
this.dormOptions = [...res.data]
|
||||
// 遍历数据,为每个对象添加 displayText 属性
|
||||
this.dormOptions = res.data.map(v => ({
|
||||
...v, // 保留原对象所有属性
|
||||
// 新增拼接后的显示文本属性
|
||||
displayText: `${v.roomNo} -- ${v.gender} -- 床位 ${v.bedNum} -- 已住 ${v.occupancy}`,
|
||||
isFull: v.occupancy >= v.bedNum // 新增:判断是否满人
|
||||
}));
|
||||
}
|
||||
},
|
||||
// 校区选择变化
|
||||
handleCampusChange(e) {
|
||||
this.form.campusName = this.campusOptions[e.detail.value].name;
|
||||
this.form.parkName = ''; // 重置园区
|
||||
this.form.buildingName = ''; // 重置楼栋
|
||||
this.form.floorName = ''; // 重置楼层
|
||||
this.form.roomNo = ''; // 重置宿舍
|
||||
// 获取选中的校区id
|
||||
this.selectedCampus = this.campusOptions[e.detail.value].id;
|
||||
// 获取对应校区下面的园区
|
||||
this.listParkByCampus(this.selectedCampus)
|
||||
},
|
||||
// 园区选择变化
|
||||
handleParkChange(e) {
|
||||
this.form.parkName = this.parkOptions[e.detail.value].name;
|
||||
this.form.buildingName = ''; // 重置楼栋
|
||||
this.form.floorName = ''; // 重置楼层
|
||||
this.form.roomNo = ''; // 重置宿舍
|
||||
// 获取选中的园区的id
|
||||
this.selectedPark = this.parkOptions[e.detail.value].id;
|
||||
// 获取对应园区下面的楼栋
|
||||
this.listBuildingByPark(this.selectedPark)
|
||||
},
|
||||
// 楼栋选择变化
|
||||
handleBuildingChange(e) {
|
||||
this.form.buildingName = this.buildingOptions[e.detail.value].name;
|
||||
this.form.floorName = ''; // 重置楼层
|
||||
this.form.roomNo = ''; // 重置宿舍
|
||||
// 获取选中的楼栋的id
|
||||
this.selectedBuilding = this.buildingOptions[e.detail.value].id;
|
||||
// 获取选中的楼栋下面的楼层
|
||||
this.listFloorByBuilding(this.selectedBuilding)
|
||||
},
|
||||
// 楼层选择变化(下拉框)
|
||||
handleFloorChange(e) {
|
||||
this.form.floorName = this.floorOptions[e.detail.value].floor;
|
||||
this.form.roomNo = ''; // 重置宿舍
|
||||
// 获取选中的楼层的id
|
||||
this.selectedFloor = this.floorOptions[e.detail.value].id;
|
||||
// 获取选中的楼层下面的宿舍号
|
||||
this.listAllRoomByFloor(this.selectedFloor)
|
||||
},
|
||||
// 宿舍号选择变化(行拉框)
|
||||
handleDormChange(e) {
|
||||
const index = e.detail.value;
|
||||
const selectedDorm = this.dormOptions[index]; // 获取选中的宿舍对象
|
||||
|
||||
// 判断是否满人
|
||||
if (selectedDorm.isFull) {
|
||||
// 满人时提示并重置选择
|
||||
uni.showToast({
|
||||
title: `宿舍 ${selectedDorm.roomNo} 已住满,无法选择`,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
// 重置宿舍选择(如果之前有选中值则保留,否则为空)
|
||||
if (!this.form.roomNo) {
|
||||
this.form.roomNo = '';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 未满人时正常选中
|
||||
this.form.roomNo = selectedDorm.roomNo; // 显示拼接文本
|
||||
this.selectedDorm = selectedDorm.id; // 存储宿舍ID(用于提交)
|
||||
},
|
||||
// 宿舍长选择变化
|
||||
handleDormHeadChange(e) {
|
||||
this.form.isDormitoryHead = this.dormHeadOptions[e.detail.value] == '是' ? 1 : 0;
|
||||
this.form.isDormHead = this.dormHeadOptions[e.detail.value]
|
||||
},
|
||||
// 入住时间选择变化
|
||||
handleCheckinTimeChange(e) {
|
||||
this.form.checkinTime = e.detail.value;
|
||||
},
|
||||
// 证件照上传
|
||||
handleUpload() {
|
||||
uni.chooseImage({
|
||||
count: 3,
|
||||
success: async (img) => {
|
||||
let bool = await checkPic(img.tempFiles[0]);
|
||||
if (bool) {
|
||||
uploadFile('/common/upload', img.tempFilePaths[0]).then((res) => {
|
||||
// if (this.form.photo !== "") {
|
||||
// this.form.photo = this.form.photo + "," + JSON.parse(res)
|
||||
// .fileName;
|
||||
// } else {
|
||||
// this.form.photo = JSON.parse(res).fileName;
|
||||
// }
|
||||
this.form.photoData = img.tempFilePaths[0];
|
||||
this.form.photo = JSON.parse(res).fileName;
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
// 提交表单
|
||||
async handleSubmit() {
|
||||
console.log(this.form);
|
||||
// 验证必填项
|
||||
if (
|
||||
!this.form.campusName || // 校区名称(字符串,空则false)
|
||||
!this.form.parkName || // 园区名称(字符串,空则false)
|
||||
!this.form.buildingName || // 楼栋名称(字符串,空则false)
|
||||
(!this.form.floorName && this.form.floorName !== 0) || // 楼层(数值,排除0的误判)
|
||||
(!this.form.roomNo && this.form.roomNo !== 0) || // 宿舍号(数值,排除0的误判)
|
||||
!this.form.isDormHead || // 是否宿舍长(值为"是"/"否")
|
||||
!this.form.checkinTime || // 入住时间(日期字符串,空则false)
|
||||
!this.form.photo // 证件照(blob路径,空则false,若必填需加)
|
||||
) {
|
||||
uni.showToast({
|
||||
title: '带*号的为必填项,请填写完整',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.form.dormitoryId = this.selectedDorm;
|
||||
// 模拟提交
|
||||
uni.showLoading({
|
||||
title: '提交中...'
|
||||
// 判断是否满人
|
||||
if (selectedDorm.isFull) {
|
||||
// 满人时提示并重置选择
|
||||
uni.showToast({
|
||||
title: `宿舍 ${selectedDorm.roomNo} 已住满,无法选择`,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
// 添加入住信息
|
||||
let res = await addStudent(this.form);
|
||||
if (res.code == 200) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '提交成功',
|
||||
icon: 'success'
|
||||
});
|
||||
// 上次图片头像
|
||||
let data = submitExtraInfo({
|
||||
userId: this.user.data.userId,
|
||||
whitePhoto: this.form.photo
|
||||
})
|
||||
// if (data.code == 200) {
|
||||
// console.log(data);
|
||||
// }
|
||||
|
||||
setTimeout(() => {
|
||||
// 重置表单
|
||||
this.form = {
|
||||
campusName: '',
|
||||
parkName: '',
|
||||
buildingName: '',
|
||||
floorName: '',
|
||||
roomNo: '',
|
||||
stuNo: '',
|
||||
isDormitoryHead: '',
|
||||
checkinTime: '',
|
||||
photo: ''
|
||||
};
|
||||
uni.redirectTo({
|
||||
url: `/pages/dormitory/studentDormInfo/index`
|
||||
// 重置宿舍选择(如果之前有选中值则保留,否则为空)
|
||||
if (!this.form.roomNo) {
|
||||
this.form.roomNo = '';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 未满人时正常选中
|
||||
this.form.roomNo = selectedDorm.roomNo; // 显示拼接文本
|
||||
this.selectedDorm = selectedDorm.id; // 存储宿舍ID(用于提交)
|
||||
},
|
||||
// 宿舍长选择变化
|
||||
handleDormHeadChange(e) {
|
||||
this.form.isDormitoryHead = this.dormHeadOptions[e.detail.value] == '是' ? 1 : 0;
|
||||
this.form.isDormHead = this.dormHeadOptions[e.detail.value]
|
||||
},
|
||||
// 入住时间选择变化
|
||||
handleCheckinTimeChange(e) {
|
||||
this.form.checkinTime = e.detail.value;
|
||||
},
|
||||
// 证件照上传
|
||||
handleUpload() {
|
||||
uni.chooseImage({
|
||||
count: 3,
|
||||
success: async (img) => {
|
||||
let bool = await checkPic(img.tempFiles[0]);
|
||||
if (bool) {
|
||||
uploadFile('/common/upload', img.tempFilePaths[0]).then((res) => {
|
||||
// if (this.form.photo !== "") {
|
||||
// this.form.photo = this.form.photo + "," + JSON.parse(res)
|
||||
// .fileName;
|
||||
// } else {
|
||||
// this.form.photo = JSON.parse(res).fileName;
|
||||
// }
|
||||
this.form.photoData = img.tempFilePaths[0];
|
||||
this.form.photo = JSON.parse(res).fileName;
|
||||
})
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
// 提交表单
|
||||
async handleSubmit() {
|
||||
console.log(this.form);
|
||||
// 验证必填项
|
||||
if (
|
||||
!this.form.campusName || // 校区名称(字符串,空则false)
|
||||
!this.form.parkName || // 园区名称(字符串,空则false)
|
||||
!this.form.buildingName || // 楼栋名称(字符串,空则false)
|
||||
(!this.form.floorName && this.form.floorName !== 0) || // 楼层(数值,排除0的误判)
|
||||
(!this.form.roomNo && this.form.roomNo !== 0) || // 宿舍号(数值,排除0的误判)
|
||||
!this.form.isDormHead || // 是否宿舍长(值为"是"/"否")
|
||||
!this.form.checkinTime || // 入住时间(日期字符串,空则false)
|
||||
!this.form.photo
|
||||
) {
|
||||
uni.showToast({
|
||||
title: '带*号的为必填项,请填写完整',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.form.xhk) {
|
||||
let cardRes = await alipayVali(this.form.xhk);
|
||||
if (!cardRes || cardRes.validated == false) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的银行卡号',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (cardRes.bank != 'ABC') {
|
||||
uni.showToast({
|
||||
title: '请输入正确的中国农业银行银行卡号',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
this.form.dormitoryId = this.selectedDorm;
|
||||
uni.showLoading({ title: '提交中...' });
|
||||
let res;
|
||||
if (this.mode === 'edit') {
|
||||
const dto = {
|
||||
id: this.editId,
|
||||
dormitoryId: this.form.dormitoryId,
|
||||
stuNo: this.form.stuNo,
|
||||
isDormitoryHead: this.form.isDormHead === '是' ? 1 : 0,
|
||||
checkinTime: this.form.checkinTime ? new Date(this.form.checkinTime) : null,
|
||||
isInStudentsleep: this.form.isInStudentsleep || '是'
|
||||
}
|
||||
res = await updateStudent(dto)
|
||||
} else {
|
||||
res = await addStudent(this.form);
|
||||
}
|
||||
if (res.code == 200) {
|
||||
// 上次图片头像
|
||||
let data = submitExtraInfo({
|
||||
userId: this.user.data.userId,
|
||||
whitePhoto: this.form.photo
|
||||
})
|
||||
let own = await request({ url: '/system/student/getOwnInfo', method: 'get' });
|
||||
let payload = {
|
||||
phone: own.data.phone,
|
||||
xhk: this.form.xhk ? this.form.xhk.replace(' ', '') : own.data.xhk,
|
||||
idCard: own.data.idCard,
|
||||
birthday: own.data.birthday,
|
||||
bankAddr: this.form.bankAddr ? this.form.bankAddr : own.data.bankAddr
|
||||
};
|
||||
await request({ url: '/system/student/changeOwnInfo', method: 'POST', data: payload });
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '提交成功', icon: 'success' });
|
||||
// if (data.code == 200) {
|
||||
// console.log(data);
|
||||
// }
|
||||
|
||||
setTimeout(() => {
|
||||
// 重置表单
|
||||
this.form = {
|
||||
campusName: '',
|
||||
parkName: '',
|
||||
buildingName: '',
|
||||
floorName: '',
|
||||
roomNo: '',
|
||||
stuNo: '',
|
||||
isDormitoryHead: '',
|
||||
checkinTime: '',
|
||||
photo: '',
|
||||
xhk: '',
|
||||
bankAddr: ''
|
||||
};
|
||||
uni.redirectTo({ url: `/pages/dormitory/studentDormInfo/index` })
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.form-container {
|
||||
padding: 30rpx;
|
||||
background-color: #fff;
|
||||
min-height: 100vh;
|
||||
}
|
||||
.form-container {
|
||||
padding: 30rpx;
|
||||
background-color: #fff;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.form-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.form-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.form-desc {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
text-align: center;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
.form-desc {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
text-align: center;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.form-item {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
.form-item {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.item-label {
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
margin-bottom: 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.item-label {
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
margin-bottom: 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
// 红色*号样式
|
||||
.required {
|
||||
color: #ff4d4f;
|
||||
margin-right: 6rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
// 红色*号样式
|
||||
.required {
|
||||
color: #ff4d4f;
|
||||
margin-right: 6rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.item-desc {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.item-desc {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
// 下拉框样式
|
||||
.picker-input {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 8rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 20rpx;
|
||||
box-sizing: border-box;
|
||||
font-size: 28rpx;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
// 下拉框样式
|
||||
.picker-input {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 8rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 20rpx;
|
||||
box-sizing: border-box;
|
||||
font-size: 28rpx;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
// 输入框样式
|
||||
.input {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 8rpx;
|
||||
padding: 0 20rpx;
|
||||
box-sizing: border-box;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
// 输入框样式
|
||||
.input {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 8rpx;
|
||||
padding: 0 20rpx;
|
||||
box-sizing: border-box;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
// 图片上传样式
|
||||
.upload-btn {
|
||||
width: 200rpx;
|
||||
height: 80rpx;
|
||||
border: 1px dashed #ccc;
|
||||
border-radius: 8rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
// 图片上传样式
|
||||
.upload-btn {
|
||||
width: 200rpx;
|
||||
height: 80rpx;
|
||||
border: 1px dashed #ccc;
|
||||
border-radius: 8rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.upload-icon {
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
.upload-icon {
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.upload-tip {
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.upload-tip {
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.upload-preview {
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
border-radius: 8rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
.upload-preview {
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
border-radius: 8rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.upload-preview image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.upload-preview image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
// 提交按钮样式
|
||||
.submit-btn {
|
||||
width: 100%;
|
||||
height: 90rpx;
|
||||
background-color: #1890ff;
|
||||
color: #fff;
|
||||
font-size: 32rpx;
|
||||
border-radius: 45rpx;
|
||||
margin-top: 60rpx;
|
||||
}
|
||||
// 提交按钮样式
|
||||
.submit-btn {
|
||||
width: 100%;
|
||||
height: 90rpx;
|
||||
background-color: #1890ff;
|
||||
color: #fff;
|
||||
font-size: 32rpx;
|
||||
border-radius: 45rpx;
|
||||
margin-top: 60rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user