diff --git a/dist.tar.gz b/dist.tar.gz index f14ab0fb..4185dac0 100644 Binary files a/dist.tar.gz and b/dist.tar.gz differ diff --git a/src/api/order.packing/packing.ts b/src/api/order.packing/packing.ts new file mode 100644 index 00000000..462e870e --- /dev/null +++ b/src/api/order.packing/packing.ts @@ -0,0 +1,68 @@ +import request from '@/utils/request' + +const v = '1.0' + +/** order.packing.list 查询参数 */ +export type PackingListPagination = { + page?: number + pageSize?: number +} + +export type PackingListWhere = Record & { + status?: number + pack_mode?: number + waybill_code?: string + wave_no?: string + order_id?: number + workbench_id?: number + quickWhere?: string + start_time_start?: string + start_time_end?: string +} + +export type PackingListSort = { + sortField?: string + sortOrder?: 'asc' | 'desc' | 'ASC' | 'DESC' +} + +export type PackingListParams = { + pagination?: PackingListPagination + where?: PackingListWhere + sort?: PackingListSort +} + +/** order.packing.list:打包任务列表查询(仓库侧) */ +export function packingList(data: PackingListParams = {}): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'order.packing.list', + v, + timestamp: new Date().getTime(), + }, + data, + isSystemApi: true, + } as any) +} + +/** order.packing.get 请求参数 */ +export type PackingDetailParams = { + /** 打包任务ID(必填) */ + id: number +} + +/** order.packing.get:打包任务详情查询(仓库侧) */ +export function packingDetail(data: PackingDetailParams): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'order.packing.get', + v, + timestamp: new Date().getTime(), + }, + data, + isSystemApi: true, + } as any) +} diff --git a/src/api/storage.entry/entry.ts b/src/api/storage.entry/entry.ts index 66d84538..178286e7 100644 --- a/src/api/storage.entry/entry.ts +++ b/src/api/storage.entry/entry.ts @@ -703,3 +703,48 @@ export function queryEntryLogs(data: QueryEntryLogsParams = {}): Promise { isSystemApi: true, } as any) } + +/** storage.entry.export 导出参数(异步任务模式) */ +export type EntryExportParams = { + where?: Record + sort?: { + sortField?: string + sortOrder?: 'asc' | 'desc' | 'ASC' | 'DESC' + } +} + +/** storage.entry.export:导出入库单列表及明细(异步任务模式),返回 task_id */ +export function entryExport(data: EntryExportParams = {}): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.entry.export', + v, + timestamp: new Date().getTime(), + }, + data, + isSystemApi: true, + } as any) +} + +/** storage.entry.exportTaskProgress 查询参数 */ +export type EntryExportTaskProgressParams = { + task_id?: string + taskId?: string +} + +/** storage.entry.exportTaskProgress:查询入库单导出任务进度与下载链接 */ +export function entryExportTaskProgress(data: EntryExportTaskProgressParams): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.entry.exportTaskProgress', + v, + timestamp: new Date().getTime(), + }, + data, + isSystemApi: true, + } as any) +} diff --git a/src/router/map.ts b/src/router/map.ts index 888c2b44..eb6bf601 100644 --- a/src/router/map.ts +++ b/src/router/map.ts @@ -63,7 +63,7 @@ export const componentMap: Record = { 'material/packageMaterial/index':() => import('@/views/material/packageMaterial/index.vue'), 'material/packageSupplier/index':() => import('@/views/material/packageSupplier/index.vue'), 'system/setting/pickcart/index':() => import('@/views/system/setting/pickcart/index.vue'), - 'video/cameraServer/index': () => import('@/views/video/cameraServer/index.vue'), + 'video/cameraServer/index': () => import('@/views/video/newcamaraserver/index.vue'), 'video/camera/index': () => import('@/views/video/newcamara/index.vue'), 'data/packingflow': () => import('@/views/data/packingflow/index.vue'), }; \ No newline at end of file diff --git a/src/views/data/packingflow/index.vue b/src/views/data/packingflow/index.vue index 76783b17..944ecf09 100644 --- a/src/views/data/packingflow/index.vue +++ b/src/views/data/packingflow/index.vue @@ -72,9 +72,6 @@ - @@ -189,8 +186,7 @@ const columns = [ { prop: 'start_time', label: '开始时间', width: 170, sortable: true, formatter: (row: any) => row.start_time ? dayjs(row.start_time).format('YYYY-MM-DD HH:mm:ss') : '—' }, { prop: 'end_time', label: '结束时间', width: 170, sortable: true, formatter: (row: any) => row.end_time ? dayjs(row.end_time).format('YYYY-MM-DD HH:mm:ss') : '—' }, { prop: 'create_time', label: '创建时间', width: 170, sortable: true, formatter: (row: any) => row.create_time ? dayjs(row.create_time).format('YYYY-MM-DD HH:mm:ss') : '—' }, - { prop: 'videos', label: '录像', width: 110, fixed: 'right' }, - { prop: 'actions', label: '操作', width: 80, fixed: 'right' } + { prop: 'videos', label: '录像', width: 110, fixed: 'right' } ] // ─── 筛选字段配置 ────────────────────────────────────────────────────────── diff --git a/src/views/order/waveOrder2/config/waveorder-config.ts b/src/views/order/waveOrder2/config/waveorder-config.ts index 22f36598..04778fe9 100644 --- a/src/views/order/waveOrder2/config/waveorder-config.ts +++ b/src/views/order/waveOrder2/config/waveorder-config.ts @@ -1180,6 +1180,7 @@ export const waveOrder2TabPages: TabPageRawConfig[] = [ // ============================================================ // 十、向后兼容导出 // ============================================================ +// 单页模式 singlePage export const WAVEORDER2_PAGE_CONFIG = { showTabArea: true, singlePage: false, enableDetailPanel: true } export const waveOrder2Tabs = waveOrder2TabPages.map((t) => ({ diff --git a/src/views/stock/stock/component/add.vue b/src/views/stock/stock/component/add.vue index b17d1e05..a633560c 100644 --- a/src/views/stock/stock/component/add.vue +++ b/src/views/stock/stock/component/add.vue @@ -395,12 +395,6 @@ const validateItemCode = async (rule: any, value: any, callback: any) => { return } - if (value.length > 20) { - itemCodeError.value = "条码长度不能超过20个字符" - callback(new Error(itemCodeError.value)) - return - } - if (!formData.store_id) { itemCodeError.value = '请先选择货主' callback(new Error(itemCodeError.value)) diff --git a/src/views/stock/stock/component/barcode.vue b/src/views/stock/stock/component/barcode.vue index 2f00086f..abc8ea5b 100644 --- a/src/views/stock/stock/component/barcode.vue +++ b/src/views/stock/stock/component/barcode.vue @@ -18,7 +18,7 @@ clearable resize="none" class="barcode-textarea" - :disabled="!hasPermission('stock.saveWarehouseStockBarcode')" + :disabled="!hasPermission('stock.warehouse.saveWarehouseStockBarcode')" @blur="handleBlur" /> @@ -30,7 +30,7 @@ diff --git a/src/views/stock/stock/component/info.vue b/src/views/stock/stock/component/info.vue index fd231ccc..0f758007 100644 --- a/src/views/stock/stock/component/info.vue +++ b/src/views/stock/stock/component/info.vue @@ -1,6 +1,6 @@ @@ -330,7 +351,6 @@ import UpperTable from '@/components/UpperTable/index.vue' import * as indexApi from '@/api/index/index' import * as entryApi from '@/api/storage.entry/entry' import type { StorageEntryListParams } from '@/api/storage.entry/entry' -import * as XLSX from 'xlsx' import { availableFields, @@ -356,8 +376,9 @@ import entryoperate from './component/entryoperate.vue' import BindReceivingToEntryDialog from './component/BindReceivingToEntryDialog.vue' import DirectInboundLogs from './component/DirectInboundLogs.vue' import EntryBindingRelations from './component/EntryBindingRelations.vue' -import ExportModeDropdown from '@/components/ExportModeDropdown.vue' import BatchReceivingPrintDialog from '@/components/BatchReceivingPrintDialog.vue' +import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue' +import { useAsyncExportTask } from '@/composables/useAsyncExportTask' import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane' import { useSettingsStore } from '@/stores/modules/settings' @@ -421,9 +442,22 @@ const activeTab = ref('details') const list = ref([]) const loading = ref(false) -const exportLoading = ref(false) const queryTime = ref(0) +const { + exportLoading, + exportDialogVisible, + exportTaskProgress, + exportProgressPercent, + exportProgressStatus, + exportStatusLabel, + submitExportTask +} = useAsyncExportTask({ + storageKey: 'storage:entry:exportTaskId', + submitExport: (payload) => entryApi.entryExport(payload as any), + queryProgress: (params) => entryApi.entryExportTaskProgress(params) +}) + const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 }) const tableSize = ref('small') const columns = ref(entryColums) @@ -436,6 +470,43 @@ const selectedEntryId = ref(null) const quickSearch = ref('') const currentSort = reactive({ prop: '', order: '' }) +// 导出相关 —— 使用异步任务模式 +function buildExportPayload() { + if (currentCondition.value && currentCondition.value !== 'reset') { + return { where: normalizeToWhere(currentCondition.value) } + } + return { where: normalizeToWhere({}) } +} + +function buildExportSelectedPayload() { + const ids = selectionRows.value.map((item: any) => item.id) + return { + where: { + id: { operator: 'in', value: ids } + } + } +} + +async function handleExportAll() { + await submitExportTask(buildExportPayload()) +} + +async function handleExportSelected() { + if (!selectionRows.value.length) { + ElMessage.warning('请先勾选需要导出的入库单') + return + } + await submitExportTask(buildExportSelectedPayload()) +} + +function handleExportCommand(command: string) { + if (command === 'handleExportSelected') { + handleExportSelected() + } else { + handleExportAll() + } +} + const componentMap: Record = { details: entrydetail, bindingRelations: EntryBindingRelations, @@ -1093,84 +1164,6 @@ async function confirmBatchCancel() { } } -async function handleExport(mode: 'waybill' | 'item' = 'waybill') { - const sourceRows = selectionRows.value.length ? selectionRows.value : list.value - if (!sourceRows.length) { - ElMessage.warning('当前无数据可导出') - return - } - exportLoading.value = true - try { - const exportColumns = columns.value.filter(col => col.prop && col.label) - - if (mode === 'waybill') { - const headers = exportColumns.map(col => col.label) - const data = sourceRows.map(row => - exportColumns.map(col => { - const val = row[col.prop] - if (['order_status', 'order_type', 'sync_status'].includes(col.prop)) { - return translateField(col.prop, val) - } - return val === null || val === undefined ? '' : val - }) - ) - const ws = XLSX.utils.aoa_to_sheet([headers, ...data]) - const wb = XLSX.utils.book_new() - XLSX.utils.book_append_sheet(wb, ws, '入库单列表') - XLSX.writeFile(wb, `入库单列表_${new Date().getTime()}.xlsx`) - ElMessage.success('导出成功') - return - } - - const detailRows: any[] = [] - for (const row of sourceRows) { - try { - const res: any = await entryApi.getEntryDetail({ id: row.id }) - const payload = res?.data || res - const bindings = Array.isArray(payload?.bindings) - ? payload.bindings - : Array.isArray(payload?.details) - ? payload.details - : [] - bindings.forEach((item: any) => { - detailRows.push({ - '入库单号': row.entry_number || row.order_code || row.id, - '商品编码': item.item_code || item.product_code || '', - '商品名称': item.item_name || item.product_name || '', - '计划数量': item.plan_qty ?? item.quantity ?? '', - '实收数量': item.actual_qty ?? item.received_qty ?? '', - '批次号': item.batch_number || '', - '库位': item.space_id || item.space_name || '', - '备注': item.remark || '' - }) - }) - } catch (e) { - console.warn(`获取入库单 ${row.id} 明细失败`, e) - } - } - - if (!detailRows.length) { - ElMessage.warning('未获取到可导出的入库明细') - return - } - - const ws = XLSX.utils.json_to_sheet(detailRows) - const wb = XLSX.utils.book_new() - XLSX.utils.book_append_sheet(wb, ws, '入库明细') - XLSX.writeFile(wb, `入库明细_${new Date().getTime()}.xlsx`) - ElMessage.success('导出成功') - } catch (e) { - console.error('导出 Excel 失败:', e) - ElMessage.error('导出失败') - } finally { - exportLoading.value = false - } -} - -function handleExportAction(action: string) { - void handleExport(action === 'handleExportItem' ? 'item' : 'waybill') -} - function handleImport() { if (!selectedEntryId.value) { ElMessage.warning('请先在列表中选择一个入库单') diff --git a/src/views/system/setting/workbench2/components/ColumnCellRenderer.vue b/src/views/system/setting/workbench2/components/ColumnCellRenderer.vue new file mode 100644 index 00000000..8aa6b3a8 --- /dev/null +++ b/src/views/system/setting/workbench2/components/ColumnCellRenderer.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/src/views/system/setting/workbench2/components/OperationCellRenderer.vue b/src/views/system/setting/workbench2/components/OperationCellRenderer.vue new file mode 100644 index 00000000..a1190233 --- /dev/null +++ b/src/views/system/setting/workbench2/components/OperationCellRenderer.vue @@ -0,0 +1,175 @@ + + + + + + diff --git a/src/views/system/setting/workbench2/components/TabArea.vue b/src/views/system/setting/workbench2/components/TabArea.vue new file mode 100644 index 00000000..288ec6f1 --- /dev/null +++ b/src/views/system/setting/workbench2/components/TabArea.vue @@ -0,0 +1,132 @@ + + + + + diff --git a/src/views/system/setting/workbench2/config/components/DetailPanel.vue b/src/views/system/setting/workbench2/config/components/DetailPanel.vue new file mode 100644 index 00000000..eb992d25 --- /dev/null +++ b/src/views/system/setting/workbench2/config/components/DetailPanel.vue @@ -0,0 +1,159 @@ + + + + + + diff --git a/src/views/system/setting/workbench2/config/components/LogPanel.vue b/src/views/system/setting/workbench2/config/components/LogPanel.vue new file mode 100644 index 00000000..0adae9f3 --- /dev/null +++ b/src/views/system/setting/workbench2/config/components/LogPanel.vue @@ -0,0 +1,227 @@ + + + + + + diff --git a/src/views/system/setting/workbench2/config/template-config.ts b/src/views/system/setting/workbench2/config/template-config.ts new file mode 100644 index 00000000..283b3b01 --- /dev/null +++ b/src/views/system/setting/workbench2/config/template-config.ts @@ -0,0 +1,648 @@ +/** + * 【工作台管理】页面配置 — 基于 waveOrder2 架构设计 + */ + +import type { Component } from 'vue' +import DetailPanel from './components/DetailPanel.vue' +import LogPanel from './components/LogPanel.vue' +import { + list as workbenchList, + detail as workbenchDetail, + create as workbenchCreate, + update as workbenchUpdate, + del as workbenchDelete, + checkBarcode as workbenchCheckBarcode, + bindCamera as workbenchBindCamera +} from '@/api/workbench/workbench' +import { list as cameraList } from '@/api/camera/camera' + +// ============================================================ +// 〇、全局页面配置 +// ============================================================ +export const PAGE_CONFIG = { + /** 是否显示顶部多标签栏 */ + showTabArea: false, + /** 单页模式:不显示标签栏,仅一个标签页内容 */ + singlePage: true, + /** 是否启用详情面板(底部分栏 + 显示/隐藏详情按钮),false 时表格占满全高 */ + enableDetailPanel: false +} + +// ============================================================ +// 〇-A、组件注册表 — 所有可复用组件在此注册 +// ============================================================ +export const COMPONENT_REGISTRY: Record = { + DetailPanel, + LogPanel +} + +// ============================================================ +// 〇-B、SCANBOX_GROUPS — ScanBox 分组名称 +// ============================================================ +export const SCANBOX_GROUPS = { + basic: '基础信息', + process: '流程状态', + time: '时间范围', + custom: '自定义字段' +} as const + +// ============================================================ +// 一、FIELD_DICT — 全局字段预设表(唯一真相来源) +// ============================================================ +// 每个字段拥有: +// label — 唯一翻译文本 +// scanBox — ScanBox 渲染配置(type/options/group) +// table — 表格列配置(minWidth/fixed/align/sortable) +// slot — 单元格渲染配置(tag/tagResolver/translateField) +// detailLabel — 明细面板中的标签文本(可选,默认用 label) +// filterParamMap — ScanBox 筛选值 → API 传参值映射 + +export interface FieldDefinition { + key: string + label: string + scanBox: { + type: 'text' | 'select' | 'daterange' | 'number' + group?: string + options?: { label: string; value: any }[] + } | null + table: { + minWidth?: number + width?: number + fixed?: 'left' | 'right' | boolean + align?: 'left' | 'center' | 'right' + sortable?: boolean + showOverflowTooltip?: boolean + copyAction?: 'copy' | 'copyQr' + copyValue?: (row: any) => any + } | null + slot: { + type: 'tag' | 'text' | 'default' | 'operation' + tagType?: string | Record + tagResolver?: string + translateField?: string + format?: 'datetime' + } | null + detailLabel?: string + filterParamMap?: Record +} + +// ============================================================ +// VALUE_MAPS — 值翻译映射 +// ============================================================ +export const VALUE_MAPS: Record> = { + workbenchStatus: { '1': '启用', '0': '禁用', '启用': '启用', '禁用': '禁用' }, + bool: { '1': '是', '0': '否', '是': '是', '否': '否' } +} + +/** 从 VALUE_MAPS 衍生 options(优先取中文值作为 option value) */ +export function getOptions(field: string): { label: string; value: string }[] { + const map = VALUE_MAPS[field] + if (!map) return [] + const seen = new Set() + const opts: { label: string; value: string }[] = [] + const chineseKeys: [string, string][] = [] + const otherKeys: [string, string][] = [] + for (const [v, l] of Object.entries(map)) { + if (/^[\u4e00-\u9fa5]/.test(v)) { + chineseKeys.push([v, l]) + } else { + otherKeys.push([v, l]) + } + } + for (const [v, l] of [...chineseKeys, ...otherKeys]) { + if (!seen.has(l)) { + seen.add(l) + opts.push({ label: l, value: v }) + } + } + return opts +} + +/** 翻译 value → label */ +export function translate(field: string, value: any): string { + const map = VALUE_MAPS[field] + if (!map) return String(value ?? '—') + return map[String(value)] ?? String(value ?? '—') +} + +/** 格式化时间戳为 YYYY-MM-DD HH:mm:ss */ +export function formatTime(value: any): string { + if (!value) return '—' + try { + const d = new Date(value) + if (isNaN(d.getTime())) return String(value) + const pad = (n: number) => String(n).padStart(2, '0') + return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}` + } catch { + return String(value) + } +} + +// ============================================================ +// TAG_RESOLVERS — 标签颜色解析器 +// ============================================================ +export const TAG_RESOLVERS: Record string> = { + resolveWorkbenchStatusTag(v) { + if (v === undefined || v === null) return 'info' + return Number(v) === 1 ? 'success' : 'info' + }, + resolveBoolTag(v) { + if (v === undefined || v === null) return 'info' + if (v === '是' || v === true || v === 1 || v === '1') return 'success' + return 'info' + } +} + +// ============================================================ +// 二、FIELD_DICT 实例 — 工作台管理字段定义 +// ============================================================ +export const FIELD_DICT: Record = { + id: { + key: 'id', + label: 'ID', + scanBox: null, + table: { width: 80, sortable: true }, + slot: null, + detailLabel: 'ID' + }, + name: { + key: 'name', + label: '工作台名称', + scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, + table: { minWidth: 140, showOverflowTooltip: true }, + slot: null, + detailLabel: '工作台名称' + }, + barcode: { + key: 'barcode', + label: '条码', + scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, + table: { minWidth: 120, showOverflowTooltip: true }, + slot: null, + detailLabel: '条码' + }, + warehouse_id: { + key: 'warehouse_id', + label: '仓库ID', + scanBox: null, + table: { width: 100 }, + slot: null, + detailLabel: '仓库ID' + }, + status: { + key: 'status', + label: '状态', + scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('workbenchStatus') }, + table: { width: 80, align: 'center' }, + slot: { type: 'tag', tagResolver: 'resolveWorkbenchStatusTag', translateField: 'workbenchStatus' }, + detailLabel: '状态', + filterParamMap: { '启用': '1', '禁用': '0' } + }, + device_ids: { + key: 'device_ids', + label: '绑定摄像头', + scanBox: null, + table: { width: 120, align: 'center' }, + slot: { type: 'tag', tagType: { '0': 'info' } }, + detailLabel: '绑定摄像头' + }, + remark: { + key: 'remark', + label: '备注', + scanBox: null, + table: { minWidth: 140, showOverflowTooltip: true }, + slot: null, + detailLabel: '备注' + }, + created_at: { + key: 'created_at', + label: '创建时间', + scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time }, + table: { minWidth: 160, sortable: true }, + slot: { type: 'text', format: 'datetime' }, + detailLabel: '创建时间' + }, + updated_at: { + key: 'updated_at', + label: '更新时间', + scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time }, + table: { minWidth: 160, sortable: true }, + slot: { type: 'text', format: 'datetime' }, + detailLabel: '更新时间' + }, + /** 操作列(虚拟字段,仅用于表格列渲染) */ + operation: { + key: 'operation', + label: '操作', + scanBox: null, + table: { minWidth: 260, fixed: 'right', align: 'center' }, + slot: { type: 'operation' } + } +} + +// ============================================================ +// 三、ColumnSlotConfig — 列单元格渲染配置 +// ============================================================ +export interface ColumnSlotConfig { + type: 'tag' | 'text' | 'default' | 'operation' + tagType?: string | Record + tagResolver?: string + translateField?: string + format?: 'datetime' +} + +// ============================================================ +// 三-A、OperationButtonConfig — 操作列按钮配置 +// ============================================================ +export interface OperationButtonConfig { + key: string + label: string + type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | '' + actionType: 'form' | 'action' + formKey?: string + formTitle?: string + formWidth?: string + paramMap?: Record + extraParams?: Record + disabledOnField?: string + confirmMessage?: string + confirmTitle?: string + confirmType?: 'warning' | 'danger' | 'info' + confirmButtonText?: string +} + +// ============================================================ +// 四、DetailFieldConfig / DetailSectionConfig — 明细面板配置 +// ============================================================ +export interface DetailFieldConfig { + key: string + label?: string + span?: number + renderType?: 'text' | 'tag' | 'pre' + tagType?: string | Record + tagResolver?: string + translateField?: string +} + +export interface DetailSectionConfig { + title: string + columnCount: number + fields: DetailFieldConfig[] +} + +export interface DetailTabConfig { + name: string + label: string + componentKey: string + component?: Component +} + +// ============================================================ +// 五、TabPageApiConfig — 标签页接口插槽配置 +// ============================================================ +export type ApiMethod = (...args: any[]) => Promise +export type ApiSource = 'api' | 'list' +export type ComponentApiConfig = { source: 'list' } | ApiMethod + +export interface TabPageApiConfig { + /** 列表查询接口 */ + list: ApiMethod + /** 明细面板接口(可选,不配则用 row 数据) */ + detail?: ComponentApiConfig + /** 操作日志接口(可选) */ + log?: ComponentApiConfig + /** 导出接口(可选) */ + export?: ApiMethod + /** 导出进度查询接口(可选) */ + exportProgress?: ApiMethod + /** ScanBox 下拉选项数据源接口(可选) */ + scanBoxOptions?: Record + /** 工具栏按钮 → API 方法映射(可选) */ + toolbar?: Record + /** 列表响应解析器 */ + parseListResponse?: (res: any) => { list: any[]; total: number } + /** 构建列表请求参数 */ + buildListParams?: (params: { + pagination: { page: number; pageSize: number } + conditions: Record + sort?: { prop: string; order: string } + }) => Record +} + +// ============================================================ +// 六、TabPageRawConfig — 标签页声明配置(仅用 key 引用) +// ============================================================ +export interface TabPageRawConfig { + name: string + label: string + scanBoxCacheKey: string + /** ScanBox 需要的字段 key 列表(从 FIELD_DICT 中查找) */ + scanBoxFieldKeys: string[] + /** 表格需要的列 key 列表(从 FIELD_DICT 中查找) */ + tableColumnKeys: string[] + upperTableDefaults: { + title: string + enableColumnConfig?: boolean + showIndex?: boolean + showSelection?: boolean + emptyText?: string + } + /** 明细面板标签页配置 */ + detailTabs?: { name: string; label: string; componentKey: string }[] + /** 明细面板分区配置(字段 key 列表,resolveTabConfig 展开) */ + detailSections: { + title: string + columnCount: number + fieldKeys: string[] + }[] + /** 接口配置(有 api 时启用真实接口) */ + api?: TabPageApiConfig + /** 操作列按钮配置(需 tableColumnKeys 包含 'operation') */ + operationButtons?: OperationButtonConfig[] +} + +// ============================================================ +// 七、TabPageConfig — 展开后的完整配置(给 index.vue 使用) +// ============================================================ +export interface TabPageConfig { + name: string + label: string + scanBoxCacheKey: string + scanBoxFields: Record[] + upperTable: { + title: string + enableColumnConfig: boolean + showIndex: boolean + showSelection: boolean + emptyText: string + columns: Record[] + } + columnSlots: Record + detailConfig: DetailSectionConfig[] + detailTabs: DetailTabConfig[] + api?: TabPageApiConfig + operationButtons?: OperationButtonConfig[] +} + +// ============================================================ +// 八、resolveTabConfig — 加载时将 RawConfig 展开为完整配置 +// ============================================================ +export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig { + // 展开 ScanBox 字段 + const scanBoxFields: Record[] = [] + for (const key of raw.scanBoxFieldKeys) { + const def = FIELD_DICT[key] + if (!def || !def.scanBox) continue + scanBoxFields.push({ + label: def.label, + value: def.key, + type: def.scanBox.type, + options: def.scanBox.options ? [...def.scanBox.options] : undefined, + group: def.scanBox.group, + required: (def.scanBox as any).required + }) + } + + // 展开表格列 + const columns: Record[] = [] + for (const key of raw.tableColumnKeys) { + const def = FIELD_DICT[key] + if (!def || !def.table) continue + columns.push({ + prop: def.key, + label: def.label, + ...def.table + }) + } + + // 展开列插槽 + const columnSlots: Record = {} + for (const key of raw.tableColumnKeys) { + const def = FIELD_DICT[key] + if (!def || !def.slot) continue + columnSlots[def.key] = { ...def.slot } + } + + // 展开明细面板配置 + const detailConfig: DetailSectionConfig[] = raw.detailSections.map((sec) => ({ + title: sec.title, + columnCount: sec.columnCount, + fields: sec.fieldKeys + .map((key): DetailFieldConfig | null => { + const def = FIELD_DICT[key] + if (!def) return null + return { + key: def.key, + label: def.detailLabel ?? def.label, + translateField: def.slot?.translateField, + tagResolver: def.slot?.tagResolver, + tagType: def.slot?.tagType, + renderType: def.slot?.type === 'tag' ? 'tag' : 'text' + } + }) + .filter((f): f is DetailFieldConfig => f !== null) + })) + + // 展开明细标签页(解析 componentKey → Component) + const detailTabs: DetailTabConfig[] = raw.detailTabs + ? raw.detailTabs.map((tab) => ({ + name: tab.name, + label: tab.label, + componentKey: tab.componentKey, + component: COMPONENT_REGISTRY[tab.componentKey] + })) + : [{ name: 'detail', label: '明细', componentKey: 'DetailPanel', component: COMPONENT_REGISTRY['DetailPanel'] }] + + return { + name: raw.name, + label: raw.label, + scanBoxCacheKey: raw.scanBoxCacheKey, + scanBoxFields, + upperTable: { + title: raw.upperTableDefaults.title, + enableColumnConfig: raw.upperTableDefaults.enableColumnConfig ?? true, + showIndex: raw.upperTableDefaults.showIndex ?? true, + showSelection: raw.upperTableDefaults.showSelection ?? true, + emptyText: raw.upperTableDefaults.emptyText ?? '暂无数据', + columns + }, + columnSlots, + detailConfig, + detailTabs, + api: raw.api, + operationButtons: raw.operationButtons + } +} + +// ============================================================ +// 九、buildWhereConditions — 将 ScanBox 条件转为 API where 参数 +// ============================================================ +export function buildWhereConditions(rawConditions: Record): Record { + const where: Record = {} + for (const [key, cond] of Object.entries(rawConditions || {})) { + let value: any = undefined + if (cond && typeof cond === 'object' && 'operator' in cond) { + value = (cond as any).value + } else if (cond !== undefined && cond !== null && cond !== '') { + value = Array.isArray(cond) ? cond[0] ?? '' : cond + } + if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) { + continue + } + const def = FIELD_DICT[key] + if (def?.filterParamMap) { + const mapped = def.filterParamMap[String(value)] + if (mapped !== undefined) { + where[key] = mapped + continue + } + } + where[key] = value + } + return where +} + +// ============================================================ +// 十、工具栏按钮系统 +// ============================================================ + +export interface ToolbarButtonConfig { + key: string + label: string + category: 'common' | 'function' | 'basic' + size?: '' | 'default' | 'small' | 'large' + type?: '' | 'primary' | 'success' | 'warning' | 'info' | 'danger' + plain?: boolean + loadingKey?: string + disabledKey?: string + action: string + dynamicLabelKey?: string + onlyForTabs?: string[] + buttonType?: 'default' | 'dropdown' + dropdownOptions?: Array<{ label: string; action: string; divided?: boolean }> + formKey?: string +} + +export const TOOLBAR_BUTTONS: Record = { + refresh: { + key: 'refresh', + label: '刷新', + category: 'common', + type: 'primary', + size: 'small', + loadingKey: 'loading', + action: 'loadData' + }, + addWorkbench: { + key: 'addWorkbench', + label: '新增工作台', + category: 'function', + type: 'success', + size: 'small', + action: 'openCreateDialog' + }, + toggleDetail: { + key: 'toggleDetail', + label: '显示详情', + category: 'basic', + dynamicLabelKey: 'detailToggleLabel', + size: 'small', + action: 'toggleDetailVisible' + } +} + +/** 按标签页名称获取工具栏按钮列表 */ +export function getTabToolbarButtons(tabName: string): ToolbarButtonConfig[] { + return Object.values(TOOLBAR_BUTTONS).filter((btn) => { + if (btn.onlyForTabs && !btn.onlyForTabs.includes(tabName)) return false + if (!PAGE_CONFIG.enableDetailPanel && btn.key === 'toggleDetail') return false + return true + }) +} + +// ============================================================ +// 十一、标签页注册表 — 工作台管理 +// ============================================================ +export const tabPages: TabPageRawConfig[] = [ + { + name: 'workbench', + label: '工作台管理', + scanBoxCacheKey: 'setting-workbench', + scanBoxFieldKeys: ['name', 'barcode', 'status', 'created_at'], + tableColumnKeys: ['id', 'name', 'barcode', 'warehouse_id', 'status', 'device_ids', 'remark', 'created_at', 'updated_at', 'operation'], + upperTableDefaults: { + title: '工作台列表', + showSelection: false, + showIndex: true, + emptyText: '暂无工作台数据,可调整左侧筛选条件或点击新增' + }, + detailTabs: [ + { name: 'detail', label: '明细', componentKey: 'DetailPanel' } + ], + detailSections: [ + { + title: '基础信息', + columnCount: 1, + fieldKeys: ['id', 'warehouse_id', 'name', 'barcode', 'status', 'remark'] + }, + { + title: '时间信息', + columnCount: 2, + fieldKeys: ['created_at', 'updated_at'] + } + ], + api: { + list: workbenchList, + detail: workbenchDetail, + parseListResponse(res) { + const data = res?.data || res + return { + list: (data as any)?.list ?? [], + total: Number((data as any)?.pagination?.total ?? (data as any)?.total ?? 0) + } + }, + buildListParams({ pagination, conditions, sort }) { + return { + pagination: { page: pagination.page, pageSize: pagination.pageSize }, + where: buildWhereConditions(conditions), + ...(sort?.prop ? { sortField: sort.prop, sortOrder: sort.order === 'ascending' ? 'ASC' : 'DESC' } : {}) + } + } + }, + operationButtons: [ + { + key: 'viewDetail', + label: '详情', + actionType: 'action', + type: 'primary' + }, + { + key: 'edit', + label: '编辑', + actionType: 'action', + type: 'primary' + }, + { + key: 'bindCamera', + label: '摄像头', + actionType: 'action', + type: 'success' + }, + { + key: 'delete', + label: '删除', + actionType: 'action', + type: 'danger', + confirmMessage: '确定要删除该工作台吗?删除后数据不可恢复。', + confirmTitle: '删除确认', + confirmType: 'warning', + confirmButtonText: '确定' + } + ] + } +] + +// ============================================================ +// 十三、向后兼容导出 +// ============================================================ +export const templateTabs = tabPages.map((t) => ({ name: t.name, label: t.label, scanBoxCacheKey: t.scanBoxCacheKey })) diff --git a/src/views/system/setting/workbench2/index.vue b/src/views/system/setting/workbench2/index.vue new file mode 100644 index 00000000..8576e9c2 --- /dev/null +++ b/src/views/system/setting/workbench2/index.vue @@ -0,0 +1,1174 @@ + + + + + + diff --git a/src/views/system/setting/workbench2/pages/ExampleFormDialog.vue b/src/views/system/setting/workbench2/pages/ExampleFormDialog.vue new file mode 100644 index 00000000..945481b8 --- /dev/null +++ b/src/views/system/setting/workbench2/pages/ExampleFormDialog.vue @@ -0,0 +1,107 @@ + + + + + + diff --git a/src/views/video/newcamara/components/ColumnCellRenderer.vue b/src/views/video/newcamara/components/ColumnCellRenderer.vue index 8aa6b3a8..74e640bf 100644 --- a/src/views/video/newcamara/components/ColumnCellRenderer.vue +++ b/src/views/video/newcamara/components/ColumnCellRenderer.vue @@ -23,8 +23,8 @@ diff --git a/src/views/video/newcamaraserver/components/TabArea.vue b/src/views/video/newcamaraserver/components/TabArea.vue new file mode 100644 index 00000000..288ec6f1 --- /dev/null +++ b/src/views/video/newcamaraserver/components/TabArea.vue @@ -0,0 +1,132 @@ + + + + + diff --git a/src/views/video/newcamaraserver/config/camaraserver-config.ts b/src/views/video/newcamaraserver/config/camaraserver-config.ts new file mode 100644 index 00000000..b4b45f21 --- /dev/null +++ b/src/views/video/newcamaraserver/config/camaraserver-config.ts @@ -0,0 +1,703 @@ +/** + * 【录像服务器管理】配置文件 — 基于 newcamara 页面模板 v2 架构 + * + * ===== 核心设计 ===== + * 1. FIELD_DICT — 全局字段预设表,每个字段拥有唯一翻译(label)和完整元数据 + * 2. VALUE_MAPS — 值翻译映射表(select options 和 tag 翻译共用) + * 3. TAG_RESOLVERS — 标签颜色解析器(集中管理 tag 颜色逻辑) + * 4. 各标签页通过 key 引用所需字段(scanBoxFieldKeys / tableColumnKeys) + * 5. resolveTabConfig() — 加载时将 key 列表展开为完整配置 + */ + +import type { Component } from 'vue' +import DetailPanel from './components/DetailPanel.vue' +import LogPanel from './components/LogPanel.vue' +import ServerFormDialog from '../pages/ServerFormDialog.vue' + +// ============================================================ +// 〇、全局页面配置 +// ============================================================ +export const PAGE_CONFIG = { + /** 是否显示顶部多标签栏 */ + showTabArea: false, + /** 单页模式:不显示标签栏,仅一个标签页内容 */ + singlePage: true, + /** 是否启用详情面板(底部分栏 + 显示/隐藏详情按钮),false 时表格占满全高 */ + enableDetailPanel: false +} + +// ============================================================ +// 〇-A、组件注册表 — 所有可复用组件在此注册 +// ============================================================ +export const COMPONENT_REGISTRY: Record = { + DetailPanel, + LogPanel, + ServerFormDialog +} + +// ============================================================ +// 〇-B、SCANBOX_GROUPS — ScanBox 分组名称 +// ============================================================ +export const SCANBOX_GROUPS = { + basic: '基础信息', + status: '状态筛选' +} as const + +// ============================================================ +// 一、FIELD_DICT — 全局字段预设表(唯一真相来源) +// ============================================================ +export interface FieldDefinition { + key: string + label: string + scanBox: { + type: 'text' | 'select' | 'daterange' | 'number' + group?: string + options?: { label: string; value: any }[] + placeholder?: string + operators?: string[] + defaultOperator?: string + } | null + table: { + minWidth?: number + width?: number + fixed?: 'left' | 'right' | boolean + align?: 'left' | 'center' | 'right' + sortable?: boolean + showOverflowTooltip?: boolean + copyAction?: 'copy' | 'copyQr' + copyValue?: (row: any) => any + } | null + slot: { + type: 'tag' | 'text' | 'default' | 'operation' + tagType?: string | Record + tagResolver?: string + translateField?: string + format?: 'datetime' + } | null + detailLabel?: string + filterParamMap?: Record +} + +// ============================================================ +// VALUE_MAPS — 值翻译映射(select options 和 tag 翻译共用) +// ============================================================ +export const VALUE_MAPS: Record> = { + serverStatus: { '1': '启用', '0': '禁用', '启用': '启用', '禁用': '禁用' } +} + +/** 从 VALUE_MAPS 衍生 options(优先取中文值作为 option value) */ +export function getOptions(field: string): { label: string; value: string }[] { + const map = VALUE_MAPS[field] + if (!map) return [] + const seen = new Set() + const opts: { label: string; value: string }[] = [] + const chineseKeys: [string, string][] = [] + const otherKeys: [string, string][] = [] + for (const [v, l] of Object.entries(map)) { + if (/^[\u4e00-\u9fa5]/.test(v)) { + chineseKeys.push([v, l]) + } else { + otherKeys.push([v, l]) + } + } + for (const [v, l] of [...chineseKeys, ...otherKeys]) { + if (!seen.has(l)) { + seen.add(l) + opts.push({ label: l, value: v }) + } + } + return opts +} + +/** 翻译 value → label */ +export function translate(field: string, value: any): string { + const map = VALUE_MAPS[field] + if (!map) return String(value ?? '—') + return map[String(value)] ?? String(value ?? '—') +} + +/** 格式化时间戳为 YYYY-MM-DD HH:mm:ss */ +export function formatTime(value: any): string { + if (!value) return '—' + try { + const d = new Date(value) + if (isNaN(d.getTime())) return String(value) + const pad = (n: number) => String(n).padStart(2, '0') + return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}` + } catch { + return String(value) + } +} + +// ============================================================ +// TAG_RESOLVERS — 标签颜色解析器 +// ============================================================ +export const TAG_RESOLVERS: Record string> = { + resolveServerStatusTag(v) { + if (v === 1 || v === '1' || v === '启用') return 'success' + return 'info' + } +} + +// ============================================================ +// 二、FIELD_DICT 实例 — 录像服务器页面字段 +// ============================================================ +export const FIELD_DICT: Record = { + /** 关键词搜索(虚拟字段,仅用于 ScanBox) */ + quickWhere: { + key: 'quickWhere', + label: '关键词', + scanBox: { type: 'text', group: SCANBOX_GROUPS.basic, placeholder: '服务器名称/IP', operators: ['contains'], defaultOperator: 'contains' }, + table: null, + slot: null, + detailLabel: '关键词' + }, + id: { + key: 'id', + label: 'ID', + scanBox: null, + table: { width: 80, sortable: true }, + slot: null, + detailLabel: 'ID' + }, + name: { + key: 'name', + label: '服务器名称', + scanBox: { type: 'text', group: SCANBOX_GROUPS.basic, placeholder: '请输入名称', operators: ['contains'], defaultOperator: 'contains' }, + table: { minWidth: 160, showOverflowTooltip: true }, + slot: null, + detailLabel: '服务器名称' + }, + brand: { + key: 'brand', + label: '品牌', + scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: getOptions('brand') }, + table: { width: 120, align: 'center' }, + slot: { type: 'tag', tagResolver: 'resolveBrandTag', translateField: 'brand' }, + detailLabel: '品牌' + }, + public_ip: { + key: 'public_ip', + label: '公网IP', + scanBox: null, + table: { width: 150, showOverflowTooltip: true }, + slot: null, + detailLabel: '公网IP' + }, + internal_ip: { + key: 'internal_ip', + label: '内网IP', + scanBox: null, + table: { width: 150, showOverflowTooltip: true }, + slot: null, + detailLabel: '内网IP' + }, + port: { + key: 'port', + label: '端口', + scanBox: null, + table: { width: 80, align: 'center' }, + slot: null, + detailLabel: '端口' + }, + username: { + key: 'username', + label: '用户名', + scanBox: null, + table: { width: 120 }, + slot: null, + detailLabel: '用户名' + }, + status: { + key: 'status', + label: '状态', + scanBox: { type: 'select', group: SCANBOX_GROUPS.status, options: getOptions('serverStatus') }, + table: { width: 90, align: 'center' }, + slot: { type: 'tag', tagResolver: 'resolveServerStatusTag', translateField: 'serverStatus' }, + detailLabel: '状态', + filterParamMap: { '启用': '1', '禁用': '0' } + }, + remark: { + key: 'remark', + label: '备注', + scanBox: null, + table: { minWidth: 160, showOverflowTooltip: true }, + slot: null, + detailLabel: '备注' + }, + connectivity: { + key: 'connectivity', + label: '连通', + scanBox: null, + table: { width: 110, align: 'center' }, + slot: { type: 'default' }, + detailLabel: '连通状态' + }, + created_at: { + key: 'created_at', + label: '创建时间', + scanBox: null, + table: { minWidth: 170, sortable: true }, + slot: { type: 'text', format: 'datetime' }, + detailLabel: '创建时间' + }, + updated_at: { + key: 'updated_at', + label: '更新时间', + scanBox: null, + table: { minWidth: 170, sortable: true }, + slot: { type: 'text', format: 'datetime' }, + detailLabel: '更新时间' + }, + /** 操作列(虚拟字段,仅用于表格列渲染) */ + operation: { + key: 'operation', + label: '操作', + scanBox: null, + table: { width: 150, fixed: 'right', align: 'center' }, + slot: { type: 'operation' } + } +} + +// ============================================================ +// 三、ColumnSlotConfig — 列单元格渲染配置 +// ============================================================ +export interface ColumnSlotConfig { + type: 'tag' | 'text' | 'default' | 'operation' + tagType?: string | Record + tagResolver?: string + translateField?: string + format?: 'datetime' +} + +// ============================================================ +// 三-A、OperationButtonConfig — 操作列按钮配置 +// ============================================================ +export interface OperationButtonConfig { + key: string + label: string + type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | '' + actionType: 'form' | 'action' + formKey?: string + formTitle?: string + formWidth?: string + paramMap?: Record + extraParams?: Record + disabledOnField?: string + confirmMessage?: string + confirmTitle?: string + confirmType?: 'warning' | 'danger' | 'info' + confirmButtonText?: string +} + +// ============================================================ +// 四、DetailFieldConfig / DetailSectionConfig — 明细面板配置 +// ============================================================ +export interface DetailFieldConfig { + key: string + label?: string + span?: number + renderType?: 'text' | 'tag' | 'pre' + tagType?: string | Record + tagResolver?: string + translateField?: string +} + +export interface DetailSectionConfig { + title: string + columnCount: number + fields: DetailFieldConfig[] +} + +export interface DetailTabConfig { + name: string + label: string + componentKey: string + component?: Component +} + +// ============================================================ +// 五、TabPageApiConfig — 标签页接口插槽配置 +// ============================================================ +export type ApiMethod = (...args: any[]) => Promise +export type ApiSource = 'api' | 'list' +export type ComponentApiConfig = { source: 'list' } | ApiMethod + +export interface TabPageApiConfig { + /** 列表查询接口 */ + list: ApiMethod + /** 明细面板接口(可选,不配则用 row 数据) */ + detail?: ComponentApiConfig + /** 操作日志接口(可选) */ + log?: ComponentApiConfig + /** 导出接口(可选) */ + export?: ApiMethod + /** 导出进度查询接口(可选) */ + exportProgress?: ApiMethod + /** ScanBox 下拉选项数据源接口(可选) */ + scanBoxOptions?: Record + /** 工具栏按钮 → API 方法映射(可选) */ + toolbar?: Record + /** 列表响应解析器 */ + parseListResponse?: (res: any) => { list: any[]; total: number } + /** 构建列表请求参数 */ + buildListParams?: (params: { + pagination: { page: number; pageSize: number } + conditions: Record + sort?: { prop: string; order: string } + }) => Record +} + +// ============================================================ +// 六、TabPageRawConfig — 标签页声明配置(仅用 key 引用) +// ============================================================ +export interface TabPageRawConfig { + name: string + label: string + scanBoxCacheKey: string + /** ScanBox 需要的字段 key 列表(从 FIELD_DICT 中查找) */ + scanBoxFieldKeys: string[] + /** 表格需要的列 key 列表(从 FIELD_DICT 中查找) */ + tableColumnKeys: string[] + upperTableDefaults: { + title: string + enableColumnConfig?: boolean + showIndex?: boolean + showSelection?: boolean + emptyText?: string + } + /** 明细面板标签页配置 */ + detailTabs?: { name: string; label: string; componentKey: string }[] + /** 明细面板分区配置(字段 key 列表,resolveTabConfig 展开) */ + detailSections: { + title: string + columnCount: number + fieldKeys: string[] + }[] + /** 接口配置(有 api 时启用真实接口) */ + api?: TabPageApiConfig + /** 操作列按钮配置(需 tableColumnKeys 包含 'operation') */ + operationButtons?: OperationButtonConfig[] +} + +// ============================================================ +// 七、TabPageConfig — 展开后的完整配置(给 index.vue 使用) +// ============================================================ +export interface TabPageConfig { + name: string + label: string + scanBoxCacheKey: string + scanBoxFields: Record[] + upperTable: { + title: string + enableColumnConfig: boolean + showIndex: boolean + showSelection: boolean + emptyText: string + columns: Record[] + } + columnSlots: Record + detailConfig: DetailSectionConfig[] + detailTabs: DetailTabConfig[] + api?: TabPageApiConfig + operationButtons?: OperationButtonConfig[] +} + +// ============================================================ +// 八、resolveTabConfig — 加载时将 RawConfig 展开为完整配置 +// ============================================================ +export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig { + // 展开 ScanBox 字段 + const scanBoxFields: Record[] = [] + for (const key of raw.scanBoxFieldKeys) { + const def = FIELD_DICT[key] + if (!def || !def.scanBox) continue + scanBoxFields.push({ + label: def.label, + value: def.key, + type: def.scanBox.type, + options: def.scanBox.options ? [...def.scanBox.options] : undefined, + group: def.scanBox.group, + placeholder: def.scanBox.placeholder, + operators: def.scanBox.operators, + defaultOperator: def.scanBox.defaultOperator, + required: (def.scanBox as any).required + }) + } + + // 展开表格列 + const columns: Record[] = [] + for (const key of raw.tableColumnKeys) { + const def = FIELD_DICT[key] + if (!def || !def.table) continue + columns.push({ + prop: def.key, + label: def.label, + ...def.table + }) + } + + // 展开列插槽 + const columnSlots: Record = {} + for (const key of raw.tableColumnKeys) { + const def = FIELD_DICT[key] + if (!def || !def.slot) continue + columnSlots[def.key] = { ...def.slot } + } + + // 展开明细面板配置 + const detailConfig: DetailSectionConfig[] = raw.detailSections.map((sec) => ({ + title: sec.title, + columnCount: sec.columnCount, + fields: sec.fieldKeys + .map((key): DetailFieldConfig | null => { + const def = FIELD_DICT[key] + if (!def) return null + return { + key: def.key, + label: def.detailLabel ?? def.label, + translateField: def.slot?.translateField, + tagResolver: def.slot?.tagResolver, + tagType: def.slot?.tagType, + renderType: def.slot?.type === 'tag' ? 'tag' : 'text' + } + }) + .filter((f): f is DetailFieldConfig => f !== null) + })) + + // 展开明细标签页(解析 componentKey → Component) + const detailTabs: DetailTabConfig[] = raw.detailTabs + ? raw.detailTabs.map((tab) => ({ + name: tab.name, + label: tab.label, + componentKey: tab.componentKey, + component: COMPONENT_REGISTRY[tab.componentKey] + })) + : [{ name: 'detail', label: '明细', componentKey: 'DetailPanel', component: COMPONENT_REGISTRY['DetailPanel'] }] + + return { + name: raw.name, + label: raw.label, + scanBoxCacheKey: raw.scanBoxCacheKey, + scanBoxFields, + upperTable: { + title: raw.upperTableDefaults.title, + enableColumnConfig: raw.upperTableDefaults.enableColumnConfig ?? true, + showIndex: raw.upperTableDefaults.showIndex ?? true, + showSelection: raw.upperTableDefaults.showSelection ?? false, + emptyText: raw.upperTableDefaults.emptyText ?? '暂无录像服务器数据', + columns + }, + columnSlots, + detailConfig, + detailTabs, + api: raw.api, + operationButtons: raw.operationButtons + } +} + +// ============================================================ +// 九、buildWhereConditions — 将 ScanBox 条件转为 API where 参数 +// ============================================================ +export function buildWhereConditions(rawConditions: Record): Record { + const where: Record = {} + for (const [key, cond] of Object.entries(rawConditions || {})) { + let value: any = undefined + if (cond && typeof cond === 'object' && 'operator' in cond) { + value = (cond as any).value + } else if (cond !== undefined && cond !== null && cond !== '') { + value = Array.isArray(cond) ? cond[0] ?? '' : cond + } + if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) { + continue + } + + // quickWhere 特殊处理 + if (key === 'quickWhere') { + where.quickWhere = String(value) + continue + } + + const def = FIELD_DICT[key] + if (def?.filterParamMap) { + const mapped = def.filterParamMap[String(value)] + if (mapped !== undefined) { + where[key] = mapped + continue + } + } + where[key] = value + } + return where +} + +// ============================================================ +// 十、工具栏按钮系统 +// ============================================================ +export interface ToolbarButtonConfig { + key: string + label: string + category: 'common' | 'function' | 'basic' + size?: '' | 'default' | 'small' | 'large' + type?: '' | 'primary' | 'success' | 'warning' | 'info' | 'danger' + plain?: boolean + loadingKey?: string + disabledKey?: string + action: string + dynamicLabelKey?: string + onlyForTabs?: string[] + buttonType?: 'default' | 'dropdown' + dropdownOptions?: Array<{ label: string; action: string; divided?: boolean }> + formKey?: string +} + +/** ★ 录像服务器工具栏按钮 */ +export const TOOLBAR_BUTTONS: Record = { + // ===== 公共按钮 ===== + refresh: { + key: 'refresh', + label: '刷新', + category: 'common', + type: 'primary', + size: 'small', + loadingKey: 'loading', + action: 'loadData' + }, + // ===== 功能按钮 ===== + addServer: { + key: 'addServer', + label: '新增录像服务器', + category: 'function', + type: 'success', + size: 'small', + action: 'openAddServerDialog', + formKey: 'ServerFormDialog' + }, + // ===== 基础操作 ===== + columnConfig: { + key: 'columnConfig', + label: '字段设置', + category: 'basic', + size: 'small', + action: 'openColumnConfigPanel' + } +} + +/** 按标签页名称获取工具栏按钮列表(自动根据 PAGE_CONFIG 过滤) */ +export function getTabToolbarButtons(tabName: string): ToolbarButtonConfig[] { + return Object.values(TOOLBAR_BUTTONS).filter((btn) => { + if (btn.onlyForTabs && !btn.onlyForTabs.includes(tabName)) return false + return true + }) +} + +// ============================================================ +// 十一、批量操作配置(录像服务器暂无需批量操作) +// ============================================================ +export interface BatchOperationConfig { + action: string + title: string + confirmText: string + confirmType?: 'warning' | 'error' | 'info' | 'success' + confirmButtonText: string + successText: string + failText: string + apiMethod: (...args: any[]) => Promise + payloadKey?: string + idField?: string | string[] + payloadBuilder?: (rows: Record[]) => Record + useProgress?: boolean + progressApiMethod?: (...args: any[]) => Promise +} + +export const BATCH_OPERATION_CONFIGS: Record = {} + +// ============================================================ +// 十二、标签页注册表 — 录像服务器管理 +// ============================================================ +import { list, create, update, del } from '@/api/camera_server/camera_server' + +export const tabPages: TabPageRawConfig[] = [ + { + name: 'server', + label: '录像服务器管理', + scanBoxCacheKey: 'video-camera-server', + scanBoxFieldKeys: ['quickWhere', 'name', 'status'], + tableColumnKeys: [ + 'id', 'name', 'public_ip', + 'internal_ip', 'port', 'username', 'status', + 'remark', 'connectivity', 'created_at', 'updated_at', 'operation' + ], + upperTableDefaults: { + title: '录像服务器列表', + showIndex: true, + showSelection: false, + emptyText: '暂无录像服务器数据,可调整左侧筛选条件' + }, + detailTabs: [ + { name: 'detail', label: '明细', componentKey: 'DetailPanel' } + ], + detailSections: [ + { + title: '基础信息', + columnCount: 3, + fieldKeys: ['id', 'name', 'public_ip', 'internal_ip', 'port', 'username', 'status', 'remark'], + }, + { + title: '时间信息', + columnCount: 2, + fieldKeys: ['created_at', 'updated_at'] + } + ], + api: { + list, + detail: { source: 'list' }, + parseListResponse(res) { + return { + list: res?.list ?? [], + total: Number(res?.pagination?.total ?? res?.total ?? 0) + } + }, + buildListParams({ pagination, conditions }) { + return { + pagination: { page: pagination.page, pageSize: pagination.pageSize }, + where: buildWhereConditions(conditions) + } + }, + toolbar: { delete: del, create, update } + }, + operationButtons: [ + { + key: 'edit', + label: '编辑', + actionType: 'action', + type: 'primary' + }, + { + key: 'delete', + label: '删除', + actionType: 'action', + type: 'danger', + confirmTitle: '提示', + confirmMessage: '确认删除该录像服务器吗?删除后关联的摄像头将不可用', + confirmType: 'warning', + confirmButtonText: '确认删除' + }, + { + key: 'testConnection', + label: '连通测试', + actionType: 'action', + type: 'warning' + } + ] + } +] + +// ============================================================ +// 十三、向后兼容导出 +// ============================================================ +export const templateTabs = tabPages.map((t) => ({ + name: t.name, + label: t.label, + scanBoxCacheKey: t.scanBoxCacheKey +})) diff --git a/src/views/video/newcamaraserver/config/components/DetailPanel.vue b/src/views/video/newcamaraserver/config/components/DetailPanel.vue new file mode 100644 index 00000000..5117cc77 --- /dev/null +++ b/src/views/video/newcamaraserver/config/components/DetailPanel.vue @@ -0,0 +1,159 @@ + + + + + + diff --git a/src/views/video/newcamaraserver/config/components/LogPanel.vue b/src/views/video/newcamaraserver/config/components/LogPanel.vue new file mode 100644 index 00000000..0adae9f3 --- /dev/null +++ b/src/views/video/newcamaraserver/config/components/LogPanel.vue @@ -0,0 +1,227 @@ + + + + + + diff --git a/src/views/video/newcamaraserver/index.vue b/src/views/video/newcamaraserver/index.vue new file mode 100644 index 00000000..63845caf --- /dev/null +++ b/src/views/video/newcamaraserver/index.vue @@ -0,0 +1,555 @@ + + + + + + diff --git a/src/views/video/newcamaraserver/pages/ExampleFormDialog.vue b/src/views/video/newcamaraserver/pages/ExampleFormDialog.vue new file mode 100644 index 00000000..eb39d0d9 --- /dev/null +++ b/src/views/video/newcamaraserver/pages/ExampleFormDialog.vue @@ -0,0 +1,107 @@ + + + + + + diff --git a/src/views/video/newcamaraserver/pages/ServerFormDialog.vue b/src/views/video/newcamaraserver/pages/ServerFormDialog.vue new file mode 100644 index 00000000..412ac8fc --- /dev/null +++ b/src/views/video/newcamaraserver/pages/ServerFormDialog.vue @@ -0,0 +1,221 @@ + + + + + +