feat: 审批配置/待办页,价格发布提交审批提示
Some checks failed
Build and Deploy Front / deploy (push) Failing after 7s
Some checks failed
Build and Deploy Front / deploy (push) Failing after 7s
系统管理接入审批菜单同步;价格发布返回 PendingApproval 时提示审批单号。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
f77c478981
commit
dc3da65e1c
@ -217,15 +217,27 @@ export async function getSalesProductPublishSyncStatus(params: {
|
||||
}>(res.data)
|
||||
}
|
||||
|
||||
export type SalesProductPublishResult = {
|
||||
decision?: string
|
||||
Decision?: string
|
||||
approvalInstanceId?: number
|
||||
ApprovalInstanceId?: number
|
||||
approvalInstanceNo?: string
|
||||
ApprovalInstanceNo?: string
|
||||
message?: string
|
||||
Message?: string
|
||||
}
|
||||
|
||||
export async function publishSalesProduct(body: {
|
||||
salesProductId: number | string
|
||||
operatorType: string
|
||||
description?: string
|
||||
/** 价格发布必填:AI 风险分析报告原文 */
|
||||
aiAnalysisReport?: string
|
||||
}) {
|
||||
}): Promise<SalesProductPublishResult | null> {
|
||||
const res = await axiosInstance.post(omsUrl('/channel/sales-product/publish'), body)
|
||||
assertBusinessOk(res.data)
|
||||
return unwrapData<SalesProductPublishResult | null>(res.data)
|
||||
}
|
||||
|
||||
export async function rollbackSalesProductPublish(body: {
|
||||
|
||||
312
src/api/system/approval.ts
Normal file
312
src/api/system/approval.ts
Normal file
@ -0,0 +1,312 @@
|
||||
import { axiosInstance } from '@/api/rbac'
|
||||
import {
|
||||
assertBusinessOk,
|
||||
extractOmsRequestError,
|
||||
omsUrl,
|
||||
parseListPayload,
|
||||
unwrapData,
|
||||
} from '@/api/oms/common'
|
||||
|
||||
export interface ApprovalDefinitionDto {
|
||||
id: number
|
||||
operationCode: string
|
||||
operationName: string
|
||||
isEnabled: boolean
|
||||
conditionFormula?: string | null
|
||||
approverType: string
|
||||
approverIds: string[]
|
||||
forbidSelfApprove: boolean
|
||||
remark?: string | null
|
||||
createTime?: string
|
||||
updateTime?: string
|
||||
}
|
||||
|
||||
export interface ApprovalCatalogItem {
|
||||
code: string
|
||||
name: string
|
||||
module: string
|
||||
supportsCondition: boolean
|
||||
conditionHint: string
|
||||
}
|
||||
|
||||
export interface ApprovalInstanceDto {
|
||||
id: number
|
||||
instanceNo: string
|
||||
operationCode: string
|
||||
bizKey: string
|
||||
title: string
|
||||
status: number
|
||||
statusName: string
|
||||
applicantUserId: number
|
||||
applicantUserGuid: string
|
||||
applicantUserName?: string | null
|
||||
payloadJson?: string | null
|
||||
summaryJson?: string | null
|
||||
definitionSnapshot?: string | null
|
||||
currentTaskId?: number | null
|
||||
createTime?: string
|
||||
completedTime?: string | null
|
||||
executedTime?: string | null
|
||||
executeMessage?: string | null
|
||||
concurrencyStamp?: string | null
|
||||
canApprove?: boolean
|
||||
canWithdraw?: boolean
|
||||
events?: ApprovalEventDto[]
|
||||
}
|
||||
|
||||
export interface ApprovalEventDto {
|
||||
id: number
|
||||
eventType: string
|
||||
fromStatus?: number | null
|
||||
toStatus?: number | null
|
||||
operatorUserName?: string | null
|
||||
message?: string | null
|
||||
createTime?: string
|
||||
}
|
||||
|
||||
function pickString(row: Record<string, unknown>, ...keys: string[]) {
|
||||
for (const key of keys) {
|
||||
const value = row[key]
|
||||
if (value != null && String(value).trim()) return String(value).trim()
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function pickBool(row: Record<string, unknown>, ...keys: string[]) {
|
||||
for (const key of keys) {
|
||||
const value = row[key]
|
||||
if (typeof value === 'boolean') return value
|
||||
if (value === 1 || value === '1' || value === 'true') return true
|
||||
if (value === 0 || value === '0' || value === 'false') return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function pickNumber(row: Record<string, unknown>, ...keys: string[]) {
|
||||
for (const key of keys) {
|
||||
const value = row[key]
|
||||
if (typeof value === 'number' && Number.isFinite(value)) return value
|
||||
const n = Number(value)
|
||||
if (Number.isFinite(n)) return n
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
function pickIds(row: Record<string, unknown>): string[] {
|
||||
const raw = row.approverIds ?? row.ApproverIds
|
||||
if (Array.isArray(raw)) return raw.map((x) => String(x).trim()).filter(Boolean)
|
||||
if (typeof raw === 'string') {
|
||||
return raw.split(/[,;,\s]+/).map((x) => x.trim()).filter(Boolean)
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
export function mapDefinitionRow(row: Record<string, unknown>): ApprovalDefinitionDto {
|
||||
return {
|
||||
id: pickNumber(row, 'id', 'Id'),
|
||||
operationCode: pickString(row, 'operationCode', 'OperationCode'),
|
||||
operationName: pickString(row, 'operationName', 'OperationName'),
|
||||
isEnabled: pickBool(row, 'isEnabled', 'IsEnabled'),
|
||||
conditionFormula: pickString(row, 'conditionFormula', 'ConditionFormula') || null,
|
||||
approverType: pickString(row, 'approverType', 'ApproverType') || 'User',
|
||||
approverIds: pickIds(row),
|
||||
forbidSelfApprove: pickBool(row, 'forbidSelfApprove', 'ForbidSelfApprove'),
|
||||
remark: pickString(row, 'remark', 'Remark') || null,
|
||||
createTime: pickString(row, 'createTime', 'CreateTime') || undefined,
|
||||
updateTime: pickString(row, 'updateTime', 'UpdateTime') || undefined,
|
||||
}
|
||||
}
|
||||
|
||||
export function mapInstanceRow(row: Record<string, unknown>): ApprovalInstanceDto {
|
||||
const eventsRaw = (row.events ?? row.Events) as Record<string, unknown>[] | undefined
|
||||
return {
|
||||
id: pickNumber(row, 'id', 'Id'),
|
||||
instanceNo: pickString(row, 'instanceNo', 'InstanceNo'),
|
||||
operationCode: pickString(row, 'operationCode', 'OperationCode'),
|
||||
bizKey: pickString(row, 'bizKey', 'BizKey'),
|
||||
title: pickString(row, 'title', 'Title'),
|
||||
status: pickNumber(row, 'status', 'Status'),
|
||||
statusName: pickString(row, 'statusName', 'StatusName'),
|
||||
applicantUserId: pickNumber(row, 'applicantUserId', 'ApplicantUserId'),
|
||||
applicantUserGuid: pickString(row, 'applicantUserGuid', 'ApplicantUserGuid'),
|
||||
applicantUserName: pickString(row, 'applicantUserName', 'ApplicantUserName') || null,
|
||||
payloadJson: pickString(row, 'payloadJson', 'PayloadJson') || null,
|
||||
summaryJson: pickString(row, 'summaryJson', 'SummaryJson') || null,
|
||||
definitionSnapshot: pickString(row, 'definitionSnapshot', 'DefinitionSnapshot') || null,
|
||||
currentTaskId: pickNumber(row, 'currentTaskId', 'CurrentTaskId') || null,
|
||||
createTime: pickString(row, 'createTime', 'CreateTime') || undefined,
|
||||
completedTime: pickString(row, 'completedTime', 'CompletedTime') || null,
|
||||
executedTime: pickString(row, 'executedTime', 'ExecutedTime') || null,
|
||||
executeMessage: pickString(row, 'executeMessage', 'ExecuteMessage') || null,
|
||||
concurrencyStamp: pickString(row, 'concurrencyStamp', 'ConcurrencyStamp') || null,
|
||||
canApprove: pickBool(row, 'canApprove', 'CanApprove'),
|
||||
canWithdraw: pickBool(row, 'canWithdraw', 'CanWithdraw'),
|
||||
events: Array.isArray(eventsRaw)
|
||||
? eventsRaw.map((e) => ({
|
||||
id: pickNumber(e, 'id', 'Id'),
|
||||
eventType: pickString(e, 'eventType', 'EventType'),
|
||||
fromStatus: pickNumber(e, 'fromStatus', 'FromStatus') || null,
|
||||
toStatus: pickNumber(e, 'toStatus', 'ToStatus') || null,
|
||||
operatorUserName: pickString(e, 'operatorUserName', 'OperatorUserName') || null,
|
||||
message: pickString(e, 'message', 'Message') || null,
|
||||
createTime: pickString(e, 'createTime', 'CreateTime') || undefined,
|
||||
}))
|
||||
: [],
|
||||
}
|
||||
}
|
||||
|
||||
export async function getApprovalDefinitionList(params: {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
keyword?: string
|
||||
isEnabled?: boolean | null
|
||||
}) {
|
||||
const res = await axiosInstance.get(omsUrl('/system/approval/definition/list'), { params })
|
||||
const { items, total } = parseListPayload(res.data)
|
||||
return {
|
||||
items: (items || []).map((row) => mapDefinitionRow(row as Record<string, unknown>)),
|
||||
total,
|
||||
}
|
||||
}
|
||||
|
||||
export async function getApprovalCatalog() {
|
||||
const res = await axiosInstance.get(omsUrl('/system/approval/operation-catalog'))
|
||||
const payload = unwrapData<Record<string, unknown>[] | null>(res.data)
|
||||
if (!Array.isArray(payload)) return [] as ApprovalCatalogItem[]
|
||||
return payload.map((row) => ({
|
||||
code: pickString(row, 'code', 'Code'),
|
||||
name: pickString(row, 'name', 'Name'),
|
||||
module: pickString(row, 'module', 'Module'),
|
||||
supportsCondition: pickBool(row, 'supportsCondition', 'SupportsCondition'),
|
||||
conditionHint: pickString(row, 'conditionHint', 'ConditionHint'),
|
||||
}))
|
||||
}
|
||||
|
||||
export async function saveApprovalDefinition(body: {
|
||||
id?: number
|
||||
operationCode: string
|
||||
isEnabled: boolean
|
||||
conditionFormula?: string | null
|
||||
approverType: string
|
||||
approverIds: string[]
|
||||
forbidSelfApprove: boolean
|
||||
remark?: string | null
|
||||
}) {
|
||||
try {
|
||||
const res = await axiosInstance.post(omsUrl('/system/approval/definition/save'), body)
|
||||
assertBusinessOk(res.data)
|
||||
return mapDefinitionRow((unwrapData(res.data) || {}) as Record<string, unknown>)
|
||||
} catch (e) {
|
||||
throw new Error(extractOmsRequestError(e))
|
||||
}
|
||||
}
|
||||
|
||||
export async function enableApprovalDefinition(id: number, isEnabled: boolean) {
|
||||
try {
|
||||
const res = await axiosInstance.post(omsUrl('/system/approval/definition/enable'), { id, isEnabled })
|
||||
assertBusinessOk(res.data)
|
||||
} catch (e) {
|
||||
throw new Error(extractOmsRequestError(e))
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteApprovalDefinition(id: number) {
|
||||
try {
|
||||
const res = await axiosInstance.post(omsUrl('/system/approval/definition/delete'), { id })
|
||||
assertBusinessOk(res.data)
|
||||
} catch (e) {
|
||||
throw new Error(extractOmsRequestError(e))
|
||||
}
|
||||
}
|
||||
|
||||
export async function getApprovalMyTodo(params: {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
keyword?: string
|
||||
}) {
|
||||
const res = await axiosInstance.get(omsUrl('/system/approval/engine/my-todo'), { params })
|
||||
const { items, total } = parseListPayload(res.data)
|
||||
return {
|
||||
items: (items || []).map((row) => mapInstanceRow(row as Record<string, unknown>)),
|
||||
total,
|
||||
}
|
||||
}
|
||||
|
||||
export async function getApprovalMySubmitted(params: {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
keyword?: string
|
||||
status?: number | null
|
||||
}) {
|
||||
const res = await axiosInstance.get(omsUrl('/system/approval/engine/my-submitted'), { params })
|
||||
const { items, total } = parseListPayload(res.data)
|
||||
return {
|
||||
items: (items || []).map((row) => mapInstanceRow(row as Record<string, unknown>)),
|
||||
total,
|
||||
}
|
||||
}
|
||||
|
||||
export async function getApprovalDetail(id: number) {
|
||||
const res = await axiosInstance.get(omsUrl('/system/approval/engine/detail'), { params: { id } })
|
||||
return mapInstanceRow((unwrapData(res.data) || {}) as Record<string, unknown>)
|
||||
}
|
||||
|
||||
export async function approveApproval(body: {
|
||||
instanceId: number
|
||||
comment?: string
|
||||
concurrencyStamp?: string | null
|
||||
}) {
|
||||
try {
|
||||
const res = await axiosInstance.post(omsUrl('/system/approval/engine/approve'), body)
|
||||
assertBusinessOk(res.data)
|
||||
} catch (e) {
|
||||
throw new Error(extractOmsRequestError(e))
|
||||
}
|
||||
}
|
||||
|
||||
export async function rejectApproval(body: {
|
||||
instanceId: number
|
||||
comment: string
|
||||
concurrencyStamp?: string | null
|
||||
}) {
|
||||
try {
|
||||
const res = await axiosInstance.post(omsUrl('/system/approval/engine/reject'), body)
|
||||
assertBusinessOk(res.data)
|
||||
} catch (e) {
|
||||
throw new Error(extractOmsRequestError(e))
|
||||
}
|
||||
}
|
||||
|
||||
export async function withdrawApproval(body: {
|
||||
instanceId: number
|
||||
comment?: string
|
||||
concurrencyStamp?: string | null
|
||||
}) {
|
||||
try {
|
||||
const res = await axiosInstance.post(omsUrl('/system/approval/engine/withdraw'), body)
|
||||
assertBusinessOk(res.data)
|
||||
} catch (e) {
|
||||
throw new Error(extractOmsRequestError(e))
|
||||
}
|
||||
}
|
||||
|
||||
export async function simulateApprovalSubmit(body: {
|
||||
operationCode?: string
|
||||
bizKey?: string
|
||||
title?: string
|
||||
payload?: unknown
|
||||
summary?: unknown
|
||||
}) {
|
||||
try {
|
||||
const res = await axiosInstance.post(omsUrl('/system/approval/engine/simulate-submit'), body)
|
||||
assertBusinessOk(res.data)
|
||||
return unwrapData(res.data) as {
|
||||
decision?: string
|
||||
instanceId?: number
|
||||
instanceNo?: string
|
||||
message?: string
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error(extractOmsRequestError(e))
|
||||
}
|
||||
}
|
||||
@ -1111,6 +1111,18 @@ const CORE_GROUPS: PageButtonGroup[] = [
|
||||
{ code: 'SaveConfig', name: '保存配置' },
|
||||
{ code: 'TestConnection', name: '测试连接' },
|
||||
]),
|
||||
B('System.ApprovalDefinition', [
|
||||
{ code: 'Query', name: '查询' },
|
||||
{ code: 'Create', name: '新增' },
|
||||
{ code: 'Update', name: '修改' },
|
||||
{ code: 'Delete', name: '删除' },
|
||||
{ code: 'Enable', name: '启停' },
|
||||
]),
|
||||
B('System.ApprovalTask', [
|
||||
{ code: 'Query', name: '查询' },
|
||||
{ code: 'Approve', name: '通过' },
|
||||
{ code: 'Reject', name: '驳回' },
|
||||
]),
|
||||
|
||||
// ── 小红书 ──
|
||||
B('Xhs.Agent', [
|
||||
|
||||
@ -35,6 +35,13 @@ export default {
|
||||
'common.clear': 'Clear',
|
||||
'common.delete': 'Delete',
|
||||
'common.saveSuccess': 'Save successful',
|
||||
'common.saveFailed': 'Save failed',
|
||||
'common.success': 'Success',
|
||||
'common.failed': 'Failed',
|
||||
'common.loadFailed': 'Load failed',
|
||||
'common.deleteSuccess': 'Deleted',
|
||||
'common.deleteFailed': 'Delete failed',
|
||||
'common.edit': 'Edit',
|
||||
'common.importFailed': 'Import failed',
|
||||
'common.operationFailed': 'Operation failed',
|
||||
'pagination.pageExceeded': 'Page number exceeds maximum limit, automatically jumped to page {max}',
|
||||
@ -1450,6 +1457,63 @@ export default {
|
||||
'menu.system.dataPermUsers': 'User Data Permission',
|
||||
'menu.system.dataPermTemplates': 'Permission Templates',
|
||||
'menu.system.dataPermAudit': 'Permission Audit',
|
||||
'menu.system.approvalDefinition': 'Approval Config',
|
||||
'menu.system.approvalInbox': 'Approval Inbox',
|
||||
|
||||
'system.approval.definition.searchPlaceholder': 'Operation code / name',
|
||||
'system.approval.definition.enabledFilter': 'Status',
|
||||
'system.approval.definition.enabled': 'Enabled',
|
||||
'system.approval.definition.disabled': 'Disabled',
|
||||
'system.approval.definition.addTitle': 'Add approval config',
|
||||
'system.approval.definition.editTitle': 'Edit approval config',
|
||||
'system.approval.definition.operationCode': 'Operation',
|
||||
'system.approval.definition.operationPlaceholder': 'Select operation',
|
||||
'system.approval.definition.approverType': 'Approver type',
|
||||
'system.approval.definition.approverUser': 'Users',
|
||||
'system.approval.definition.approverRole': 'Roles',
|
||||
'system.approval.definition.approvers': 'Approvers',
|
||||
'system.approval.definition.userPlaceholder': 'Select users',
|
||||
'system.approval.definition.rolePlaceholder': 'Select roles',
|
||||
'system.approval.definition.condition': 'Condition',
|
||||
'system.approval.definition.conditionPlaceholder': 'Optional; empty means always require approval when enabled',
|
||||
'system.approval.definition.forbidSelf': 'Forbid self-approve',
|
||||
'system.approval.definition.remark': 'Remark',
|
||||
'system.approval.definition.toggle': 'Enable/Disable',
|
||||
'system.approval.definition.simulate': 'Simulate submit',
|
||||
'system.approval.definition.simulateTitle': 'Approval engine simulation',
|
||||
'system.approval.definition.deleteConfirm': 'Delete approval config for "{name}"?',
|
||||
'system.approval.definition.col.operation': 'Operation',
|
||||
'system.approval.definition.col.code': 'Code',
|
||||
'system.approval.definition.col.approverType': 'Type',
|
||||
'system.approval.definition.col.approvers': 'Approvers',
|
||||
'system.approval.definition.col.enabled': 'Status',
|
||||
'system.approval.definition.col.updateTime': 'Updated',
|
||||
'system.approval.definition.rules.operation': 'Operation is required',
|
||||
'system.approval.definition.rules.approverType': 'Approver type is required',
|
||||
'system.approval.definition.rules.approvers': 'Approvers are required',
|
||||
|
||||
'system.approval.inbox.tabTodo': 'My tasks',
|
||||
'system.approval.inbox.tabSubmitted': 'Submitted by me',
|
||||
'system.approval.inbox.tabsAria': 'Approval inbox tabs',
|
||||
'system.approval.inbox.searchPlaceholder': 'No. / title / operation',
|
||||
'system.approval.inbox.detailTitle': 'Approval detail',
|
||||
'system.approval.inbox.detail': 'Detail',
|
||||
'system.approval.inbox.approve': 'Approve',
|
||||
'system.approval.inbox.reject': 'Reject',
|
||||
'system.approval.inbox.withdraw': 'Withdraw',
|
||||
'system.approval.inbox.payload': 'Payload',
|
||||
'system.approval.inbox.timeline': 'Timeline',
|
||||
'system.approval.inbox.rejectPlaceholder': 'Rejection reason',
|
||||
'system.approval.inbox.rejectRequired': 'Rejection reason is required',
|
||||
'system.approval.inbox.approveConfirm': 'Approve instance {no}?',
|
||||
'system.approval.inbox.withdrawConfirm': 'Withdraw instance {no}?',
|
||||
'system.approval.inbox.col.instanceNo': 'No.',
|
||||
'system.approval.inbox.col.title': 'Title',
|
||||
'system.approval.inbox.col.operation': 'Operation',
|
||||
'system.approval.inbox.col.status': 'Status',
|
||||
'system.approval.inbox.col.applicant': 'Applicant',
|
||||
'system.approval.inbox.col.createTime': 'Submitted at',
|
||||
|
||||
'system.dataPerm.users.title': 'User Data Permission',
|
||||
'system.dataPerm.users.desc': 'Configure direct five-dimension permissions for internal users',
|
||||
'system.dataPerm.users.loading': 'Loading users...',
|
||||
@ -5388,6 +5452,8 @@ export default {
|
||||
'channel.salesProducts.publish.effectiveTime': 'Effective time',
|
||||
'channel.salesProducts.publish.effectiveTimeHint': 'Leave empty for immediate effect',
|
||||
'channel.salesProducts.publish.success': 'Published successfully',
|
||||
'channel.salesProducts.publish.pendingApproval': 'Submitted for approval ({no}); takes effect after approval',
|
||||
'channel.salesProducts.publish.pendingApprovalFallback': 'Submitted for approval; takes effect after approval',
|
||||
'channel.salesProducts.publish.fail': 'Publish failed',
|
||||
'channel.salesProducts.publish.status.synced': 'Content matches the live cache; no republish needed',
|
||||
'channel.salesProducts.publish.status.changed': '{count} change(s) detected; confirm to update the live cache',
|
||||
|
||||
@ -35,6 +35,13 @@ export default {
|
||||
'common.clear': '清空',
|
||||
'common.delete': '删除',
|
||||
'common.saveSuccess': '保存成功',
|
||||
'common.saveFailed': '保存失败',
|
||||
'common.success': '操作成功',
|
||||
'common.failed': '操作失败',
|
||||
'common.loadFailed': '加载失败',
|
||||
'common.deleteSuccess': '删除成功',
|
||||
'common.deleteFailed': '删除失败',
|
||||
'common.edit': '编辑',
|
||||
'common.importFailed': '导入失败',
|
||||
'common.operationFailed': '操作失败',
|
||||
'pagination.pageExceeded': '页码超出最大限制,已自动跳转到第 {max} 页',
|
||||
@ -1441,6 +1448,62 @@ export default {
|
||||
'menu.system.dataPermUsers': '用户数据权限',
|
||||
'menu.system.dataPermTemplates': '权限模板',
|
||||
'menu.system.dataPermAudit': '权限审计',
|
||||
'menu.system.approvalDefinition': '审批配置',
|
||||
'menu.system.approvalInbox': '审批待办',
|
||||
|
||||
'system.approval.definition.searchPlaceholder': '操作编码/名称',
|
||||
'system.approval.definition.enabledFilter': '启停状态',
|
||||
'system.approval.definition.enabled': '启用',
|
||||
'system.approval.definition.disabled': '停用',
|
||||
'system.approval.definition.addTitle': '新增审批配置',
|
||||
'system.approval.definition.editTitle': '编辑审批配置',
|
||||
'system.approval.definition.operationCode': '操作',
|
||||
'system.approval.definition.operationPlaceholder': '选择可审批操作',
|
||||
'system.approval.definition.approverType': '审批人类型',
|
||||
'system.approval.definition.approverUser': '指定用户',
|
||||
'system.approval.definition.approverRole': '指定角色',
|
||||
'system.approval.definition.approvers': '审批人',
|
||||
'system.approval.definition.userPlaceholder': '选择用户',
|
||||
'system.approval.definition.rolePlaceholder': '选择角色',
|
||||
'system.approval.definition.condition': '触发条件',
|
||||
'system.approval.definition.conditionPlaceholder': '可留空;空表示启用即始终需审',
|
||||
'system.approval.definition.forbidSelf': '禁止自审',
|
||||
'system.approval.definition.remark': '备注',
|
||||
'system.approval.definition.toggle': '启停',
|
||||
'system.approval.definition.simulate': '模拟提交',
|
||||
'system.approval.definition.simulateTitle': '审批引擎模拟单',
|
||||
'system.approval.definition.deleteConfirm': '确认删除「{name}」的审批配置?',
|
||||
'system.approval.definition.col.operation': '操作名称',
|
||||
'system.approval.definition.col.code': '操作编码',
|
||||
'system.approval.definition.col.approverType': '类型',
|
||||
'system.approval.definition.col.approvers': '审批人',
|
||||
'system.approval.definition.col.enabled': '状态',
|
||||
'system.approval.definition.col.updateTime': '更新时间',
|
||||
'system.approval.definition.rules.operation': '请选择操作',
|
||||
'system.approval.definition.rules.approverType': '请选择审批人类型',
|
||||
'system.approval.definition.rules.approvers': '请选择审批人',
|
||||
|
||||
'system.approval.inbox.tabTodo': '待我审批',
|
||||
'system.approval.inbox.tabSubmitted': '我发起的',
|
||||
'system.approval.inbox.tabsAria': '审批待办分类',
|
||||
'system.approval.inbox.searchPlaceholder': '单号/标题/操作码',
|
||||
'system.approval.inbox.detailTitle': '审批详情',
|
||||
'system.approval.inbox.detail': '详情',
|
||||
'system.approval.inbox.approve': '通过',
|
||||
'system.approval.inbox.reject': '驳回',
|
||||
'system.approval.inbox.withdraw': '撤回',
|
||||
'system.approval.inbox.payload': '业务载荷',
|
||||
'system.approval.inbox.timeline': '事件时间线',
|
||||
'system.approval.inbox.rejectPlaceholder': '请填写驳回意见',
|
||||
'system.approval.inbox.rejectRequired': '驳回意见不能为空',
|
||||
'system.approval.inbox.approveConfirm': '确认通过审批单 {no}?',
|
||||
'system.approval.inbox.withdrawConfirm': '确认撤回审批单 {no}?',
|
||||
'system.approval.inbox.col.instanceNo': '单号',
|
||||
'system.approval.inbox.col.title': '标题',
|
||||
'system.approval.inbox.col.operation': '操作',
|
||||
'system.approval.inbox.col.status': '状态',
|
||||
'system.approval.inbox.col.applicant': '申请人',
|
||||
'system.approval.inbox.col.createTime': '提交时间',
|
||||
|
||||
'menu.xhs': '小红书',
|
||||
'menu.xhs.startService': '启动服务',
|
||||
@ -5412,6 +5475,8 @@ export default {
|
||||
'channel.salesProducts.publish.effectiveTime': '生效时间',
|
||||
'channel.salesProducts.publish.effectiveTimeHint': '不选默认立即生效',
|
||||
'channel.salesProducts.publish.success': '发布成功',
|
||||
'channel.salesProducts.publish.pendingApproval': '已提交审批({no}),通过后生效',
|
||||
'channel.salesProducts.publish.pendingApprovalFallback': '已提交审批,通过后生效',
|
||||
'channel.salesProducts.publish.fail': '发布失败',
|
||||
'channel.salesProducts.publish.status.synced': '当前内容与线上一致,无需重复发布',
|
||||
'channel.salesProducts.publish.status.changed': '检测到 {count} 处变更,确认后将更新线上缓存',
|
||||
|
||||
@ -178,6 +178,33 @@ const SYSTEM_MANAGEMENT: AppRouteRecordRaw = {
|
||||
permission: 'Rbac.DataPerm.Audit',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'approval/definition',
|
||||
name: 'SystemApprovalDefinition',
|
||||
component: () => import('@/views/system/approval/definition/index.vue'),
|
||||
meta: {
|
||||
locale: 'menu.system.approvalDefinition',
|
||||
requiresAuth: true,
|
||||
// 供菜单管理「同步子菜单及按钮」写入二级菜单权限码(不走路由守卫)
|
||||
menuPermission: 'System.ApprovalDefinition',
|
||||
permission: 'System.ApprovalDefinition.Query',
|
||||
order: 40,
|
||||
icon: 'icon-check-circle',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'approval/inbox',
|
||||
name: 'SystemApprovalInbox',
|
||||
component: () => import('@/views/system/approval/inbox/index.vue'),
|
||||
meta: {
|
||||
locale: 'menu.system.approvalInbox',
|
||||
requiresAuth: true,
|
||||
menuPermission: 'System.ApprovalTask',
|
||||
permission: 'System.ApprovalTask.Query',
|
||||
order: 41,
|
||||
icon: 'icon-calendar',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@ -95,6 +95,8 @@ export const SUB_MENU_DEFAULT_ICONS: Record<string, string> = {
|
||||
'menu.system.dataPermUsers': 'IconUser',
|
||||
'menu.system.dataPermTemplates': 'IconFile',
|
||||
'menu.system.dataPermAudit': 'IconHistory',
|
||||
'menu.system.approvalDefinition': 'IconCheckCircle',
|
||||
'menu.system.approvalInbox': 'IconCalendar',
|
||||
'menu.xhs.startService': 'IconPlayArrow',
|
||||
'menu.xhs.analysis': 'IconBarChart',
|
||||
'menu.xhs.creation': 'IconEdit',
|
||||
@ -132,6 +134,8 @@ export const PATH_TO_LOCALE_KEY: Record<string, string> = {
|
||||
'/kb/training': 'menu.kb.training',
|
||||
'/agentAdmin/list': 'menu.agentAdmin.list',
|
||||
'/agentAdmin/commission': 'menu.agentAdmin.commission',
|
||||
'/system/approval/definition': 'menu.system.approvalDefinition',
|
||||
'/system/approval/inbox': 'menu.system.approvalInbox',
|
||||
}
|
||||
|
||||
type MenuIconItem = {
|
||||
|
||||
@ -2313,14 +2313,28 @@
|
||||
}
|
||||
pricePublishSubmitting.value = true;
|
||||
try {
|
||||
await publishSalesProduct({
|
||||
const publishResult = await publishSalesProduct({
|
||||
salesProductId: Number(pid),
|
||||
operatorType,
|
||||
description: publishDescription.value || undefined,
|
||||
aiAnalysisReport:
|
||||
operatorType === 'price' ? pricePublishAiReport.value.trim() || undefined : undefined,
|
||||
});
|
||||
Message.success(t('channel.salesProducts.publish.success'));
|
||||
const decision = String(
|
||||
publishResult?.decision ?? publishResult?.Decision ?? '',
|
||||
).trim();
|
||||
const approvalNo = String(
|
||||
publishResult?.approvalInstanceNo ?? publishResult?.ApprovalInstanceNo ?? '',
|
||||
).trim();
|
||||
if (decision === 'PendingApproval') {
|
||||
Message.info(
|
||||
approvalNo
|
||||
? t('channel.salesProducts.publish.pendingApproval', { no: approvalNo })
|
||||
: t('channel.salesProducts.publish.pendingApprovalFallback'),
|
||||
);
|
||||
} else {
|
||||
Message.success(t('channel.salesProducts.publish.success'));
|
||||
}
|
||||
if (operatorType === 'rules') {
|
||||
configPublishPending.value = false;
|
||||
rulesPublishPending.value = false;
|
||||
@ -2334,12 +2348,14 @@
|
||||
publishConfirmDate.value = dayjs();
|
||||
clearPricePublishAiReport();
|
||||
publishModalMethods.closeModal();
|
||||
await loadRecordsTabData(pid, true);
|
||||
if (operatorType === 'price') {
|
||||
// 不乐观改徽章;等后端 sync-status 重算
|
||||
pricePublishPending.value = null;
|
||||
await loadPriceTabData(pid, { force: true });
|
||||
await refreshPricePublishSyncStatus(pid);
|
||||
if (decision !== 'PendingApproval') {
|
||||
await loadRecordsTabData(pid, true);
|
||||
if (operatorType === 'price') {
|
||||
// 不乐观改徽章;等后端 sync-status 重算
|
||||
pricePublishPending.value = null;
|
||||
await loadPriceTabData(pid, { force: true });
|
||||
await refreshPricePublishSyncStatus(pid);
|
||||
}
|
||||
}
|
||||
} catch (e: any) {
|
||||
Message.error(e?.message || t('channel.salesProducts.publish.fail'));
|
||||
|
||||
489
src/views/system/approval/definition/index.vue
Normal file
489
src/views/system/approval/definition/index.vue
Normal file
@ -0,0 +1,489 @@
|
||||
<template>
|
||||
<div class="approval-definition-page">
|
||||
<div class="approval-definition-card">
|
||||
<div class="table-toolbar">
|
||||
<div class="toolbar-left">
|
||||
<a-input
|
||||
v-model="keyword"
|
||||
allow-clear
|
||||
:placeholder="t('system.approval.definition.searchPlaceholder')"
|
||||
style="width: 260px"
|
||||
@press-enter="handleSearch"
|
||||
@clear="handleSearch"
|
||||
/>
|
||||
<a-select
|
||||
v-model="enabledFilter"
|
||||
allow-clear
|
||||
:placeholder="t('system.approval.definition.enabledFilter')"
|
||||
style="width: 140px"
|
||||
@change="handleSearch"
|
||||
>
|
||||
<a-option :value="true">{{ t('system.approval.definition.enabled') }}</a-option>
|
||||
<a-option :value="false">{{ t('system.approval.definition.disabled') }}</a-option>
|
||||
</a-select>
|
||||
<a-button class="app-btn-search" @click="handleSearch">{{ t('common.search') }}</a-button>
|
||||
<a-button
|
||||
v-if="hasPermission('System.ApprovalDefinition.Create')"
|
||||
class="btn-add app-btn-primary-soft"
|
||||
@click="handleAdd"
|
||||
>
|
||||
{{ t('common.add') }}
|
||||
</a-button>
|
||||
<a-button
|
||||
v-if="hasPermission('System.ApprovalDefinition.Create')"
|
||||
@click="handleSimulate"
|
||||
>
|
||||
{{ t('system.approval.definition.simulate') }}
|
||||
</a-button>
|
||||
</div>
|
||||
<div class="toolbar-right">
|
||||
<PaginationPro
|
||||
:total-count="totalCount"
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
@page-change="loadList"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ref="tableContainerRef" class="list-wrap">
|
||||
<a-spin :loading="loading" class="list-spin">
|
||||
<HandsontablePro
|
||||
:columns="hotColumns"
|
||||
:data="rows"
|
||||
:total="totalCount"
|
||||
:current-page="currentPage"
|
||||
:page-size="pageSize"
|
||||
:show-action-column="true"
|
||||
:action-renderer="actionRenderer"
|
||||
:custom-cell-renderer="customCellRenderer"
|
||||
:stretch-columns="true"
|
||||
:height="handsontableHeight"
|
||||
:read-only="true"
|
||||
:enable-column-filter="false"
|
||||
@action-click="handleActionClick"
|
||||
/>
|
||||
</a-spin>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a-modal
|
||||
v-model:visible="modalVisible"
|
||||
:title="isEdit ? t('system.approval.definition.editTitle') : t('system.approval.definition.addTitle')"
|
||||
:confirm-loading="modalLoading"
|
||||
width="640px"
|
||||
:mask-closable="false"
|
||||
unmount-on-close
|
||||
@before-ok="handleModalOk"
|
||||
@cancel="() => (modalVisible = false)"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="formState"
|
||||
:rules="formRules"
|
||||
:label-col-props="{ span: 6 }"
|
||||
:wrapper-col-props="{ span: 16 }"
|
||||
>
|
||||
<a-form-item :label="t('system.approval.definition.operationCode')" field="operationCode">
|
||||
<a-select
|
||||
v-model="formState.operationCode"
|
||||
:disabled="isEdit"
|
||||
:placeholder="t('system.approval.definition.operationPlaceholder')"
|
||||
allow-search
|
||||
>
|
||||
<a-option v-for="item in catalog" :key="item.code" :value="item.code">
|
||||
{{ item.name }}({{ item.code }})
|
||||
</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('system.approval.definition.approverType')" field="approverType">
|
||||
<a-radio-group v-model="formState.approverType">
|
||||
<a-radio value="User">{{ t('system.approval.definition.approverUser') }}</a-radio>
|
||||
<a-radio value="Role">{{ t('system.approval.definition.approverRole') }}</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
v-if="formState.approverType === 'User'"
|
||||
:label="t('system.approval.definition.approvers')"
|
||||
field="approverIds"
|
||||
>
|
||||
<SelectPro
|
||||
v-model="formState.approverIds"
|
||||
clearable
|
||||
immediate
|
||||
:placeholder="t('system.approval.definition.userPlaceholder')"
|
||||
:api="getRbacUserList"
|
||||
:label-keys="['name', 'account']"
|
||||
id-key="id"
|
||||
search-key="name"
|
||||
:is-page="true"
|
||||
:multiple="true"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item v-else :label="t('system.approval.definition.approvers')" field="approverIds">
|
||||
<a-select
|
||||
v-model="formState.approverIds"
|
||||
multiple
|
||||
allow-search
|
||||
:placeholder="t('system.approval.definition.rolePlaceholder')"
|
||||
:options="roleOptions"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('system.approval.definition.condition')" field="conditionFormula">
|
||||
<a-textarea
|
||||
v-model="formState.conditionFormula"
|
||||
:placeholder="conditionHint"
|
||||
:auto-size="{ minRows: 2, maxRows: 4 }"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('system.approval.definition.forbidSelf')" field="forbidSelfApprove">
|
||||
<a-switch v-model="formState.forbidSelfApprove" />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('system.approval.definition.enabled')" field="isEnabled">
|
||||
<a-switch v-model="formState.isEnabled" />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('system.approval.definition.remark')" field="remark">
|
||||
<a-input v-model="formState.remark" allow-clear />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { Message, Modal } from '@arco-design/web-vue'
|
||||
import HandsontablePro from '@/components/HandsontablePro/index.vue'
|
||||
import PaginationPro from '@/components/PaginationPro/index.vue'
|
||||
import SelectPro from '@/components/SelectPro/index.vue'
|
||||
import { useTableContainerHeight } from '@/composables/useTableContainerHeight'
|
||||
import { hasPermission } from '@/utils/rbac-permission'
|
||||
import { renderWarehouseActionBtn, wrapWarehouseActions } from '@/utils/warehouseActionRenderer'
|
||||
import { RoleService, UserService } from '@/api/rbac'
|
||||
import {
|
||||
deleteApprovalDefinition,
|
||||
enableApprovalDefinition,
|
||||
getApprovalCatalog,
|
||||
getApprovalDefinitionList,
|
||||
saveApprovalDefinition,
|
||||
simulateApprovalSubmit,
|
||||
type ApprovalCatalogItem,
|
||||
type ApprovalDefinitionDto,
|
||||
} from '@/api/system/approval'
|
||||
|
||||
defineOptions({ name: 'SystemApprovalDefinition' })
|
||||
|
||||
const { t } = useI18n()
|
||||
const { tableContainerRef, tableHeight } = useTableContainerHeight()
|
||||
const handsontableHeight = computed(() => Math.max(tableHeight.value || 0, 400))
|
||||
|
||||
const loading = ref(false)
|
||||
const rows = ref<ApprovalDefinitionDto[]>([])
|
||||
const totalCount = ref(0)
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(50)
|
||||
const keyword = ref('')
|
||||
const enabledFilter = ref<boolean | undefined>(undefined)
|
||||
const catalog = ref<ApprovalCatalogItem[]>([])
|
||||
const roleOptions = ref<Array<{ label: string; value: string }>>([])
|
||||
|
||||
const modalVisible = ref(false)
|
||||
const modalLoading = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const editingId = ref<number | null>(null)
|
||||
const formRef = ref()
|
||||
const formState = reactive({
|
||||
operationCode: '',
|
||||
approverType: 'User',
|
||||
approverIds: [] as string[],
|
||||
conditionFormula: '',
|
||||
forbidSelfApprove: true,
|
||||
isEnabled: true,
|
||||
remark: '',
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
operationCode: [{ required: true, message: t('system.approval.definition.rules.operation') }],
|
||||
approverType: [{ required: true, message: t('system.approval.definition.rules.approverType') }],
|
||||
approverIds: [{ required: true, message: t('system.approval.definition.rules.approvers') }],
|
||||
}
|
||||
|
||||
const conditionHint = computed(() => {
|
||||
const hit = catalog.value.find((x) => x.code === formState.operationCode)
|
||||
return hit?.conditionHint || t('system.approval.definition.conditionPlaceholder')
|
||||
})
|
||||
|
||||
const hotColumns = computed(() => [
|
||||
{ key: 'operationName', label: t('system.approval.definition.col.operation'), width: 160 },
|
||||
{ key: 'operationCode', label: t('system.approval.definition.col.code'), width: 220 },
|
||||
{ key: 'approverType', label: t('system.approval.definition.col.approverType'), width: 90 },
|
||||
{ key: 'approverSummary', label: t('system.approval.definition.col.approvers'), width: 180 },
|
||||
{ key: 'isEnabledText', label: t('system.approval.definition.col.enabled'), width: 80 },
|
||||
{ key: 'updateTime', label: t('system.approval.definition.col.updateTime'), width: 170 },
|
||||
])
|
||||
|
||||
async function getRbacUserList(params: { pageIndex?: number; pageSize?: number; keyword?: string }) {
|
||||
const res = await UserService.getRbacUserGetList(
|
||||
params.keyword,
|
||||
undefined,
|
||||
params.pageIndex ?? 1,
|
||||
params.pageSize ?? 30,
|
||||
)
|
||||
return { items: res?.items ?? [] }
|
||||
}
|
||||
|
||||
function actionRenderer() {
|
||||
const buttons = []
|
||||
if (hasPermission('System.ApprovalDefinition.Update')) {
|
||||
buttons.push(renderWarehouseActionBtn('edit', t('common.edit')))
|
||||
}
|
||||
if (hasPermission('System.ApprovalDefinition.Enable')) {
|
||||
buttons.push(renderWarehouseActionBtn('toggle', t('system.approval.definition.toggle')))
|
||||
}
|
||||
if (hasPermission('System.ApprovalDefinition.Delete')) {
|
||||
buttons.push(renderWarehouseActionBtn('delete', t('common.delete')))
|
||||
}
|
||||
return wrapWarehouseActions(buttons)
|
||||
}
|
||||
|
||||
function customCellRenderer(rowData: any, colKey: string) {
|
||||
if (colKey === 'isEnabledText') {
|
||||
return rowData.isEnabled
|
||||
? t('system.approval.definition.enabled')
|
||||
: t('system.approval.definition.disabled')
|
||||
}
|
||||
if (colKey === 'approverSummary') {
|
||||
const ids = rowData.approverIds || []
|
||||
return `${rowData.approverType || 'User'}: ${ids.length}`
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
function handleActionClick(row: ApprovalDefinitionDto, _idx: number, action?: string) {
|
||||
if (action === 'edit') {
|
||||
openEdit(row)
|
||||
return
|
||||
}
|
||||
if (action === 'toggle') {
|
||||
toggleEnable(row)
|
||||
return
|
||||
}
|
||||
if (action === 'delete') {
|
||||
handleDelete(row)
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
currentPage.value = 1
|
||||
loadList()
|
||||
}
|
||||
|
||||
function handlePageSizeChange() {
|
||||
currentPage.value = 1
|
||||
loadList()
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
formState.operationCode = ''
|
||||
formState.approverType = 'User'
|
||||
formState.approverIds = []
|
||||
formState.conditionFormula = ''
|
||||
formState.forbidSelfApprove = true
|
||||
formState.isEnabled = true
|
||||
formState.remark = ''
|
||||
editingId.value = null
|
||||
isEdit.value = false
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
resetForm()
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
function openEdit(row: ApprovalDefinitionDto) {
|
||||
isEdit.value = true
|
||||
editingId.value = row.id
|
||||
formState.operationCode = row.operationCode
|
||||
formState.approverType = row.approverType || 'User'
|
||||
formState.approverIds = [...(row.approverIds || [])]
|
||||
formState.conditionFormula = row.conditionFormula || ''
|
||||
formState.forbidSelfApprove = row.forbidSelfApprove
|
||||
formState.isEnabled = row.isEnabled
|
||||
formState.remark = row.remark || ''
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
async function handleModalOk() {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
modalLoading.value = true
|
||||
try {
|
||||
await saveApprovalDefinition({
|
||||
id: isEdit.value ? editingId.value || undefined : undefined,
|
||||
operationCode: formState.operationCode,
|
||||
isEnabled: formState.isEnabled,
|
||||
conditionFormula: formState.conditionFormula || null,
|
||||
approverType: formState.approverType,
|
||||
approverIds: formState.approverIds,
|
||||
forbidSelfApprove: formState.forbidSelfApprove,
|
||||
remark: formState.remark || null,
|
||||
})
|
||||
Message.success(t('common.saveSuccess'))
|
||||
modalVisible.value = false
|
||||
await loadList()
|
||||
return true
|
||||
} catch (e: unknown) {
|
||||
Message.error((e as Error)?.message || t('common.saveFailed'))
|
||||
return false
|
||||
} finally {
|
||||
modalLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleEnable(row: ApprovalDefinitionDto) {
|
||||
try {
|
||||
await enableApprovalDefinition(row.id, !row.isEnabled)
|
||||
Message.success(t('common.success'))
|
||||
await loadList()
|
||||
} catch (e: unknown) {
|
||||
Message.error((e as Error)?.message || t('common.failed'))
|
||||
}
|
||||
}
|
||||
|
||||
function handleDelete(row: ApprovalDefinitionDto) {
|
||||
Modal.warning({
|
||||
title: t('common.delete'),
|
||||
content: t('system.approval.definition.deleteConfirm', { name: row.operationName || row.operationCode }),
|
||||
hideCancel: false,
|
||||
onOk: async () => {
|
||||
try {
|
||||
await deleteApprovalDefinition(row.id)
|
||||
Message.success(t('common.deleteSuccess'))
|
||||
await loadList()
|
||||
} catch (e: unknown) {
|
||||
Message.error((e as Error)?.message || t('common.deleteFailed'))
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async function handleSimulate() {
|
||||
try {
|
||||
const result = await simulateApprovalSubmit({
|
||||
operationCode: 'System.Approval.Simulate',
|
||||
title: t('system.approval.definition.simulateTitle'),
|
||||
payload: { demo: true, at: new Date().toISOString() },
|
||||
summary: { tip: 'simulate' },
|
||||
})
|
||||
Message.success(
|
||||
`${result.decision || ''} ${result.instanceNo || result.message || ''}`.trim() || t('common.success'),
|
||||
)
|
||||
} catch (e: unknown) {
|
||||
Message.error((e as Error)?.message || t('common.failed'))
|
||||
}
|
||||
}
|
||||
|
||||
async function loadList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const { items, total } = await getApprovalDefinitionList({
|
||||
page: currentPage.value,
|
||||
pageSize: pageSize.value,
|
||||
keyword: keyword.value || undefined,
|
||||
isEnabled: enabledFilter.value,
|
||||
})
|
||||
rows.value = items.map((x) => ({
|
||||
...x,
|
||||
isEnabledText: x.isEnabled ? '1' : '0',
|
||||
approverSummary: `${x.approverType}:${(x.approverIds || []).length}`,
|
||||
})) as any
|
||||
totalCount.value = total
|
||||
} catch (e: unknown) {
|
||||
Message.error((e as Error)?.message || t('common.loadFailed'))
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadMeta() {
|
||||
try {
|
||||
catalog.value = await getApprovalCatalog()
|
||||
const roles = await RoleService.getRbacRoleGetAllRoles()
|
||||
roleOptions.value = (roles || []).map((r) => ({
|
||||
label: `${r.name || r.code}(${r.code})`,
|
||||
value: String(r.id),
|
||||
}))
|
||||
} catch {
|
||||
// ignore meta load failure for page shell
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadMeta()
|
||||
await loadList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.approval-definition-page {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--app-page-bg, #f0f3f4);
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.approval-definition-card {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.table-toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16px 16px 0;
|
||||
margin-bottom: 16px;
|
||||
flex-shrink: 0;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
|
||||
.toolbar-left,
|
||||
.toolbar-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
.list-wrap {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 0 16px 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.list-spin {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
</style>
|
||||
452
src/views/system/approval/inbox/index.vue
Normal file
452
src/views/system/approval/inbox/index.vue
Normal file
@ -0,0 +1,452 @@
|
||||
<template>
|
||||
<div class="approval-inbox-page">
|
||||
<div class="approval-inbox-card">
|
||||
<div class="page-header">
|
||||
<SlidingTabs
|
||||
v-model="activeTab"
|
||||
class="inbox-tabs"
|
||||
:items="inboxTabs"
|
||||
:aria-label="t('system.approval.inbox.tabsAria')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="table-toolbar">
|
||||
<div class="toolbar-left">
|
||||
<a-input
|
||||
v-model="keyword"
|
||||
allow-clear
|
||||
:placeholder="t('system.approval.inbox.searchPlaceholder')"
|
||||
style="width: 260px"
|
||||
@press-enter="handleSearch"
|
||||
@clear="handleSearch"
|
||||
/>
|
||||
<a-button class="app-btn-search" @click="handleSearch">{{ t('common.search') }}</a-button>
|
||||
<a-button @click="loadList">{{ t('common.refresh') }}</a-button>
|
||||
</div>
|
||||
<div class="toolbar-right">
|
||||
<PaginationPro
|
||||
:total-count="totalCount"
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
@page-change="loadList"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ref="tableContainerRef" class="list-wrap">
|
||||
<a-spin :loading="loading" class="list-spin">
|
||||
<HandsontablePro
|
||||
:key="activeTab"
|
||||
:columns="hotColumns"
|
||||
:data="rows"
|
||||
:total="totalCount"
|
||||
:current-page="currentPage"
|
||||
:page-size="pageSize"
|
||||
:show-action-column="true"
|
||||
:action-renderer="actionRenderer"
|
||||
:stretch-columns="true"
|
||||
:height="handsontableHeight"
|
||||
:read-only="true"
|
||||
:enable-column-filter="false"
|
||||
@action-click="handleActionClick"
|
||||
/>
|
||||
</a-spin>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a-drawer
|
||||
v-model:visible="detailVisible"
|
||||
:title="t('system.approval.inbox.detailTitle')"
|
||||
:width="560"
|
||||
unmount-on-close
|
||||
>
|
||||
<template v-if="detail">
|
||||
<a-descriptions :column="1" size="large" bordered>
|
||||
<a-descriptions-item :label="t('system.approval.inbox.col.instanceNo')">
|
||||
{{ detail.instanceNo }}
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item :label="t('system.approval.inbox.col.title')">
|
||||
{{ detail.title }}
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item :label="t('system.approval.inbox.col.operation')">
|
||||
{{ detail.operationCode }}
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item :label="t('system.approval.inbox.col.status')">
|
||||
{{ detail.statusName }}
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item :label="t('system.approval.inbox.col.applicant')">
|
||||
{{ detail.applicantUserName || detail.applicantUserGuid }}
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item :label="t('system.approval.inbox.payload')">
|
||||
<pre class="json-block">{{ formatJson(detail.payloadJson) }}</pre>
|
||||
</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
|
||||
<div class="timeline-title">{{ t('system.approval.inbox.timeline') }}</div>
|
||||
<a-timeline>
|
||||
<a-timeline-item v-for="ev in detail.events || []" :key="ev.id">
|
||||
<div class="event-head">
|
||||
<strong>{{ ev.eventType }}</strong>
|
||||
<span class="event-time">{{ ev.createTime }}</span>
|
||||
</div>
|
||||
<div>{{ ev.operatorUserName }} {{ ev.message }}</div>
|
||||
</a-timeline-item>
|
||||
</a-timeline>
|
||||
|
||||
<div v-if="detail.canApprove || detail.canWithdraw" class="detail-actions">
|
||||
<a-button
|
||||
v-if="detail.canApprove && hasPermission('System.ApprovalTask.Approve')"
|
||||
type="primary"
|
||||
@click="doApprove(detail)"
|
||||
>
|
||||
{{ t('system.approval.inbox.approve') }}
|
||||
</a-button>
|
||||
<a-button
|
||||
v-if="detail.canApprove && hasPermission('System.ApprovalTask.Reject')"
|
||||
status="danger"
|
||||
@click="openReject(detail)"
|
||||
>
|
||||
{{ t('system.approval.inbox.reject') }}
|
||||
</a-button>
|
||||
<a-button v-if="detail.canWithdraw" @click="doWithdraw(detail)">
|
||||
{{ t('system.approval.inbox.withdraw') }}
|
||||
</a-button>
|
||||
</div>
|
||||
</template>
|
||||
</a-drawer>
|
||||
|
||||
<a-modal
|
||||
v-model:visible="rejectVisible"
|
||||
:title="t('system.approval.inbox.reject')"
|
||||
:confirm-loading="actionLoading"
|
||||
@before-ok="confirmReject"
|
||||
>
|
||||
<a-textarea
|
||||
v-model="rejectComment"
|
||||
:placeholder="t('system.approval.inbox.rejectPlaceholder')"
|
||||
:auto-size="{ minRows: 3, maxRows: 6 }"
|
||||
/>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { Message, Modal } from '@arco-design/web-vue'
|
||||
import HandsontablePro from '@/components/HandsontablePro/index.vue'
|
||||
import PaginationPro from '@/components/PaginationPro/index.vue'
|
||||
import SlidingTabs from '@/components/SlidingTabs/index.vue'
|
||||
import { useTableContainerHeight } from '@/composables/useTableContainerHeight'
|
||||
import { hasPermission } from '@/utils/rbac-permission'
|
||||
import { renderWarehouseActionBtn, wrapWarehouseActions } from '@/utils/warehouseActionRenderer'
|
||||
import {
|
||||
approveApproval,
|
||||
getApprovalDetail,
|
||||
getApprovalMySubmitted,
|
||||
getApprovalMyTodo,
|
||||
rejectApproval,
|
||||
withdrawApproval,
|
||||
type ApprovalInstanceDto,
|
||||
} from '@/api/system/approval'
|
||||
|
||||
defineOptions({ name: 'SystemApprovalInbox' })
|
||||
|
||||
const { t } = useI18n()
|
||||
const { tableContainerRef, tableHeight } = useTableContainerHeight()
|
||||
const handsontableHeight = computed(() => Math.max(tableHeight.value || 0, 400))
|
||||
|
||||
const activeTab = ref<'todo' | 'submitted'>('todo')
|
||||
const inboxTabs = computed(() => [
|
||||
{ key: 'todo', label: t('system.approval.inbox.tabTodo') },
|
||||
{ key: 'submitted', label: t('system.approval.inbox.tabSubmitted') },
|
||||
])
|
||||
const loading = ref(false)
|
||||
const rows = ref<ApprovalInstanceDto[]>([])
|
||||
const totalCount = ref(0)
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(50)
|
||||
const keyword = ref('')
|
||||
|
||||
const detailVisible = ref(false)
|
||||
const detail = ref<ApprovalInstanceDto | null>(null)
|
||||
const rejectVisible = ref(false)
|
||||
const rejectComment = ref('')
|
||||
const rejectTarget = ref<ApprovalInstanceDto | null>(null)
|
||||
const actionLoading = ref(false)
|
||||
|
||||
const hotColumns = computed(() => [
|
||||
{ key: 'instanceNo', label: t('system.approval.inbox.col.instanceNo'), width: 160 },
|
||||
{ key: 'title', label: t('system.approval.inbox.col.title'), width: 180 },
|
||||
{ key: 'operationCode', label: t('system.approval.inbox.col.operation'), width: 200 },
|
||||
{ key: 'statusName', label: t('system.approval.inbox.col.status'), width: 100 },
|
||||
{ key: 'applicantUserName', label: t('system.approval.inbox.col.applicant'), width: 120 },
|
||||
{ key: 'createTime', label: t('system.approval.inbox.col.createTime'), width: 170 },
|
||||
])
|
||||
|
||||
function actionRenderer(rowData: ApprovalInstanceDto) {
|
||||
const buttons = [renderWarehouseActionBtn('detail', t('system.approval.inbox.detail'))]
|
||||
if (rowData.canApprove && hasPermission('System.ApprovalTask.Approve')) {
|
||||
buttons.push(renderWarehouseActionBtn('approve', t('system.approval.inbox.approve')))
|
||||
}
|
||||
if (rowData.canApprove && hasPermission('System.ApprovalTask.Reject')) {
|
||||
buttons.push(renderWarehouseActionBtn('reject', t('system.approval.inbox.reject')))
|
||||
}
|
||||
if (rowData.canWithdraw) {
|
||||
buttons.push(renderWarehouseActionBtn('withdraw', t('system.approval.inbox.withdraw')))
|
||||
}
|
||||
return wrapWarehouseActions(buttons)
|
||||
}
|
||||
|
||||
function handleActionClick(row: ApprovalInstanceDto, _idx: number, action?: string) {
|
||||
if (action === 'detail') {
|
||||
openDetail(row.id)
|
||||
return
|
||||
}
|
||||
if (action === 'approve') {
|
||||
doApprove(row)
|
||||
return
|
||||
}
|
||||
if (action === 'reject') {
|
||||
openReject(row)
|
||||
return
|
||||
}
|
||||
if (action === 'withdraw') {
|
||||
doWithdraw(row)
|
||||
}
|
||||
}
|
||||
|
||||
watch(activeTab, () => {
|
||||
currentPage.value = 1
|
||||
loadList()
|
||||
})
|
||||
|
||||
function handleSearch() {
|
||||
currentPage.value = 1
|
||||
loadList()
|
||||
}
|
||||
|
||||
function handlePageSizeChange() {
|
||||
currentPage.value = 1
|
||||
loadList()
|
||||
}
|
||||
|
||||
function formatJson(raw?: string | null) {
|
||||
if (!raw) return '—'
|
||||
try {
|
||||
return JSON.stringify(JSON.parse(raw), null, 2)
|
||||
} catch {
|
||||
return raw
|
||||
}
|
||||
}
|
||||
|
||||
async function openDetail(id: number) {
|
||||
try {
|
||||
detail.value = await getApprovalDetail(id)
|
||||
detailVisible.value = true
|
||||
} catch (e: unknown) {
|
||||
Message.error((e as Error)?.message || t('common.loadFailed'))
|
||||
}
|
||||
}
|
||||
|
||||
async function doApprove(row: ApprovalInstanceDto) {
|
||||
Modal.warning({
|
||||
title: t('system.approval.inbox.approve'),
|
||||
content: t('system.approval.inbox.approveConfirm', { no: row.instanceNo }),
|
||||
hideCancel: false,
|
||||
onOk: async () => {
|
||||
try {
|
||||
await approveApproval({
|
||||
instanceId: row.id,
|
||||
concurrencyStamp: row.concurrencyStamp,
|
||||
})
|
||||
Message.success(t('common.success'))
|
||||
detailVisible.value = false
|
||||
await loadList()
|
||||
} catch (e: unknown) {
|
||||
Message.error((e as Error)?.message || t('common.failed'))
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function openReject(row: ApprovalInstanceDto) {
|
||||
rejectTarget.value = row
|
||||
rejectComment.value = ''
|
||||
rejectVisible.value = true
|
||||
}
|
||||
|
||||
async function confirmReject() {
|
||||
if (!rejectComment.value.trim()) {
|
||||
Message.warning(t('system.approval.inbox.rejectRequired'))
|
||||
return false
|
||||
}
|
||||
if (!rejectTarget.value) return false
|
||||
actionLoading.value = true
|
||||
try {
|
||||
await rejectApproval({
|
||||
instanceId: rejectTarget.value.id,
|
||||
comment: rejectComment.value.trim(),
|
||||
concurrencyStamp: rejectTarget.value.concurrencyStamp,
|
||||
})
|
||||
Message.success(t('common.success'))
|
||||
rejectVisible.value = false
|
||||
detailVisible.value = false
|
||||
await loadList()
|
||||
return true
|
||||
} catch (e: unknown) {
|
||||
Message.error((e as Error)?.message || t('common.failed'))
|
||||
return false
|
||||
} finally {
|
||||
actionLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function doWithdraw(row: ApprovalInstanceDto) {
|
||||
Modal.warning({
|
||||
title: t('system.approval.inbox.withdraw'),
|
||||
content: t('system.approval.inbox.withdrawConfirm', { no: row.instanceNo }),
|
||||
hideCancel: false,
|
||||
onOk: async () => {
|
||||
try {
|
||||
await withdrawApproval({
|
||||
instanceId: row.id,
|
||||
concurrencyStamp: row.concurrencyStamp,
|
||||
})
|
||||
Message.success(t('common.success'))
|
||||
detailVisible.value = false
|
||||
await loadList()
|
||||
} catch (e: unknown) {
|
||||
Message.error((e as Error)?.message || t('common.failed'))
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async function loadList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const params = {
|
||||
page: currentPage.value,
|
||||
pageSize: pageSize.value,
|
||||
keyword: keyword.value || undefined,
|
||||
}
|
||||
const result =
|
||||
activeTab.value === 'todo'
|
||||
? await getApprovalMyTodo(params)
|
||||
: await getApprovalMySubmitted(params)
|
||||
rows.value = result.items
|
||||
totalCount.value = result.total
|
||||
} catch (e: unknown) {
|
||||
Message.error((e as Error)?.message || t('common.loadFailed'))
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.approval-inbox-page {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--app-page-bg, #f0f3f4);
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.approval-inbox-card {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
padding: 12px 16px 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.inbox-tabs {
|
||||
width: fit-content;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.table-toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 12px 16px 0;
|
||||
margin-bottom: 16px;
|
||||
flex-shrink: 0;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
|
||||
.toolbar-left,
|
||||
.toolbar-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
.list-wrap {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 0 16px 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.list-spin {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.json-block {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
font-size: 12px;
|
||||
max-height: 200px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.timeline-title {
|
||||
margin: 20px 0 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.event-head {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.event-time {
|
||||
color: var(--color-text-3);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.detail-actions {
|
||||
margin-top: 24px;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user