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
| import type { VbenFormSchema } from '#/adapter/form';
| import type { VxeTableGridOptions } from '#/adapter/vxe-table';
| import type { WmsApprovalApi } from '#/api/mes/wm/approval';
|
| import { h } from 'vue';
|
| import { Switch, Tag } from 'ant-design-vue';
|
| import { getWarehouseSimpleList } from '#/api/mes/wm/warehouse';
|
| /** 业务类型选项 */
| export const BIZ_TYPE_OPTIONS = [
| { label: '入库审批', value: 'INBOUND' },
| { label: '出库审批', value: 'OUTBOUND' },
| { label: '调拨审批', value: 'TRANSFER' },
| { label: '盘点审批', value: 'CHECK' },
| ];
|
| /** 列表的搜索表单 */
| export function useGridFormSchema(): VbenFormSchema[] {
| return [
| {
| fieldName: 'warehouseId',
| label: '仓库',
| component: 'ApiSelect',
| componentProps: {
| allowClear: true,
| api: getWarehouseSimpleList,
| labelField: 'name',
| valueField: 'id',
| placeholder: '请选择仓库',
| },
| },
| ];
| }
|
| /** 列表的字段 */
| export function useGridColumns(
| handleChange: (row: any, bizType: string, enabled: boolean) => void,
| ): VxeTableGridOptions['columns'] {
| return [
| {
| field: 'warehouseName',
| title: '仓库名称',
| minWidth: 160,
| },
| {
| field: 'warehouseCode',
| title: '仓库编码',
| minWidth: 120,
| },
| {
| title: '入库审批',
| width: 100,
| align: 'center',
| slots: {
| default: ({ row }) => {
| const config = row.configs?.find(
| (c: WmsApprovalApi.ApprovalConfig) => c.bizType === 'INBOUND',
| );
| return h(Switch, {
| checked: config?.approvalEnabled ?? false,
| checkedChildren: '开',
| unCheckedChildren: '关',
| onChange: (checked: boolean) => {
| handleChange(row, 'INBOUND', checked);
| },
| });
| },
| },
| },
| {
| title: '出库审批',
| width: 100,
| align: 'center',
| slots: {
| default: ({ row }) => {
| const config = row.configs?.find(
| (c: WmsApprovalApi.ApprovalConfig) => c.bizType === 'OUTBOUND',
| );
| return h(Switch, {
| checked: config?.approvalEnabled ?? false,
| checkedChildren: '开',
| unCheckedChildren: '关',
| onChange: (checked: boolean) => {
| handleChange(row, 'OUTBOUND', checked);
| },
| });
| },
| },
| },
| {
| title: '调拨审批',
| width: 100,
| align: 'center',
| slots: {
| default: ({ row }) => {
| const config = row.configs?.find(
| (c: WmsApprovalApi.ApprovalConfig) => c.bizType === 'TRANSFER',
| );
| return h(Switch, {
| checked: config?.approvalEnabled ?? false,
| checkedChildren: '开',
| unCheckedChildren: '关',
| onChange: (checked: boolean) => {
| handleChange(row, 'TRANSFER', checked);
| },
| });
| },
| },
| },
| {
| title: '盘点审批',
| width: 100,
| align: 'center',
| slots: {
| default: ({ row }) => {
| const config = row.configs?.find(
| (c: WmsApprovalApi.ApprovalConfig) => c.bizType === 'CHECK',
| );
| return h(Switch, {
| checked: config?.approvalEnabled ?? false,
| checkedChildren: '开',
| unCheckedChildren: '关',
| onChange: (checked: boolean) => {
| handleChange(row, 'CHECK', checked);
| },
| });
| },
| },
| },
| {
| title: '流程配置',
| minWidth: 200,
| slots: {
| default: ({ row }) => {
| const configs = row.configs || [];
| if (configs.length === 0) {
| return h(Tag, { color: 'default' }, () => '未配置');
| }
| const enabledConfigs = configs.filter(
| (c: WmsApprovalApi.ApprovalConfig) => c.approvalEnabled,
| );
| if (enabledConfigs.length === 0) {
| return h(Tag, { color: 'default' }, () => '未配置');
| }
| return h(
| 'div',
| { class: 'flex flex-wrap gap-1' },
| enabledConfigs.map((config: WmsApprovalApi.ApprovalConfig) => {
| const option = BIZ_TYPE_OPTIONS.find(
| (o) => o.value === config.bizType,
| );
| return h(
| Tag,
| {
| color: config.processDefinitionKey ? 'green' : 'orange',
| },
| () => option?.label || config.bizType,
| );
| }),
| );
| },
| },
| },
| {
| title: '操作',
| width: 100,
| fixed: 'right',
| slots: { default: 'actions' },
| },
| ];
| }
|
| /** 流程配置表单 */
| export function useProcessFormSchema(): VbenFormSchema[] {
| return [
| {
| fieldName: 'warehouseId',
| label: '仓库',
| component: 'Input',
| componentProps: {
| disabled: true,
| },
| },
| {
| fieldName: 'bizType',
| label: '业务类型',
| component: 'Select',
| componentProps: {
| options: BIZ_TYPE_OPTIONS,
| placeholder: '请选择业务类型',
| },
| rules: 'required',
| },
| {
| fieldName: 'processDefinitionKey',
| label: '审批流程',
| component: 'ApiSelect',
| componentProps: {
| allowClear: true,
| labelField: 'name',
| valueField: 'key',
| placeholder: '请选择审批流程',
| },
| rules: 'required',
| },
| ];
| }
|
|