gaoluyang
昨天 b64a0deae5b5d33f9e20671a68936b27f0b9b00b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { HrmLeaveTypeConfigApi } from '#/api/hrm/leave-type-config';
 
/** 表单类型 */
export type FormType = 'update';
 
/** 新增/修改请假扣款配置的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'name',
      label: '请假类型',
      component: 'Input',
      componentProps: {
        disabled: true,
        placeholder: '',
      },
      formItemClass: 'col-span-2',
    },
    {
      fieldName: 'deductionRatio',
      label: '扣款比例',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入扣款比例',
        min: 0,
        max: 100,
        step: 10,
        precision: 0,
        formatter: (value: number) => `${value}%`,
        parser: (value: string) => parseFloat(value.replace('%', '')),
        style: { width: '100%' },
      },
      rules: 'required',
      help: '扣款比例,如50%表示按一半扣款',
    },
    {
      fieldName: 'status',
      label: '状态',
      component: 'RadioGroup',
      componentProps: {
        options: [
          { label: '启用', value: 0 },
          { label: '禁用', value: 1 },
        ],
      },
      rules: 'required',
    },
    {
      fieldName: 'remark',
      label: '备注',
      component: 'Textarea',
      componentProps: {
        placeholder: '请输入备注',
        rows: 2,
      },
      formItemClass: 'col-span-2',
    },
  ];
}
 
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<HrmLeaveTypeConfigApi.LeaveTypeConfig>['columns'] {
  return [
    { field: 'name', title: '请假类型', minWidth: 120 },
    {
      field: 'deductionRatio',
      title: '扣款比例',
      width: 120,
      slots: { default: 'deductionRatio' },
    },
    { field: 'remark', title: '备注', minWidth: 200 },
    {
      field: 'status',
      title: '状态',
      width: 80,
      slots: { default: 'status' },
    },
    {
      field: 'createTime',
      title: '创建时间',
      width: 180,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 100,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}