@nokecy/qc-ui 1.1.9 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -211,12 +211,87 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
211
211
|
onClose();
|
|
212
212
|
}, [snapshotColumnDefs, gridApi, onClose]);
|
|
213
213
|
|
|
214
|
+
/**
|
|
215
|
+
* 加载方案
|
|
216
|
+
* 应用方案到 Grid,并更新表单数据
|
|
217
|
+
*/
|
|
218
|
+
var handleLoadScheme = useCallback( /*#__PURE__*/function () {
|
|
219
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(schemeId) {
|
|
220
|
+
var scheme, gridColumnDefs, columnState;
|
|
221
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
222
|
+
while (1) switch (_context.prev = _context.next) {
|
|
223
|
+
case 0:
|
|
224
|
+
_context.prev = 0;
|
|
225
|
+
_context.next = 3;
|
|
226
|
+
return setCurrentColumnScheme === null || setCurrentColumnScheme === void 0 ? void 0 : setCurrentColumnScheme(gridKey, schemeId);
|
|
227
|
+
case 3:
|
|
228
|
+
// 应用方案到 Grid
|
|
229
|
+
scheme = schemes.find(function (s) {
|
|
230
|
+
return s.id === schemeId;
|
|
231
|
+
});
|
|
232
|
+
if (!(scheme && gridApi)) {
|
|
233
|
+
_context.next = 12;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
// 【关键修复】先更新 columnDefs(处理分组结构)
|
|
237
|
+
gridColumnDefs = flatConfigToGridState(scheme.columnConfig, originalColumnDefs);
|
|
238
|
+
gridApi.setGridOption('columnDefs', gridColumnDefs);
|
|
239
|
+
|
|
240
|
+
// 等待 columnDefs 更新完成
|
|
241
|
+
_context.next = 9;
|
|
242
|
+
return new Promise(function (resolve) {
|
|
243
|
+
return setTimeout(resolve, 100);
|
|
244
|
+
});
|
|
245
|
+
case 9:
|
|
246
|
+
// 【修复】然后应用列状态(宽度、隐藏、顺序等)
|
|
247
|
+
columnState = flatConfigToColumnState(scheme.columnConfig);
|
|
248
|
+
gridApi.applyColumnState({
|
|
249
|
+
state: columnState,
|
|
250
|
+
applyOrder: true // 强制应用列顺序
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// 应用过滤器
|
|
254
|
+
if (scheme.filterModel) {
|
|
255
|
+
gridApi.setFilterModel(scheme.filterModel);
|
|
256
|
+
}
|
|
257
|
+
case 12:
|
|
258
|
+
message.success('方案已加载');
|
|
259
|
+
|
|
260
|
+
// 等待Grid状态更新后再刷新表单
|
|
261
|
+
setTimeout(function () {
|
|
262
|
+
if (form) {
|
|
263
|
+
var newData = getColumnData();
|
|
264
|
+
form.setValues({
|
|
265
|
+
items: newData
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}, 100);
|
|
269
|
+
|
|
270
|
+
// 自动关闭弹窗,让用户看到Grid的变化
|
|
271
|
+
onClose();
|
|
272
|
+
_context.next = 20;
|
|
273
|
+
break;
|
|
274
|
+
case 17:
|
|
275
|
+
_context.prev = 17;
|
|
276
|
+
_context.t0 = _context["catch"](0);
|
|
277
|
+
message.error(_context.t0.message || '加载方案失败');
|
|
278
|
+
case 20:
|
|
279
|
+
case "end":
|
|
280
|
+
return _context.stop();
|
|
281
|
+
}
|
|
282
|
+
}, _callee, null, [[0, 17]]);
|
|
283
|
+
}));
|
|
284
|
+
return function (_x) {
|
|
285
|
+
return _ref2.apply(this, arguments);
|
|
286
|
+
};
|
|
287
|
+
}(), [setCurrentColumnScheme, gridKey, schemes, gridApi, originalColumnDefs, form, getColumnData, onClose]);
|
|
288
|
+
|
|
214
289
|
/**
|
|
215
290
|
* 保存列配置
|
|
216
|
-
*
|
|
291
|
+
* 优化逻辑:先保存配置到存储,再通过 handleLoadScheme 统一加载
|
|
217
292
|
*/
|
|
218
293
|
var handleSaveColumns = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
219
|
-
var values, flatConfig, configToSave, invalidColumns,
|
|
294
|
+
var values, flatConfig, configToSave, invalidColumns, filterModel, schemeIdToLoad, defaultScheme, newScheme;
|
|
220
295
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
221
296
|
while (1) switch (_context2.prev = _context2.next) {
|
|
222
297
|
case 0:
|
|
@@ -234,7 +309,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
234
309
|
message.info('检测到旧版本配置,已自动迁移到新格式');
|
|
235
310
|
}
|
|
236
311
|
|
|
237
|
-
//
|
|
312
|
+
// 验证数据完整性,过滤掉无效的列配置
|
|
238
313
|
invalidColumns = configToSave.filter(function (item) {
|
|
239
314
|
return item.type === 'column' && item.field !== "" && !item.field;
|
|
240
315
|
});
|
|
@@ -245,114 +320,78 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
245
320
|
return item.type === 'group' || item.type === 'column' && item.field;
|
|
246
321
|
});
|
|
247
322
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
_context2.next =
|
|
255
|
-
return
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
// 等待 Grid 状态更新完成后再保存到方案
|
|
267
|
-
setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
268
|
-
var filterModel, defaultScheme, newScheme;
|
|
269
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
270
|
-
while (1) switch (_context.prev = _context.next) {
|
|
271
|
-
case 0:
|
|
272
|
-
_context.prev = 0;
|
|
273
|
-
filterModel = gridApi.getFilterModel();
|
|
274
|
-
if (!currentScheme) {
|
|
275
|
-
_context.next = 8;
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
_context.next = 5;
|
|
279
|
-
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, _objectSpread(_objectSpread({}, currentScheme), {}, {
|
|
280
|
-
columnConfig: configToSave,
|
|
281
|
-
filterModel: filterModel,
|
|
282
|
-
updatedAt: Date.now()
|
|
283
|
-
}));
|
|
284
|
-
case 5:
|
|
285
|
-
message.success('列配置已保存到方案');
|
|
286
|
-
_context.next = 23;
|
|
287
|
-
break;
|
|
288
|
-
case 8:
|
|
289
|
-
// 如果没有激活的方案,自动创建默认方案
|
|
290
|
-
defaultScheme = schemes.find(function (s) {
|
|
291
|
-
return s.isDefault;
|
|
292
|
-
});
|
|
293
|
-
if (!defaultScheme) {
|
|
294
|
-
_context.next = 17;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
_context.next = 12;
|
|
298
|
-
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, _objectSpread(_objectSpread({}, defaultScheme), {}, {
|
|
299
|
-
columnConfig: configToSave,
|
|
300
|
-
filterModel: filterModel,
|
|
301
|
-
updatedAt: Date.now()
|
|
302
|
-
}));
|
|
303
|
-
case 12:
|
|
304
|
-
_context.next = 14;
|
|
305
|
-
return setCurrentColumnScheme === null || setCurrentColumnScheme === void 0 ? void 0 : setCurrentColumnScheme(gridKey, defaultScheme.id);
|
|
306
|
-
case 14:
|
|
307
|
-
message.success('列配置已保存到默认方案');
|
|
308
|
-
_context.next = 23;
|
|
309
|
-
break;
|
|
310
|
-
case 17:
|
|
311
|
-
// 创建新的默认方案并激活
|
|
312
|
-
newScheme = {
|
|
313
|
-
id: uuidv4(),
|
|
314
|
-
name: '默认配置',
|
|
315
|
-
description: '自动创建的默认列配置',
|
|
316
|
-
columnConfig: configToSave,
|
|
317
|
-
filterModel: filterModel,
|
|
318
|
-
isDefault: true,
|
|
319
|
-
isSystem: false,
|
|
320
|
-
createdAt: Date.now(),
|
|
321
|
-
updatedAt: Date.now()
|
|
322
|
-
};
|
|
323
|
-
_context.next = 20;
|
|
324
|
-
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, newScheme);
|
|
325
|
-
case 20:
|
|
326
|
-
_context.next = 22;
|
|
327
|
-
return setCurrentColumnScheme === null || setCurrentColumnScheme === void 0 ? void 0 : setCurrentColumnScheme(gridKey, newScheme.id);
|
|
328
|
-
case 22:
|
|
329
|
-
message.success('已创建并保存到默认方案');
|
|
330
|
-
case 23:
|
|
331
|
-
_context.next = 29;
|
|
332
|
-
break;
|
|
333
|
-
case 25:
|
|
334
|
-
_context.prev = 25;
|
|
335
|
-
_context.t0 = _context["catch"](0);
|
|
336
|
-
console.error('保存列配置到方案失败:', _context.t0);
|
|
337
|
-
message.error('保存列配置失败');
|
|
338
|
-
case 29:
|
|
339
|
-
case "end":
|
|
340
|
-
return _context.stop();
|
|
341
|
-
}
|
|
342
|
-
}, _callee, null, [[0, 25]]);
|
|
343
|
-
})), 50);
|
|
344
|
-
|
|
345
|
-
// 【修复】保存成功后清除快照
|
|
346
|
-
setSnapshotColumnDefs(null);
|
|
347
|
-
|
|
348
|
-
// message.success 已经在上面的逻辑中处理了
|
|
349
|
-
onClose();
|
|
323
|
+
_context2.prev = 8;
|
|
324
|
+
filterModel = gridApi.getFilterModel();
|
|
325
|
+
if (!currentScheme) {
|
|
326
|
+
_context2.next = 17;
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
_context2.next = 13;
|
|
330
|
+
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, _objectSpread(_objectSpread({}, currentScheme), {}, {
|
|
331
|
+
columnConfig: configToSave,
|
|
332
|
+
filterModel: filterModel,
|
|
333
|
+
updatedAt: Date.now()
|
|
334
|
+
}));
|
|
335
|
+
case 13:
|
|
336
|
+
schemeIdToLoad = currentScheme.id;
|
|
337
|
+
message.success('列配置已保存到方案');
|
|
338
|
+
_context2.next = 30;
|
|
339
|
+
break;
|
|
350
340
|
case 17:
|
|
341
|
+
// 如果没有激活的方案,自动创建或更新默认方案
|
|
342
|
+
defaultScheme = schemes.find(function (s) {
|
|
343
|
+
return s.isDefault;
|
|
344
|
+
});
|
|
345
|
+
if (!defaultScheme) {
|
|
346
|
+
_context2.next = 25;
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
_context2.next = 21;
|
|
350
|
+
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, _objectSpread(_objectSpread({}, defaultScheme), {}, {
|
|
351
|
+
columnConfig: configToSave,
|
|
352
|
+
filterModel: filterModel,
|
|
353
|
+
updatedAt: Date.now()
|
|
354
|
+
}));
|
|
355
|
+
case 21:
|
|
356
|
+
schemeIdToLoad = defaultScheme.id;
|
|
357
|
+
message.success('列配置已保存到默认方案');
|
|
358
|
+
_context2.next = 30;
|
|
359
|
+
break;
|
|
360
|
+
case 25:
|
|
361
|
+
// 创建新的默认方案
|
|
362
|
+
newScheme = {
|
|
363
|
+
id: uuidv4(),
|
|
364
|
+
name: '默认配置',
|
|
365
|
+
description: '自动创建的默认列配置',
|
|
366
|
+
columnConfig: configToSave,
|
|
367
|
+
filterModel: filterModel,
|
|
368
|
+
isDefault: true,
|
|
369
|
+
isSystem: false,
|
|
370
|
+
createdAt: Date.now(),
|
|
371
|
+
updatedAt: Date.now()
|
|
372
|
+
};
|
|
373
|
+
_context2.next = 28;
|
|
374
|
+
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, newScheme);
|
|
375
|
+
case 28:
|
|
376
|
+
schemeIdToLoad = newScheme.id;
|
|
377
|
+
message.success('已创建并保存到默认方案');
|
|
378
|
+
case 30:
|
|
379
|
+
_context2.next = 32;
|
|
380
|
+
return handleLoadScheme(schemeIdToLoad);
|
|
381
|
+
case 32:
|
|
382
|
+
_context2.next = 38;
|
|
383
|
+
break;
|
|
384
|
+
case 34:
|
|
385
|
+
_context2.prev = 34;
|
|
386
|
+
_context2.t0 = _context2["catch"](8);
|
|
387
|
+
console.error('保存列配置到方案失败:', _context2.t0);
|
|
388
|
+
message.error('保存列配置失败');
|
|
389
|
+
case 38:
|
|
351
390
|
case "end":
|
|
352
391
|
return _context2.stop();
|
|
353
392
|
}
|
|
354
|
-
}, _callee2);
|
|
355
|
-
})), [form, gridApi,
|
|
393
|
+
}, _callee2, null, [[8, 34]]);
|
|
394
|
+
})), [form, gridApi, saveColumnScheme, setCurrentColumnScheme, currentScheme, schemes, gridKey, handleLoadScheme]);
|
|
356
395
|
|
|
357
396
|
// 保存为新方案
|
|
358
397
|
var handleSaveScheme = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
@@ -440,128 +479,56 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
440
479
|
}, _callee3, null, [[3, 30]]);
|
|
441
480
|
})), [gridApi, saveColumnScheme, gridKey, schemeName, schemeDescription, activeTab, form, originalColumnDefs]);
|
|
442
481
|
|
|
443
|
-
//
|
|
444
|
-
var
|
|
482
|
+
// 设置默认方案
|
|
483
|
+
var handleSetDefault = useCallback( /*#__PURE__*/function () {
|
|
445
484
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(schemeId) {
|
|
446
|
-
var scheme,
|
|
485
|
+
var scheme, _iterator, _step, s;
|
|
447
486
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
448
487
|
while (1) switch (_context4.prev = _context4.next) {
|
|
449
488
|
case 0:
|
|
450
489
|
_context4.prev = 0;
|
|
451
|
-
_context4.next = 3;
|
|
452
|
-
return setCurrentColumnScheme === null || setCurrentColumnScheme === void 0 ? void 0 : setCurrentColumnScheme(gridKey, schemeId);
|
|
453
|
-
case 3:
|
|
454
|
-
// 应用方案到 Grid
|
|
455
|
-
scheme = schemes.find(function (s) {
|
|
456
|
-
return s.id === schemeId;
|
|
457
|
-
});
|
|
458
|
-
if (!(scheme && gridApi)) {
|
|
459
|
-
_context4.next = 12;
|
|
460
|
-
break;
|
|
461
|
-
}
|
|
462
|
-
// 【关键修复】先更新 columnDefs(处理分组结构)
|
|
463
|
-
gridColumnDefs = flatConfigToGridState(scheme.columnConfig, originalColumnDefs);
|
|
464
|
-
gridApi.setGridOption('columnDefs', gridColumnDefs);
|
|
465
|
-
|
|
466
|
-
// 等待 columnDefs 更新完成
|
|
467
|
-
_context4.next = 9;
|
|
468
|
-
return new Promise(function (resolve) {
|
|
469
|
-
return setTimeout(resolve, 100);
|
|
470
|
-
});
|
|
471
|
-
case 9:
|
|
472
|
-
// 【修复】然后应用列状态(宽度、隐藏、顺序等)
|
|
473
|
-
columnState = flatConfigToColumnState(scheme.columnConfig);
|
|
474
|
-
gridApi.applyColumnState({
|
|
475
|
-
state: columnState,
|
|
476
|
-
applyOrder: true // 强制应用列顺序
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
// 应用过滤器
|
|
480
|
-
if (scheme.filterModel) {
|
|
481
|
-
gridApi.setFilterModel(scheme.filterModel);
|
|
482
|
-
}
|
|
483
|
-
case 12:
|
|
484
|
-
message.success('方案已加载');
|
|
485
|
-
|
|
486
|
-
// 等待Grid状态更新后再刷新表单
|
|
487
|
-
setTimeout(function () {
|
|
488
|
-
if (form) {
|
|
489
|
-
var newData = getColumnData();
|
|
490
|
-
form.setValues({
|
|
491
|
-
items: newData
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
}, 100);
|
|
495
|
-
|
|
496
|
-
// 自动关闭弹窗,让用户看到Grid的变化
|
|
497
|
-
onClose();
|
|
498
|
-
_context4.next = 20;
|
|
499
|
-
break;
|
|
500
|
-
case 17:
|
|
501
|
-
_context4.prev = 17;
|
|
502
|
-
_context4.t0 = _context4["catch"](0);
|
|
503
|
-
message.error(_context4.t0.message || '加载方案失败');
|
|
504
|
-
case 20:
|
|
505
|
-
case "end":
|
|
506
|
-
return _context4.stop();
|
|
507
|
-
}
|
|
508
|
-
}, _callee4, null, [[0, 17]]);
|
|
509
|
-
}));
|
|
510
|
-
return function (_x) {
|
|
511
|
-
return _ref5.apply(this, arguments);
|
|
512
|
-
};
|
|
513
|
-
}(), [setCurrentColumnScheme, gridKey, schemes, gridApi, originalColumnDefs, form, getColumnData, onClose]);
|
|
514
|
-
|
|
515
|
-
// 设置默认方案
|
|
516
|
-
var handleSetDefault = useCallback( /*#__PURE__*/function () {
|
|
517
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(schemeId) {
|
|
518
|
-
var scheme, _iterator, _step, s;
|
|
519
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
520
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
521
|
-
case 0:
|
|
522
|
-
_context5.prev = 0;
|
|
523
490
|
scheme = schemes.find(function (s) {
|
|
524
491
|
return s.id === schemeId;
|
|
525
492
|
});
|
|
526
493
|
if (!scheme) {
|
|
527
|
-
|
|
494
|
+
_context4.next = 24;
|
|
528
495
|
break;
|
|
529
496
|
}
|
|
530
497
|
// 将其他方案设为非默认
|
|
531
498
|
_iterator = _createForOfIteratorHelper(schemes);
|
|
532
|
-
|
|
499
|
+
_context4.prev = 4;
|
|
533
500
|
_iterator.s();
|
|
534
501
|
case 6:
|
|
535
502
|
if ((_step = _iterator.n()).done) {
|
|
536
|
-
|
|
503
|
+
_context4.next = 13;
|
|
537
504
|
break;
|
|
538
505
|
}
|
|
539
506
|
s = _step.value;
|
|
540
507
|
if (!(s.isDefault && s.id !== schemeId)) {
|
|
541
|
-
|
|
508
|
+
_context4.next = 11;
|
|
542
509
|
break;
|
|
543
510
|
}
|
|
544
|
-
|
|
511
|
+
_context4.next = 11;
|
|
545
512
|
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, _objectSpread(_objectSpread({}, s), {}, {
|
|
546
513
|
isDefault: false,
|
|
547
514
|
updatedAt: Date.now()
|
|
548
515
|
}));
|
|
549
516
|
case 11:
|
|
550
|
-
|
|
517
|
+
_context4.next = 6;
|
|
551
518
|
break;
|
|
552
519
|
case 13:
|
|
553
|
-
|
|
520
|
+
_context4.next = 18;
|
|
554
521
|
break;
|
|
555
522
|
case 15:
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
_iterator.e(
|
|
523
|
+
_context4.prev = 15;
|
|
524
|
+
_context4.t0 = _context4["catch"](4);
|
|
525
|
+
_iterator.e(_context4.t0);
|
|
559
526
|
case 18:
|
|
560
|
-
|
|
527
|
+
_context4.prev = 18;
|
|
561
528
|
_iterator.f();
|
|
562
|
-
return
|
|
529
|
+
return _context4.finish(18);
|
|
563
530
|
case 21:
|
|
564
|
-
|
|
531
|
+
_context4.next = 23;
|
|
565
532
|
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, _objectSpread(_objectSpread({}, scheme), {}, {
|
|
566
533
|
isDefault: true,
|
|
567
534
|
updatedAt: Date.now()
|
|
@@ -569,37 +536,37 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
569
536
|
case 23:
|
|
570
537
|
message.success('已设置为默认方案');
|
|
571
538
|
case 24:
|
|
572
|
-
|
|
539
|
+
_context4.next = 29;
|
|
573
540
|
break;
|
|
574
541
|
case 26:
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
message.error(
|
|
542
|
+
_context4.prev = 26;
|
|
543
|
+
_context4.t1 = _context4["catch"](0);
|
|
544
|
+
message.error(_context4.t1.message || '设置失败');
|
|
578
545
|
case 29:
|
|
579
546
|
case "end":
|
|
580
|
-
return
|
|
547
|
+
return _context4.stop();
|
|
581
548
|
}
|
|
582
|
-
},
|
|
549
|
+
}, _callee4, null, [[0, 26], [4, 15, 18, 21]]);
|
|
583
550
|
}));
|
|
584
551
|
return function (_x2) {
|
|
585
|
-
return
|
|
552
|
+
return _ref5.apply(this, arguments);
|
|
586
553
|
};
|
|
587
554
|
}(), [schemes, saveColumnScheme, gridKey]);
|
|
588
555
|
|
|
589
556
|
// 删除方案
|
|
590
557
|
var handleDeleteScheme = useCallback( /*#__PURE__*/function () {
|
|
591
|
-
var
|
|
558
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(schemeId, schemeName) {
|
|
592
559
|
var _currentSchemes$gridK2, isCurrentScheme, defaultScheme;
|
|
593
|
-
return _regeneratorRuntime().wrap(function
|
|
594
|
-
while (1) switch (
|
|
560
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
561
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
595
562
|
case 0:
|
|
596
|
-
|
|
563
|
+
_context5.prev = 0;
|
|
597
564
|
// 检查是否删除的是当前方案
|
|
598
565
|
isCurrentScheme = schemeId === (currentSchemes === null || currentSchemes === void 0 || (_currentSchemes$gridK2 = currentSchemes[gridKey]) === null || _currentSchemes$gridK2 === void 0 ? void 0 : _currentSchemes$gridK2.columnSchemeId); // 查找默认方案
|
|
599
566
|
defaultScheme = schemes.find(function (s) {
|
|
600
567
|
return s.isDefault && s.id !== schemeId;
|
|
601
568
|
});
|
|
602
|
-
|
|
569
|
+
_context5.next = 5;
|
|
603
570
|
return deleteColumnScheme === null || deleteColumnScheme === void 0 ? void 0 : deleteColumnScheme(gridKey, schemeId);
|
|
604
571
|
case 5:
|
|
605
572
|
// 根据情况显示不同的提示消息
|
|
@@ -610,20 +577,20 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
610
577
|
} else {
|
|
611
578
|
message.success("\u65B9\u6848\"".concat(schemeName, "\"\u5DF2\u5220\u9664"));
|
|
612
579
|
}
|
|
613
|
-
|
|
580
|
+
_context5.next = 11;
|
|
614
581
|
break;
|
|
615
582
|
case 8:
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
message.error(
|
|
583
|
+
_context5.prev = 8;
|
|
584
|
+
_context5.t0 = _context5["catch"](0);
|
|
585
|
+
message.error(_context5.t0.message || '删除失败');
|
|
619
586
|
case 11:
|
|
620
587
|
case "end":
|
|
621
|
-
return
|
|
588
|
+
return _context5.stop();
|
|
622
589
|
}
|
|
623
|
-
},
|
|
590
|
+
}, _callee5, null, [[0, 8]]);
|
|
624
591
|
}));
|
|
625
592
|
return function (_x3, _x4) {
|
|
626
|
-
return
|
|
593
|
+
return _ref6.apply(this, arguments);
|
|
627
594
|
};
|
|
628
595
|
}(), [deleteColumnScheme, gridKey, schemes, currentSchemes]);
|
|
629
596
|
|
|
@@ -635,26 +602,26 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
635
602
|
}, []);
|
|
636
603
|
|
|
637
604
|
// 保存编辑
|
|
638
|
-
var handleSaveEdit = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
605
|
+
var handleSaveEdit = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
639
606
|
var scheme;
|
|
640
|
-
return _regeneratorRuntime().wrap(function
|
|
641
|
-
while (1) switch (
|
|
607
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
608
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
642
609
|
case 0:
|
|
643
610
|
if (editingId) {
|
|
644
|
-
|
|
611
|
+
_context6.next = 2;
|
|
645
612
|
break;
|
|
646
613
|
}
|
|
647
|
-
return
|
|
614
|
+
return _context6.abrupt("return");
|
|
648
615
|
case 2:
|
|
649
|
-
|
|
616
|
+
_context6.prev = 2;
|
|
650
617
|
scheme = schemes.find(function (s) {
|
|
651
618
|
return s.id === editingId;
|
|
652
619
|
});
|
|
653
620
|
if (!scheme) {
|
|
654
|
-
|
|
621
|
+
_context6.next = 9;
|
|
655
622
|
break;
|
|
656
623
|
}
|
|
657
|
-
|
|
624
|
+
_context6.next = 7;
|
|
658
625
|
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, _objectSpread(_objectSpread({}, scheme), {}, {
|
|
659
626
|
name: editingName.trim(),
|
|
660
627
|
description: editingDescription.trim() || undefined,
|
|
@@ -664,17 +631,17 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
664
631
|
message.success('更新成功');
|
|
665
632
|
setEditingId(null);
|
|
666
633
|
case 9:
|
|
667
|
-
|
|
634
|
+
_context6.next = 14;
|
|
668
635
|
break;
|
|
669
636
|
case 11:
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
message.error(
|
|
637
|
+
_context6.prev = 11;
|
|
638
|
+
_context6.t0 = _context6["catch"](2);
|
|
639
|
+
message.error(_context6.t0.message || '更新失败');
|
|
673
640
|
case 14:
|
|
674
641
|
case "end":
|
|
675
|
-
return
|
|
642
|
+
return _context6.stop();
|
|
676
643
|
}
|
|
677
|
-
},
|
|
644
|
+
}, _callee6, null, [[2, 11]]);
|
|
678
645
|
})), [schemes, saveColumnScheme, gridKey, editingId, editingName, editingDescription]);
|
|
679
646
|
|
|
680
647
|
// 筛选方案列表
|