fix(signing): align workbench with MEDISIGN contract
This commit is contained in:
@@ -48,7 +48,6 @@ const STATUS_VALUES: SigningTaskStatus[] = [
|
||||
'pending',
|
||||
'signing',
|
||||
'signed',
|
||||
'rejected',
|
||||
'expired',
|
||||
'void',
|
||||
'failed',
|
||||
@@ -59,7 +58,6 @@ const statusLabels: Record<SigningTaskStatus, string> = {
|
||||
pending: '待签署',
|
||||
signing: '签署中',
|
||||
signed: '已签署',
|
||||
rejected: '已拒签',
|
||||
expired: '已超时',
|
||||
void: '已作废',
|
||||
failed: '处理失败',
|
||||
@@ -78,6 +76,8 @@ const filter = reactive<SigningFilterForm>({
|
||||
|
||||
const tasks = ref<SigningTaskRecord[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(20)
|
||||
const selectedTaskId = ref<string | null>(null)
|
||||
const selectedTask = ref<SigningTaskRecord | null>(null)
|
||||
const taskEvents = ref<SigningTaskEvent[]>([])
|
||||
@@ -145,6 +145,7 @@ const documentOptions = computed<SigningFilterOption[]>(() => [
|
||||
const signingApiOptions = computed(() => ({
|
||||
campus: appStore.selectedCampus,
|
||||
campusId: campusIds.value[appStore.selectedCampus],
|
||||
campusIds: campusIds.value,
|
||||
campusNames: campusNames.value,
|
||||
departmentIds: departmentIds.value,
|
||||
templates: templates.value,
|
||||
@@ -275,7 +276,11 @@ async function loadTaskDetail(id: string | null) {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadTasks(preferredTaskId?: string) {
|
||||
async function loadTasks(preferredTaskId?: string, resetPage = false) {
|
||||
if (resetPage) {
|
||||
page.value = 1
|
||||
}
|
||||
|
||||
const requestId = ++listRequestId
|
||||
loading.value = true
|
||||
|
||||
@@ -283,8 +288,8 @@ async function loadTasks(preferredTaskId?: string) {
|
||||
const response = await getSigningTasks(
|
||||
{
|
||||
...filter,
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
},
|
||||
signingApiOptions.value,
|
||||
)
|
||||
@@ -295,6 +300,8 @@ async function loadTasks(preferredTaskId?: string) {
|
||||
|
||||
tasks.value = response.records
|
||||
total.value = response.total
|
||||
page.value = response.page
|
||||
pageSize.value = response.pageSize
|
||||
|
||||
const taskIds = new Set(response.records.map((task) => task.id))
|
||||
const routeTaskId = getQueryString(route.query.taskId)
|
||||
@@ -323,7 +330,7 @@ async function loadTasks(preferredTaskId?: string) {
|
||||
function handleSearch(nextFilter: SigningFilterForm) {
|
||||
Object.assign(filter, nextFilter)
|
||||
selectedTaskId.value = null
|
||||
void loadTasks()
|
||||
void loadTasks(undefined, true)
|
||||
}
|
||||
|
||||
function selectTask(id: string) {
|
||||
@@ -331,13 +338,25 @@ function selectTask(id: string) {
|
||||
void loadTaskDetail(id)
|
||||
}
|
||||
|
||||
function handlePageChange(nextPage: number) {
|
||||
const pageCount = Math.max(Math.ceil(total.value / pageSize.value), 1)
|
||||
|
||||
if (nextPage < 1 || nextPage > pageCount || nextPage === page.value) {
|
||||
return
|
||||
}
|
||||
|
||||
page.value = nextPage
|
||||
selectedTaskId.value = null
|
||||
void loadTasks()
|
||||
}
|
||||
|
||||
async function refreshTask(updatedTask: SigningTaskRecord | null, successMessage: string) {
|
||||
if (!updatedTask) {
|
||||
ElMessage.error('签署任务不存在或已被删除')
|
||||
return
|
||||
}
|
||||
|
||||
await loadTasks(updatedTask.id)
|
||||
await loadTasks(updatedTask.id, true)
|
||||
ElMessage.success(successMessage)
|
||||
}
|
||||
|
||||
@@ -389,15 +408,18 @@ async function handleTaskAction(action: SigningTaskAction) {
|
||||
return
|
||||
}
|
||||
|
||||
if (action === 'reopen' && task.status !== 'expired') {
|
||||
ElMessage.info('只有已超时任务可以重新发起')
|
||||
return
|
||||
}
|
||||
|
||||
if (action === 'download-pdf') {
|
||||
const artifact =
|
||||
artifacts.value.find((item) => item.artifactType === 'SIGNED_PDF') ??
|
||||
artifacts.value.find((item) => item.artifactType === 'ORIGINAL_PDF')
|
||||
const artifact = artifacts.value.find((item) => item.artifactType === 'SIGNED_PDF')
|
||||
|
||||
if (artifact) {
|
||||
await downloadArtifact(artifact)
|
||||
} else {
|
||||
ElMessage.info('当前任务暂无 PDF 文件')
|
||||
ElMessage.info('当前任务暂无签署后 PDF')
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -535,13 +557,14 @@ async function initializePage() {
|
||||
}
|
||||
|
||||
async function handleTaskCreated(task: SigningTaskRecord) {
|
||||
await loadTasks(task.id)
|
||||
await loadTasks(task.id, true)
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [route.query.status, route.query.range, route.query.taskId],
|
||||
() => {
|
||||
syncFilterFromRoute()
|
||||
page.value = 1
|
||||
selectedTaskId.value = null
|
||||
void loadTasks()
|
||||
},
|
||||
@@ -553,6 +576,7 @@ watch(
|
||||
if (filter.campus !== 'all') {
|
||||
filter.campus = campus
|
||||
}
|
||||
page.value = 1
|
||||
void loadTasks()
|
||||
},
|
||||
)
|
||||
@@ -593,8 +617,11 @@ onMounted(() => {
|
||||
:tasks="tasks"
|
||||
:selected-id="selectedTaskId"
|
||||
:total="total"
|
||||
:page="page"
|
||||
:page-size="pageSize"
|
||||
:loading="loading"
|
||||
@select="selectTask"
|
||||
@page-change="handlePageChange"
|
||||
/>
|
||||
<SigningTaskDetail
|
||||
:task="selectedTask"
|
||||
|
||||
Reference in New Issue
Block a user