gaoluyang
3 小时以前 787ccc59ba89bacc075562a161ecf02bc76ebadc
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
102
103
104
105
106
107
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { HrmTaxRateConfigApi } from '#/api/hrm/salary/tax-rate-config';
 
/** 表单类型 */
export type FormType = 'create' | 'update';
 
/** 新增/修改个税税率配置的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'level',
      label: '税率级数',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入税率级数',
        min: 1,
        max: 7,
        precision: 0,
      },
      rules: 'required',
    },
    {
      fieldName: 'minAmount',
      label: '应纳税所得额下限',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入下限(含)',
        min: 0,
        precision: 2,
      },
      rules: 'required',
    },
    {
      fieldName: 'maxAmount',
      label: '应纳税所得额上限',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入上限(不含),0表示无上限',
        min: 0,
        precision: 2,
      },
      help: '上限不含,0表示无上限',
    },
    {
      fieldName: 'taxRate',
      label: '税率',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入税率',
        min: 0,
        max: 1,
        step: 0.01,
        precision: 4,
        formatter: (value: number) => `${(value * 100).toFixed(0)}%`,
        parser: (value: string) => parseFloat(value.replace('%', '')) / 100,
      },
      rules: 'required',
    },
    {
      fieldName: 'quickDeduction',
      label: '速算扣除数',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入速算扣除数',
        min: 0,
        precision: 2,
      },
      rules: 'required',
    },
  ];
}
 
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<HrmTaxRateConfigApi.TaxRateConfig>['columns'] {
  return [
    { field: 'level', title: '级数', width: 80 },
    {
      field: 'amountRange',
      title: '应纳税所得额',
      minWidth: 200,
      slots: { default: 'amountRange' },
    },
    {
      field: 'taxRate',
      title: '税率',
      width: 100,
      slots: { default: 'taxRate' },
    },
    { field: 'quickDeduction', title: '速算扣除数', width: 120, formatter: 'formatAmount2' },
    { field: 'effectiveDate', title: '生效日期', width: 110 },
    {
      title: '操作',
      width: 150,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}