@nokecy/qc-ui 1.1.17 → 1.1.19
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/ag-gridPlus.js +23 -0
- package/dist/cjs/ag-grid-plus/context/gridContext.d.ts +5 -0
- package/dist/cjs/ag-grid-plus/index.less +13 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnConfigTable.js +79 -76
- package/dist/cjs/ag-grid-plus/setting/ColumnNameCellRenderer.d.ts +22 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnNameCellRenderer.js +211 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +133 -70
- package/dist/cjs/ag-grid-plus/setting/DebounceInputs.d.ts +1 -0
- package/dist/cjs/ag-grid-plus/setting/DebounceInputs.js +2 -0
- package/dist/cjs/ag-grid-plus/setting/QuerySchemeManager.js +64 -54
- package/dist/cjs/ag-grid-plus/setting/columnGroupTypes.d.ts +3 -1
- package/dist/cjs/ag-grid-plus/setting/columnGroupUtils.d.ts +2 -1
- package/dist/cjs/ag-grid-plus/setting/columnGroupUtils.js +49 -9
- package/dist/esm/ag-grid-plus/ag-gridPlus.js +23 -0
- package/dist/esm/ag-grid-plus/context/gridContext.d.ts +5 -0
- package/dist/esm/ag-grid-plus/index.less +13 -0
- package/dist/esm/ag-grid-plus/setting/ColumnConfigTable.js +81 -78
- package/dist/esm/ag-grid-plus/setting/ColumnNameCellRenderer.d.ts +22 -0
- package/dist/esm/ag-grid-plus/setting/ColumnNameCellRenderer.js +204 -0
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +133 -70
- package/dist/esm/ag-grid-plus/setting/DebounceInputs.d.ts +1 -0
- package/dist/esm/ag-grid-plus/setting/DebounceInputs.js +2 -0
- package/dist/esm/ag-grid-plus/setting/QuerySchemeManager.js +64 -54
- package/dist/esm/ag-grid-plus/setting/columnGroupTypes.d.ts +3 -1
- package/dist/esm/ag-grid-plus/setting/columnGroupUtils.d.ts +2 -1
- package/dist/esm/ag-grid-plus/setting/columnGroupUtils.js +49 -9
- package/dist/esm/standardFormDialog/withStandardForm.d.ts +2 -2
- package/dist/umd/qc-ui.min.css +1 -1
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
|
@@ -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);
|
|
@@ -17,8 +17,10 @@ export interface FlatColumnItem {
|
|
|
17
17
|
level: number;
|
|
18
18
|
/** 排序序号,用于维护节点顺序 */
|
|
19
19
|
order: number;
|
|
20
|
-
/** 显示名称 */
|
|
20
|
+
/** 显示名称 (当前值,可被用户修改) */
|
|
21
21
|
headerName: string;
|
|
22
|
+
/** 原始显示名称 (用于对比和重置) */
|
|
23
|
+
originalHeaderName?: string;
|
|
22
24
|
/** AG-Grid 分组标识(仅分组类型) */
|
|
23
25
|
groupId?: string;
|
|
24
26
|
/** 子列是否必须保持一起(仅分组类型) */
|
|
@@ -13,9 +13,10 @@ export declare const generateId: () => string;
|
|
|
13
13
|
* 将 AG-Grid 的树形结构转换为扁平化数组,用于 UI 展示和编辑
|
|
14
14
|
*
|
|
15
15
|
* @param columnDefs AG-Grid 列定义数组
|
|
16
|
+
* @param originalColumnDefs 原始列定义数组(可选),用于获取 originalHeaderName
|
|
16
17
|
* @returns 扁平化配置数组
|
|
17
18
|
*/
|
|
18
|
-
export declare function gridStateToFlatConfig(columnDefs: (ColDef | ColGroupDef)[]): FlatColumnItem[];
|
|
19
|
+
export declare function gridStateToFlatConfig(columnDefs: (ColDef | ColGroupDef)[], originalColumnDefs?: (ColDef | ColGroupDef)[]): FlatColumnItem[];
|
|
19
20
|
/**
|
|
20
21
|
* 扁平化配置 → Grid State
|
|
21
22
|
* 将扁平化数组重建为 AG-Grid 的树形结构
|
|
@@ -40,12 +40,44 @@ var generateId = exports.generateId = function generateId() {
|
|
|
40
40
|
* 将 AG-Grid 的树形结构转换为扁平化数组,用于 UI 展示和编辑
|
|
41
41
|
*
|
|
42
42
|
* @param columnDefs AG-Grid 列定义数组
|
|
43
|
+
* @param originalColumnDefs 原始列定义数组(可选),用于获取 originalHeaderName
|
|
43
44
|
* @returns 扁平化配置数组
|
|
44
45
|
*/
|
|
45
|
-
function gridStateToFlatConfig(columnDefs) {
|
|
46
|
+
function gridStateToFlatConfig(columnDefs, originalColumnDefs) {
|
|
46
47
|
var result = [];
|
|
47
48
|
var order = 0;
|
|
48
49
|
|
|
50
|
+
/**
|
|
51
|
+
* 从原始列定义中查找指定字段的原始 headerName
|
|
52
|
+
*/
|
|
53
|
+
function findOriginalHeaderName(field, defs) {
|
|
54
|
+
if (!defs || !field) return undefined;
|
|
55
|
+
var _iterator = _createForOfIteratorHelper(defs),
|
|
56
|
+
_step;
|
|
57
|
+
try {
|
|
58
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
59
|
+
var def = _step.value;
|
|
60
|
+
// 检查是否是分组
|
|
61
|
+
if ('children' in def && def.children) {
|
|
62
|
+
// 递归查找分组内的列
|
|
63
|
+
var found = findOriginalHeaderName(field, def.children);
|
|
64
|
+
if (found) return found;
|
|
65
|
+
} else {
|
|
66
|
+
// 检查是否是目标列
|
|
67
|
+
var colDef = def;
|
|
68
|
+
if (colDef.field === field) {
|
|
69
|
+
return colDef.headerName;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
} catch (err) {
|
|
74
|
+
_iterator.e(err);
|
|
75
|
+
} finally {
|
|
76
|
+
_iterator.f();
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
|
|
49
81
|
/**
|
|
50
82
|
* 递归遍历列定义树
|
|
51
83
|
*/
|
|
@@ -54,13 +86,16 @@ function gridStateToFlatConfig(columnDefs) {
|
|
|
54
86
|
if (item.children && item.children.length > 0) {
|
|
55
87
|
// 这是一个分组节点
|
|
56
88
|
var groupId = generateId();
|
|
89
|
+
var headerName = item.headerName || '未命名分组';
|
|
57
90
|
result.push({
|
|
58
91
|
id: groupId,
|
|
59
92
|
type: 'group',
|
|
60
93
|
parentId: parentId,
|
|
61
94
|
level: level,
|
|
62
95
|
order: order++,
|
|
63
|
-
headerName:
|
|
96
|
+
headerName: headerName,
|
|
97
|
+
originalHeaderName: headerName,
|
|
98
|
+
// 保存原始 headerName
|
|
64
99
|
groupId: item.groupId || item.field || generateId(),
|
|
65
100
|
marryChildren: item.marryChildren
|
|
66
101
|
});
|
|
@@ -68,6 +103,9 @@ function gridStateToFlatConfig(columnDefs) {
|
|
|
68
103
|
traverse(item.children, level + 1, groupId);
|
|
69
104
|
} else {
|
|
70
105
|
// 这是一个列节点
|
|
106
|
+
var _headerName = item.headerName || item.field || '未命名列';
|
|
107
|
+
// 从原始列定义中获取 originalHeaderName,如果没有则使用当前 headerName
|
|
108
|
+
var originalHeaderName = item.field ? findOriginalHeaderName(item.field, originalColumnDefs) || _headerName : _headerName;
|
|
71
109
|
result.push({
|
|
72
110
|
id: generateId(),
|
|
73
111
|
type: 'column',
|
|
@@ -75,7 +113,9 @@ function gridStateToFlatConfig(columnDefs) {
|
|
|
75
113
|
level: level,
|
|
76
114
|
order: order++,
|
|
77
115
|
field: item.field,
|
|
78
|
-
headerName:
|
|
116
|
+
headerName: _headerName,
|
|
117
|
+
originalHeaderName: originalHeaderName,
|
|
118
|
+
// 从原始定义获取,或使用当前值
|
|
79
119
|
width: item.width,
|
|
80
120
|
hide: item.hide,
|
|
81
121
|
pinned: item.pinned === null ? 'notPinned' : item.pinned,
|
|
@@ -107,11 +147,11 @@ function flatConfigToGridState(flatConfig, originalColumnDefs) {
|
|
|
107
147
|
*/
|
|
108
148
|
function findOriginalColDef(field, defs) {
|
|
109
149
|
if (!defs) return undefined;
|
|
110
|
-
var
|
|
111
|
-
|
|
150
|
+
var _iterator2 = _createForOfIteratorHelper(defs),
|
|
151
|
+
_step2;
|
|
112
152
|
try {
|
|
113
|
-
for (
|
|
114
|
-
var def =
|
|
153
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
154
|
+
var def = _step2.value;
|
|
115
155
|
// 检查是否是分组
|
|
116
156
|
if ('children' in def && def.children) {
|
|
117
157
|
// 递归查找分组内的列
|
|
@@ -126,9 +166,9 @@ function flatConfigToGridState(flatConfig, originalColumnDefs) {
|
|
|
126
166
|
}
|
|
127
167
|
}
|
|
128
168
|
} catch (err) {
|
|
129
|
-
|
|
169
|
+
_iterator2.e(err);
|
|
130
170
|
} finally {
|
|
131
|
-
|
|
171
|
+
_iterator2.f();
|
|
132
172
|
}
|
|
133
173
|
return undefined;
|
|
134
174
|
}
|
|
@@ -93,6 +93,10 @@ function AgGridPlus(props) {
|
|
|
93
93
|
var apiRef = useRef();
|
|
94
94
|
var allColDefsRef = useRef([]);
|
|
95
95
|
|
|
96
|
+
// 【新增】缓存初始的 columnDefs,用于保留原始 headerName
|
|
97
|
+
// 这个值在组件生命周期中保持不变,不会被列方案修改
|
|
98
|
+
var initialColumnDefsRef = useRef([]);
|
|
99
|
+
|
|
96
100
|
// 【新增】用于缓存每个数据对象的唯一 ID(降级方案)
|
|
97
101
|
var rowIdCacheRef = useRef(new WeakMap());
|
|
98
102
|
var rowIdCounterRef = useRef(0);
|
|
@@ -582,6 +586,21 @@ function AgGridPlus(props) {
|
|
|
582
586
|
var cols = getTableColumns([dataForTypeInference]);
|
|
583
587
|
allColDefsRef.current = cols; // 同步更新 ref
|
|
584
588
|
|
|
589
|
+
// 【新增】首次初始化时缓存初始列定义(浅拷贝即可,只需要保留 headerName)
|
|
590
|
+
if (initialColumnDefsRef.current.length === 0) {
|
|
591
|
+
initialColumnDefsRef.current = cols.map(function (col) {
|
|
592
|
+
// 递归处理分组的 children
|
|
593
|
+
if ('children' in col && col.children) {
|
|
594
|
+
return _objectSpread(_objectSpread({}, col), {}, {
|
|
595
|
+
children: col.children.map(function (child) {
|
|
596
|
+
return _objectSpread({}, child);
|
|
597
|
+
})
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
// 普通列只需要浅拷贝
|
|
601
|
+
return _objectSpread({}, col);
|
|
602
|
+
});
|
|
603
|
+
}
|
|
585
604
|
return cols;
|
|
586
605
|
}, [React.Children.count(children), props.columnDefs, extensibleColumns, gridKey]);
|
|
587
606
|
|
|
@@ -1109,6 +1128,8 @@ function AgGridPlus(props) {
|
|
|
1109
1128
|
columnState: gridPlusColumnState,
|
|
1110
1129
|
allColDefs: allColDefsRef.current,
|
|
1111
1130
|
// 【修复】传入原始完整的列定义
|
|
1131
|
+
initialColumnDefs: initialColumnDefsRef.current,
|
|
1132
|
+
// 【新增】传入初始列定义(用于获取原始 headerName)
|
|
1112
1133
|
onSaveColumnState: onSaveColumnState,
|
|
1113
1134
|
applyToGlobal: applyToGlobal,
|
|
1114
1135
|
resetCurrent: resetCurrent,
|
|
@@ -1135,6 +1156,8 @@ function AgGridPlus(props) {
|
|
|
1135
1156
|
};
|
|
1136
1157
|
}, [extensibleColumns, gridPlusColumnState, allColDefsRef.current,
|
|
1137
1158
|
// 【修复】添加到依赖数组
|
|
1159
|
+
initialColumnDefsRef.current,
|
|
1160
|
+
// 【新增】添加初始列定义到依赖数组
|
|
1138
1161
|
onSaveColumnState, applyToGlobal, resetCurrent, resetAll, currentQueryScheme, queryItemsOrder, queryFormItems,
|
|
1139
1162
|
// 方案管理依赖
|
|
1140
1163
|
columnSchemes, querySchemes, currentSchemes, schemesLoading, lastSyncTime, saveColumnScheme, deleteColumnScheme, saveQueryScheme, deleteQueryScheme, setCurrentColumnScheme, setCurrentQueryScheme, refreshSchemes, getColumnSchemes, getQuerySchemes, getCurrentScheme]);
|
|
@@ -100,6 +100,11 @@ export interface GridPlusContextValue extends SchemeManagementAPI {
|
|
|
100
100
|
* 用于列方案应用时保留这些属性
|
|
101
101
|
*/
|
|
102
102
|
allColDefs?: import('../types').ExtendedColDef[];
|
|
103
|
+
/**
|
|
104
|
+
* 初始列定义(从 props 传入的原始值,不会被列方案修改)
|
|
105
|
+
* 用于获取原始 headerName,以便显示修改状态
|
|
106
|
+
*/
|
|
107
|
+
initialColumnDefs?: import('../types').ExtendedColDef[];
|
|
103
108
|
/**
|
|
104
109
|
* 保存当前表格的列状态到服务器(仅保存当前表格)
|
|
105
110
|
* @param gridKey 表格唯一标识
|
|
@@ -35,3 +35,16 @@
|
|
|
35
35
|
width: 18px !important;
|
|
36
36
|
height: 18px !important;
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
// 列内容对齐方式样式
|
|
40
|
+
.custom-cell-left {
|
|
41
|
+
text-align: left !important;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.custom-cell-centered {
|
|
45
|
+
text-align: center !important;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.custom-cell-right {
|
|
49
|
+
text-align: right !important;
|
|
50
|
+
}
|