ol-base-components 2.9.3 → 2.9.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol-base-components",
3
- "version": "2.9.3",
3
+ "version": "2.9.4",
4
4
  "private": false,
5
5
  "main": "src/package/index.js",
6
6
  "bin": {
@@ -188,7 +188,6 @@
188
188
  import { getData } from "../../index.js";
189
189
  import { getEnum } from "../../../utils/getEnum.js";
190
190
  import OlNumberRange from "../../numberRange/index.js";
191
- import { camelCaseToChinese } from "./index.js";
192
191
 
193
192
  export default {
194
193
  name: "search",
@@ -279,7 +278,7 @@ export default {
279
278
  type: Boolean,
280
279
  },
281
280
  //获取swagger后的钩子,返回swagger结构数据。用于处理swagger数据
282
- swaggerColumnsProcessor: {
281
+ onSwagger: {
283
282
  type: Function,
284
283
  default: null,
285
284
  },
@@ -321,10 +320,10 @@ export default {
321
320
  async init() {
322
321
  const swaggerData = await getData();
323
322
  let swaggersearchColumns = swaggerData.paths[this.url].get.parameters || [];
324
- if (typeof this.swaggerColumnsProcessor === "function") {
323
+ if (typeof this.onSwagger === "function") {
325
324
  try {
326
- const res = await this.swaggerColumnsProcessor({ swaggersearchColumns });
327
- swaggersearchColumns = res;
325
+ const res = await this.onSwagger({ columns: swaggersearchColumns });
326
+ if (res) swaggersearchColumns = res;
328
327
  } catch (err) {}
329
328
  }
330
329
  swaggersearchColumns.forEach(item => {
@@ -423,12 +423,12 @@ export default {
423
423
  default: true,
424
424
  },
425
425
  //获取swagger后的钩子,返回swagger结构数据。用于处理swagger数据
426
- swaggerColumnsProcessor: {
426
+ onSwagger: {
427
427
  type: Function,
428
428
  default: null,
429
429
  },
430
430
  // swagger与本地columns合并完成后的钩子,允许父组件二次处理columns,一般用于不影响顺序的属性修改。区别于直接column中添加
431
- mergedColumnsProcessor: {
431
+ onMerged: {
432
432
  type: Function,
433
433
  default: null,
434
434
  },
@@ -484,42 +484,6 @@ export default {
484
484
  this.stopColumnsWatching();
485
485
  },
486
486
  methods: {
487
- // init() {
488
- // // 从 IndexedDB 中获取 Swagger 数据
489
- // getData().then((swaggerData) => {
490
- // const swaggerColumns = swaggerData.paths[this.url].get.responses["200"].content['application/json'].schema.properties.items.items.properties;
491
-
492
- // Object.keys(swaggerColumns).forEach(key => {
493
- // const item = swaggerColumns[key];
494
- // let tempItem = this.tableData.columns.find((e) => e.prop == key);
495
- // if (tempItem) {
496
- // tempItem = { ...item, ...tempItem };
497
- // } else if (item.description) {
498
- // this.tableData.columns.push({
499
- // prop: key,
500
- // label: item.description,
501
- // show: true,
502
- // sortable: false,
503
- // attrs: {}
504
- // });
505
- // }
506
- // });
507
- // console.log(`\x1b[36m\x1b[4mol插件-表格`, this.tableData.columns)
508
- // }).catch((error) => {
509
- // console.error("获取 Swagger 数据失败:", error);
510
- // });
511
- // },
512
- // 支持多级表头 useSlotHeader: true,且支持排序,通过columns中的顺序实现
513
- // columns: [
514
- // {
515
- // label: '一级表头',
516
- // children: [{ prop: 'bindStateEnum', label: '112' }, { prop: 'tagNumber' }]
517
- // },
518
- // {
519
- // prop: "remark",
520
- // label: "备注123",
521
- // },
522
- // ],
523
487
  init() {
524
488
  // 从 IndexedDB 中获取 Swagger 数据
525
489
  getData()
@@ -527,10 +491,10 @@ export default {
527
491
  let swaggerColumns =
528
492
  swaggerData.paths[this.url].get.responses["200"].content["application/json"].schema
529
493
  .properties.items.items.properties;
530
- if (typeof this.swaggerColumnsProcessor === "function") {
494
+ if (typeof this.onSwagger === "function") {
531
495
  try {
532
- const res = await this.swaggerColumnsProcessor({ swaggerColumns });
533
- swaggerColumns = res;
496
+ const res = await this.onSwagger({ columns: swaggerColumns });
497
+ if (res) swaggerColumns = res;
534
498
  } catch (err) {}
535
499
  }
536
500
  // 递归映射函数
@@ -596,11 +560,14 @@ export default {
596
560
  console.log(`\x1b[36m\x1b[4mol插件-表格`, this.tableData.columns);
597
561
 
598
562
  // 合并完成后,暴露处理钩子
599
- if (typeof this.mergedColumnsProcessor === "function") {
563
+ if (typeof this.onMerged === "function") {
600
564
  try {
601
- await this.mergedColumnsProcessor({
565
+ const res = await this.onMerged({
602
566
  columns: this.tableData.columns,
603
567
  });
568
+ if (Array.isArray(res)) {
569
+ this.tableData.columns = res;
570
+ }
604
571
  } catch (e) {}
605
572
  }
606
573