317 lines
7.4 KiB
Vue
Raw Normal View History

<template>
<BasicLayout>
<view class="qj-detail">
<!-- 请假信息卡片 -->
<view class="info-card">
<view class="card-header">
2025-08-28 00:57:52 +08:00
<text class="applicant-name" v-if="dbFlag">{{ xxtsData.xxzy }}</text>
2025-07-26 15:27:02 +08:00
<text class="applicant-name" v-else>学生{{ qjData.xsxm }}的请假申请</text>
</view>
<view class="divider"></view>
<view class="card-body">
<view class="info-row">
<text class="label">请假类型:</text>
<text class="value">{{ qjData.qjlx }}</text>
</view>
<view class="info-row">
<text class="label">开始时间:</text>
<text class="value">{{ qjData.qjkstime }}</text>
</view>
<view class="info-row">
<text class="label">结束时间:</text>
<text class="value">{{ qjData.qjjstime }}</text>
</view>
<view class="info-row">
<text class="label">请假时长:</text>
<text class="value">{{ qjData.qjsc }}</text>
</view>
<view class="info-row">
<text class="label">是否离校:</text>
<text class="value">{{ qjData.sflx === 1 ? '是' : '否' }}</text>
</view>
<view class="info-column">
<text class="label">请假事由:</text>
<text class="value">{{ qjData.qjsy }}</text>
</view>
</view>
</view>
2025-08-28 00:57:52 +08:00
<!-- 审批意见卡片 -->
<view class="info-card">
<view class="card-header">
<text class="applicant-name">审批意见</text>
</view>
<view class="divider"></view>
2025-08-28 00:57:52 +08:00
<view class="card-body">
<BasicForm @register="register" />
</view>
</view>
</view>
<template #bottom>
<view class="white-bg-color py-5">
<view class="flex-row items-center pb-10 pt-5">
<u-button
text="取消"
class="ml-15 mr-7"
:plain="true"
@click="navigateBack"
/>
<u-button
text="提交"
class="mr-15 mr-7"
type="primary"
@click="submit"
/>
</view>
</view>
</template>
</BasicLayout>
</template>
<script setup lang="ts">
import { onLoad } from "@dcloudio/uni-app";
import { useForm } from "@/components/BasicForm/hooks/useForm";
import { navigateBack } from "@/utils/uniapp";
2025-08-01 20:11:36 +08:00
import { xsQjFindByIdApi, xsQjSpApi } from "@/api/base/server";
import { useUserStore } from "@/store/modules/user";
2025-08-02 14:23:51 +08:00
import { useDataStore } from "@/store/modules/data";
2025-08-01 20:11:36 +08:00
import { ref, nextTick } from "vue";
import { xxtsFindByIdApi } from "@/api/base/server";
2025-08-01 20:11:36 +08:00
2025-08-02 14:23:51 +08:00
const { getJs, loginByOpenId } = useUserStore();
2025-08-01 20:11:36 +08:00
const { getData, setXxts, setData, getXxts } = useDataStore();
const dbFlag = ref(false);
2025-08-28 00:57:52 +08:00
// 从URL参数获取请假ID
const qjId = getData.id || '';
const [register, { getValue }] = useForm({
schema: [
{
2025-08-28 00:57:52 +08:00
field: "spStatus",
label: "审批意见",
component: "BasicCheckbox",
required: true,
itemProps: {
labelPosition: "top",
},
componentProps: {
data: [
2025-08-28 00:57:52 +08:00
{ value: 'approved', text: "同意" },
{ value: 'rejected', text: "拒绝" },
],
},
},
{
2025-08-28 00:57:52 +08:00
field: "spYj",
label: "审批说明",
component: "BasicInput",
required: true,
itemProps: {
labelPosition: "top",
},
componentProps: {
type: "textarea",
2025-08-28 00:57:52 +08:00
placeholder: "请输入审批说明",
},
},
],
});
// 请假基础数据
const qjData = computed(() => getData || {});
2025-08-28 00:57:52 +08:00
const xxtsData = ref<any>({})
2025-08-01 20:11:36 +08:00
const submit = async () => {
2025-08-28 00:57:52 +08:00
try {
const formData = await getValue();
if (!formData.spStatus || !formData.spYj) {
uni.showToast({
title: '请填写完整的审批信息',
icon: 'none'
});
return;
}
const params = {
qjId: qjData.value.id,
jsId: getJs.id,
spStatus: formData.spStatus,
spYj: formData.spYj,
};
uni.showLoading({
title: "提交中...",
});
const res = await xsQjSpApi(params);
uni.hideLoading();
uni.showToast({
title: '审批提交成功',
icon: 'success'
});
setTimeout(() => {
navigateBack();
}, 1500);
} catch (error) {
uni.hideLoading();
uni.showToast({
title: '提交失败,请重试',
icon: 'none'
});
console.error('审批提交失败:', error);
}
};
onLoad(async (data: any) => {
// 从待办过来的,需要从后端获取数据
if (data && data.from && data.from == "db") {
dbFlag.value = true;
2025-08-01 20:11:36 +08:00
2025-08-02 14:23:51 +08:00
// 检查登录状态
const isLoggedIn = await loginByOpenId(data.openId);
if (!isLoggedIn) {
console.log("用户未登录,跳过处理");
return;
}
2025-08-01 20:11:36 +08:00
try {
// 优先从后端根据url中的id去查询Xxts
const xxtsRes = await xxtsFindByIdApi({ id: data.id });
if (xxtsRes && xxtsRes.result) {
const xxts = xxtsRes.result;
2025-08-28 00:57:52 +08:00
xxtsData.value = xxts;
2025-08-01 20:11:36 +08:00
// 检查待办状态
if (xxts.dbZt === "B") {
setData({ id: xxts.xxzbId });
let url = "/pages/base/xs/qj/detail";
uni.navigateTo({ url });
return;
}
setXxts(xxts);
// 根据主表ID去查询学生请假信息
const res = await xsQjFindByIdApi({ id: xxts.xxzbId });
nextTick(() => {
setData(res.result);
});
}
} catch (error) {
console.error("获取待办信息失败", error);
// 如果获取Xxts失败回退到原来的逻辑
2025-08-28 00:57:52 +08:00
const xxtsData = getXxts;
2025-08-01 20:11:36 +08:00
if (xxtsData && xxtsData.dbZt === "B") {
setData({ id: data.id });
let url = "/pages/base/xs/qj/detail";
uni.navigateTo({ url });
return;
}
const res = await xsQjFindByIdApi({ id: data.id });
nextTick(() => {
setData(res.result);
});
}
} else {
dbFlag.value = false;
}
});
</script>
<style lang="scss" scoped>
.qj-detail {
background-color: #f5f7fa;
}
.info-card {
margin: 15px;
background-color: #fff;
border-radius: 8px;
padding: 15px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
.card-header {
font-size: 16px;
font-weight: bold;
color: #333;
margin-bottom: 10px;
.applicant-name {
font-size: 16px;
font-weight: bold;
color: #333;
}
}
.divider {
height: 1px;
background-color: #eee;
margin-bottom: 15px;
}
.card-body {
padding: 15px;
.info-row {
display: flex;
margin-bottom: 10px;
.label {
font-size: 14px;
color: #bbb;
width: 70px;
flex-shrink: 0;
margin-right: 8px;
}
.value {
font-size: 14px;
color: #333;
flex: 1;
}
}
2025-08-28 00:57:52 +08:00
.info-column {
display: flex;
flex-direction: column;
.label {
font-size: 14px;
color: #bbb;
flex-shrink: 0;
margin-right: 8px;
width: 100%;
margin-bottom: 5px;
}
.value {
font-size: 14px;
color: #333;
flex: 1;
}
}
}
}
.bottom-action {
padding: 15px;
margin-top: 20px;
.back-btn {
width: 100%;
height: 44px;
line-height: 44px;
background-color: #fff;
color: #333;
border-radius: 22px;
font-size: 16px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}
}
</style>