初始化

This commit is contained in:
2025-08-01 10:44:32 +08:00
commit cbb8dc2ba6
1083 changed files with 178320 additions and 0 deletions

1011
pages/sub/StuApply.vue Normal file

File diff suppressed because it is too large Load Diff

648
pages/sub/StuReturn.vue Normal file
View File

@@ -0,0 +1,648 @@
<template>
<view>
<view v-if="canUse">
<view class="form-item" v-if="[1, 2, 10].includes(Number(formData.leaveStatus))">
<view class="status-flex">
<label>审核状态</label>
<!-- <view style="color: red;border-bottom: 1px solid black;"> {{formData.status == 1 ? "已提交"
: formData.status == 2 ? "通过"
:formData.status == 10 ? "打回" :""}}
</view> -->
<view>
<u-tag :text="leaveStatusText"></u-tag>
</view>
</view>
</view>
<view class="form-item">
<label>家长姓名</label>
<input :disabled="formData.status == 2" placeholder="请输入" v-model="formData.parentName" />
</view>
<view class="form-item">
<label>家长电话</label>
<input :disabled="formData.status == 2" placeholder="请输入" v-model="formData.parentPhone" />
</view>
<view v-if="formData.status != 2" class="form-item">
<label>家长是否知晓</label>
<radio-group @change="radioChange1">
<label class="uni-list-cell uni-list-cell-pd">
<view class="radio-flex">
<radio :checked="formData.know=='是'" :value="'是'" />
</view>
</label>
<label style="margin-left: 80rpx;" class="uni-list-cell uni-list-cell-pd">
<view class="radio-flex">
<radio :checked="formData.know=='否'" :value="'否'" />
</view>
</label>
</radio-group>
</view>
<view v-if="formData.status == 2" class="form-item">
<label>家长是否知晓{{formData.know}}</label>
</view>
<view>
<view v-if="formData.status != 2" class="form-item">
<label>是否到校 <text style="color: red;">*请在到校后填写</text></label>
<radio-group @change="radioChange2">
<label class="uni-list-cell uni-list-cell-pd">
<view class="radio-flex">
<radio :checked="formData.reachSchoolStatus=='是'" :value="'是'" />
</view>
</label>
<label style="margin-left: 80rpx;" class="uni-list-cell uni-list-cell-pd">
<view class="radio-flex">
<radio :checked="formData.reachSchoolStatus=='否'" :value="'否'" />
</view>
</label>
</radio-group>
</view>
<view v-if="formData.status == 2" class="form-item">
<label>是否到校<text style="color: red;">{{formData.reachSchoolStatus}}</text></label>
</view>
<view v-if="formData.reachSchoolStatus=='是'">
<view class="form-item">
<label>到校时间 <text style="color: red;">*请在到校后填写</text></label>
<DateTimePicker :disabled="formData.status == 2" v-model="formData.attendSchoolTime" />
</view>
<view class="form-item">
<label>到校定位 <text style="color: red;">*请在到校后填写</text> </label>
<view>
<button style="display: inline-block;" @click="getLocation">获取定位</button>
<button v-if="formData.status!=2" type="primary"
style="display: inline-block;margin-left: 30rpx;" @click="stuSchoolUpdate">点我提交</button>
<map style="width:100%;height:300px;" :latitude="latitude" :longitude="longitude"
:markers="covers" show-location></map>
</view>
</view>
</view>
<view v-if="formData.reachSchoolStatus=='否'">
<view class="form-item">
<label>未返校原因</label>
<uni-data-select :disabled="formData.status == 2" placeholder="请选择"
v-model="formData.absentSchoolType" :localdata="absentSchoolTypeList">
</uni-data-select>
</view>
<view class="form-item">
<label>未返校详细原因</label>
<textarea :disabled="formData.status == 2" placeholder="请输入"
v-model="formData.absentSchoolRemark" />
</view>
<button v-if="formData.status!=2" type="primary" @click="stuSchoolUpdate">点我提交</button>
</view>
</view>
</view>
</view>
</template>
<script>
import DateTimePicker from "@/components/DateTimePicker.vue";
import {
getWxConfig
} from "@/api/common/wechat";
import wx from "weixin-js-sdk"; // 引入微信 JS-SDK
import * as ww from '@wecom/jssdk'
import {
isEmpty,
isValidPhone
} from "@/api/helpFunc/index.js";
import {
boolStuOwnReturn,
stuWillReturnUpdate,
stuSchoolUpdate,
getStuCampus
} from '@/api/sur';
import {
getOwnInfo,
getOwnFamily
} from "@/api/person/person.js";
export default {
components: {
DateTimePicker
},
data() {
return {
absentSchoolTypeList: [{
text: '路上',
value: '路上'
},
{
text: '病假',
value: '病假'
},
{
text: '无票',
value: '无票'
},
{
text: '无课请事假延长',
value: '无课请事假延长'
},
{
text: '事假',
value: '事假'
},
{
text: '红白事',
value: '红白事'
},
{
text: '考试',
value: '考试'
},
{
text: '参赛',
value: '参赛'
},
{
text: '兵检或役前训练',
value: '兵检或役前训练'
},
{
text: '退学或休学',
value: '退学或休学'
}
],
latitude: 108.31019592285156, // 纬度
longitude: 22.90125274658203, // 经度
covers: [{
latitude: 108.31019592285156,
longitude: 22.90125274658203,
iconPath: '../../static/images/applyrelieve/location.png'
}],
canUse: false,
formData: {
scheduledReturnTime: '',
attendSchoolTime: ''
},
returnSchoolId: null,
distanceThreshold: 1000,
circlePolyline: [],
ownPhone: null,
ownParentName: null,
ownParentPhone: null
}
},
computed: {
leaveStatusText() {
const statusMap = {
1: "已提交",
2: "通过",
10: "打回"
};
return statusMap[this.formData.leaveStatus] || "";
}
},
onLoad(options) {
if (isEmpty(options.id)) {
uni.redirectTo({
url: "/pages/sub/StuApply"
})
} else {
this.returnSchoolId = options.id;
this.boolStuOwnReturn();
}
},
async onShow() {
await this.initWxConfig(); // 初始化微信配置
this.getLocation();
},
methods: {
async getOwnFamily() {
uni.showLoading();
let res = await getOwnFamily();
uni.hideLoading();
if (res.code == 200) {
let data = [...res.data];
if (!isEmpty(data)) {
this.ownParentName = data[0].familyName;
this.ownParentPhone = data[0].phone;
}
}
},
async getOwnInfo() {
uni.showLoading();
let res = await getOwnInfo();
uni.hideLoading();
if (res.code == 200) {
this.ownPhone = res.data.stuPhone;
}
},
async stuSchoolUpdate() {
let sdata = {
...this.formData
};
if (isEmpty(sdata.reachSchoolStatus)) {
uni.showToast({
title: "请选择是否到校",
icon: "none",
mask: true
});
return;
}
if (isEmpty(sdata.parentName)) {
uni.showToast({
title: "请输入家长姓名",
icon: "none",
mask: true
});
return;
}
if (isEmpty(sdata.parentPhone)) {
uni.showToast({
title: "请输入家长电话",
icon: "none",
mask: true
});
return;
}
if (!isValidPhone(sdata.parentPhone)) {
uni.showToast({
title: "家长电话格式不正确",
icon: "none",
mask: true
});
return;
}
if (sdata.reachSchoolStatus == "是" && isEmpty(sdata.attendSchoolTime)) {
uni.showToast({
title: "请选择到校时间",
icon: "none",
mask: true
});
return;
}
if (sdata.reachSchoolStatus == "是" && isEmpty(this.latitude)) {
uni.showToast({
title: "请定位",
icon: "none",
mask: true
});
return;
}
if (sdata.reachSchoolStatus == "是") {
if (await this.checkIfNearCampus()) {
sdata.attendSchoolGps = this.latitude + "," + this.longitude;
} else {
uni.showToast({
title: "您不在学校附近",
icon: "error"
});
return;
}
}
if (sdata.reachSchoolStatus == "否" && isEmpty(sdata.absentSchoolType)) {
uni.showToast({
title: "请选择未返校原因",
icon: "none",
mask: true
});
return;
}
if (sdata.reachSchoolStatus == "否" && isEmpty(sdata.absentSchoolRemark)) {
uni.showToast({
title: "请输入详细原因",
icon: "none",
mask: true
});
return;
}
uni.showLoading();
let res = await stuSchoolUpdate(sdata).then(res => {
uni.hideLoading();
if (res.code == 200) {
uni.showToast({
title: res.msg,
mask: true,
icon: "success"
});
//返回
uni.navigateBack();
}
});
},
async checkIfNearCampus() {
const campuses = [{
name: "长堽校区",
latitude: 22.835938,
longitude: 108.351728
},
{
name: "里建校区",
latitude: 23.206284,
longitude: 108.18664
}
];
let isNearby = false;
let res = false;
let campus = campuses[0];
let p1 = {
latitude: this.latitude,
longitude: this.longitude
}
let distance = this.getDistance(
p1.latitude, p1.longitude,
campus.latitude, campus.longitude
);
isNearby = distance < this.distanceThreshold;
if (isNearby) {
res = true;
}
campus = campuses[1];
distance = this.getDistance(
p1.latitude, p1.longitude,
campus.latitude, campus.longitude
);
isNearby = distance < this.distanceThreshold;
if (isNearby) {
res = true;
}
if (res) {
return true;
} else {
uni.showToast({
icon: "error",
title: "您不在校区范围内"
});
return false;
}
},
distanceToLngLatOffset(distance) {
const earthRadius = 6371000; // 地球半径,单位:米
const radLat = this.centerLat * (Math.PI / 180);
const dLat = (distance / earthRadius) * (180 / Math.PI);
const dLng = (distance / (earthRadius * Math.cos(radLat))) * (180 / Math.PI);
return {
dLat,
dLng
};
},
toRadians(degree) {
return degree * (Math.PI / 180);
},
// 计算两个经纬度之间的距离(近似计算,适用于小范围)
getDistance(lat1, lng1, lat2, lng2) {
const EARTH_RADIUS = 6378137; // 地球半径,单位:米
const dLat = this.toRadians(lat2 - lat1);
const dLng = this.toRadians(lng2 - lng1);
const a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(this.toRadians(lat1)) *
Math.cos(this.toRadians(lat2)) *
Math.sin(dLng / 2) *
Math.sin(dLng / 2);
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
return EARTH_RADIUS * c;
},
drawCircle() {
const points = [];
const distance = 1000; // 1000米的半径
const offset = this.distanceToLngLatOffset(distance);
const numPoints = 30; // 圆圈由多少个点组成,越多越接近圆形
for (let i = 0; i < numPoints; i++) {
const angle = (i / numPoints) * 2 * Math.PI;
const newLat = this.latitude + offset.dLat * Math.sin(angle);
const newLng = this.longitude + offset.dLng * Math.cos(angle);
points.push({
latitude: newLat,
longitude: newLng
});
}
// 确保最后一个点和第一个点重合,形成封闭图形
points.push({
latitude: points[0].latitude,
longitude: points[0].longitude
});
this.circlePolyline = [{
points: points,
color: "#FF0000", // 圆圈颜色
width: 2, // 线条宽度
dottedLine: false // 是否为虚线
}];
},
async initWxConfig() {
let that = this;
let res = await that.getConfigSignature();
that.info += JSON.stringify(res)
ww.register({
corpId: 'wx129e6bf0f36b8b3d', // 必填当前用户企业所属企业ID
agentId: 1000093, // 必填当前应用的AgentID
jsApiList: ["getLocation", "openLocation"], // 必填需要使用的JSAPI列表
// getAgentConfigSignature: that.getAgentConfigSignature, // 必填根据url生成应用签名的回调函数
getConfigSignature() {
console.log(res)
return res
}
})
},
// 初始化微信 JS-SDK
async getConfigSignature() {
return new Promise((resolve, reject) => {
// 调用后端接口获取签名信息(需要后端支持)
getWxConfig("corpId").then(res => {
const {
timestamp,
nonceStr,
signature
} = res;
resolve({
timestamp,
nonceStr,
signature
});
}).catch(err => {
reject(err);
});
});
},
async getAgentConfigSignature() {
return new Promise((resolve, reject) => {
// 调用后端接口获取签名信息(需要后端支持)
getWxConfig("agentId").then(res => {
const {
timestamp,
nonceStr,
signature
} = res;
resolve({
timestamp,
nonceStr,
signature
});
}).catch(err => {
reject(err);
});
});
},
getLocation() {
let that = this;
ww.getLocation({
type: 'gcj02', // GPS坐标 gcj02 wgs84
success(res) {
that.latitude = res.latitude
that.longitude = res.longitude
that.covers[0].latitude = res.latitude
that.covers[0].longitude = res.longitude
// this.drawCircle();
},
fail(err) {
that.info += JSON.stringify(err) + "定位失败fail";
uni.showToast({
title: '定位失败' + JSON.stringify(err),
icon: 'none'
})
},
complete(err) {
that.info += JSON.stringify(err) + "定位失败complete";
}
})
},
radioChange2(evt) {
this.formData.reachSchoolStatus = evt.detail.value;
},
radioChange1(evt) {
this.formData.know = evt.detail.value;
},
async stuWillReturnUpdate() {
let sdata = {
...this.formData
};
uni.showLoading();
let res = await stuWillReturnUpdate(sdata);
uni.hideLoading();
if (res.code == 200) {
uni.showToast({
icon: "success",
title: res.msg
});
this.boolStuOwnReturn();
}
},
async boolStuOwnReturn() {
uni.showLoading();
let res = await boolStuOwnReturn(this.returnSchoolId);
uni.hideLoading();
if (res.code != 200) {
uni.redirectTo({
url: "/pages/sub/StuApply"
})
} else {
this.canUse = true;
this.formData = {
...res.data
};
await this.getOwnInfo();
await this.getOwnFamily();
if (this.formData.status != 2 && this.formData.status != 11) {
this.formData.parentName = this.ownParentName;
this.formData.parentPhone = this.ownParentPhone;
}
console.log(this.formData);
}
}
}
}
</script>
<style scoped lang="scss">
.form-item {
display: flex;
flex-direction: column;
padding: 22rpx 40rpx;
background-color: white;
margin-bottom: 20rpx;
border-radius: 16rpx;
&.tip {
justify-content: center;
text:first-child {
color: red;
}
text:last-child {
margin-top: 10rpx;
color: #FFBA00;
}
}
.tip {
color: red;
font-size: 24rpx;
}
label {
margin-bottom: 20rpx;
display: inline-block;
font-weight: bold;
text {
color: red;
}
}
textarea {
height: 200rpx;
border: 1px solid #E1E1E1;
padding: 20rpx;
width: 100%;
}
input {
border: 1px solid #E1E1E1;
border-radius: 10rpx;
height: 70rpx;
padding-left: 30rpx;
}
picker {
border: 1px solid #E1E1E1;
height: 70rpx;
line-height: 70rpx;
padding: 0 30rpx;
.uni-input {
display: flex;
color: #797979;
.val {
flex: 1;
}
}
}
}
.status-flex {
display: flex;
}
.radio-flex {
display: flex;
gap: 20rpx;
align-items: center;
}
</style>

728
pages/sub/StudoEdit.vue Normal file
View File

@@ -0,0 +1,728 @@
<template>
<view>
<view class="container">
<!-- <view v-if="formData.leaveStatus == '2'" class="header-btn">
<view class="back-school" @tap="toReturn">
<u--text text="点我返校" size="20" color="white"></u--text>
<u-icon name="arrow-right" size="20" color="white"></u-icon>
</view>
</view> -->
<!-- 内容部分 -->
<view class="content">
<view class="card" v-if="[1, 2, 10].includes(Number(formData.leaveStatus))">
<view class="form-item">
<view class="status-flex">
<label>审核状态</label>
<view>
<u-tag :text="leaveStatusText"></u-tag>
</view>
</view>
</view>
</view>
<view class="card">
<view class="form-item" @tap="showDeptPicker = true">
<label>学院</label>
<u-input v-model="formData.moreDeptName" placeholder="请选择学院"
:disabled="formData.leaveStatus == '2'" readonly></u-input>
<!-- <select v-model="formData.moreDeptName" :disabled="formData.leaveStatus == 2">
<option v-for="(v,i) in moreDeptList" :key="i">{{v.dictValue}}</option>
</select> -->
</view>
<view class="form-item">
<label>班级</label>
<u-input :disabled="formData.leaveStatus == 2" placeholder="请输入"
v-model="formData.className" readonly></u-input>
</view>
<view class="form-item">
<label>学号</label>
<u-input :disabled="formData.leaveStatus == 2" placeholder="请输入"
v-model="formData.stuNo" readonly></u-input>
</view>
<view class="form-item">
<label>姓名</label>
<u-input :disabled="formData.leaveStatus == 2" placeholder="请输入"
v-model="formData.name" readonly></u-input>
</view>
<view class="form-item">
<label>辅导员</label>
<u-input :disabled="formData.leaveStatus == 2" placeholder="请输入"
v-model="formData.stuFdyName"></u-input>
</view>
</view>
<view class="card" v-if="formData.leaveStatus == 2">
<view class="form-item">
<view class="status-flex">
<label>是否离校</label>
<u-tag :text='formData.isLeave== "1" ?"是":"否"'></u-tag>
</view>
</view>
</view>
<view class="card">
<view v-if="formData.leaveStatus != 2">
<view class="form-item">
<label>是否离校</label>
<radio-group @change="radioChange3">
<label class="uni-list-cell uni-list-cell-pd">
<view class="radio-flex">
<radio :checked="formData.isLeave=='1'" :value="'1'" /> 离校
</view>
</label>
<label style="margin-left: 80rpx;" class="uni-list-cell uni-list-cell-pd">
<view class="radio-flex">
<radio :checked="formData.isLeave=='0'" :value="'0'" /> 留校
</view>
</label>
</radio-group>
</view>
</view>
<view v-if="formData.leaveStatus != 2" class="form-item">
<label>家长是否知晓</label>
<radio-group :disabled="formData.leaveStatus == 2" @change="radioChange1">
<label class="uni-list-cell uni-list-cell-pd">
<view class="radio-flex">
<radio :checked="formData.famKnow=='是'" :value="'是'" />
</view>
</label>
<label style="margin-left: 80rpx;" class="uni-list-cell uni-list-cell-pd">
<view class="radio-flex">
<radio :checked="formData.famKnow=='否'" :value="'否'" />
</view>
</label>
</radio-group>
</view>
<view v-if="formData.leaveStatus == 2" class="form-item">
<view class="status-flex">
<label>家长是否知晓</label>
<u-tag :text="formData.famKnow"></u-tag>
</view>
</view>
</view>
<view class="card">
<view class="form-item">
<label>家长姓名</label>
<u-input :disabled="formData.leaveStatus == 2" placeholder="请输入"
v-model="formData.famName"></u-input>
</view>
<view class="form-item">
<label>家长电话</label>
<u-input :disabled="formData.leaveStatus == 2" placeholder="请输入"
v-model="formData.famPhone"></u-input>
</view>
<view class="form-item">
<label>学生电话</label>
<u-input :disabled="formData.leaveStatus == 2" placeholder="请输入"
v-model="formData.phone"></u-input>
</view>
<view class="form-item">
<label>紧急联系人姓名</label>
<u-input :disabled="formData.leaveStatus == 2" placeholder="请输入"
v-model="formData.emergencyContact"></u-input>
</view>
<view class="form-item">
<label>紧急联系人电话</label>
<u-input :disabled="formData.leaveStatus == 2" placeholder="请输入"
v-model="formData.emergencyContactPhone"></u-input>
</view>
</view>
<view v-if="formData.isLeave == '1'" class="card-list">
<view class="card">
<view class="form-item">
<label>去向地</label>
<u-input :disabled="formData.leaveStatus == 2" placeholder="请输入" v-model="formData.willAddr" />
</view>
<view class="form-item">
<label>预计离校时间</label>
<DateTimePicker :disabled="formData.leaveStatus == 2" v-model="formData.willLeaveTime" />
</view>
<view class="form-item">
<label>预计返校时间</label>
<DateTimePicker :disabled="formData.leaveStatus == 2"
v-model="formData.scheduledReturnTime" />
</view>
</view>
<view v-if="formData.leaveStatus == '2' && formData.isLeave == '1'" class="card">
<view v-if="isEmpty(formData.homeGps)" class="form-item">
<label>是否到家 <text style="color: red;">*请在到达目的地后填写</text> </label>
<radio-group @change="radioChange2">
<label class="uni-list-cell uni-list-cell-pd">
<view class="radio-flex">
<radio :checked="formData.isHome=='是'" :value="'是'" />
</view>
</label>
<label style="margin-left: 80rpx;" class="uni-list-cell uni-list-cell-pd">
<view class="radio-flex">
<radio :checked="formData.isHome=='否'" :value="'否'" />
</view>
</label>
</radio-group>
</view>
<view class="form-item" v-if="formData.homeSubmit == '1'">
<view class="status-flex">
<label>是否到家</label>
<u-tag :text='formData.isHome'></u-tag>
</view>
</view>
<view class="form-item" v-if="formData.isHome == '是'">
<view v-if="formData.homeSubmit != '1'">
<label>到家定位: <text style="color: red;">*请在到家后获取</text> </label>
<view>
<button style="display: inline-block;" @click="getLocation">获取定位</button>
<button type="primary" style="display: inline-block;margin-left: 30rpx;"
@click="stuHomeUpdate">点我提交</button>
</view>
</view>
<view v-if="formData.homeSubmit != '1'">
<map style="width:100%;height:300px;" :latitude="latitude" :longitude="longitude"
:markers="covers" show-location></map>
</view>
<view v-else>
<label>到家定位 </label>
<map style="width:100%;height:300px;" :latitude="formData.homeGps.split(',')[0]"
:longitude="formData.homeGps.split(',')[1]" :markers="covers" show-location></map>
</view>
</view>
<view v-if="formData.isHome == '否'" class="form-item">
<view v-if="formData.homeSubmit != '1'">
<label>到目的地定位 <text style="color: red;">*请在到达目的地后获取</text> </label>
<view>
<button style="display: inline-block;" @click="getLocation">获取定位</button>
<button type="primary" style="display: inline-block;margin-left: 30rpx;"
@click="stuHomeUpdate">点我提交</button>
</view>
</view>
<view v-if="formData.homeSubmit != '1'">
<map style="width:100%;height:300px;" :latitude="latitude" :longitude="longitude"
:markers="covers" show-location></map>
</view>
<view v-else>
<label>到目的地定位 </label>
<map style="width:100%;height:300px;" :latitude="formData.homeGps.split(',')[0]"
:longitude="formData.homeGps.split(',')[1]" :markers="covers" show-location></map>
</view>
</view>
</view>
</view>
<view v-if="formData.isLeave == '0'" class="card">
<view class="form-item" @tap="showCalendar = true">
<label>预计留校时间 <text style="color: red;">*xxxx年x月x日至xxxx年x月x日</text> </label>
<u-input placeholder="请输入xxxx年x月x日至xxxx年x月x日" v-model="formData.willStayTime"></u-input>
</view>
<view class="form-item">
<label>留校事由</label>
<u--textarea v-model="formData.stayReason" placeholder="请输入留校事由" maxlength="-1"
:autoHeight="true"></u--textarea>
</view>
</view>
<view v-if="formData.leaveStatus != '2'" style="text-align: center;">
<button type="primary" @click="doApply" style="width: 80%;display: inline-block;">
{{ formData.leaveStatus == 1 || formData.leaveStatus == 10 ? "修改" :"提交" }}
</button>
</view>
</view>
</view>
<!-- 弹窗 -->
<u-picker :show="showDeptPicker" :columns="[moreDeptList.map(item => item.dictValue)]" @confirm="onDeptConfirm"
@cancel="showDeptPicker = false"></u-picker>
<!-- 日期范围 -->
<u-calendar :show="showCalendar" :mode="modeCalendar" @close="showCalendar=false"
@confirm="confirmCalendar"></u-calendar>
</view>
</template>
<script>
import DateTimePicker from "@/components/DateTimePicker.vue";
import {
stuGetRecordBySvId,
stuLeaveApply,
stuHomeUpdate,
} from '@/api/sur';
import {
getWxConfig
} from "@/api/common/wechat";
import {
getDicts
} from "@/api/system/dict/data.js";
import {
isEmpty,
isValidPhone
} from "@/api/helpFunc/index.js";
import * as ww from '@wecom/jssdk'
export default {
components: {
DateTimePicker
},
data() {
return {
isSubmit: '否',
formData: {},
moreDeptList: [],
isEmpty,
covers: [{
latitude: null,
longitude: null,
iconPath: '../../static/images/applyrelieve/location.png'
}],
showDeptPicker: false, //院校选择器
showCalendar: false, //离校日期选择器
modeCalendar: "range",
}
},
computed: {
leaveStatusText() {
const statusMap = {
1: "已提交",
2: "通过",
10: "打回"
};
return statusMap[this.formData.leaveStatus] || "";
}
},
onLoad(params) {
// console.log("StuApply参数", params)
this.formData = params
this.formData.surveyId = Number(this.formData.surveyId); //转换数据类型
if (this.formData.isSubmit == "是") {
this.getstuGetRecordBySvId()
}
this.initWxConfig(); // 初始化微信配置
},
async onShow() {
this.getDicts();
},
methods: {
//获取学院列表
async getDicts() {
let res = await getDicts("more_dept_name");
if (res.code == 200) {
this.moreDeptList = [...res.data];
}
},
//触发返校
toReturn() {
uni.navigateTo({
url: "/pages/sub/StuReturn?id=" + this.formData.returnSchoolId
});
},
//选择学院
onDeptConfirm(e) {
// console.log(e)
this.formData.moreDeptName = e.value[0];
this.showDeptPicker = false;
// console.log(this.formData)
},
//家长是否知晓
radioChange1(evt) {
this.formData.famKnow = evt.detail.value;
this.$forceUpdate();
},
//是否返校
radioChange2(evt) {
this.formData.isHome = evt.detail.value;
this.$forceUpdate();
},
//是否留校
radioChange3(evt) {
this.formData.isLeave = evt.detail.value;
this.$forceUpdate();
},
//预计留校时间
confirmCalendar(e) {
this.formData.willStayTime = e[0] + "至" + e[e.length - 1];
this.showCalendar = false;
this.$forceUpdate();
},
//提交填写
async doApply(val) {
let sdata = {
...this.formData
};
if (isEmpty(sdata.moreDeptName)) {
uni.showToast({
title: "请选择学院",
icon: "none",
mask: true
});
return;
}
if (isEmpty(sdata.phone)) {
uni.showToast({
title: "请输入学生电话",
icon: "none",
mask: true
});
return;
}
if (isEmpty(sdata.stuFdyName)) {
uni.showToast({
title: "请填写辅导员",
icon: "none",
mask: true
});
return;
}
if (!isValidPhone(sdata.phone)) {
uni.showToast({
title: "学生电话格式不正确",
icon: "none",
mask: true
});
return;
}
if (isEmpty(sdata.emergencyContact)) {
uni.showToast({
title: "请输入紧急联系人姓名",
icon: "none",
mask: true
});
return;
}
// 使用示例
if (isEmpty(sdata.emergencyContactPhone)) {
uni.showToast({
title: "请输入紧急联系人电话",
icon: "none",
mask: true
});
return;
}
if (!isValidPhone(sdata.emergencyContactPhone)) {
uni.showToast({
title: "紧急联系人电话格式不正确",
icon: "none",
mask: true
});
return;
}
if (isEmpty(sdata.famName)) {
uni.showToast({
title: "请输入家长姓名",
icon: "none",
mask: true
});
return;
}
// 使用示例
if (isEmpty(sdata.famPhone)) {
uni.showToast({
title: "请输入家长电话",
icon: "none",
mask: true
});
return;
}
if (!isValidPhone(sdata.famPhone)) {
uni.showToast({
title: "家长电话格式不正确",
icon: "none",
mask: true
});
return;
}
if (isEmpty(sdata.famKnow)) {
uni.showToast({
title: "请选择家长是否知晓",
icon: "none",
mask: true
});
return;
}
if (sdata.isLeave == "1") {
if (isEmpty(sdata.willAddr)) {
uni.showToast({
title: "请输入去向地",
icon: "none",
mask: true
});
return;
}
if (isEmpty(sdata.willLeaveTime)) {
uni.showToast({
title: "请选择离校时间",
icon: "none",
mask: true
});
return;
}
if (isEmpty(sdata.scheduledReturnTime)) {
uni.showToast({
title: "请选择预计返校时间",
icon: "none",
mask: true
});
return;
}
const today = new Date();
today.setHours(0, 0, 0, 0);
const willLeaveTime = new Date(sdata.willLeaveTime.replace(/-/g, '/'));
if (willLeaveTime < today) {
uni.showToast({
title: "预计离校时间不能早于今天",
icon: "none",
mask: true
});
return;
}
}
if (sdata.isLeave == "0") {
if (isEmpty(sdata.willStayTime)) {
uni.showToast({
title: "请填写预计留校时间",
icon: "none",
mask: true
});
return;
}
if (isEmpty(sdata.stayReason)) {
uni.showToast({
title: "请填写留校事由",
icon: "none",
mask: true
});
return;
}
}
// console.log("表单", sdata)
uni.showLoading({
mask: true
});
await stuLeaveApply(sdata).then(res => {
uni.hideLoading();
if (res.code == 200) {
uni.showToast({
title: res.msg,
mask: true
});
//返回上一页
uni.navigateBack({
delta: 1
});
}
});
},
//到家提交
async stuHomeUpdate() {
let sdata = {
...this.formData
};
if (isEmpty(sdata.isHome)) {
uni.showToast({
title: "请选择是否到家",
icon: "none",
mask: true
});
return;
}
if (isEmpty(this.formData.tempHomeGps)) {
uni.showToast({
title: "请点击定位",
icon: "none",
mask: true
});
return;
} else {
sdata.homeGps = this.formData.tempHomeGps;
}
uni.showLoading({
mask: true
});
let res = await stuHomeUpdate(sdata).then(res => {
uni.hideLoading();
if (res.code == 200) {
uni.showToast({
title: res.msg,
mask: true
});
this.lookV = false;
//返回上一页
uni.navigateBack({
delta: 1
});
}
});
},
//获取已经填写的信息
getstuGetRecordBySvId() {
let that = this;
uni.showLoading({
mask: true
});
stuGetRecordBySvId(that.formData.surveyId).then(res => {
uni.hideLoading();
if (res.code == 200) {
that.formData = {
...res.data
};
that.$forceUpdate();
}
});
},
//关于定位
async initWxConfig() {
let that = this;
let res = await that.getConfigSignature();
that.info += JSON.stringify(res)
ww.register({
corpId: 'wx129e6bf0f36b8b3d', // 必填当前用户企业所属企业ID
agentId: 1000093, // 必填当前应用的AgentID
jsApiList: ["getLocation", "openLocation"], // 必填需要使用的JSAPI列表
// getAgentConfigSignature: that.getAgentConfigSignature, // 必填根据url生成应用签名的回调函数
getConfigSignature() {
// console.log(res)
return res
}
})
},
// 初始化微信 JS-SDK
async getConfigSignature() {
return new Promise((resolve, reject) => {
// 调用后端接口获取签名信息(需要后端支持)
getWxConfig("corpId").then(res => {
const {
timestamp,
nonceStr,
signature
} = res;
resolve({
timestamp,
nonceStr,
signature
});
}).catch(err => {
reject(err);
});
});
},
//调用签名接口
async getAgentConfigSignature() {
return new Promise((resolve, reject) => {
// 调用后端接口获取签名信息(需要后端支持)
getWxConfig("agentId").then(res => {
const {
timestamp,
nonceStr,
signature
} = res;
resolve({
timestamp,
nonceStr,
signature
});
}).catch(err => {
reject(err);
});
});
},
//获取定位
getLocation() {
ww.getLocation({
isHighAccuracy: true,
type: 'gcj02',
success: async (res) => {
this.covers[0].latitude = res.latitude
this.covers[0].longitude = res.longitude
this.latitude = res.latitude;
this.longitude = res.longitude;
this.accuracy = res.accuracy;
this.formData.tempHomeGps = this.latitude + "," + this.longitude;
},
fail: (err) => {
uni.showToast({
title: "获取定位失败",
icon: 'fail'
})
// console.error('Location fail:', err);
}
});
},
}
}
</script>
<style lang="scss">
page {
background-color: #F5F5F7;
/* 设置背景颜色为浅灰色 */
}
.container {
padding: 20rpx;
box-sizing: border-box;
}
.header-btn {
display: flex;
justify-content: end;
.back-school {
display: flex;
justify-content: space-evenly;
align-items: center;
background: #2979ff;
border-radius: 10rpx;
padding: 10rpx;
}
}
.content {
margin-top: 40rpx;
display: flex;
flex-direction: column;
gap: 40rpx;
}
.card-list {
display: flex;
flex-direction: column;
gap: 40rpx;
}
.card {
background-color: white;
padding: 40rpx 20rpx;
border-radius: 20rpx;
display: flex;
flex-direction: column;
gap: 40rpx;
.form-item {
display: flex;
flex-direction: column;
gap: 10rpx;
}
}
.status-flex {
display: flex;
}
.radio-flex {
display: flex;
gap: 20rpx;
align-items: center;
}
</style>

262
pages/sub/add.vue Normal file
View File

@@ -0,0 +1,262 @@
template>
<view class="add">
<view>
<view class="form-item"
v-if="formData.leaveStatus == 1 || formData.leaveStatus == 2 ||formData.leaveStatus == 10">
<label>审核状态</label>
<view style="color: red;border-bottom: 1px solid black;"> {{formData.leaveStatus == 1 ? "已提交"
: formData.leaveStatus == 2 ? "通过"
:formData.leaveStatus == 10 ? "打回" :""}}
</view>
</view>
<view class="form-item">
<label>学生电话</label>
<input :disabled="formData.leaveStatus == 2" placeholder="请输入" v-model="formData.phone" />
</view>
<view class="form-item">
<label>紧急联系人姓名</label>
<input :disabled="formData.leaveStatus == 2" placeholder="请输入"
v-model="formData.emergencyContact" />
</view>
<view class="form-item">
<label>紧急联系人电话</label>
<input :disabled="formData.leaveStatus == 2" placeholder="请输入"
v-model="formData.emergencyContactPhone" />
</view>
<view class="form-item">
<label>家长姓名</label>
<input :disabled="formData.leaveStatus == 2" placeholder="请输入" v-model="formData.famName" />
</view>
<view class="form-item">
<label>家长电话</label>
<input :disabled="formData.leaveStatus == 2" placeholder="请输入" v-model="formData.famPhone" />
</view>
<view v-if="formData.leaveStatus != 2" class="form-item">
<label>家长是否知晓</label>
<radio-group :disabled="formData.leaveStatus == 2" @change="radioChange1">
<label class="uni-list-cell uni-list-cell-pd">
<view>
<radio :checked="formData.famKnow=='是'" :value="'是'" />
</view>
<view></view>
</label>
<label style="margin-left: 80rpx;" class="uni-list-cell uni-list-cell-pd">
<view>
<radio :checked="formData.famKnow=='否'" :value="'否'" />
</view>
<view></view>
</label>
</radio-group>
</view>
<view v-if="formData.leaveStatus == 2" class="form-item">
<label>家长是否知晓{{formData.famKnow}}</label>
</view>
<view v-if="formData.leaveStatus != 2">
<view class="form-item">
<label>是否离校</label>
<radio-group @change="radioChange3">
<label class="uni-list-cell uni-list-cell-pd">
<view>
<radio :checked="formData.isLeave=='1'" :value="'1'" />
</view>
<view>离校</view>
</label>
<label style="margin-left: 80rpx;" class="uni-list-cell uni-list-cell-pd">
<view>
<radio :checked="formData.isLeave=='0'" :value="'0'" />
</view>
<view>留校</view>
</label>
</radio-group>
</view>
</view>
<view v-if="formData.leaveStatus == 2" class="form-item">
<label>是否离校{{formData.isLeave== "1" ?"是":"否"}}</label>
</view>
<view v-if="formData.isLeave == '1'">
<view class="form-item">
<label>预计离校时间</label>
<picker :disabled="formData.leaveStatus == 2" @change="onChangeTime" mode="date"
:value="formData.willLeaveTime">
<view class="uni-input">
<text
class="val">{{isEmpty(formData.willLeaveTime)?'请选择日期':formData.willLeaveTime}}</text>
<uni-icons type="calendar" size="25" color="#202020"></uni-icons>
</view>
</picker>
</view>
<view v-if="formData.leaveStatus == '2' && formData.isLeave == '1'">
<view class="form-item">
<label>是否到家 <text style="color: red;">*请在到达目的地后填写</text> </label>
<radio-group @change="radioChange2">
<label class="uni-list-cell uni-list-cell-pd">
<view>
<radio :checked="formData.isHome=='是'" :value="'是'" />
</view>
<view></view>
</label>
<label style="margin-left: 80rpx;" class="uni-list-cell uni-list-cell-pd">
<view>
<radio :checked="formData.isHome=='否'" :value="'否'" />
</view>
<view></view>
</label>
</radio-group>
</view>
<view class="form-item">
<label>到家定位 <text style="color: red;">*请在到达目的地后获取</text> </label>
<view>
<button style="display: inline-block;" @click="getLocation">获取定位</button>
<button type="primary" style="display: inline-block;margin-left: 30rpx;"
@click="stuHomeUpdate">点我提交</button>
</view>
</view>
</view>
</view>
<view v-if="formData.isLeave == '0'">
<view class="form-item">
<label>预计留校时间 <text style="color: red;">*xxxx年x月x日至xxxx年x月x日</text> </label>
<input placeholder="请输入xxxx年x月x日至xxxx年x月x日" v-model="formData.willStayTime" />
</view>
<view class="form-item">
<label>留校事由</label>
<textarea placeholder="请输入留校事由" v-model="formData.stayReason" />
</view>
</view>
<view v-if="formData.leaveStatus != '2'" style="text-align: center;">
<button type="primary" @click="doApply" style="width: 80%;display: inline-block;">
{{ formData.leaveStatus == 1 || formData.leaveStatus == 10 ? "修改" :"提交" }}
</button>
</view>
</view>
</view>
</template>
<script>
import {
getQuestionnaire,
addAnswer,
updateAnswer
} from '@/api/questionnaire/questionnaire.js';
import {
toBackPage
} from "@/utils/toBack.js"
import {
isEmpty,
isValidPhone
} from "@/api/helpFunc/index.js";
export default {
data() {
return {
isSubmitting: false, //表单提交标志位
questionnaireDetail: {},
questionnaireId: "", //问卷id
targetId: "", //目标id
navIndex:"",
formData: {
willLeaveTime: "",
isLeave: "1",
homeGps: ""
},
}
},
onLoad(option) {
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.questionnaire-detail {
padding: 30rpx 30rpx 95rpx;
&>.title {
font-weight: bold;
font-size: 40rpx;
text-align: center;
margin-bottom: 35rpx;
}
.list {
.item {
.title {
font-weight: bold;
}
/* 选项 */
.option {
display: flex;
justify-content: start;
gap: 10px;
margin: 16px 0;
.option_number {
text-align: center;
width: 24px;
height: 24px;
border-radius: 50%;
border: 1px solid #E1EAF4;
line-height: 22px;
font-size: 14px;
color: #646873;
cursor: pointer;
}
.active {
background-color: #409EFF;
border: 1px solid #409EFF;
color: #fff;
}
}
textarea {
border: 1px solid #d3d3d3;
margin: 40rpx 0;
width: 100%;
border-radius: 16rpx;
padding: 20rpx;
color: #202020;
opacity: 0.7;
height: 80px;
.textarea-placeholder {
color: #202020;
opacity: 0.5;
}
}
}
}
.btns {
padding: 10px;
display: flex;
background: white;
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 999;
button {
flex: 1;
background-color: #1890FF;
color: white;
&:first-child {
margin-right: 10px;
background-color: white;
border: 1px solid #1890FF;
color: #1890FF;
}
}
}
}
</style>