ol-base-components 1.2.3 → 1.2.5

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": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "private": false,
5
5
  "main": "src/package/index.js",
6
6
  "scripts": {
package/src/main.js CHANGED
@@ -2,16 +2,14 @@ import Vue from "vue";
2
2
  import ElementUI from "element-ui";
3
3
  import "element-ui/lib/theme-chalk/index.css";
4
4
  import App from "./App.vue";
5
+ import OlCom from "@/package/index.js";
5
6
 
6
- // import olCom, { SwaggerHandler } from "@/package/index.js";
7
-
8
- // Vue.use(olCom);
9
- // SwaggerHandler(Vue)
10
- // Vue.config.productionTip = false;
11
7
  Vue.use(ElementUI);
12
8
 
13
- setTimeout(() => {
14
- new Vue({
15
- render: (h) => h(App),
16
- }).$mount("#app");
17
- }, 20000);
9
+ Vue.use(OlCom, {
10
+ swaggerUrl: "http://220.179.249.140:20019/swagger/v1/swagger.json",
11
+ });
12
+
13
+ new Vue({
14
+ render: (h) => h(App),
15
+ }).$mount("#app");
@@ -32,26 +32,25 @@ export const SwaggerHandler = async (Vue, swaggerUrl) => {
32
32
 
33
33
  const components = [OlTable, OlSearch, Dialog];
34
34
 
35
- const install = function (
35
+ const install = async function (
36
36
  Vue,
37
37
  options = {
38
38
  swaggerUrl: "",
39
39
  }
40
40
  ) {
41
- if (options && options.swaggerUrl) {
42
- // "http://220.179.249.140:20019/swagger/v1/swagger.json"
43
- const client = new SwaggerClient(options.swaggerUrl);
44
- Vue.prototype.$swagger = { specification: client.spec };
45
- }
46
41
  // 遍历所有组件
47
42
  components.map((item) => {
48
43
  Vue.component(`ol-${item.name}`, item);
49
44
  });
50
45
 
46
+ if (options && options.swaggerUrl) {
47
+ // "http://220.179.249.140:20019/swagger/v1/swagger.json"
48
+ const client = await SwaggerClient(options.swaggerUrl);
49
+ Vue.prototype.$swagger = { specification: client.spec };
50
+ }
51
51
  consoleTooltip();
52
52
  };
53
53
 
54
54
  // 判断是否引入文件
55
55
  export default install; //全局导入
56
56
  export { OlTable, OlSearch, Dialog }; //按需导入
57
- // export { Swagger };
@@ -340,6 +340,10 @@ export default {
340
340
  default: true,
341
341
  },
342
342
  },
343
+ created() {
344
+ // 通过swagger完善columns
345
+ this.init()
346
+ },
343
347
  data() {
344
348
  return {
345
349
  nodata,
@@ -354,49 +358,78 @@ export default {
354
358
  },
355
359
  computed: {
356
360
  bindTableColumns() {
357
- // 读取接口和类型获取表头数据
358
- if (!this.$swagger) return this.tableData.columns.filter((column) =>
361
+ return this.tableData.columns.filter((column) =>
359
362
  Object.keys(column).includes("show") ? column.show : true
360
363
  );
361
- const tableColumns = this.$swagger.specification.paths[this.url].get.responses["200"].content['application/json'].schema.properties.items.items.properties
362
- let swaggerColumns = Object.keys(tableColumns).reduce((acc, key) => {
363
- const column = tableColumns[key];
364
- if (column.description) {
365
- acc.push({
366
- prop: key,
367
- label: column.description,
368
- minWidth: column.minWidth || "150px",
369
- sortable: true,
370
- show: true,
371
- attrs: {},
372
- })
373
- }
374
- return acc;
375
- }, []);
376
364
 
377
- this.tableData.columns.filter((column) =>
378
- Object.keys(column).includes("show") ? column.show : true
379
- );
365
+ // const swaggerColumns = this.$swagger.specification.paths[this.url].get.responses["200"].content['application/json'].schema.properties.items.items.properties
366
+ // swaggerColumns.forEach(item => {
367
+ // const tempItem = this.tableData.columns.find((e) => e.prop == item.prop)
368
+ // tempItem ? tempItem = { ...item, ...tempItem } : this.tableData.columns.push(item)
369
+ // })
380
370
 
381
- this.tableData.columns.forEach(dataColumn => {
382
- const tempIndex = swaggerColumns.findIndex((item) => item.prop == dataColumn.prop)
383
- if (tempIndex == -1) {
384
- swaggerColumns.push(dataColumn)
385
- } else {
386
- Object.assign(swaggerColumns[tempIndex], dataColumn)
387
- }
388
- })
371
+ // // 一定加上selection,通过show显示隐藏
372
+ // const itemSelection = this.tableData.columns.find((item) => item.type == "selection");
373
+ // const hasSelection = this.tableData.options.selection;
374
+ // if (itemSelection) {
375
+ // itemSelection.show = !!hasSelection;
376
+ // } else {
377
+ // this.tableData.columns.unshift({
378
+ // label: "",
379
+ // minWidth: "",
380
+ // type: "selection",
381
+ // show: !!hasSelection,
382
+ // });
383
+ // }
389
384
 
390
- // 如果options.selection有多选框直接加
391
- swaggerColumns.unshift({
392
- label: "",
393
- minWidth: "",
394
- type: "selection",
395
- show: true,
396
- });
397
- console.log('表头数据', swaggerColumns)
398
- return swaggerColumns
385
+ // return this.tableData.columns.filter((column) =>
386
+ // Object.keys(column).includes("show") ? column.show : true
387
+ // );
399
388
  },
389
+ // bindTableColumns1() {
390
+ // // 读取接口和类型获取表头数据
391
+ // if (!this.$swagger) return this.tableData.columns.filter((column) =>
392
+ // Object.keys(column).includes("show") ? column.show : true
393
+ // );
394
+ // const tableColumns = this.$swagger.specification.paths[this.url].get.responses["200"].content['application/json'].schema.properties.items.items.properties
395
+ // let swaggerColumns = Object.keys(tableColumns).reduce((acc, key) => {
396
+ // const column = tableColumns[key];
397
+ // if (column.description) {
398
+ // acc.push({
399
+ // prop: key,
400
+ // label: column.description,
401
+ // minWidth: column.minWidth || "150px",
402
+ // sortable: true,
403
+ // show: true,
404
+ // attrs: {},
405
+ // })
406
+ // }
407
+ // return acc;
408
+ // }, []);
409
+
410
+ // this.tableData.columns.filter((column) =>
411
+ // Object.keys(column).includes("show") ? column.show : true
412
+ // );
413
+
414
+ // this.tableData.columns.forEach(dataColumn => {
415
+ // const tempIndex = swaggerColumns.findIndex((item) => item.prop == dataColumn.prop)
416
+ // if (tempIndex == -1) {
417
+ // swaggerColumns.push(dataColumn)
418
+ // } else {
419
+ // Object.assign(swaggerColumns[tempIndex], dataColumn)
420
+ // }
421
+ // })
422
+
423
+ // // 如果options.selection有多选框直接加
424
+ // swaggerColumns.unshift({
425
+ // label: "",
426
+ // minWidth: "",
427
+ // type: "selection",
428
+ // show: true,
429
+ // });
430
+ // console.log('表头数据', swaggerColumns)
431
+ // return swaggerColumns
432
+ // },
400
433
  checkedTableList: {
401
434
  get() {
402
435
  // 返回选中的列名
@@ -436,6 +469,27 @@ export default {
436
469
  },
437
470
  },
438
471
  methods: {
472
+ init() {
473
+ const swaggerColumns = this.$swagger.specification.paths[this.url].get.responses["200"].content['application/json'].schema.properties.items.items.properties
474
+ swaggerColumns.forEach(item => {
475
+ const tempItem = this.tableData.columns.find((e) => e.prop == item.prop)
476
+ tempItem ? tempItem = { ...item, ...tempItem } : this.tableData.columns.push(item)
477
+ })
478
+
479
+ // 一定加上selection,通过show显示隐藏
480
+ const itemSelection = this.tableData.columns.find((item) => item.type == "selection");
481
+ const hasSelection = this.tableData.options.selection;
482
+ if (itemSelection) {
483
+ itemSelection.show = !!hasSelection;
484
+ } else {
485
+ this.tableData.columns.unshift({
486
+ label: "",
487
+ minWidth: "",
488
+ type: "selection",
489
+ show: !!hasSelection,
490
+ });
491
+ }
492
+ },
439
493
  radioChange() {
440
494
  this.$emit("radioChange", this.twinPage);
441
495
  },