1
This commit is contained in:
parent
8d9360bb9f
commit
1fc20db3d5
BIN
dist.tar.gz
BIN
dist.tar.gz
Binary file not shown.
@ -40,14 +40,16 @@ export function create(data: {
|
||||
server_id: number
|
||||
channel_id: number
|
||||
channel_name?: string
|
||||
custom_name?: string
|
||||
status?: number
|
||||
username?: string
|
||||
password?: string
|
||||
remark?: string
|
||||
ip?: string
|
||||
port?: number
|
||||
model?: string
|
||||
serial_number?: string
|
||||
stream_type?: string
|
||||
custom_name?: string
|
||||
status?: number
|
||||
remark?: string
|
||||
}) {
|
||||
return request({
|
||||
url: '/system',
|
||||
@ -68,14 +70,16 @@ export function update(data: {
|
||||
server_id?: number
|
||||
channel_id?: number
|
||||
channel_name?: string
|
||||
custom_name?: string
|
||||
status?: number
|
||||
username?: string
|
||||
password?: string
|
||||
remark?: string
|
||||
ip?: string
|
||||
port?: number
|
||||
model?: string
|
||||
serial_number?: string
|
||||
stream_type?: string
|
||||
custom_name?: string
|
||||
status?: number
|
||||
remark?: string
|
||||
}) {
|
||||
return request({
|
||||
url: '/system',
|
||||
@ -90,6 +94,26 @@ export function update(data: {
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 设置摄像头 OSD 文字叠加 */
|
||||
export function setOsd(data: {
|
||||
id: number
|
||||
text: string
|
||||
x?: number
|
||||
y?: number
|
||||
}) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'camera.setOsd',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 删除摄像头(软删除) */
|
||||
export function del(data: { id: number }) {
|
||||
return request({
|
||||
|
||||
@ -419,6 +419,55 @@ export function queryRecheckOrderSingleList(
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** order.recheckOrder.batchQuickRecheckByWave 请求参数 */
|
||||
export type BatchQuickRecheckByWaveParams = {
|
||||
wave_ids: number[] | string
|
||||
waveIds?: number[] | string
|
||||
wave_id?: number
|
||||
}
|
||||
|
||||
/** order.recheckOrder.batchQuickRecheckByWave 响应 data */
|
||||
export type BatchQuickRecheckByWaveResponse = {
|
||||
success: unknown[]
|
||||
failed: unknown[]
|
||||
success_count: number
|
||||
failed_count: number
|
||||
}
|
||||
|
||||
function pickWaveIdsBody(data: BatchQuickRecheckByWaveParams): Record<string, number[] | string> {
|
||||
if (Array.isArray(data.wave_ids) && data.wave_ids.length > 0) {
|
||||
return { wave_ids: data.wave_ids }
|
||||
}
|
||||
if (typeof data.wave_ids === 'string' && data.wave_ids.trim() !== '') {
|
||||
return { wave_ids: data.wave_ids.trim() }
|
||||
}
|
||||
if (Array.isArray(data.waveIds) && data.waveIds.length > 0) {
|
||||
return { wave_ids: data.waveIds }
|
||||
}
|
||||
if (typeof data.waveIds === 'string' && data.waveIds.trim() !== '') {
|
||||
return { wave_ids: data.waveIds.trim() }
|
||||
}
|
||||
if (data.wave_id !== undefined && data.wave_id !== null) {
|
||||
return { wave_ids: [data.wave_id] }
|
||||
}
|
||||
throw new Error('波次 ID 不能为空(wave_ids / waveIds / wave_id)')
|
||||
}
|
||||
|
||||
/** order.recheckOrder.batchQuickRecheckByWave:按波次批量快捷复核 */
|
||||
export function batchQuickRecheckByWave(data: BatchQuickRecheckByWaveParams): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'order.recheckOrder.batchQuickRecheckByWave',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data: pickWaveIdsBody(data),
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** order.recheckOrder.confirmIntercept:确认拦截,入参 order_id,匹配单个订单并标记拦截 */
|
||||
export function confirmIntercept(data: ConfirmRecheckParams): Promise<any> {
|
||||
return request({
|
||||
@ -437,6 +486,7 @@ export function confirmIntercept(data: ConfirmRecheckParams): Promise<any> {
|
||||
export const orderRecheckOrder = {
|
||||
scanOrder,
|
||||
batchQuickRecheck,
|
||||
batchQuickRecheckByWave,
|
||||
confirmRecheck,
|
||||
confirmIntercept,
|
||||
queryRecheckOrderSingleList
|
||||
|
||||
@ -348,3 +348,44 @@ export function notify_lock(data?: PrintNotifyLockParams) {
|
||||
data: data ?? {}
|
||||
})
|
||||
}
|
||||
|
||||
/** print.markWavePrintStatus 请求参数 */
|
||||
export type MarkWavePrintStatusParams = {
|
||||
/** 波次ID(必填,正整数) */
|
||||
wave_id: number
|
||||
/** 目标状态:'printed'=标记已打印,'unprinted'=取消已打印标记。默认 'printed' */
|
||||
status?: 'printed' | 'unprinted'
|
||||
}
|
||||
|
||||
/** print.markWavePrintStatus 响应 data */
|
||||
export type MarkWavePrintStatusResponse = {
|
||||
wave_id?: number
|
||||
status?: string
|
||||
print_status?: string
|
||||
total_orders?: number
|
||||
affected_orders?: number
|
||||
order_ids?: Array<number | string>
|
||||
}
|
||||
|
||||
/** 标记/取消标记整个波次订单的打印状态 */
|
||||
export function markWavePrintStatus(data: MarkWavePrintStatusParams): Promise<any> {
|
||||
const waveId = Number(data.wave_id)
|
||||
if (!Number.isFinite(waveId) || waveId <= 0) {
|
||||
return Promise.reject(new Error('print.markWavePrintStatus:wave_id 必须为正整数'))
|
||||
}
|
||||
const body: Record<string, unknown> = { wave_id: waveId }
|
||||
if (data.status) {
|
||||
body.status = data.status
|
||||
}
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'print.markWavePrintStatus',
|
||||
v,
|
||||
timestamp: stamp()
|
||||
},
|
||||
data: body,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
@ -74,6 +74,8 @@ export function shopsEdit(data: {
|
||||
export function shopGetAuthorizeSessionKey(data: {
|
||||
id: number
|
||||
callbackurl?: string
|
||||
appId?: string
|
||||
toUserName?: string
|
||||
}) {
|
||||
return request({
|
||||
url: '/system',
|
||||
|
||||
@ -164,6 +164,81 @@ export function getExpiryList(data: any): Promise<any> {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
/** storage.inventory.export 请求参数 */
|
||||
export type InventoryExportParams = {
|
||||
/** 导出模式:'stock_location'(默认,按商品+库位聚合)| 'storage'(按库存记录逐条导出) */
|
||||
exportMode?: 'stock_location' | 'storage'
|
||||
/** 统一 where 条件对象,与 storage.inventory.list 的 where 语义一致 */
|
||||
where?: Record<string, any>
|
||||
/** 排序参数 { sortField, sortOrder } */
|
||||
sort?: {
|
||||
sortField?: string
|
||||
sortOrder?: 'ASC' | 'DESC'
|
||||
}
|
||||
/** 是否按批次查询导出,对齐查询模式 group_by_batch */
|
||||
group_by_batch?: boolean
|
||||
}
|
||||
|
||||
/** storage.inventory.export 响应 data */
|
||||
export type InventoryExportResponse = {
|
||||
task_id?: string
|
||||
status?: string
|
||||
progress?: number
|
||||
message?: string
|
||||
update_time?: number
|
||||
}
|
||||
|
||||
/** 提交库存导出异步任务 */
|
||||
export function exportInventory(data: InventoryExportParams = {}): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.inventory.export',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** storage.inventory.exportTaskProgress 请求参数 */
|
||||
export type ExportTaskProgressParams = {
|
||||
task_id?: string
|
||||
taskId?: string
|
||||
}
|
||||
|
||||
/** storage.inventory.exportTaskProgress 响应 data */
|
||||
export type ExportTaskProgressResponse = {
|
||||
task_id?: string
|
||||
status?: string
|
||||
progress?: number
|
||||
message?: string
|
||||
result?: Record<string, unknown>
|
||||
error?: string
|
||||
download_url?: string
|
||||
}
|
||||
|
||||
/** 按 task_id 查询库存导出任务进度 */
|
||||
export function exportTaskProgress(data: ExportTaskProgressParams): Promise<any> {
|
||||
const taskId = data.task_id || data.taskId
|
||||
if (!taskId) {
|
||||
throw new Error('task_id 不能为空')
|
||||
}
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.inventory.exportTaskProgress',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: { task_id: taskId },
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
// export function transaction(data:any) {
|
||||
// return request({
|
||||
// url: '/system',
|
||||
|
||||
@ -10,29 +10,55 @@
|
||||
{{ label }}
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="handleExportWaybill">不含明细</el-dropdown-item>
|
||||
<el-dropdown-item command="handleExportItem" divided>含明细</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
v-for="item in resolvedItems"
|
||||
:key="item.action"
|
||||
:command="item.action"
|
||||
:divided="item.divided"
|
||||
>
|
||||
{{ item.label }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(
|
||||
import { computed } from 'vue'
|
||||
|
||||
export interface ExportDropdownItem {
|
||||
label: string
|
||||
action: string
|
||||
divided?: boolean
|
||||
}
|
||||
|
||||
const DEFAULT_ITEMS: ExportDropdownItem[] = [
|
||||
{ label: '不含明细', action: 'handleExportWaybill' },
|
||||
{ label: '含明细', action: 'handleExportItem', divided: true }
|
||||
]
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
label?: string
|
||||
loading?: boolean
|
||||
disabled?: boolean
|
||||
defaultAction?: string
|
||||
items?: ExportDropdownItem[]
|
||||
}>(),
|
||||
{
|
||||
label: '导出',
|
||||
loading: false,
|
||||
disabled: false,
|
||||
defaultAction: 'handleExportWaybill'
|
||||
defaultAction: 'handleExportWaybill',
|
||||
items: () => []
|
||||
}
|
||||
)
|
||||
|
||||
const resolvedItems = computed(() => {
|
||||
if (props.items && props.items.length > 0) return props.items
|
||||
return DEFAULT_ITEMS
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'action', action: string): void
|
||||
}>()
|
||||
|
||||
@ -340,7 +340,7 @@ async function loadScanBoxOptions() {
|
||||
])
|
||||
const expressRaw: any[] = expressRes?.data?.list ?? expressRes?.data ?? []
|
||||
const platformRaw: any[] = platformRes?.data?.list ?? platformRes?.data ?? []
|
||||
const storesRaw: any[] = storesRes?.stores ?? []
|
||||
const storesRaw: any[] = (storesRes as any)?.data?.stores ?? (storesRes as any)?.stores ?? []
|
||||
|
||||
const expressOptions = expressRaw.map((item: any) => ({
|
||||
label: `${item.code ?? item.logistics_code ?? ''} — ${item.name ?? item.logistics_name ?? ''}`,
|
||||
|
||||
@ -138,10 +138,6 @@
|
||||
<span class="order-info-text">{{ row.item_detail_machine || '—' }}</span>
|
||||
</template>
|
||||
|
||||
<template #column-item_snapshot_key="{ row }">
|
||||
<span class="order-info-text">{{ row.item_snapshot_key || '—' }}</span>
|
||||
</template>
|
||||
|
||||
<template #column-item_snapshot="{ row }">
|
||||
<span class="order-info-text">{{ getItemSnapshotText(row) }}</span>
|
||||
</template>
|
||||
@ -173,6 +169,15 @@
|
||||
>
|
||||
批量拣货
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="warning"
|
||||
size="small"
|
||||
:loading="isTogglePrintStatusLoading(row)"
|
||||
@click.stop="handleToggleWavePrintStatus(row)"
|
||||
>
|
||||
{{ getPrintStatusButtonText(row) }}
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template #empty>
|
||||
@ -928,6 +933,8 @@ import {
|
||||
orderWaveFetchTaskProgress,
|
||||
orderWaveGroupOrderFetchList
|
||||
} from '@/api/order.wave/orderwave'
|
||||
import { batchQuickRecheckByWave } from '@/api/order.recheckorder/recheckOrder'
|
||||
import { markWavePrintStatus } from '@/api/print/print'
|
||||
import { orderWaveBatchList, unwrapWaveBatchListResponse } from '@/api/order/order'
|
||||
import type {
|
||||
WaveBatchAutoGroupingResponse,
|
||||
@ -987,6 +994,8 @@ const onlyTodoWaves = ref(false)
|
||||
const batchAutoGroupingLoading = ref(false)
|
||||
const batchFinishAutoGroupingLoading = ref(false)
|
||||
const batchCancelLoading = ref(false)
|
||||
const batchQuickRecheckByWaveLoading = ref(false)
|
||||
const printStatusLoadingRowIds = ref<Set<number | string>>(new Set())
|
||||
const batchPrintLoading = ref(false)
|
||||
const batchOutboundPrintLoading = ref(false)
|
||||
const batchPlatformPrintLoading = ref(false)
|
||||
@ -1186,6 +1195,7 @@ const buttonLoadingMap = computed(() => ({
|
||||
batchAutoGroupingLoading: batchAutoGroupingLoading.value,
|
||||
batchFinishAutoGroupingLoading: batchFinishAutoGroupingLoading.value,
|
||||
batchCancelLoading: batchCancelLoading.value,
|
||||
batchQuickRecheckByWaveLoading: batchQuickRecheckByWaveLoading.value,
|
||||
batchPrintLoading: batchPrintLoading.value,
|
||||
batchOutboundPrintLoading: batchOutboundPrintLoading.value,
|
||||
batchPlatformPrintLoading: batchPlatformPrintLoading.value,
|
||||
@ -1209,6 +1219,7 @@ const buttonLabelMap = computed(() => ({
|
||||
batchOutboundPrintTotal: `批量打印出库单(${selectedWaveOrderTotal.value})`,
|
||||
batchPlatformPrintTotal: `批量打印(平台)(${selectedWaveOrderTotal.value})`,
|
||||
batchPickingPrintTotal: `批量打印拣货单(${selectionRows.value.length})`,
|
||||
batchQuickRecheckByWaveTotal: `批量发货(${selectionRows.value.length})`,
|
||||
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
|
||||
}))
|
||||
|
||||
@ -1258,6 +1269,9 @@ const toolbarActionMap: Record<string, () => void> = {
|
||||
handleBatchCancel: () => {
|
||||
void handleBatchCancel()
|
||||
},
|
||||
handleBatchQuickRecheckByWave: () => {
|
||||
void handleBatchQuickRecheckByWave()
|
||||
},
|
||||
handleBatchAllocateExpress: () => {
|
||||
void handleBatchAllocateExpress()
|
||||
},
|
||||
@ -2862,6 +2876,105 @@ async function handleBatchCancel() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleBatchQuickRecheckByWave() {
|
||||
if (!selectionRows.value.length) {
|
||||
ElMessage.warning('请先勾选要批量发货的波次')
|
||||
return
|
||||
}
|
||||
|
||||
const waveIds = getSelectedWaveIds()
|
||||
if (!waveIds.length) {
|
||||
ElMessage.warning('当前勾选记录缺少可用的波次 ID')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定要对 ${waveIds.length} 个波次执行批量发货(快捷复核)吗?`,
|
||||
'批量发货',
|
||||
{ type: 'warning', confirmButtonText: '确认发货', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
batchQuickRecheckByWaveLoading.value = true
|
||||
try {
|
||||
const res = await batchQuickRecheckByWave({ wave_ids: waveIds })
|
||||
const data = res?.data || res
|
||||
if (data && (data.success_count !== undefined || data.failed_count !== undefined)) {
|
||||
const successCount = data.success_count || 0
|
||||
const failedCount = data.failed_count || 0
|
||||
if (failedCount > 0) {
|
||||
ElMessage.warning(`批量发货完成:成功 ${successCount} 个,失败 ${failedCount} 个`)
|
||||
} else {
|
||||
ElMessage.success(`批量发货完成:成功 ${successCount} 个`)
|
||||
}
|
||||
} else {
|
||||
ElMessage.success('批量发货请求已提交')
|
||||
}
|
||||
selectionRows.value = []
|
||||
hasSelection.value = false
|
||||
await loadData()
|
||||
} catch (error: any) {
|
||||
console.error('batchQuickRecheckByWave failed:', error)
|
||||
ElMessage.error(error?.message || '批量发货失败')
|
||||
} finally {
|
||||
batchQuickRecheckByWaveLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function getPrintStatusButtonText(row: any): string {
|
||||
return getPrintStatusNormalized(row) === 'printed' ? '标记未打印' : '标记已打印'
|
||||
}
|
||||
|
||||
function isTogglePrintStatusLoading(row: any) {
|
||||
const id = row?.wave_id ?? row?.id
|
||||
return id != null && printStatusLoadingRowIds.value.has(id)
|
||||
}
|
||||
|
||||
function getPrintStatusNormalized(row: any): string {
|
||||
const raw = String(row?.print_assignment_status ?? '').trim().toLowerCase()
|
||||
if (['printed', '已打印'].includes(raw)) return 'printed'
|
||||
return raw || 'unprinted'
|
||||
}
|
||||
|
||||
async function handleToggleWavePrintStatus(row: any) {
|
||||
const waveId = row?.wave_id ?? row?.id
|
||||
if (waveId == null) {
|
||||
ElMessage.warning('当前记录缺少可用的波次 ID')
|
||||
return
|
||||
}
|
||||
|
||||
const waveNo = row?.wave_no ?? waveId
|
||||
const currentStatus = getPrintStatusNormalized(row)
|
||||
const isPrinted = currentStatus === 'printed'
|
||||
const targetStatus = isPrinted ? 'unprinted' : 'printed'
|
||||
const actionText = isPrinted ? '标记为未打印' : '标记为已打印'
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定要${actionText}波次「${waveNo}」吗?`,
|
||||
actionText,
|
||||
{ type: 'warning', confirmButtonText: '确认', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
printStatusLoadingRowIds.value.add(waveId)
|
||||
try {
|
||||
await markWavePrintStatus({ wave_id: Number(waveId), status: targetStatus })
|
||||
ElMessage.success(`${actionText}成功`)
|
||||
await loadData()
|
||||
} catch (error: any) {
|
||||
console.error('toggleWavePrintStatus failed:', error)
|
||||
ElMessage.error(error?.message || `${actionText}失败`)
|
||||
} finally {
|
||||
printStatusLoadingRowIds.value.delete(waveId)
|
||||
}
|
||||
}
|
||||
|
||||
function openGroupOrderDialog() {
|
||||
groupOrderDialogVisible.value = true
|
||||
groupOrderFilters.distinguishExpress = true
|
||||
|
||||
@ -138,10 +138,6 @@
|
||||
<span class="order-info-text">{{ row.item_detail_machine || '—' }}</span>
|
||||
</template>
|
||||
|
||||
<template #column-item_snapshot_key="{ row }">
|
||||
<span class="order-info-text">{{ row.item_snapshot_key || '—' }}</span>
|
||||
</template>
|
||||
|
||||
<template #column-item_snapshot="{ row }">
|
||||
<span class="order-info-text">{{ getItemSnapshotText(row) }}</span>
|
||||
</template>
|
||||
@ -173,6 +169,15 @@
|
||||
>
|
||||
批量拣货
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="warning"
|
||||
size="small"
|
||||
:loading="isTogglePrintStatusLoading(row)"
|
||||
@click.stop="handleToggleWavePrintStatus(row)"
|
||||
>
|
||||
{{ getPrintStatusButtonText(row) }}
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template #empty>
|
||||
@ -512,6 +517,8 @@ import {
|
||||
orderWaveSingleOrderFetchList,
|
||||
orderWaveFetchTaskProgress
|
||||
} from '@/api/order.wave/orderwave'
|
||||
import { batchQuickRecheckByWave } from '@/api/order.recheckorder/recheckOrder'
|
||||
import { markWavePrintStatus } from '@/api/print/print'
|
||||
import { orderWaveBatchList, unwrapWaveBatchListResponse } from '@/api/order/order'
|
||||
import type {
|
||||
WaveBatchAutoGroupingResponse,
|
||||
@ -555,6 +562,8 @@ const onlyTodoWaves = ref(false)
|
||||
const batchAutoGroupingLoading = ref(false)
|
||||
const batchFinishAutoGroupingLoading = ref(false)
|
||||
const batchCancelLoading = ref(false)
|
||||
const batchQuickRecheckByWaveLoading = ref(false)
|
||||
const printStatusLoadingRowIds = ref<Set<number | string>>(new Set())
|
||||
const batchPrintLoading = ref(false)
|
||||
const batchOutboundPrintLoading = ref(false)
|
||||
const batchPlatformPrintLoading = ref(false)
|
||||
@ -687,6 +696,7 @@ const buttonLoadingMap = computed(() => ({
|
||||
batchAutoGroupingLoading: batchAutoGroupingLoading.value,
|
||||
batchFinishAutoGroupingLoading: batchFinishAutoGroupingLoading.value,
|
||||
batchCancelLoading: batchCancelLoading.value,
|
||||
batchQuickRecheckByWaveLoading: batchQuickRecheckByWaveLoading.value,
|
||||
batchPrintLoading: batchPrintLoading.value,
|
||||
batchOutboundPrintLoading: batchOutboundPrintLoading.value,
|
||||
batchPlatformPrintLoading: batchPlatformPrintLoading.value,
|
||||
@ -708,6 +718,7 @@ const buttonLabelMap = computed(() => ({
|
||||
batchPrintTotal: `批量打印(${selectedWaveOrderTotal.value})`,
|
||||
batchOutboundPrintTotal: `打印货单(${printableSelectionRows.value.length})`,
|
||||
batchPlatformPrintTotal: `批量打印(平台)(${selectedWaveOrderTotal.value})`,
|
||||
batchQuickRecheckByWaveTotal: `批量发货(${selectionRows.value.length})`,
|
||||
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
|
||||
}))
|
||||
|
||||
@ -759,6 +770,9 @@ const toolbarActionMap: Record<string, () => void> = {
|
||||
handleBatchCancel: () => {
|
||||
void handleBatchCancel()
|
||||
},
|
||||
handleBatchQuickRecheckByWave: () => {
|
||||
void handleBatchQuickRecheckByWave()
|
||||
},
|
||||
handleBatchAllocateExpress: () => {
|
||||
void handleBatchAllocateExpress()
|
||||
},
|
||||
@ -2342,6 +2356,105 @@ async function handleBatchCancel() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleBatchQuickRecheckByWave() {
|
||||
if (!selectionRows.value.length) {
|
||||
ElMessage.warning('请先勾选要批量发货的波次')
|
||||
return
|
||||
}
|
||||
|
||||
const waveIds = getSelectedWaveIds()
|
||||
if (!waveIds.length) {
|
||||
ElMessage.warning('当前勾选记录缺少可用的波次 ID')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定要对 ${waveIds.length} 个波次执行批量发货(快捷复核)吗?`,
|
||||
'批量发货',
|
||||
{ type: 'warning', confirmButtonText: '确认发货', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
batchQuickRecheckByWaveLoading.value = true
|
||||
try {
|
||||
const res = await batchQuickRecheckByWave({ wave_ids: waveIds })
|
||||
const data = res?.data || res
|
||||
if (data && (data.success_count !== undefined || data.failed_count !== undefined)) {
|
||||
const successCount = data.success_count || 0
|
||||
const failedCount = data.failed_count || 0
|
||||
if (failedCount > 0) {
|
||||
ElMessage.warning(`批量发货完成:成功 ${successCount} 个,失败 ${failedCount} 个`)
|
||||
} else {
|
||||
ElMessage.success(`批量发货完成:成功 ${successCount} 个`)
|
||||
}
|
||||
} else {
|
||||
ElMessage.success('批量发货请求已提交')
|
||||
}
|
||||
selectionRows.value = []
|
||||
hasSelection.value = false
|
||||
await loadData()
|
||||
} catch (error: any) {
|
||||
console.error('batchQuickRecheckByWave failed:', error)
|
||||
ElMessage.error(error?.message || '批量发货失败')
|
||||
} finally {
|
||||
batchQuickRecheckByWaveLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function getPrintStatusButtonText(row: any): string {
|
||||
return getPrintStatusNormalized(row) === 'printed' ? '标记未打印' : '标记已打印'
|
||||
}
|
||||
|
||||
function isTogglePrintStatusLoading(row: any) {
|
||||
const id = row?.wave_id ?? row?.id
|
||||
return id != null && printStatusLoadingRowIds.value.has(id)
|
||||
}
|
||||
|
||||
function getPrintStatusNormalized(row: any): string {
|
||||
const raw = String(row?.print_assignment_status ?? '').trim().toLowerCase()
|
||||
if (['printed', '已打印'].includes(raw)) return 'printed'
|
||||
return raw || 'unprinted'
|
||||
}
|
||||
|
||||
async function handleToggleWavePrintStatus(row: any) {
|
||||
const waveId = row?.wave_id ?? row?.id
|
||||
if (waveId == null) {
|
||||
ElMessage.warning('当前记录缺少可用的波次 ID')
|
||||
return
|
||||
}
|
||||
|
||||
const waveNo = row?.wave_no ?? waveId
|
||||
const currentStatus = getPrintStatusNormalized(row)
|
||||
const isPrinted = currentStatus === 'printed'
|
||||
const targetStatus = isPrinted ? 'unprinted' : 'printed'
|
||||
const actionText = isPrinted ? '标记为未打印' : '标记为已打印'
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定要${actionText}波次「${waveNo}」吗?`,
|
||||
actionText,
|
||||
{ type: 'warning', confirmButtonText: '确认', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
printStatusLoadingRowIds.value.add(waveId)
|
||||
try {
|
||||
await markWavePrintStatus({ wave_id: Number(waveId), status: targetStatus })
|
||||
ElMessage.success(`${actionText}成功`)
|
||||
await loadData()
|
||||
} catch (error: any) {
|
||||
console.error('toggleWavePrintStatus failed:', error)
|
||||
ElMessage.error(error?.message || `${actionText}失败`)
|
||||
} finally {
|
||||
printStatusLoadingRowIds.value.delete(waveId)
|
||||
}
|
||||
}
|
||||
|
||||
function openGroupOrderDialog() {
|
||||
groupOrderDialogVisible.value = true
|
||||
groupOrderFilters.distinguishExpress = true
|
||||
|
||||
@ -51,18 +51,28 @@
|
||||
<div class="section">
|
||||
<div class="section-title">结构与订单信息</div>
|
||||
<el-descriptions :column="2" border size="small" class="detail-descriptions">
|
||||
<el-descriptions-item label="商品结构快照" :span="2">{{ getItemSnapshotText(row) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="订单信息" :span="2">{{ getOrderInfoSummary(row) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="订单列表" :span="2">{{ getOrderListPreview(row) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">{{ formatDateTime(row.create_time || row.created_at || row.create_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">{{ formatDateTime(row.update_time || row.updated_at || row.update_at) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
|
||||
<div v-if="parsedItems.length" class="section">
|
||||
<div class="section-title">商品结构快照</div>
|
||||
<el-table :data="parsedItems" border size="small" class="snapshot-table">
|
||||
<el-table-column prop="sku" label="SKU" min-width="100" />
|
||||
<el-table-column prop="barcode" label="条码" min-width="130" />
|
||||
<el-table-column prop="name" label="商品名称" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="quantity" label="数量" width="80" align="center" />
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import {
|
||||
waveStatusTextMap,
|
||||
waveStorageAssignmentErrorPhraseMap,
|
||||
@ -75,10 +85,42 @@ import {
|
||||
getWaveAssignmentAggregateTagType
|
||||
} from '../config/wave-config'
|
||||
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
row: Record<string, any> | null
|
||||
}>()
|
||||
|
||||
interface SnapshotItem {
|
||||
sku: string
|
||||
barcode: string
|
||||
name: string
|
||||
quantity: string
|
||||
}
|
||||
|
||||
/** 解析 item_snapshot_key 字段,按 "::" 分隔字段、"|" 分隔商品 */
|
||||
function parseItemSnapshotKey(raw: string | undefined | null): SnapshotItem[] {
|
||||
if (!raw || !raw.trim()) return []
|
||||
// 特殊值:非标准快照格式,直接跳过
|
||||
if (raw === 'manual_single_ids') return []
|
||||
const items = raw.split('|')
|
||||
const result: SnapshotItem[] = []
|
||||
for (const item of items) {
|
||||
const parts = item.split('::')
|
||||
if (parts.length < 5) continue
|
||||
result.push({
|
||||
sku: parts[0] || '—',
|
||||
barcode: parts[1] || '—',
|
||||
name: parts[2] || '—',
|
||||
quantity: parts[4] || '—'
|
||||
})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
const parsedItems = computed<SnapshotItem[]>(() => {
|
||||
const raw = (props.row as any)?.item_snapshot_key
|
||||
return parseItemSnapshotKey(raw)
|
||||
})
|
||||
|
||||
function getWaveCode(row: any) {
|
||||
return row?.wave_code || row?.batch_code || row?.wave_no || row?.batch_no || row?.code || row?.id || '—'
|
||||
}
|
||||
@ -159,10 +201,6 @@ function getStorageAssignmentError(row: any) {
|
||||
)
|
||||
}
|
||||
|
||||
function getItemSnapshotText(row: any) {
|
||||
return row?.item_snapshot_key || row?.item_detail_machine || row?.item_detail || '—'
|
||||
}
|
||||
|
||||
function getOrderInfoSummary(row: any) {
|
||||
if (Array.isArray(row?.order_list) && row.order_list.length) {
|
||||
const preview = row.order_list
|
||||
|
||||
@ -1036,7 +1036,7 @@ async function notifyLockAfterBrowserPrint(
|
||||
}
|
||||
}
|
||||
|
||||
/** 精简 waveGroups 数据,移除 print.send 不需要的字段 */
|
||||
/** 精简 waveGroups 数据,移除 print.send 不需要的字段(仅移除 contents 内的 config) */
|
||||
function stripRedundantPrintFields(waveGroups: unknown[]): unknown[] {
|
||||
return waveGroups.map((wg: any) => {
|
||||
if (!wg || typeof wg !== 'object') return wg
|
||||
@ -1056,14 +1056,8 @@ function stripRedundantPrintFields(waveGroups: unknown[]): unknown[] {
|
||||
return { ...o, contents }
|
||||
})
|
||||
: p.orders
|
||||
const {
|
||||
platform_name: _pn,
|
||||
sys_logistics_name: _sln,
|
||||
order_count: _oc,
|
||||
order_ids: _oi,
|
||||
...restPlatform
|
||||
} = p
|
||||
return { ...restPlatform, orders }
|
||||
// 保留 platform 层的所有字段(包括 order_ids、platform_name、sys_logistics_name、order_count)
|
||||
return { ...p, orders }
|
||||
})
|
||||
: wg.platforms
|
||||
return { ...wg, platforms }
|
||||
|
||||
@ -338,12 +338,11 @@ export const waveBatchColumns = applyWaveListCopyActions([
|
||||
{ prop: 'review_assignment_status', label: '复核状态', minWidth: 110 },
|
||||
{ prop: 'unreviewed_order_count', label: '未复核数', minWidth: 96 },
|
||||
{ prop: 'logistics_name', label: '快递', minWidth: 120 },
|
||||
{ prop: 'item_snapshot_key', label: '商品快照键', minWidth: 320 },
|
||||
{ prop: 'creator', label: '创建人', minWidth: 100 },
|
||||
{ prop: 'warehouse_id', label: '仓库ID', minWidth: 110 },
|
||||
{ prop: 'create_time', label: '创建时间', minWidth: 168 },
|
||||
{ prop: 'update_time', label: '更新时间', minWidth: 168 },
|
||||
{ prop: 'operation', label: '操作', minWidth: 180, fixed: 'right' }
|
||||
{ prop: 'operation', label: '操作', minWidth: 280, fixed: 'right' }
|
||||
])
|
||||
|
||||
/** 列表查询 where 白名单(与 sanitizeWaveWhere 一致) */
|
||||
@ -550,6 +549,16 @@ export const waveToolbarButtons: WaveToolbarButtonConfig[] = [
|
||||
loadingKey: 'batchCancelLoading',
|
||||
action: 'handleBatchCancel'
|
||||
},
|
||||
{
|
||||
key: 'batchQuickRecheckByWave',
|
||||
label: '批量发货(0)',
|
||||
dynamicLabelKey: 'batchQuickRecheckByWaveTotal',
|
||||
type: 'success',
|
||||
size: 'small',
|
||||
disabledKey: 'noSelection',
|
||||
loadingKey: 'batchQuickRecheckByWaveLoading',
|
||||
action: 'handleBatchQuickRecheckByWave'
|
||||
},
|
||||
{
|
||||
key: 'batchAllocateExpress',
|
||||
label: '快速分配快递号',
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { TAG_RESOLVERS, translate } from '../../config/waveorder-config'
|
||||
import { TAG_RESOLVERS, translate, formatTime } from '../../config/waveorder-config'
|
||||
import type { DetailSectionConfig, DetailFieldConfig } from '../../config/waveorder-config'
|
||||
|
||||
defineOptions({ name: 'WaveOrder2DetailPanel' })
|
||||
@ -88,11 +88,14 @@ function getRowData(): Record<string, any> | null {
|
||||
return props.row
|
||||
}
|
||||
|
||||
/** 解析显示值:优先使用 translateField 翻译,否则显示原始值 */
|
||||
/** 解析显示值:优先使用 translateField 翻译,然后 format 格式化,否则显示原始值 */
|
||||
function resolveDisplayValue(field: DetailFieldConfig, value: any): string {
|
||||
if (field.translateField) {
|
||||
return translate(field.translateField, value)
|
||||
}
|
||||
if (field.format === 'datetime') {
|
||||
return formatTime(value)
|
||||
}
|
||||
return value ?? '—'
|
||||
}
|
||||
|
||||
|
||||
@ -590,6 +590,8 @@ export interface DetailFieldConfig {
|
||||
tagResolver?: string
|
||||
/** 翻译字段名(查 VALUE_MAPS) */
|
||||
translateField?: string
|
||||
/** 格式化类型:'datetime' 将时间戳转为 YYYY-MM-DD HH:mm:ss */
|
||||
format?: 'datetime'
|
||||
}
|
||||
|
||||
/** 明细面板分区配置 */
|
||||
@ -810,7 +812,8 @@ export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig {
|
||||
translateField: def.slot?.translateField,
|
||||
tagResolver: def.slot?.tagResolver,
|
||||
tagType: def.slot?.tagType,
|
||||
renderType: def.slot?.type === 'tag' ? 'tag' : 'text'
|
||||
renderType: def.slot?.type === 'tag' ? 'tag' : 'text',
|
||||
format: def.slot?.format
|
||||
}
|
||||
})
|
||||
.filter((f): f is DetailFieldConfig => f !== null)
|
||||
@ -935,17 +938,17 @@ export const waveOrder2TabPages: TabPageRawConfig[] = [
|
||||
{
|
||||
title: '基础信息',
|
||||
columnCount: 4,
|
||||
fieldKeys: ['wave_no', 'wave_type', 'wave_status', 'warehouse_id', 'total_orders', 'processed_orders', 'logistics_name', 'creator']
|
||||
fieldKeys: ['wave_no', 'wave_type', 'wave_status', 'distinguish_express', 'logistics_name', 'creator', 'warehouse_id', 'create_time']
|
||||
},
|
||||
{
|
||||
title: '分配状态',
|
||||
title: '订单统计',
|
||||
columnCount: 4,
|
||||
fieldKeys: ['total_orders', 'order_count', 'processed_orders', 'unreviewed_order_count']
|
||||
},
|
||||
{
|
||||
title: '流程状态',
|
||||
columnCount: 3,
|
||||
fieldKeys: ['storage_assignment_status', 'express_assignment_status', 'print_assignment_status', 'pick_assignment_status', 'review_assignment_status', 'unreviewed_order_count']
|
||||
},
|
||||
{
|
||||
title: '结构与订单信息',
|
||||
columnCount: 2,
|
||||
fieldKeys: ['create_time', 'update_time']
|
||||
fieldKeys: ['storage_assignment_status', 'express_assignment_status', 'print_assignment_status', 'pick_assignment_status', 'review_assignment_status', 'update_time']
|
||||
}
|
||||
],
|
||||
api: {
|
||||
@ -1021,17 +1024,17 @@ export const waveOrder2TabPages: TabPageRawConfig[] = [
|
||||
{
|
||||
title: '基础信息',
|
||||
columnCount: 4,
|
||||
fieldKeys: ['wave_no', 'wave_type', 'wave_status', 'warehouse_id', 'total_orders', 'processed_orders', 'logistics_name', 'creator']
|
||||
fieldKeys: ['wave_no', 'wave_type', 'wave_status', 'distinguish_express', 'logistics_name', 'creator', 'warehouse_id', 'create_time']
|
||||
},
|
||||
{
|
||||
title: '分配状态',
|
||||
title: '订单统计',
|
||||
columnCount: 4,
|
||||
fieldKeys: ['total_orders', 'order_count', 'processed_orders', 'unreviewed_order_count']
|
||||
},
|
||||
{
|
||||
title: '流程状态',
|
||||
columnCount: 3,
|
||||
fieldKeys: ['storage_assignment_status', 'express_assignment_status', 'print_assignment_status', 'pick_assignment_status', 'review_assignment_status', 'unreviewed_order_count']
|
||||
},
|
||||
{
|
||||
title: '结构与订单信息',
|
||||
columnCount: 2,
|
||||
fieldKeys: ['create_time', 'update_time']
|
||||
fieldKeys: ['storage_assignment_status', 'express_assignment_status', 'print_assignment_status', 'pick_assignment_status', 'review_assignment_status', 'update_time']
|
||||
}
|
||||
],
|
||||
api: {
|
||||
|
||||
@ -20,7 +20,12 @@
|
||||
<el-button size="small" type="primary" @click="loadData">刷新</el-button>
|
||||
<!-- <el-button size="small" @click="handleCreateEntry">新建入库单</el-button> -->
|
||||
<el-button size="small" :disabled="!hasSelection" @click="confirmBatchCancel">批量作废</el-button>
|
||||
<ExportModeDropdown :loading="exportLoading" @action="handleExportAction" />
|
||||
<ExportModeDropdown
|
||||
:loading="exportLoading"
|
||||
:items="exportDropdownItems"
|
||||
:default-action="'handleExportSelected'"
|
||||
@action="handleExportAction"
|
||||
/>
|
||||
<el-button size="small" @click="handleImport">导入</el-button>
|
||||
<el-button size="small" @click="openColumnConfigPanel">字段设置</el-button>
|
||||
<el-button size="small" @click="toggleDetailVisible">{{ detailVisible ? '隐藏详情' : '显示详情' }}</el-button>
|
||||
@ -135,6 +140,19 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<AsyncExportProgressDialog
|
||||
v-model:visible="exportDialogVisible"
|
||||
title="库存导出进度"
|
||||
:loading="exportLoading"
|
||||
:progress-percent="exportProgressPercent"
|
||||
:progress-status="exportProgressStatus"
|
||||
:status-label="exportStatusLabel"
|
||||
:task-id="exportTaskProgress.taskId"
|
||||
:message="exportTaskProgress.message"
|
||||
:error="exportTaskProgress.error"
|
||||
:update-time="exportTaskProgress.updateTime"
|
||||
/>
|
||||
|
||||
<InventoryStockPickerDialog
|
||||
v-model="stockPickerVisible"
|
||||
:store-id="stockPickerStoreId"
|
||||
@ -149,6 +167,8 @@ import { ref, reactive, onMounted, computed, nextTick } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
|
||||
import { useAsyncExportTask, type AsyncExportPayload } from '@/composables/useAsyncExportTask'
|
||||
import * as indexApi from '@/api/index/index'
|
||||
// import * as entryApi from '@/api/storage.entry/entry'
|
||||
import * as inventoryApi from '@/api/storage.inventory/inventory'
|
||||
@ -158,17 +178,15 @@ import {
|
||||
formatInventoryBarcodes,
|
||||
formatInventoryFlagLabel,
|
||||
formatInventoryOptionalText,
|
||||
inventoryExportColumns,
|
||||
isInventoryFlagEnabled,
|
||||
productstockColums,
|
||||
} from './inventory-config'
|
||||
import { exportUpperTableRows } from '@/views/order/orderManagement/utils/export'
|
||||
|
||||
import entrydetail from './component/panelstockdetail.vue'
|
||||
import log from './component/log.vue'
|
||||
import InventoryStockPickerDialog from './component/InventoryStockPickerDialog.vue'
|
||||
import type { InventoryStockPickerItem } from './component/InventoryStockPickerDialog.vue'
|
||||
import ExportModeDropdown from '@/components/ExportModeDropdown.vue'
|
||||
import ExportModeDropdown, { type ExportDropdownItem } from '@/components/ExportModeDropdown.vue'
|
||||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
|
||||
@ -214,9 +232,30 @@ const activeTab = ref('details')
|
||||
|
||||
const list = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const exportLoading = ref(false)
|
||||
const queryTime = ref(0)
|
||||
|
||||
// --- 异步导出 ---
|
||||
const {
|
||||
exportLoading,
|
||||
exportDialogVisible,
|
||||
exportTaskProgress,
|
||||
exportProgressPercent,
|
||||
exportProgressStatus,
|
||||
exportStatusLabel,
|
||||
submitExportTask,
|
||||
resumeExportTaskFromStorage,
|
||||
hasPendingExportTask
|
||||
} = useAsyncExportTask({
|
||||
storageKey: 'storage.inventory.export.taskId',
|
||||
submitExport: (payload) => inventoryApi.exportInventory(payload as any),
|
||||
queryProgress: (params) => inventoryApi.exportTaskProgress(params)
|
||||
})
|
||||
|
||||
const exportDropdownItems: ExportDropdownItem[] = [
|
||||
{ label: '导出选中', action: 'handleExportSelected' },
|
||||
{ label: '导出全部', action: 'handleExportAll', divided: true }
|
||||
]
|
||||
|
||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
const tableSize = ref('small')
|
||||
const groupByBatch = ref(false)
|
||||
@ -281,6 +320,7 @@ const selectedRow = computed(() => {
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
loadFilterData()
|
||||
resumeExportTaskFromStorage()
|
||||
})
|
||||
|
||||
async function loadData() {
|
||||
@ -517,101 +557,56 @@ async function confirmBatchCancel() {
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
async function handleExport(mode: 'waybill' | 'item' = 'waybill') {
|
||||
exportLoading.value = true
|
||||
try {
|
||||
if (mode === 'waybill') {
|
||||
const sourceRows = selectionRows.value.length ? selectionRows.value : list.value
|
||||
if (!sourceRows.length) {
|
||||
ElMessage.warning('当前无数据可导出')
|
||||
return
|
||||
}
|
||||
exportUpperTableRows({
|
||||
rows: sourceRows,
|
||||
columns: inventoryExportColumns,
|
||||
fileName: `库存列表-${Date.now()}.xlsx`,
|
||||
transformCell: (prop, value) => {
|
||||
if (prop === 'is_shelf_life_mgmt') return formatInventoryFlagLabel(value)
|
||||
if (prop === 'remaining_threshold_days') return formatInventoryOptionalText(value)
|
||||
return value
|
||||
}
|
||||
})
|
||||
ElMessage.success('导出成功')
|
||||
return
|
||||
}
|
||||
|
||||
const params: any = {
|
||||
pagination: { page: 1, pageSize: 10000 },
|
||||
where: scanBox.value?.getConditions?.() || {},
|
||||
group_by_batch: true
|
||||
}
|
||||
const res: any = await inventoryApi.getInventoryList(params)
|
||||
if (!(res && (res.code === 200 || res.code === 1 || res.flag === 'success'))) {
|
||||
ElMessage.error('获取库存明细失败')
|
||||
return
|
||||
}
|
||||
|
||||
const data = res.data || res
|
||||
const rawRows = Array.isArray(data.list) ? data.list : []
|
||||
let exportRows = rawRows.map((item: any) => {
|
||||
return {
|
||||
store_name: item.store_name || item.stock?.store_name || '',
|
||||
item_code: item.stock?.item_code || '',
|
||||
item_name: item.stock?.item_name || '',
|
||||
barcodes: formatInventoryBarcodes(item.stock?.barcodes),
|
||||
sku_property: formatInventoryOptionalText(item.stock?.sku_property),
|
||||
stock_unit: formatInventoryOptionalText(item.stock?.stock_unit),
|
||||
production_date: item.production_date || '',
|
||||
expiry_date: item.expiry_date || '',
|
||||
quantity: item.quantity,
|
||||
available_quantity: item.available_quantity,
|
||||
locked_quantity: item.locked_quantity,
|
||||
first_inbound_time: item.first_inbound_time || '',
|
||||
last_inbound_time: item.last_inbound_time,
|
||||
batch_count: Number(item.batch_count || 0),
|
||||
is_shelf_life_mgmt: item.stock?.is_shelf_life_mgmt ?? '',
|
||||
remaining_threshold_days: item.stock?.remaining_threshold_days ?? '',
|
||||
is_batch_mgmt_enabled: item.stock?.is_batch_mgmt_enabled
|
||||
}
|
||||
})
|
||||
|
||||
if (selectionRows.value.length) {
|
||||
const selectedKeys = new Set(
|
||||
selectionRows.value.map((row: any) => row.stock_id)
|
||||
)
|
||||
exportRows = exportRows.filter((row: any) =>
|
||||
selectedKeys.has(row.stock_id)
|
||||
)
|
||||
}
|
||||
|
||||
if (!exportRows.length) {
|
||||
ElMessage.warning('未获取到可导出的库存明细')
|
||||
return
|
||||
}
|
||||
|
||||
exportUpperTableRows({
|
||||
rows: exportRows,
|
||||
columns: productstockColums,
|
||||
fileName: `库存明细-${Date.now()}.xlsx`,
|
||||
transformCell: (prop, value) => {
|
||||
if (prop === 'is_shelf_life_mgmt' || prop === 'is_batch_mgmt_enabled') {
|
||||
return formatInventoryFlagLabel(value)
|
||||
}
|
||||
if (prop === 'remaining_threshold_days') return formatInventoryOptionalText(value)
|
||||
return value
|
||||
}
|
||||
})
|
||||
ElMessage.success('导出成功')
|
||||
} catch (e) {
|
||||
console.error('导出 Excel 失败:', e)
|
||||
ElMessage.error('导出失败')
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
function buildExportPayload(): AsyncExportPayload {
|
||||
const rawWhere = scanBox.value?.getConditions?.() || {}
|
||||
return {
|
||||
where: { ...rawWhere },
|
||||
group_by_batch: groupByBatch.value
|
||||
}
|
||||
}
|
||||
|
||||
async function handleExportSelected() {
|
||||
if (!selectionRows.value.length) {
|
||||
ElMessage.warning('请先选择要导出的库存记录')
|
||||
return
|
||||
}
|
||||
if (hasPendingExportTask()) {
|
||||
ElMessage.warning('检测到未完成导出任务,请等待当前任务完成后再试')
|
||||
resumeExportTaskFromStorage()
|
||||
return
|
||||
}
|
||||
const stockIds = selectionRows.value
|
||||
.map((row: any) => Number(row.stock_id))
|
||||
.filter((id: number) => Number.isFinite(id) && id > 0)
|
||||
if (!stockIds.length) {
|
||||
ElMessage.warning('选中的记录无有效 stock_id')
|
||||
return
|
||||
}
|
||||
await submitExportTask({
|
||||
where: { stock_id: stockIds.length === 1 ? stockIds[0] : stockIds },
|
||||
group_by_batch: groupByBatch.value
|
||||
})
|
||||
}
|
||||
|
||||
async function handleExportAll() {
|
||||
if (!list.value.length) {
|
||||
ElMessage.warning('当前无数据可导出')
|
||||
return
|
||||
}
|
||||
if (hasPendingExportTask()) {
|
||||
ElMessage.warning('检测到未完成导出任务,请等待当前任务完成后再试')
|
||||
resumeExportTaskFromStorage()
|
||||
return
|
||||
}
|
||||
await submitExportTask(buildExportPayload())
|
||||
}
|
||||
|
||||
function handleExportAction(action: string) {
|
||||
void handleExport(action === 'handleExportItem' ? 'item' : 'waybill')
|
||||
if (action === 'handleExportAll') {
|
||||
void handleExportAll()
|
||||
return
|
||||
}
|
||||
void handleExportSelected()
|
||||
}
|
||||
|
||||
function handleImport() {
|
||||
|
||||
@ -149,14 +149,16 @@
|
||||
<el-button type="primary" plain :loading="authLinkLoading" @click="handleOpenAuthorizeLink">
|
||||
去授权
|
||||
</el-button>
|
||||
<!-- <el-text v-if="authNeedCallbackUrl" type="info" size="small" class="auth-tip">
|
||||
请先在平台完成授权,再将回调地址粘贴到上方输入框后点击「确认授权」。
|
||||
</el-text>
|
||||
<el-text v-else type="info" size="small" class="auth-tip">
|
||||
请先在平台完成授权,再点击「确认授权」完成绑定。
|
||||
</el-text> -->
|
||||
</el-form-item>
|
||||
<el-form-item v-if="authNeedCallbackUrl" label="回调地址" prop="callbackurl">
|
||||
<template v-if="isWechatChannel">
|
||||
<el-form-item label="appId" prop="appId">
|
||||
<el-input v-model="authForm.appId" placeholder="请输入视频号 appId" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="toUserName" prop="toUserName">
|
||||
<el-input v-model="authForm.toUserName" placeholder="请输入视频号 toUserName" clearable />
|
||||
</el-form-item>
|
||||
</template>
|
||||
<el-form-item v-else-if="authNeedCallbackUrl" label="回调地址" prop="callbackurl">
|
||||
<el-input
|
||||
v-model="authForm.callbackurl"
|
||||
placeholder="请输入授权完成后的回调 URL"
|
||||
@ -261,17 +263,33 @@ const authForm = reactive({
|
||||
shopLabel: '',
|
||||
platform_name: '',
|
||||
platformCode: '',
|
||||
callbackurl: ''
|
||||
callbackurl: '',
|
||||
appId: '',
|
||||
toUserName: ''
|
||||
})
|
||||
|
||||
/** 视频号平台需要 appId + toUserName,callbackUrl 固定为 "-" */
|
||||
const isWechatChannel = computed(() => {
|
||||
const code = String(authForm.platformCode || '').trim().toLowerCase()
|
||||
return code === 'shipinhao' || code === '视频号'
|
||||
})
|
||||
|
||||
const authNeedCallbackUrl = computed(() => {
|
||||
const code = String(authForm.platformCode || '').trim()
|
||||
if (!code) return false
|
||||
// 视频号不需要显示 callbackurl
|
||||
if (isWechatChannel.value) return false
|
||||
const platform = platformOptions.value.find((item) => item.code === code)
|
||||
return isNeedCallbackUrl(platform?.need_callback_url)
|
||||
})
|
||||
|
||||
const authRules = computed<FormRules>(() => {
|
||||
if (isWechatChannel.value) {
|
||||
return {
|
||||
appId: [{ required: true, message: '请输入 appId', trigger: 'blur' }],
|
||||
toUserName: [{ required: true, message: '请输入 toUserName', trigger: 'blur' }]
|
||||
}
|
||||
}
|
||||
if (!authNeedCallbackUrl.value) return {}
|
||||
return {
|
||||
callbackurl: [{ required: true, message: '请输入回调地址', trigger: 'blur' }]
|
||||
@ -557,6 +575,8 @@ function resetAuthForm() {
|
||||
authForm.platform_name = ''
|
||||
authForm.platformCode = ''
|
||||
authForm.callbackurl = ''
|
||||
authForm.appId = ''
|
||||
authForm.toUserName = ''
|
||||
authFormRef.value?.clearValidate()
|
||||
}
|
||||
|
||||
@ -615,8 +635,14 @@ async function submitConfirmAuthorize() {
|
||||
|
||||
authConfirmLoading.value = true
|
||||
try {
|
||||
const payload: { id: number; callbackurl?: string } = { id: authForm.shopId }
|
||||
if (authNeedCallbackUrl.value) {
|
||||
const payload: { id: number; callbackurl?: string; appId?: string; toUserName?: string } = {
|
||||
id: authForm.shopId
|
||||
}
|
||||
if (isWechatChannel.value) {
|
||||
payload.appId = authForm.appId.trim()
|
||||
payload.toUserName = authForm.toUserName.trim()
|
||||
payload.callbackurl = '-'
|
||||
} else if (authNeedCallbackUrl.value) {
|
||||
payload.callbackurl = String(authForm.callbackurl || '').trim()
|
||||
}
|
||||
|
||||
|
||||
@ -52,6 +52,7 @@
|
||||
<template #column-actions="{ row }">
|
||||
<el-button link type="primary" size="small" @click.stop="openEdit(row)">编辑</el-button>
|
||||
<el-button link type="danger" size="small" @click.stop="handleDelete(row)">删除</el-button>
|
||||
<el-button link type="warning" size="small" @click.stop="openOsd(row)">OSD</el-button>
|
||||
<el-button link type="success" size="small" @click.stop="openPreview(row)">预览</el-button>
|
||||
</template>
|
||||
|
||||
@ -157,6 +158,77 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- OSD 文字叠加设置弹窗 -->
|
||||
<el-dialog
|
||||
v-model="osdVisible"
|
||||
title="设置 OSD 文字叠加"
|
||||
width="520px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="resetOsdForm"
|
||||
>
|
||||
<div class="osd-camera-info">
|
||||
<span class="osd-label">摄像头:</span>
|
||||
<span>{{ osdCameraName }}</span>
|
||||
</div>
|
||||
<el-form ref="osdFormRef" :model="osdForm" :rules="osdRules" label-width="100px" class="osd-form">
|
||||
<el-form-item label="叠加文字" prop="text">
|
||||
<el-input
|
||||
v-model="osdForm.text"
|
||||
placeholder="请输入要在画面中叠加的文字"
|
||||
maxlength="64"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="X 坐标">
|
||||
<div class="osd-coord-row">
|
||||
<el-slider
|
||||
v-model="osdForm.x"
|
||||
:min="-1"
|
||||
:max="1"
|
||||
:step="0.1"
|
||||
:marks="osdCoordMarks"
|
||||
show-input
|
||||
style="flex:1"
|
||||
/>
|
||||
</div>
|
||||
<div class="osd-coord-hint">范围 -1(左)~ 1(右),默认 -0.9</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="Y 坐标">
|
||||
<div class="osd-coord-row">
|
||||
<el-slider
|
||||
v-model="osdForm.y"
|
||||
:min="-1"
|
||||
:max="1"
|
||||
:step="0.1"
|
||||
:marks="osdCoordMarks"
|
||||
show-input
|
||||
style="flex:1"
|
||||
/>
|
||||
</div>
|
||||
<div class="osd-coord-hint">范围 -1(上)~ 1(下),默认 0.8</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="osd-preview-box">
|
||||
<div class="osd-preview-label">位置预览</div>
|
||||
<div class="osd-preview-canvas">
|
||||
<span
|
||||
class="osd-preview-dot"
|
||||
:style="osdDotStyle"
|
||||
title="OSD 文字参考位置"
|
||||
>●</span>
|
||||
</div>
|
||||
<div class="osd-preview-pos">当前坐标:({{ osdForm.x.toFixed(1) }}, {{ osdForm.y.toFixed(1) }})</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="osdVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="osdSaving" @click="submitOsd">
|
||||
应用 OSD
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 预览弹窗 -->
|
||||
<CameraPreviewDialog v-model="previewVisible" :camera-row="previewCameraRow" />
|
||||
</div>
|
||||
@ -169,7 +241,7 @@ import type { FormInstance, FormRules } from 'element-plus'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import CameraPreviewDialog from './component/CameraPreviewDialog.vue'
|
||||
import { list, create, update, del } from '@/api/camera/camera'
|
||||
import { list, create, update, del, setOsd } from '@/api/camera/camera'
|
||||
import { list as serverList, detail as serverDetail } from '@/api/camera_server/camera_server'
|
||||
import { getHikvisionChannels } from '@/api/camera_server/localServerApi'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
@ -227,7 +299,7 @@ const columns = [
|
||||
{ prop: 'custom_name', label: '自定义名称', minWidth: '160', showOverflowTooltip: true },
|
||||
{ prop: 'status', label: '状态', width: '90' },
|
||||
{ prop: 'remark', label: '备注', minWidth: '160', showOverflowTooltip: true },
|
||||
{ prop: 'actions', label: '操作', width: '150', fixed: 'right' }
|
||||
{ prop: 'actions', label: '操作', width: '220', fixed: 'right' }
|
||||
]
|
||||
|
||||
const availableFields = [
|
||||
@ -281,6 +353,29 @@ const serverPassword = ref('')
|
||||
const selectedServerNeedsPassword = ref(false)
|
||||
const previewVisible = ref(false)
|
||||
const previewCameraRow = ref<CameraRecord | null>(null)
|
||||
|
||||
// --- OSD 文字叠加 ---
|
||||
const osdVisible = ref(false)
|
||||
const osdSaving = ref(false)
|
||||
const osdCameraRow = ref<CameraRecord | null>(null)
|
||||
const osdFormRef = ref<FormInstance>()
|
||||
const osdForm = reactive({ text: '', x: -0.9, y: 0.8 })
|
||||
const osdRules: FormRules = {
|
||||
text: [{ required: true, message: '请输入叠加文字', trigger: 'blur' }]
|
||||
}
|
||||
const osdCoordMarks = { '-1': '-1', '0': '0', '1': '1' }
|
||||
|
||||
const osdCameraName = computed(() => {
|
||||
const row = osdCameraRow.value
|
||||
if (!row) return '--'
|
||||
return row.custom_name || row.channel_name || `摄像头 #${row.id}`
|
||||
})
|
||||
|
||||
const osdDotStyle = computed(() => {
|
||||
const left = ((osdForm.x + 1) / 2) * 100
|
||||
const top = ((1 - osdForm.y) / 2) * 100
|
||||
return { left: `${left}%`, top: `${top}%` }
|
||||
})
|
||||
const queryTime = ref(0)
|
||||
const tableSize = ref<'small' | 'default' | 'large'>('small')
|
||||
const currentConditionRaw = ref<any>(null)
|
||||
@ -718,6 +813,53 @@ function openPreview(row: CameraRecord) {
|
||||
previewVisible.value = true
|
||||
}
|
||||
|
||||
/** 打开 OSD 设置弹窗 */
|
||||
function openOsd(row: CameraRecord) {
|
||||
osdCameraRow.value = row
|
||||
resetOsdForm()
|
||||
osdVisible.value = true
|
||||
}
|
||||
|
||||
function resetOsdForm() {
|
||||
osdForm.text = ''
|
||||
osdForm.x = -0.9
|
||||
osdForm.y = 0.8
|
||||
osdFormRef.value?.clearValidate()
|
||||
}
|
||||
|
||||
/** 提交 OSD 文字叠加 */
|
||||
async function submitOsd() {
|
||||
if (!osdFormRef.value || osdSaving.value) return
|
||||
const valid = await osdFormRef.value.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
|
||||
const row = osdCameraRow.value
|
||||
if (!row?.id) {
|
||||
ElMessage.error('未找到摄像头信息')
|
||||
return
|
||||
}
|
||||
|
||||
osdSaving.value = true
|
||||
try {
|
||||
const res: any = await setOsd({
|
||||
id: row.id,
|
||||
text: osdForm.text.trim(),
|
||||
x: osdForm.x,
|
||||
y: osdForm.y
|
||||
})
|
||||
if (isSuccess(res)) {
|
||||
ElMessage.success(`已为「${osdCameraName.value}」设置 OSD 文字`)
|
||||
osdVisible.value = false
|
||||
} else {
|
||||
ElMessage.error(res?.message || 'OSD 设置失败')
|
||||
}
|
||||
} catch {
|
||||
ElMessage.error('OSD 设置失败,请检查网络连接')
|
||||
} finally {
|
||||
osdSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadList()
|
||||
loadServerOptions()
|
||||
@ -760,4 +902,71 @@ onMounted(() => {
|
||||
color: #909399;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
/* --- OSD 弹窗样式 --- */
|
||||
.osd-camera-info {
|
||||
padding: 8px 12px;
|
||||
margin-bottom: 16px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
color: #303133;
|
||||
}
|
||||
.osd-label {
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.osd-form {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.osd-coord-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.osd-coord-hint {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.osd-preview-box {
|
||||
margin-top: 16px;
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 6px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.osd-preview-label {
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.osd-preview-canvas {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 120px;
|
||||
background: #1a1a2e;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.osd-preview-dot {
|
||||
position: absolute;
|
||||
font-size: 16px;
|
||||
color: #67c23a;
|
||||
transform: translate(-50%, -50%);
|
||||
text-shadow: 0 0 4px rgba(103, 194, 58, 0.6);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.osd-preview-pos {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -247,7 +247,7 @@ export const FIELD_DICT: Record<string, FieldDefinition> = {
|
||||
key: 'operation',
|
||||
label: '操作',
|
||||
scanBox: null,
|
||||
table: { width: 180, fixed: 'right', align: 'center' },
|
||||
table: { width: 220, fixed: 'right', align: 'center' },
|
||||
slot: { type: 'operation' }
|
||||
}
|
||||
}
|
||||
@ -689,6 +689,12 @@ export const tabPages: TabPageRawConfig[] = [
|
||||
confirmType: 'warning',
|
||||
confirmButtonText: '确认删除'
|
||||
},
|
||||
{
|
||||
key: 'osd',
|
||||
label: 'OSD',
|
||||
actionType: 'action',
|
||||
type: 'warning'
|
||||
},
|
||||
{
|
||||
key: 'preview',
|
||||
label: '预览',
|
||||
|
||||
@ -114,6 +114,7 @@
|
||||
<div class="operation-cell">
|
||||
<el-button link type="primary" size="small" @click.stop="openCameraForm('edit', getRowById(row['id']))">编辑</el-button>
|
||||
<el-button link type="danger" size="small" @click.stop="handleDeleteCamera(getRowById(row['id'])!)">删除</el-button>
|
||||
<el-button link type="warning" size="small" @click.stop="openOsdDialog(getRowById(row['id'])!)">OSD</el-button>
|
||||
<el-button link type="success" size="small" @click.stop="handlePreview(getRowById(row['id'])!)">预览</el-button>
|
||||
</div>
|
||||
</template>
|
||||
@ -207,6 +208,7 @@
|
||||
<div class="operation-cell">
|
||||
<el-button link type="primary" size="small" @click.stop="openCameraForm('edit', getRowById(row['id']))">编辑</el-button>
|
||||
<el-button link type="danger" size="small" @click.stop="handleDeleteCamera(getRowById(row['id'])!)">删除</el-button>
|
||||
<el-button link type="warning" size="small" @click.stop="openOsdDialog(getRowById(row['id'])!)">OSD</el-button>
|
||||
<el-button link type="success" size="small" @click.stop="handlePreview(getRowById(row['id'])!)">预览</el-button>
|
||||
</div>
|
||||
</template>
|
||||
@ -239,6 +241,77 @@
|
||||
|
||||
<!-- ===== 预览弹窗 ===== -->
|
||||
<CameraPreviewDialog v-model="previewVisible" :camera-row="previewCameraRow" />
|
||||
|
||||
<!-- ===== OSD 文字叠加设置弹窗 ===== -->
|
||||
<el-dialog
|
||||
v-model="osdVisible"
|
||||
title="设置 OSD 文字叠加"
|
||||
width="520px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="resetOsdForm"
|
||||
>
|
||||
<div class="osd-camera-info">
|
||||
<span class="osd-label">摄像头:</span>
|
||||
<span>{{ osdCameraName }}</span>
|
||||
</div>
|
||||
<el-form ref="osdFormRef" :model="osdForm" :rules="osdRules" label-width="100px" class="osd-form">
|
||||
<el-form-item label="叠加文字" prop="text">
|
||||
<el-input
|
||||
v-model="osdForm.text"
|
||||
placeholder="请输入要在画面中叠加的文字"
|
||||
maxlength="64"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="X 坐标">
|
||||
<div class="osd-coord-row">
|
||||
<el-slider
|
||||
v-model="osdForm.x"
|
||||
:min="-1"
|
||||
:max="1"
|
||||
:step="0.1"
|
||||
:marks="osdCoordMarks"
|
||||
show-input
|
||||
style="flex:1"
|
||||
/>
|
||||
</div>
|
||||
<div class="osd-coord-hint">范围 -1(左)~ 1(右),默认 -0.9</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="Y 坐标">
|
||||
<div class="osd-coord-row">
|
||||
<el-slider
|
||||
v-model="osdForm.y"
|
||||
:min="-1"
|
||||
:max="1"
|
||||
:step="0.1"
|
||||
:marks="osdCoordMarks"
|
||||
show-input
|
||||
style="flex:1"
|
||||
/>
|
||||
</div>
|
||||
<div class="osd-coord-hint">范围 -1(上)~ 1(下),默认 0.8</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="osd-preview-box">
|
||||
<div class="osd-preview-label">位置预览</div>
|
||||
<div class="osd-preview-canvas">
|
||||
<span
|
||||
class="osd-preview-dot"
|
||||
:style="osdDotStyle"
|
||||
title="OSD 文字参考位置"
|
||||
>●</span>
|
||||
</div>
|
||||
<div class="osd-preview-pos">当前坐标:({{ osdForm.x.toFixed(1) }}, {{ osdForm.y.toFixed(1) }})</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="osdVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="osdSaving" @click="submitOsd">
|
||||
应用 OSD
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -250,6 +323,7 @@ defineOptions({ name: 'NewCamera' })
|
||||
|
||||
import { ref, computed, onMounted, reactive } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
@ -261,7 +335,7 @@ import CameraFormDialog from './pages/CameraFormDialog.vue'
|
||||
import CameraPreviewDialog from './components/CameraPreviewDialog.vue'
|
||||
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
||||
import type { ToolbarButtonConfig as OrderToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||||
import { del } from '@/api/camera/camera'
|
||||
import { del, setOsd } from '@/api/camera/camera'
|
||||
import {
|
||||
PAGE_CONFIG,
|
||||
tabPages,
|
||||
@ -465,6 +539,76 @@ function handleFormSuccess() {
|
||||
const previewVisible = ref(false)
|
||||
const previewCameraRow = ref<Record<string, any> | null>(null)
|
||||
|
||||
// ============================================================
|
||||
// OSD 文字叠加
|
||||
// ============================================================
|
||||
const osdVisible = ref(false)
|
||||
const osdSaving = ref(false)
|
||||
const osdCameraRow = ref<Record<string, any> | null>(null)
|
||||
const osdFormRef = ref<FormInstance>()
|
||||
const osdForm = reactive({ text: '', x: -0.9, y: 0.8 })
|
||||
const osdRules: FormRules = {
|
||||
text: [{ required: true, message: '请输入叠加文字', trigger: 'blur' }]
|
||||
}
|
||||
const osdCoordMarks = { '-1': '-1', '0': '0', '1': '1' }
|
||||
|
||||
const osdCameraName = computed(() => {
|
||||
const row = osdCameraRow.value
|
||||
if (!row) return '--'
|
||||
return row.custom_name || row.channel_name || `摄像头 #${row.id}`
|
||||
})
|
||||
|
||||
const osdDotStyle = computed(() => {
|
||||
const left = ((osdForm.x + 1) / 2) * 100
|
||||
const top = ((1 - osdForm.y) / 2) * 100
|
||||
return { left: `${left}%`, top: `${top}%` }
|
||||
})
|
||||
|
||||
function openOsdDialog(row: Record<string, any>) {
|
||||
osdCameraRow.value = row
|
||||
resetOsdForm()
|
||||
osdVisible.value = true
|
||||
}
|
||||
|
||||
function resetOsdForm() {
|
||||
osdForm.text = ''
|
||||
osdForm.x = -0.9
|
||||
osdForm.y = 0.8
|
||||
osdFormRef.value?.clearValidate()
|
||||
}
|
||||
|
||||
async function submitOsd() {
|
||||
if (!osdFormRef.value || osdSaving.value) return
|
||||
const valid = await osdFormRef.value.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
|
||||
const row = osdCameraRow.value
|
||||
if (!row?.id) {
|
||||
ElMessage.error('未找到摄像头信息')
|
||||
return
|
||||
}
|
||||
|
||||
osdSaving.value = true
|
||||
try {
|
||||
const res: any = await setOsd({
|
||||
id: row.id,
|
||||
text: osdForm.text.trim(),
|
||||
x: osdForm.x,
|
||||
y: osdForm.y
|
||||
})
|
||||
if (res && [0, 1, 200].includes(res.code)) {
|
||||
ElMessage.success(`已为「${osdCameraName.value}」设置 OSD 文字`)
|
||||
osdVisible.value = false
|
||||
} else {
|
||||
ElMessage.error(res?.message || 'OSD 设置失败')
|
||||
}
|
||||
} catch {
|
||||
ElMessage.error('OSD 设置失败,请检查网络连接')
|
||||
} finally {
|
||||
osdSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 操作列按钮事件处理
|
||||
// ============================================================
|
||||
@ -479,6 +623,9 @@ async function handleOperationAction(key: string, row: Record<string, any>) {
|
||||
case 'preview':
|
||||
handlePreview(row)
|
||||
break
|
||||
case 'osd':
|
||||
openOsdDialog(row)
|
||||
break
|
||||
default:
|
||||
console.warn('[NewCamera] 未处理的操作按钮:', key)
|
||||
}
|
||||
@ -815,4 +962,65 @@ onMounted(() => {
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
/* ================================================================
|
||||
6. OSD 弹窗样式
|
||||
================================================================ */
|
||||
.osd-camera-info {
|
||||
padding: 8px 12px;
|
||||
margin-bottom: 16px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
color: #303133;
|
||||
}
|
||||
.osd-label {
|
||||
color: #909399;
|
||||
}
|
||||
.osd-form {
|
||||
margin-top: 0;
|
||||
}
|
||||
.osd-coord-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
.osd-coord-hint {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.osd-preview-box {
|
||||
margin-top: 16px;
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 6px;
|
||||
padding: 12px;
|
||||
}
|
||||
.osd-preview-label {
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.osd-preview-canvas {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 120px;
|
||||
background: #1a1a2e;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.osd-preview-dot {
|
||||
position: absolute;
|
||||
font-size: 16px;
|
||||
color: #67c23a;
|
||||
transform: translate(-50%, -50%);
|
||||
text-shadow: 0 0 4px rgba(103, 194, 58, 0.6);
|
||||
pointer-events: none;
|
||||
}
|
||||
.osd-preview-pos {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user