236 lines
6.0 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 pb-5">
<text class="label">请假事由:</text>
<text class="value">{{ qjData.qjsy }}</text>
</view>
<view class="info-row">
<text class="label">申请时间:</text>
<text class="value">{{ qjData.createdTime }}</text>
</view>
</view>
</view>
<!-- 审批流程 -->
<LcglSp :yw-id="qjId" yw-type="XS_QJ" />
</view>
<template #bottom>
<YwConfirm :spApi="xsQjSpApi" :stopApi="xsQjStopApi"
:transferApi="xsQjTransferApi" :params="spParams" />
</template>
</BasicLayout>
</template>
<script setup lang="ts">
import { onLoad } from "@dcloudio/uni-app";
import { xsQjFindByIdApi, xsQjSpApi, xsQjStopApi, xsQjTransferApi } from "@/api/base/server";
2025-08-01 20:11:36 +08:00
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/xxtsApi";
import LcglSp from "@/components/LcglSp/index.vue";
import YwConfirm from "@/pages/components/YwConfirm/index.vue";
import { XkTfPageUtils } from "@/utils/xkTfPageUtils";
2025-08-01 20:11:36 +08:00
2025-08-02 14:23:51 +08:00
const { getJs, loginByOpenId } = useUserStore();
2025-09-23 21:52:00 +08:00
const { getQjData, setXxts, setQjData, getXxts } = useDataStore();
const dbFlag = ref(false);
2025-08-28 00:57:52 +08:00
// 从URL参数获取请假ID
const qjId = computed(() => {
2025-09-23 21:52:00 +08:00
return getQjData.id || '';
})
const spParams = computed(() => {
return {
xxtsId: getXxts.id,
ywId: qjId.value
};
});
// 请假基础数据
2025-09-23 21:52:00 +08:00
const qjData = computed(() => getQjData || {});
2025-08-28 00:57:52 +08:00
const xxtsData = ref<any>({})
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") {
2025-09-23 21:52:00 +08:00
setQjData({ id: xxts.xxzbId });
2025-08-01 20:11:36 +08:00
let url = "/pages/base/xs/qj/detail";
uni.navigateTo({ url });
return;
}
setXxts(xxts);
// 根据主表ID去查询学生请假信息
const res = await xsQjFindByIdApi({ id: xxts.xxzbId });
const xsQj = res.result || {};
if (xsQj.spResult != "A" && getXxts && getXxts.dbZt === "A") {
uni.reLaunch({ url: '/pages/base/xs/qj/detail' });
2025-09-22 18:11:59 +08:00
const flag = await XkTfPageUtils.updateXxts();
} else {
nextTick(() => {
2025-09-23 21:52:00 +08:00
setQjData(xsQj);
});
}
2025-08-01 20:11:36 +08:00
}
} 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") {
2025-09-23 21:52:00 +08:00
setQjData({ id: data.id });
2025-08-01 20:11:36 +08:00
let url = "/pages/base/xs/qj/detail";
uni.navigateTo({ url });
return;
}
const res = await xsQjFindByIdApi({ id: data.id });
nextTick(() => {
2025-09-23 21:52:00 +08:00
setQjData(res.result);
2025-08-01 20:11:36 +08:00
});
}
} 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>