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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
| import type { VbenFormSchema } from '#/adapter/form';
| import type { VxeTableGridOptions } from '#/adapter/vxe-table';
| import type { MesCalScheduleDetailApi } from '#/api/mes/cal/scheduleDetail';
|
| import { getPlanPage } from '#/api/mes/cal/plan';
| import { getTeamList } from '#/api/mes/cal/team';
| import { getSimpleUserList } from '#/api/system/user';
| import { getRangePickerDefaultProps } from '#/utils';
|
| /** 下拉选项 */
| export interface OptionItem {
| label: string;
| value: number;
| }
|
| /** 来源:自动生成 */
| export const SOURCE_AUTO = 1;
| /** 来源:人工调整 */
| export const SOURCE_MANUAL = 2;
|
| /** 违规类型描述 */
| export const issueTypeMap: Record<number, string> = {
| 1: '单日疑似连续工时超长',
| 2: '相邻班次间休息不足',
| };
|
| /** 排班计划选项缓存(搜索表单与列表名称回显共用) */
| let planOptionsCache: OptionItem[] | undefined;
|
| export async function fetchPlanOptions(): Promise<OptionItem[]> {
| if (planOptionsCache) {
| return planOptionsCache;
| }
| const page = await getPlanPage({ pageNo: 1, pageSize: 100 });
| planOptionsCache = page.list.map((item) => ({
| label: item.name!,
| value: item.id!,
| }));
| return planOptionsCache;
| }
|
| /** 班组选项缓存 */
| let teamOptionsCache: OptionItem[] | undefined;
|
| export async function fetchTeamOptions(): Promise<OptionItem[]> {
| if (teamOptionsCache) {
| return teamOptionsCache;
| }
| const list = await getTeamList();
| teamOptionsCache = list.map((item) => ({
| label: item.name!,
| value: item.id!,
| }));
| return teamOptionsCache;
| }
|
| /** 员工选项缓存 */
| let userOptionsCache: OptionItem[] | undefined;
|
| export async function fetchUserOptions(): Promise<OptionItem[]> {
| if (userOptionsCache) {
| return userOptionsCache;
| }
| const list = await getSimpleUserList();
| userOptionsCache = list.map((item) => ({
| label: item.nickname!,
| value: item.id!,
| }));
| return userOptionsCache;
| }
|
| /** 生成排班明细的表单 */
| export function useGenerateFormSchema(): VbenFormSchema[] {
| return [
| {
| fieldName: 'planId',
| label: '排班计划',
| component: 'ApiSelect',
| componentProps: {
| allowClear: true,
| api: fetchPlanOptions,
| optionFilterProp: 'label',
| placeholder: '请选择排班计划',
| showSearch: true,
| },
| rules: 'selectRequired',
| help: '按该计划下的班组排班展开为员工级明细,重复生成会先清理旧明细',
| },
| ];
| }
|
| /** 人工调整排班明细的表单 */
| export function useFormSchema(): VbenFormSchema[] {
| return [
| {
| fieldName: 'id',
| component: 'Input',
| dependencies: {
| triggerFields: [''],
| show: () => false,
| },
| },
| {
| fieldName: 'shiftId',
| component: 'Input',
| dependencies: {
| triggerFields: [''],
| show: () => false,
| },
| },
| {
| fieldName: 'shiftName',
| label: '班次名称',
| component: 'Input',
| componentProps: {
| placeholder: '请输入班次名称',
| },
| rules: 'required',
| },
| {
| fieldName: 'startTime',
| label: '开始时间',
| component: 'TimePicker',
| componentProps: {
| class: '!w-full',
| format: 'HH:mm',
| placeholder: '请选择开始时间',
| valueFormat: 'HH:mm',
| },
| rules: 'required',
| },
| {
| fieldName: 'endTime',
| label: '结束时间',
| component: 'TimePicker',
| componentProps: {
| class: '!w-full',
| format: 'HH:mm',
| placeholder: '请选择结束时间',
| valueFormat: 'HH:mm',
| },
| rules: 'required',
| },
| {
| fieldName: 'remark',
| label: '备注',
| component: 'Textarea',
| componentProps: {
| placeholder: '请输入备注',
| rows: 3,
| },
| },
| ];
| }
|
| /** 列表的搜索表单 */
| export function useGridFormSchema(): VbenFormSchema[] {
| return [
| {
| fieldName: 'planId',
| label: '排班计划',
| component: 'ApiSelect',
| componentProps: {
| allowClear: true,
| api: fetchPlanOptions,
| optionFilterProp: 'label',
| placeholder: '请选择排班计划',
| showSearch: true,
| },
| },
| {
| fieldName: 'teamId',
| label: '班组',
| component: 'ApiSelect',
| componentProps: {
| allowClear: true,
| api: fetchTeamOptions,
| optionFilterProp: 'label',
| placeholder: '请选择班组',
| showSearch: true,
| },
| },
| {
| fieldName: 'userId',
| label: '员工',
| component: 'ApiSelect',
| componentProps: {
| allowClear: true,
| api: fetchUserOptions,
| optionFilterProp: 'label',
| placeholder: '请选择员工',
| showSearch: true,
| },
| },
| {
| fieldName: 'day',
| label: '日期',
| component: 'RangePicker',
| componentProps: {
| ...getRangePickerDefaultProps(),
| },
| },
| ];
| }
|
| /** 列表的字段 */
| export function useGridColumns(): VxeTableGridOptions<MesCalScheduleDetailApi.Detail>['columns'] {
| return [
| {
| field: 'day',
| title: '日期',
| minWidth: 120,
| formatter: 'formatDate',
| },
| {
| field: 'planId',
| title: '排班计划',
| minWidth: 150,
| slots: { default: 'planId' },
| },
| {
| field: 'teamId',
| title: '班组',
| minWidth: 120,
| slots: { default: 'teamId' },
| },
| {
| field: 'userId',
| title: '员工',
| minWidth: 100,
| slots: { default: 'userId' },
| },
| { field: 'shiftName', title: '班次名称', minWidth: 110 },
| { field: 'startTime', title: '开始时间', width: 100 },
| { field: 'endTime', title: '结束时间', width: 100 },
| {
| field: 'source',
| title: '来源',
| width: 110,
| slots: { default: 'source' },
| },
| { field: 'remark', title: '备注', minWidth: 140 },
| {
| title: '操作',
| width: 180,
| fixed: 'right',
| slots: {
| default: 'actions',
| },
| },
| ];
| }
|
|