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