重构报表配置与投递计划:定义按id+type+fields管理、投递计划关联报表定义、复制到其他货主
- report.definition: save/list/delete/typeList 对接新契约(id upsert、type 注册表、fields 子集、{date} 文件名模板)
- 报表定义表单改为下拉选 type + 勾选 fields(来自 report.definition.typeList)
- 投递计划改按 report_id 关联报表定义,下拉单选、渠道收敛 inbox、新增计划名称与 store_name 展示
- 新增 report.deliveryPlan.copy 复制到其他货主(DeliveryPlanCopyDialog 多选货主)
- inbox.group.quickList 增加 store_id 过滤;members 改为 groupIds 数组入参
- 移除导出任务标签页及关联代码
- 移除 code/scope/三段 JSON 配置等旧模型字段
This commit is contained in:
parent
92a731c8a3
commit
6c8843e85b
@ -261,6 +261,8 @@ export function inboxGroupMessages(data: InboxGroupMessagesParams) {
|
||||
|
||||
/** 群快速查询参数(下拉选择用,不分页) */
|
||||
export interface InboxGroupQuickListParams {
|
||||
/** 货主ID(>0 时按货主过滤;不传返回所有群) */
|
||||
store_id?: number // 货主ID,不传则返回全部
|
||||
keyword?: string // 关键词,模糊匹配群名称与外部群ID
|
||||
groupType?: string // 群类型筛选:store(货主) / warehouse(仓库) / express(快递)
|
||||
limit?: number // 返回条数上限,默认20,最大100(无分页)
|
||||
@ -283,12 +285,12 @@ export function inboxGroupQuickList(data: InboxGroupQuickListParams = {}) {
|
||||
|
||||
/** 查询群成员参数(下拉选择用) */
|
||||
export interface InboxGroupMembersParams {
|
||||
groupId: number // 群记录主键ID(必填)
|
||||
groupIds: number[] // 群记录主键ID数组(必填,非空)
|
||||
keyword?: string // 关键词,模糊匹配用户名与用户ID
|
||||
limit?: number // 返回条数上限,默认20,最大100(无分页)
|
||||
}
|
||||
|
||||
/** 查询指定群的成员列表(inbox.group.members) */
|
||||
/** 查询多个群的成员列表(inbox.group.members) */
|
||||
export function inboxGroupMembers(data: InboxGroupMembersParams) {
|
||||
return request({
|
||||
url: '/system',
|
||||
|
||||
@ -91,8 +91,12 @@ export function generateTaskProgress(
|
||||
export interface DeliveryPlanSaveParams {
|
||||
/** 货主ID(必填,正整数;<=0 报错) */
|
||||
store_id: number
|
||||
/** 报表编码(必填,须为已启用的报表定义) */
|
||||
report_code: string
|
||||
/** 计划名称(必填,≤100 字符) */
|
||||
name: string
|
||||
/** 报表定义ID(必填,正整数;须为已启用 is_enabled=1 的报表定义;与 reportId 二选一,均传优先 reportId) */
|
||||
report_id: number
|
||||
/** 报表定义ID驼峰别名(兼容,优先级高于 report_id) */
|
||||
reportId?: number
|
||||
/** 每日投递时间点数组(HH:mm 24 小时制,非空;自动去重并升序) */
|
||||
schedule_times: string[]
|
||||
/** 投递渠道:仅支持 inbox,默认 inbox;wecom/link 已弃用 */
|
||||
@ -112,7 +116,14 @@ export interface DeliveryPlanSaveParams {
|
||||
export interface DeliveryPlanItem {
|
||||
id: number
|
||||
store_id: number
|
||||
report_code: string
|
||||
/** 货主名称(列表/详情展示) */
|
||||
store_name?: string
|
||||
/** 计划名称 */
|
||||
name: string
|
||||
/** 关联的报表定义ID(wms_report_definition.id) */
|
||||
report_definition_id: number
|
||||
/** 关联报表名称(前端由 report_definition_id 关联填充) */
|
||||
report_name?: string
|
||||
schedule_times: string[]
|
||||
channel: string
|
||||
/** 是否启用:0=停用 1=启用 */
|
||||
@ -126,7 +137,7 @@ export interface DeliveryPlanItem {
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
/** 新增/更新货主报表投递计划(货主 store_id + 报表 report_code 唯一,存在则更新) */
|
||||
/** 新增/更新货主报表投递计划(货主 store_id + 报表定义 report_id 唯一,存在则更新) */
|
||||
export function saveDeliveryPlan(
|
||||
data: DeliveryPlanSaveParams
|
||||
): Promise<DeliveryPlanItem> {
|
||||
@ -147,8 +158,8 @@ export interface DeliveryPlanListParams {
|
||||
where?: {
|
||||
/** 货主ID(>0 时精确过滤) */
|
||||
store_id?: number
|
||||
/** 报表编码(精确过滤) */
|
||||
report_code?: string
|
||||
/** 报表定义ID(>0 时精确过滤) */
|
||||
report_id?: number
|
||||
/** 启用状态:0=停用 1=启用;空值/未传不过滤 */
|
||||
enabled?: number | string
|
||||
}
|
||||
@ -191,6 +202,38 @@ export function listDeliveryPlan(
|
||||
} as any)
|
||||
}
|
||||
|
||||
export interface DeliveryPlanCopyParams {
|
||||
/** 源投递计划ID(必填,正整数) */
|
||||
id: number
|
||||
/** 目标货主ID数组(必填,正整数去重;复制到其他货主) */
|
||||
store_ids: number[]
|
||||
}
|
||||
|
||||
export interface DeliveryPlanCopyResult {
|
||||
/** 成功复制的计划数 */
|
||||
copied: number
|
||||
/** 复制后的计划ID列表 */
|
||||
plan_ids?: number[]
|
||||
code?: number
|
||||
}
|
||||
|
||||
/** 复制投递计划到其他货主(report.deliveryPlan.copy) */
|
||||
export function copyDeliveryPlan(
|
||||
data: DeliveryPlanCopyParams
|
||||
): Promise<DeliveryPlanCopyResult> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'report.deliveryPlan.copy',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/* ===== 货主报表投递记录 ===== */
|
||||
|
||||
export interface DeliveryLogListParams {
|
||||
@ -304,48 +347,104 @@ export function meta(data?: ReportMetaParams): Promise<ReportMetaResponse> {
|
||||
} as any)
|
||||
}
|
||||
|
||||
/* ===== 报表定义管理 ===== */
|
||||
/* ===== 报表定义管理(report.definition.*) ===== */
|
||||
|
||||
/** 报表类型注册清单中的字段项(report.definition.typeList) */
|
||||
export interface ReportDefinitionTypeField {
|
||||
/** 字段 key(与查询器返回行字段一一对应,如 item_code) */
|
||||
key: string
|
||||
/** 字段中文名 */
|
||||
label: string
|
||||
/** 字段类型:string/number/boolean/array */
|
||||
type?: string
|
||||
/** 是否为格式化器预计算字段 */
|
||||
computed?: boolean
|
||||
/** 是否为文本单元格(导出时按文本处理) */
|
||||
asText?: boolean
|
||||
/** 数组类型字段的子字段清单(仅 type=array 时返回) */
|
||||
children?: ReportDefinitionTypeField[]
|
||||
}
|
||||
|
||||
/** 报表类型注册项(report.definition.typeList) */
|
||||
export interface ReportDefinitionTypeItem {
|
||||
/** 类型 key(如 stockFlow) */
|
||||
key: string
|
||||
/** 类型标题(如「库存变化以及补货报表」) */
|
||||
title: string
|
||||
/** 口径描述 */
|
||||
description: string
|
||||
/** 日窗口参数 */
|
||||
window: {
|
||||
/** 窗口数量 */
|
||||
dayCount: number
|
||||
/** 切点小时 0-23 */
|
||||
cutoverHour: number
|
||||
}
|
||||
/** 全量字段清单 */
|
||||
fields: ReportDefinitionTypeField[]
|
||||
}
|
||||
|
||||
export interface ReportDefinitionTypeListResult {
|
||||
/** 注册类型清单(当前仅 stockFlow) */
|
||||
list: ReportDefinitionTypeItem[]
|
||||
code?: number
|
||||
}
|
||||
|
||||
/** 查询报表类型注册清单(只读公共元数据;免权限/免鉴权/免审计日志,仅要求登录) */
|
||||
export function reportDefinitionTypeList(): Promise<ReportDefinitionTypeListResult> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'report.definition.typeList',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: {},
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export interface ReportDefinitionSaveParams {
|
||||
/** 报表编码(必填,upsert 键):小写字母开头,仅含小写字母/数字/下划线,长度 2-64 */
|
||||
code: string
|
||||
/** 报表定义ID(正整数;不传视为新增;传入不存在报「报表定义不存在: id=<id>」) */
|
||||
id?: number
|
||||
/** 报表名称(必填,≤100 字符) */
|
||||
name: string
|
||||
/** 适用维度:warehouse=仓库 / store=货主 / open=通用;默认 warehouse */
|
||||
scope?: string
|
||||
/** 报表描述(≤500 字符,超出截断) */
|
||||
description?: string
|
||||
/** 输出配置(对象或 JSON 字符串) */
|
||||
output_config?: Record<string, unknown>
|
||||
/** 数据源配置(对象或 JSON 字符串),query 须为注册表已有查询器 */
|
||||
source_config?: Record<string, unknown>
|
||||
/** 工作表配置(对象或 JSON 字符串) */
|
||||
sheet_config?: Record<string, unknown>
|
||||
/** 是否启用:0=停用 1=启用 */
|
||||
/** 报表类型(注册 key,如 stockFlow;新增必填,须命中注册表;更新时未传不覆盖既有值) */
|
||||
type?: string
|
||||
/** 导出文件名模板(支持 {date} 占位;新增必填,≤200 字符;更新时未传不覆盖既有值) */
|
||||
file_name?: string
|
||||
/** 导出文件名驼峰别名(兼容,优先级高于 file_name) */
|
||||
fileName?: string
|
||||
/** 勾选字段 key 数组(新增必填,须为该类型注册字段子集;更新时未传不覆盖既有值) */
|
||||
fields?: string[]
|
||||
/** 是否启用:0=停用 1=启用(仅入参存在时生效,未传不覆盖既有值) */
|
||||
is_enabled?: number
|
||||
/** 备注(≤500 字符,超出截断) */
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export interface ReportDefinitionItem {
|
||||
/** 报表编码(保存后的定义 code 平铺为 report_code) */
|
||||
report_code: string
|
||||
/** 报表定义ID */
|
||||
id: number
|
||||
/** 报表名称 */
|
||||
name: string
|
||||
/** 适用维度:warehouse/store/open */
|
||||
scope: string
|
||||
description: string
|
||||
/** 报表类型(注册 key,如 stockFlow) */
|
||||
type: string
|
||||
/** 导出文件名模板(支持 {date} 占位) */
|
||||
file_name: string
|
||||
/** 勾选字段 key 数组(保存后按传入顺序去重) */
|
||||
fields: string[]
|
||||
/** 是否启用:0=停用 1=启用 */
|
||||
is_enabled: number
|
||||
/** 备注 */
|
||||
remark: string
|
||||
output_config: Record<string, unknown>
|
||||
source_config: Record<string, unknown>
|
||||
sheet_config: Record<string, unknown>
|
||||
created_at: string
|
||||
updated_at: string
|
||||
code?: number
|
||||
}
|
||||
|
||||
/** 新增/更新报表定义(report.definition.save,按 code upsert) */
|
||||
/** 新增/更新报表定义(report.definition.save,按 id upsert,未传字段不覆盖) */
|
||||
export function saveReportDefinition(
|
||||
data: ReportDefinitionSaveParams
|
||||
): Promise<ReportDefinitionItem> {
|
||||
@ -364,12 +463,10 @@ export function saveReportDefinition(
|
||||
|
||||
export interface ReportDefinitionListParams {
|
||||
where?: {
|
||||
/** 报表编码模糊关键字 */
|
||||
code?: string
|
||||
/** 报表名称模糊关键字 */
|
||||
/** 报表名称模糊关键字(LIKE,通配符已转义) */
|
||||
name?: string
|
||||
/** 适用维度精确筛选(warehouse/store/open) */
|
||||
scope?: string
|
||||
/** 报表类型精确筛选(注册 key,如 stockFlow;未命中注册表报「未知的报表类型」) */
|
||||
type?: string
|
||||
/** 启用状态精确筛选:0=停用 1=启用;空值/未传不过滤 */
|
||||
is_enabled?: number | string
|
||||
}
|
||||
@ -391,7 +488,7 @@ export interface ReportDefinitionListResult {
|
||||
code?: number
|
||||
}
|
||||
|
||||
/** 分页查询报表定义列表(report.definition.list) */
|
||||
/** 分页查询报表定义列表(report.definition.list,软删自动排除) */
|
||||
export function listReportDefinition(
|
||||
data?: ReportDefinitionListParams
|
||||
): Promise<ReportDefinitionListResult> {
|
||||
@ -409,19 +506,19 @@ export function listReportDefinition(
|
||||
}
|
||||
|
||||
export interface ReportDefinitionDeleteParams {
|
||||
/** 报表编码(必填,按 code 软删除;重复删除幂等成功) */
|
||||
code: string
|
||||
/** 报表定义ID(必填,正整数;按 id 软删除,重复删除幂等成功) */
|
||||
id: number
|
||||
}
|
||||
|
||||
export interface ReportDefinitionDeleteResult {
|
||||
/** 已删除的报表编码(定义 code 平铺为 report_code) */
|
||||
report_code: string
|
||||
/** 已删除的报表定义ID */
|
||||
id: number
|
||||
/** 删除结果标记(恒为 1) */
|
||||
deleted: number
|
||||
code?: number
|
||||
}
|
||||
|
||||
/** 软删除报表定义(report.definition.delete) */
|
||||
/** 软删除报表定义(report.definition.delete,删除前检查启用中的投递计划引用) */
|
||||
export function deleteReportDefinition(
|
||||
data: ReportDefinitionDeleteParams
|
||||
): Promise<ReportDefinitionDeleteResult> {
|
||||
|
||||
@ -17,16 +17,23 @@
|
||||
* 5. 在 router/map.ts 中添加路由
|
||||
*/
|
||||
|
||||
import { ref, isRef, type Component, type Ref } from 'vue'
|
||||
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 ApiAppFormDialog from '../pages/ApiAppFormDialog.vue'
|
||||
import DeliveryPlanFormDialog from '../pages/DeliveryPlanFormDialog.vue'
|
||||
import ExportReportDialog from '../pages/ExportReportDialog.vue'
|
||||
import DefinitionFormDialog from '../pages/DefinitionFormDialog.vue'
|
||||
import DeliveryPlanCopyDialog from '../pages/DeliveryPlanCopyDialog.vue'
|
||||
import { apiAppList } from '@/api/apiapp/apiapp'
|
||||
import { listDeliveryPlan, listDeliveryLog, meta, listReportDefinition } from '@/api/report/report'
|
||||
import {
|
||||
listDeliveryPlan,
|
||||
listDeliveryLog,
|
||||
listReportDefinition,
|
||||
reportDefinitionTypeList,
|
||||
type ReportDefinitionTypeField,
|
||||
type ReportDefinitionTypeItem
|
||||
} from '@/api/report/report'
|
||||
import { loadStores } from '@/api/index/index'
|
||||
|
||||
// ============================================================
|
||||
@ -50,7 +57,7 @@ export const COMPONENT_REGISTRY: Record<string, Component> = {
|
||||
WarehouseSettingsForm,
|
||||
ApiAppFormDialog,
|
||||
DeliveryPlanFormDialog,
|
||||
ExportReportDialog,
|
||||
DeliveryPlanCopyDialog,
|
||||
DefinitionFormDialog
|
||||
}
|
||||
|
||||
@ -98,6 +105,112 @@ export async function loadStoreOptions() {
|
||||
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>>({})
|
||||
let reportDefinitionLoading = false
|
||||
|
||||
/** 加载报表定义(force 强制刷新):下拉选项仅取启用项,名称映射取全量非软删 */
|
||||
export async function loadReportDefinitions(force = false): Promise<{ value: number; label: string }[]> {
|
||||
if (reportDefinitionOptions.value.length && !force) 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> = {}
|
||||
for (const d of list) {
|
||||
const id = Number(d?.id)
|
||||
if (id > 0) nameMap[id] = d?.name ? String(d.name) : `报表 #${id}`
|
||||
}
|
||||
reportDefinitionNameMap.value = nameMap
|
||||
// 下拉选项仅取启用项
|
||||
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 = {}
|
||||
} finally {
|
||||
reportDefinitionLoading = false
|
||||
}
|
||||
return reportDefinitionOptions.value
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 〇-B、SCANBOX_GROUPS — ScanBox 分组名称
|
||||
// ============================================================
|
||||
@ -164,7 +277,9 @@ export const VALUE_MAPS: Record<string, Record<string, string>> = {
|
||||
/** 报表导出任务状态 */
|
||||
taskStatus: { 'submitted': '已提交', 'running': '执行中', 'success': '已完成', 'failed': '失败', 'not_found': '未找到' },
|
||||
/** 报表适用维度(report.meta.scope) */
|
||||
scope: { 'warehouse': '仓库', 'store': '货主', 'open': '通用' }
|
||||
scope: { 'warehouse': '仓库', 'store': '货主', 'open': '通用' },
|
||||
/** 报表定义类型标题(report.definition.typeList,运行时填充) */
|
||||
reportType: {}
|
||||
}
|
||||
|
||||
/** 从 VALUE_MAPS 衍生 options(优先取中文值作为 option value) */
|
||||
@ -269,14 +384,14 @@ export const FIELD_DICT: Record<string, FieldDefinition> = {
|
||||
slot: null,
|
||||
detailLabel: '报表名称'
|
||||
},
|
||||
/** 报表定义类型(注册 key,选项来自 report.definition.typeList) */
|
||||
type: {
|
||||
key: 'type',
|
||||
label: '类型',
|
||||
scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: getOptions('type') },
|
||||
table: { minWidth: 100, align: 'center' },
|
||||
slot: { type: 'tag', tagType: 'info', translateField: 'type' },
|
||||
detailLabel: '类型',
|
||||
filterParamMap: { '类型A': 'A', '类型B': 'B', '类型C': 'C' }
|
||||
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',
|
||||
@ -450,6 +565,15 @@ export const FIELD_DICT: Record<string, FieldDefinition> = {
|
||||
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',
|
||||
@ -459,6 +583,42 @@ export const FIELD_DICT: Record<string, FieldDefinition> = {
|
||||
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',
|
||||
@ -675,12 +835,12 @@ export const FIELD_DICT: Record<string, FieldDefinition> = {
|
||||
slot: null,
|
||||
detailLabel: '切点小时'
|
||||
},
|
||||
/** 查询器静态字段清单(report.meta.fields) */
|
||||
/** 查询器静态字段清单(report.meta.fields)/ 报表定义勾选字段 key 数组 */
|
||||
fields: {
|
||||
key: 'fields',
|
||||
label: '字段清单',
|
||||
scanBox: null,
|
||||
table: null,
|
||||
table: { minWidth: 240, showOverflowTooltip: true },
|
||||
slot: { type: 'pre' },
|
||||
detailLabel: '字段清单'
|
||||
},
|
||||
@ -791,6 +951,8 @@ 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 中查找) */
|
||||
@ -855,7 +1017,7 @@ export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig {
|
||||
const def = FIELD_DICT[key]
|
||||
if (!def || !def.scanBox) continue
|
||||
scanBoxFields.push({
|
||||
label: def.label,
|
||||
label: raw.labelOverrides?.[def.key] ?? def.label,
|
||||
value: def.key,
|
||||
type: def.scanBox.type,
|
||||
options: def.scanBox.options
|
||||
@ -873,7 +1035,7 @@ export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig {
|
||||
if (!def || !def.table) continue
|
||||
columns.push({
|
||||
prop: def.key,
|
||||
label: def.label,
|
||||
label: raw.labelOverrides?.[def.key] ?? def.label,
|
||||
...def.table
|
||||
})
|
||||
}
|
||||
@ -896,7 +1058,7 @@ export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig {
|
||||
if (!def) return null
|
||||
return {
|
||||
key: def.key,
|
||||
label: def.detailLabel ?? def.label,
|
||||
label: raw.labelOverrides?.[def.key] ?? def.detailLabel ?? def.label,
|
||||
translateField: def.slot?.translateField,
|
||||
tagResolver: def.slot?.tagResolver,
|
||||
tagType: def.slot?.tagType,
|
||||
@ -1054,16 +1216,6 @@ export const TOOLBAR_BUTTONS: Record<string, ToolbarButtonConfig> = {
|
||||
action: 'openCreatePlan',
|
||||
onlyForTabs: ['plan']
|
||||
},
|
||||
/** 提交报表导出(仅导出任务标签页) */
|
||||
submitExport: {
|
||||
key: 'submitExport',
|
||||
label: '提交导出',
|
||||
category: 'function',
|
||||
type: 'primary',
|
||||
size: 'small',
|
||||
action: 'openExportReport',
|
||||
onlyForTabs: ['export']
|
||||
},
|
||||
/** 新增报表定义(仅报表定义标签页) */
|
||||
createDefinition: {
|
||||
key: 'createDefinition',
|
||||
@ -1238,8 +1390,9 @@ export const tabPages: TabPageRawConfig[] = [
|
||||
name: 'plan',
|
||||
label: '投递计划',
|
||||
scanBoxCacheKey: 'basic-settings-plan',
|
||||
scanBoxFieldKeys: ['store_id', 'report_code', 'enabled'],
|
||||
tableColumnKeys: ['id', 'store_id', 'report_code', 'schedule_times', 'channel', 'enabled', 'late_grace_minutes', 'notify_group_ids', 'notify_member_ids', 'remark', 'created_at', 'updated_at', 'operation'],
|
||||
scanBoxFieldKeys: ['store_id', 'report_id', 'enabled'],
|
||||
labelOverrides: { name: '计划名称' },
|
||||
tableColumnKeys: ['id', '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
|
||||
@ -1251,7 +1404,7 @@ export const tabPages: TabPageRawConfig[] = [
|
||||
{
|
||||
title: '基础信息',
|
||||
columnCount: 3,
|
||||
fieldKeys: ['store_id', 'report_code', 'schedule_times', 'channel', 'enabled', 'late_grace_minutes', 'remark']
|
||||
fieldKeys: ['store_name', 'name', 'report_name', 'report_definition_id', 'schedule_times', 'channel', 'enabled', 'late_grace_minutes', 'remark']
|
||||
},
|
||||
{
|
||||
title: '通知配置',
|
||||
@ -1268,7 +1421,14 @@ export const tabPages: TabPageRawConfig[] = [
|
||||
list: listDeliveryPlan,
|
||||
detail: { source: 'list' },
|
||||
parseListResponse(res) {
|
||||
return { list: res?.data?.list ?? res?.list ?? [], total: res?.data?.total ?? res?.total ?? 0 }
|
||||
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 {
|
||||
@ -1287,9 +1447,9 @@ export const tabPages: TabPageRawConfig[] = [
|
||||
formKey: 'DeliveryPlanFormDialog',
|
||||
paramMap: {
|
||||
store_id: 'store_id',
|
||||
report_code: 'report_code',
|
||||
name: 'name',
|
||||
report_definition_id: 'report_definition_id',
|
||||
schedule_times: 'schedule_times',
|
||||
channel: 'channel',
|
||||
late_grace_minutes: 'late_grace_minutes',
|
||||
remark: 'remark',
|
||||
notify_template: 'notify_template',
|
||||
@ -1297,6 +1457,19 @@ export const tabPages: TabPageRawConfig[] = [
|
||||
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: '查看详情',
|
||||
@ -1361,60 +1534,13 @@ export const tabPages: TabPageRawConfig[] = [
|
||||
]
|
||||
},
|
||||
|
||||
// ===== 标签页五:导出任务(列表来自 report.meta 查询报表元数据;导出用 report.generate + report.generateTaskProgress) =====
|
||||
{
|
||||
name: 'export',
|
||||
label: '导出任务',
|
||||
scanBoxCacheKey: 'basic-settings-export',
|
||||
scanBoxFieldKeys: ['report_code'],
|
||||
tableColumnKeys: ['report_code', 'name', 'scope', 'query', 'day_count', 'cutover_hour', 'operation'],
|
||||
upperTableDefaults: {
|
||||
title: '报表定义(report.meta)',
|
||||
showSelection: false,
|
||||
emptyText: '请输入报表编码查询报表元数据'
|
||||
},
|
||||
detailTabs: [
|
||||
{ name: 'detail', label: '报表详情', componentKey: 'DetailPanel' }
|
||||
],
|
||||
detailSections: [
|
||||
{
|
||||
title: '报表信息',
|
||||
columnCount: 3,
|
||||
fieldKeys: ['report_code', 'name', 'scope', 'query', 'day_count', 'cutover_hour']
|
||||
},
|
||||
{
|
||||
title: '可导出字段',
|
||||
columnCount: 1,
|
||||
fieldKeys: ['fields']
|
||||
}
|
||||
],
|
||||
api: {
|
||||
list: queryReportMetaList,
|
||||
detail: { source: 'list' },
|
||||
parseListResponse(res) {
|
||||
return { list: res?.data?.list ?? [], total: res?.data?.total ?? 0 }
|
||||
},
|
||||
buildListParams({ conditions }) {
|
||||
return { report_code: conditions?.report_code }
|
||||
}
|
||||
},
|
||||
operationButtons: [
|
||||
{
|
||||
key: 'exportThisReport',
|
||||
label: '导出此报表',
|
||||
actionType: 'action',
|
||||
type: 'primary'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
// ===== 标签页六:报表定义(wms_report_definition 管理,report.definition.*) =====
|
||||
// ===== 标签页五:报表定义(wms_report_definition 管理,report.definition.*) =====
|
||||
{
|
||||
name: 'definition',
|
||||
label: '报表定义',
|
||||
scanBoxCacheKey: 'basic-settings-definition',
|
||||
scanBoxFieldKeys: ['report_code', 'name', 'scope', 'is_enabled'],
|
||||
tableColumnKeys: ['report_code', 'name', 'scope', 'description', 'is_enabled', 'remark', 'updated_at', 'operation'],
|
||||
scanBoxFieldKeys: ['name', 'type', 'is_enabled'],
|
||||
tableColumnKeys: ['id', 'name', 'type', 'file_name', 'fields', 'is_enabled', 'remark', 'updated_at', 'operation'],
|
||||
upperTableDefaults: {
|
||||
title: '报表定义',
|
||||
showSelection: false
|
||||
@ -1426,12 +1552,12 @@ export const tabPages: TabPageRawConfig[] = [
|
||||
{
|
||||
title: '基本信息',
|
||||
columnCount: 3,
|
||||
fieldKeys: ['report_code', 'name', 'scope', 'description', 'is_enabled', 'remark']
|
||||
fieldKeys: ['id', 'name', 'type', 'file_name', 'is_enabled', 'remark']
|
||||
},
|
||||
{
|
||||
title: '配置信息',
|
||||
columnCount: 1,
|
||||
fieldKeys: ['output_config', 'source_config', 'sheet_config']
|
||||
fieldKeys: ['fields']
|
||||
},
|
||||
{
|
||||
title: '时间信息',
|
||||
@ -1461,16 +1587,13 @@ export const tabPages: TabPageRawConfig[] = [
|
||||
type: 'warning',
|
||||
formKey: 'DefinitionFormDialog',
|
||||
paramMap: {
|
||||
report_code: 'report_code',
|
||||
code: 'code',
|
||||
id: 'id',
|
||||
name: 'name',
|
||||
scope: 'scope',
|
||||
description: 'description',
|
||||
type: 'type',
|
||||
file_name: 'file_name',
|
||||
fields: 'fields',
|
||||
is_enabled: 'is_enabled',
|
||||
remark: 'remark',
|
||||
output_config: 'output_config',
|
||||
source_config: 'source_config',
|
||||
sheet_config: 'sheet_config'
|
||||
remark: 'remark'
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -1491,37 +1614,3 @@ export const tabPages: TabPageRawConfig[] = [
|
||||
// ============================================================
|
||||
export const templateTabs = tabPages.map((t) => ({ name: t.name, label: t.label, scanBoxCacheKey: t.scanBoxCacheKey }))
|
||||
|
||||
// ============================================================
|
||||
// 十四、导出任务:报表元数据查询(report.meta)
|
||||
// ============================================================
|
||||
/**
|
||||
* 按报表编码调用 report.meta 查询报表元数据,包装为列表行(导出任务页的 api.list)。
|
||||
* 未传报表编码时返回空列表。
|
||||
*/
|
||||
export async function queryReportMetaList(params?: { report_code?: string }): Promise<any> {
|
||||
const code = params?.report_code
|
||||
if (!code) {
|
||||
return { code: 1, data: { list: [], total: 0 } }
|
||||
}
|
||||
try {
|
||||
const res: any = await meta({ report_code: code })
|
||||
const payload = res?.data ?? res
|
||||
if (payload && payload.report_code) {
|
||||
const row = {
|
||||
report_code: payload.report_code,
|
||||
name: payload.name,
|
||||
scope: payload.scope,
|
||||
query: payload.query,
|
||||
day_count: payload.window?.dayCount,
|
||||
cutover_hour: payload.window?.cutoverHour,
|
||||
fields: payload.fields ?? []
|
||||
}
|
||||
return { code: 1, data: { list: [row], total: 1 } }
|
||||
}
|
||||
return { code: 1, data: { list: [], total: 0 } }
|
||||
} catch (e) {
|
||||
console.error('查询报表元数据失败', e)
|
||||
return { code: 1, data: { list: [], total: 0 } }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -247,10 +247,6 @@
|
||||
v-model:visible="definitionCreateVisible"
|
||||
@success="handleDefinitionSaved"
|
||||
/>
|
||||
<ExportReportDialog
|
||||
v-model:visible="exportReportVisible"
|
||||
:report-code="exportInitialReportCode"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -277,6 +273,8 @@ import {
|
||||
resolveTabConfig,
|
||||
getTabToolbarButtons,
|
||||
loadStoreOptions,
|
||||
loadReportTypeList,
|
||||
loadReportDefinitions,
|
||||
type TabPageConfig,
|
||||
type DetailTabConfig,
|
||||
type ToolbarButtonConfig,
|
||||
@ -285,7 +283,6 @@ import { apiAppDelete, apiAppRegenerateSecret } from '@/api/apiapp/apiapp'
|
||||
import { deleteReportDefinition } from '@/api/report/report'
|
||||
import ApiAppFormDialog from './pages/ApiAppFormDialog.vue'
|
||||
import DeliveryPlanFormDialog from './pages/DeliveryPlanFormDialog.vue'
|
||||
import ExportReportDialog from './pages/ExportReportDialog.vue'
|
||||
import DefinitionFormDialog from './pages/DefinitionFormDialog.vue'
|
||||
|
||||
// ============================================================
|
||||
@ -453,7 +450,6 @@ const toolbarActionMap: Record<string, () => void> = {
|
||||
openCreateApiApp: () => { apiAppCreateVisible.value = true },
|
||||
openCreatePlan: () => { createPlanVisible.value = true },
|
||||
openCreateDefinition: () => { definitionCreateVisible.value = true },
|
||||
openExportReport: () => { exportReportVisible.value = true },
|
||||
handleExport: () => { console.log('[BasicManagement] 导出(不含明细)', activeTabName.value) },
|
||||
handleExportItem: () => { console.log('[BasicManagement] 导出(含明细)', activeTabName.value) }
|
||||
}
|
||||
@ -484,10 +480,9 @@ async function handleOperationAction(key: string, row: Record<string, any>) {
|
||||
// 投递计划编辑弹窗提交成功后触发,刷新列表
|
||||
loadData()
|
||||
break
|
||||
case 'exportThisReport':
|
||||
// 将该报表编码带入导出弹窗
|
||||
exportInitialReportCode.value = row?.report_code ?? ''
|
||||
exportReportVisible.value = true
|
||||
case 'copyPlan':
|
||||
// 投递计划复制成功后刷新列表
|
||||
loadData()
|
||||
break
|
||||
case 'regenerateSecret':
|
||||
await handleRegenerateSecret(row)
|
||||
@ -509,9 +504,6 @@ async function handleOperationAction(key: string, row: Record<string, any>) {
|
||||
const apiAppCreateVisible = ref(false)
|
||||
const createPlanVisible = ref(false)
|
||||
const definitionCreateVisible = ref(false)
|
||||
const exportReportVisible = ref(false)
|
||||
/** 导出弹窗初始报表编码(导出任务行「导出此报表」带入) */
|
||||
const exportInitialReportCode = ref('')
|
||||
|
||||
function handleApiAppDialogSuccess() {
|
||||
loadData()
|
||||
@ -560,13 +552,13 @@ async function handleDeleteApiApp(row: Record<string, any>) {
|
||||
}
|
||||
|
||||
async function handleDeleteReportDefinition(row: Record<string, any>) {
|
||||
const code = row?.report_code ?? row?.code
|
||||
if (!code) {
|
||||
ElMessage.warning('缺少报表编码')
|
||||
const id = Number(row?.id)
|
||||
if (!(id > 0)) {
|
||||
ElMessage.warning('缺少报表定义ID')
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res: any = await deleteReportDefinition({ code })
|
||||
const res: any = await deleteReportDefinition({ id })
|
||||
if (res && (res.code === 1 || res.code === 200)) {
|
||||
ElMessage.success('已删除')
|
||||
loadData()
|
||||
@ -759,6 +751,10 @@ const upperPaneFullStyle = computed(() => ({
|
||||
// ============================================================
|
||||
onMounted(() => {
|
||||
void loadStoreOptions()
|
||||
// 预加载报表类型注册清单(报表定义页 type 筛选下拉与表单字段依赖)
|
||||
void loadReportTypeList()
|
||||
// 预加载报表定义选项(投递计划页报表筛选下拉与表单下拉依赖)
|
||||
void loadReportDefinitions()
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<!--
|
||||
DefinitionFormDialog — 报表定义(wms_report_definition)新增/编辑 表单弹窗
|
||||
对接接口:report.definition.save(按 code upsert,未传字段不覆盖)
|
||||
对接接口:report.definition.save(按 id upsert,未传字段不覆盖)
|
||||
极简配置:报表类型 type(report.definition.typeList 注册)+ 勾选字段 fields + 导出文件名 file_name(支持 {date} 占位)
|
||||
-->
|
||||
<template>
|
||||
<el-dialog
|
||||
@ -21,66 +22,63 @@
|
||||
label-width="120px"
|
||||
size="small"
|
||||
>
|
||||
<el-form-item label="报表编码" prop="report_code">
|
||||
<el-input
|
||||
v-model="form.report_code"
|
||||
:disabled="isEdit"
|
||||
placeholder="小写字母开头,仅含小写字母/数字/下划线,长度 2-64"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="报表名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入报表名称(≤100 字符)" maxlength="100" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="适用维度" prop="scope">
|
||||
<el-select v-model="form.scope" placeholder="请选择适用维度" style="width: 100%">
|
||||
<el-option label="仓库" value="warehouse" />
|
||||
<el-option label="货主" value="store" />
|
||||
<el-option label="通用" value="open" />
|
||||
<el-form-item label="报表类型" prop="type">
|
||||
<el-select
|
||||
v-model="form.type"
|
||||
:disabled="isEdit"
|
||||
placeholder="请选择报表类型"
|
||||
style="width: 100%"
|
||||
@change="handleTypeChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in typeOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
<div class="form-tip" v-if="isEdit">报表类型一经创建不可更改</div>
|
||||
<div v-if="currentTypeInfo" class="form-tip type-desc">{{ currentTypeInfo.description }}</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="导出文件名" prop="file_name">
|
||||
<el-input
|
||||
v-model="form.file_name"
|
||||
placeholder="导出文件名模板,支持 {date} 占位(≤200 字符)"
|
||||
maxlength="200"
|
||||
/>
|
||||
<div class="form-tip">如:库存变化报表_{date},{date} 自动替换为数据日期</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="勾选字段" prop="fields">
|
||||
<el-checkbox-group v-model="form.fields" class="field-checkbox-group">
|
||||
<el-checkbox
|
||||
v-for="f in currentTypeFields"
|
||||
:key="f.key"
|
||||
:label="f.key"
|
||||
>
|
||||
{{ f.label }}
|
||||
<span v-if="f.computed" class="field-computed">(预计算)</span>
|
||||
<span v-else-if="f.asText" class="field-astext">(文本)</span>
|
||||
<span v-if="f.children?.length" class="field-array">(含子字段 {{ f.children.length }} 项)</span>
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
<div v-if="!currentTypeFields.length" class="form-tip">
|
||||
{{ isEdit ? '未找到该类型的字段清单' : '请先选择报表类型' }}
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="启用状态" prop="is_enabled">
|
||||
<el-switch v-model="form.is_enabled" :active-value="1" :inactive-value="0" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="报表描述" prop="description">
|
||||
<el-input v-model="form.description" type="textarea" :rows="2" maxlength="500" placeholder="最长 500 字符" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" :rows="2" maxlength="500" placeholder="最长 500 字符" />
|
||||
</el-form-item>
|
||||
|
||||
<el-divider content-position="left">JSON 配置(可选,支持对象或 JSON 字符串)</el-divider>
|
||||
|
||||
<el-form-item label="输出配置" prop="output_config_text">
|
||||
<el-input
|
||||
v-model="form.output_config_text"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder='如 {"filename":"报表","sheetName":"Sheet1"}'
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="数据源配置" prop="source_config_text">
|
||||
<el-input
|
||||
v-model="form.source_config_text"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder='如 {"query":"week_inout_7d"}'
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="工作表配置" prop="sheet_config_text">
|
||||
<el-input
|
||||
v-model="form.sheet_config_text"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder='如 {"columns":[]}'
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
@ -97,22 +95,31 @@
|
||||
import { reactive, ref, watch, computed } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { saveReportDefinition } from '@/api/report/report'
|
||||
import {
|
||||
loadReportTypeList,
|
||||
reportTypeOptions as typeOptions,
|
||||
getReportTypeFields,
|
||||
getReportTypeInfo
|
||||
} from '../config/template-config'
|
||||
|
||||
defineOptions({ name: 'DefinitionFormDialog' })
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
/** 编辑时由行数据注入的初始值(report.definition 响应中 code 平铺为 report_code) */
|
||||
report_code?: string
|
||||
code?: string
|
||||
/** 报表定义ID(编辑时传入,save 按 id upsert;未传视为新增) */
|
||||
id?: number
|
||||
/** 报表名称 */
|
||||
name?: string
|
||||
scope?: string
|
||||
description?: string
|
||||
/** 报表类型(注册 key,如 stockFlow) */
|
||||
type?: string
|
||||
/** 导出文件名模板(支持 {date} 占位) */
|
||||
file_name?: string
|
||||
/** 勾选字段 key 数组 */
|
||||
fields?: any[]
|
||||
/** 是否启用:0=停用 1=启用 */
|
||||
is_enabled?: number
|
||||
/** 备注 */
|
||||
remark?: string
|
||||
output_config?: any
|
||||
source_config?: any
|
||||
sheet_config?: any
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@ -124,69 +131,55 @@ const formRef = ref<any>(null)
|
||||
const submitting = ref(false)
|
||||
|
||||
const form = reactive({
|
||||
report_code: '',
|
||||
name: '',
|
||||
scope: 'warehouse',
|
||||
description: '',
|
||||
type: '',
|
||||
file_name: '',
|
||||
fields: [] as string[],
|
||||
is_enabled: 1,
|
||||
remark: '',
|
||||
output_config_text: '',
|
||||
source_config_text: '',
|
||||
sheet_config_text: ''
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const isEdit = computed(() => Boolean(props.report_code || props.code))
|
||||
const isEdit = computed(() => Number(props.id) > 0)
|
||||
|
||||
const rules = {
|
||||
report_code: [
|
||||
{ required: true, message: '请输入报表编码', trigger: 'blur' },
|
||||
{ pattern: /^[a-z][a-z0-9_]{1,63}$/, message: '须以小写字母开头,仅含小写字母/数字/下划线,长度 2-64', trigger: 'blur' }
|
||||
],
|
||||
name: [{ required: true, message: '请输入报表名称', trigger: 'blur' }]
|
||||
name: [{ required: true, message: '请输入报表名称', trigger: 'blur' }],
|
||||
type: [{ required: true, message: '请选择报表类型', trigger: 'change' }],
|
||||
file_name: [{ required: true, message: '请输入导出文件名', trigger: 'blur' }],
|
||||
fields: [{ required: true, type: 'array' as any, message: '请至少勾选一个字段', trigger: 'change' }]
|
||||
}
|
||||
|
||||
/** 将文本解析为对象(失败则原样返回字符串,后端同时支持对象或 JSON 字符串) */
|
||||
function parseJsonOrRaw(text: string): any {
|
||||
const raw = text.trim()
|
||||
if (!raw) return undefined
|
||||
try {
|
||||
return JSON.parse(raw)
|
||||
} catch {
|
||||
return raw
|
||||
/** 当前类型的注册字段清单(编辑时类型不在清单中则回退展示既有字段) */
|
||||
const currentTypeFields = computed(() => {
|
||||
const fields = getReportTypeFields(form.type)
|
||||
if (fields.length) return fields
|
||||
// 编辑兜底:类型未命中清单时,用既有字段构造可读选项
|
||||
if (isEdit.value && form.fields.length) {
|
||||
return form.fields.map((k) => ({ key: k, label: k }))
|
||||
}
|
||||
return []
|
||||
})
|
||||
|
||||
/** 当前所选类型的注册信息(口径描述等,来自 report.definition.typeList) */
|
||||
const currentTypeInfo = computed(() => getReportTypeInfo(form.type))
|
||||
|
||||
/** 切换类型时清空已勾选字段(新增模式) */
|
||||
function handleTypeChange() {
|
||||
if (!isEdit.value) {
|
||||
form.fields = []
|
||||
formRef.value?.clearValidate?.('fields')
|
||||
}
|
||||
}
|
||||
|
||||
/** 将任意值序列化为可编辑文本(对象 → JSON 字符串,其他 → 字符串) */
|
||||
function toConfigText(v: any): string {
|
||||
if (v === undefined || v === null || v === '') return ''
|
||||
if (typeof v === 'string') {
|
||||
const trimmed = v.trim()
|
||||
if (!trimmed) return ''
|
||||
try {
|
||||
JSON.parse(trimmed) // 已是合法 JSON 字符串则原样展示
|
||||
return trimmed
|
||||
} catch {
|
||||
return v
|
||||
}
|
||||
}
|
||||
try {
|
||||
return JSON.stringify(v, null, 2)
|
||||
} catch {
|
||||
return String(v)
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => props.visible, (v) => {
|
||||
watch(() => props.visible, async (v) => {
|
||||
if (v) {
|
||||
form.report_code = props.report_code ?? props.code ?? ''
|
||||
// 打开前确保类型注册清单已加载
|
||||
await loadReportTypeList()
|
||||
form.name = props.name ?? ''
|
||||
form.scope = props.scope ?? 'warehouse'
|
||||
form.description = props.description ?? ''
|
||||
form.type = props.type ?? ''
|
||||
form.file_name = props.file_name ?? ''
|
||||
form.fields = Array.isArray(props.fields) ? [...props.fields] : []
|
||||
form.is_enabled = props.is_enabled ?? 1
|
||||
form.remark = props.remark ?? ''
|
||||
form.output_config_text = toConfigText(props.output_config)
|
||||
form.source_config_text = toConfigText(props.source_config)
|
||||
form.sheet_config_text = toConfigText(props.sheet_config)
|
||||
formRef.value?.clearValidate?.()
|
||||
}
|
||||
}, { immediate: true })
|
||||
@ -205,15 +198,13 @@ async function handleSubmit() {
|
||||
submitting.value = true
|
||||
try {
|
||||
await saveReportDefinition({
|
||||
code: form.report_code.trim(),
|
||||
...(isEdit.value ? { id: props.id } : {}),
|
||||
name: form.name.trim(),
|
||||
...(form.scope ? { scope: form.scope } : {}),
|
||||
...(form.description ? { description: form.description } : {}),
|
||||
...(form.remark ? { remark: form.remark } : {}),
|
||||
type: form.type,
|
||||
file_name: form.file_name.trim(),
|
||||
fields: [...form.fields],
|
||||
is_enabled: form.is_enabled,
|
||||
...(form.output_config_text.trim() ? { output_config: parseJsonOrRaw(form.output_config_text) } : {}),
|
||||
...(form.source_config_text.trim() ? { source_config: parseJsonOrRaw(form.source_config_text) } : {}),
|
||||
...(form.sheet_config_text.trim() ? { sheet_config: parseJsonOrRaw(form.sheet_config_text) } : {})
|
||||
...(form.remark ? { remark: form.remark.trim() } : {})
|
||||
})
|
||||
|
||||
ElMessage.success(isEdit.value ? '报表定义已更新' : '报表定义已创建')
|
||||
@ -237,5 +228,32 @@ async function handleSubmit() {
|
||||
line-height: 1.5;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.field-checkbox-group {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 18px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.field-computed {
|
||||
font-size: 12px;
|
||||
color: #e6a23c;
|
||||
}
|
||||
|
||||
.field-astext {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.field-array {
|
||||
font-size: 12px;
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
.type-desc {
|
||||
max-height: 52px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -0,0 +1,161 @@
|
||||
<!--
|
||||
DeliveryPlanCopyDialog — 复制投递计划到其他货主
|
||||
对接接口:report.deliveryPlan.copy(传入源计划 id + 目标货主 store_ids)
|
||||
-->
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
title="复制投递计划"
|
||||
width="520px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
append-to-body
|
||||
@closed="handleClosed"
|
||||
>
|
||||
<div class="form-body">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="90px"
|
||||
size="small"
|
||||
>
|
||||
<el-form-item label="源计划">
|
||||
<div class="source-info">
|
||||
<el-tag size="small" type="info" effect="plain">{{ sourceLabel }}</el-tag>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="复制到" prop="store_ids">
|
||||
<el-select
|
||||
v-model="form.store_ids"
|
||||
multiple
|
||||
filterable
|
||||
placeholder="选择要复制到的货主(可多选,不含源货主)"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in targetStoreOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
<div class="form-tip">按源计划配置复制给所选货主;同一货主已有该报表计划时后端会返回冲突提示</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button size="small" @click="handleClosed">取消</el-button>
|
||||
<el-button size="small" type="primary" :loading="submitting" @click="handleSubmit">确认复制</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, computed, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { copyDeliveryPlan } from '@/api/report/report'
|
||||
import { storeOptions, loadStoreOptions } from '../config/template-config'
|
||||
|
||||
defineOptions({ name: 'DeliveryPlanCopyDialog' })
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
/** 源投递计划ID */
|
||||
id?: number
|
||||
/** 源计划名称 */
|
||||
name?: string
|
||||
/** 源计划所属货主ID(从可选目标中排除) */
|
||||
store_id?: number | string
|
||||
/** 关联报表名称(展示用) */
|
||||
report_name?: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', v: boolean): void
|
||||
(e: 'success'): void
|
||||
}>()
|
||||
|
||||
const formRef = ref<any>(null)
|
||||
const submitting = ref(false)
|
||||
|
||||
const form = reactive({
|
||||
store_ids: [] as number[]
|
||||
})
|
||||
|
||||
const rules = {
|
||||
store_ids: [{ required: true, type: 'array' as any, min: 1, message: '请至少选择一个货主', trigger: 'change' }]
|
||||
}
|
||||
|
||||
/** 源计划展示文案:计划名称(关联报表) */
|
||||
const sourceLabel = computed(() => {
|
||||
const name = props.name || `计划 #${props.id}`
|
||||
const report = props.report_name ? `(${props.report_name})` : ''
|
||||
return `${name}${report}`
|
||||
})
|
||||
|
||||
/** 目标货主选项:排除源计划自身货主 */
|
||||
const targetStoreOptions = computed(() => {
|
||||
const srcId = Number(props.store_id)
|
||||
return storeOptions.value.filter((o) => Number(o.value) !== srcId)
|
||||
})
|
||||
|
||||
watch(() => props.visible, (v) => {
|
||||
if (v) {
|
||||
form.store_ids = []
|
||||
void loadStoreOptions()
|
||||
formRef.value?.clearValidate?.()
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
function handleClosed() {
|
||||
emit('update:visible', false)
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
submitting.value = true
|
||||
try {
|
||||
const res: any = await copyDeliveryPlan({ id: Number(props.id), store_ids: form.store_ids })
|
||||
if (res && (res.code === 1 || res.code === 200)) {
|
||||
const copied = Number(res?.copied ?? res?.data?.copied ?? form.store_ids.length)
|
||||
ElMessage.success(`已复制到 ${copied} 个货主`)
|
||||
emit('update:visible', false)
|
||||
emit('success')
|
||||
} else {
|
||||
ElMessage.error(res?.message || '复制失败')
|
||||
}
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '复制失败')
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.form-body {
|
||||
padding: 12px 4px 0 0;
|
||||
|
||||
.source-info {
|
||||
min-height: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.form-tip {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
line-height: 1.5;
|
||||
margin-top: 4px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -1,6 +1,7 @@
|
||||
<!--
|
||||
DeliveryPlanFormDialog — 货主报表投递计划 新增/编辑 表单弹窗
|
||||
对接接口:report.deliveryPlan.save(货主 store_id + 报表 report_code 唯一,存在则更新)
|
||||
对接接口:report.deliveryPlan.save(货主 store_id + 报表定义 report_id 唯一,存在则更新)
|
||||
报表通过下拉单选关联 report.definition.list 中的启用报表定义;渠道已收敛,仅 inbox
|
||||
-->
|
||||
<template>
|
||||
<el-dialog
|
||||
@ -21,6 +22,10 @@
|
||||
label-width="110px"
|
||||
size="small"
|
||||
>
|
||||
<el-form-item label="计划名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入计划名称(≤100 字符)" maxlength="100" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="货主" prop="store_id">
|
||||
<el-select
|
||||
v-model="form.store_id"
|
||||
@ -37,8 +42,21 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="报表编码" prop="report_code">
|
||||
<el-input v-model="form.report_code" placeholder="请输入已启用的报表编码,如 deliveryPlan" />
|
||||
<el-form-item label="关联报表" prop="report_definition_id">
|
||||
<el-select
|
||||
v-model="form.report_definition_id"
|
||||
filterable
|
||||
placeholder="请选择要关联的报表定义"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in reportOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
<div class="form-tip">仅展示启用中的报表定义,选择后按其类型与字段生成投递内容</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="投递时间" prop="schedule_times">
|
||||
@ -65,14 +83,6 @@
|
||||
<div class="form-tip">24 小时制时间点(如 08:00),系统会自动去重并升序排列</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="投递渠道" prop="channel">
|
||||
<el-select v-model="form.channel" placeholder="选择投递渠道" style="width: 100%">
|
||||
<el-option label="企业微信" value="wecom" />
|
||||
<el-option label="站内信" value="inbox" />
|
||||
<el-option label="链接" value="link" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="补投宽限(分)" prop="late_grace_minutes">
|
||||
<el-input-number
|
||||
v-model="form.late_grace_minutes"
|
||||
@ -162,17 +172,23 @@ import { reactive, ref, watch, computed, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { saveDeliveryPlan } from '@/api/report/report'
|
||||
import { inboxGroupQuickList, inboxGroupMembers } from '@/api/inbox/inbox'
|
||||
import { storeOptions, loadStoreOptions } from '../config/template-config'
|
||||
import {
|
||||
storeOptions,
|
||||
loadStoreOptions,
|
||||
reportDefinitionOptions,
|
||||
loadReportDefinitions
|
||||
} from '../config/template-config'
|
||||
|
||||
defineOptions({ name: 'DeliveryPlanFormDialog' })
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
/** 编辑时由行数据注入的初始值 */
|
||||
name?: string
|
||||
store_id?: number | string
|
||||
report_code?: string
|
||||
/** 关联的报表定义ID(列表行 report_definition_id) */
|
||||
report_definition_id?: number
|
||||
schedule_times?: string[]
|
||||
channel?: string
|
||||
late_grace_minutes?: number
|
||||
remark?: string
|
||||
notify_template?: string
|
||||
@ -189,10 +205,10 @@ const formRef = ref<any>(null)
|
||||
const submitting = ref(false)
|
||||
|
||||
const form = reactive({
|
||||
name: '',
|
||||
store_id: undefined as number | undefined,
|
||||
report_code: '',
|
||||
report_definition_id: undefined as number | undefined,
|
||||
schedule_times: [] as string[],
|
||||
channel: 'wecom',
|
||||
late_grace_minutes: 60,
|
||||
remark: '',
|
||||
notify_template: '',
|
||||
@ -237,22 +253,40 @@ const groupSearchLoading = ref(false)
|
||||
const memberOptions = ref<{ user_id: string; label: string }[]>([])
|
||||
const memberSearchLoading = ref(false)
|
||||
|
||||
const isEdit = computed(() => Boolean(props.store_id && props.report_code))
|
||||
const isEdit = computed(() => Boolean(props.store_id && props.report_definition_id))
|
||||
|
||||
/** 报表下拉选项:启用中的报表定义;编辑回显时若当前报表已停用则补占位项 */
|
||||
const reportOptions = computed(() => {
|
||||
const opts = reportDefinitionOptions.value
|
||||
const cur = form.report_definition_id
|
||||
if (cur === undefined || cur === null || opts.some((o) => o.value === cur)) return opts
|
||||
return [...opts, { value: cur, label: `报表 #${cur}` }]
|
||||
})
|
||||
|
||||
const rules = {
|
||||
name: [{ required: true, message: '请输入计划名称', trigger: 'blur' }],
|
||||
store_id: [{ required: true, message: '请选择货主', trigger: 'change' }],
|
||||
report_code: [{ required: true, message: '请输入报表编码', trigger: 'blur' }],
|
||||
report_definition_id: [{ required: true, message: '请选择关联报表', trigger: 'change' }],
|
||||
schedule_times: [{ required: true, type: 'array', min: 1, message: '至少添加一个投递时间', trigger: 'change' }]
|
||||
}
|
||||
|
||||
/** 上一个货主ID(用于判断是否切换货主;弹窗打开填充不算切换) */
|
||||
let prevStoreId: number | undefined = undefined
|
||||
|
||||
watch(() => props.visible, (v) => {
|
||||
if (v) {
|
||||
form.name = props.name ?? ''
|
||||
form.store_id = props.store_id !== undefined && props.store_id !== null && props.store_id !== ''
|
||||
? Number(props.store_id)
|
||||
: undefined
|
||||
form.report_code = props.report_code ?? ''
|
||||
// 记录基准货主(弹窗打开填充不算切换)
|
||||
prevStoreId = form.store_id
|
||||
form.report_definition_id = props.report_definition_id !== undefined && props.report_definition_id !== null && props.report_definition_id !== 0
|
||||
? Number(props.report_definition_id)
|
||||
: undefined
|
||||
// 打开时刷新报表定义下拉(force,避免同会话新增报表后未出现)
|
||||
void loadReportDefinitions(true)
|
||||
form.schedule_times = normalizeStringArray(props.schedule_times)
|
||||
form.channel = props.channel ?? 'wecom'
|
||||
form.late_grace_minutes = props.late_grace_minutes ?? 60
|
||||
form.remark = props.remark ?? ''
|
||||
form.notify_template = props.notify_template ?? ''
|
||||
@ -268,6 +302,17 @@ watch(() => props.visible, (v) => {
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
// 货主切换时刷新通知群下拉,并清空旧货主下已选的群/成员(群按 store_id 过滤)
|
||||
watch(() => form.store_id, (newVal) => {
|
||||
if (prevStoreId === newVal) return
|
||||
prevStoreId = newVal
|
||||
groupOptions.value = []
|
||||
form.notify_group_ids = []
|
||||
memberOptions.value = []
|
||||
form.notify_member_ids = []
|
||||
void searchGroups('')
|
||||
})
|
||||
|
||||
function handleClosed() {
|
||||
emit('update:visible', false)
|
||||
}
|
||||
@ -294,11 +339,15 @@ function removeScheduleTime(idx: number) {
|
||||
form.schedule_times.splice(idx, 1)
|
||||
}
|
||||
|
||||
/** 群快速查询(远程搜索) */
|
||||
/** 群快速查询(远程搜索,按已选货主过滤;未选货主时返回全部) */
|
||||
async function searchGroups(keyword: string) {
|
||||
groupSearchLoading.value = true
|
||||
try {
|
||||
const res: any = await inboxGroupQuickList({ keyword, limit: 100 })
|
||||
const res: any = await inboxGroupQuickList({
|
||||
keyword,
|
||||
limit: 100,
|
||||
...(form.store_id ? { store_id: form.store_id } : {})
|
||||
})
|
||||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
const data = res.data ?? res
|
||||
groupOptions.value = (data.list ?? []).map((g: any) => ({
|
||||
@ -315,7 +364,7 @@ async function searchGroups(keyword: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 成员查询(远程搜索,传已选群内部主键 id 聚合去重) */
|
||||
/** 成员查询(远程搜索,传已选群内部主键 id 数组一次查询,聚合去重) */
|
||||
async function searchMembers(keyword: string, silent = false) {
|
||||
const groupIds = form.notify_group_ids ?? []
|
||||
if (!groupIds.length) {
|
||||
@ -325,21 +374,21 @@ async function searchMembers(keyword: string, silent = false) {
|
||||
}
|
||||
memberSearchLoading.value = true
|
||||
try {
|
||||
const merged: { user_id: string; label: string }[] = []
|
||||
const seen = new Set<string>()
|
||||
for (const gid of groupIds) {
|
||||
const res: any = await inboxGroupMembers({ groupId: gid, keyword, limit: 100 })
|
||||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
const data = res.data ?? res
|
||||
for (const m of data.list ?? []) {
|
||||
const uid = String(m.user_id ?? '')
|
||||
if (!uid || seen.has(uid)) continue
|
||||
seen.add(uid)
|
||||
merged.push({ user_id: uid, label: m.user_name ? `${m.user_name}(${uid})` : uid })
|
||||
}
|
||||
const res: any = await inboxGroupMembers({ groupIds, keyword, limit: 100 })
|
||||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
const data = res.data ?? res
|
||||
const merged: { user_id: string; label: string }[] = []
|
||||
const seen = new Set<string>()
|
||||
for (const m of data.list ?? []) {
|
||||
const uid = String(m.user_id ?? '')
|
||||
if (!uid || seen.has(uid)) continue
|
||||
seen.add(uid)
|
||||
merged.push({ user_id: uid, label: m.user_name ? `${m.user_name}(${uid})` : uid })
|
||||
}
|
||||
memberOptions.value = merged
|
||||
} else {
|
||||
memberOptions.value = []
|
||||
}
|
||||
memberOptions.value = merged
|
||||
} catch {
|
||||
memberOptions.value = []
|
||||
} finally {
|
||||
@ -349,6 +398,7 @@ async function searchMembers(keyword: string, silent = false) {
|
||||
|
||||
onMounted(() => {
|
||||
void loadStoreOptions()
|
||||
void loadReportDefinitions()
|
||||
})
|
||||
|
||||
async function handleSubmit() {
|
||||
@ -361,10 +411,11 @@ async function handleSubmit() {
|
||||
submitting.value = true
|
||||
try {
|
||||
await saveDeliveryPlan({
|
||||
name: form.name.trim(),
|
||||
store_id: Number(form.store_id),
|
||||
report_code: form.report_code.trim(),
|
||||
// 后端参数为 report_id(报表定义ID,与 reportId 二选一);form 取自列表行的 report_definition_id
|
||||
report_id: Number(form.report_definition_id),
|
||||
schedule_times: form.schedule_times,
|
||||
channel: form.channel,
|
||||
late_grace_minutes: form.late_grace_minutes,
|
||||
remark: form.remark || undefined,
|
||||
...(form.notify_template ? { notify_template: form.notify_template } : {}),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user