diff --git a/dist.tar.gz b/dist.tar.gz index 32be704e..f14ab0fb 100644 Binary files a/dist.tar.gz and b/dist.tar.gz differ diff --git a/src/api/camera_server/camera_server.ts b/src/api/camera_server/camera_server.ts index 1beacb36..c7bb0b7b 100644 --- a/src/api/camera_server/camera_server.ts +++ b/src/api/camera_server/camera_server.ts @@ -40,7 +40,9 @@ export function create(data: { name: string brand?: string public_ip?: string + public_port?: number internal_ip?: string + internal_port?: number port?: number username?: string password?: string @@ -66,7 +68,9 @@ export function update(data: { name?: string brand?: string public_ip?: string + public_port?: number internal_ip?: string + internal_port?: number port?: number username?: string password?: string diff --git a/src/api/camera_server/localServerApi.ts b/src/api/camera_server/localServerApi.ts index 2b8b3744..a5aa25ff 100644 --- a/src/api/camera_server/localServerApi.ts +++ b/src/api/camera_server/localServerApi.ts @@ -109,9 +109,11 @@ export function getLiveStreamUrl(params: { pass: string channel: number streamType?: number + port?: number }): string { - const { ip, user, pass, channel, streamType = 1 } = params - return `${DEFAULT_PROXY_BASE}/api/hikvision/live-stream?ip=${encodeURIComponent(ip)}&user=${encodeURIComponent(user)}&pass=${encodeURIComponent(pass)}&channel=${channel}&streamType=${streamType}` + const { ip, user, pass, channel, streamType = 1, port } = params + const portParam = port ? `&port=${port}` : '' + return `${DEFAULT_PROXY_BASE}/api/hikvision/live-stream?ip=${encodeURIComponent(ip)}&user=${encodeURIComponent(user)}&pass=${encodeURIComponent(pass)}&channel=${channel}&streamType=${streamType}${portParam}` } // ---------- 后续在此追加其他 API ---------- diff --git a/src/lang/zh-CN.ts b/src/lang/zh-CN.ts index de4067b3..c49d95be 100644 --- a/src/lang/zh-CN.ts +++ b/src/lang/zh-CN.ts @@ -73,6 +73,10 @@ export default { 'StoreReport':'门店报告', 'workbench':'工作台', // 'OwnerReceiving':'仓库收货单', + 'WmsCameraServer':'录像服务器', + '':'', + '':'', + '':'', }, "login": { "title": "登录", diff --git a/src/router/map.ts b/src/router/map.ts index 823d0bb7..0567c12a 100644 --- a/src/router/map.ts +++ b/src/router/map.ts @@ -64,5 +64,5 @@ export const componentMap: Record = { '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/camera/index': () => import('@/views/video/camera/index.vue'), + 'video/camera/index': () => import('@/views/video/newcamara/index.vue'), }; \ No newline at end of file diff --git a/src/views/mode/config/template-config.ts b/src/views/mode/config/template-config.ts index f1bc4cbd..fba881a9 100644 --- a/src/views/mode/config/template-config.ts +++ b/src/views/mode/config/template-config.ts @@ -28,7 +28,9 @@ export const PAGE_CONFIG = { /** 是否显示顶部多标签栏 */ showTabArea: true, /** 单页模式:不显示标签栏,仅一个标签页内容 */ - singlePage: false + singlePage: false, + /** 是否启用详情面板(底部分栏 + 显示/隐藏详情按钮),false 时表格占满全高 */ + enableDetailPanel: true } // ============================================================ @@ -576,10 +578,12 @@ export const TOOLBAR_BUTTONS: Record = { // ★ 在此添加功能按钮(如批量操作)★ } -/** 按标签页名称获取工具栏按钮列表 */ +/** 按标签页名称获取工具栏按钮列表(自动根据 PAGE_CONFIG 过滤) */ 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 }) } diff --git a/src/views/mode/index.vue b/src/views/mode/index.vue index b6752b39..8461f22f 100644 --- a/src/views/mode/index.vue +++ b/src/views/mode/index.vue @@ -75,7 +75,8 @@ - + + + + + + @@ -508,12 +562,14 @@ const handleSelectionChange = (rows: Record[]) => { // ============================================================ // 明细面板 // ============================================================ -const detailVisible = ref(true) +const detailVisible = ref(PAGE_CONFIG.enableDetailPanel) const selectedRow = ref | null>(null) const selectedDetail = ref | null>(null) const activeDetailTab = ref('detail') const handleRowClick = async (row: Record) => { + if (!PAGE_CONFIG.enableDetailPanel) return + const cfg = currentTabConfig.value if (!cfg) return selectedRow.value = row @@ -697,6 +753,13 @@ onMounted(() => { overflow: hidden; } +/* 详情面板禁用时,表格占满全高 */ +.upper-wrapper--full { + flex: 1 1 auto; + min-height: 0; + overflow: hidden; +} + .pane-resizer { flex-shrink: 0; height: 5px; diff --git a/src/views/order/orderManagement/styles/order-sub.scss b/src/views/order/orderManagement/styles/order-sub.scss index 75ee5f47..049b25cc 100644 --- a/src/views/order/orderManagement/styles/order-sub.scss +++ b/src/views/order/orderManagement/styles/order-sub.scss @@ -116,6 +116,13 @@ overflow: hidden; } + /* 详情面板禁用时,表格占满全高 */ + .upper-wrapper--full { + flex: 1 1 auto; + min-height: 0; + overflow: hidden; + } + .upper-wrapper :deep(.upper-table-container) { height: 100%; display: flex; diff --git a/src/views/order/waveOrder2/config/waveorder-config.ts b/src/views/order/waveOrder2/config/waveorder-config.ts index 660947d1..22f36598 100644 --- a/src/views/order/waveOrder2/config/waveorder-config.ts +++ b/src/views/order/waveOrder2/config/waveorder-config.ts @@ -1180,7 +1180,7 @@ export const waveOrder2TabPages: TabPageRawConfig[] = [ // ============================================================ // 十、向后兼容导出 // ============================================================ -export const WAVEORDER2_PAGE_CONFIG = { showTabArea: true, singlePage: false } +export const WAVEORDER2_PAGE_CONFIG = { showTabArea: true, singlePage: false, enableDetailPanel: true } export const waveOrder2Tabs = waveOrder2TabPages.map((t) => ({ name: t.name, label: t.label, scanBoxCacheKey: t.scanBoxCacheKey @@ -1369,10 +1369,12 @@ export const WAVEORDER2_TOOLBAR_BUTTONS: Record { if (btn.onlyForTabs && !btn.onlyForTabs.includes(tabName)) return false + // 详情面板禁用时,隐藏「显示/隐藏详情」按钮 + if (!WAVEORDER2_PAGE_CONFIG.enableDetailPanel && btn.key === 'toggleDetail') return false return true }) } diff --git a/src/views/order/waveOrder2/index.vue b/src/views/order/waveOrder2/index.vue index 17482723..675f7baa 100644 --- a/src/views/order/waveOrder2/index.vue +++ b/src/views/order/waveOrder2/index.vue @@ -51,6 +51,8 @@ + + + + + + @@ -682,12 +737,14 @@ const handleSelectionChange = (rows: Record[]) => { } // ===== 明细面板 ===== -const detailVisible = ref(true) +const detailVisible = ref(WAVEORDER2_PAGE_CONFIG.enableDetailPanel) const selectedRow = ref | null>(null) const selectedDetail = ref | null>(null) const activeDetailTab = ref('detail') const handleRowClick = async (row: Record) => { + if (!WAVEORDER2_PAGE_CONFIG.enableDetailPanel) return + const cfg = currentTabConfig.value if (!cfg) return selectedRow.value = row diff --git a/src/views/order/waveOrder2/pages/FetchGroupOrderForm.vue b/src/views/order/waveOrder2/pages/FetchGroupOrderForm.vue index 7d42d1c3..113a8fdc 100644 --- a/src/views/order/waveOrder2/pages/FetchGroupOrderForm.vue +++ b/src/views/order/waveOrder2/pages/FetchGroupOrderForm.vue @@ -81,6 +81,7 @@
已选 {{ selectionRows.length }} 个结构
+ 返回订单 ID 列表 @@ -101,7 +102,17 @@ + + + + + + @@ -177,7 +188,8 @@ const filters = reactive({ storeId: undefined as number | string | undefined, sameOrderQuantity: undefined as number | undefined, shopName: '', - includeSku: '' + includeSku: '', + returnOrderIds: false }) const storeOptions = ref>([]) @@ -196,6 +208,43 @@ const pagination = reactive({ /** 判断响应码是否成功 */ const okCode = (code: unknown) => code === 1 || code === 200 || code === 0 +// ============================================================ +// 辅助函数(对齐 waveOrder GroupWaveBatchListPanel) +// ============================================================ + +/** 获取团购单货主文本 */ +function getGroupOrderStoreText(row: any) { + if (Array.isArray(row?.store_ids) && row.store_ids.length > 1) { + return row.store_ids.join(',') + } + return (row?.store_name || row?.store_short_name || row?.store_id) ?? row?.store_ids?.[0] ?? '—' +} + +/** 获取团购单状态汇总 */ +function getGroupOrderStatusSummary(row: any) { + const summary = row?.status_summary || {} + const parts = [ + `配货未开始 ${summary.pick_none ?? 0}`, + `配货完成 ${summary.pick_fin ?? 0}`, + `出库未开始 ${summary.outbound_none ?? 0}`, + `出库完成 ${summary.outbound_fin ?? 0}` + ] + return parts.join(' / ') +} + +/** 获取团购单商品快照文本 */ +function getGroupOrderItemSnapshotText(row: any) { + if (typeof row?.item_detail === 'string' && row.item_detail) { + return row.item_detail + } + if (Array.isArray(row?.item_snapshot) && row.item_snapshot.length) { + return row.item_snapshot + .map((item: any) => `${item.item_name || item.item_code || item.barcode || '未知商品'} x ${item.quantity ?? 0}`) + .join(' | ') + } + return row?.item_detail_machine_snapshot || '—' +} + /** 格式化时间戳 */ function formatTime(value: any): string { if (!value) return '—' @@ -250,7 +299,8 @@ function buildListPayload(): Record { page: pagination.currentPage, pageSize: pagination.pageSize }, - distinguish_express: filters.distinguishExpress + distinguish_express: filters.distinguishExpress, + return_order_ids: filters.returnOrderIds } if (filters.storeId !== undefined && filters.storeId !== null && filters.storeId !== '') { payload.store_id = Number(filters.storeId) @@ -313,6 +363,7 @@ function handleClosed() { function handleFilterChange() { pagination.currentPage = 1 + fetchList() } function resetFilters() { @@ -321,10 +372,10 @@ function resetFilters() { filters.sameOrderQuantity = undefined filters.shopName = '' filters.includeSku = '' + filters.returnOrderIds = false pagination.currentPage = 1 - list.value = [] - pagination.total = 0 selectionRows.value = [] + fetchList() } function handleSelectionChange(rows: any[]) { @@ -441,6 +492,7 @@ watch( (v) => { if (v) { filters.distinguishExpress = true + filters.returnOrderIds = false pagination.currentPage = 1 selectionRows.value = [] loadStoreOptions() @@ -487,4 +539,18 @@ watch( color: #909399; padding: 24px 0; } + +.status-summary-text { + font-size: 12px; + color: #606266; + white-space: normal; + word-break: break-all; +} + +.order-info-text { + font-size: 12px; + color: #606266; + white-space: normal; + word-break: break-all; +} diff --git a/src/views/video/camera/component/CameraPreviewDialog.vue b/src/views/video/camera/component/CameraPreviewDialog.vue index eaa67484..9663dcf7 100644 --- a/src/views/video/camera/component/CameraPreviewDialog.vue +++ b/src/views/video/camera/component/CameraPreviewDialog.vue @@ -70,10 +70,13 @@ const videoImgRef = ref(null) let probeAbort: AbortController | null = null const nvrIp = ref('') +const nvrPort = ref(undefined) const nvrUser = ref('') const nvrPass = ref('') const internalIp = ref('') const publicIp = ref('') +const internalPort = ref(undefined) +const publicPort = ref(undefined) const serverCache = ref>({}) const streamSrc = computed(() => { @@ -84,7 +87,8 @@ const streamSrc = computed(() => { user: nvrUser.value, pass: nvrPass.value, channel: row.channel_id, - streamType: 1 + streamType: 1, + port: nvrPort.value }) }) @@ -112,8 +116,11 @@ async function init() { errorLink.value = false retryHint.value = '' nvrIp.value = '' + nvrPort.value = undefined internalIp.value = '' + internalPort.value = undefined publicIp.value = '' + publicPort.value = undefined const sid = row.server_id if (!sid) { error.value = '未关联录像服务器'; loading.value = false; return } @@ -131,7 +138,9 @@ async function init() { if (!pwd) { error.value = '缺少服务器密码'; loading.value = false; return } internalIp.value = (srv.internal_ip || '').trim() + internalPort.value = srv.internal_port || srv.port publicIp.value = (srv.public_ip || '').trim() + publicPort.value = srv.public_port || srv.port nvrUser.value = srv.username || '' nvrPass.value = pwd @@ -139,6 +148,7 @@ async function init() { if (!ip) { error.value = '服务器未配置 IP'; loading.value = false; return } nvrIp.value = ip + nvrPort.value = internalIp.value ? internalPort.value : publicPort.value streamReady.value = false loading.value = false @@ -178,6 +188,7 @@ async function probeStream() { async function handleProbeFail(reason: 'proxy' | 'nvr') { stopStream() nvrIp.value = '' + nvrPort.value = undefined streamReady.value = false // 本地代理未启动 @@ -191,8 +202,10 @@ async function handleProbeFail(reason: 'proxy' | 'nvr') { if (internalIp.value && nvrIp.value !== publicIp.value && publicIp.value && publicIp.value !== internalIp.value) { retryHint.value = '内网无法访问,正在尝试公网…' nvrIp.value = '' + nvrPort.value = undefined await nextTick() nvrIp.value = publicIp.value + nvrPort.value = publicPort.value streamKey.value++ retryHint.value = '' await nextTick() @@ -231,6 +244,7 @@ function handleClosed() { retryHint.value = '' streamReady.value = false nvrIp.value = '' + nvrPort.value = undefined } watch(() => props.modelValue, (v) => { diff --git a/src/views/video/cameraServer/index.vue b/src/views/video/cameraServer/index.vue index c0f36151..bf4d2cf8 100644 --- a/src/views/video/cameraServer/index.vue +++ b/src/views/video/cameraServer/index.vue @@ -90,13 +90,16 @@ - +
+ + +
- - - - +
+ + +
@@ -140,7 +143,9 @@ type CameraServerRecord = { name?: string brand?: string public_ip?: string + public_port?: number internal_ip?: string + internal_port?: number port?: number username?: string password?: string @@ -233,7 +238,9 @@ const formData = reactive({ name: '', brand: '', public_ip: '', + public_port: undefined as number | undefined, internal_ip: '', + internal_port: undefined as number | undefined, port: undefined as number | undefined, username: '', password: '', @@ -361,7 +368,9 @@ function resetForm() { formData.name = '' formData.brand = '' formData.public_ip = '' + formData.public_port = undefined formData.internal_ip = '' + formData.internal_port = undefined formData.port = undefined formData.username = '' formData.password = '' @@ -384,7 +393,9 @@ function openEdit(row: CameraServerRecord) { formData.name = row.name || '' formData.brand = row.brand || '' formData.public_ip = row.public_ip || '' + formData.public_port = row.public_port formData.internal_ip = row.internal_ip || '' + formData.internal_port = row.internal_port formData.port = row.port formData.username = row.username || '' formData.password = '' @@ -405,7 +416,9 @@ async function submitForm() { name: formData.name.trim(), brand: formData.brand || undefined, public_ip: formData.public_ip.trim() || undefined, + public_port: formData.public_port, internal_ip: formData.internal_ip.trim() || undefined, + internal_port: formData.internal_port, port: formData.port, username: formData.username.trim() || undefined, password: formData.password || undefined, @@ -424,7 +437,9 @@ async function submitForm() { name: formData.name.trim() || undefined, brand: formData.brand || undefined, public_ip: formData.public_ip.trim() || undefined, + public_port: formData.public_port, internal_ip: formData.internal_ip.trim() || undefined, + internal_port: formData.internal_port, port: formData.port, username: formData.username.trim() || undefined, password: formData.password || undefined, @@ -511,11 +526,11 @@ async function handleTestConnection(row: CameraServerRecord) { testLoadingMap.value = { ...testLoadingMap.value, [id]: true } const localBaseUrl = 'http://localhost:17311' - const tryIp = async (label: string, ip: string): Promise => { + const tryIp = async (label: string, ip: string, port?: number): Promise => { try { await testConnection(localBaseUrl, { ip, - port: row.port, + port: port || row.port, user: username, pass: password }) @@ -527,18 +542,18 @@ async function handleTestConnection(row: CameraServerRecord) { } } - // 先尝试内网 IP + // 先尝试内网 IP(使用内网端口,回退到 SDK 端口) if (internalIp) { - const ok = await tryIp('内网IP', internalIp) + const ok = await tryIp('内网IP', internalIp, row.internal_port) if (ok) { testLoadingMap.value = { ...testLoadingMap.value, [id]: false } return } } - // 回退到公网 IP + // 回退到公网 IP(使用公网端口,回退到 SDK 端口) if (publicIp && publicIp !== internalIp) { - const ok = await tryIp('公网IP', publicIp) + const ok = await tryIp('公网IP', publicIp, row.public_port) if (ok) { testLoadingMap.value = { ...testLoadingMap.value, [id]: false } return @@ -591,4 +606,21 @@ onMounted(() => { color: #909399; padding: 24px; } + +/* IP + 端口 左右布局 */ +.ip-port-row { + display: flex; + gap: 8px; + width: 100%; +} + +.ip-input { + flex: 1; + min-width: 0; +} + +.port-input { + width: 130px; + flex-shrink: 0; +} diff --git a/src/views/video/newcamara/components/CameraPreviewDialog.vue b/src/views/video/newcamara/components/CameraPreviewDialog.vue new file mode 100644 index 00000000..4ee306cb --- /dev/null +++ b/src/views/video/newcamara/components/CameraPreviewDialog.vue @@ -0,0 +1,311 @@ + + + + + diff --git a/src/views/video/newcamara/components/ColumnCellRenderer.vue b/src/views/video/newcamara/components/ColumnCellRenderer.vue new file mode 100644 index 00000000..8aa6b3a8 --- /dev/null +++ b/src/views/video/newcamara/components/ColumnCellRenderer.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/src/views/video/newcamara/components/OperationCellRenderer.vue b/src/views/video/newcamara/components/OperationCellRenderer.vue new file mode 100644 index 00000000..a1190233 --- /dev/null +++ b/src/views/video/newcamara/components/OperationCellRenderer.vue @@ -0,0 +1,175 @@ + + + + + + diff --git a/src/views/video/newcamara/components/TabArea.vue b/src/views/video/newcamara/components/TabArea.vue new file mode 100644 index 00000000..288ec6f1 --- /dev/null +++ b/src/views/video/newcamara/components/TabArea.vue @@ -0,0 +1,132 @@ + + + + + diff --git a/src/views/video/newcamara/config/components/DetailPanel.vue b/src/views/video/newcamara/config/components/DetailPanel.vue new file mode 100644 index 00000000..eb992d25 --- /dev/null +++ b/src/views/video/newcamara/config/components/DetailPanel.vue @@ -0,0 +1,159 @@ + + + + + + diff --git a/src/views/video/newcamara/config/components/LogPanel.vue b/src/views/video/newcamara/config/components/LogPanel.vue new file mode 100644 index 00000000..0adae9f3 --- /dev/null +++ b/src/views/video/newcamara/config/components/LogPanel.vue @@ -0,0 +1,227 @@ + + + + + + diff --git a/src/views/video/newcamara/config/template-config.ts b/src/views/video/newcamara/config/template-config.ts new file mode 100644 index 00000000..52f4da8c --- /dev/null +++ b/src/views/video/newcamara/config/template-config.ts @@ -0,0 +1,710 @@ +/** + * 【摄像头管理】配置文件 — 基于页面模板 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 CameraFormDialog from '../pages/CameraFormDialog.vue' + +// ============================================================ +// 〇、全局页面配置 +// ============================================================ +export const PAGE_CONFIG = { + /** 是否显示顶部多标签栏 */ + showTabArea: false, + /** 单页模式:不显示标签栏,仅一个标签页内容 */ + singlePage: true, + /** 是否启用详情面板(底部分栏 + 显示/隐藏详情按钮),false 时表格占满全高 */ + enableDetailPanel: false +} + +// ============================================================ +// 〇-A、组件注册表 — 所有可复用组件在此注册 +// ============================================================ +export const COMPONENT_REGISTRY: Record = { + DetailPanel, + LogPanel, + CameraFormDialog +} + +// ============================================================ +// 〇-B、SCANBOX_GROUPS — ScanBox 分组名称 +// ============================================================ +export const SCANBOX_GROUPS = { + basic: '基础信息', + status: '状态筛选', + time: '时间范围' +} 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> = { + cameraStatus: { '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> = { + resolveCameraStatusTag(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: '通道名称/自定义名称', 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' + }, + server_name: { + key: 'server_name', + label: '所属服务器', + scanBox: null, + table: { minWidth: 150, showOverflowTooltip: true }, + slot: null, + detailLabel: '所属服务器' + }, + channel_id: { + key: 'channel_id', + label: '通道ID', + scanBox: null, + table: { width: 100 }, + slot: null, + detailLabel: '通道ID' + }, + channel_name: { + key: 'channel_name', + label: '通道名称', + scanBox: null, + table: { width: 140, showOverflowTooltip: true }, + slot: null, + detailLabel: '通道名称' + }, + ip: { + key: 'ip', + label: 'IP', + scanBox: null, + table: { width: 140, showOverflowTooltip: true }, + slot: null, + detailLabel: 'IP地址' + }, + model: { + key: 'model', + label: '型号', + scanBox: null, + table: { width: 150, showOverflowTooltip: true }, + slot: null, + detailLabel: '型号' + }, + custom_name: { + key: 'custom_name', + label: '自定义名称', + scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, + table: { minWidth: 160, showOverflowTooltip: true }, + slot: null, + detailLabel: '自定义名称' + }, + status: { + key: 'status', + label: '状态', + scanBox: { type: 'select', group: SCANBOX_GROUPS.status, options: getOptions('cameraStatus') }, + table: { width: 90, align: 'center' }, + slot: { type: 'tag', tagResolver: 'resolveCameraStatusTag', translateField: 'cameraStatus' }, + detailLabel: '状态', + filterParamMap: { '启用': '1', '禁用': '0' } + }, + remark: { + key: 'remark', + label: '备注', + scanBox: null, + table: { minWidth: 160, showOverflowTooltip: true }, + slot: null, + detailLabel: '备注' + }, + created_at: { + key: 'created_at', + label: '创建时间', + scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time }, + table: { minWidth: 170, sortable: true }, + slot: { type: 'text', format: 'datetime' }, + detailLabel: '创建时间' + }, + updated_at: { + key: 'updated_at', + label: '更新时间', + scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time }, + table: { minWidth: 170, sortable: true }, + slot: { type: 'text', format: 'datetime' }, + detailLabel: '更新时间' + }, + /** 操作列(虚拟字段,仅用于表格列渲染) */ + operation: { + key: 'operation', + label: '操作', + scanBox: null, + table: { width: 180, 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' + }, + // ===== 功能按钮 ===== + addCamera: { + key: 'addCamera', + label: '新增摄像头', + category: 'function', + type: 'success', + size: 'small', + action: 'openAddCameraDialog', + formKey: 'CameraFormDialog' + }, + // ===== 基础操作 ===== + columnConfig: { + key: 'columnConfig', + label: '字段设置', + category: 'basic', + size: 'small', + action: 'openColumnConfigPanel' + }, + toggleDetail: { + key: 'toggleDetail', + label: '显示详情', + category: 'basic', + dynamicLabelKey: 'detailToggleLabel', + size: 'small', + action: 'toggleDetailVisible' + } +} + +/** 按标签页名称获取工具栏按钮列表(自动根据 PAGE_CONFIG 过滤) */ +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 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/camera' + +export const tabPages: TabPageRawConfig[] = [ + { + name: 'camera', + label: '摄像头管理', + scanBoxCacheKey: 'video-camera', + scanBoxFieldKeys: ['quickWhere', 'custom_name', 'status', 'created_at'], + tableColumnKeys: [ + 'id', 'server_name', 'channel_id', 'channel_name', + 'ip', 'model', 'custom_name', 'status', 'remark', 'operation' + ], + upperTableDefaults: { + title: '摄像头列表', + showIndex: true, + showSelection: false, + emptyText: '暂无摄像头数据,可调整左侧筛选条件' + }, + detailTabs: [ + { name: 'detail', label: '明细', componentKey: 'DetailPanel' } + ], + detailSections: [ + { + title: '基础信息', + columnCount: 3, + fieldKeys: ['id', 'server_name', 'channel_id', 'channel_name', 'ip', 'model', 'custom_name', 'status', 'remark'] + }, + { + title: '时间信息', + columnCount: 2, + fieldKeys: ['created_at', 'updated_at'] + } + ], + api: { + list, + detail: { source: 'list' }, + parseListResponse(res) { + const rawList = res?.list ?? [] + return { + list: rawList.map((item: any) => ({ + ...item, + server_name: item.server?.name || item.server_name || '--' + })), + 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: 'form', + formKey: 'CameraFormDialog', + type: 'primary' + }, + { + key: 'delete', + label: '删除', + actionType: 'action', + type: 'danger', + confirmTitle: '提示', + confirmMessage: '确认删除该摄像头吗?', + confirmType: 'warning', + confirmButtonText: '确认删除' + }, + { + key: 'preview', + label: '预览', + actionType: 'action', + type: 'success' + } + ] + } +] + +// ============================================================ +// 十三、向后兼容导出 +// ============================================================ +export const templateTabs = tabPages.map((t) => ({ + name: t.name, + label: t.label, + scanBoxCacheKey: t.scanBoxCacheKey +})) diff --git a/src/views/video/newcamara/index.vue b/src/views/video/newcamara/index.vue new file mode 100644 index 00000000..3e87cfa2 --- /dev/null +++ b/src/views/video/newcamara/index.vue @@ -0,0 +1,909 @@ + + + + + + diff --git a/src/views/video/newcamara/pages/CameraFormDialog.vue b/src/views/video/newcamara/pages/CameraFormDialog.vue new file mode 100644 index 00000000..caae98bc --- /dev/null +++ b/src/views/video/newcamara/pages/CameraFormDialog.vue @@ -0,0 +1,449 @@ + + + + diff --git a/src/views/video/newcamara/pages/ExampleFormDialog.vue b/src/views/video/newcamara/pages/ExampleFormDialog.vue new file mode 100644 index 00000000..945481b8 --- /dev/null +++ b/src/views/video/newcamara/pages/ExampleFormDialog.vue @@ -0,0 +1,107 @@ + + + + + +