feat: 借库审批支持手动完结——已通过(status=1)单可强制完结,库管/主管/超管可见
This commit is contained in:
@ -174,6 +174,14 @@ export function approveBorrowRequest(id: number, data: { action: 'approve' | 're
|
||||
})
|
||||
}
|
||||
|
||||
// 手动完结已通过的借库审批单(status 1 → 3)
|
||||
export function closeBorrowRequest(id: number) {
|
||||
return request({
|
||||
url: `/v1/transactions/borrow/request/${id}/close`,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 借库选单专用库存列表(独立权限 op_borrow_apply)
|
||||
*/
|
||||
|
||||
@ -137,6 +137,19 @@
|
||||
驳回
|
||||
</el-button>
|
||||
</template>
|
||||
<!-- ★ 已通过的申请单:库管/主管可手动完结 -->
|
||||
<template v-else-if="row.status === 1">
|
||||
<el-button
|
||||
v-if="canCompleteRequest"
|
||||
type="danger"
|
||||
plain
|
||||
size="small"
|
||||
:loading="row._closing"
|
||||
@click="handleComplete(row)"
|
||||
>
|
||||
完结
|
||||
</el-button>
|
||||
</template>
|
||||
<span v-else style="color: #c0c4cc;">-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -182,14 +195,44 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { Refresh, Warning } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { getBorrowApprovalList, approveBorrowRequest } from '@/api/transaction'
|
||||
import { getBorrowApprovalList, approveBorrowRequest, closeBorrowRequest } from '@/api/transaction'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
// ★ 完结权限:超管 / 审批操作(op_borrow_approval:operation) / 借库执行(op_borrow:operation)
|
||||
const canCompleteRequest = computed(() =>
|
||||
userStore.role === 'SUPER_ADMIN' ||
|
||||
userStore.hasPermission('op_borrow_approval:operation') ||
|
||||
userStore.hasPermission('op_borrow:operation') ||
|
||||
userStore.username === 'IRIS'
|
||||
)
|
||||
|
||||
// ★ 手动完结已通过的借库审批单(status 1 → 3,仿出库审批)
|
||||
const handleComplete = (row: any) => {
|
||||
ElMessageBox.confirm(
|
||||
`确定强制完结审批单【${row.request_no}】吗?\n\n完结后该单标记为「已完成」,不可再扫码借出。`,
|
||||
'⚠️ 强制完结确认',
|
||||
{ confirmButtonText: '确认完结', cancelButtonText: '取消', type: 'warning' }
|
||||
)
|
||||
.then(async () => {
|
||||
row._closing = true
|
||||
try {
|
||||
await closeBorrowRequest(row.id)
|
||||
ElMessage.success('审批单已完结')
|
||||
fetchData()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.response?.data?.msg || e?.msg || e?.message || '完结失败')
|
||||
} finally {
|
||||
row._closing = false
|
||||
}
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
// --- 状态 ---
|
||||
const list = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
|
||||
Reference in New Issue
Block a user