feat(库存盘点): 已完成任务新增导出盘点明细(stock.check.exportDetail 异步导出)
This commit is contained in:
parent
dbf7654c0b
commit
460c8984b9
@ -1861,6 +1861,47 @@ export function stockCheckExportTaskProgress(
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ stock.check.exportDetail ============
|
||||
|
||||
/** 商品类任务的导出模式:location=按库位区分明细(默认)/ summary=明细汇总(每商品一行 + 商品差异 Sheet) */
|
||||
export type StockCheckExportDetailMode = 'location' | 'summary'
|
||||
|
||||
/** stock.check.exportDetail 请求参数(**单任务**导出,一次导一个盘点单) */
|
||||
export type StockCheckExportDetailParams = {
|
||||
/** 盘点任务ID(必填) */
|
||||
id: number
|
||||
/**
|
||||
* 仅**商品类任务**(明细 scope_type=goods)有效:
|
||||
* - location(默认)→ Sheet「库位明细」:每商品每库位一行(账面快照/盘点数量/差异)
|
||||
* - summary → Sheet1「明细汇总」(每商品一行)+ Sheet2「商品差异」(仅差异商品,含未知商品)
|
||||
* 库位类任务(明细 scope_type=location)忽略 mode,固定导出 Sheet「盘点明细」(库位/商品/盘点数量)。
|
||||
*/
|
||||
mode?: StockCheckExportDetailMode
|
||||
}
|
||||
|
||||
/**
|
||||
* stock.check.exportDetail:提交**盘点明细**导出任务(异步、单任务)。
|
||||
*
|
||||
* 立即返回任务ID(与 stock.check.export 同构:task_id/status/progress/current_count/
|
||||
* total_count/message/result/error),进度查询**复用** stock.check.exportTaskProgress
|
||||
* (Redis key TTL 1800 秒)。
|
||||
*/
|
||||
export function stockCheckExportDetail(
|
||||
data: StockCheckExportDetailParams
|
||||
): Promise<StockCheckEnvelope<StockCheckExportResponse>> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'stock.check.exportDetail',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ stock.check.batchDelete ============
|
||||
|
||||
/** stock.check.batchDelete 请求参数 */
|
||||
|
||||
@ -24,6 +24,8 @@
|
||||
3. 完成盘点(stock.check.finish,允许部分未盘完成:
|
||||
未盘商品明细按实盘 0 计入盘亏与差异行数,未盘库位明细不计差异)
|
||||
4. 「添加商品 / 添加库位」交给宿主 index.vue 打开 CheckStockPickerDialog(emit add-items)
|
||||
4b. 「导出明细」(仅 completed 任务)交给宿主 index.vue 走 stock.check.exportDetail
|
||||
(异步任务 + exportTaskProgress 进度弹窗,emit export-detail)
|
||||
5. 作业图片列:result 的 records[].images(RecordImages 缩略图 + 点击放大)
|
||||
|
||||
状态约束(与后端一致):
|
||||
@ -62,6 +64,16 @@
|
||||
>
|
||||
完成盘点
|
||||
</el-button>
|
||||
<!-- 导出盘点明细(stock.check.exportDetail,仅「已完成」任务) -->
|
||||
<el-button
|
||||
v-if="isCompleted"
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
@click="emit('export-detail')"
|
||||
>
|
||||
导出明细
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="right-actions">
|
||||
<span v-if="!useResultSource" class="hint-text">未开始盘点:仅展示盘点范围</span>
|
||||
@ -266,6 +278,8 @@ const props = defineProps<{
|
||||
const emit = defineEmits<{
|
||||
/** 点击「添加商品 / 添加库位」→ 宿主打开 CheckStockPickerDialog */
|
||||
(e: 'add-items'): void
|
||||
/** 点击「导出明细」→ 宿主提交 stock.check.exportDetail 导出任务(仅 completed 任务显示) */
|
||||
(e: 'export-detail'): void
|
||||
/** 明细发生变化(加商品 / 上报 / 完成)→ 宿主刷新列表 */
|
||||
(e: 'changed'): void
|
||||
}>()
|
||||
@ -283,6 +297,8 @@ const taskStatus = computed(() => String(props.row?.status ?? ''))
|
||||
const canAddItems = computed(() => ['created', 'rejected'].includes(taskStatus.value))
|
||||
/** approved/checking:可上报实盘、可完成 */
|
||||
const canReport = computed(() => ['approved', 'checking'].includes(taskStatus.value))
|
||||
/** completed:可导出盘点明细(stock.check.exportDetail) */
|
||||
const isCompleted = computed(() => taskStatus.value === 'completed')
|
||||
/** 库位类任务(type=all/location):明细为「库位行」,上报需带 stock_id → 在展开行里按商品上报 */
|
||||
const isLocationTask = computed(() => isLocationScopeType(props.row?.type))
|
||||
/**
|
||||
|
||||
@ -21,7 +21,8 @@
|
||||
* 完成 stock.check.finish → index.vue 操作列
|
||||
* 取消 stock.check.cancel → index.vue 操作列
|
||||
* 导出 stock.check.export → index.vue(useAsyncExportTask + 进度弹窗)
|
||||
* 导出进度 stock.check.exportTaskProgress → 同上
|
||||
* 导出明细 stock.check.exportDetail → index.vue 操作列 / CheckItemsPanel(单任务,仅 completed)
|
||||
* 导出进度 stock.check.exportTaskProgress → 同上(export 与 exportDetail 共用)
|
||||
*
|
||||
* ===== 状态机(主表 status)=====
|
||||
* created ──submit──> submitted ──audit(approve)──> approved ──report(首次)──> checking ──finish──> completed
|
||||
@ -1204,6 +1205,18 @@ const OPERATION_BUTTONS: OperationButtonConfig[] = [
|
||||
confirmType: 'warning',
|
||||
confirmButtonText: '确定取消',
|
||||
visibleWhen: (row) => ['created', 'submitted', 'rejected'].includes(String(row?.status))
|
||||
},
|
||||
/**
|
||||
* 导出盘点明细(stock.check.exportDetail):仅「已完成」任务可导出。
|
||||
* 异步任务(单任务),进度复用 stock.check.exportTaskProgress → index.vue 第二个
|
||||
* useAsyncExportTask 实例 + 进度弹窗;商品类任务默认按库位区分明细(mode 省略)。
|
||||
*/
|
||||
{
|
||||
key: 'exportDetail',
|
||||
label: '导出明细',
|
||||
actionType: 'action',
|
||||
type: 'primary',
|
||||
visibleWhen: (row) => String(row?.status) === 'completed'
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@ -153,6 +153,7 @@
|
||||
:detail-config="currentDetailConfig"
|
||||
:api-method="currentDetailTabApiMethod"
|
||||
@add-items="handlePanelAddItems"
|
||||
@export-detail="handlePanelExportDetail"
|
||||
@changed="handlePanelChanged"
|
||||
/>
|
||||
</div>
|
||||
@ -253,6 +254,20 @@
|
||||
:error="exportTaskProgress.error"
|
||||
:update-time="exportTaskProgress.updateTime"
|
||||
/>
|
||||
|
||||
<!-- ===== 盘点明细导出进度(stock.check.exportDetail + exportTaskProgress) ===== -->
|
||||
<AsyncExportProgressDialog
|
||||
v-model:visible="detailExportDialogVisible"
|
||||
title="导出盘点明细进度"
|
||||
:loading="detailExportLoading"
|
||||
:progress-percent="detailExportProgressPercent"
|
||||
:progress-status="detailExportProgressStatus"
|
||||
:status-label="detailExportStatusLabel"
|
||||
:task-id="detailExportTaskProgress.taskId"
|
||||
:message="detailExportTaskProgress.message"
|
||||
:error="detailExportTaskProgress.error"
|
||||
:update-time="detailExportTaskProgress.updateTime"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -297,6 +312,7 @@ import {
|
||||
stockCheckBatchDelete,
|
||||
stockCheckCancel,
|
||||
stockCheckExport,
|
||||
stockCheckExportDetail,
|
||||
stockCheckExportTaskProgress,
|
||||
stockCheckFinish,
|
||||
stockCheckSubmit
|
||||
@ -498,6 +514,9 @@ async function handleOperationAction(key: string, row: Record<string, any>) {
|
||||
case 'cancelCheck':
|
||||
await runCheckAction(() => stockCheckCancel({ id }), '盘点单已取消')
|
||||
break
|
||||
case 'exportDetail':
|
||||
await doExportDetail(row)
|
||||
break
|
||||
default:
|
||||
console.warn('[stockcheck] 未处理的操作按钮:', key)
|
||||
}
|
||||
@ -595,6 +614,52 @@ async function doExport() {
|
||||
await submitExportTask({ ids: targetIds })
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 导出盘点明细(stock.check.exportDetail 单任务异步导出,进度复用 exportTaskProgress)
|
||||
// ============================================================
|
||||
const {
|
||||
exportLoading: detailExportLoading,
|
||||
exportDialogVisible: detailExportDialogVisible,
|
||||
exportTaskProgress: detailExportTaskProgress,
|
||||
exportProgressPercent: detailExportProgressPercent,
|
||||
exportProgressStatus: detailExportProgressStatus,
|
||||
exportStatusLabel: detailExportStatusLabel,
|
||||
submitExportTask: submitDetailExportTask,
|
||||
resumeExportTaskFromStorage: resumeDetailExportTaskFromStorage
|
||||
} = useAsyncExportTask({
|
||||
storageKey: 'stock-check-export-detail-task',
|
||||
submitExport: (payload) => stockCheckExportDetail(payload as any),
|
||||
queryProgress: (params) => stockCheckExportTaskProgress(params)
|
||||
})
|
||||
|
||||
/**
|
||||
* 导出单个盘点单的盘点明细(仅「已完成」任务)
|
||||
*
|
||||
* 商品类任务默认按库位区分明细(不传 mode → 后端默认 location);
|
||||
* 库位类任务后端忽略 mode,导出 Sheet「盘点明细」。
|
||||
*/
|
||||
async function doExportDetail(row: Record<string, any> | null | undefined) {
|
||||
const id = Number(row?.id)
|
||||
if (!Number.isFinite(id) || id <= 0) {
|
||||
ElMessage.warning('未识别到有效的盘点任务ID')
|
||||
return
|
||||
}
|
||||
if (String(row?.status ?? '') !== 'completed') {
|
||||
ElMessage.warning('仅「已完成」的盘点任务可导出盘点明细')
|
||||
return
|
||||
}
|
||||
if (detailExportLoading.value) {
|
||||
ElMessage.warning('已有盘点明细导出任务提交中,请稍候')
|
||||
return
|
||||
}
|
||||
await submitDetailExportTask({ id })
|
||||
}
|
||||
|
||||
/** 明细面板「导出明细」按钮(目标为当前选中行) */
|
||||
function handlePanelExportDetail() {
|
||||
void doExportDetail(selectedRow.value)
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 批量删除(stock.check.batchDelete:仅删除「已作废(cancelled)」任务)
|
||||
// ============================================================
|
||||
@ -952,6 +1017,8 @@ onMounted(() => {
|
||||
void loadStoreOptions()
|
||||
// 恢复未完成的导出任务(刷新页面后可继续查看进度)
|
||||
resumeExportTaskFromStorage()
|
||||
// 盘点明细导出任务同样可恢复(独立 storageKey)
|
||||
resumeDetailExportTaskFromStorage()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user