feat(web-admin): register OA money field with uppercase display
Add DragRule, dual-host FormCreate setup, and AmountInput runtime with optional RMB uppercase. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
55e4134050
commit
8e98ffe950
5 files changed
+169
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import FcDesigner from '@form-create/designer'
|
||||
import OaMoneyField from '@/components/oa-approval/OaMoneyField.vue'
|
||||
import { moneyFieldDragRule } from '@/utils/oa-money-field-rule'
|
||||
|
||||
const FLAG = '__oaMoneyFieldConfigured'
|
||||
|
||||
export function setupOaMoneyField(formCreate?: { component?: (name: string, c: unknown) => void }) {
|
||||
if ((FcDesigner as any)[FLAG]) return
|
||||
FcDesigner.component('money', OaMoneyField)
|
||||
if (typeof formCreate?.component === 'function') {
|
||||
formCreate.component('money', OaMoneyField)
|
||||
}
|
||||
if (typeof FcDesigner.addDragRule === 'function') {
|
||||
FcDesigner.addDragRule(moneyFieldDragRule)
|
||||
}
|
||||
;(FcDesigner as any)[FLAG] = true
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/** 与 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)
|
||||
)
|
||||
}
|
||||
|
||||
/** FormCreate Designer DragRule:金额(可配大写展示) */
|
||||
export const moneyFieldDragRule = {
|
||||
menu: 'main' as const,
|
||||
icon: 'icon-number',
|
||||
label: '金额',
|
||||
name: 'money',
|
||||
input: true,
|
||||
mask: true,
|
||||
validate: ['number', 'string'],
|
||||
event: ['change'],
|
||||
rule() {
|
||||
return {
|
||||
type: 'money',
|
||||
field: uniqueId(),
|
||||
title: '金额(元)',
|
||||
info: '',
|
||||
$required: false,
|
||||
props: {
|
||||
showUpper: true,
|
||||
placeholder: '请输入金额'
|
||||
}
|
||||
}
|
||||
},
|
||||
props() {
|
||||
return [
|
||||
{
|
||||
type: 'switch',
|
||||
field: 'showUpper',
|
||||
title: '显示大写金额',
|
||||
value: true,
|
||||
props: { activeText: '是', inactiveText: '否' }
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
field: 'placeholder',
|
||||
title: '占位提示',
|
||||
value: '请输入金额'
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
field: 'formCreateInfo',
|
||||
title: '提示信息'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user