Files
zkxw/web-admin/src/utils/oa-confirmation-kit-rule.ts
T
zlwuandCursor 06db3bc966 feat(permission): replace OA roles with post-bound roles and assignee posts
Unify effective roles via post-role bindings, remove dedicated OA role UI, and update OA assignee resolution plus related SQL/docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-04 17:41:04 +08:00

219 lines
5.6 KiB
TypeScript

/** 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-idcard',
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 }
}
]
}
}