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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
| import type { VbenFormSchema } from '#/adapter/form';
| import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
| /** 资产分类选项 */
| export const AssetCategoryOptions = [
| { label: '易耗品', value: 1 },
| { label: '办公资产', value: 2 },
| { label: '固定资产', value: 3 },
| ];
|
| /** 资产分类名称 */
| export function getCategoryName(category?: number) {
| return (
| AssetCategoryOptions.find((item) => item.value === category)?.label ?? '-'
| );
| }
|
| /** 新增/修改表单 */
| export function useFormSchema(formType: 'create' | 'edit' | 'detail') {
| const disabled = formType === 'detail';
| return [
| {
| fieldName: 'id',
| component: 'Input',
| dependencies: {
| triggerFields: [''],
| show: () => false,
| },
| },
| {
| fieldName: 'assetNo',
| label: '资产编号',
| component: 'Input',
| componentProps: {
| placeholder: '留空则由系统自动生成',
| maxlength: 32,
| disabled,
| },
| },
| {
| fieldName: 'name',
| label: '资产名称',
| component: 'Input',
| componentProps: {
| placeholder: '如:激光打印机 / A4 复印纸',
| maxlength: 128,
| disabled,
| },
| rules: 'required',
| },
| {
| fieldName: 'category',
| label: '资产分类',
| component: 'Select',
| componentProps: {
| options: AssetCategoryOptions,
| placeholder: '请选择资产分类',
| allowClear: true,
| disabled,
| },
| rules: 'required',
| },
| {
| fieldName: 'spec',
| label: '规格型号',
| component: 'Input',
| componentProps: {
| placeholder: '请输入规格型号',
| maxlength: 128,
| disabled,
| },
| },
| {
| fieldName: 'unit',
| label: '计量单位',
| component: 'Input',
| componentProps: {
| placeholder: '如:台 / 个 / 箱',
| maxlength: 16,
| disabled,
| },
| },
| {
| fieldName: 'quantity',
| label: '库存数量',
| component: 'InputNumber',
| componentProps: {
| placeholder: '请输入当前库存数量',
| min: 0,
| precision: 0,
| class: '!w-full',
| disabled,
| },
| rules: 'required',
| },
| {
| fieldName: 'unitPrice',
| label: '单价(元)',
| component: 'InputNumber',
| componentProps: {
| placeholder: '请输入单价',
| min: 0,
| precision: 2,
| class: '!w-full',
| disabled,
| },
| },
| {
| fieldName: 'purchaseDate',
| label: '购入日期',
| component: 'DatePicker',
| componentProps: {
| placeholder: '请选择购入日期',
| valueFormat: 'YYYY-MM-DD',
| style: { width: '100%' },
| disabled,
| },
| },
| {
| fieldName: 'custodianName',
| label: '保管人(管理人)',
| component: 'Input',
| componentProps: {
| placeholder: '请输入资产保管人姓名',
| maxlength: 64,
| disabled,
| },
| },
| {
| fieldName: 'location',
| label: '存放地点',
| component: 'Input',
| componentProps: {
| placeholder: '请输入存放地点',
| maxlength: 128,
| disabled,
| },
| },
| {
| fieldName: 'remark',
| label: '备注',
| component: 'Textarea',
| componentProps: {
| placeholder: '请输入备注',
| autoSize: { minRows: 2, maxRows: 3 },
| disabled,
| },
| formItemClass: 'col-span-2',
| },
| ] as VbenFormSchema[];
| }
|
| /** 列表搜索表单 */
| export function useGridFormSchema(): VbenFormSchema[] {
| return [
| {
| fieldName: 'assetNo',
| label: '资产编号',
| component: 'Input',
| componentProps: { placeholder: '请输入资产编号', allowClear: true },
| },
| {
| fieldName: 'name',
| label: '资产名称',
| component: 'Input',
| componentProps: { placeholder: '请输入资产名称', allowClear: true },
| },
| {
| fieldName: 'category',
| label: '资产分类',
| component: 'Select',
| componentProps: {
| options: AssetCategoryOptions,
| placeholder: '请选择资产分类',
| allowClear: true,
| },
| },
| {
| fieldName: 'custodianName',
| label: '保管人',
| component: 'Input',
| componentProps: { placeholder: '请输入保管人', allowClear: true },
| },
| ];
| }
|
| /** 列表列 */
| export function useGridColumns(): VxeTableGridOptions['columns'] {
| return [
| { field: 'assetNo', title: '资产编号', width: 180, fixed: 'left' },
| { field: 'name', title: '资产名称', minWidth: 150 },
| {
| field: 'category',
| title: '资产分类',
| width: 110,
| slots: { default: 'category' },
| },
| { field: 'spec', title: '规格型号', minWidth: 140 },
| { field: 'unit', title: '单位', width: 70 },
| { field: 'quantity', title: '库存数量', width: 100 },
| { field: 'unitPrice', title: '单价(元)', width: 110 },
| { field: 'totalAmount', title: '总价值(元)', width: 120 },
| { field: 'custodianName', title: '保管人', width: 110 },
| { field: 'location', title: '存放地点', minWidth: 140 },
| {
| title: '操作',
| width: 180,
| fixed: 'right',
| slots: { default: 'actions' },
| },
| ];
| }
|
|