feat(approval): 员工端存档确认与归档动作 (#21)
- 详情页新增“存档确认”(无意见)与“归档”动作 - 展示存档确认人/状态(已确认、待确认)/时间与归档人/时间 - 归档后隐藏全部动作,页面只读
This commit is contained in:
@@ -44,6 +44,32 @@ export async function rejectTask(id: number, opinion: string) {
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 存档确认(无意见,只能确认)
|
||||
*/
|
||||
export async function confirmTask(id: number) {
|
||||
const res = await request.post<ApiResult<ApprovalInstance>>(
|
||||
THINK_API_URL + '/approval/task/' + id + '/confirm'
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 归档(或签,归档后单据只读)
|
||||
*/
|
||||
export async function archiveTask(id: number) {
|
||||
const res = await request.post<ApiResult<ApprovalInstance>>(
|
||||
THINK_API_URL + '/approval/task/' + id + '/archive'
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回
|
||||
*/
|
||||
|
||||
@@ -33,6 +33,18 @@
|
||||
<text class="label">提交时间</text>
|
||||
<text class="value">{{ formatTime(detail.submitTime) }}</text>
|
||||
</view>
|
||||
<view class="row">
|
||||
<text class="label">审批完成时间</text>
|
||||
<text class="value">{{ formatTime(detail.approveTime) }}</text>
|
||||
</view>
|
||||
<view v-if="detail.archiveTime" class="row">
|
||||
<text class="label">归档时间</text>
|
||||
<text class="value">{{ formatTime(detail.archiveTime) }}</text>
|
||||
</view>
|
||||
<view v-if="detail.archiveTime" class="row">
|
||||
<text class="label">归档人</text>
|
||||
<text class="value">{{ detail.archivistName || '—' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</uni-card>
|
||||
|
||||
@@ -109,6 +121,23 @@
|
||||
<view v-if="detail.records.length === 0" class="empty">暂无记录</view>
|
||||
</uni-card>
|
||||
|
||||
<uni-card
|
||||
v-if="detail.confirms && detail.confirms.length > 0"
|
||||
:border="false"
|
||||
:padding="'16px'"
|
||||
title="存档确认"
|
||||
>
|
||||
<view v-for="item in detail.confirms" :key="item.userId" class="confirm-item">
|
||||
<view class="confirm-main">
|
||||
<text class="confirm-name">{{ item.userName || '—' }}</text>
|
||||
<text class="confirm-time">{{ item.handleTime ? formatTime(item.handleTime) : '—' }}</text>
|
||||
</view>
|
||||
<text class="confirm-status" :class="'confirm-' + item.status">
|
||||
{{ item.statusName }}
|
||||
</text>
|
||||
</view>
|
||||
</uni-card>
|
||||
|
||||
<view v-if="hasActions" class="actions">
|
||||
<button
|
||||
v-if="detail.myTask && detail.permissions.canApprove"
|
||||
@@ -124,6 +153,22 @@
|
||||
>
|
||||
驳回
|
||||
</button>
|
||||
<button
|
||||
v-if="detail.myTask && detail.permissions.canConfirm"
|
||||
class="action-button primary"
|
||||
:loading="submitting"
|
||||
@click="confirmArchiveAction('confirm')"
|
||||
>
|
||||
存档确认
|
||||
</button>
|
||||
<button
|
||||
v-if="detail.myTask && detail.permissions.canArchive"
|
||||
class="action-button primary"
|
||||
:loading="submitting"
|
||||
@click="confirmArchiveAction('archive')"
|
||||
>
|
||||
归档
|
||||
</button>
|
||||
<button
|
||||
v-if="detail.permissions.canWithdraw"
|
||||
class="action-button ghost"
|
||||
@@ -179,6 +224,8 @@ import { onLoad } from '@dcloudio/uni-app';
|
||||
import { getInstance, submitInstance } from '@/api/approval/instance';
|
||||
import {
|
||||
approveTask,
|
||||
archiveTask,
|
||||
confirmTask,
|
||||
rejectTask,
|
||||
withdrawInstance
|
||||
} from '@/api/approval/task';
|
||||
@@ -194,12 +241,14 @@ const opinion = ref('');
|
||||
|
||||
const hasActions = computed(() => {
|
||||
const permissions = detail.value?.permissions;
|
||||
if (!permissions) {
|
||||
if (!permissions || detail.value?.status === 'ARCHIVED') {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
permissions.canApprove ||
|
||||
permissions.canReject ||
|
||||
permissions.canConfirm ||
|
||||
permissions.canArchive ||
|
||||
permissions.canWithdraw ||
|
||||
permissions.canSubmit ||
|
||||
permissions.canEdit
|
||||
@@ -288,6 +337,41 @@ async function confirmAction() {
|
||||
}
|
||||
}
|
||||
|
||||
function confirmArchiveAction(action: 'confirm' | 'archive') {
|
||||
const taskId = detail.value?.myTask?.id;
|
||||
if (!taskId) {
|
||||
showError('任务已处理,请刷新后重试', null);
|
||||
return;
|
||||
}
|
||||
const isConfirm = action === 'confirm';
|
||||
uni.showModal({
|
||||
title: isConfirm ? '存档确认' : '归档确认',
|
||||
content: isConfirm
|
||||
? '存档只能确认,确认后单据进入归档流程。确认存档?'
|
||||
: '归档后单据为只读终态,不可退回或修改。确认归档?',
|
||||
success: async result => {
|
||||
if (!result.confirm) {
|
||||
return;
|
||||
}
|
||||
submitting.value = true;
|
||||
try {
|
||||
const response = isConfirm
|
||||
? await confirmTask(taskId)
|
||||
: await archiveTask(taskId);
|
||||
uni.showToast({
|
||||
title: response.message || (isConfirm ? '已存档' : '已归档'),
|
||||
icon: 'none'
|
||||
});
|
||||
await load();
|
||||
} catch (error: any) {
|
||||
showError(error?.message || '操作失败', null);
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function withdraw() {
|
||||
uni.showModal({
|
||||
title: '撤回确认',
|
||||
@@ -541,6 +625,53 @@ function formatSize(value?: number) {
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.confirm-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 16rpx 0;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.confirm-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.confirm-name {
|
||||
font-size: 26rpx;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.confirm-time {
|
||||
margin-top: 6rpx;
|
||||
font-size: 24rpx;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.confirm-status {
|
||||
font-size: 24rpx;
|
||||
padding: 4rpx 14rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #f2f3f5;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.confirm-PENDING {
|
||||
background: #fff7e6;
|
||||
color: #d46b08;
|
||||
}
|
||||
|
||||
.confirm-DONE {
|
||||
background: #f6ffed;
|
||||
color: #389e0d;
|
||||
}
|
||||
|
||||
.confirm-CANCELLED {
|
||||
background: #f2f3f5;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.empty {
|
||||
padding: 24rpx 0;
|
||||
text-align: center;
|
||||
|
||||
Reference in New Issue
Block a user