<template>
|
<view class="approve-page">
|
<PageHeader title="审核"
|
@back="goBack" />
|
<!-- 申请信息 -->
|
<view class="application-info">
|
<view class="info-header">
|
<text class="info-title">申请信息</text>
|
</view>
|
<view class="info-content">
|
<view class="info-row">
|
<text class="info-label">申请人</text>
|
<text class="info-value">{{ approvalData.approveUserName }}</text>
|
</view>
|
<view class="info-row">
|
<text class="info-label">申请部门</text>
|
<text class="info-value">{{ approvalData.approveDeptName }}</text>
|
</view>
|
<view class="info-row">
|
<text class="info-label">申请事由</text>
|
<text class="info-value">{{ approvalData.approveReason }}</text>
|
</view>
|
<view class="info-row">
|
<text class="info-label">申请日期</text>
|
<text class="info-value">{{ approvalData.approveTime }}</text>
|
</view>
|
<!-- approveType=2 请假相关字段 -->
|
<template v-if="approvalData.approveType === 2">
|
<view class="info-row">
|
<text class="info-label">请假开始时间</text>
|
<text class="info-value">{{ approvalData.startDate || '-' }}</text>
|
</view>
|
<view class="info-row">
|
<text class="info-label">请假结束时间</text>
|
<text class="info-value">{{ approvalData.endDate || '-' }}</text>
|
</view>
|
</template>
|
<!-- approveType=3 出差相关字段 -->
|
<view v-if="approvalData.approveType === 3"
|
class="info-row">
|
<text class="info-label">出差地点</text>
|
<text class="info-value">{{ approvalData.location || '-' }}</text>
|
</view>
|
<!-- approveType=4 报销相关字段 -->
|
<view v-if="approvalData.approveType === 4"
|
class="info-row">
|
<text class="info-label">报销金额</text>
|
<text class="info-value">{{ approvalData.price ? `¥${approvalData.price}` : '-' }}</text>
|
</view>
|
</view>
|
</view>
|
<!-- 采购/报价/发货审批详情 -->
|
<view v-if="isBusinessApproval"
|
class="business-detail-wrap">
|
<ApprovalBusinessDetail :approve-type="approvalData.approveType || approveType"
|
:business-no="approvalData.approveReason" />
|
</view>
|
<!-- 审批流程 -->
|
<ApproveFlowSteps :steps="approvalSteps" />
|
<!-- 审核意见输入 -->
|
<view v-if="canApprove"
|
class="approval-input">
|
<view class="input-header">
|
<text class="input-title">审核意见</text>
|
</view>
|
<view class="input-content">
|
<u-textarea v-model="approvalOpinion"
|
rows="4"
|
placeholder="请输入审核意见"
|
maxlength="200"
|
count />
|
</view>
|
</view>
|
<!-- 底部操作按钮 -->
|
<view v-if="canApprove"
|
class="footer-actions">
|
<u-button class="reject-btn"
|
@click="handleReject">驳回</u-button>
|
<u-button class="approve-btn"
|
@click="handleApprove">通过</u-button>
|
</view>
|
</view>
|
</template>
|
|
<script setup>
|
import { ref, onMounted, computed } from "vue";
|
import {
|
approveProcessGetInfo,
|
approveProcessDetails,
|
updateApproveNode,
|
} from "@/api/collaborativeApproval/approvalProcess";
|
import useUserStore from "@/store/modules/user";
|
import ApprovalBusinessDetail from "./_components/ApprovalBusinessDetail.vue";
|
import ApproveFlowSteps from "./_components/ApproveFlowSteps.vue";
|
import { mapApprovalSteps } from "./_utils/approveFlowSteps.js";
|
const showToast = message => {
|
uni.showToast({
|
title: message,
|
icon: "none",
|
});
|
};
|
import PageHeader from "@/components/PageHeader.vue";
|
|
const userStore = useUserStore();
|
const approvalData = ref({});
|
const approvalSteps = ref([]);
|
const approvalOpinion = ref("");
|
const approveId = ref("");
|
const approveType = ref(0);
|
|
/** 5 采购 / 6 报价 / 7 发货:需展示业务单据详情 */
|
const isBusinessApproval = computed(() =>
|
[5, 6, 7].includes(
|
Number(approvalData.value.approveType || approveType.value)
|
)
|
);
|
|
// 从详情接口字段对齐 canApprove:仅当有 isShen 的节点时可审批
|
const canApprove = computed(() => {
|
return approvalSteps.value.some(step => step.isShen === true);
|
});
|
|
onMounted(() => {
|
approveId.value = uni.getStorageSync("approveId");
|
approveType.value = Number(uni.getStorageSync("approveType")) || 0;
|
if (approveId.value) {
|
loadApprovalData();
|
}
|
});
|
|
const loadApprovalData = () => {
|
// 基本申请信息
|
approveProcessGetInfo({ id: approveId.value }).then(res => {
|
approvalData.value = res.data || {};
|
});
|
// 审批节点详情
|
approveProcessDetails(approveId.value).then(res => {
|
const list = Array.isArray(res.data) ? res.data : [];
|
// 保存原始节点数据供提交使用
|
activities.value = list;
|
approvalSteps.value = mapApprovalSteps(list);
|
});
|
};
|
|
const goBack = () => {
|
uni.removeStorageSync("approveId");
|
uni.navigateBack();
|
};
|
|
const submitForm = status => {
|
// 可选:校验审核意见
|
if (!approvalOpinion.value?.trim()) {
|
showToast("请输入审核意见");
|
return;
|
}
|
// 找到当前可审批节点
|
const filteredActivities = activities.value.filter(
|
activity => activity.isShen
|
);
|
if (!filteredActivities.length) {
|
showToast("当前无可审批节点");
|
return;
|
}
|
// 写入状态和意见
|
filteredActivities[0].approveNodeStatus = status;
|
filteredActivities[0].approveNodeReason = approvalOpinion.value || "";
|
// 计算是否为最后一步
|
const isLast =
|
activities.value.findIndex(a => a.isShen) === activities.value.length - 1;
|
// 调用后端
|
updateApproveNode({ ...filteredActivities[0], isLast }).then(() => {
|
const msg = status === 1 ? "审批通过" : "审批已驳回";
|
showToast(msg);
|
// 提示后返回上一个页面
|
setTimeout(() => {
|
goBack(); // 内部是 uni.navigateBack()
|
}, 800);
|
});
|
};
|
|
const handleApprove = () => {
|
uni.showModal({
|
title: "确认操作",
|
content: "确定要通过此审批吗?",
|
success: res => {
|
if (res.confirm) submitForm(1);
|
},
|
});
|
};
|
|
const handleReject = () => {
|
uni.showModal({
|
title: "确认操作",
|
content: "确定要驳回此审批吗?",
|
success: res => {
|
if (res.confirm) submitForm(2);
|
},
|
});
|
};
|
// 原始节点数据(用于提交逻辑)
|
const activities = ref([]);
|
</script>
|
|
<style scoped lang="scss">
|
.approve-page {
|
min-height: 100vh;
|
background: #f8f9fa;
|
padding-bottom: 80px;
|
}
|
|
.header {
|
display: flex;
|
align-items: center;
|
background: #fff;
|
padding: 16px 20px;
|
border-bottom: 1px solid #f0f0f0;
|
position: sticky;
|
top: 0;
|
z-index: 100;
|
}
|
|
.title {
|
flex: 1;
|
text-align: center;
|
font-size: 18px;
|
font-weight: 600;
|
color: #333;
|
}
|
|
.application-info {
|
background: #fff;
|
margin: 16px;
|
border-radius: 12px;
|
overflow: hidden;
|
}
|
|
.business-detail-wrap {
|
background: #fff;
|
margin: 16px;
|
border-radius: 12px;
|
overflow: hidden;
|
padding: 1px 0;
|
}
|
|
.info-header {
|
padding: 16px;
|
border-bottom: 1px solid #f0f0f0;
|
background: #f8f9fa;
|
}
|
|
.info-title {
|
font-size: 16px;
|
font-weight: 600;
|
color: #333;
|
}
|
|
.info-content {
|
padding: 16px;
|
}
|
|
.info-row {
|
display: flex;
|
align-items: center;
|
margin-bottom: 12px;
|
|
&:last-child {
|
margin-bottom: 0;
|
}
|
}
|
|
.info-label {
|
font-size: 14px;
|
color: #666;
|
width: 80px;
|
flex-shrink: 0;
|
}
|
|
.info-value {
|
font-size: 14px;
|
color: #333;
|
flex: 1;
|
}
|
|
.approval-input {
|
background: #fff;
|
margin: 16px;
|
border-radius: 12px;
|
overflow: hidden;
|
}
|
|
.input-header {
|
padding: 16px;
|
border-bottom: 1px solid #f0f0f0;
|
background: #f8f9fa;
|
}
|
|
.input-title {
|
font-size: 16px;
|
font-weight: 600;
|
color: #333;
|
}
|
|
.input-content {
|
padding: 16px;
|
}
|
|
.footer-actions {
|
position: fixed;
|
left: 0;
|
right: 0;
|
bottom: 0;
|
background: #fff;
|
display: flex;
|
justify-content: space-around;
|
align-items: center;
|
padding: 16px;
|
box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
|
z-index: 1000;
|
}
|
|
.reject-btn {
|
width: 120px;
|
background: #ff4d4f;
|
color: #fff;
|
}
|
|
.approve-btn {
|
width: 120px;
|
background: #52c41a;
|
color: #fff;
|
}
|
|
/* 适配u-button样式 */
|
:deep(.u-button) {
|
border-radius: 6px;
|
}
|
|
.signature-section {
|
background: #fff;
|
padding: 12px 16px 16px;
|
border-top: 1px solid #f0f0f0;
|
}
|
.signature-header {
|
margin-bottom: 8px;
|
}
|
.signature-title {
|
font-size: 14px;
|
font-weight: 600;
|
color: #333;
|
}
|
.signature-box {
|
width: 100%;
|
height: 180px;
|
background: #fff;
|
border: 1px dashed #d9d9d9;
|
border-radius: 8px;
|
overflow: hidden;
|
}
|
.signature-actions {
|
margin-top: 8px;
|
display: flex;
|
justify-content: flex-end;
|
}
|
</style>
|