feat(oa): register confirmation kit (转正套件) in FormCreate designer
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b22777fa2d
commit
898a337f96
6 files changed
+305
No files matched your search
@@ -0,0 +1,218 @@
|
||||
/** FormCreate Designer DragRule:转正套件 */
|
||||
|
||||
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'
|
||||
)
|
||||
}
|
||||
|
||||
export const CONFIRMATION_KIT_FIELD_DEFS = [
|
||||
{ key: 'hireDate', title: '入职日期', showProp: 'showHireDate' },
|
||||
{ key: 'probationMonths', title: '试用期(月)', showProp: 'showProbationMonths' },
|
||||
{ key: 'confirmationDate', title: '转正日期', showProp: 'showConfirmationDate' },
|
||||
{ key: 'post', title: '职位', showProp: 'showPost' },
|
||||
{ key: 'jobLevel', title: '岗位职级', showProp: 'showJobLevel' },
|
||||
{ key: 'name', title: '姓名', showProp: 'showName' },
|
||||
{ key: 'email', title: '邮箱', showProp: 'showEmail' },
|
||||
{ key: 'dept', title: '部门', showProp: 'showDept' },
|
||||
{ key: 'phone', title: '手机号', showProp: 'showPhone' }
|
||||
] as const
|
||||
|
||||
export type ConfirmationKitFieldKey = (typeof CONFIRMATION_KIT_FIELD_DEFS)[number]['key']
|
||||
|
||||
function buildConfirmationKitChildren() {
|
||||
const hireDateField = uniqueId()
|
||||
const probationMonthsField = uniqueId()
|
||||
const confirmationDateField = uniqueId()
|
||||
const postField = uniqueId()
|
||||
const jobLevelField = uniqueId()
|
||||
const nameField = uniqueId()
|
||||
const emailField = uniqueId()
|
||||
const deptField = uniqueId()
|
||||
const phoneField = uniqueId()
|
||||
|
||||
return {
|
||||
hireDateField,
|
||||
probationMonthsField,
|
||||
confirmationDateField,
|
||||
postField,
|
||||
jobLevelField,
|
||||
nameField,
|
||||
emailField,
|
||||
deptField,
|
||||
phoneField,
|
||||
children: [
|
||||
{
|
||||
type: 'datePicker',
|
||||
field: hireDateField,
|
||||
title: '入职日期',
|
||||
info: '',
|
||||
$required: true,
|
||||
props: {
|
||||
_fc_kit_field: 'hireDate',
|
||||
type: 'date',
|
||||
format: 'YYYY-MM-DD',
|
||||
valueFormat: 'YYYY-MM-DD',
|
||||
placeholder: '请选择入职日期'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'inputNumber',
|
||||
field: probationMonthsField,
|
||||
title: '试用期(月)',
|
||||
info: '',
|
||||
$required: true,
|
||||
props: {
|
||||
_fc_kit_field: 'probationMonths',
|
||||
min: 0,
|
||||
precision: 0,
|
||||
controlsPosition: 'right'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'datePicker',
|
||||
field: confirmationDateField,
|
||||
title: '转正日期',
|
||||
info: '可根据入职日期与试用期自动建议;手改后不再自动联动',
|
||||
$required: false,
|
||||
props: {
|
||||
_fc_kit_field: 'confirmationDate',
|
||||
type: 'date',
|
||||
format: 'YYYY-MM-DD',
|
||||
valueFormat: 'YYYY-MM-DD',
|
||||
placeholder: '请选择转正日期'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'post',
|
||||
field: postField,
|
||||
title: '职位',
|
||||
info: '',
|
||||
$required: false,
|
||||
props: {
|
||||
_fc_kit_field: 'post',
|
||||
multiple: true
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
field: jobLevelField,
|
||||
title: '岗位职级',
|
||||
info: '',
|
||||
$required: false,
|
||||
props: {
|
||||
_fc_kit_field: 'jobLevel',
|
||||
placeholder: '请输入岗位职级'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
field: nameField,
|
||||
title: '姓名',
|
||||
info: '',
|
||||
$required: true,
|
||||
props: {
|
||||
_fc_kit_field: 'name',
|
||||
placeholder: '请输入姓名'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
field: emailField,
|
||||
title: '邮箱',
|
||||
info: '',
|
||||
$required: false,
|
||||
props: {
|
||||
_fc_kit_field: 'email',
|
||||
placeholder: '请输入邮箱'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'dept',
|
||||
field: deptField,
|
||||
title: '部门',
|
||||
info: '',
|
||||
$required: true,
|
||||
props: {
|
||||
_fc_kit_field: 'dept',
|
||||
multiple: false
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
field: phoneField,
|
||||
title: '手机号',
|
||||
info: '',
|
||||
$required: false,
|
||||
props: {
|
||||
_fc_kit_field: 'phone',
|
||||
placeholder: '请输入手机号'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
export const confirmationKitDragRule = {
|
||||
menu: 'kit' as const,
|
||||
icon: 'icon-user',
|
||||
label: '转正',
|
||||
name: 'confirmationKit',
|
||||
input: false,
|
||||
drag: true,
|
||||
dragBtn: true,
|
||||
mask: false,
|
||||
inside: true,
|
||||
rule() {
|
||||
const built = buildConfirmationKitChildren()
|
||||
return {
|
||||
type: 'confirmationKit',
|
||||
props: {
|
||||
showHireDate: true,
|
||||
showProbationMonths: true,
|
||||
showConfirmationDate: true,
|
||||
showPost: true,
|
||||
showJobLevel: true,
|
||||
showName: true,
|
||||
showEmail: true,
|
||||
showDept: true,
|
||||
showPhone: true,
|
||||
hireDateField: built.hireDateField,
|
||||
probationMonthsField: built.probationMonthsField,
|
||||
confirmationDateField: built.confirmationDateField,
|
||||
postField: built.postField,
|
||||
jobLevelField: built.jobLevelField,
|
||||
nameField: built.nameField,
|
||||
emailField: built.emailField,
|
||||
deptField: built.deptField,
|
||||
phoneField: built.phoneField
|
||||
},
|
||||
children: built.children
|
||||
}
|
||||
},
|
||||
props() {
|
||||
const switches = CONFIRMATION_KIT_FIELD_DEFS.map((d) => ({
|
||||
type: 'switch',
|
||||
field: d.showProp,
|
||||
title: `显示:${d.title}`,
|
||||
value: true,
|
||||
props: { activeText: '显示', inactiveText: '隐藏' }
|
||||
}))
|
||||
return [
|
||||
...switches,
|
||||
{
|
||||
type: 'input',
|
||||
field: 'formCreateInfo',
|
||||
title: '提示',
|
||||
value: '隐藏字段仍会写入默认值;审批通过后可能回写用户主数据。',
|
||||
props: { disabled: true, type: 'textarea', rows: 2 }
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import FcDesigner from '@form-create/designer'
|
||||
import OaConfirmationKit from '@/components/oa-approval/OaConfirmationKit.vue'
|
||||
import { confirmationKitDragRule } from '@/utils/oa-confirmation-kit-rule'
|
||||
|
||||
const FLAG = '__oaConfirmationKitConfigured'
|
||||
|
||||
export function setupOaConfirmationKit(formCreate?: {
|
||||
component?: (name: string, c: unknown) => void
|
||||
}) {
|
||||
if ((FcDesigner as any)[FLAG]) return
|
||||
|
||||
// kit 菜单可能已由请假套件注册;幂等再调一次无妨
|
||||
if (typeof FcDesigner.addMenu === 'function') {
|
||||
try {
|
||||
FcDesigner.addMenu({ name: 'kit', title: '套件', list: [] })
|
||||
} catch {
|
||||
/* already */
|
||||
}
|
||||
}
|
||||
|
||||
FcDesigner.component('confirmationKit', OaConfirmationKit)
|
||||
if (typeof formCreate?.component === 'function') {
|
||||
formCreate.component('confirmationKit', OaConfirmationKit)
|
||||
}
|
||||
if (typeof FcDesigner.addDragRule === 'function') {
|
||||
FcDesigner.addDragRule(confirmationKitDragRule)
|
||||
}
|
||||
;(FcDesigner as any)[FLAG] = true
|
||||
}
|
||||
Reference in new issue
Block a user