diff --git a/src/api/inbox/autoReply.ts b/src/api/inbox/autoReply.ts new file mode 100644 index 00000000..351344d5 --- /dev/null +++ b/src/api/inbox/autoReply.ts @@ -0,0 +1,551 @@ +import type { AxiosRequestConfig } from 'axios' +import request from '@/utils/request' + +const v = '1.0' + +// ============================================================ +// 站内信 v2 可配置回信引擎 —— 配置管理 API(inbox.v2.*) +// +// 说明: +// - 所有接口经 /system 网关,method 形如 inbox.v2.type.list; +// - warehouseId 由服务端从登录上下文注入,前端不传; +// - 系统预设数据(is_system=1 / warehouse_id=null)只读,写操作会被后端拒绝; +// - 写操作后端会自动失效该仓库 v2 配置缓存(TTL 300s),无需前端额外处理。 +// ============================================================ + +/** /system 网关统一响应结构 */ +export interface InboxV2Response { + flag?: string + code?: number + message?: string + data?: T + timestamp?: number +} + +/** 分页信息 */ +export interface InboxV2Pagination { + page: number + pageSize: number + total: number +} + +function call(method: string, data?: Record): Promise> { + return request({ + url: '/system', + method: 'post', + params: { + method, + v, + timestamp: Date.now(), + }, + data: data ?? {}, + // 自定义标记:request 内部据此走 /system 网关(非 axios 标准字段) + isSystemApi: true, + } as AxiosRequestConfig) as unknown as Promise> +} + +/** + * 取网关返回的业务数据(服务层返回值)。 + * 兼容 data 为空时回退到顶层(便于容错)。 + */ +export function unwrapInboxV2Data(res: InboxV2Response | null | undefined): T | null { + if (!res) return null + if (res.data !== null && res.data !== undefined) return res.data + return (res as unknown as T) ?? null +} + +// ─────────────────────────── 类型 ─────────────────────────── + +/** 售后类型(wms_after_sale_type) */ +export interface InboxV2TypeItem { + id: number + /** NULL=系统级(全部仓库可见且只读);非 NULL=该仓库自定义 */ + warehouse_id: number | null + /** 类型编码(order/receiving/entry/stockout 或仓库自定义编码) */ + type: string + name: string + is_system: number + is_enabled: number + sort_order: number + created_at?: string + updated_at?: string +} + +export interface InboxV2TypeListParams { + isEnabled?: number + page?: number + pageSize?: number +} + +export interface InboxV2TypeListData { + list: InboxV2TypeItem[] + pagination: InboxV2Pagination +} + +/** 类型列表(系统级 + 本仓库自定义,分页) */ +export function inboxV2TypeList(data: InboxV2TypeListParams = {}) { + return call('inbox.v2.type.list', data as Record) +} + +export interface InboxV2TypeCreateParams { + /** 类型编码(≤20),仓库内唯一 */ + type: string + /** 类型名称(≤50) */ + name: string + sortOrder?: number +} + +/** 创建仓库自定义类型 */ +export function inboxV2TypeCreate(data: InboxV2TypeCreateParams) { + return call<{ id: number; message: string }>('inbox.v2.type.create', data as unknown as Record) +} + +export interface InboxV2TypeUpdateParams { + id: number + name?: string + isEnabled?: number + sortOrder?: number +} + +/** 更新仓库自定义类型(系统预设拒绝修改) */ +export function inboxV2TypeUpdate(data: InboxV2TypeUpdateParams) { + return call<{ message: string }>('inbox.v2.type.update', data as unknown as Record) +} + +/** 删除仓库自定义类型(有子类型引用时拒绝) */ +export function inboxV2TypeDelete(id: number) { + return call<{ message: string }>('inbox.v2.type.delete', { id }) +} + +// ─────────────────────────── 子类型 ─────────────────────────── + +/** 售后子类型(wms_after_sale_sub_type) */ +export interface InboxV2SubTypeItem { + id: number + warehouse_id: number | null + /** 所属类型编码 */ + type: string + /** 子类型编码 */ + sub_type: string + name: string + is_system: number + is_enabled: number + sort_order: number + created_at?: string + updated_at?: string +} + +export interface InboxV2SubTypeListParams { + type?: string + isEnabled?: number + page?: number + pageSize?: number +} + +export interface InboxV2SubTypeListData { + list: InboxV2SubTypeItem[] + pagination: InboxV2Pagination +} + +/** 子类型列表(系统级 + 本仓库自定义,分页) */ +export function inboxV2SubTypeList(data: InboxV2SubTypeListParams = {}) { + return call('inbox.v2.subType.list', data as Record) +} + +export interface InboxV2SubTypeCreateParams { + /** 所属类型编码(系统级类型或本仓库自定义类型均可) */ + type: string + /** 子类型编码(≤50) */ + subType: string + /** 子类型名称(≤50) */ + name: string + sortOrder?: number +} + +/** 创建仓库自定义子类型 */ +export function inboxV2SubTypeCreate(data: InboxV2SubTypeCreateParams) { + return call<{ id: number; message: string }>('inbox.v2.subType.create', data as unknown as Record) +} + +export interface InboxV2SubTypeUpdateParams { + id: number + name?: string + isEnabled?: number + sortOrder?: number +} + +/** 更新仓库自定义子类型(系统预设拒绝修改) */ +export function inboxV2SubTypeUpdate(data: InboxV2SubTypeUpdateParams) { + return call<{ message: string }>('inbox.v2.subType.update', data as unknown as Record) +} + +/** 删除仓库自定义子类型(有关联引用时拒绝) */ +export function inboxV2SubTypeDelete(id: number) { + return call<{ message: string }>('inbox.v2.subType.delete', { id }) +} + +// ─────────────────────────── 关键词 ─────────────────────────── + +/** 关键词(wms_after_sale_keyword) */ +export interface InboxV2KeywordItem { + id: number + warehouse_id: number | null + sub_type_id: number + keyword: string + is_system: number + is_enabled: number + sort_order: number + created_at?: string + updated_at?: string +} + +export interface InboxV2KeywordListParams { + subTypeId?: number + isEnabled?: number + page?: number + pageSize?: number +} + +export interface InboxV2KeywordListData { + list: InboxV2KeywordItem[] + pagination: InboxV2Pagination +} + +/** 关键词列表 */ +export function inboxV2KeywordList(data: InboxV2KeywordListParams = {}) { + return call('inbox.v2.keyword.list', data as Record) +} + +export interface InboxV2KeywordCreateParams { + subTypeId: number + /** 关键词(≤100),仓库内唯一 */ + keyword: string + sortOrder?: number +} + +/** 创建仓库自定义关键词 */ +export function inboxV2KeywordCreate(data: InboxV2KeywordCreateParams) { + return call<{ id: number; message: string }>('inbox.v2.keyword.create', data as unknown as Record) +} + +export interface InboxV2KeywordUpdateParams { + id: number + keyword?: string + subTypeId?: number + isEnabled?: number + sortOrder?: number +} + +/** 更新仓库自定义关键词(系统预设拒绝修改) */ +export function inboxV2KeywordUpdate(data: InboxV2KeywordUpdateParams) { + return call<{ message: string }>('inbox.v2.keyword.update', data as unknown as Record) +} + +/** 删除仓库自定义关键词 */ +export function inboxV2KeywordDelete(id: number) { + return call<{ message: string }>('inbox.v2.keyword.delete', { id }) +} + +// ─────────────────────────── 取号规则(全局只读) ─────────────────────────── + +/** 取号规则(wms_inbox_number_rule,全局资源,仓库侧只读) */ +export interface InboxV2NumberRuleItem { + id: number + /** 规则名称 */ + name: string + /** 提取目标类型:waybill_no/receiving_no/entry_order_no/stockout_no/order_no/source_order_codes/express_name/plate_no */ + target: string + /** 取号正则(JS 正则源字符串) */ + regexp: string + sort_order: number +} + +/** 取号规则列表(只读,供关联配置选择) */ +export function inboxV2NumberRuleList() { + return call<{ list: InboxV2NumberRuleItem[] }>('inbox.v2.numberRule.list') +} + +// ─────────────────────────── 处理函数 ─────────────────────────── + +/** 处理函数(wms_after_sale_function,代码同步权威) */ +export interface InboxV2FunctionItem { + id: number + function_code: string + name: string + description?: string | null + is_enabled: number + sort_order: number + /** 是否存在于代码注册表(false 表示已下线) */ + in_registry?: boolean | null +} + +export interface InboxV2FunctionListParams { + isEnabled?: number + keyword?: string +} + +/** 处理函数列表 */ +export function inboxV2FunctionList(data: InboxV2FunctionListParams = {}) { + return call<{ list: InboxV2FunctionItem[] }>('inbox.v2.function.list', data as Record) +} + +export interface InboxV2FunctionUpdateParams { + id: number + isEnabled?: number + sortOrder?: number +} + +/** + * 更新函数启用开关 / 排序(function_code 不可改)。 + * + * 注意:函数是否启用**不在「自动回复设置」页面做配置**(由后台代码注册表/运维控制), + * 本方法仅保留后端接口映射以备他用,页面侧不再调用。 + */ +export function inboxV2FunctionUpdate(data: InboxV2FunctionUpdateParams) { + return call<{ message: string }>('inbox.v2.function.update', data as unknown as Record) +} + +// ─────────────────────────── 回复配置 ─────────────────────────── + +/** 回复配置(wms_after_sale_reply) */ +export interface InboxV2ReplyItem { + id: number + /** NULL=系统级回复(只读兜底);非 NULL=仓库级回复(整条覆盖系统级) */ + warehouse_id: number | null + sub_type_id: number + reply: string + /** 1=命中后回复,0=静默(不回复消息) */ + is_reply: number + /** 1=执行函数并登记工单(默认),0=函数照常执行但跳过工单登记 */ + create_work_order: number + /** 未取到单据号时的引导语 */ + no_number_hint: string | null + is_enabled: number + created_at?: string + updated_at?: string +} + +export interface InboxV2ReplyListParams { + subTypeId?: number + isEnabled?: number + page?: number + pageSize?: number +} + +export interface InboxV2ReplyListData { + list: InboxV2ReplyItem[] + pagination: InboxV2Pagination +} + +/** 合并后的生效回复配置(inbox.v2.reply.merged;仓库级整条覆盖系统级,每子类型一条) */ +export interface InboxV2MergedReplyItem { + /** 生效行 id(自定义时为仓库级行 id,继承时为系统级行 id) */ + id: number + sub_type_id: number + type: string + sub_type: string + sub_type_name: string + /** 自定义时为本仓库 id;继承系统级时为 null */ + warehouse_id: number | null + /** 1=本仓库自定义,0=继承系统级 */ + is_custom: number + reply: string + is_reply: number + create_work_order: number + /** 无引导语时为空串 */ + no_number_hint: string + created_at?: string + updated_at?: string +} + +export interface InboxV2ReplyMergedParams { + /** 只看某子类型 */ + subTypeId?: number +} + +/** 合并后的生效配置列表(全量,无分页) */ +export interface InboxV2ReplyMergedData { + /** 每个子类型一条生效配置 */ + merged: InboxV2MergedReplyItem[] + total: number +} + +/** + * 回复配置列表(合并后的**生效配置**,推荐接口)。 + * 每个子类型只返回一条:本仓库有自定义则整条覆盖系统级,读取口径与 v2 引擎一致,前端无需自行合并。 + * 返回结构为 `{ merged, total }`,不分页。 + */ +export function inboxV2ReplyMerged(data: InboxV2ReplyMergedParams = {}) { + return call('inbox.v2.reply.merged', data as Record) +} + +/** + * 回复配置原始行列表(系统级 + 本仓库级,未合并)。 + * @deprecated 页面展示用 {@link inboxV2ReplyMerged}(合并后的生效配置);本接口保留供排查原始行使用。 + */ +export function inboxV2ReplyList(data: InboxV2ReplyListParams = {}) { + return call('inbox.v2.reply.list', data as Record) +} + +/** + * 保存(upsert)仓库级回复配置参数 —— **按传入字段保存,未传字段保持原值**; + * 无仓库级配置时按传入字段创建(默认 reply 空、isReply=1、createWorkOrder=1、isEnabled=1)。 + * 仓库级与系统级为整条覆盖关系,未配置或停用时回退系统级。 + * 注意:createWorkOrder=0 是「函数照常执行、仅跳过工单登记」,不是不执行函数。 + */ +export interface InboxV2ReplySaveParams { + subTypeId: number + /** 回复文案,支持 {keyword}/{express}/{sub_type_name}/{back_text} 占位符(≤2000) */ + reply?: string + /** 1 回复 0 不回复 */ + isReply?: number + /** 1 登记工单 0 不登记工单 */ + createWorkOrder?: number + noNumberHint?: string +} + +/** 保存结果 */ +export interface InboxV2ReplySaveResult { + /** 已有仓库级行的 ID;新建时为 null */ + id: number | null + message: string +} + +/** 保存仓库级回复配置(upsert,推荐接口;未传字段保持原值) */ +export function inboxV2ReplySave(data: InboxV2ReplySaveParams) { + return call('inbox.v2.reply.save', data as unknown as Record) +} + +/** + * 还原仓库级回复配置:删除仓库级行,回退系统级配置(幂等)。 + * 无仓库级配置时同样返回成功(message 为「…已是系统级配置」)。 + */ +export function inboxV2ReplyRestore(subTypeId: number) { + return call<{ message: string }>('inbox.v2.reply.restore', { subTypeId }) +} + +/** @deprecated 见 {@link InboxV2ReplySaveParams} */ +export interface InboxV2ReplyCreateParams { + subTypeId: number + /** 回复文案,支持 {keyword}/{express}/{sub_type_name}/{back_text} 占位符 */ + reply: string + /** 1 回复 0 静默,默认 1 */ + isReply?: number + /** 1 执行函数并登记工单(默认)0 函数照常执行但跳过工单登记 */ + createWorkOrder?: number + noNumberHint?: string + isEnabled?: number +} + +/** + * 创建仓库级回复配置(每子类型仅一条)。 + * @deprecated 后端保留的兼容接口,页面统一改用 {@link inboxV2ReplySave}(upsert)。 + */ +export function inboxV2ReplyCreate(data: InboxV2ReplyCreateParams) { + return call<{ id: number; message: string }>('inbox.v2.reply.create', data as unknown as Record) +} + +export interface InboxV2ReplyUpdateParams { + id: number + reply?: string + isReply?: number + createWorkOrder?: number + noNumberHint?: string + isEnabled?: number +} + +/** + * 更新仓库级回复配置(系统级回复只读)。 + * @deprecated 后端保留的兼容接口,页面统一改用 {@link inboxV2ReplySave}(upsert)。 + */ +export function inboxV2ReplyUpdate(data: InboxV2ReplyUpdateParams) { + return call<{ message: string }>('inbox.v2.reply.update', data as unknown as Record) +} + +/** + * 删除仓库级回复配置(删除后回退系统级)。 + * @deprecated 后端保留的兼容接口,页面统一改用 {@link inboxV2ReplyRestore}(幂等还原)。 + */ +export function inboxV2ReplyDelete(id: number) { + return call<{ message: string }>('inbox.v2.reply.delete', { id }) +} + +// ─────────────────────────── 子类型关联关系 ─────────────────────────── +// set 语义:全量替换(items 传全量数组) + +/** 子类型-处理函数关联行(wms_after_sale_sub_type_function) */ +export interface InboxV2SubTypeFunctionItem { + id: number + sub_type_id: number + function_id: number + sort_order: number +} + +/** 子类型-取号规则关联行(wms_after_sale_sub_type_rule) */ +export interface InboxV2SubTypeRuleItem { + id: number + sub_type_id: number + number_rule_id: number + sort_order: number +} + +/** 子类型-群白名单关联行(wms_after_sale_sub_type_group) */ +export interface InboxV2SubTypeGroupItem { + id: number + sub_type_id: number + /** 群类型:store / warehouse / express */ + group_type: string + /** 群子类型编码 */ + sub_group: string + /** 1=系统预设关联(不可删);0=自定义 */ + is_system: number + sort_order: number +} + +/** 子类型已关联的处理函数列表 */ +export function inboxV2RelationFunctionList(subTypeId: number) { + return call<{ list: InboxV2SubTypeFunctionItem[] }>('inbox.v2.relation.function.list', { subTypeId }) +} + +/** 全量替换子类型的处理函数关联 */ +export function inboxV2RelationFunctionSet( + subTypeId: number, + items: Array<{ functionId: number; sortOrder?: number }> +) { + return call<{ message: string }>('inbox.v2.relation.function.set', { + subTypeId, + items, + } as unknown as Record) +} + +/** 子类型已关联的取号规则列表 */ +export function inboxV2RelationRuleList(subTypeId: number) { + return call<{ list: InboxV2SubTypeRuleItem[] }>('inbox.v2.relation.rule.list', { subTypeId }) +} + +/** 全量替换子类型的取号规则关联 */ +export function inboxV2RelationRuleSet( + subTypeId: number, + items: Array<{ ruleId: number; sortOrder?: number }> +) { + return call<{ message: string }>('inbox.v2.relation.rule.set', { + subTypeId, + items, + } as unknown as Record) +} + +/** 子类型已关联的群白名单列表 */ +export function inboxV2RelationGroupList(subTypeId: number) { + return call<{ list: InboxV2SubTypeGroupItem[] }>('inbox.v2.relation.group.list', { subTypeId }) +} + +/** 替换子类型的群白名单(系统预设行后端自动保留) */ +export function inboxV2RelationGroupSet( + subTypeId: number, + items: Array<{ groupType: string; subGroup: string; sortOrder?: number }> +) { + return call<{ message: string }>('inbox.v2.relation.group.set', { + subTypeId, + items, + } as unknown as Record) +} diff --git a/src/api/inbox/inbox.ts b/src/api/inbox/inbox.ts index f1b1e05a..b39cfa26 100644 --- a/src/api/inbox/inbox.ts +++ b/src/api/inbox/inbox.ts @@ -196,8 +196,9 @@ export interface InboxGroupUpdateParams { subType?: string // 群子类型,值取决于groupType。store→after_sales/finance/receiving。warehouse→receiving/production/stockout/finance/all/customer_service/exception。express→pickup/after_sales storeId?: number // 关联货主ID expressInterfaces?: number[] // 快递接口ID数组,仅groupType=express时生效 - systemExpressCode?: string // 系统快递编码,groupType=express时必填 - aiEnabled?: number // 是否启用AI自动回复: 0=关闭 1=开启,默认1 + systemExpressCode?: string // 系统快递编码,groupType=express时必填。需校验wms_express.code存在 + aiEnabled?: number // 是否启用AI自动回复: 0=关闭 1=开启,默认1(所有群类型均支持,用于灰度测试) + templateReplyEnabled?: number // 是否启用模板消息回复: 0=关闭(普通文本回复) 1=开启(模板消息回复),默认0(所有群类型均支持,独立于aiEnabled) } /** 修改群信息(inbox.group.update) */ diff --git a/src/router/index.ts b/src/router/index.ts index 2471650f..a46b4132 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -152,6 +152,16 @@ export const constantRoutes: RouteRecordRaw[] = [ icon: 'connection', affix: false } + }, + { + path: 'autoReply', + name: 'InboxAutoReply', + component: () => import('@/views/inbox/autoReply/index.vue'), + meta: { + title: '自动回复设置', + icon: 'chat-dot-round', + affix: false + } } ] }, diff --git a/src/router/map.ts b/src/router/map.ts index aac4e457..2ded45f4 100644 --- a/src/router/map.ts +++ b/src/router/map.ts @@ -77,6 +77,8 @@ export const componentMap: Record = { 'system/setting/storeExpressBindingPolicy/index':() => import('@/views/system/setting/storeExpressBindingPolicy/index.vue'), 'inbox/message/index': () => import('@/views/inbox/message/index.vue'), 'inbox/group/index': () => import('@/views/inbox/group/index.vue'), + 'inbox/autoReply/index': () => import('@/views/inbox/autoReply/index.vue'), + 'inbox/autoReply': () => import('@/views/inbox/autoReply/index.vue'), 'express/returnUnpack/index': () => import('@/views/express/returnUnpack/index.vue'), 'express/returnwaybill/index': () => import('@/views/express/returnwaybill/index.vue'), 'express/returnUnpackwork/index': () => import('@/views/express/returnUnpackwork/index.vue'), diff --git a/src/views/inbox/autoReply/autoReply-config.ts b/src/views/inbox/autoReply/autoReply-config.ts new file mode 100644 index 00000000..7aa6440c --- /dev/null +++ b/src/views/inbox/autoReply/autoReply-config.ts @@ -0,0 +1,210 @@ +import type { + InboxV2SubTypeGroupItem, + InboxV2SubTypeItem, + InboxV2TypeItem, +} from '@/api/inbox/autoReply' + +// ============================================================ +// 自动回复设置 - 常量与选项 +// ============================================================ + +/** 群类型选项(对应 wms_inbox_group.group_type) */ +export const groupTypeOptions = [ + { label: '货主群', value: 'store' }, + { label: '仓库群', value: 'warehouse' }, + { label: '快递群', value: 'express' }, +] + +/** 群子类型选项(对应 wms_inbox_group.sub_type,受群类型约束) */ +export const subGroupOptionsMap: Record> = { + store: [ + { label: '售后', value: 'after_sales' }, + { label: '财务', value: 'finance' }, + { label: '收货', value: 'receiving' }, + ], + warehouse: [ + { label: '收货', value: 'receiving' }, + { label: '生产', value: 'production' }, + { label: '出库', value: 'stockout' }, + { label: '财务', value: 'finance' }, + { label: '全体', value: 'all' }, + { label: '客服', value: 'customer_service' }, + { label: '异常', value: 'exception' }, + ], + express: [ + { label: '揽收', value: 'pickup' }, + { label: '售后', value: 'after_sales' }, + ], +} + +/** 群类型通配:全部群(对应 group_type='*') */ +export const wildcardGroupTypeOption = { label: '全部', value: '*' } + +/** 群子类型通配:该群类型下所有子类型(对应 sub_group='*') */ +export const wildcardSubGroupOption = { label: '全部', value: '*' } + +/** 群类型选项(含通配「全部」,置顶) */ +export function getGroupTypeOptions() { + return [ wildcardGroupTypeOption, ...groupTypeOptions ] +} + +/** 群子类型选项(含通配「全部」,置顶) */ +export function getSubGroupOptions(groupType: string) { + return [ wildcardSubGroupOption, ...(subGroupOptionsMap[groupType] ?? []) ] +} + +export function groupTypeLabel(groupType: string): string { + if (!groupType) return '-' + if (groupType === '*') return wildcardGroupTypeOption.label + return groupTypeOptions.find((item) => item.value === groupType)?.label ?? groupType +} + +export function subGroupLabel(groupType: string, subGroup: string): string { + if (!subGroup) return '-' + if (subGroup === '*') return wildcardSubGroupOption.label + const hit = getSubGroupOptions(groupType).find((item) => item.value === subGroup) + return hit?.label ?? subGroup +} + +/** 取号目标类型中文标签(对应 wms_inbox_number_rule.target) */ +export const numberRuleTargetLabels: Record = { + waybill_no: '运单号', + receiving_no: '收货单号', + entry_order_no: '入库单号', + stockout_no: '出库单号', + order_no: '订单编号', + source_order_codes: '平台订单号', + express_name: '快递名称', + plate_no: '车牌号', +} + +export function numberRuleTargetLabel(target: string): string { + return numberRuleTargetLabels[target] ?? target ?? '-' +} + +/** 回复文案支持的占位符(后端 rules 引擎替换;back_text 来自函数返回 data.back_text) */ +export const replyPlaceholders = ['{keyword}', '{express}', '{sub_type_name}', '{back_text}'] + +/** + * 判断记录是否为系统预设(只读)。 + * 系统级:warehouse_id 为 null,或 is_system=1。 + * 注意:关键词与回复属仓库级数据,可挂在系统级子类型下(后端只对子类型做存在性校验); + * 处理函数/取号规则/群白名单的关联写操作仍要求本仓库自定义子类型。 + */ +export function isSystemRecord(row: { + warehouse_id?: number | null + is_system?: number | null +}): boolean { + if (Number(row?.is_system) === 1) return true + const wid = row?.warehouse_id + return wid === null || wid === undefined +} + +/** 系统预设标记文案 */ +export const systemTagText = '系统预设' + +// ============================================================ +// 表格列配置 +// ============================================================ + +export interface AutoReplyColumn { + prop: string + label: string + width?: string + minWidth?: string + align?: 'left' | 'center' | 'right' + showOverflowTooltip?: boolean +} + +/** 类型列表列 */ +export const typeColumns: AutoReplyColumn[] = [ + { prop: 'type', label: '类型编码', minWidth: '120', showOverflowTooltip: true }, + { prop: 'name', label: '类型名称', minWidth: '120', showOverflowTooltip: true }, + { prop: 'source', label: '来源', width: '90', align: 'center' }, + { prop: 'is_enabled', label: '状态', width: '80', align: 'center' }, + { prop: 'sort_order', label: '排序', width: '70', align: 'center' }, +] + +/** 子类型列表列 */ +export const subTypeColumns: AutoReplyColumn[] = [ + { prop: 'sub_type', label: '子类型编码', minWidth: '130', showOverflowTooltip: true }, + { prop: 'name', label: '子类型名称', minWidth: '120', showOverflowTooltip: true }, + { prop: 'source', label: '来源', width: '90', align: 'center' }, + { prop: 'is_enabled', label: '状态', width: '80', align: 'center' }, + { prop: 'sort_order', label: '排序', width: '70', align: 'center' }, +] + +/** 关键词列表列 */ +export const keywordColumns: AutoReplyColumn[] = [ + { prop: 'keyword', label: '关键词', minWidth: '180', showOverflowTooltip: true }, + { prop: 'source', label: '来源', width: '90', align: 'center' }, + { prop: 'is_enabled', label: '启用', width: '80', align: 'center' }, + { prop: 'sort_order', label: '匹配优先级', width: '100', align: 'center' }, + { prop: 'actions', label: '操作', width: '130', align: 'center' }, +] + +/** 处理函数关联列 */ +export const functionColumns: AutoReplyColumn[] = [ + { prop: 'sort_order', label: '顺序', width: '70', align: 'center' }, + { prop: 'name', label: '函数名称', minWidth: '150', showOverflowTooltip: true }, + { prop: 'function_code', label: '函数编码', minWidth: '160', showOverflowTooltip: true }, + { prop: 'status', label: '状态', width: '160', align: 'center' }, + { prop: 'actions', label: '操作', width: '130', align: 'center' }, +] + +/** 取号规则关联列 */ +export const numberRuleColumns: AutoReplyColumn[] = [ + { prop: 'sort_order', label: '顺序', width: '70', align: 'center' }, + { prop: 'name', label: '规则名称', minWidth: '150', showOverflowTooltip: true }, + { prop: 'target_label', label: '提取目标', width: '110', align: 'center' }, + { prop: 'regexp', label: '取号正则', minWidth: '200', showOverflowTooltip: true }, + { prop: 'actions', label: '操作', width: '130', align: 'center' }, +] + +/** 群白名单列 */ +export const groupColumns: AutoReplyColumn[] = [ + { prop: 'group_type_label', label: '群类型', width: '110', align: 'center' }, + { prop: 'sub_group_label', label: '群子类型', width: '130', align: 'center' }, + { prop: 'source', label: '来源', width: '90', align: 'center' }, + { prop: 'sort_order', label: '排序', width: '80', align: 'center' }, + { prop: 'actions', label: '操作', width: '90', align: 'center' }, +] + +// ============================================================ +// 类型 / 子类型 / 关键词 / 回复 归一化辅助 +// ============================================================ + +/** 归一化布尔/数字开关 */ +export function toFlag(value: unknown, fallback = 0): number { + if (value === undefined || value === null || value === '') return fallback + return Number(value) === 1 || value === true || value === 'true' ? 1 : 0 +} + +export type AutoReplyTreeNode = { + key: string + kind: 'type' | 'subType' + label: string + /** 所属类型编码 */ + typeCode: string + subTypeId?: number + isSystem: boolean + isEnabled: boolean + typeRaw?: InboxV2TypeItem + subTypeRaw?: InboxV2SubTypeItem + children?: AutoReplyTreeNode[] +} + +/** 类型节点 key */ +export function typeNodeKey(typeCode: string) { + return `type:${typeCode}` +} + +/** 子类型节点 key */ +export function subTypeNodeKey(subTypeId: number) { + return `subType:${subTypeId}` +} + +/** 群白名单行是否可删(系统预设关联不可删) */ +export function isGroupRelationRemovable(row: InboxV2SubTypeGroupItem): boolean { + return Number(row?.is_system) !== 1 +} diff --git a/src/views/inbox/autoReply/components/FunctionPanel.vue b/src/views/inbox/autoReply/components/FunctionPanel.vue new file mode 100644 index 00000000..f6f30bc7 --- /dev/null +++ b/src/views/inbox/autoReply/components/FunctionPanel.vue @@ -0,0 +1,295 @@ + + + + + diff --git a/src/views/inbox/autoReply/components/GroupPanel.vue b/src/views/inbox/autoReply/components/GroupPanel.vue new file mode 100644 index 00000000..f0a85b38 --- /dev/null +++ b/src/views/inbox/autoReply/components/GroupPanel.vue @@ -0,0 +1,273 @@ + + + + + diff --git a/src/views/inbox/autoReply/components/KeywordPanel.vue b/src/views/inbox/autoReply/components/KeywordPanel.vue new file mode 100644 index 00000000..3fbe41ea --- /dev/null +++ b/src/views/inbox/autoReply/components/KeywordPanel.vue @@ -0,0 +1,310 @@ + + + + + diff --git a/src/views/inbox/autoReply/components/NumberRulePanel.vue b/src/views/inbox/autoReply/components/NumberRulePanel.vue new file mode 100644 index 00000000..7bf41ece --- /dev/null +++ b/src/views/inbox/autoReply/components/NumberRulePanel.vue @@ -0,0 +1,267 @@ + + + + + diff --git a/src/views/inbox/autoReply/components/ReplyPanel.vue b/src/views/inbox/autoReply/components/ReplyPanel.vue new file mode 100644 index 00000000..c9166792 --- /dev/null +++ b/src/views/inbox/autoReply/components/ReplyPanel.vue @@ -0,0 +1,244 @@ + + + + + diff --git a/src/views/inbox/autoReply/components/SubTypeFormDialog.vue b/src/views/inbox/autoReply/components/SubTypeFormDialog.vue new file mode 100644 index 00000000..5cc9e2e6 --- /dev/null +++ b/src/views/inbox/autoReply/components/SubTypeFormDialog.vue @@ -0,0 +1,163 @@ + + + diff --git a/src/views/inbox/autoReply/components/TypeFormDialog.vue b/src/views/inbox/autoReply/components/TypeFormDialog.vue new file mode 100644 index 00000000..2677df8c --- /dev/null +++ b/src/views/inbox/autoReply/components/TypeFormDialog.vue @@ -0,0 +1,149 @@ + + + diff --git a/src/views/inbox/autoReply/components/panel.scss b/src/views/inbox/autoReply/components/panel.scss new file mode 100644 index 00000000..5d7d1875 --- /dev/null +++ b/src/views/inbox/autoReply/components/panel.scss @@ -0,0 +1,62 @@ +// 自动回复设置 - 配置面板通用样式(由各子面板 @use 复用) + +.ar-panel { + display: flex; + flex-direction: column; + gap: 8px; + height: 100%; + min-height: 0; +} + +.ar-panel-toolbar { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + flex-wrap: wrap; + flex-shrink: 0; +} + +.ar-panel-toolbar-left { + flex: 1; + min-width: 0; +} + +.ar-panel-toolbar-right { + display: flex; + align-items: center; + gap: 8px; + flex-shrink: 0; +} + +.ar-panel-tip { + font-size: 12px; + color: #909399; + line-height: 1.5; +} + +.ar-panel-table { + flex: 1; + min-height: 0; + display: flex; + flex-direction: column; +} + +.ar-panel-pagination { + display: flex; + justify-content: flex-end; + flex-shrink: 0; +} + +.ar-form-tip { + margin-left: 10px; + font-size: 12px; + color: #909399; +} + +.ar-inline-empty { + padding: 24px 0; + text-align: center; + color: #909399; + font-size: 13px; +} diff --git a/src/views/inbox/autoReply/index.vue b/src/views/inbox/autoReply/index.vue new file mode 100644 index 00000000..9a6f102c --- /dev/null +++ b/src/views/inbox/autoReply/index.vue @@ -0,0 +1,1018 @@ + + + + + diff --git a/src/views/inbox/group/group-config.ts b/src/views/inbox/group/group-config.ts index f3ff33f6..aa58a7f3 100644 --- a/src/views/inbox/group/group-config.ts +++ b/src/views/inbox/group/group-config.ts @@ -61,6 +61,7 @@ export const groupColumns = [ { prop: 'express_interfaces', label: '快递接口', minWidth: '160', showOverflowTooltip: true }, { prop: 'system_express_name', label: '系统快递', width: '110', showOverflowTooltip: true }, { prop: 'ai_enabled', label: 'AI回复', width: '90' }, + { prop: 'template_reply_enabled', label: '模板回复', width: '90' }, { prop: 'is_blocked', label: '状态', width: '80' }, { prop: 'created_at', label: '创建时间', width: '170' }, { prop: 'updated_at', label: '更新时间', width: '170' }, diff --git a/src/views/inbox/group/index.vue b/src/views/inbox/group/index.vue index 79dee049..bd0b3fed 100644 --- a/src/views/inbox/group/index.vue +++ b/src/views/inbox/group/index.vue @@ -86,6 +86,12 @@ + +