144 lines
3.4 KiB
TypeScript
144 lines
3.4 KiB
TypeScript
import { DEFAULT_OVERTIME_WINDOWS } from '@/utils/oa-overtime-hours'
|
||
|
||
/** 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) +
|
||
'o'
|
||
)
|
||
}
|
||
|
||
function buildOvertimeKitChildren() {
|
||
const personField = uniqueId()
|
||
const startField = uniqueId()
|
||
const endField = uniqueId()
|
||
const durationField = uniqueId()
|
||
return {
|
||
personField,
|
||
startField,
|
||
endField,
|
||
durationField,
|
||
children: [
|
||
{
|
||
type: 'person',
|
||
field: personField,
|
||
title: '加班人',
|
||
info: '',
|
||
$required: true,
|
||
props: {
|
||
_fc_kit_field: 'overtimePerson',
|
||
multiple: true
|
||
}
|
||
},
|
||
{
|
||
type: 'datePicker',
|
||
field: startField,
|
||
title: '开始时间',
|
||
info: '',
|
||
$required: true,
|
||
props: {
|
||
_fc_kit_field: 'overtimeStart',
|
||
type: 'datetime',
|
||
format: 'YYYY-MM-DD HH:mm',
|
||
valueFormat: 'YYYY-MM-DD HH:mm',
|
||
placeholder: '请选择开始时间'
|
||
}
|
||
},
|
||
{
|
||
type: 'datePicker',
|
||
field: endField,
|
||
title: '结束时间',
|
||
info: '',
|
||
$required: true,
|
||
props: {
|
||
_fc_kit_field: 'overtimeEnd',
|
||
type: 'datetime',
|
||
format: 'YYYY-MM-DD HH:mm',
|
||
valueFormat: 'YYYY-MM-DD HH:mm',
|
||
placeholder: '请选择结束时间'
|
||
}
|
||
},
|
||
{
|
||
type: 'inputNumber',
|
||
field: durationField,
|
||
title: '时长(h)',
|
||
info: '可根据起止时间自动计算,支持手改',
|
||
$required: true,
|
||
props: {
|
||
_fc_kit_field: 'overtimeDuration',
|
||
precision: 1,
|
||
min: 0,
|
||
controlsPosition: 'right',
|
||
align: 'left'
|
||
},
|
||
class: 'oa-overtime-duration'
|
||
}
|
||
]
|
||
}
|
||
}
|
||
|
||
/** FormCreate Designer DragRule:加班套件 */
|
||
export const overtimeKitDragRule = {
|
||
menu: 'kit' as const,
|
||
icon: 'icon-time',
|
||
label: '加班',
|
||
name: 'overtimeKit',
|
||
input: false,
|
||
drag: true,
|
||
dragBtn: true,
|
||
mask: false,
|
||
inside: true,
|
||
rule() {
|
||
const built = buildOvertimeKitChildren()
|
||
return {
|
||
type: 'overtimeKit',
|
||
props: {
|
||
...DEFAULT_OVERTIME_WINDOWS,
|
||
personField: built.personField,
|
||
startField: built.startField,
|
||
endField: built.endField,
|
||
durationField: built.durationField
|
||
},
|
||
children: built.children
|
||
}
|
||
},
|
||
props() {
|
||
return [
|
||
{
|
||
type: 'input',
|
||
field: 'workdayOvertimeStart',
|
||
title: '工作日加班起',
|
||
value: DEFAULT_OVERTIME_WINDOWS.workdayOvertimeStart,
|
||
props: { placeholder: 'HH:mm' }
|
||
},
|
||
{
|
||
type: 'input',
|
||
field: 'workdayOvertimeEnd',
|
||
title: '工作日加班止(次日)',
|
||
value: DEFAULT_OVERTIME_WINDOWS.workdayOvertimeEnd,
|
||
props: { placeholder: 'HH:mm' }
|
||
},
|
||
{
|
||
type: 'input',
|
||
field: 'restBreakStart',
|
||
title: '休息日午休起',
|
||
value: DEFAULT_OVERTIME_WINDOWS.restBreakStart,
|
||
props: { placeholder: 'HH:mm' }
|
||
},
|
||
{
|
||
type: 'input',
|
||
field: 'restBreakEnd',
|
||
title: '休息日午休止',
|
||
value: DEFAULT_OVERTIME_WINDOWS.restBreakEnd,
|
||
props: { placeholder: 'HH:mm' }
|
||
}
|
||
]
|
||
}
|
||
}
|