@nokecy/qc-ui 1.1.12 → 1.1.13
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/shared/storage/backendApiAdapter.d.ts +17 -0
- package/dist/cjs/ag-grid-plus/shared/storage/backendApiAdapter.js +50 -5
- package/dist/cjs/array-table/index.js +17 -7
- package/dist/esm/ag-grid-plus/shared/storage/backendApiAdapter.d.ts +17 -0
- package/dist/esm/ag-grid-plus/shared/storage/backendApiAdapter.js +50 -5
- package/dist/esm/array-table/index.js +17 -7
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
|
@@ -37,6 +37,23 @@ export declare class BackendApiSchemeAdapter implements SchemeStorageAdapter {
|
|
|
37
37
|
* 日志输出
|
|
38
38
|
*/
|
|
39
39
|
private log;
|
|
40
|
+
/**
|
|
41
|
+
* 【修复】将 JavaScript 时间戳转换为 ISO 字符串
|
|
42
|
+
*
|
|
43
|
+
* JavaScript Date.now() 返回毫秒时间戳(如 1699344567890)
|
|
44
|
+
* .NET DateTimeOffset 需要 ISO 8601 格式字符串(如 "2023-11-07T08:36:07.890Z")
|
|
45
|
+
*
|
|
46
|
+
* @param timestamp 毫秒时间戳
|
|
47
|
+
* @returns ISO 8601 格式字符串
|
|
48
|
+
*/
|
|
49
|
+
private toIsoString;
|
|
50
|
+
/**
|
|
51
|
+
* 【修复】将 ISO 字符串转换为 JavaScript 时间戳
|
|
52
|
+
*
|
|
53
|
+
* @param isoString ISO 8601 格式字符串
|
|
54
|
+
* @returns 毫秒时间戳
|
|
55
|
+
*/
|
|
56
|
+
private fromIsoString;
|
|
40
57
|
/**
|
|
41
58
|
* 生成请求头
|
|
42
59
|
*/
|
|
@@ -82,6 +82,39 @@ var BackendApiSchemeAdapter = exports.BackendApiSchemeAdapter = /*#__PURE__*/fun
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* 【修复】将 JavaScript 时间戳转换为 ISO 字符串
|
|
87
|
+
*
|
|
88
|
+
* JavaScript Date.now() 返回毫秒时间戳(如 1699344567890)
|
|
89
|
+
* .NET DateTimeOffset 需要 ISO 8601 格式字符串(如 "2023-11-07T08:36:07.890Z")
|
|
90
|
+
*
|
|
91
|
+
* @param timestamp 毫秒时间戳
|
|
92
|
+
* @returns ISO 8601 格式字符串
|
|
93
|
+
*/
|
|
94
|
+
}, {
|
|
95
|
+
key: "toIsoString",
|
|
96
|
+
value: function toIsoString(timestamp) {
|
|
97
|
+
if (timestamp === undefined || timestamp === null) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
return new Date(timestamp).toISOString();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 【修复】将 ISO 字符串转换为 JavaScript 时间戳
|
|
105
|
+
*
|
|
106
|
+
* @param isoString ISO 8601 格式字符串
|
|
107
|
+
* @returns 毫秒时间戳
|
|
108
|
+
*/
|
|
109
|
+
}, {
|
|
110
|
+
key: "fromIsoString",
|
|
111
|
+
value: function fromIsoString(isoString) {
|
|
112
|
+
if (!isoString) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
return new Date(isoString).getTime();
|
|
116
|
+
}
|
|
117
|
+
|
|
85
118
|
/**
|
|
86
119
|
* 生成请求头
|
|
87
120
|
*/
|
|
@@ -256,9 +289,11 @@ var BackendApiSchemeAdapter = exports.BackendApiSchemeAdapter = /*#__PURE__*/fun
|
|
|
256
289
|
_context3.prev = 0;
|
|
257
290
|
this.log("\u4FDD\u5B58\u5217\u65B9\u6848: ".concat(gridId, " - ").concat(scheme.name));
|
|
258
291
|
|
|
259
|
-
//
|
|
292
|
+
// 【修复】将时间戳转换为 ISO 字符串,并将 columnConfig 转换为 JSON 字符串
|
|
260
293
|
schemeForBackend = _objectSpread(_objectSpread({}, scheme), {}, {
|
|
261
|
-
columnConfig: JSON.stringify(scheme.columnConfig)
|
|
294
|
+
columnConfig: JSON.stringify(scheme.columnConfig),
|
|
295
|
+
createdAt: this.toIsoString(scheme.createdAt),
|
|
296
|
+
updatedAt: this.toIsoString(scheme.updatedAt)
|
|
262
297
|
});
|
|
263
298
|
url = "".concat(this.config.apiBaseUrl, "/api/extra-object/table-scheme/save-column-scheme");
|
|
264
299
|
_context3.next = 6;
|
|
@@ -277,10 +312,20 @@ var BackendApiSchemeAdapter = exports.BackendApiSchemeAdapter = /*#__PURE__*/fun
|
|
|
277
312
|
}
|
|
278
313
|
throw new Error(response.message || '保存失败');
|
|
279
314
|
case 9:
|
|
280
|
-
//
|
|
315
|
+
// 【修复】将返回的数据转换回前端格式
|
|
281
316
|
savedScheme = response.scheme;
|
|
282
|
-
if (savedScheme
|
|
283
|
-
|
|
317
|
+
if (savedScheme) {
|
|
318
|
+
// 解析 columnConfig
|
|
319
|
+
if (typeof savedScheme.columnConfig === 'string') {
|
|
320
|
+
savedScheme.columnConfig = JSON.parse(savedScheme.columnConfig);
|
|
321
|
+
}
|
|
322
|
+
// 将 ISO 字符串转换回时间戳
|
|
323
|
+
if (savedScheme.createdAt) {
|
|
324
|
+
savedScheme.createdAt = this.fromIsoString(savedScheme.createdAt);
|
|
325
|
+
}
|
|
326
|
+
if (savedScheme.updatedAt) {
|
|
327
|
+
savedScheme.updatedAt = this.fromIsoString(savedScheme.updatedAt);
|
|
328
|
+
}
|
|
284
329
|
}
|
|
285
330
|
this.log('保存成功', savedScheme);
|
|
286
331
|
return _context3.abrupt("return", savedScheme);
|
|
@@ -94,8 +94,11 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
94
94
|
});
|
|
95
95
|
}, [props.gridKey, currentSchemes, columnSchemes]);
|
|
96
96
|
|
|
97
|
-
// 使用 ref
|
|
98
|
-
var
|
|
97
|
+
// 使用 ref 记录上次应用的方案状态,避免重复应用
|
|
98
|
+
var lastAppliedSchemeRef = (0, _react.useRef)({
|
|
99
|
+
id: null,
|
|
100
|
+
updatedAt: null
|
|
101
|
+
});
|
|
99
102
|
|
|
100
103
|
/**
|
|
101
104
|
* 方案自动加载
|
|
@@ -110,10 +113,14 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
110
113
|
if (!props.gridKey || !gridApiState || !currentScheme) return;
|
|
111
114
|
if (!currentScheme.columnConfig || currentScheme.columnConfig.length === 0) return;
|
|
112
115
|
|
|
113
|
-
//
|
|
114
|
-
|
|
116
|
+
// 【关键修复】检查方案是否真正变化(比对 ID 和 updatedAt)
|
|
117
|
+
// 只有当方案 ID 变化,或者同一方案但 updatedAt 变化时,才重新应用
|
|
118
|
+
var isSameScheme = currentScheme.id === lastAppliedSchemeRef.current.id;
|
|
119
|
+
var isSameVersion = currentScheme.updatedAt === lastAppliedSchemeRef.current.updatedAt;
|
|
120
|
+
if (isSameScheme && isSameVersion) {
|
|
115
121
|
return;
|
|
116
122
|
}
|
|
123
|
+
if (isSameScheme && !isSameVersion) {}
|
|
117
124
|
// 使用 Promise 链确保顺序执行,避免竞态条件
|
|
118
125
|
var cancelled = false;
|
|
119
126
|
Promise.resolve().then(function () {
|
|
@@ -159,8 +166,11 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
159
166
|
gridApiState.setFilterModel(currentScheme.filterModel);
|
|
160
167
|
}
|
|
161
168
|
|
|
162
|
-
//
|
|
163
|
-
|
|
169
|
+
// 【关键修复】记录已应用的方案状态(ID + updatedAt)
|
|
170
|
+
lastAppliedSchemeRef.current = {
|
|
171
|
+
id: currentScheme.id,
|
|
172
|
+
updatedAt: currentScheme.updatedAt
|
|
173
|
+
};
|
|
164
174
|
}).catch(function (error) {
|
|
165
175
|
if (!cancelled) {
|
|
166
176
|
console.error('[ArrayTable] 应用方案失败:', error);
|
|
@@ -171,7 +181,7 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
171
181
|
return function () {
|
|
172
182
|
cancelled = true;
|
|
173
183
|
};
|
|
174
|
-
}, [props.gridKey, gridApiState, currentScheme === null || currentScheme === void 0 ? void 0 : currentScheme.id]);
|
|
184
|
+
}, [props.gridKey, gridApiState, currentScheme === null || currentScheme === void 0 ? void 0 : currentScheme.id, currentScheme === null || currentScheme === void 0 ? void 0 : currentScheme.updatedAt]);
|
|
175
185
|
|
|
176
186
|
//@ts-ignore
|
|
177
187
|
if (columns.length > 0) {
|
|
@@ -37,6 +37,23 @@ export declare class BackendApiSchemeAdapter implements SchemeStorageAdapter {
|
|
|
37
37
|
* 日志输出
|
|
38
38
|
*/
|
|
39
39
|
private log;
|
|
40
|
+
/**
|
|
41
|
+
* 【修复】将 JavaScript 时间戳转换为 ISO 字符串
|
|
42
|
+
*
|
|
43
|
+
* JavaScript Date.now() 返回毫秒时间戳(如 1699344567890)
|
|
44
|
+
* .NET DateTimeOffset 需要 ISO 8601 格式字符串(如 "2023-11-07T08:36:07.890Z")
|
|
45
|
+
*
|
|
46
|
+
* @param timestamp 毫秒时间戳
|
|
47
|
+
* @returns ISO 8601 格式字符串
|
|
48
|
+
*/
|
|
49
|
+
private toIsoString;
|
|
50
|
+
/**
|
|
51
|
+
* 【修复】将 ISO 字符串转换为 JavaScript 时间戳
|
|
52
|
+
*
|
|
53
|
+
* @param isoString ISO 8601 格式字符串
|
|
54
|
+
* @returns 毫秒时间戳
|
|
55
|
+
*/
|
|
56
|
+
private fromIsoString;
|
|
40
57
|
/**
|
|
41
58
|
* 生成请求头
|
|
42
59
|
*/
|
|
@@ -83,6 +83,39 @@ export var BackendApiSchemeAdapter = /*#__PURE__*/function () {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
/**
|
|
87
|
+
* 【修复】将 JavaScript 时间戳转换为 ISO 字符串
|
|
88
|
+
*
|
|
89
|
+
* JavaScript Date.now() 返回毫秒时间戳(如 1699344567890)
|
|
90
|
+
* .NET DateTimeOffset 需要 ISO 8601 格式字符串(如 "2023-11-07T08:36:07.890Z")
|
|
91
|
+
*
|
|
92
|
+
* @param timestamp 毫秒时间戳
|
|
93
|
+
* @returns ISO 8601 格式字符串
|
|
94
|
+
*/
|
|
95
|
+
}, {
|
|
96
|
+
key: "toIsoString",
|
|
97
|
+
value: function toIsoString(timestamp) {
|
|
98
|
+
if (timestamp === undefined || timestamp === null) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
return new Date(timestamp).toISOString();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 【修复】将 ISO 字符串转换为 JavaScript 时间戳
|
|
106
|
+
*
|
|
107
|
+
* @param isoString ISO 8601 格式字符串
|
|
108
|
+
* @returns 毫秒时间戳
|
|
109
|
+
*/
|
|
110
|
+
}, {
|
|
111
|
+
key: "fromIsoString",
|
|
112
|
+
value: function fromIsoString(isoString) {
|
|
113
|
+
if (!isoString) {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
return new Date(isoString).getTime();
|
|
117
|
+
}
|
|
118
|
+
|
|
86
119
|
/**
|
|
87
120
|
* 生成请求头
|
|
88
121
|
*/
|
|
@@ -257,9 +290,11 @@ export var BackendApiSchemeAdapter = /*#__PURE__*/function () {
|
|
|
257
290
|
_context3.prev = 0;
|
|
258
291
|
this.log("\u4FDD\u5B58\u5217\u65B9\u6848: ".concat(gridId, " - ").concat(scheme.name));
|
|
259
292
|
|
|
260
|
-
//
|
|
293
|
+
// 【修复】将时间戳转换为 ISO 字符串,并将 columnConfig 转换为 JSON 字符串
|
|
261
294
|
schemeForBackend = _objectSpread(_objectSpread({}, scheme), {}, {
|
|
262
|
-
columnConfig: JSON.stringify(scheme.columnConfig)
|
|
295
|
+
columnConfig: JSON.stringify(scheme.columnConfig),
|
|
296
|
+
createdAt: this.toIsoString(scheme.createdAt),
|
|
297
|
+
updatedAt: this.toIsoString(scheme.updatedAt)
|
|
263
298
|
});
|
|
264
299
|
url = "".concat(this.config.apiBaseUrl, "/api/extra-object/table-scheme/save-column-scheme");
|
|
265
300
|
_context3.next = 6;
|
|
@@ -278,10 +313,20 @@ export var BackendApiSchemeAdapter = /*#__PURE__*/function () {
|
|
|
278
313
|
}
|
|
279
314
|
throw new Error(response.message || '保存失败');
|
|
280
315
|
case 9:
|
|
281
|
-
//
|
|
316
|
+
// 【修复】将返回的数据转换回前端格式
|
|
282
317
|
savedScheme = response.scheme;
|
|
283
|
-
if (savedScheme
|
|
284
|
-
|
|
318
|
+
if (savedScheme) {
|
|
319
|
+
// 解析 columnConfig
|
|
320
|
+
if (typeof savedScheme.columnConfig === 'string') {
|
|
321
|
+
savedScheme.columnConfig = JSON.parse(savedScheme.columnConfig);
|
|
322
|
+
}
|
|
323
|
+
// 将 ISO 字符串转换回时间戳
|
|
324
|
+
if (savedScheme.createdAt) {
|
|
325
|
+
savedScheme.createdAt = this.fromIsoString(savedScheme.createdAt);
|
|
326
|
+
}
|
|
327
|
+
if (savedScheme.updatedAt) {
|
|
328
|
+
savedScheme.updatedAt = this.fromIsoString(savedScheme.updatedAt);
|
|
329
|
+
}
|
|
285
330
|
}
|
|
286
331
|
this.log('保存成功', savedScheme);
|
|
287
332
|
return _context3.abrupt("return", savedScheme);
|
|
@@ -90,8 +90,11 @@ var ArrayTableInner = observer(function (props) {
|
|
|
90
90
|
});
|
|
91
91
|
}, [props.gridKey, currentSchemes, columnSchemes]);
|
|
92
92
|
|
|
93
|
-
// 使用 ref
|
|
94
|
-
var
|
|
93
|
+
// 使用 ref 记录上次应用的方案状态,避免重复应用
|
|
94
|
+
var lastAppliedSchemeRef = useRef({
|
|
95
|
+
id: null,
|
|
96
|
+
updatedAt: null
|
|
97
|
+
});
|
|
95
98
|
|
|
96
99
|
/**
|
|
97
100
|
* 方案自动加载
|
|
@@ -106,10 +109,14 @@ var ArrayTableInner = observer(function (props) {
|
|
|
106
109
|
if (!props.gridKey || !gridApiState || !currentScheme) return;
|
|
107
110
|
if (!currentScheme.columnConfig || currentScheme.columnConfig.length === 0) return;
|
|
108
111
|
|
|
109
|
-
//
|
|
110
|
-
|
|
112
|
+
// 【关键修复】检查方案是否真正变化(比对 ID 和 updatedAt)
|
|
113
|
+
// 只有当方案 ID 变化,或者同一方案但 updatedAt 变化时,才重新应用
|
|
114
|
+
var isSameScheme = currentScheme.id === lastAppliedSchemeRef.current.id;
|
|
115
|
+
var isSameVersion = currentScheme.updatedAt === lastAppliedSchemeRef.current.updatedAt;
|
|
116
|
+
if (isSameScheme && isSameVersion) {
|
|
111
117
|
return;
|
|
112
118
|
}
|
|
119
|
+
if (isSameScheme && !isSameVersion) {}
|
|
113
120
|
// 使用 Promise 链确保顺序执行,避免竞态条件
|
|
114
121
|
var cancelled = false;
|
|
115
122
|
Promise.resolve().then(function () {
|
|
@@ -155,8 +162,11 @@ var ArrayTableInner = observer(function (props) {
|
|
|
155
162
|
gridApiState.setFilterModel(currentScheme.filterModel);
|
|
156
163
|
}
|
|
157
164
|
|
|
158
|
-
//
|
|
159
|
-
|
|
165
|
+
// 【关键修复】记录已应用的方案状态(ID + updatedAt)
|
|
166
|
+
lastAppliedSchemeRef.current = {
|
|
167
|
+
id: currentScheme.id,
|
|
168
|
+
updatedAt: currentScheme.updatedAt
|
|
169
|
+
};
|
|
160
170
|
}).catch(function (error) {
|
|
161
171
|
if (!cancelled) {
|
|
162
172
|
console.error('[ArrayTable] 应用方案失败:', error);
|
|
@@ -167,7 +177,7 @@ var ArrayTableInner = observer(function (props) {
|
|
|
167
177
|
return function () {
|
|
168
178
|
cancelled = true;
|
|
169
179
|
};
|
|
170
|
-
}, [props.gridKey, gridApiState, currentScheme === null || currentScheme === void 0 ? void 0 : currentScheme.id]);
|
|
180
|
+
}, [props.gridKey, gridApiState, currentScheme === null || currentScheme === void 0 ? void 0 : currentScheme.id, currentScheme === null || currentScheme === void 0 ? void 0 : currentScheme.updatedAt]);
|
|
171
181
|
|
|
172
182
|
//@ts-ignore
|
|
173
183
|
if (columns.length > 0) {
|