@nokecy/qc-ui 1.1.17 → 1.1.18
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.
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +53 -45
- package/dist/cjs/ag-grid-plus/setting/QuerySchemeManager.js +64 -54
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +53 -45
- package/dist/esm/ag-grid-plus/setting/QuerySchemeManager.js +64 -54
- package/dist/esm/standardFormDialog/withStandardForm.d.ts +2 -2
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
|
@@ -17,10 +17,15 @@ var _ColumnConfigTable = _interopRequireDefault(require("./ColumnConfigTable"));
|
|
|
17
17
|
var _draggableModal = _interopRequireDefault(require("../../draggableModal"));
|
|
18
18
|
var _useSchemeManager = require("../context/useSchemeManager");
|
|
19
19
|
var _uuid = require("uuid");
|
|
20
|
+
var _excluded = ["createdAt", "updatedAt"],
|
|
21
|
+
_excluded2 = ["createdAt", "updatedAt"],
|
|
22
|
+
_excluded3 = ["createdAt", "updatedAt"];
|
|
20
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
24
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
22
25
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
23
26
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
27
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
28
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
24
29
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
25
30
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
26
31
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -300,7 +305,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
300
305
|
* 优化逻辑:先保存配置到存储,再直接应用到 Grid,不依赖 handleLoadScheme
|
|
301
306
|
*/
|
|
302
307
|
var handleSaveColumns = (0, _react.useCallback)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
303
|
-
var values, flatConfig, configToSave, invalidColumns, filterModel, savedScheme, defaultScheme, hasGroups, gridColumnDefs, columnState;
|
|
308
|
+
var values, flatConfig, configToSave, invalidColumns, filterModel, savedScheme, createdAt, updatedAt, schemeWithoutTimestamps, defaultScheme, _createdAt, _updatedAt, _schemeWithoutTimestamps, hasGroups, gridColumnDefs, columnState;
|
|
304
309
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
305
310
|
while (1) switch (_context2.prev = _context2.next) {
|
|
306
311
|
case 0:
|
|
@@ -332,43 +337,45 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
332
337
|
_context2.prev = 8;
|
|
333
338
|
filterModel = gridApi.getFilterModel();
|
|
334
339
|
if (!currentScheme) {
|
|
335
|
-
_context2.next =
|
|
340
|
+
_context2.next = 18;
|
|
336
341
|
break;
|
|
337
342
|
}
|
|
338
343
|
// 如果有激活的方案,更新该方案
|
|
339
|
-
|
|
344
|
+
createdAt = currentScheme.createdAt, updatedAt = currentScheme.updatedAt, schemeWithoutTimestamps = _objectWithoutProperties(currentScheme, _excluded);
|
|
345
|
+
savedScheme = _objectSpread(_objectSpread({}, schemeWithoutTimestamps), {}, {
|
|
340
346
|
columnConfig: configToSave,
|
|
341
347
|
filterModel: filterModel
|
|
342
|
-
// updatedAt 由存储适配器自动生成
|
|
348
|
+
// createdAt 和 updatedAt 由存储适配器自动生成
|
|
343
349
|
});
|
|
344
|
-
_context2.next =
|
|
350
|
+
_context2.next = 15;
|
|
345
351
|
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, savedScheme);
|
|
346
|
-
case
|
|
352
|
+
case 15:
|
|
347
353
|
_antd.message.success('列配置已保存到方案');
|
|
348
|
-
_context2.next =
|
|
354
|
+
_context2.next = 31;
|
|
349
355
|
break;
|
|
350
|
-
case
|
|
356
|
+
case 18:
|
|
351
357
|
// 如果没有激活的方案,自动创建或更新默认方案
|
|
352
358
|
defaultScheme = schemes.find(function (s) {
|
|
353
359
|
return s.isDefault;
|
|
354
360
|
});
|
|
355
361
|
if (!defaultScheme) {
|
|
356
|
-
_context2.next =
|
|
362
|
+
_context2.next = 27;
|
|
357
363
|
break;
|
|
358
364
|
}
|
|
359
365
|
// 更新默认方案
|
|
360
|
-
|
|
366
|
+
_createdAt = defaultScheme.createdAt, _updatedAt = defaultScheme.updatedAt, _schemeWithoutTimestamps = _objectWithoutProperties(defaultScheme, _excluded2);
|
|
367
|
+
savedScheme = _objectSpread(_objectSpread({}, _schemeWithoutTimestamps), {}, {
|
|
361
368
|
columnConfig: configToSave,
|
|
362
369
|
filterModel: filterModel
|
|
363
|
-
// updatedAt 由存储适配器自动生成
|
|
370
|
+
// createdAt 和 updatedAt 由存储适配器自动生成
|
|
364
371
|
});
|
|
365
|
-
_context2.next =
|
|
372
|
+
_context2.next = 24;
|
|
366
373
|
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, savedScheme);
|
|
367
|
-
case
|
|
374
|
+
case 24:
|
|
368
375
|
_antd.message.success('列配置已保存到默认方案');
|
|
369
|
-
_context2.next =
|
|
376
|
+
_context2.next = 31;
|
|
370
377
|
break;
|
|
371
|
-
case
|
|
378
|
+
case 27:
|
|
372
379
|
// 创建新的默认方案
|
|
373
380
|
savedScheme = {
|
|
374
381
|
id: (0, _uuid.v4)(),
|
|
@@ -380,33 +387,33 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
380
387
|
isSystem: false
|
|
381
388
|
// createdAt 和 updatedAt 由存储适配器自动生成
|
|
382
389
|
};
|
|
383
|
-
_context2.next =
|
|
390
|
+
_context2.next = 30;
|
|
384
391
|
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, savedScheme);
|
|
385
|
-
case
|
|
392
|
+
case 30:
|
|
386
393
|
_antd.message.success('已创建并保存到默认方案');
|
|
387
|
-
case
|
|
388
|
-
_context2.next =
|
|
394
|
+
case 31:
|
|
395
|
+
_context2.next = 33;
|
|
389
396
|
return new Promise(function (resolve) {
|
|
390
397
|
return setTimeout(resolve, 100);
|
|
391
398
|
});
|
|
392
|
-
case
|
|
399
|
+
case 33:
|
|
393
400
|
// 1. 检查是否包含分组配置
|
|
394
401
|
hasGroups = savedScheme.columnConfig.some(function (item) {
|
|
395
402
|
return item.type === 'group';
|
|
396
403
|
}); // 如果包含分组,先更新 columnDefs
|
|
397
404
|
if (!hasGroups) {
|
|
398
|
-
_context2.next =
|
|
405
|
+
_context2.next = 39;
|
|
399
406
|
break;
|
|
400
407
|
}
|
|
401
408
|
gridColumnDefs = (0, _columnGroupUtils.flatConfigToGridState)(savedScheme.columnConfig, originalColumnDefs);
|
|
402
409
|
gridApi.setGridOption('columnDefs', gridColumnDefs);
|
|
403
410
|
|
|
404
411
|
// 等待 columnDefs 更新完成
|
|
405
|
-
_context2.next =
|
|
412
|
+
_context2.next = 39;
|
|
406
413
|
return new Promise(function (resolve) {
|
|
407
414
|
return setTimeout(resolve, 100);
|
|
408
415
|
});
|
|
409
|
-
case
|
|
416
|
+
case 39:
|
|
410
417
|
columnState = (0, _columnGroupUtils.flatConfigToColumnState)(savedScheme.columnConfig);
|
|
411
418
|
gridApi.applyColumnState({
|
|
412
419
|
state: columnState,
|
|
@@ -420,31 +427,31 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
420
427
|
|
|
421
428
|
// 4. 设置为当前方案(如果不是当前方案)
|
|
422
429
|
if (!(!currentScheme || savedScheme.id !== currentScheme.id)) {
|
|
423
|
-
_context2.next =
|
|
430
|
+
_context2.next = 45;
|
|
424
431
|
break;
|
|
425
432
|
}
|
|
426
|
-
_context2.next = 43;
|
|
427
|
-
return setCurrentColumnScheme === null || setCurrentColumnScheme === void 0 ? void 0 : setCurrentColumnScheme(gridKey, savedScheme.id);
|
|
428
|
-
case 43:
|
|
429
433
|
_context2.next = 45;
|
|
434
|
+
return setCurrentColumnScheme === null || setCurrentColumnScheme === void 0 ? void 0 : setCurrentColumnScheme(gridKey, savedScheme.id);
|
|
435
|
+
case 45:
|
|
436
|
+
_context2.next = 47;
|
|
430
437
|
return new Promise(function (resolve) {
|
|
431
438
|
return setTimeout(resolve, 50);
|
|
432
439
|
});
|
|
433
|
-
case
|
|
440
|
+
case 47:
|
|
434
441
|
// 5. 关闭弹窗
|
|
435
442
|
onClose();
|
|
436
|
-
_context2.next =
|
|
443
|
+
_context2.next = 54;
|
|
437
444
|
break;
|
|
438
|
-
case
|
|
439
|
-
_context2.prev =
|
|
445
|
+
case 50:
|
|
446
|
+
_context2.prev = 50;
|
|
440
447
|
_context2.t0 = _context2["catch"](8);
|
|
441
448
|
console.error('保存列配置到方案失败:', _context2.t0);
|
|
442
449
|
_antd.message.error('保存列配置失败');
|
|
443
|
-
case
|
|
450
|
+
case 54:
|
|
444
451
|
case "end":
|
|
445
452
|
return _context2.stop();
|
|
446
453
|
}
|
|
447
|
-
}, _callee2, null, [[8,
|
|
454
|
+
}, _callee2, null, [[8, 50]]);
|
|
448
455
|
})), [form, gridApi, saveColumnScheme, setCurrentColumnScheme, currentScheme, schemes, gridKey, originalColumnDefs, onClose]);
|
|
449
456
|
|
|
450
457
|
// 保存为新方案
|
|
@@ -654,7 +661,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
654
661
|
|
|
655
662
|
// 保存编辑
|
|
656
663
|
var handleSaveEdit = (0, _react.useCallback)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
657
|
-
var scheme;
|
|
664
|
+
var scheme, createdAt, updatedAt, schemeWithoutTimestamps;
|
|
658
665
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
659
666
|
while (1) switch (_context6.prev = _context6.next) {
|
|
660
667
|
case 0:
|
|
@@ -669,30 +676,31 @@ var ColumnSetting = function ColumnSetting(_ref) {
|
|
|
669
676
|
return s.id === editingId;
|
|
670
677
|
});
|
|
671
678
|
if (!scheme) {
|
|
672
|
-
_context6.next =
|
|
679
|
+
_context6.next = 10;
|
|
673
680
|
break;
|
|
674
681
|
}
|
|
675
|
-
|
|
676
|
-
|
|
682
|
+
createdAt = scheme.createdAt, updatedAt = scheme.updatedAt, schemeWithoutTimestamps = _objectWithoutProperties(scheme, _excluded3);
|
|
683
|
+
_context6.next = 8;
|
|
684
|
+
return saveColumnScheme === null || saveColumnScheme === void 0 ? void 0 : saveColumnScheme(gridKey, _objectSpread(_objectSpread({}, schemeWithoutTimestamps), {}, {
|
|
677
685
|
name: editingName.trim(),
|
|
678
686
|
description: editingDescription.trim() || undefined
|
|
679
|
-
// updatedAt 由存储适配器自动生成
|
|
687
|
+
// createdAt 和 updatedAt 由存储适配器自动生成
|
|
680
688
|
}));
|
|
681
|
-
case
|
|
689
|
+
case 8:
|
|
682
690
|
_antd.message.success('更新成功');
|
|
683
691
|
setEditingId(null);
|
|
684
|
-
case
|
|
685
|
-
_context6.next =
|
|
692
|
+
case 10:
|
|
693
|
+
_context6.next = 15;
|
|
686
694
|
break;
|
|
687
|
-
case
|
|
688
|
-
_context6.prev =
|
|
695
|
+
case 12:
|
|
696
|
+
_context6.prev = 12;
|
|
689
697
|
_context6.t0 = _context6["catch"](2);
|
|
690
698
|
_antd.message.error(_context6.t0.message || '更新失败');
|
|
691
|
-
case
|
|
699
|
+
case 15:
|
|
692
700
|
case "end":
|
|
693
701
|
return _context6.stop();
|
|
694
702
|
}
|
|
695
|
-
}, _callee6, null, [[2,
|
|
703
|
+
}, _callee6, null, [[2, 12]]);
|
|
696
704
|
})), [schemes, saveColumnScheme, gridKey, editingId, editingName, editingDescription]);
|
|
697
705
|
|
|
698
706
|
// 筛选方案列表
|
|
@@ -15,11 +15,17 @@ var _gridContext = require("../context/gridContext");
|
|
|
15
15
|
var _uuid = require("uuid");
|
|
16
16
|
var _schemeDataMigration = require("../shared/utils/schemeDataMigration");
|
|
17
17
|
var _theme = require("../theme");
|
|
18
|
+
var _excluded = ["createdAt", "updatedAt"],
|
|
19
|
+
_excluded2 = ["createdAt", "updatedAt"],
|
|
20
|
+
_excluded3 = ["createdAt", "updatedAt"],
|
|
21
|
+
_excluded4 = ["createdAt", "updatedAt"];
|
|
18
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
20
24
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
25
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
22
26
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
27
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
28
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
23
29
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
24
30
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
25
31
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -193,7 +199,7 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
|
|
|
193
199
|
* 应用当前顺序和隐藏设置
|
|
194
200
|
*/
|
|
195
201
|
var handleApplyOrder = (0, _react.useCallback)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
196
|
-
var editingOrder, hiddenFields, queryConfig, newScheme;
|
|
202
|
+
var editingOrder, hiddenFields, queryConfig, createdAt, updatedAt, schemeWithoutTimestamps, newScheme;
|
|
197
203
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
198
204
|
while (1) switch (_context.prev = _context.next) {
|
|
199
205
|
case 0:
|
|
@@ -208,19 +214,20 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
|
|
|
208
214
|
}); // 构建新格式的配置
|
|
209
215
|
queryConfig = (0, _schemeDataMigration.buildQueryConfig)(editingOrder, hiddenFields); // 如果有当前方案,更新方案
|
|
210
216
|
if (!currentScheme) {
|
|
211
|
-
_context.next =
|
|
217
|
+
_context.next = 11;
|
|
212
218
|
break;
|
|
213
219
|
}
|
|
214
|
-
|
|
215
|
-
|
|
220
|
+
createdAt = currentScheme.createdAt, updatedAt = currentScheme.updatedAt, schemeWithoutTimestamps = _objectWithoutProperties(currentScheme, _excluded);
|
|
221
|
+
_context.next = 8;
|
|
222
|
+
return saveQueryScheme === null || saveQueryScheme === void 0 ? void 0 : saveQueryScheme(gridKey, _objectSpread(_objectSpread({}, schemeWithoutTimestamps), {}, {
|
|
216
223
|
queryConfig: queryConfig
|
|
217
|
-
// updatedAt 由存储适配器自动生成
|
|
224
|
+
// createdAt 和 updatedAt 由存储适配器自动生成
|
|
218
225
|
}));
|
|
219
|
-
case
|
|
226
|
+
case 8:
|
|
220
227
|
_antd.message.success('已应用新配置');
|
|
221
|
-
_context.next =
|
|
228
|
+
_context.next = 17;
|
|
222
229
|
break;
|
|
223
|
-
case
|
|
230
|
+
case 11:
|
|
224
231
|
// 创建新方案
|
|
225
232
|
newScheme = {
|
|
226
233
|
id: (0, _uuid.v4)(),
|
|
@@ -231,28 +238,28 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
|
|
|
231
238
|
isSystem: false
|
|
232
239
|
// createdAt 和 updatedAt 由存储适配器自动生成
|
|
233
240
|
};
|
|
234
|
-
_context.next =
|
|
241
|
+
_context.next = 14;
|
|
235
242
|
return saveQueryScheme === null || saveQueryScheme === void 0 ? void 0 : saveQueryScheme(gridKey, newScheme);
|
|
236
|
-
case
|
|
237
|
-
_context.next =
|
|
243
|
+
case 14:
|
|
244
|
+
_context.next = 16;
|
|
238
245
|
return setCurrentQueryScheme === null || setCurrentQueryScheme === void 0 ? void 0 : setCurrentQueryScheme(gridKey, newScheme.id);
|
|
239
|
-
case 15:
|
|
240
|
-
_antd.message.success('已自动创建并应用默认方案');
|
|
241
246
|
case 16:
|
|
247
|
+
_antd.message.success('已自动创建并应用默认方案');
|
|
248
|
+
case 17:
|
|
242
249
|
// 应用顺序到表单
|
|
243
250
|
updateQueryOrder === null || updateQueryOrder === void 0 || updateQueryOrder(editingOrder);
|
|
244
251
|
onClose();
|
|
245
|
-
_context.next =
|
|
252
|
+
_context.next = 24;
|
|
246
253
|
break;
|
|
247
|
-
case
|
|
248
|
-
_context.prev =
|
|
254
|
+
case 21:
|
|
255
|
+
_context.prev = 21;
|
|
249
256
|
_context.t0 = _context["catch"](0);
|
|
250
257
|
_antd.message.error(_context.t0.message || '应用失败');
|
|
251
|
-
case
|
|
258
|
+
case 24:
|
|
252
259
|
case "end":
|
|
253
260
|
return _context.stop();
|
|
254
261
|
}
|
|
255
|
-
}, _callee, null, [[0,
|
|
262
|
+
}, _callee, null, [[0, 21]]);
|
|
256
263
|
})), [queryItemsData, currentScheme, saveQueryScheme, gridKey, updateQueryOrder, onClose, setCurrentQueryScheme]);
|
|
257
264
|
|
|
258
265
|
/**
|
|
@@ -320,7 +327,7 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
|
|
|
320
327
|
* 保存编辑
|
|
321
328
|
*/
|
|
322
329
|
var handleSaveEdit = (0, _react.useCallback)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
323
|
-
var scheme;
|
|
330
|
+
var scheme, createdAt, updatedAt, schemeWithoutTimestamps;
|
|
324
331
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
325
332
|
while (1) switch (_context3.prev = _context3.next) {
|
|
326
333
|
case 0:
|
|
@@ -340,26 +347,27 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
|
|
|
340
347
|
}
|
|
341
348
|
return _context3.abrupt("return");
|
|
342
349
|
case 6:
|
|
343
|
-
|
|
344
|
-
|
|
350
|
+
createdAt = scheme.createdAt, updatedAt = scheme.updatedAt, schemeWithoutTimestamps = _objectWithoutProperties(scheme, _excluded2);
|
|
351
|
+
_context3.next = 9;
|
|
352
|
+
return saveQueryScheme === null || saveQueryScheme === void 0 ? void 0 : saveQueryScheme(gridKey, _objectSpread(_objectSpread({}, schemeWithoutTimestamps), {}, {
|
|
345
353
|
name: editingName.trim(),
|
|
346
354
|
description: editingDescription.trim() || undefined
|
|
347
|
-
// updatedAt 由存储适配器自动生成
|
|
355
|
+
// createdAt 和 updatedAt 由存储适配器自动生成
|
|
348
356
|
}));
|
|
349
|
-
case
|
|
357
|
+
case 9:
|
|
350
358
|
_antd.message.success('更新成功');
|
|
351
359
|
setEditingId(null);
|
|
352
|
-
_context3.next =
|
|
360
|
+
_context3.next = 16;
|
|
353
361
|
break;
|
|
354
|
-
case
|
|
355
|
-
_context3.prev =
|
|
362
|
+
case 13:
|
|
363
|
+
_context3.prev = 13;
|
|
356
364
|
_context3.t0 = _context3["catch"](2);
|
|
357
365
|
_antd.message.error(_context3.t0.message || '更新失败');
|
|
358
|
-
case
|
|
366
|
+
case 16:
|
|
359
367
|
case "end":
|
|
360
368
|
return _context3.stop();
|
|
361
369
|
}
|
|
362
|
-
}, _callee3, null, [[2,
|
|
370
|
+
}, _callee3, null, [[2, 13]]);
|
|
363
371
|
})), [editingId, editingName, editingDescription, schemes, saveQueryScheme, gridKey]);
|
|
364
372
|
|
|
365
373
|
/**
|
|
@@ -406,7 +414,7 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
|
|
|
406
414
|
*/
|
|
407
415
|
var handleSetDefault = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
408
416
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(schemeId, schemeName) {
|
|
409
|
-
var _iterator, _step, _scheme, scheme;
|
|
417
|
+
var _iterator, _step, _scheme, _createdAt, _updatedAt, _schemeWithoutTimestamps, scheme, createdAt, updatedAt, schemeWithoutTimestamps;
|
|
410
418
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
411
419
|
while (1) switch (_context5.prev = _context5.next) {
|
|
412
420
|
case 0:
|
|
@@ -417,61 +425,63 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
|
|
|
417
425
|
_iterator.s();
|
|
418
426
|
case 4:
|
|
419
427
|
if ((_step = _iterator.n()).done) {
|
|
420
|
-
_context5.next =
|
|
428
|
+
_context5.next = 12;
|
|
421
429
|
break;
|
|
422
430
|
}
|
|
423
431
|
_scheme = _step.value;
|
|
424
432
|
if (!(_scheme.isDefault && _scheme.id !== schemeId)) {
|
|
425
|
-
_context5.next =
|
|
433
|
+
_context5.next = 10;
|
|
426
434
|
break;
|
|
427
435
|
}
|
|
428
|
-
|
|
429
|
-
|
|
436
|
+
_createdAt = _scheme.createdAt, _updatedAt = _scheme.updatedAt, _schemeWithoutTimestamps = _objectWithoutProperties(_scheme, _excluded4);
|
|
437
|
+
_context5.next = 10;
|
|
438
|
+
return saveQueryScheme === null || saveQueryScheme === void 0 ? void 0 : saveQueryScheme(gridKey, _objectSpread(_objectSpread({}, _schemeWithoutTimestamps), {}, {
|
|
430
439
|
isDefault: false
|
|
431
|
-
// updatedAt 由存储适配器自动生成
|
|
440
|
+
// createdAt 和 updatedAt 由存储适配器自动生成
|
|
432
441
|
}));
|
|
433
|
-
case
|
|
442
|
+
case 10:
|
|
434
443
|
_context5.next = 4;
|
|
435
444
|
break;
|
|
436
|
-
case
|
|
437
|
-
_context5.next =
|
|
445
|
+
case 12:
|
|
446
|
+
_context5.next = 17;
|
|
438
447
|
break;
|
|
439
|
-
case
|
|
440
|
-
_context5.prev =
|
|
448
|
+
case 14:
|
|
449
|
+
_context5.prev = 14;
|
|
441
450
|
_context5.t0 = _context5["catch"](2);
|
|
442
451
|
_iterator.e(_context5.t0);
|
|
443
|
-
case
|
|
444
|
-
_context5.prev =
|
|
452
|
+
case 17:
|
|
453
|
+
_context5.prev = 17;
|
|
445
454
|
_iterator.f();
|
|
446
|
-
return _context5.finish(
|
|
447
|
-
case
|
|
455
|
+
return _context5.finish(17);
|
|
456
|
+
case 20:
|
|
448
457
|
// 设置新的默认方案
|
|
449
458
|
scheme = schemes.find(function (s) {
|
|
450
459
|
return s.id === schemeId;
|
|
451
460
|
});
|
|
452
461
|
if (!scheme) {
|
|
453
|
-
_context5.next =
|
|
462
|
+
_context5.next = 26;
|
|
454
463
|
break;
|
|
455
464
|
}
|
|
456
|
-
|
|
457
|
-
|
|
465
|
+
createdAt = scheme.createdAt, updatedAt = scheme.updatedAt, schemeWithoutTimestamps = _objectWithoutProperties(scheme, _excluded3);
|
|
466
|
+
_context5.next = 25;
|
|
467
|
+
return saveQueryScheme === null || saveQueryScheme === void 0 ? void 0 : saveQueryScheme(gridKey, _objectSpread(_objectSpread({}, schemeWithoutTimestamps), {}, {
|
|
458
468
|
isDefault: true
|
|
459
|
-
// updatedAt 由存储适配器自动生成
|
|
469
|
+
// createdAt 和 updatedAt 由存储适配器自动生成
|
|
460
470
|
}));
|
|
461
|
-
case
|
|
471
|
+
case 25:
|
|
462
472
|
_antd.message.success("\u5DF2\u5C06\"".concat(schemeName, "\"\u8BBE\u4E3A\u9ED8\u8BA4\u65B9\u6848"));
|
|
463
|
-
case 24:
|
|
464
|
-
_context5.next = 29;
|
|
465
|
-
break;
|
|
466
473
|
case 26:
|
|
467
|
-
_context5.
|
|
474
|
+
_context5.next = 31;
|
|
475
|
+
break;
|
|
476
|
+
case 28:
|
|
477
|
+
_context5.prev = 28;
|
|
468
478
|
_context5.t1 = _context5["catch"](0);
|
|
469
479
|
_antd.message.error(_context5.t1.message || '设置失败');
|
|
470
|
-
case
|
|
480
|
+
case 31:
|
|
471
481
|
case "end":
|
|
472
482
|
return _context5.stop();
|
|
473
483
|
}
|
|
474
|
-
}, _callee5, null, [[0,
|
|
484
|
+
}, _callee5, null, [[0, 28], [2, 14, 17, 20]]);
|
|
475
485
|
}));
|
|
476
486
|
return function (_x3, _x4) {
|
|
477
487
|
return _ref6.apply(this, arguments);
|