ol-base-components 2.8.10 → 2.8.12
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
|
@@ -422,11 +422,16 @@ export default {
|
|
|
422
422
|
type: Boolean,
|
|
423
423
|
default: true,
|
|
424
424
|
},
|
|
425
|
-
//获取swagger后的钩子,返回swagger
|
|
425
|
+
//获取swagger后的钩子,返回swagger结构数据。用于处理swagger数据
|
|
426
426
|
swaggerColumnsProcessor: {
|
|
427
427
|
type: Function,
|
|
428
428
|
default: null,
|
|
429
429
|
},
|
|
430
|
+
// swagger与本地columns合并完成后的钩子,允许父组件二次处理columns,一般用于不影响顺序的属性修改。区别于直接column中添加
|
|
431
|
+
mergedColumnsProcessor: {
|
|
432
|
+
type: Function,
|
|
433
|
+
default: null,
|
|
434
|
+
},
|
|
430
435
|
},
|
|
431
436
|
|
|
432
437
|
data() {
|
|
@@ -522,12 +527,12 @@ export default {
|
|
|
522
527
|
let swaggerColumns =
|
|
523
528
|
swaggerData.paths[this.url].get.responses["200"].content["application/json"].schema
|
|
524
529
|
.properties.items.items.properties;
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
530
|
+
if (typeof this.swaggerColumnsProcessor === "function") {
|
|
531
|
+
try {
|
|
532
|
+
const res = await this.swaggerColumnsProcessor({ swaggerColumns });
|
|
533
|
+
swaggerColumns = res;
|
|
534
|
+
} catch (err) {}
|
|
535
|
+
}
|
|
531
536
|
// 递归映射函数
|
|
532
537
|
const mapSwaggerToColumns = columns => {
|
|
533
538
|
columns.forEach(column => {
|
|
@@ -559,7 +564,7 @@ export default {
|
|
|
559
564
|
// 如果是枚举值直接转成Desc结尾的,swagger中没有Desc但是后端接口会返回带Desc的字段,用于前端展示枚举值的中文
|
|
560
565
|
if (item.enum && Array.isArray(item.enum)) {
|
|
561
566
|
obj.prop = `${key}Desc`;
|
|
562
|
-
obj.label = item.description.replace(
|
|
567
|
+
obj.label = item.description.replace(/(枚举|枚举值)/g, "");
|
|
563
568
|
}
|
|
564
569
|
this.tableData.columns.push(obj);
|
|
565
570
|
}
|
|
@@ -586,6 +591,15 @@ export default {
|
|
|
586
591
|
addShow(this.tableData.columns);
|
|
587
592
|
console.log(`\x1b[36m\x1b[4mol插件-表格`, this.tableData.columns);
|
|
588
593
|
|
|
594
|
+
// 合并完成后,暴露处理钩子
|
|
595
|
+
if (typeof this.mergedColumnsProcessor === "function") {
|
|
596
|
+
try {
|
|
597
|
+
await this.mergedColumnsProcessor({
|
|
598
|
+
columns: this.tableData.columns,
|
|
599
|
+
});
|
|
600
|
+
} catch (e) {}
|
|
601
|
+
}
|
|
602
|
+
|
|
589
603
|
// init 执行完成后,添加深度监听
|
|
590
604
|
this.startColumnsWatching();
|
|
591
605
|
})
|