@yoooloo42/joker 1.0.144 → 1.0.146

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/index.cjs.js CHANGED
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var vueRouter = require('vue-router');
6
- var vue = require('vue');
7
6
  var elementPlus = require('element-plus');
7
+ var vue = require('vue');
8
8
 
9
9
  function _mergeNamespaces(n, m) {
10
10
  m.forEach(function (e) {
@@ -16873,7 +16873,7 @@ var lookup = [];
16873
16873
  var revLookup = [];
16874
16874
  var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
16875
16875
  var inited = false;
16876
- function init () {
16876
+ function init$1 () {
16877
16877
  inited = true;
16878
16878
  var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
16879
16879
  for (var i = 0, len = code.length; i < len; ++i) {
@@ -16887,7 +16887,7 @@ function init () {
16887
16887
 
16888
16888
  function toByteArray (b64) {
16889
16889
  if (!inited) {
16890
- init();
16890
+ init$1();
16891
16891
  }
16892
16892
  var i, j, l, tmp, placeHolders, arr;
16893
16893
  var len = b64.length;
@@ -16946,7 +16946,7 @@ function encodeChunk (uint8, start, end) {
16946
16946
 
16947
16947
  function fromByteArray (uint8) {
16948
16948
  if (!inited) {
16949
- init();
16949
+ init$1();
16950
16950
  }
16951
16951
  var tmp;
16952
16952
  var len = uint8.length;
@@ -22140,6 +22140,767 @@ var request = {
22140
22140
  ly0: ly0request$1
22141
22141
  };
22142
22142
 
22143
+ // 引用标准:GB/T 2260
22144
+
22145
+ /**
22146
+ * 深度拷贝函数
22147
+ *
22148
+ * @param {any} obj 需要拷贝的对象、数组或基本类型值
22149
+ * @param {WeakMap} [cache=new WeakMap()] 用于处理循环引用的缓存
22150
+ * @returns {any} 深度拷贝后的新对象/新值
22151
+ */
22152
+ function deepClone$1(obj, cache = new WeakMap()) {
22153
+ // 1. 基本类型值(包括 null)和函数,直接返回
22154
+ if (obj === null || typeof obj !== 'object') {
22155
+ return obj;
22156
+ }
22157
+ // 处理函数(尽管技术上函数是对象,但我们通常不克隆它,而是直接引用)
22158
+ if (typeof obj === 'function') {
22159
+ return obj;
22160
+ }
22161
+
22162
+ // 2. 检查循环引用
22163
+ // 如果缓存中已存在该对象,说明遇到了循环引用,直接返回缓存中的克隆对象
22164
+ if (cache.has(obj)) {
22165
+ return cache.get(obj);
22166
+ }
22167
+
22168
+ // 3. 处理特定内置对象(Date 和 RegExp)
22169
+ if (obj instanceof Date) {
22170
+ return new Date(obj.getTime());
22171
+ }
22172
+ if (obj instanceof RegExp) {
22173
+ // g: global, i: ignoreCase, m: multiline, u: unicode, y: sticky
22174
+ const flags = obj.global ? 'g' : ''
22175
+ + obj.ignoreCase ? 'i' : ''
22176
+ + obj.multiline ? 'm' : ''
22177
+ + obj.unicode ? 'u' : ''
22178
+ + obj.sticky ? 'y' : '';
22179
+ return new RegExp(obj.source, flags);
22180
+ }
22181
+
22182
+ // 4. 初始化克隆对象
22183
+ // 如果是数组,则初始化为空数组;否则初始化为空对象
22184
+ const clone = Array.isArray(obj) ? [] : {};
22185
+
22186
+ // 将克隆对象放入缓存,以处理接下来的递归调用中可能遇到的循环引用
22187
+ cache.set(obj, clone);
22188
+
22189
+ // 5. 递归拷贝属性
22190
+ for (const key in obj) {
22191
+ // 确保只处理对象自身的属性,排除原型链上的属性
22192
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
22193
+ clone[key] = deepClone$1(obj[key], cache);
22194
+ }
22195
+ }
22196
+
22197
+ // 6. 拷贝 Symbol 属性 (ES6/ES2015+)
22198
+ if (typeof Object.getOwnPropertySymbols === 'function') {
22199
+ Object.getOwnPropertySymbols(obj).forEach(sym => {
22200
+ clone[sym] = deepClone$1(obj[sym], cache);
22201
+ });
22202
+ }
22203
+
22204
+ return clone;
22205
+ }
22206
+
22207
+ /**
22208
+ * 深度拷贝函数,并在拷贝叶节点值时应用一个转换函数。
22209
+ *
22210
+ * @param {any} obj - 需要拷贝的对象、数组或基本类型值。
22211
+ * @param {function} valueMapper - 接收叶节点值作为参数,并返回新值的转换函数。
22212
+ * @param {WeakMap} [cache=new WeakMap()] - 用于处理循环引用的缓存。
22213
+ * @returns {any} 深度拷贝并转换后的新对象/新值。
22214
+ */
22215
+ function deepCloneAndMap(obj, valueMapper, cache = new WeakMap()) {
22216
+ // 1. 基本类型值(包括 null)和函数,**应用 valueMapper**
22217
+
22218
+ // 如果是基本类型值(包括 null),则认为是叶节点,应用 valueMapper
22219
+ if (obj === null || typeof obj !== 'object') {
22220
+ // 对基本类型值应用转换函数
22221
+ return valueMapper ? valueMapper(obj) : obj;
22222
+ }
22223
+
22224
+ // 如果是函数,通常我们不克隆它,也不转换它的值,直接返回
22225
+ if (typeof obj === 'function') {
22226
+ return obj;
22227
+ }
22228
+
22229
+ // 2. 检查循环引用 (与原函数逻辑相同)
22230
+ if (cache.has(obj)) {
22231
+ return cache.get(obj);
22232
+ }
22233
+
22234
+ // 3. 处理特定内置对象(Date 和 RegExp),**应用 valueMapper**
22235
+
22236
+ // 对于 Date 和 RegExp 这种对象实例,我们通常将它们的**值**视为叶节点,
22237
+ // 克隆实例本身后,再对这个克隆实例应用 valueMapper。
22238
+ let clone;
22239
+
22240
+ if (obj instanceof Date) {
22241
+ clone = new Date(obj.getTime());
22242
+ } else if (obj instanceof RegExp) {
22243
+ // 提取 flags
22244
+ const flags = (obj.global ? 'g' : '')
22245
+ + (obj.ignoreCase ? 'i' : '')
22246
+ + (obj.multiline ? 'm' : '')
22247
+ + (obj.unicode ? 'u' : '')
22248
+ + (obj.sticky ? 'y' : '');
22249
+ clone = new RegExp(obj.source, flags);
22250
+ }
22251
+
22252
+ // 检查是否是内置对象(Date/RegExp),如果是,对克隆后的实例应用转换
22253
+ if (clone) {
22254
+ return valueMapper ? valueMapper(clone) : clone;
22255
+ }
22256
+
22257
+ // 4. 初始化克隆对象 (普通对象和数组)
22258
+ clone = Array.isArray(obj) ? [] : {};
22259
+
22260
+ // 将克隆对象放入缓存
22261
+ cache.set(obj, clone);
22262
+
22263
+ // 5. 递归拷贝属性
22264
+ for (const key in obj) {
22265
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
22266
+ // 递归调用自身,对子属性进行深拷贝和转换
22267
+ clone[key] = deepCloneAndMap(obj[key], valueMapper, cache);
22268
+ }
22269
+ }
22270
+
22271
+ // 6. 拷贝 Symbol 属性
22272
+ if (typeof Object.getOwnPropertySymbols === 'function') {
22273
+ Object.getOwnPropertySymbols(obj).forEach(sym => {
22274
+ // 递归调用自身,对 Symbol 属性的值进行深拷贝和转换
22275
+ clone[sym] = deepCloneAndMap(obj[sym], valueMapper, cache);
22276
+ });
22277
+ }
22278
+
22279
+ // 7. 返回深度克隆并转换后的对象/数组
22280
+ return clone;
22281
+ }
22282
+
22283
+ /**
22284
+ * 健壮的数据类型判断函数
22285
+ *
22286
+ * @param {any} value 需要判断类型的值
22287
+ * @returns {string} 小写的类型字符串,例如:'string', 'number', 'array', 'function', 'object', 'null', 'undefined'
22288
+ */
22289
+ function typeOfValue(value) {
22290
+ // 1. 处理基本类型值(typeof 准确的部分)
22291
+ const type = typeof value;
22292
+
22293
+ // 'string', 'number', 'boolean', 'symbol', 'bigint', 'function', 'undefined'
22294
+ if (type !== 'object') {
22295
+ return type;
22296
+ }
22297
+
22298
+ // 2. 处理 null (typeof 的缺陷:typeof null === 'object')
22299
+ if (value === null) {
22300
+ return 'null';
22301
+ }
22302
+
22303
+ // 3. 处理对象类型值 (使用 Object.prototype.toString.call() 获取内部 [[Class]] 属性)
22304
+ // 结果格式为:[object Class]
22305
+ const classString = Object.prototype.toString.call(value);
22306
+
22307
+ // 提取 'Array', 'Date', 'RegExp', 'Map', 'Set', 'Object' 等 Class 名称
22308
+ const className = classString.slice(8, -1);
22309
+
22310
+ // 4. 特殊处理 Array.isArray()
22311
+ // 虽然 className 已经是 'Array',但 Array.isArray 更快且明确
22312
+ if (className === 'Array') {
22313
+ return 'array';
22314
+ }
22315
+
22316
+ // 5. 将其他内置对象和普通对象名称转为小写返回
22317
+ return className.toLowerCase();
22318
+ }
22319
+
22320
+ /**
22321
+ * 判断一个字符串是否是有效的 JSON 格式
22322
+ *
22323
+ * @param {string} strValue - 要检查的字符串值
22324
+ * @returns {boolean} 如果字符串是有效的 JSON 格式则返回 true,否则返回 false
22325
+ */
22326
+ function isJsonString(strValue) {
22327
+ // 1. 确保输入是一个字符串,如果不是,则直接返回 false
22328
+ // JSON 格式只能是字符串
22329
+ if (typeof strValue !== 'string') {
22330
+ return false;
22331
+ }
22332
+
22333
+ // 2. 尝试解析字符串
22334
+ try {
22335
+ // 使用 JSON.parse() 尝试解析。
22336
+ // 如果解析成功,它就会返回解析后的对象或值。
22337
+ // 如果解析失败,就会抛出 SyntaxError 错误。
22338
+ JSON.parse(strValue);
22339
+
22340
+ // 3. 额外的检查 (可选但推荐):
22341
+ // 确保解析结果不是原始类型值,例如 "123" 或 "true"
22342
+ // 某些场景下,用户希望 JSON 字符串必须是对象或数组的字符串表示
22343
+ // const parsed = JSON.parse(strValue);
22344
+ // if (typeof parsed !== 'object' || parsed === null) {
22345
+ // // 如果你想排除 "123", "null", "true" 这些原始值的 JSON 字符串,可以取消注释
22346
+ // // return false;
22347
+ // }
22348
+
22349
+ } catch (e) {
22350
+ // 捕获任何解析错误(通常是 SyntaxError),表示格式不符合 JSON 规范
22351
+ return false;
22352
+ }
22353
+
22354
+ // 4. 解析成功,返回 true
22355
+ return true;
22356
+ }
22357
+
22358
+ /**
22359
+ * 遍历树形结构(对象或数组)的所有叶节点,将叶节点的值收集到数组中。
22360
+ *
22361
+ * 叶节点被定义为:值不是普通对象或数组的节点。
22362
+ *
22363
+ * @param {object|Array} tree - 要扁平化处理的树形结构对象或数组。
22364
+ * @param {Array<any>} [result=[]] - 存储叶节点值的数组(递归内部使用)。
22365
+ * @returns {Array<any>} 包含所有叶节点值的数组。
22366
+ */
22367
+ function flattenTreeValues(tree, result = []) {
22368
+ // 确保输入是对象或数组。如果不是,或者为 null,则直接返回结果数组。
22369
+ if (typeof tree !== 'object' || tree === null) {
22370
+ return result;
22371
+ }
22372
+
22373
+ // 遍历对象的键(如果是数组,键就是索引)
22374
+ for (const key in tree) {
22375
+ // 确保只处理对象自身的属性,排除原型链上的属性
22376
+ if (Object.prototype.hasOwnProperty.call(tree, key)) {
22377
+ const value = tree[key];
22378
+
22379
+ // 判断当前值是否为“叶节点”
22380
+ // 检查:值不是对象,且值不是 null
22381
+ if (typeof value !== 'object' || value === null) {
22382
+ // 1. 如果是基本类型值(叶节点),则将其压入结果数组
22383
+ result.push(value);
22384
+ } else {
22385
+ // 2. 如果是对象或数组(非叶节点),则进行递归调用
22386
+ // 注意:这里没有处理 Date, RegExp, Set, Map 等特殊对象,
22387
+ // 默认将它们视为非叶节点,直到它们内部的值被遍历完(这通常是不对的)
22388
+ //
22389
+ // 为了更精确地实现“叶节点”概念,我们将 Date, RegExp 等内置对象视为叶节点:
22390
+ const isArray = Array.isArray(value);
22391
+ const isPlainObject = !isArray && Object.prototype.toString.call(value) === '[object Object]';
22392
+
22393
+ if (isArray || isPlainObject) {
22394
+ // 如果是普通数组或普通对象,则递归
22395
+ flattenTreeValues(value, result);
22396
+ } else {
22397
+ // 如果是像 Date, RegExp, Map, Set 等特殊内置对象,
22398
+ // 我们将其视为叶节点的值(而不是继续遍历其内部结构)
22399
+ result.push(value);
22400
+ }
22401
+ }
22402
+ }
22403
+ }
22404
+
22405
+ return result;
22406
+ }
22407
+
22408
+ /**
22409
+ * 将扁平化的对象数组转换为树形结构数据,并在每个节点中保留原始数据。
22410
+ *
22411
+ * @param {Object[]} flatArray 待转化的扁平数组。
22412
+ * @param {Object} inputFields 描述输入数组中字段名的对象。
22413
+ * @param {string} inputFields.idField 节点代码字段名。
22414
+ * @param {string} inputFields.textField 节点文本字段名。
22415
+ * @param {string} inputFields.parentField 父节点代码字段名。
22416
+ * @param {Object} outputFields 描述输出树形结构中字段名的对象。
22417
+ * @param {string} outputFields.idField 输出节点代码字段名 (接收 inputFields.idField 的值)。
22418
+ * @param {string} outputFields.textField 输出节点文本字段名 (接收 inputFields.textField 的值)。
22419
+ * @param {string} outputFields.childrenField 子节点数组字段名。
22420
+ * @param {string} outputFields.originDataField 原始数据字段名 (用于存储原始的 item 对象)。
22421
+ * @returns {Object[]} 转换后的树形结构数组。
22422
+ */
22423
+ function arrayToTree(flatArray, inputFields, outputFields) {
22424
+ // 1. 参数校验和字段提取
22425
+ if (!Array.isArray(flatArray) || flatArray.length === 0) {
22426
+ return [];
22427
+ }
22428
+
22429
+ // 提取输入字段名
22430
+ const {
22431
+ idField: inputId,
22432
+ textField: inputText,
22433
+ parentField: inputParent
22434
+ } = inputFields;
22435
+
22436
+ // 提取输出字段名
22437
+ const {
22438
+ idField: outputId,
22439
+ textField: outputText,
22440
+ childrenField: outputChildren,
22441
+ originDataField: outputRawData // 新增:用于存储原始数据的字段名
22442
+ } = outputFields;
22443
+
22444
+ // 2. 初始化辅助数据结构
22445
+ const tree = [];
22446
+ const childrenMap = new Map(); // 存储所有节点,键为节点ID
22447
+ const rootCandidates = new Set(); // 存储所有可能的根节点ID
22448
+
22449
+ // 3. 第一次遍历:创建所有节点并建立 ID-Node 映射
22450
+ for (const item of flatArray) {
22451
+ // 关键:创建一个只包含转换后字段和子节点的结构
22452
+ const newNode = {
22453
+ // 映射输入字段到输出字段
22454
+ [outputId]: item[inputId],
22455
+ [outputText]: item[inputText],
22456
+ [outputChildren]: [], // 初始化子节点数组
22457
+ [outputRawData]: item // 新增:存储原始数据对象
22458
+ };
22459
+
22460
+ childrenMap.set(newNode[outputId], newNode);
22461
+ rootCandidates.add(newNode[outputId]); // 假设所有节点都是根节点
22462
+ }
22463
+
22464
+ // 4. 第二次遍历:连接父子关系
22465
+ for (const node of childrenMap.values()) {
22466
+ const parentId = node[outputRawData][inputParent]; // 从原始数据中获取父ID
22467
+
22468
+ // 查找父节点
22469
+ const parentNode = childrenMap.get(parentId);
22470
+
22471
+ if (parentNode) {
22472
+ // 如果找到了父节点,则将当前节点添加到父节点的子节点列表中
22473
+ parentNode[outputChildren].push(node);
22474
+
22475
+ // 如果当前节点有父节点,它就不是根节点,从根节点候选中移除
22476
+ rootCandidates.delete(node[outputId]);
22477
+ }
22478
+ }
22479
+
22480
+ // 5. 组装最终树结构
22481
+ // 最终的树结构由所有仍在 rootCandidates 列表中的节点组成
22482
+ for (const rootId of rootCandidates) {
22483
+ const rootNode = childrenMap.get(rootId);
22484
+ if (rootNode) {
22485
+ tree.push(rootNode);
22486
+ }
22487
+ }
22488
+
22489
+ return tree;
22490
+ }
22491
+
22492
+ /**
22493
+ * 在树形对象中查找指定名称的叶子节点值
22494
+ * @param {Object} tree - 被查找的对象(树形结构)
22495
+ * @param {String} leafName - 要查找的属性名称
22496
+ * @returns {any} - 查找到的叶节点内容,未找到返回 undefined
22497
+ */
22498
+ function getLeafValue(tree, leafName) {
22499
+ // 边界检查:如果 tree 不是对象或者是 null,无法查找
22500
+ if (typeof tree !== 'object' || tree === null) {
22501
+ return undefined;
22502
+ }
22503
+
22504
+ // 遍历当前层级的键
22505
+ for (const key in tree) {
22506
+ const value = tree[key];
22507
+
22508
+ // 判断当前值是否为“结构节点”(即中间节点:非数组的非空对象)
22509
+ // 这里假设数组是数据(叶子),普通对象是结构(中间节点)
22510
+ const isStructuralNode = typeof value === 'object' && value !== null && !Array.isArray(value);
22511
+
22512
+ // 1. 如果 key 匹配
22513
+ if (key === leafName) {
22514
+ // 且它不是中间节点(即它是叶子节点),则直接返回
22515
+ if (!isStructuralNode) {
22516
+ return value;
22517
+ }
22518
+ // 如果 key 匹配但是它是中间节点(Object),根据要求“不包括中间节点”,
22519
+ // 我们不返回它,而是继续在这个对象内部递归查找(进入下方的递归逻辑)
22520
+ }
22521
+
22522
+ // 2. 如果当前值是对象(中间节点),则递归查找
22523
+ if (isStructuralNode) {
22524
+ const result = getLeafValue(value, leafName);
22525
+ // 如果在深层找到了结果,直接返回(冒泡上来)
22526
+ if (result !== undefined) {
22527
+ return result;
22528
+ }
22529
+ }
22530
+ }
22531
+
22532
+ return undefined; // 遍历完未找到
22533
+ }
22534
+
22535
+ /**
22536
+ * 在树形对象中查找任意指定名称的节点(包含中间节点和叶子节点)
22537
+ * @param {Object} tree - 被查找的对象
22538
+ * @param {String} nodeName - 要查找的属性名称
22539
+ * @returns {any} - 查找到的节点内容(可能是值,也可能是对象),未找到返回 undefined
22540
+ */
22541
+ function getNodeValue(tree, nodeName) {
22542
+ // 边界检查
22543
+ if (typeof tree !== 'object' || tree === null) {
22544
+ return undefined;
22545
+ }
22546
+
22547
+ // 1. 优先检查当前层级是否存在该 key (广度优先视角的微调,可选)
22548
+ // 如果你希望优先匹配当前层级,而不是先钻入第一个子对象里找,可以取消下面这行的注释:
22549
+ // if (tree.hasOwnProperty(nodeName)) return tree[nodeName];
22550
+
22551
+ // 遍历当前对象
22552
+ for (const key in tree) {
22553
+ const value = tree[key];
22554
+
22555
+ // 1. 只要 Key 匹配,立刻返回 Value
22556
+ // 无论 value 是字符串、数字、还是另一个对象,都视为找到了
22557
+ if (key === nodeName) {
22558
+ return value;
22559
+ }
22560
+
22561
+ // 2. 如果不匹配,且 value 是对象(具备子结构),则递归查找
22562
+ // 注意:这里通常建议排除数组,除非你确定数组里也包含带 key 的对象
22563
+ if (typeof value === 'object' && value !== null) {
22564
+ const result = getNodeValue(value, nodeName);
22565
+ if (result !== undefined) {
22566
+ return result;
22567
+ }
22568
+ }
22569
+ }
22570
+
22571
+ return undefined;
22572
+ }
22573
+
22574
+ /**
22575
+ * 深度非侵入式合并函数 (Deep Non-Destructive Merge)
22576
+ * * 特点:
22577
+ * 1. 深度递归地合并对象属性。
22578
+ * 2. 源对象中缺失的属性不会删除或覆盖目标对象中已存在的对应属性。
22579
+ * 3. 数组会被源对象中的数组完全覆盖。
22580
+ * * @param {Object} target 目标对象(将被修改)
22581
+ * @param {Object} source 源对象
22582
+ * @returns {Object} 修改后的目标对象
22583
+ */
22584
+ function deepMerge(target, source) {
22585
+ // 确保源对象是一个有效的对象,如果不是则直接返回目标对象
22586
+ if (typeof source !== 'object' || source === null) {
22587
+ return target;
22588
+ }
22589
+
22590
+ for (const key in source) {
22591
+ // 确保只处理源对象自身的属性
22592
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
22593
+ const sourceValue = source[key];
22594
+ const targetValue = target[key];
22595
+
22596
+ // 1. 如果源属性的值是对象且目标属性的值也是对象,则递归合并
22597
+ if (
22598
+ typeof sourceValue === 'object' && sourceValue !== null &&
22599
+ !Array.isArray(sourceValue) &&
22600
+ typeof targetValue === 'object' && targetValue !== null &&
22601
+ !Array.isArray(targetValue)
22602
+ ) {
22603
+ // 递归调用自身进行深度合并
22604
+ target[key] = deepMerge(targetValue, sourceValue);
22605
+ }
22606
+ // 2. 对于其他类型(基本类型、数组、null),直接覆盖
22607
+ else {
22608
+ // 这里的关键是:只有源对象中存在的属性,才会覆盖目标对象的属性。
22609
+ // 如果源对象中不存在某个键(key),则不会进入此循环,
22610
+ // 从而目标对象中已有的该属性得以保留。
22611
+ target[key] = sourceValue;
22612
+ }
22613
+ }
22614
+ }
22615
+
22616
+ return target;
22617
+ }
22618
+ var deepClone = {
22619
+ deepClone: deepClone$1,
22620
+ deepCloneAndMap,
22621
+ typeOfValue,
22622
+ isJsonString,
22623
+ flattenTreeValues,
22624
+ arrayToTree,
22625
+ getLeafValue,
22626
+ getNodeValue,
22627
+ deepMerge
22628
+ };
22629
+
22630
+ var unclassified = {
22631
+ deepClone};
22632
+
22633
+ // with-table数据模板
22634
+
22635
+ const ly0default$4 = {
22636
+ pageSize: 10
22637
+ };
22638
+
22639
+ // 数据刷新
22640
+ const refresh = async _ref => {
22641
+ let {
22642
+ scopeThis
22643
+ } = _ref;
22644
+ const result = await ly0request$1.ly0.storpro({
22645
+ storproName: scopeThis.storpro.refresh,
22646
+ data: {
22647
+ query: scopeThis.query && scopeThis.query.formData ? scopeThis.query.formData : null,
22648
+ sort: scopeThis.query && scopeThis.query.sort ? scopeThis.query.sort : null,
22649
+ limit: scopeThis.query && scopeThis.query.pageSize ? scopeThis.query.pageSize : ly0default$4.pageSize,
22650
+ page: scopeThis.query && scopeThis.query.currentPage ? scopeThis.query.currentPage : 1
22651
+ }
22652
+ });
22653
+ if (result.code === 0) {
22654
+ scopeThis.tableData = {
22655
+ data: result.data,
22656
+ total: result.total
22657
+ };
22658
+ }
22659
+ return {
22660
+ code: result.code,
22661
+ message: result.message
22662
+ };
22663
+ };
22664
+
22665
+ // 数据重载
22666
+ const reload = async _ref2 => {
22667
+ let {
22668
+ scopeThis
22669
+ } = _ref2;
22670
+ scopeThis.query = scopeThis.queryInit ? unclassified.deepClone.deepClone(scopeThis.queryInit) : null;
22671
+ const result = await refresh({
22672
+ scopeThis
22673
+ });
22674
+ elementPlus.ElMessage(result.code === 0 ? '数据已重载' : '数据重载错误');
22675
+ };
22676
+
22677
+ // 获取页面数据附加
22678
+ const getPgData = async _ref3 => {
22679
+ let {
22680
+ scopeThis
22681
+ } = _ref3;
22682
+ const result = await ly0request$1.ly0.storpro({
22683
+ storproName: scopeThis.storpro.getPgData,
22684
+ data: scopeThis.pgData && scopeThis.pgData.query ? scopeThis.pgData.query : null
22685
+ });
22686
+ if (result.code === 0) {
22687
+ scopeThis.pgData = unclassified.deepClone.deepMerge(scopeThis.pgData, {
22688
+ data: result.data
22689
+ });
22690
+ elementPlus.ElMessage('已获取页面数据');
22691
+ return;
22692
+ }
22693
+ elementPlus.ElMessage('获取页面数据错误');
22694
+ };
22695
+
22696
+ // 初始化
22697
+ const init = async _ref4 => {
22698
+ let {
22699
+ scopeThis
22700
+ } = _ref4;
22701
+ if (scopeThis.pgData) {
22702
+ await getPgData({
22703
+ scopeThis
22704
+ });
22705
+ }
22706
+ await reload({
22707
+ scopeThis
22708
+ });
22709
+ };
22710
+
22711
+ // 弹出 - 查询
22712
+ const popupFind = async _ref5 => {
22713
+ let {
22714
+ scopeThis
22715
+ } = _ref5;
22716
+ scopeThis.formData = scopeThis.query && scopeThis.query.formData ? unclassified.deepClone.deepClone(scopeThis.query.formData) : null;
22717
+ scopeThis.TableProps.query.sort = scopeThis.query && scopeThis.query.sort ? JSON.parse(JSON.stringify(scopeThis.query.sort)) : null;
22718
+ scopeThis.TableProps.query.pageSize = scopeThis.query && scopeThis.query.pageSize ? scopeThis.query.pageSize : ly0default$4.pageSize;
22719
+ scopeThis.TableProps.query.currentPage = scopeThis.query && scopeThis.query.currentPage ? scopeThis.query.currentPage : 1;
22720
+ scopeThis.formProps = unclassified.deepClone.deepClone(scopeThis.find.formProps);
22721
+ // 弹出窗口
22722
+ scopeThis.formProps.popup = unclassified.deepClone.deepMerge(scopeThis.formProps.popup, {
22723
+ visible: true
22724
+ });
22725
+ };
22726
+
22727
+ // 弹出 - 新增一条记录
22728
+ const popupInsertOne = async _ref6 => {
22729
+ let {
22730
+ scopeThis
22731
+ } = _ref6;
22732
+ scopeThis.formData = unclassified.deepClone.deepClone(scopeThis.insertOne.formData);
22733
+ scopeThis.formProps = unclassified.deepClone.deepClone(scopeThis.insertOne.formProps);
22734
+ // 弹出窗口
22735
+ scopeThis.formProps.popup = unclassified.deepClone.deepMerge(scopeThis.formProps.popup, {
22736
+ visible: true
22737
+ });
22738
+ };
22739
+
22740
+ // 弹出 - 修改一条记录
22741
+ const popupUpdateOne = async _ref7 => {
22742
+ let {
22743
+ scopeThis,
22744
+ formData
22745
+ } = _ref7;
22746
+ scopeThis.formData = unclassified.deepClone.deepClone(formData); // 继承行记录的值
22747
+ scopeThis.formProps = unclassified.deepClone.deepClone(scopeThis.UpdateOne.formProps);
22748
+ // 弹出窗口
22749
+ scopeThis.formProps.popup = unclassified.deepClone.deepMerge(scopeThis.formProps.popup, {
22750
+ visible: true
22751
+ });
22752
+ };
22753
+
22754
+ // 弹出 - 详细信息
22755
+ const popupDoc = async _ref8 => {
22756
+ let {
22757
+ scopeThis,
22758
+ formData
22759
+ } = _ref8;
22760
+ scopeThis.formData = unclassified.deepClone.deepClone(formData); // 继承行记录的值
22761
+ scopeThis.formProps = unclassified.deepClone.deepClone(scopeThis.doc.formProps);
22762
+ // 弹出窗口
22763
+ scopeThis.formProps.popup = unclassified.deepClone.deepMerge(scopeThis.formProps.popup, {
22764
+ visible: true
22765
+ });
22766
+ };
22767
+
22768
+ // 提交 - 查询
22769
+ const submitFind = async _ref9 => {
22770
+ let {
22771
+ scopeThis
22772
+ } = _ref9;
22773
+ scopeThis.query.formData = scopeThis.formData ? unclassified.deepClone.deepClone(scopeThis.formData) : null;
22774
+ scopeThis.query.sort = scopeThis.tableProps.query && scopeThis.tableProps.query.sort ? JSON.parse(JSON.stringify(scopeThis.tableProps.query.sort)) : null;
22775
+ scopeThis.query.pageSize = scopeThis.tableProps.query && scopeThis.tableProps.query.pageSize ? scopeThis.tableProps.query.pageSize : ly0default$4.pageSize;
22776
+ scopeThis.query.currentPage = scopeThis.tableProps.query && scopeThis.tableProps.query.currentPage ? scopeThis.tableProps.query.currentPage : 1;
22777
+ const result = await refresh({
22778
+ scopeThis
22779
+ });
22780
+ if (result.code === 0) {
22781
+ // 关闭表单窗口
22782
+ scopeThis.formProps.popup.visible = false;
22783
+ elementPlus.ElMessage('查询已提交并刷新数据');
22784
+ } else {
22785
+ elementPlus.ElMessage('查询错误');
22786
+ }
22787
+ };
22788
+
22789
+ // 提交 - 新增一条记录
22790
+ const submitInsertOne = async _ref0 => {
22791
+ let {
22792
+ scopeThis
22793
+ } = _ref0;
22794
+ try {
22795
+ await elementPlus.ElMessageBox.confirm('新增一条记录, 提交?', '提示', {
22796
+ confirmButtonText: '确认',
22797
+ cancelButtonText: '取消',
22798
+ type: 'warning' // 警告图标
22799
+ });
22800
+ const result = await ly0request$1.ly0.storpro({
22801
+ storproName: scopeThis.storpro.insertOne,
22802
+ data: scopeThis.formData
22803
+ });
22804
+ if (result.code === 0) {
22805
+ // 关闭表单窗口
22806
+ scopeThis.formProps.popup.visible = false;
22807
+ elementPlus.ElMessage('新增一条记录成功');
22808
+ scopeThis.query.currentPage = 1;
22809
+ scopeThis.tableData = {
22810
+ data: result.dataNew,
22811
+ total: 1
22812
+ };
22813
+ } else {
22814
+ elementPlus.ElMessage('新增一条记录失败');
22815
+ }
22816
+ } catch (error) {
22817
+ elementPlus.ElMessage('已取消');
22818
+ }
22819
+ };
22820
+
22821
+ // 提交 - 修改一条记录
22822
+ const submitUpdateOne = async _ref1 => {
22823
+ let {
22824
+ scopeThis
22825
+ } = _ref1;
22826
+ try {
22827
+ await elementPlus.ElMessageBox.confirm('修改一条记录, 提交?', '提示', {
22828
+ confirmButtonText: '确认',
22829
+ cancelButtonText: '取消',
22830
+ type: 'warning' // 警告图标
22831
+ });
22832
+ const result = await ly0request$1.ly0.storpro({
22833
+ storproName: scopeThis.storpro.updateOne,
22834
+ data: scopeThis.formData
22835
+ });
22836
+ if (result.code === 0) {
22837
+ // 关闭表单窗口
22838
+ scopeThis.formProps.popup.visible = false;
22839
+ elementPlus.ElMessage('修改一条记录成功');
22840
+ const resultRefresh = await refresh({
22841
+ scopeThis
22842
+ });
22843
+ if (resultRefresh.code === 0) {
22844
+ elementPlus.ElMessage('已刷新数据');
22845
+ } else {
22846
+ elementPlus.ElMessage('刷新错误');
22847
+ }
22848
+ } else {
22849
+ elementPlus.ElMessage('修改一条记录失败');
22850
+ }
22851
+ } catch (error) {
22852
+ elementPlus.ElMessage('已取消');
22853
+ }
22854
+ };
22855
+
22856
+ // 提交 - 删除一条记录
22857
+ const submitDeleteOne = async _ref10 => {
22858
+ let {
22859
+ scopeThis,
22860
+ formData
22861
+ } = _ref10;
22862
+ try {
22863
+ await elementPlus.ElMessageBox.confirm('删除一条记录, 提交?', '警告', {
22864
+ confirmButtonText: '确认',
22865
+ cancelButtonText: '取消',
22866
+ type: 'warning' // 警告图标
22867
+ });
22868
+ const result = await ly0request$1.ly0.storpro({
22869
+ storproName: scopeThis.storpro.deleteOne,
22870
+ data: formData // 继承行记录的值
22871
+ });
22872
+ if (result.code === 0) {
22873
+ elementPlus.ElMessage('删除一条记录成功');
22874
+ const resultRefresh = await refresh({
22875
+ scopeThis
22876
+ });
22877
+ if (resultRefresh.code === 0) {
22878
+ elementPlus.ElMessage('已刷新数据');
22879
+ } else {
22880
+ elementPlus.ElMessage('刷新错误');
22881
+ }
22882
+ } else {
22883
+ elementPlus.ElMessage('删除一条记录失败');
22884
+ }
22885
+ } catch (error) {
22886
+ elementPlus.ElMessage('已取消');
22887
+ }
22888
+ };
22889
+ var withTable = {
22890
+ refresh,
22891
+ reload,
22892
+ getPgData,
22893
+ init,
22894
+ popupFind,
22895
+ popupInsertOne,
22896
+ popupUpdateOne,
22897
+ popupDoc,
22898
+ submitFind,
22899
+ submitInsertOne,
22900
+ submitUpdateOne,
22901
+ submitDeleteOne
22902
+ };
22903
+
22143
22904
  // 默认值
22144
22905
 
22145
22906
  var ly0default$3 = {
@@ -23578,496 +24339,6 @@ return (_ctx, _cache) => {
23578
24339
 
23579
24340
  script$i.__file = "src/form/Form.vue";
23580
24341
 
23581
- // 引用标准:GB/T 2260
23582
-
23583
- /**
23584
- * 深度拷贝函数
23585
- *
23586
- * @param {any} obj 需要拷贝的对象、数组或基本类型值
23587
- * @param {WeakMap} [cache=new WeakMap()] 用于处理循环引用的缓存
23588
- * @returns {any} 深度拷贝后的新对象/新值
23589
- */
23590
- function deepClone$1(obj, cache = new WeakMap()) {
23591
- // 1. 基本类型值(包括 null)和函数,直接返回
23592
- if (obj === null || typeof obj !== 'object') {
23593
- return obj;
23594
- }
23595
- // 处理函数(尽管技术上函数是对象,但我们通常不克隆它,而是直接引用)
23596
- if (typeof obj === 'function') {
23597
- return obj;
23598
- }
23599
-
23600
- // 2. 检查循环引用
23601
- // 如果缓存中已存在该对象,说明遇到了循环引用,直接返回缓存中的克隆对象
23602
- if (cache.has(obj)) {
23603
- return cache.get(obj);
23604
- }
23605
-
23606
- // 3. 处理特定内置对象(Date 和 RegExp)
23607
- if (obj instanceof Date) {
23608
- return new Date(obj.getTime());
23609
- }
23610
- if (obj instanceof RegExp) {
23611
- // g: global, i: ignoreCase, m: multiline, u: unicode, y: sticky
23612
- const flags = obj.global ? 'g' : ''
23613
- + obj.ignoreCase ? 'i' : ''
23614
- + obj.multiline ? 'm' : ''
23615
- + obj.unicode ? 'u' : ''
23616
- + obj.sticky ? 'y' : '';
23617
- return new RegExp(obj.source, flags);
23618
- }
23619
-
23620
- // 4. 初始化克隆对象
23621
- // 如果是数组,则初始化为空数组;否则初始化为空对象
23622
- const clone = Array.isArray(obj) ? [] : {};
23623
-
23624
- // 将克隆对象放入缓存,以处理接下来的递归调用中可能遇到的循环引用
23625
- cache.set(obj, clone);
23626
-
23627
- // 5. 递归拷贝属性
23628
- for (const key in obj) {
23629
- // 确保只处理对象自身的属性,排除原型链上的属性
23630
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
23631
- clone[key] = deepClone$1(obj[key], cache);
23632
- }
23633
- }
23634
-
23635
- // 6. 拷贝 Symbol 属性 (ES6/ES2015+)
23636
- if (typeof Object.getOwnPropertySymbols === 'function') {
23637
- Object.getOwnPropertySymbols(obj).forEach(sym => {
23638
- clone[sym] = deepClone$1(obj[sym], cache);
23639
- });
23640
- }
23641
-
23642
- return clone;
23643
- }
23644
-
23645
- /**
23646
- * 深度拷贝函数,并在拷贝叶节点值时应用一个转换函数。
23647
- *
23648
- * @param {any} obj - 需要拷贝的对象、数组或基本类型值。
23649
- * @param {function} valueMapper - 接收叶节点值作为参数,并返回新值的转换函数。
23650
- * @param {WeakMap} [cache=new WeakMap()] - 用于处理循环引用的缓存。
23651
- * @returns {any} 深度拷贝并转换后的新对象/新值。
23652
- */
23653
- function deepCloneAndMap(obj, valueMapper, cache = new WeakMap()) {
23654
- // 1. 基本类型值(包括 null)和函数,**应用 valueMapper**
23655
-
23656
- // 如果是基本类型值(包括 null),则认为是叶节点,应用 valueMapper
23657
- if (obj === null || typeof obj !== 'object') {
23658
- // 对基本类型值应用转换函数
23659
- return valueMapper ? valueMapper(obj) : obj;
23660
- }
23661
-
23662
- // 如果是函数,通常我们不克隆它,也不转换它的值,直接返回
23663
- if (typeof obj === 'function') {
23664
- return obj;
23665
- }
23666
-
23667
- // 2. 检查循环引用 (与原函数逻辑相同)
23668
- if (cache.has(obj)) {
23669
- return cache.get(obj);
23670
- }
23671
-
23672
- // 3. 处理特定内置对象(Date 和 RegExp),**应用 valueMapper**
23673
-
23674
- // 对于 Date 和 RegExp 这种对象实例,我们通常将它们的**值**视为叶节点,
23675
- // 克隆实例本身后,再对这个克隆实例应用 valueMapper。
23676
- let clone;
23677
-
23678
- if (obj instanceof Date) {
23679
- clone = new Date(obj.getTime());
23680
- } else if (obj instanceof RegExp) {
23681
- // 提取 flags
23682
- const flags = (obj.global ? 'g' : '')
23683
- + (obj.ignoreCase ? 'i' : '')
23684
- + (obj.multiline ? 'm' : '')
23685
- + (obj.unicode ? 'u' : '')
23686
- + (obj.sticky ? 'y' : '');
23687
- clone = new RegExp(obj.source, flags);
23688
- }
23689
-
23690
- // 检查是否是内置对象(Date/RegExp),如果是,对克隆后的实例应用转换
23691
- if (clone) {
23692
- return valueMapper ? valueMapper(clone) : clone;
23693
- }
23694
-
23695
- // 4. 初始化克隆对象 (普通对象和数组)
23696
- clone = Array.isArray(obj) ? [] : {};
23697
-
23698
- // 将克隆对象放入缓存
23699
- cache.set(obj, clone);
23700
-
23701
- // 5. 递归拷贝属性
23702
- for (const key in obj) {
23703
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
23704
- // 递归调用自身,对子属性进行深拷贝和转换
23705
- clone[key] = deepCloneAndMap(obj[key], valueMapper, cache);
23706
- }
23707
- }
23708
-
23709
- // 6. 拷贝 Symbol 属性
23710
- if (typeof Object.getOwnPropertySymbols === 'function') {
23711
- Object.getOwnPropertySymbols(obj).forEach(sym => {
23712
- // 递归调用自身,对 Symbol 属性的值进行深拷贝和转换
23713
- clone[sym] = deepCloneAndMap(obj[sym], valueMapper, cache);
23714
- });
23715
- }
23716
-
23717
- // 7. 返回深度克隆并转换后的对象/数组
23718
- return clone;
23719
- }
23720
-
23721
- /**
23722
- * 健壮的数据类型判断函数
23723
- *
23724
- * @param {any} value 需要判断类型的值
23725
- * @returns {string} 小写的类型字符串,例如:'string', 'number', 'array', 'function', 'object', 'null', 'undefined'
23726
- */
23727
- function typeOfValue(value) {
23728
- // 1. 处理基本类型值(typeof 准确的部分)
23729
- const type = typeof value;
23730
-
23731
- // 'string', 'number', 'boolean', 'symbol', 'bigint', 'function', 'undefined'
23732
- if (type !== 'object') {
23733
- return type;
23734
- }
23735
-
23736
- // 2. 处理 null (typeof 的缺陷:typeof null === 'object')
23737
- if (value === null) {
23738
- return 'null';
23739
- }
23740
-
23741
- // 3. 处理对象类型值 (使用 Object.prototype.toString.call() 获取内部 [[Class]] 属性)
23742
- // 结果格式为:[object Class]
23743
- const classString = Object.prototype.toString.call(value);
23744
-
23745
- // 提取 'Array', 'Date', 'RegExp', 'Map', 'Set', 'Object' 等 Class 名称
23746
- const className = classString.slice(8, -1);
23747
-
23748
- // 4. 特殊处理 Array.isArray()
23749
- // 虽然 className 已经是 'Array',但 Array.isArray 更快且明确
23750
- if (className === 'Array') {
23751
- return 'array';
23752
- }
23753
-
23754
- // 5. 将其他内置对象和普通对象名称转为小写返回
23755
- return className.toLowerCase();
23756
- }
23757
-
23758
- /**
23759
- * 判断一个字符串是否是有效的 JSON 格式
23760
- *
23761
- * @param {string} strValue - 要检查的字符串值
23762
- * @returns {boolean} 如果字符串是有效的 JSON 格式则返回 true,否则返回 false
23763
- */
23764
- function isJsonString(strValue) {
23765
- // 1. 确保输入是一个字符串,如果不是,则直接返回 false
23766
- // JSON 格式只能是字符串
23767
- if (typeof strValue !== 'string') {
23768
- return false;
23769
- }
23770
-
23771
- // 2. 尝试解析字符串
23772
- try {
23773
- // 使用 JSON.parse() 尝试解析。
23774
- // 如果解析成功,它就会返回解析后的对象或值。
23775
- // 如果解析失败,就会抛出 SyntaxError 错误。
23776
- JSON.parse(strValue);
23777
-
23778
- // 3. 额外的检查 (可选但推荐):
23779
- // 确保解析结果不是原始类型值,例如 "123" 或 "true"
23780
- // 某些场景下,用户希望 JSON 字符串必须是对象或数组的字符串表示
23781
- // const parsed = JSON.parse(strValue);
23782
- // if (typeof parsed !== 'object' || parsed === null) {
23783
- // // 如果你想排除 "123", "null", "true" 这些原始值的 JSON 字符串,可以取消注释
23784
- // // return false;
23785
- // }
23786
-
23787
- } catch (e) {
23788
- // 捕获任何解析错误(通常是 SyntaxError),表示格式不符合 JSON 规范
23789
- return false;
23790
- }
23791
-
23792
- // 4. 解析成功,返回 true
23793
- return true;
23794
- }
23795
-
23796
- /**
23797
- * 遍历树形结构(对象或数组)的所有叶节点,将叶节点的值收集到数组中。
23798
- *
23799
- * 叶节点被定义为:值不是普通对象或数组的节点。
23800
- *
23801
- * @param {object|Array} tree - 要扁平化处理的树形结构对象或数组。
23802
- * @param {Array<any>} [result=[]] - 存储叶节点值的数组(递归内部使用)。
23803
- * @returns {Array<any>} 包含所有叶节点值的数组。
23804
- */
23805
- function flattenTreeValues(tree, result = []) {
23806
- // 确保输入是对象或数组。如果不是,或者为 null,则直接返回结果数组。
23807
- if (typeof tree !== 'object' || tree === null) {
23808
- return result;
23809
- }
23810
-
23811
- // 遍历对象的键(如果是数组,键就是索引)
23812
- for (const key in tree) {
23813
- // 确保只处理对象自身的属性,排除原型链上的属性
23814
- if (Object.prototype.hasOwnProperty.call(tree, key)) {
23815
- const value = tree[key];
23816
-
23817
- // 判断当前值是否为“叶节点”
23818
- // 检查:值不是对象,且值不是 null
23819
- if (typeof value !== 'object' || value === null) {
23820
- // 1. 如果是基本类型值(叶节点),则将其压入结果数组
23821
- result.push(value);
23822
- } else {
23823
- // 2. 如果是对象或数组(非叶节点),则进行递归调用
23824
- // 注意:这里没有处理 Date, RegExp, Set, Map 等特殊对象,
23825
- // 默认将它们视为非叶节点,直到它们内部的值被遍历完(这通常是不对的)
23826
- //
23827
- // 为了更精确地实现“叶节点”概念,我们将 Date, RegExp 等内置对象视为叶节点:
23828
- const isArray = Array.isArray(value);
23829
- const isPlainObject = !isArray && Object.prototype.toString.call(value) === '[object Object]';
23830
-
23831
- if (isArray || isPlainObject) {
23832
- // 如果是普通数组或普通对象,则递归
23833
- flattenTreeValues(value, result);
23834
- } else {
23835
- // 如果是像 Date, RegExp, Map, Set 等特殊内置对象,
23836
- // 我们将其视为叶节点的值(而不是继续遍历其内部结构)
23837
- result.push(value);
23838
- }
23839
- }
23840
- }
23841
- }
23842
-
23843
- return result;
23844
- }
23845
-
23846
- /**
23847
- * 将扁平化的对象数组转换为树形结构数据,并在每个节点中保留原始数据。
23848
- *
23849
- * @param {Object[]} flatArray 待转化的扁平数组。
23850
- * @param {Object} inputFields 描述输入数组中字段名的对象。
23851
- * @param {string} inputFields.idField 节点代码字段名。
23852
- * @param {string} inputFields.textField 节点文本字段名。
23853
- * @param {string} inputFields.parentField 父节点代码字段名。
23854
- * @param {Object} outputFields 描述输出树形结构中字段名的对象。
23855
- * @param {string} outputFields.idField 输出节点代码字段名 (接收 inputFields.idField 的值)。
23856
- * @param {string} outputFields.textField 输出节点文本字段名 (接收 inputFields.textField 的值)。
23857
- * @param {string} outputFields.childrenField 子节点数组字段名。
23858
- * @param {string} outputFields.originDataField 原始数据字段名 (用于存储原始的 item 对象)。
23859
- * @returns {Object[]} 转换后的树形结构数组。
23860
- */
23861
- function arrayToTree(flatArray, inputFields, outputFields) {
23862
- // 1. 参数校验和字段提取
23863
- if (!Array.isArray(flatArray) || flatArray.length === 0) {
23864
- return [];
23865
- }
23866
-
23867
- // 提取输入字段名
23868
- const {
23869
- idField: inputId,
23870
- textField: inputText,
23871
- parentField: inputParent
23872
- } = inputFields;
23873
-
23874
- // 提取输出字段名
23875
- const {
23876
- idField: outputId,
23877
- textField: outputText,
23878
- childrenField: outputChildren,
23879
- originDataField: outputRawData // 新增:用于存储原始数据的字段名
23880
- } = outputFields;
23881
-
23882
- // 2. 初始化辅助数据结构
23883
- const tree = [];
23884
- const childrenMap = new Map(); // 存储所有节点,键为节点ID
23885
- const rootCandidates = new Set(); // 存储所有可能的根节点ID
23886
-
23887
- // 3. 第一次遍历:创建所有节点并建立 ID-Node 映射
23888
- for (const item of flatArray) {
23889
- // 关键:创建一个只包含转换后字段和子节点的结构
23890
- const newNode = {
23891
- // 映射输入字段到输出字段
23892
- [outputId]: item[inputId],
23893
- [outputText]: item[inputText],
23894
- [outputChildren]: [], // 初始化子节点数组
23895
- [outputRawData]: item // 新增:存储原始数据对象
23896
- };
23897
-
23898
- childrenMap.set(newNode[outputId], newNode);
23899
- rootCandidates.add(newNode[outputId]); // 假设所有节点都是根节点
23900
- }
23901
-
23902
- // 4. 第二次遍历:连接父子关系
23903
- for (const node of childrenMap.values()) {
23904
- const parentId = node[outputRawData][inputParent]; // 从原始数据中获取父ID
23905
-
23906
- // 查找父节点
23907
- const parentNode = childrenMap.get(parentId);
23908
-
23909
- if (parentNode) {
23910
- // 如果找到了父节点,则将当前节点添加到父节点的子节点列表中
23911
- parentNode[outputChildren].push(node);
23912
-
23913
- // 如果当前节点有父节点,它就不是根节点,从根节点候选中移除
23914
- rootCandidates.delete(node[outputId]);
23915
- }
23916
- }
23917
-
23918
- // 5. 组装最终树结构
23919
- // 最终的树结构由所有仍在 rootCandidates 列表中的节点组成
23920
- for (const rootId of rootCandidates) {
23921
- const rootNode = childrenMap.get(rootId);
23922
- if (rootNode) {
23923
- tree.push(rootNode);
23924
- }
23925
- }
23926
-
23927
- return tree;
23928
- }
23929
-
23930
- /**
23931
- * 在树形对象中查找指定名称的叶子节点值
23932
- * @param {Object} tree - 被查找的对象(树形结构)
23933
- * @param {String} leafName - 要查找的属性名称
23934
- * @returns {any} - 查找到的叶节点内容,未找到返回 undefined
23935
- */
23936
- function getLeafValue(tree, leafName) {
23937
- // 边界检查:如果 tree 不是对象或者是 null,无法查找
23938
- if (typeof tree !== 'object' || tree === null) {
23939
- return undefined;
23940
- }
23941
-
23942
- // 遍历当前层级的键
23943
- for (const key in tree) {
23944
- const value = tree[key];
23945
-
23946
- // 判断当前值是否为“结构节点”(即中间节点:非数组的非空对象)
23947
- // 这里假设数组是数据(叶子),普通对象是结构(中间节点)
23948
- const isStructuralNode = typeof value === 'object' && value !== null && !Array.isArray(value);
23949
-
23950
- // 1. 如果 key 匹配
23951
- if (key === leafName) {
23952
- // 且它不是中间节点(即它是叶子节点),则直接返回
23953
- if (!isStructuralNode) {
23954
- return value;
23955
- }
23956
- // 如果 key 匹配但是它是中间节点(Object),根据要求“不包括中间节点”,
23957
- // 我们不返回它,而是继续在这个对象内部递归查找(进入下方的递归逻辑)
23958
- }
23959
-
23960
- // 2. 如果当前值是对象(中间节点),则递归查找
23961
- if (isStructuralNode) {
23962
- const result = getLeafValue(value, leafName);
23963
- // 如果在深层找到了结果,直接返回(冒泡上来)
23964
- if (result !== undefined) {
23965
- return result;
23966
- }
23967
- }
23968
- }
23969
-
23970
- return undefined; // 遍历完未找到
23971
- }
23972
-
23973
- /**
23974
- * 在树形对象中查找任意指定名称的节点(包含中间节点和叶子节点)
23975
- * @param {Object} tree - 被查找的对象
23976
- * @param {String} nodeName - 要查找的属性名称
23977
- * @returns {any} - 查找到的节点内容(可能是值,也可能是对象),未找到返回 undefined
23978
- */
23979
- function getNodeValue(tree, nodeName) {
23980
- // 边界检查
23981
- if (typeof tree !== 'object' || tree === null) {
23982
- return undefined;
23983
- }
23984
-
23985
- // 1. 优先检查当前层级是否存在该 key (广度优先视角的微调,可选)
23986
- // 如果你希望优先匹配当前层级,而不是先钻入第一个子对象里找,可以取消下面这行的注释:
23987
- // if (tree.hasOwnProperty(nodeName)) return tree[nodeName];
23988
-
23989
- // 遍历当前对象
23990
- for (const key in tree) {
23991
- const value = tree[key];
23992
-
23993
- // 1. 只要 Key 匹配,立刻返回 Value
23994
- // 无论 value 是字符串、数字、还是另一个对象,都视为找到了
23995
- if (key === nodeName) {
23996
- return value;
23997
- }
23998
-
23999
- // 2. 如果不匹配,且 value 是对象(具备子结构),则递归查找
24000
- // 注意:这里通常建议排除数组,除非你确定数组里也包含带 key 的对象
24001
- if (typeof value === 'object' && value !== null) {
24002
- const result = getNodeValue(value, nodeName);
24003
- if (result !== undefined) {
24004
- return result;
24005
- }
24006
- }
24007
- }
24008
-
24009
- return undefined;
24010
- }
24011
-
24012
- /**
24013
- * 深度非侵入式合并函数 (Deep Non-Destructive Merge)
24014
- * * 特点:
24015
- * 1. 深度递归地合并对象属性。
24016
- * 2. 源对象中缺失的属性不会删除或覆盖目标对象中已存在的对应属性。
24017
- * 3. 数组会被源对象中的数组完全覆盖。
24018
- * * @param {Object} target 目标对象(将被修改)
24019
- * @param {Object} source 源对象
24020
- * @returns {Object} 修改后的目标对象
24021
- */
24022
- function deepMerge(target, source) {
24023
- // 确保源对象是一个有效的对象,如果不是则直接返回目标对象
24024
- if (typeof source !== 'object' || source === null) {
24025
- return target;
24026
- }
24027
-
24028
- for (const key in source) {
24029
- // 确保只处理源对象自身的属性
24030
- if (Object.prototype.hasOwnProperty.call(source, key)) {
24031
- const sourceValue = source[key];
24032
- const targetValue = target[key];
24033
-
24034
- // 1. 如果源属性的值是对象且目标属性的值也是对象,则递归合并
24035
- if (
24036
- typeof sourceValue === 'object' && sourceValue !== null &&
24037
- !Array.isArray(sourceValue) &&
24038
- typeof targetValue === 'object' && targetValue !== null &&
24039
- !Array.isArray(targetValue)
24040
- ) {
24041
- // 递归调用自身进行深度合并
24042
- target[key] = deepMerge(targetValue, sourceValue);
24043
- }
24044
- // 2. 对于其他类型(基本类型、数组、null),直接覆盖
24045
- else {
24046
- // 这里的关键是:只有源对象中存在的属性,才会覆盖目标对象的属性。
24047
- // 如果源对象中不存在某个键(key),则不会进入此循环,
24048
- // 从而目标对象中已有的该属性得以保留。
24049
- target[key] = sourceValue;
24050
- }
24051
- }
24052
- }
24053
-
24054
- return target;
24055
- }
24056
- var deepClone = {
24057
- deepClone: deepClone$1,
24058
- deepCloneAndMap,
24059
- typeOfValue,
24060
- isJsonString,
24061
- flattenTreeValues,
24062
- arrayToTree,
24063
- getLeafValue,
24064
- getNodeValue,
24065
- deepMerge
24066
- };
24067
-
24068
- var unclassified = {
24069
- deepClone};
24070
-
24071
24342
  var script$h = {
24072
24343
  __name: 'index',
24073
24344
  props: {
@@ -45136,7 +45407,8 @@ var index = {
45136
45407
  app.component('ly0d7thumb', script);
45137
45408
  },
45138
45409
  FileSaver: FileSaver$1,
45139
- request
45410
+ request,
45411
+ withTable
45140
45412
  };
45141
45413
 
45142
45414
  exports.FileSaver = FileSaver$1;