liufumingren 401d1aa3df feat(系统设置): 新增微信小程序配置页(标签页 + 独立页)
- 接口:setting.warehouse.getweChatApp 拉取已授权小程序配置
- 接口:wechat.getAuthUrl 获取微信授权链接(点击按钮后在新小窗打开)
- 未授权(data 为 null)时提示需要授权,授权完成自动轮询刷新
- 新增「微信小程序」标签页与 system/setting/miniprogram 独立页路由(备用)
2026-09-21 18:26:00 +08:00

1673 lines
56 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 【页面模板】配置文件 v2 — 基于 waveOrder2 架构设计
*
* ===== 核心设计 =====
*
* 1. FIELD_DICT — 全局字段预设表,每个字段拥有唯一翻译(label)和完整元数据
* 2. VALUE_MAPS — 值翻译映射表(select options 和 tag 翻译共用)
* 3. TAG_RESOLVERS — 标签颜色解析器(集中管理 tag 颜色逻辑)
* 4. 各标签页通过 key 引用所需字段(scanBoxFieldKeys / tableColumnKeys)
* 5. resolveTabConfig() — 加载时将 key 列表展开为完整配置
*
* ===== 快速上手 =====
* 1. 复制整个 views/mode/ 文件夹,重命名为你的页面名
* 2. 在 FIELD_DICT 中添加你需要的字段定义
* 3. 在 tabPages 中配置标签页(引用 FIELD_DICT 的 key)
* 4. 在 TabPageApiConfig 中接入真实接口
* 5. 在 router/map.ts 中添加路由
*/
import { ref, isRef, computed, type Component, type Ref } from 'vue'
import DetailPanel from './components/DetailPanel.vue'
import LogPanel from './components/LogPanel.vue'
import WarehouseSettingsForm from '../pages/WarehouseSettingsForm.vue'
import FrontConfigForm from '../pages/FrontConfigForm.vue'
import MiniProgramConfigForm from '../pages/MiniProgramConfigForm.vue'
import ApiAppFormDialog from '../pages/ApiAppFormDialog.vue'
import DeliveryPlanFormDialog from '../pages/DeliveryPlanFormDialog.vue'
import DefinitionFormDialog from '../pages/DefinitionFormDialog.vue'
import DeliveryPlanCopyDialog from '../pages/DeliveryPlanCopyDialog.vue'
import { apiAppList } from '@/api/apiapp/apiapp'
import {
listDeliveryPlan,
listDeliveryLog,
listReportDefinition,
reportDefinitionTypeList,
type ReportDefinitionTypeField,
type ReportDefinitionTypeItem
} from '@/api/report/report'
import { loadStores } from '@/api/index/index'
// ============================================================
// 〇、全局页面配置
// ============================================================
export const PAGE_CONFIG = {
/** 是否显示顶部多标签栏 */
showTabArea: true,
/** 单页模式:不显示标签栏,仅一个标签页内容 */
singlePage: false,
/** 是否启用详情面板(底部分栏 + 显示/隐藏详情按钮),false 时表格占满全高 */
enableDetailPanel: true
}
// ============================================================
// 〇-A、组件注册表 — 所有可复用组件在此注册
// ============================================================
export const COMPONENT_REGISTRY: Record<string, Component> = {
DetailPanel,
LogPanel,
WarehouseSettingsForm,
FrontConfigForm,
MiniProgramConfigForm,
ApiAppFormDialog,
DeliveryPlanFormDialog,
DeliveryPlanCopyDialog,
DefinitionFormDialog
}
// ============================================================
// 〇-A1、货主选项数据源(对齐 storage/receiving:index.loadStores)
// ============================================================
/** 货主下拉选项(value 为货主ID),ScanBox 与表单共用 */
export const storeOptions = ref<{ value: number; label: string }[]>([])
/**
* 将 loadStores / ScanBox 等处的货主项归一化为下拉可用的 { value, label }。
* 兼容 { value, label }、{ id, store_remask }、{ store_id, store_name } 等形态。
*/
export function normalizeStoreOptionsForSelect(stores: any[]): { value: number; label: string }[] {
if (!Array.isArray(stores)) return []
const out: { value: number; label: string }[] = []
for (const s of stores) {
const rawVal = s?.value ?? s?.id ?? s?.store_id
if (rawVal === undefined || rawVal === null || rawVal === '') continue
const num = typeof rawVal === 'number' ? rawVal : Number(rawVal)
const value = Number.isFinite(num) ? num : (rawVal as number)
const label =
(s?.label != null && String(s.label).trim() !== '' && String(s.label)) ||
(s?.store_remask != null && String(s.store_remask)) ||
(s?.name != null && String(s.name)) ||
(s?.store_name != null && String(s.store_name)) ||
String(value)
out.push({ value: value as number, label })
}
return out
}
/** 加载货主下拉选项(已加载则复用) */
export async function loadStoreOptions() {
if (storeOptions.value.length) return storeOptions.value
try {
const res: any = await loadStores()
if (res && res.code === 200) {
const raw = res.stores ?? res.data?.stores ?? []
storeOptions.value = normalizeStoreOptionsForSelect(raw)
}
} catch (e) {
console.error('加载货主列表失败', e)
}
return storeOptions.value
}
// ============================================================
// 〇-A2、报表类型注册清单(report.definition.typeList)
// ============================================================
/** 报表类型注册清单缓存(type key → 类型描述) */
export const reportTypeList = ref<ReportDefinitionTypeItem[]>([])
let reportTypeLoading = false
let reportTypePromise: Promise<ReportDefinitionTypeItem[]> | null = null
/** 加载报表类型注册清单(并发去重;失败回退空数组) */
export async function loadReportTypeList(force = false): Promise<ReportDefinitionTypeItem[]> {
if (reportTypeList.value.length && !force) return reportTypeList.value
if (reportTypeLoading && reportTypePromise) return reportTypePromise
reportTypeLoading = true
reportTypePromise = (async () => {
try {
const res: any = await reportDefinitionTypeList()
const list: ReportDefinitionTypeItem[] = Array.isArray(res?.list)
? res.list
: (Array.isArray(res?.data?.list) ? res.data.list : [])
reportTypeList.value = list
// 填充标题映射,供 translate('reportType', typeKey) 使用
const map: Record<string, string> = {}
for (const item of list) {
map[item.key] = item.title || item.key
}
VALUE_MAPS.reportType = map
return list
} catch (e) {
console.error('加载报表类型注册清单失败', e)
return []
} finally {
reportTypeLoading = false
reportTypePromise = null
}
})()
return reportTypePromise
}
/** 报表类型下拉选项(value=类型 key,label=标题(key)) */
export const reportTypeOptions = computed<{ value: string; label: string }[]>(() =>
reportTypeList.value.map((t) => ({
value: t.key,
label: t.title ? `${t.title}(${t.key})` : t.key
}))
)
/** 取指定类型的注册字段清单 */
export function getReportTypeFields(typeKey: string): ReportDefinitionTypeField[] {
return reportTypeList.value.find((t) => t.key === typeKey)?.fields ?? []
}
/** 取指定类型的注册信息(title/description/window,来自 report.definition.typeList) */
export function getReportTypeInfo(typeKey: string): ReportDefinitionTypeItem | null {
return reportTypeList.value.find((t) => t.key === typeKey) ?? null
}
/** 报表类型 key → 标题(未加载时回退空串) */
export function reportTypeTitle(typeKey: string): string {
return reportTypeList.value.find((t) => t.key === typeKey)?.title ?? ''
}
// ============================================================
// 〇-A3、报表定义选项(report.definition.list,投递计划下拉关联用)
// ============================================================
/** 可投递的报表定义选项(value=报表定义ID,label=报表名称(类型标题)) */
export const reportDefinitionOptions = ref<{ value: number; label: string }[]>([])
/** 报表定义 ID → 名称(全量非软删,用于投递计划列表/详情展示关联报表名) */
export const reportDefinitionNameMap = ref<Record<number, string>>({})
/** 报表定义 ID → 类型 key(如 stockFlow / interceptOrder;供导出弹窗按类型做数据日期限制等) */
export const reportDefinitionTypeMap = ref<Record<number, string>>({})
let reportDefinitionLoading = false
/** 报表定义缓存是否已失效(报表定义新增/编辑/删除后置位,下次读取时再拉一次,避免当次多发请求) */
let reportDefinitionCacheStale = false
/** 标记报表定义缓存失效:不立即发请求,下次读取(打开使用下拉的弹窗)时重新调用 report.definition.list */
export function invalidateReportDefinitions() {
reportDefinitionCacheStale = true
}
/** 加载报表定义(force 强制刷新):下拉选项仅取启用项,名称映射取全量非软删 */
export async function loadReportDefinitions(force = false): Promise<{ value: number; label: string }[]> {
// 缓存失效标记与 force 等效:命中任一时重新拉取
if (reportDefinitionOptions.value.length && !force && !reportDefinitionCacheStale) {
return reportDefinitionOptions.value
}
if (reportDefinitionLoading) return reportDefinitionOptions.value
reportDefinitionLoading = true
try {
// 先确保类型标题就绪(选项文案里带类型标题)
await loadReportTypeList()
const res: any = await listReportDefinition({
pagination: { page: 1, pageSize: 200 }
})
const list: any[] = res?.data?.list ?? res?.list ?? []
// 全量名称/类型映射(列表/详情展示、导出弹窗类型判断用,含停用报表)
const nameMap: Record<number, string> = {}
const typeMap: Record<number, string> = {}
for (const d of list) {
const id = Number(d?.id)
if (id > 0) {
nameMap[id] = d?.name ? String(d.name) : `报表 #${id}`
typeMap[id] = d?.type ? String(d.type) : ''
}
}
reportDefinitionNameMap.value = nameMap
reportDefinitionTypeMap.value = typeMap
// 下拉选项仅取启用项
reportDefinitionOptions.value = list
.filter((d: any) => d && Number(d.id) > 0 && Number(d.is_enabled) === 1)
.map((d: any) => ({
value: Number(d.id),
label: d.name ? `${d.name}(${reportTypeTitle(d.type) || d.type})` : `报表 #${d.id}`
}))
} catch (e) {
console.error('加载报表定义选项失败', e)
reportDefinitionOptions.value = []
reportDefinitionNameMap.value = {}
reportDefinitionTypeMap.value = {}
} finally {
reportDefinitionLoading = false
// 无论成功或失败都清掉失效标记(失败时 options 已清空,天然会触发下次重新拉取)
reportDefinitionCacheStale = false
}
return reportDefinitionOptions.value
}
// ============================================================
// 〇-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 }[] | Ref<{ 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' | 'pre'
tagType?: string | Record<string, string>
tagResolver?: string
translateField?: string
format?: 'datetime'
} | null
detailLabel?: string
filterParamMap?: Record<string, string>
}
// ============================================================
// VALUE_MAPS — 值翻译映射(select options 和 tag 翻译共用)
// ============================================================
export const VALUE_MAPS: Record<string, Record<string, string>> = {
status: { 'pending': '待处理', 'processing': '处理中', 'done': '已完成', '待处理': '待处理', '处理中': '处理中', '已完成': '已完成' },
type: { 'A': '类型A', 'B': '类型B', 'C': '类型C', '类型A': '类型A', '类型B': '类型B', '类型C': '类型C' },
bool: { '1': '是', '0': '否', '是': '是', '否': '否' },
/** API 应用启用状态 */
enabled: { '1': '启用', '0': '停用', '启用': '启用', '停用': '停用' },
/** 报表投递渠道 */
channel: { 'wecom': '企业微信', 'inbox': '站内信', 'link': '链接' },
/** 报表投递记录状态 */
deliveryStatus: { 'pending': '待投递', 'exporting': '导出中', 'delivered': '已投递', 'failed': '投递失败', 'cancelled': '已取消' },
/** 报表导出任务状态 */
taskStatus: { 'submitted': '已提交', 'running': '执行中', 'success': '已完成', 'failed': '失败', 'not_found': '未找到' },
/** 报表适用维度(report.meta.scope) */
scope: { 'warehouse': '仓库', 'store': '货主', 'open': '通用' },
/** 报表定义类型标题(report.definition.typeList,运行时填充) */
reportType: {}
}
/** 从 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<string>()
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 — 标签颜色解析器
// ============================================================
// 颜色规则:未xx=info(灰) 已xx=success(绿) xx中/部分xx=warning(黄) 错误=danger(红)
export const TAG_RESOLVERS: Record<string, (val: any) => string> = {
resolveStatusTag(v) {
if (!v) return 'info'
if (v === '已完成' || v === 'done') return 'success'
if (v === '处理中' || v === 'processing') return 'warning'
return 'info'
},
resolveBoolTag(v) {
if (v === undefined || v === null) return 'info'
if (v === '是' || v === true || v === 1 || v === '1') return 'success'
return 'info'
},
resolveEnabledTag(v) {
if (v === 1 || v === '1' || v === true) return 'success'
return 'info'
},
resolveChannelTag(v) {
const map: Record<string, string> = { wecom: 'primary', inbox: 'success', link: 'warning' }
return map[String(v)] || 'info'
},
resolveDeliveryStatusTag(v) {
const map: Record<string, string> = { delivered: 'success', failed: 'danger', exporting: 'warning', pending: 'info', cancelled: 'info' }
return map[String(v)] || 'info'
},
resolveTaskStatusTag(v) {
const map: Record<string, string> = { success: 'success', failed: 'danger', not_found: 'danger', running: 'warning', submitted: 'info' }
return map[String(v)] || 'info'
},
resolveScopeTag(v) {
const map: Record<string, string> = { warehouse: 'primary', store: 'success', open: 'warning' }
return map[String(v)] || 'info'
}
}
// ============================================================
// 二、FIELD_DICT 实例 — 在此定义页面所需的所有字段
// ============================================================
export const FIELD_DICT: Record<string, FieldDefinition> = {
code: {
key: 'code',
label: '编号',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: { minWidth: 160, fixed: 'left', copyAction: 'copy', showOverflowTooltip: true },
slot: null,
detailLabel: '编号'
},
name: {
key: 'name',
label: '报表名称',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: { minWidth: 150, showOverflowTooltip: true },
slot: null,
detailLabel: '报表名称'
},
/** 报表定义类型(注册 key,选项来自 report.definition.typeList) */
type: {
key: 'type',
label: '报表类型',
scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: reportTypeOptions as any },
table: { minWidth: 140, align: 'center' },
slot: { type: 'tag', tagType: 'info', translateField: 'reportType' },
detailLabel: '报表类型'
},
status: {
key: 'status',
label: '投递状态',
scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('deliveryStatus') },
table: { minWidth: 110, align: 'center' },
slot: { type: 'tag', tagResolver: 'resolveDeliveryStatusTag', translateField: 'deliveryStatus' },
detailLabel: '投递状态'
},
count: {
key: 'count',
label: '数量',
scanBox: null,
table: { minWidth: 80, align: 'center', sortable: true },
slot: null
},
amount: {
key: 'amount',
label: '金额(元)',
scanBox: null,
table: { minWidth: 110, align: 'center', sortable: true },
slot: null
},
creator: {
key: 'creator',
label: '创建人',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: { minWidth: 100 },
slot: null,
detailLabel: '创建人'
},
create_time: {
key: 'create_time',
label: '创建时间',
scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time },
table: { minWidth: 170, sortable: true },
slot: { type: 'text', format: 'datetime' },
detailLabel: '创建时间'
},
update_time: {
key: 'update_time',
label: '更新时间',
scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time },
table: { minWidth: 170, sortable: true },
slot: { type: 'text', format: 'datetime' },
detailLabel: '更新时间'
},
/** API应用:应用名称 */
app_name: {
key: 'app_name',
label: '应用名称',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: { minWidth: 160, showOverflowTooltip: true },
slot: null,
detailLabel: '应用名称'
},
/** API应用:AppKey */
self_app_key: {
key: 'self_app_key',
label: 'AppKey',
scanBox: null,
table: { minWidth: 200, copyAction: 'copy', showOverflowTooltip: true },
slot: null,
detailLabel: 'AppKey'
},
/** API应用:AppSecret */
self_app_secret: {
key: 'self_app_secret',
label: 'AppSecret',
scanBox: null,
table: { minWidth: 180, showOverflowTooltip: true },
slot: null,
detailLabel: 'AppSecret'
},
/** API应用:签名方法 */
sign_method: {
key: 'sign_method',
label: '签名方法',
scanBox: null,
table: { minWidth: 100, align: 'center' },
slot: { type: 'tag', tagType: 'info' },
detailLabel: '签名方法'
},
/** API应用:速率限制 */
rate_limit: {
key: 'rate_limit',
label: '速率限制(次/秒)',
scanBox: null,
table: { minWidth: 130, align: 'center' },
slot: null,
detailLabel: '速率限制(次/秒)'
},
/** API应用:启用状态 */
is_enabled: {
key: 'is_enabled',
label: '状态',
scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('enabled') },
table: { minWidth: 90, align: 'center' },
slot: { type: 'tag', tagResolver: 'resolveEnabledTag', translateField: 'enabled' },
detailLabel: '状态'
},
/** 记录ID / API应用ID */
id: {
key: 'id',
label: 'ID',
scanBox: null,
table: { minWidth: 80, align: 'center' },
slot: null,
detailLabel: '应用ID'
},
/** API应用:接口类型 */
interface_type_id: {
key: 'interface_type_id',
label: '接口类型',
scanBox: null,
table: { minWidth: 100, align: 'center' },
slot: null,
detailLabel: '接口类型'
},
/** API应用:仓库ID */
warehouse_id: {
key: 'warehouse_id',
label: '仓库ID',
scanBox: null,
table: { minWidth: 100, align: 'center' },
slot: null,
detailLabel: '仓库ID'
},
/** API应用:IP白名单 */
self_ip_whitelist: {
key: 'self_ip_whitelist',
label: 'IP白名单',
scanBox: null,
table: { minWidth: 160, showOverflowTooltip: true },
slot: { type: 'pre' },
detailLabel: 'IP白名单'
},
/** API应用:更新时间 */
updated_at: {
key: 'updated_at',
label: '更新时间',
scanBox: null,
table: { minWidth: 170, sortable: true },
slot: { type: 'text', format: 'datetime' },
detailLabel: '更新时间'
},
/** API应用:回调URL */
callback_url: {
key: 'callback_url',
label: '回调URL',
scanBox: null,
table: { minWidth: 200, showOverflowTooltip: true },
slot: null,
detailLabel: '回调URL'
},
/** API应用:创建时间 */
created_at: {
key: 'created_at',
label: '创建时间',
scanBox: null,
table: { minWidth: 170, sortable: true },
slot: { type: 'text', format: 'datetime' },
detailLabel: '创建时间'
},
/** 货主(下拉选择,选项来自 index.loadStores,value 为货主ID) */
store_id: {
key: 'store_id',
label: '货主',
scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: storeOptions as any },
table: { minWidth: 100, align: 'center', sortable: true },
slot: null,
detailLabel: '货主'
},
/** 货主名称(列表/详情展示,来自 deliveryPlan.list 的 store_name) */
store_name: {
key: 'store_name',
label: '货主',
scanBox: null,
table: { minWidth: 120, showOverflowTooltip: true },
slot: null,
detailLabel: '货主'
},
/** 报表编码 */
report_code: {
key: 'report_code',
label: '报表编码',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: { minWidth: 140, copyAction: 'copy', showOverflowTooltip: true },
slot: null,
detailLabel: '报表编码'
},
/** 报表定义:导出文件名模板(支持 {date} 占位) */
file_name: {
key: 'file_name',
label: '导出文件名',
scanBox: null,
table: { minWidth: 180, showOverflowTooltip: true },
slot: null,
detailLabel: '导出文件名'
},
/** 投递计划筛选:关联的报表定义ID(下拉选项来自 report.definition.list 启用项) */
report_id: {
key: 'report_id',
label: '报表',
scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: reportDefinitionOptions as any },
table: null,
slot: null,
detailLabel: '报表'
},
/** 投递计划:关联的报表定义ID(详情展示) */
report_definition_id: {
key: 'report_definition_id',
label: '报表定义ID',
scanBox: null,
table: null,
slot: null,
detailLabel: '报表定义ID'
},
/** 投递计划:关联报表名称(列表/详情展示,前端由 report_definition_id 关联填充) */
report_name: {
key: 'report_name',
label: '报表',
scanBox: null,
table: { minWidth: 180, showOverflowTooltip: true },
slot: null,
detailLabel: '报表'
},
/** 每日投递时间点(HH:mm 数组) */
schedule_times: {
key: 'schedule_times',
label: '投递时间',
scanBox: null,
table: { minWidth: 180, showOverflowTooltip: true },
slot: null,
detailLabel: '投递时间'
},
/** 投递渠道 */
channel: {
key: 'channel',
label: '投递渠道',
scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('channel') },
table: { minWidth: 100, align: 'center' },
slot: { type: 'tag', tagResolver: 'resolveChannelTag', translateField: 'channel' },
detailLabel: '投递渠道'
},
/** 启用状态 */
enabled: {
key: 'enabled',
label: '启用状态',
scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('enabled') },
table: { minWidth: 100, align: 'center' },
slot: { type: 'tag', tagResolver: 'resolveEnabledTag', translateField: 'enabled' },
detailLabel: '启用状态'
},
/** 补投宽限分钟 */
late_grace_minutes: {
key: 'late_grace_minutes',
label: '补投宽限(分)',
scanBox: null,
table: { minWidth: 120, align: 'center' },
slot: null,
detailLabel: '补投宽限(分)'
},
/** 备注 */
remark: {
key: 'remark',
label: '备注',
scanBox: null,
table: { minWidth: 150, showOverflowTooltip: true },
slot: null,
detailLabel: '备注'
},
/** 文本通知模板 */
notify_template: {
key: 'notify_template',
label: '通知模板',
scanBox: null,
table: { minWidth: 200, showOverflowTooltip: true },
slot: null,
detailLabel: '通知模板'
},
/** 通知群ID数组 */
notify_group_ids: {
key: 'notify_group_ids',
label: '通知群',
scanBox: null,
table: { minWidth: 120, showOverflowTooltip: true },
slot: { type: 'pre' },
detailLabel: '通知群'
},
/** 通知成员ID数组 */
notify_member_ids: {
key: 'notify_member_ids',
label: '通知成员',
scanBox: null,
table: { minWidth: 140, showOverflowTooltip: true },
slot: { type: 'pre' },
detailLabel: '通知成员'
},
/** 投递目标快照 */
notify_targets: {
key: 'notify_targets',
label: '投递目标快照',
scanBox: null,
table: null,
slot: { type: 'pre' },
detailLabel: '投递目标快照'
},
/** 数据日期 */
biz_date: {
key: 'biz_date',
label: '数据日期',
scanBox: null,
table: { minWidth: 120, align: 'center', sortable: true },
slot: null,
detailLabel: '数据日期'
},
/** 投递时间点(report.deliveryLog.time_point) */
time_point: {
key: 'time_point',
label: '投递时间点',
scanBox: null,
table: { minWidth: 100, align: 'center' },
slot: null,
detailLabel: '投递时间点'
},
/** 投递文件链接(report.deliveryLog.file_url) */
file_url: {
key: 'file_url',
label: '文件链接',
scanBox: null,
table: { minWidth: 220, showOverflowTooltip: true, copyAction: 'copy' },
slot: null,
detailLabel: '文件链接'
},
/** 重试次数(report.deliveryLog.retry_count) */
retry_count: {
key: 'retry_count',
label: '重试次数',
scanBox: null,
table: { minWidth: 90, align: 'center' },
slot: null,
detailLabel: '重试次数'
},
/** 下次重试时间(report.deliveryLog.next_retry_at) */
next_retry_at: {
key: 'next_retry_at',
label: '下次重试时间',
scanBox: null,
table: { minWidth: 170 },
slot: { type: 'text', format: 'datetime' },
detailLabel: '下次重试时间'
},
/** 错误信息(report.deliveryLog.error_message) */
error_message: {
key: 'error_message',
label: '错误信息',
scanBox: null,
table: { minWidth: 220, showOverflowTooltip: true },
slot: null,
detailLabel: '错误信息'
},
/** 投递完成时间(report.deliveryLog.delivered_at) */
delivered_at: {
key: 'delivered_at',
label: '投递完成时间',
scanBox: null,
table: { minWidth: 170, sortable: true },
slot: { type: 'text', format: 'datetime' },
detailLabel: '投递完成时间'
},
/** 报表描述(report.definition.description) */
description: {
key: 'description',
label: '报表描述',
scanBox: null,
table: { minWidth: 200, showOverflowTooltip: true },
slot: null,
detailLabel: '报表描述'
},
/** 输出配置(report.definition.output_config) */
output_config: {
key: 'output_config',
label: '输出配置',
scanBox: null,
table: null,
slot: { type: 'pre' },
detailLabel: '输出配置'
},
/** 数据源配置(report.definition.source_config) */
source_config: {
key: 'source_config',
label: '数据源配置',
scanBox: null,
table: null,
slot: { type: 'pre' },
detailLabel: '数据源配置'
},
/** 工作表配置(report.definition.sheet_config) */
sheet_config: {
key: 'sheet_config',
label: '工作表配置',
scanBox: null,
table: null,
slot: { type: 'pre' },
detailLabel: '工作表配置'
},
/** 适用维度(report.meta.scope / report.definition.scope) */
scope: {
key: 'scope',
label: '适用维度',
scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: getOptions('scope') },
table: { minWidth: 100, align: 'center' },
slot: { type: 'tag', tagResolver: 'resolveScopeTag', translateField: 'scope' },
detailLabel: '适用维度'
},
/** 查询器 key(report.meta.query) */
query: {
key: 'query',
label: '查询器',
scanBox: null,
table: { minWidth: 120, showOverflowTooltip: true },
slot: null,
detailLabel: '查询器'
},
/** 窗口数量(report.meta.window.dayCount) */
day_count: {
key: 'day_count',
label: '窗口天数',
scanBox: null,
table: { minWidth: 100, align: 'center' },
slot: null,
detailLabel: '窗口天数'
},
/** 切点小时(report.meta.window.cutoverHour) */
cutover_hour: {
key: 'cutover_hour',
label: '切点小时',
scanBox: null,
table: { minWidth: 100, align: 'center' },
slot: null,
detailLabel: '切点小时'
},
/** 查询器静态字段清单(report.meta.fields)/ 报表定义勾选字段 key 数组 */
fields: {
key: 'fields',
label: '字段清单',
scanBox: null,
table: { minWidth: 240, showOverflowTooltip: true },
slot: { type: 'pre' },
detailLabel: '字段清单'
},
/** 操作列(虚拟字段,仅用于表格列渲染) */
operation: {
key: 'operation',
label: '操作',
scanBox: null,
table: { minWidth: 180, fixed: 'right', align: 'center' },
slot: { type: 'operation' }
}
}
// ============================================================
// 三、ColumnSlotConfig — 列单元格渲染配置
// ============================================================
export interface ColumnSlotConfig {
type: 'tag' | 'text' | 'default' | 'operation' | 'pre'
tagType?: string | Record<string, string>
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<string, string>
extraParams?: Record<string, any>
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<string, string>
tagResolver?: string
translateField?: string
format?: 'datetime'
}
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<any>
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<string, ApiMethod>
/** 工具栏按钮 → API 方法映射(可选) */
toolbar?: Record<string, ApiMethod>
/** 列表响应解析器 */
parseListResponse?: (res: any) => { list: any[]; total: number }
/** 构建列表请求参数 */
buildListParams?: (params: {
pagination: { page: number; pageSize: number }
conditions: Record<string, any>
sort?: { prop: string; order: string }
}) => Record<string, any>
}
// ============================================================
// 六、TabPageRawConfig — 标签页声明配置(仅用 key 引用)
// ============================================================
export interface TabPageRawConfig {
name: string
label: string
scanBoxCacheKey: string
/** 本标签页字段 label 覆盖(key=字段 key,覆盖 FIELD_DICT 的 label/detailLabel;如计划页 name 显示为「计划名称」) */
labelOverrides?: Record<string, 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[]
}[]
/** 视图类型:list=scan-box+upper-table 列表(默认);form=表单页(渲染 formPage) */
viewType?: 'list' | 'form'
/** 表单页组件(viewType='form' 时渲染,替换列表结构,不使用 scan-box/upper-table/明细) */
formPage?: Component
/** 接口配置(有 api 时启用真实接口) */
api?: TabPageApiConfig
/** 操作列按钮配置(需 tableColumnKeys 包含 'operation') */
operationButtons?: OperationButtonConfig[]
}
// ============================================================
// 七、TabPageConfig — 展开后的完整配置(给 index.vue 使用)
// ============================================================
export interface TabPageConfig {
name: string
label: string
scanBoxCacheKey: string
scanBoxFields: Record<string, any>[]
upperTable: {
title: string
enableColumnConfig: boolean
showIndex: boolean
showSelection: boolean
emptyText: string
columns: Record<string, any>[]
}
columnSlots: Record<string, ColumnSlotConfig>
detailConfig: DetailSectionConfig[]
detailTabs: DetailTabConfig[]
viewType: 'list' | 'form'
formPage?: Component
api?: TabPageApiConfig
operationButtons?: OperationButtonConfig[]
}
// ============================================================
// 八、resolveTabConfig — 加载时将 RawConfig 展开为完整配置
// ============================================================
export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig {
// 展开 ScanBox 字段
const scanBoxFields: Record<string, any>[] = []
for (const key of raw.scanBoxFieldKeys) {
const def = FIELD_DICT[key]
if (!def || !def.scanBox) continue
scanBoxFields.push({
label: raw.labelOverrides?.[def.key] ?? def.label,
value: def.key,
type: def.scanBox.type,
options: def.scanBox.options
? (isRef(def.scanBox.options) ? def.scanBox.options.value : [...def.scanBox.options])
: undefined,
group: def.scanBox.group,
required: (def.scanBox as any).required
})
}
// 展开表格列
const columns: Record<string, any>[] = []
for (const key of raw.tableColumnKeys) {
const def = FIELD_DICT[key]
if (!def || !def.table) continue
columns.push({
prop: def.key,
label: raw.labelOverrides?.[def.key] ?? def.label,
...def.table
})
}
// 展开列插槽
const columnSlots: Record<string, ColumnSlotConfig> = {}
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: raw.labelOverrides?.[def.key] ?? def.detailLabel ?? def.label,
translateField: def.slot?.translateField,
tagResolver: def.slot?.tagResolver,
tagType: def.slot?.tagType,
renderType: def.slot?.type === 'tag' ? 'tag' : def.slot?.type === 'pre' ? 'pre' : 'text',
format: def.slot?.format
}
})
.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,
viewType: raw.viewType ?? 'list',
formPage: raw.formPage,
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<string, any>): Record<string, any> {
const where: Record<string, any> = {}
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
}
// ============================================================
// 十、工具栏按钮系统
// ============================================================
// 按钮分为三类:
// common — 公共按钮(刷新、导出)
// function — 功能按钮(打开表单/确认窗口)
// basic — 基础操作(字段设置、隐藏详情)
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<string, ToolbarButtonConfig> = {
// ===== 公共按钮 =====
refresh: {
key: 'refresh',
label: '刷新',
category: 'common',
type: 'primary',
size: 'small',
loadingKey: 'loading',
action: 'loadData'
},
export: {
key: 'export',
label: '导出',
category: 'common',
size: 'small',
loadingKey: 'exportLoading',
action: 'handleExport',
buttonType: 'dropdown',
dropdownOptions: [
{ label: '不含明细', action: 'handleExport' },
{ label: '含明细', action: 'handleExportItem', divided: true }
]
},
// ===== 基础操作 =====
columnConfig: {
key: 'columnConfig',
label: '字段设置',
category: 'basic',
size: 'small',
action: 'openColumnConfigPanel'
},
toggleDetail: {
key: 'toggleDetail',
label: '显示详情',
category: 'basic',
dynamicLabelKey: 'detailToggleLabel',
size: 'small',
action: 'toggleDetailVisible'
},
// ===== 本页功能按钮 =====
/** 创建 API 应用(仅 API开放接口标签页) */
createApiApp: {
key: 'createApiApp',
label: '创建应用',
category: 'function',
type: 'primary',
size: 'small',
action: 'openCreateApiApp',
onlyForTabs: ['apiOpen']
},
/** 新增投递计划(仅投递计划标签页) */
createPlan: {
key: 'createPlan',
label: '新增计划',
category: 'function',
type: 'primary',
size: 'small',
action: 'openCreatePlan',
onlyForTabs: ['plan']
},
/** 新增报表定义(仅报表定义标签页) */
createDefinition: {
key: 'createDefinition',
label: '新增定义',
category: 'function',
type: 'primary',
size: 'small',
action: 'openCreateDefinition',
onlyForTabs: ['definition']
}
// ★ 在此添加功能按钮(如批量操作)★
}
/** 按标签页名称获取工具栏按钮列表(自动根据 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
})
}
// ============================================================
// 十一、批量操作配置(可选,接入 BatchOperationForm 时使用)
// ============================================================
export interface BatchOperationConfig {
action: string
title: string
confirmText: string
confirmType?: 'warning' | 'error' | 'info' | 'success'
confirmButtonText: string
successText: string
failText: string
apiMethod: (...args: any[]) => Promise<any>
payloadKey?: string
idField?: string | string[]
payloadBuilder?: (rows: Record<string, any>[]) => Record<string, any>
useProgress?: boolean
progressApiMethod?: (...args: any[]) => Promise<any>
}
/** ★ 在此配置批量操作 */
export const BATCH_OPERATION_CONFIGS: Record<string, BatchOperationConfig> = {
// batchExample: {
// action: 'batchExample',
// title: '批量操作示例',
// confirmText: '确定对选中的 {count} 项执行操作吗?',
// confirmType: 'warning',
// confirmButtonText: '确认操作',
// successText: '批量操作成功',
// failText: '批量操作失败',
// apiMethod: yourBatchApi,
// payloadKey: 'ids',
// idField: 'id'
// }
}
// ============================================================
// 十二、标签页注册表 — 在此定义你的页面标签页
// ============================================================
export const tabPages: TabPageRawConfig[] = [
// ===== 标签页一:基础设置(表单项页面,不使用 scan-box / upper-table / 明细) =====
{
name: 'form',
label: '基础设置',
viewType: 'form',
formPage: WarehouseSettingsForm,
scanBoxCacheKey: 'basic-settings-form',
scanBoxFieldKeys: [],
tableColumnKeys: [],
upperTableDefaults: {
title: '',
showSelection: false
},
detailSections: []
},
// ===== 前端独立部署(品牌配置 + 自持域名&证书,独立表单项页) =====
{
name: 'frontConfig',
label: '前端独立部署',
viewType: 'form',
formPage: FrontConfigForm,
scanBoxCacheKey: 'basic-settings-frontconfig',
scanBoxFieldKeys: [],
tableColumnKeys: [],
upperTableDefaults: {
title: '',
showSelection: false
},
detailSections: []
},
// ===== 标签页二:API开放接口(scan-box + upper-table 列表) =====
{
name: 'apiOpen',
label: 'API开放接口',
scanBoxCacheKey: 'basic-settings-apiopen',
scanBoxFieldKeys: ['app_name', 'is_enabled'],
tableColumnKeys: ['app_name', 'self_app_key', 'self_app_secret', 'sign_method', 'rate_limit', 'is_enabled', 'created_at', 'operation'],
upperTableDefaults: {
title: 'API 应用列表',
showSelection: false,
emptyText: '暂无 API 应用数据'
},
detailTabs: [
{ name: 'detail', label: '应用详情', componentKey: 'DetailPanel' }
],
detailSections: [
{
title: '应用信息',
columnCount: 3,
fieldKeys: ['id', 'app_name', 'self_app_key', 'self_app_secret', 'sign_method', 'rate_limit', 'is_enabled']
},
{
title: '归属信息',
columnCount: 2,
fieldKeys: ['interface_type_id', 'warehouse_id']
},
{
title: '网络配置',
columnCount: 2,
fieldKeys: ['callback_url', 'self_ip_whitelist']
},
{
title: '时间信息',
columnCount: 2,
fieldKeys: ['created_at', 'updated_at']
}
],
api: {
list: apiAppList,
detail: { source: 'list' },
parseListResponse(res) {
return { list: res?.list ?? res?.data?.list ?? [], total: res?.pagination?.total ?? res?.data?.pagination?.total ?? 0 }
},
buildListParams({ pagination, conditions }) {
return {
page: pagination.page,
pageSize: pagination.pageSize,
app_name: conditions?.app_name || undefined,
is_enabled: conditions?.is_enabled
}
}
},
operationButtons: [
{
key: 'editApiApp',
label: '编辑',
actionType: 'form',
type: 'warning',
formKey: 'ApiAppFormDialog',
paramMap: {
id: 'id',
app_name: 'app_name',
rate_limit: 'rate_limit',
callback_url: 'callback_url',
self_ip_whitelist: 'self_ip_whitelist',
is_enabled: 'is_enabled'
}
},
{
key: 'regenerateSecret',
label: '重置密钥',
actionType: 'action',
type: 'warning',
confirmMessage: '确定要重新生成该应用的 AppSecret 吗?旧密钥将立即失效!',
confirmTitle: '重置密钥确认',
confirmType: 'warning',
confirmButtonText: '确定重置'
},
{
key: 'deleteApiApp',
label: '停用',
actionType: 'action',
type: 'danger',
confirmMessage: '确定要停用该应用吗?停用后其 API 密钥将立即失效。',
confirmTitle: '停用确认',
confirmType: 'warning',
confirmButtonText: '确定停用'
}
]
},
// ===== 标签页三:报表投递计划 =====
{
name: 'plan',
label: '投递计划',
scanBoxCacheKey: 'basic-settings-plan',
scanBoxFieldKeys: ['store_id', 'report_id', 'enabled'],
labelOverrides: { name: '计划名称' },
tableColumnKeys: ['name', 'store_name', 'report_name', 'schedule_times', 'channel', 'enabled', 'late_grace_minutes', 'notify_group_ids', 'notify_member_ids', 'remark', 'created_at', 'updated_at', 'operation'],
upperTableDefaults: {
title: '报表投递计划',
showSelection: false
},
detailTabs: [
{ name: 'detail', label: '计划详情', componentKey: 'DetailPanel' }
],
detailSections: [
{
title: '基础信息',
columnCount: 3,
fieldKeys: ['store_name', 'name', 'report_name', 'report_definition_id', 'schedule_times', 'channel', 'enabled', 'late_grace_minutes', 'remark']
},
{
title: '通知配置',
columnCount: 3,
fieldKeys: ['notify_template', 'notify_group_ids', 'notify_member_ids']
},
{
title: '时间信息',
columnCount: 2,
fieldKeys: ['created_at', 'updated_at']
}
],
api: {
list: listDeliveryPlan,
detail: { source: 'list' },
parseListResponse(res) {
const list: any[] = res?.data?.list ?? res?.list ?? []
// 后端不返回报表名称,按 report_definition_id 关联填充(停用/软删报表回退显示 id)
const enriched = list.map((row) => {
const id = Number(row?.report_definition_id)
if (!(id > 0)) return row
return { ...row, report_name: reportDefinitionNameMap.value[id] || `报表 #${id}` }
})
return { list: enriched, total: res?.data?.total ?? res?.total ?? 0 }
},
buildListParams({ pagination, conditions, sort }) {
return {
where: buildWhereConditions(conditions),
pagination: { page: pagination.page, pageSize: pagination.pageSize },
...(sort?.prop ? { sort: { sortField: sort.prop, sortOrder: sort.order === 'ascending' ? 'ASC' : 'DESC' } } : {})
}
}
},
operationButtons: [
{
key: 'editPlan',
label: '编辑',
actionType: 'form',
type: 'warning',
formKey: 'DeliveryPlanFormDialog',
paramMap: {
store_id: 'store_id',
name: 'name',
report_definition_id: 'report_definition_id',
schedule_times: 'schedule_times',
late_grace_minutes: 'late_grace_minutes',
remark: 'remark',
notify_template: 'notify_template',
notify_group_ids: 'notify_group_ids',
notify_member_ids: 'notify_member_ids'
}
},
{
key: 'copyPlan',
label: '复制',
actionType: 'form',
type: 'primary',
formKey: 'DeliveryPlanCopyDialog',
paramMap: {
id: 'id',
name: 'name',
store_id: 'store_id',
report_name: 'report_name'
}
},
{
key: 'viewDetail',
label: '查看详情',
actionType: 'action',
type: 'primary'
}
]
},
// ===== 标签页四:报表投递记录 =====
{
name: 'log',
label: '投递记录',
scanBoxCacheKey: 'basic-settings-log',
scanBoxFieldKeys: ['store_id', 'report_code', 'status'],
tableColumnKeys: ['id', 'store_id', 'report_code', 'biz_date', 'time_point', 'status', 'channel', 'retry_count', 'file_url', 'error_message', 'delivered_at', 'created_at', 'operation'],
upperTableDefaults: {
title: '报表投递记录',
showSelection: false
},
detailTabs: [
{ name: 'detail', label: '记录详情', componentKey: 'DetailPanel' }
],
detailSections: [
{
title: '投递信息',
columnCount: 3,
fieldKeys: ['id', 'store_id', 'report_code', 'biz_date', 'time_point', 'status', 'channel', 'retry_count', 'delivered_at', 'created_at']
},
{
title: '文件与错误',
columnCount: 1,
fieldKeys: ['file_url', 'error_message']
},
{
title: '投递目标快照',
columnCount: 1,
fieldKeys: ['notify_targets']
}
],
api: {
list: listDeliveryLog,
detail: { source: 'list' },
parseListResponse(res) {
return { list: res?.data?.list ?? res?.list ?? [], total: res?.data?.total ?? res?.total ?? 0 }
},
buildListParams({ pagination, conditions, sort }) {
return {
where: buildWhereConditions(conditions),
pagination: { page: pagination.page, pageSize: pagination.pageSize },
...(sort?.prop ? { sort: { sortField: sort.prop, sortOrder: sort.order === 'ascending' ? 'ASC' : 'DESC' } } : {})
}
}
},
operationButtons: [
{
key: 'viewDetail',
label: '查看详情',
actionType: 'action',
type: 'primary'
}
]
},
// ===== 标签页五:报表定义(wms_report_definition 管理,report.definition.*) =====
{
name: 'definition',
label: '报表定义',
scanBoxCacheKey: 'basic-settings-definition',
scanBoxFieldKeys: ['name', 'type', 'is_enabled'],
tableColumnKeys: ['id', 'name', 'type', 'file_name', 'fields', 'is_enabled', 'remark', 'updated_at', 'operation'],
upperTableDefaults: {
title: '报表定义',
showSelection: false
},
detailTabs: [
{ name: 'detail', label: '定义详情', componentKey: 'DetailPanel' }
],
detailSections: [
{
title: '基本信息',
columnCount: 3,
fieldKeys: ['id', 'name', 'type', 'file_name', 'is_enabled', 'remark']
},
{
title: '配置信息',
columnCount: 1,
fieldKeys: ['fields']
},
{
title: '时间信息',
columnCount: 2,
fieldKeys: ['created_at', 'updated_at']
}
],
api: {
list: listReportDefinition,
detail: { source: 'list' },
parseListResponse(res) {
return { list: res?.data?.list ?? res?.list ?? [], total: res?.data?.total ?? res?.total ?? 0 }
},
buildListParams({ pagination, conditions, sort }) {
return {
where: buildWhereConditions(conditions),
pagination: { page: pagination.page, pageSize: pagination.pageSize },
...(sort?.prop ? { sort: { sortField: sort.prop, sortOrder: sort.order === 'ascending' ? 'ASC' : 'DESC' } } : {})
}
}
},
operationButtons: [
{
key: 'editDefinition',
label: '编辑',
actionType: 'form',
type: 'warning',
formKey: 'DefinitionFormDialog',
paramMap: {
id: 'id',
name: 'name',
type: 'type',
file_name: 'file_name',
fields: 'fields',
is_enabled: 'is_enabled',
remark: 'remark'
}
},
{
key: 'deleteDefinition',
label: '删除',
actionType: 'action',
type: 'danger',
confirmMessage: '删除后该报表定义将不可用(软删除,可恢复)。确定删除?',
confirmTitle: '删除报表定义',
confirmButtonText: '删除'
}
]
},
// ===== 标签页六:微信小程序配置(备用,表单项页面;独立页入口见 views/system/setting/miniprogram/index.vue) =====
{
name: 'miniProgram',
label: '微信小程序',
viewType: 'form',
formPage: MiniProgramConfigForm,
scanBoxCacheKey: 'basic-settings-miniprogram',
scanBoxFieldKeys: [],
tableColumnKeys: [],
upperTableDefaults: {
title: '',
showSelection: false
},
detailSections: []
}
]
// ============================================================
// 十三、向后兼容导出
// ============================================================
export const templateTabs = tabPages.map((t) => ({ name: t.name, label: t.label, scanBoxCacheKey: t.scanBoxCacheKey }))