@nokecy/qc-ui 1.1.27 → 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.
@@ -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; }
@@ -170,7 +174,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
170
174
  /**
171
175
  * 合并代码中新增的列到配置中
172
176
  * 场景:用户保存列配置后,开发者在代码中新增了列,这些列应该显示在配置表格中
173
- * 【增强】按照原始定义的顺序插入新增列,保留原始位置
177
+ * 【修复】只检测并追加新增列到末尾,不改变已保存配置的顺序
174
178
  */
175
179
  var mergeNewColumns = (0, _react.useCallback)(function (config, originalDefs) {
176
180
  if (!originalDefs || originalDefs.length === 0) {
@@ -178,93 +182,75 @@ var ColumnSetting = function ColumnSetting(_ref) {
178
182
  }
179
183
 
180
184
  // 创建 field -> config item 的映射(用于快速查找已保存的列配置)
181
- var configByField = new Map();
185
+ var existingFields = new Set();
182
186
  config.filter(function (item) {
183
187
  return item.type === 'column' && item.field;
184
188
  }).forEach(function (item) {
185
- configByField.set(item.field, item);
189
+ existingFields.add(item.field);
186
190
  });
187
191
 
188
192
  // 创建 groupId -> config item 的映射(用于快速查找已保存的分组配置)
189
- var configByGroupId = new Map();
193
+ var existingGroupIds = new Set();
190
194
  config.filter(function (item) {
191
195
  return item.type === 'group' && item.groupId;
192
196
  }).forEach(function (item) {
193
- configByGroupId.set(item.groupId, item);
197
+ existingGroupIds.add(item.groupId);
194
198
  });
195
- var result = [];
196
- var order = 0;
197
- var hasNewColumns = false;
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]));
198
205
 
199
206
  /**
200
- * 递归处理列定义,按原始顺序构建结果
201
- * @param defs 列定义数组
202
- * @param level 当前层级
203
- * @param parentId 父节点 ID(如果有)
207
+ * 递归处理列定义,查找新增的列和分组
204
208
  */
205
- var processDefsInOrder = function processDefsInOrder(defs, level, parentId) {
209
+ var findNewColumns = function findNewColumns(defs, level, parentId) {
206
210
  var _iterator2 = _createForOfIteratorHelper(defs),
207
211
  _step2;
208
212
  try {
209
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
213
+ var _loop = function _loop() {
210
214
  var def = _step2.value;
211
215
  // 检查是否是分组
212
216
  if ('children' in def && def.children && def.children.length > 0) {
213
217
  var groupDef = def;
214
218
  var groupIdValue = groupDef.groupId || groupDef.field || (0, _columnGroupUtils.generateId)();
215
-
216
- // 查找已保存的分组配置
217
- var existingGroup = configByGroupId.get(groupIdValue);
218
- var groupItem = void 0;
219
- if (existingGroup) {
220
- // 使用已保存的分组配置,但更新 order 和 parentId
221
- groupItem = _objectSpread(_objectSpread({}, existingGroup), {}, {
222
- order: order++,
223
- parentId: parentId,
224
- level: level
225
- });
226
- } else {
219
+ if (!existingGroupIds.has(groupIdValue)) {
227
220
  // 新分组
228
- hasNewColumns = true;
229
- groupItem = {
230
- id: (0, _columnGroupUtils.generateId)(),
221
+ var newGroupId = (0, _columnGroupUtils.generateId)();
222
+ newItems.push({
223
+ id: newGroupId,
231
224
  type: 'group',
232
225
  parentId: parentId,
233
226
  level: level,
234
- order: order++,
227
+ order: ++maxOrder,
235
228
  headerName: groupDef.headerName || '未命名分组',
236
229
  originalHeaderName: groupDef.headerName || '未命名分组',
237
230
  groupId: groupIdValue,
238
231
  marryChildren: groupDef.marryChildren
239
- };
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);
240
241
  }
241
- result.push(groupItem);
242
-
243
- // 递归处理子节点
244
- processDefsInOrder(groupDef.children, level + 1, groupItem.id);
245
242
  } else {
246
243
  // 普通列
247
244
  var colDef = def;
248
- if (!colDef.field) continue;
249
-
250
- // 查找已保存的列配置
251
- var existingCol = configByField.get(colDef.field);
252
- if (existingCol) {
253
- // 使用已保存的列配置,但更新 order 和 parentId
254
- result.push(_objectSpread(_objectSpread({}, existingCol), {}, {
255
- order: order++,
256
- parentId: parentId,
257
- level: level
258
- }));
259
- } else {
260
- // 新列
261
- hasNewColumns = true;
262
- result.push({
245
+ if (!colDef.field) return 1; // continue
246
+ if (!existingFields.has(colDef.field)) {
247
+ // 新列 - 追加到末尾
248
+ newItems.push({
263
249
  id: (0, _columnGroupUtils.generateId)(),
264
250
  type: 'column',
265
251
  parentId: parentId,
266
252
  level: level,
267
- order: order++,
253
+ order: ++maxOrder,
268
254
  field: colDef.field,
269
255
  headerName: colDef.headerName || colDef.field || '未命名列',
270
256
  originalHeaderName: colDef.headerName || colDef.field || '未命名列',
@@ -277,6 +263,9 @@ var ColumnSetting = function ColumnSetting(_ref) {
277
263
  });
278
264
  }
279
265
  }
266
+ };
267
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
268
+ if (_loop()) continue;
280
269
  }
281
270
  } catch (err) {
282
271
  _iterator2.e(err);
@@ -285,10 +274,12 @@ var ColumnSetting = function ColumnSetting(_ref) {
285
274
  }
286
275
  };
287
276
 
288
- // 从根级别开始处理
289
- processDefsInOrder(originalDefs, 0);
290
- if (hasNewColumns) {}
291
- return result;
277
+ // 从根级别开始查找新增列
278
+ findNewColumns(originalDefs, 0);
279
+ if (newItems.length > 0) {
280
+ return [].concat(_toConsumableArray(config), newItems);
281
+ }
282
+ return config;
292
283
  }, []);
293
284
 
294
285
  /**
@@ -302,6 +293,10 @@ var ColumnSetting = function ColumnSetting(_ref) {
302
293
  var config = fixOriginalHeaderName(currentScheme.columnConfig);
303
294
  // 【修复】检测并追加代码中新增的列到配置末尾
304
295
  config = mergeNewColumns(config, originalColumnDefs);
296
+ // 【修复】按 order 字段排序,确保配置弹窗显示的列顺序与保存时一致
297
+ config = _toConsumableArray(config).sort(function (a, b) {
298
+ return a.order - b.order;
299
+ });
305
300
  return config;
306
301
  }
307
302
 
@@ -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; }
@@ -161,7 +165,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
161
165
  /**
162
166
  * 合并代码中新增的列到配置中
163
167
  * 场景:用户保存列配置后,开发者在代码中新增了列,这些列应该显示在配置表格中
164
- * 【增强】按照原始定义的顺序插入新增列,保留原始位置
168
+ * 【修复】只检测并追加新增列到末尾,不改变已保存配置的顺序
165
169
  */
166
170
  var mergeNewColumns = useCallback(function (config, originalDefs) {
167
171
  if (!originalDefs || originalDefs.length === 0) {
@@ -169,93 +173,75 @@ var ColumnSetting = function ColumnSetting(_ref) {
169
173
  }
170
174
 
171
175
  // 创建 field -> config item 的映射(用于快速查找已保存的列配置)
172
- var configByField = new Map();
176
+ var existingFields = new Set();
173
177
  config.filter(function (item) {
174
178
  return item.type === 'column' && item.field;
175
179
  }).forEach(function (item) {
176
- configByField.set(item.field, item);
180
+ existingFields.add(item.field);
177
181
  });
178
182
 
179
183
  // 创建 groupId -> config item 的映射(用于快速查找已保存的分组配置)
180
- var configByGroupId = new Map();
184
+ var existingGroupIds = new Set();
181
185
  config.filter(function (item) {
182
186
  return item.type === 'group' && item.groupId;
183
187
  }).forEach(function (item) {
184
- configByGroupId.set(item.groupId, item);
188
+ existingGroupIds.add(item.groupId);
185
189
  });
186
- var result = [];
187
- var order = 0;
188
- var hasNewColumns = false;
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]));
189
196
 
190
197
  /**
191
- * 递归处理列定义,按原始顺序构建结果
192
- * @param defs 列定义数组
193
- * @param level 当前层级
194
- * @param parentId 父节点 ID(如果有)
198
+ * 递归处理列定义,查找新增的列和分组
195
199
  */
196
- var processDefsInOrder = function processDefsInOrder(defs, level, parentId) {
200
+ var findNewColumns = function findNewColumns(defs, level, parentId) {
197
201
  var _iterator2 = _createForOfIteratorHelper(defs),
198
202
  _step2;
199
203
  try {
200
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
204
+ var _loop = function _loop() {
201
205
  var def = _step2.value;
202
206
  // 检查是否是分组
203
207
  if ('children' in def && def.children && def.children.length > 0) {
204
208
  var groupDef = def;
205
209
  var groupIdValue = groupDef.groupId || groupDef.field || generateId();
206
-
207
- // 查找已保存的分组配置
208
- var existingGroup = configByGroupId.get(groupIdValue);
209
- var groupItem = void 0;
210
- if (existingGroup) {
211
- // 使用已保存的分组配置,但更新 order 和 parentId
212
- groupItem = _objectSpread(_objectSpread({}, existingGroup), {}, {
213
- order: order++,
214
- parentId: parentId,
215
- level: level
216
- });
217
- } else {
210
+ if (!existingGroupIds.has(groupIdValue)) {
218
211
  // 新分组
219
- hasNewColumns = true;
220
- groupItem = {
221
- id: generateId(),
212
+ var newGroupId = generateId();
213
+ newItems.push({
214
+ id: newGroupId,
222
215
  type: 'group',
223
216
  parentId: parentId,
224
217
  level: level,
225
- order: order++,
218
+ order: ++maxOrder,
226
219
  headerName: groupDef.headerName || '未命名分组',
227
220
  originalHeaderName: groupDef.headerName || '未命名分组',
228
221
  groupId: groupIdValue,
229
222
  marryChildren: groupDef.marryChildren
230
- };
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);
231
232
  }
232
- result.push(groupItem);
233
-
234
- // 递归处理子节点
235
- processDefsInOrder(groupDef.children, level + 1, groupItem.id);
236
233
  } else {
237
234
  // 普通列
238
235
  var colDef = def;
239
- if (!colDef.field) continue;
240
-
241
- // 查找已保存的列配置
242
- var existingCol = configByField.get(colDef.field);
243
- if (existingCol) {
244
- // 使用已保存的列配置,但更新 order 和 parentId
245
- result.push(_objectSpread(_objectSpread({}, existingCol), {}, {
246
- order: order++,
247
- parentId: parentId,
248
- level: level
249
- }));
250
- } else {
251
- // 新列
252
- hasNewColumns = true;
253
- result.push({
236
+ if (!colDef.field) return 1; // continue
237
+ if (!existingFields.has(colDef.field)) {
238
+ // 新列 - 追加到末尾
239
+ newItems.push({
254
240
  id: generateId(),
255
241
  type: 'column',
256
242
  parentId: parentId,
257
243
  level: level,
258
- order: order++,
244
+ order: ++maxOrder,
259
245
  field: colDef.field,
260
246
  headerName: colDef.headerName || colDef.field || '未命名列',
261
247
  originalHeaderName: colDef.headerName || colDef.field || '未命名列',
@@ -268,6 +254,9 @@ var ColumnSetting = function ColumnSetting(_ref) {
268
254
  });
269
255
  }
270
256
  }
257
+ };
258
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
259
+ if (_loop()) continue;
271
260
  }
272
261
  } catch (err) {
273
262
  _iterator2.e(err);
@@ -276,10 +265,12 @@ var ColumnSetting = function ColumnSetting(_ref) {
276
265
  }
277
266
  };
278
267
 
279
- // 从根级别开始处理
280
- processDefsInOrder(originalDefs, 0);
281
- if (hasNewColumns) {}
282
- return result;
268
+ // 从根级别开始查找新增列
269
+ findNewColumns(originalDefs, 0);
270
+ if (newItems.length > 0) {
271
+ return [].concat(_toConsumableArray(config), newItems);
272
+ }
273
+ return config;
283
274
  }, []);
284
275
 
285
276
  /**
@@ -293,6 +284,10 @@ var ColumnSetting = function ColumnSetting(_ref) {
293
284
  var config = fixOriginalHeaderName(currentScheme.columnConfig);
294
285
  // 【修复】检测并追加代码中新增的列到配置末尾
295
286
  config = mergeNewColumns(config, originalColumnDefs);
287
+ // 【修复】按 order 字段排序,确保配置弹窗显示的列顺序与保存时一致
288
+ config = _toConsumableArray(config).sort(function (a, b) {
289
+ return a.order - b.order;
290
+ });
296
291
  return config;
297
292
  }
298
293