admin-vben5/apps/web-antd/src/views/workflow/leave/data.tsx

136 lines
2.8 KiB
TypeScript
Raw Normal View History

2024-12-12 16:07:42 +08:00
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { DictEnum } from '@vben/constants';
import { getPopupContainer } from '@vben/utils';
import dayjs from 'dayjs';
import { OptionsTag } from '#/components/table';
import { renderDict } from '#/utils/render';
const leaveTypeOptions = [
{ label: '病假', value: '1' },
{ label: '事假', value: '2' },
{ label: '年假', value: '3' },
{ label: '婚假', value: '4' },
{ label: '产假', value: '5' },
{ label: '其他', value: '7' },
];
export const querySchema: FormSchemaGetter = () => [
{
component: 'InputNumber',
componentProps: {
min: 1,
},
fieldName: 'startLeaveDays',
label: '请假天数',
},
{
component: 'InputNumber',
componentProps: {
min: 1,
},
fieldName: 'endLeaveDays',
label: '至',
labelClass: 'justify-center',
},
];
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '请假类型',
field: 'leaveType',
slots: {
default: ({ row }) => {
return <OptionsTag options={leaveTypeOptions} value={row.leaveType} />;
},
},
},
{
title: '开始时间',
field: 'startDate',
formatter: ({ cellValue }) => dayjs(cellValue).format('YYYY-MM-DD'),
},
{
title: '结束时间',
field: 'endDate',
formatter: ({ cellValue }) => dayjs(cellValue).format('YYYY-MM-DD'),
},
{
title: '请假天数',
field: 'leaveDays',
formatter: ({ cellValue }) => `${cellValue}`,
},
{
title: '请假原因',
field: 'remark',
},
{
title: '流程状态',
field: 'status',
slots: {
default: ({ row }) => {
return renderDict(row.status, DictEnum.WF_BUSINESS_STATUS);
},
},
},
{
field: 'action',
fixed: 'right',
slots: { default: 'action' },
title: '操作',
width: 180,
},
];
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '请假类型',
fieldName: 'leaveType',
component: 'Select',
componentProps: {
options: leaveTypeOptions,
getPopupContainer,
},
rules: 'selectRequired',
},
{
label: '开始时间',
fieldName: 'dateRange',
component: 'RangePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
rules: 'required',
},
{
label: '请假天数',
fieldName: 'leaveDays',
component: 'Input',
componentProps: {
disabled: true,
},
rules: 'required',
},
{
label: '请假原因',
fieldName: 'remark',
component: 'Textarea',
formItemClass: 'items-baseline',
},
];