From cf61ce340dce6146c5b30c3eaffbf95e8d0af508 Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Thu, 30 Jul 2026 13:49:43 +0800 Subject: [PATCH] feat(web-admin): register receiveAccount FormCreate control. Co-authored-by: Cursor --- web-admin/src/api/oaApproval.ts | 44 +++ .../oa-approval/OaReceiveAccountSelect.vue | 316 ++++++++++++++++++ web-admin/src/main.ts | 2 + web-admin/src/oa-fc-host/main.ts | 2 + web-admin/src/utils/oa-approval-print.ts | 7 + .../utils/oa-form-create-receive-account.ts | 19 ++ .../src/utils/oa-receive-account-rule.ts | 45 +++ 7 files changed, 435 insertions(+) create mode 100644 web-admin/src/components/oa-approval/OaReceiveAccountSelect.vue create mode 100644 web-admin/src/utils/oa-form-create-receive-account.ts create mode 100644 web-admin/src/utils/oa-receive-account-rule.ts diff --git a/web-admin/src/api/oaApproval.ts b/web-admin/src/api/oaApproval.ts index b64e4e83..03c7c399 100644 --- a/web-admin/src/api/oaApproval.ts +++ b/web-admin/src/api/oaApproval.ts @@ -71,6 +71,50 @@ export function fetchReplaceOaRoleUsers(roleId: string, userIds: string[]) { }) } +// --------------------------------------------------------------------------- +// 收款账户 +// --------------------------------------------------------------------------- + +export function fetchOaReceiveAccountList(params?: { + keyword?: string + accountType?: string + page?: number + pageSize?: number +}) { + return request.get<{ list: any[]; total: number }>({ + url: `${BASE}/receive-accounts`, + params + }) +} + +export function fetchOaReceiveAccountOptions() { + return request.get<{ list: any[] }>({ url: `${BASE}/receive-accounts/options` }) +} + +export function fetchOaReceiveAccountDetail(id: string) { + return request.get({ url: `${BASE}/receive-accounts/${id}` }) +} + +export function fetchCreateOaReceiveAccount(data: Record) { + return request.post({ url: `${BASE}/receive-accounts`, data, showSuccessMessage: true }) +} + +export function fetchUpdateOaReceiveAccount(id: string, data: Record) { + return request.put({ url: `${BASE}/receive-accounts/${id}`, data, showSuccessMessage: true }) +} + +export function fetchDeleteOaReceiveAccount(id: string) { + return request.del({ url: `${BASE}/receive-accounts/${id}`, showSuccessMessage: true }) +} + +export function fetchBatchDeleteOaReceiveAccounts(ids: string[]) { + return request.post({ + url: `${BASE}/receive-accounts/batch-delete`, + data: { ids }, + showSuccessMessage: true + }) +} + // --------------------------------------------------------------------------- // 分组 / 应用 / 草稿 / 发布 // --------------------------------------------------------------------------- diff --git a/web-admin/src/components/oa-approval/OaReceiveAccountSelect.vue b/web-admin/src/components/oa-approval/OaReceiveAccountSelect.vue new file mode 100644 index 00000000..70363430 --- /dev/null +++ b/web-admin/src/components/oa-approval/OaReceiveAccountSelect.vue @@ -0,0 +1,316 @@ + + + + + + diff --git a/web-admin/src/main.ts b/web-admin/src/main.ts index d7673163..3725a694 100644 --- a/web-admin/src/main.ts +++ b/web-admin/src/main.ts @@ -20,6 +20,7 @@ import { setupOaRelatedApproval } from '@/utils/oa-form-create-related-approval' import { setupOaDeptSelect } from '@/utils/oa-form-create-dept' import { setupOaMoneyField } from '@/utils/oa-form-create-money' import { setupOaPersonSelect } from '@/utils/oa-form-create-person' +import { setupOaReceiveAccountSelect } from '@/utils/oa-form-create-receive-account' // FormCreate 按字符串解析 el-input / fc-radio 等,主应用是按需自动导入,不会全局注册; // 必须挂上官方 auto-import,否则发起审批/详情里动态表单控件会残缺(如单选项只剩文字)。 @@ -30,6 +31,7 @@ setupOaRelatedApproval(FcDesigner.formCreate) setupOaDeptSelect(FcDesigner.formCreate) setupOaMoneyField(FcDesigner.formCreate) setupOaPersonSelect(FcDesigner.formCreate) +setupOaReceiveAccountSelect(FcDesigner.formCreate) function maskSecret(value?: string) { if (!value) return '(empty)' diff --git a/web-admin/src/oa-fc-host/main.ts b/web-admin/src/oa-fc-host/main.ts index dca92aea..d93e5cc8 100644 --- a/web-admin/src/oa-fc-host/main.ts +++ b/web-admin/src/oa-fc-host/main.ts @@ -17,6 +17,7 @@ import { setupOaRelatedApproval } from '@/utils/oa-form-create-related-approval' import { setupOaDeptSelect } from '@/utils/oa-form-create-dept' import { setupOaMoneyField } from '@/utils/oa-form-create-money' import { setupOaPersonSelect } from '@/utils/oa-form-create-person' +import { setupOaReceiveAccountSelect } from '@/utils/oa-form-create-receive-account' import App from './App.vue' const app = createApp(App) @@ -37,4 +38,5 @@ setupOaRelatedApproval(FcDesigner.formCreate) setupOaDeptSelect(FcDesigner.formCreate) setupOaMoneyField(FcDesigner.formCreate) setupOaPersonSelect(FcDesigner.formCreate) +setupOaReceiveAccountSelect(FcDesigner.formCreate) app.mount('#app') diff --git a/web-admin/src/utils/oa-approval-print.ts b/web-admin/src/utils/oa-approval-print.ts index 108be500..d56733f0 100644 --- a/web-admin/src/utils/oa-approval-print.ts +++ b/web-admin/src/utils/oa-approval-print.ts @@ -15,6 +15,7 @@ import { formatProgressPersonLines } from '@/utils/oa-progress-person-lines' import { formatDeptDisplay } from '@/utils/oa-dept-value' import { formatPersonDisplay } from '@/utils/oa-person-value' import { formatMoneyDisplay } from '@/utils/money-format' +import { formatReceiveAccountDisplay } from '@/utils/oa-receive-account-value' import { toRmbUpper } from '@/utils/rmb-upper' export const OA_PRINT_COMPANY_NAME = '安徽中科兴皖医学研究有限公司' @@ -274,6 +275,12 @@ async function walkRules( continue } + if (type === 'receiveAccount') { + const text = formatReceiveAccountDisplay(value) + out.push({ label, text: text || '-' }) + continue + } + if (UPLOAD_TYPES.has(type) || String(rule.name || '').toLowerCase().includes('upload')) { const urls = extractUrls(value) out.push({ label, urls: urls.length ? urls : [], text: urls.length ? undefined : '-' }) diff --git a/web-admin/src/utils/oa-form-create-receive-account.ts b/web-admin/src/utils/oa-form-create-receive-account.ts new file mode 100644 index 00000000..1ab54501 --- /dev/null +++ b/web-admin/src/utils/oa-form-create-receive-account.ts @@ -0,0 +1,19 @@ +import FcDesigner from '@form-create/designer' +import OaReceiveAccountSelect from '@/components/oa-approval/OaReceiveAccountSelect.vue' +import { receiveAccountSelectDragRule } from '@/utils/oa-receive-account-rule' + +const FLAG = '__oaReceiveAccountSelectConfigured' + +export function setupOaReceiveAccountSelect(formCreate?: { + component?: (name: string, c: unknown) => void +}) { + if ((FcDesigner as any)[FLAG]) return + FcDesigner.component('receiveAccount', OaReceiveAccountSelect) + if (typeof formCreate?.component === 'function') { + formCreate.component('receiveAccount', OaReceiveAccountSelect) + } + if (typeof FcDesigner.addDragRule === 'function') { + FcDesigner.addDragRule(receiveAccountSelectDragRule) + } + ;(FcDesigner as any)[FLAG] = true +} diff --git a/web-admin/src/utils/oa-receive-account-rule.ts b/web-admin/src/utils/oa-receive-account-rule.ts new file mode 100644 index 00000000..94fd423c --- /dev/null +++ b/web-admin/src/utils/oa-receive-account-rule.ts @@ -0,0 +1,45 @@ +/** 与 FormCreate 官方 unique 同类:生成不重复 field */ +let _uidSeq = 0 +function uniqueId() { + const num = 370 + ++_uidSeq + return ( + 'F' + + Math.random().toString(36).slice(3, 6) + + Number(`${Date.now()}`).toString(36) + + num.toString(36) + + 'r' + ) +} + +/** FormCreate Designer DragRule:收款账户选择 */ +export const receiveAccountSelectDragRule = { + menu: 'main' as const, + icon: 'icon-input', + label: '收款账户', + name: 'receiveAccount', + input: true, + mask: true, + validate: ['string', 'array', 'object'], + event: ['change'], + rule() { + return { + type: 'receiveAccount', + field: uniqueId(), + title: '收款账户', + info: '', + $required: false, + props: { + multiple: true + } + } + }, + props() { + return [ + { + type: 'input', + field: 'formCreateInfo', + title: '提示信息' + } + ] + } +}