@nokecy/qc-ui 1.1.26 → 1.1.28

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.
@@ -1293,9 +1293,8 @@ function AgGridPlus(props) {
1293
1293
  gridApi: apiRef.current,
1294
1294
  onSaveColumnState: onColumnStateChanged
1295
1295
  }),
1296
- /*#__PURE__*/
1297
- // 高级搜索(图标风格,位于设置右边)
1298
- _react.default.createElement(_antd.Popover, {
1296
+ // 高级搜索(图标风格,位于设置右边)- 遵循 search 属性
1297
+ search !== false ? /*#__PURE__*/_react.default.createElement(_antd.Popover, {
1299
1298
  key: "advanced-search-setting",
1300
1299
  content: /*#__PURE__*/_react.default.createElement("div", {
1301
1300
  style: {
@@ -1364,7 +1363,7 @@ function AgGridPlus(props) {
1364
1363
  fontSize: 16,
1365
1364
  cursor: "pointer"
1366
1365
  }
1367
- }, /*#__PURE__*/_react.default.createElement(_icons.FilterOutlined, null))))]
1366
+ }, /*#__PURE__*/_react.default.createElement(_icons.FilterOutlined, null)))) : null].filter(Boolean)
1368
1367
  }), /*#__PURE__*/_react.default.createElement(_agGridReact.AgGridReact, _extends({
1369
1368
  theme: _theme.agGridTheme
1370
1369
  }, rest, {
@@ -28,6 +28,10 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
28
28
  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; }
29
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); } }
30
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); }); }; }
31
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
32
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
33
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
34
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
31
35
  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; }
32
36
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
33
37
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -167,6 +171,117 @@ var ColumnSetting = function ColumnSetting(_ref) {
167
171
  });
168
172
  }, [originalColumnDefs]);
169
173
 
174
+ /**
175
+ * 合并代码中新增的列到配置中
176
+ * 场景:用户保存列配置后,开发者在代码中新增了列,这些列应该显示在配置表格中
177
+ * 【修复】只检测并追加新增列到末尾,不改变已保存配置的顺序
178
+ */
179
+ var mergeNewColumns = (0, _react.useCallback)(function (config, originalDefs) {
180
+ if (!originalDefs || originalDefs.length === 0) {
181
+ return config;
182
+ }
183
+
184
+ // 创建 field -> config item 的映射(用于快速查找已保存的列配置)
185
+ var existingFields = new Set();
186
+ config.filter(function (item) {
187
+ return item.type === 'column' && item.field;
188
+ }).forEach(function (item) {
189
+ existingFields.add(item.field);
190
+ });
191
+
192
+ // 创建 groupId -> config item 的映射(用于快速查找已保存的分组配置)
193
+ var existingGroupIds = new Set();
194
+ config.filter(function (item) {
195
+ return item.type === 'group' && item.groupId;
196
+ }).forEach(function (item) {
197
+ existingGroupIds.add(item.groupId);
198
+ });
199
+
200
+ // 收集新增的列(在 originalDefs 中存在但 config 中不存在)
201
+ var newItems = [];
202
+ var maxOrder = Math.max.apply(Math, _toConsumableArray(config.map(function (item) {
203
+ return item.order;
204
+ })).concat([-1]));
205
+
206
+ /**
207
+ * 递归处理列定义,查找新增的列和分组
208
+ */
209
+ var findNewColumns = function findNewColumns(defs, level, parentId) {
210
+ var _iterator2 = _createForOfIteratorHelper(defs),
211
+ _step2;
212
+ try {
213
+ var _loop = function _loop() {
214
+ var def = _step2.value;
215
+ // 检查是否是分组
216
+ if ('children' in def && def.children && def.children.length > 0) {
217
+ var groupDef = def;
218
+ var groupIdValue = groupDef.groupId || groupDef.field || (0, _columnGroupUtils.generateId)();
219
+ if (!existingGroupIds.has(groupIdValue)) {
220
+ // 新分组
221
+ var newGroupId = (0, _columnGroupUtils.generateId)();
222
+ newItems.push({
223
+ id: newGroupId,
224
+ type: 'group',
225
+ parentId: parentId,
226
+ level: level,
227
+ order: ++maxOrder,
228
+ headerName: groupDef.headerName || '未命名分组',
229
+ originalHeaderName: groupDef.headerName || '未命名分组',
230
+ groupId: groupIdValue,
231
+ marryChildren: groupDef.marryChildren
232
+ });
233
+ // 递归处理子节点(新分组的子节点也都是新的)
234
+ findNewColumns(groupDef.children, level + 1, newGroupId);
235
+ } else {
236
+ // 已存在的分组,但要检查子节点是否有新增
237
+ var existingGroup = config.find(function (item) {
238
+ return item.type === 'group' && item.groupId === groupIdValue;
239
+ });
240
+ findNewColumns(groupDef.children, level + 1, existingGroup === null || existingGroup === void 0 ? void 0 : existingGroup.id);
241
+ }
242
+ } else {
243
+ // 普通列
244
+ var colDef = def;
245
+ if (!colDef.field) return 1; // continue
246
+ if (!existingFields.has(colDef.field)) {
247
+ // 新列 - 追加到末尾
248
+ newItems.push({
249
+ id: (0, _columnGroupUtils.generateId)(),
250
+ type: 'column',
251
+ parentId: parentId,
252
+ level: level,
253
+ order: ++maxOrder,
254
+ field: colDef.field,
255
+ headerName: colDef.headerName || colDef.field || '未命名列',
256
+ originalHeaderName: colDef.headerName || colDef.field || '未命名列',
257
+ width: colDef.width,
258
+ hide: colDef.hide,
259
+ pinned: colDef.pinned === null || colDef.pinned === true || colDef.pinned === false ? 'notPinned' : colDef.pinned,
260
+ cellClass: colDef.cellClass,
261
+ flex: colDef.flex,
262
+ suppressHeaderFilterButton: colDef.suppressHeaderFilterButton
263
+ });
264
+ }
265
+ }
266
+ };
267
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
268
+ if (_loop()) continue;
269
+ }
270
+ } catch (err) {
271
+ _iterator2.e(err);
272
+ } finally {
273
+ _iterator2.f();
274
+ }
275
+ };
276
+
277
+ // 从根级别开始查找新增列
278
+ findNewColumns(originalDefs, 0);
279
+ if (newItems.length > 0) {
280
+ return [].concat(_toConsumableArray(config), newItems);
281
+ }
282
+ return config;
283
+ }, []);
284
+
170
285
  /**
171
286
  * 获取列数据 - 将 Grid 的列定义转换为扁平化配置
172
287
  * 新版本使用树形结构,兼容旧版本的 groupName 结构
@@ -175,7 +290,14 @@ var ColumnSetting = function ColumnSetting(_ref) {
175
290
  // 优先使用当前方案中保存的完整列配置(包含分组结构)
176
291
  if (currentScheme !== null && currentScheme !== void 0 && currentScheme.columnConfig) {
177
292
  // 【修复】修正 originalHeaderName,确保使用 initialColumnDefs 中的原始值
178
- return fixOriginalHeaderName(currentScheme.columnConfig);
293
+ var config = fixOriginalHeaderName(currentScheme.columnConfig);
294
+ // 【修复】检测并追加代码中新增的列到配置末尾
295
+ config = mergeNewColumns(config, originalColumnDefs);
296
+ // 【修复】按 order 字段排序,确保配置弹窗显示的列顺序与保存时一致
297
+ config = _toConsumableArray(config).sort(function (a, b) {
298
+ return a.order - b.order;
299
+ });
300
+ return config;
179
301
  }
180
302
 
181
303
  // 如果方案中没有 columnConfig,则从 Grid 读取
@@ -215,7 +337,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
215
337
  return item;
216
338
  });
217
339
  return flatConfig;
218
- }, [gridApi, currentScheme, fixOriginalHeaderName, originalColumnDefs]);
340
+ }, [gridApi, currentScheme, fixOriginalHeaderName, originalColumnDefs, mergeNewColumns]);
219
341
 
220
342
  // 创建 Formily Form 实例
221
343
  var form = (0, _react.useMemo)(function () {
@@ -589,7 +711,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
589
711
  // 设置默认方案
590
712
  var handleSetDefault = (0, _react.useCallback)( /*#__PURE__*/function () {
591
713
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(schemeId) {
592
- var scheme, _iterator2, _step2, s;
714
+ var scheme, _iterator3, _step3, s;
593
715
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
594
716
  while (1) switch (_context4.prev = _context4.next) {
595
717
  case 0:
@@ -602,15 +724,15 @@ var ColumnSetting = function ColumnSetting(_ref) {
602
724
  break;
603
725
  }
604
726
  // 将其他方案设为非默认
605
- _iterator2 = _createForOfIteratorHelper(schemes);
727
+ _iterator3 = _createForOfIteratorHelper(schemes);
606
728
  _context4.prev = 4;
607
- _iterator2.s();
729
+ _iterator3.s();
608
730
  case 6:
609
- if ((_step2 = _iterator2.n()).done) {
731
+ if ((_step3 = _iterator3.n()).done) {
610
732
  _context4.next = 13;
611
733
  break;
612
734
  }
613
- s = _step2.value;
735
+ s = _step3.value;
614
736
  if (!(s.isDefault && s.id !== schemeId)) {
615
737
  _context4.next = 11;
616
738
  break;
@@ -628,10 +750,10 @@ var ColumnSetting = function ColumnSetting(_ref) {
628
750
  case 15:
629
751
  _context4.prev = 15;
630
752
  _context4.t0 = _context4["catch"](4);
631
- _iterator2.e(_context4.t0);
753
+ _iterator3.e(_context4.t0);
632
754
  case 18:
633
755
  _context4.prev = 18;
634
- _iterator2.f();
756
+ _iterator3.f();
635
757
  return _context4.finish(18);
636
758
  case 21:
637
759
  _context4.next = 23;
@@ -1285,9 +1285,8 @@ function AgGridPlus(props) {
1285
1285
  gridApi: apiRef.current,
1286
1286
  onSaveColumnState: onColumnStateChanged
1287
1287
  }),
1288
- /*#__PURE__*/
1289
- // 高级搜索(图标风格,位于设置右边)
1290
- React.createElement(Popover, {
1288
+ // 高级搜索(图标风格,位于设置右边)- 遵循 search 属性
1289
+ search !== false ? /*#__PURE__*/React.createElement(Popover, {
1291
1290
  key: "advanced-search-setting",
1292
1291
  content: /*#__PURE__*/React.createElement("div", {
1293
1292
  style: {
@@ -1356,7 +1355,7 @@ function AgGridPlus(props) {
1356
1355
  fontSize: 16,
1357
1356
  cursor: "pointer"
1358
1357
  }
1359
- }, /*#__PURE__*/React.createElement(FilterOutlined, null))))]
1358
+ }, /*#__PURE__*/React.createElement(FilterOutlined, null)))) : null].filter(Boolean)
1360
1359
  }), /*#__PURE__*/React.createElement(AgGridReact, _extends({
1361
1360
  theme: agGridTheme
1362
1361
  }, rest, {
@@ -7,6 +7,10 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
7
7
  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; }
8
8
  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); } }
9
9
  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); }); }; }
10
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
11
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
13
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
14
  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; }
11
15
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
16
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -26,7 +30,7 @@ import { AgGridReact } from 'ag-grid-react';
26
30
  import { agGridTheme } from "../theme";
27
31
  import { localeText } from "../locale";
28
32
  import { createForm, onFormInit } from '@formily/core';
29
- import { gridStateToFlatConfig, flatConfigToGridState, flatConfigToColumnState, isOldSchemeData, migrateOldScheme } from "./columnGroupUtils";
33
+ import { gridStateToFlatConfig, flatConfigToGridState, flatConfigToColumnState, isOldSchemeData, migrateOldScheme, generateId } from "./columnGroupUtils";
30
34
  import ColumnConfigTable from "./ColumnConfigTable";
31
35
  import DraggableModal from "../../draggableModal";
32
36
  import { useGridSchemes } from "../context/useSchemeManager";
@@ -158,6 +162,117 @@ var ColumnSetting = function ColumnSetting(_ref) {
158
162
  });
159
163
  }, [originalColumnDefs]);
160
164
 
165
+ /**
166
+ * 合并代码中新增的列到配置中
167
+ * 场景:用户保存列配置后,开发者在代码中新增了列,这些列应该显示在配置表格中
168
+ * 【修复】只检测并追加新增列到末尾,不改变已保存配置的顺序
169
+ */
170
+ var mergeNewColumns = useCallback(function (config, originalDefs) {
171
+ if (!originalDefs || originalDefs.length === 0) {
172
+ return config;
173
+ }
174
+
175
+ // 创建 field -> config item 的映射(用于快速查找已保存的列配置)
176
+ var existingFields = new Set();
177
+ config.filter(function (item) {
178
+ return item.type === 'column' && item.field;
179
+ }).forEach(function (item) {
180
+ existingFields.add(item.field);
181
+ });
182
+
183
+ // 创建 groupId -> config item 的映射(用于快速查找已保存的分组配置)
184
+ var existingGroupIds = new Set();
185
+ config.filter(function (item) {
186
+ return item.type === 'group' && item.groupId;
187
+ }).forEach(function (item) {
188
+ existingGroupIds.add(item.groupId);
189
+ });
190
+
191
+ // 收集新增的列(在 originalDefs 中存在但 config 中不存在)
192
+ var newItems = [];
193
+ var maxOrder = Math.max.apply(Math, _toConsumableArray(config.map(function (item) {
194
+ return item.order;
195
+ })).concat([-1]));
196
+
197
+ /**
198
+ * 递归处理列定义,查找新增的列和分组
199
+ */
200
+ var findNewColumns = function findNewColumns(defs, level, parentId) {
201
+ var _iterator2 = _createForOfIteratorHelper(defs),
202
+ _step2;
203
+ try {
204
+ var _loop = function _loop() {
205
+ var def = _step2.value;
206
+ // 检查是否是分组
207
+ if ('children' in def && def.children && def.children.length > 0) {
208
+ var groupDef = def;
209
+ var groupIdValue = groupDef.groupId || groupDef.field || generateId();
210
+ if (!existingGroupIds.has(groupIdValue)) {
211
+ // 新分组
212
+ var newGroupId = generateId();
213
+ newItems.push({
214
+ id: newGroupId,
215
+ type: 'group',
216
+ parentId: parentId,
217
+ level: level,
218
+ order: ++maxOrder,
219
+ headerName: groupDef.headerName || '未命名分组',
220
+ originalHeaderName: groupDef.headerName || '未命名分组',
221
+ groupId: groupIdValue,
222
+ marryChildren: groupDef.marryChildren
223
+ });
224
+ // 递归处理子节点(新分组的子节点也都是新的)
225
+ findNewColumns(groupDef.children, level + 1, newGroupId);
226
+ } else {
227
+ // 已存在的分组,但要检查子节点是否有新增
228
+ var existingGroup = config.find(function (item) {
229
+ return item.type === 'group' && item.groupId === groupIdValue;
230
+ });
231
+ findNewColumns(groupDef.children, level + 1, existingGroup === null || existingGroup === void 0 ? void 0 : existingGroup.id);
232
+ }
233
+ } else {
234
+ // 普通列
235
+ var colDef = def;
236
+ if (!colDef.field) return 1; // continue
237
+ if (!existingFields.has(colDef.field)) {
238
+ // 新列 - 追加到末尾
239
+ newItems.push({
240
+ id: generateId(),
241
+ type: 'column',
242
+ parentId: parentId,
243
+ level: level,
244
+ order: ++maxOrder,
245
+ field: colDef.field,
246
+ headerName: colDef.headerName || colDef.field || '未命名列',
247
+ originalHeaderName: colDef.headerName || colDef.field || '未命名列',
248
+ width: colDef.width,
249
+ hide: colDef.hide,
250
+ pinned: colDef.pinned === null || colDef.pinned === true || colDef.pinned === false ? 'notPinned' : colDef.pinned,
251
+ cellClass: colDef.cellClass,
252
+ flex: colDef.flex,
253
+ suppressHeaderFilterButton: colDef.suppressHeaderFilterButton
254
+ });
255
+ }
256
+ }
257
+ };
258
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
259
+ if (_loop()) continue;
260
+ }
261
+ } catch (err) {
262
+ _iterator2.e(err);
263
+ } finally {
264
+ _iterator2.f();
265
+ }
266
+ };
267
+
268
+ // 从根级别开始查找新增列
269
+ findNewColumns(originalDefs, 0);
270
+ if (newItems.length > 0) {
271
+ return [].concat(_toConsumableArray(config), newItems);
272
+ }
273
+ return config;
274
+ }, []);
275
+
161
276
  /**
162
277
  * 获取列数据 - 将 Grid 的列定义转换为扁平化配置
163
278
  * 新版本使用树形结构,兼容旧版本的 groupName 结构
@@ -166,7 +281,14 @@ var ColumnSetting = function ColumnSetting(_ref) {
166
281
  // 优先使用当前方案中保存的完整列配置(包含分组结构)
167
282
  if (currentScheme !== null && currentScheme !== void 0 && currentScheme.columnConfig) {
168
283
  // 【修复】修正 originalHeaderName,确保使用 initialColumnDefs 中的原始值
169
- return fixOriginalHeaderName(currentScheme.columnConfig);
284
+ var config = fixOriginalHeaderName(currentScheme.columnConfig);
285
+ // 【修复】检测并追加代码中新增的列到配置末尾
286
+ config = mergeNewColumns(config, originalColumnDefs);
287
+ // 【修复】按 order 字段排序,确保配置弹窗显示的列顺序与保存时一致
288
+ config = _toConsumableArray(config).sort(function (a, b) {
289
+ return a.order - b.order;
290
+ });
291
+ return config;
170
292
  }
171
293
 
172
294
  // 如果方案中没有 columnConfig,则从 Grid 读取
@@ -206,7 +328,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
206
328
  return item;
207
329
  });
208
330
  return flatConfig;
209
- }, [gridApi, currentScheme, fixOriginalHeaderName, originalColumnDefs]);
331
+ }, [gridApi, currentScheme, fixOriginalHeaderName, originalColumnDefs, mergeNewColumns]);
210
332
 
211
333
  // 创建 Formily Form 实例
212
334
  var form = useMemo(function () {
@@ -580,7 +702,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
580
702
  // 设置默认方案
581
703
  var handleSetDefault = useCallback( /*#__PURE__*/function () {
582
704
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(schemeId) {
583
- var scheme, _iterator2, _step2, s;
705
+ var scheme, _iterator3, _step3, s;
584
706
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
585
707
  while (1) switch (_context4.prev = _context4.next) {
586
708
  case 0:
@@ -593,15 +715,15 @@ var ColumnSetting = function ColumnSetting(_ref) {
593
715
  break;
594
716
  }
595
717
  // 将其他方案设为非默认
596
- _iterator2 = _createForOfIteratorHelper(schemes);
718
+ _iterator3 = _createForOfIteratorHelper(schemes);
597
719
  _context4.prev = 4;
598
- _iterator2.s();
720
+ _iterator3.s();
599
721
  case 6:
600
- if ((_step2 = _iterator2.n()).done) {
722
+ if ((_step3 = _iterator3.n()).done) {
601
723
  _context4.next = 13;
602
724
  break;
603
725
  }
604
- s = _step2.value;
726
+ s = _step3.value;
605
727
  if (!(s.isDefault && s.id !== schemeId)) {
606
728
  _context4.next = 11;
607
729
  break;
@@ -619,10 +741,10 @@ var ColumnSetting = function ColumnSetting(_ref) {
619
741
  case 15:
620
742
  _context4.prev = 15;
621
743
  _context4.t0 = _context4["catch"](4);
622
- _iterator2.e(_context4.t0);
744
+ _iterator3.e(_context4.t0);
623
745
  case 18:
624
746
  _context4.prev = 18;
625
- _iterator2.f();
747
+ _iterator3.f();
626
748
  return _context4.finish(18);
627
749
  case 21:
628
750
  _context4.next = 23;