ol-base-components 0.3.2 → 1.0.0

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/src/App.vue CHANGED
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div id="app">
3
- <MyTable
3
+ <!-- <MyTable
4
4
  :paginations="paginations"
5
5
  :empty-img="tableData.emptyImg"
6
6
  :btnlist="[]"
@@ -9,7 +9,22 @@
9
9
  @SelectionChange="SelectionChange"
10
10
  @handleSizeChange="handleSizeChange"
11
11
  @handleindexChange="handleindexChange"
12
- ></MyTable>
12
+ ></MyTable> -->
13
+ <!-- url="/api/app/admission-info/paged-result" -->
14
+
15
+ <div>table组件案例</div>
16
+ <ol-table
17
+ :paginations="paginations"
18
+ :empty-img="tableData.emptyImg"
19
+ :btnlist="[]"
20
+ url="/api/app/admission-info/paged-result"
21
+ :table-data="tableData"
22
+ :multiple-selection="multipleSelection"
23
+ @SelectionChange="SelectionChange"
24
+ @handleSizeChange="handleSizeChange"
25
+ @handleindexChange="handleindexChange"
26
+ ></ol-table>
27
+ <el-button @click="handlePrint">接口</el-button>
13
28
  </div>
14
29
  </template>
15
30
 
@@ -35,119 +50,123 @@ export default {
35
50
  }, // 序号和复选框
36
51
  rows: [], // 表数据
37
52
  columns: [
38
- {
39
- label: "",
40
- minWidth: "",
41
- type: "selection",
42
- show: true,
43
- },
44
- {
45
- prop: "qualityEnumDesc",
46
- label: "状态",
47
- },
48
- {
49
- prop: "stockTypeDesc",
50
- label: "类型",
51
- },
52
- {
53
- prop: "productCode",
54
- label: "零件编码",
55
- minWidth: "200",
56
- sortable: false,
57
- show: true,
58
- },
59
- {
60
- prop: "productName",
61
- label: "零件名称",
62
- minWidth: "180",
63
- sortable: false,
64
- show: true,
65
- },
66
- {
67
- prop: "productBatch",
68
- label: "批次",
69
- minWidth: "",
70
- sortable: false,
71
- show: true,
72
- },
73
- {
74
- prop: "receivingTime",
75
- label: "收货日期",
76
- minWidth: "160",
77
- sortable: false,
78
- show: true,
79
- },
80
- {
81
- prop: "expireTime",
82
- label: "到期时间",
83
- },
84
- {
85
- prop: "projectCode",
86
- label: "项目号",
87
- },
88
- {
89
- prop: "boxCode",
90
- label: "箱卡号",
91
- },
92
- {
93
- prop: "region",
94
- label: "区域",
95
- },
96
- {
97
- prop: "area",
98
- label: "库区",
99
- },
100
- {
101
- prop: "carBodyTagNumber",
102
- label: "标签号",
103
- },
104
- {
105
- prop: "cargoLocationCode",
106
- label: "库位编码",
107
- minWidth: "",
108
- sortable: false,
109
- show: true,
110
- },
111
- {
112
- prop: "containerCode",
113
- label: "容器编码",
114
- minWidth: "",
115
- sortable: false,
116
- show: true,
117
- },
118
- {
119
- prop: "totalQty",
120
- label: "库存数量",
121
- minWidth: "120",
122
- sortable: false,
123
- show: true,
124
- },
125
- {
126
- prop: "usableQty",
127
- label: "可用数量",
128
- minWidth: "120",
129
- sortable: false,
130
- show: true,
131
- },
132
- {
133
- prop: "lockQty",
134
- label: "占用数量",
135
- minWidth: "120",
136
- sortable: false,
137
- show: true,
138
- },
139
- {
140
- prop: "stockoutBillNo",
141
- label: "出库单号",
142
- },
143
- {
144
- prop: "loadPercent",
145
- label: "容器承载百分比",
146
- },
147
- {
148
- prop: "alv",
149
- label: "客户件号",
150
- },
53
+ // {
54
+ // label: "",
55
+ // minWidth: "",
56
+ // type: "selection",
57
+ // show: true,
58
+ // },
59
+ {
60
+ prop: "remark",
61
+ label: "备注123",
62
+ },
63
+ {
64
+ prop: "qualityEnumDesc123",
65
+ label: "状态1111112222222",
66
+ },
67
+ // {
68
+ // prop: "stockTypeDesc",
69
+ // label: "类型",
70
+ // },
71
+ // {
72
+ // prop: "productCode",
73
+ // label: "零件编码",
74
+ // minWidth: "200",
75
+ // sortable: false,
76
+ // show: true,
77
+ // },
78
+ // {
79
+ // prop: "productName",
80
+ // label: "零件名称",
81
+ // minWidth: "180",
82
+ // sortable: false,
83
+ // show: true,
84
+ // },
85
+ // {
86
+ // prop: "productBatch",
87
+ // label: "批次",
88
+ // minWidth: "",
89
+ // sortable: false,
90
+ // show: true,
91
+ // },
92
+ // {
93
+ // prop: "receivingTime",
94
+ // label: "收货日期",
95
+ // minWidth: "160",
96
+ // sortable: false,
97
+ // show: true,
98
+ // },
99
+ // {
100
+ // prop: "expireTime",
101
+ // label: "到期时间",
102
+ // },
103
+ // {
104
+ // prop: "projectCode",
105
+ // label: "项目号",
106
+ // },
107
+ // {
108
+ // prop: "boxCode",
109
+ // label: "箱卡号",
110
+ // },
111
+ // {
112
+ // prop: "region",
113
+ // label: "区域",
114
+ // },
115
+ // {
116
+ // prop: "area",
117
+ // label: "库区",
118
+ // },
119
+ // {
120
+ // prop: "carBodyTagNumber",
121
+ // label: "标签号",
122
+ // },
123
+ // {
124
+ // prop: "cargoLocationCode",
125
+ // label: "库位编码",
126
+ // minWidth: "",
127
+ // sortable: false,
128
+ // show: true,
129
+ // },
130
+ // {
131
+ // prop: "containerCode",
132
+ // label: "容器编码",
133
+ // minWidth: "",
134
+ // sortable: false,
135
+ // show: true,
136
+ // },
137
+ // {
138
+ // prop: "totalQty",
139
+ // label: "库存数量",
140
+ // minWidth: "120",
141
+ // sortable: false,
142
+ // show: true,
143
+ // },
144
+ // {
145
+ // prop: "usableQty",
146
+ // label: "可用数量",
147
+ // minWidth: "120",
148
+ // sortable: false,
149
+ // show: true,
150
+ // },
151
+ // {
152
+ // prop: "lockQty",
153
+ // label: "占用数量",
154
+ // minWidth: "120",
155
+ // sortable: false,
156
+ // show: true,
157
+ // },
158
+ // {
159
+ // prop: "stockoutBillNo",
160
+ // label: "出库单号",
161
+ // },
162
+ // {
163
+ // prop: "loadPercent",
164
+ // label: "容器承载百分比",
165
+ // },
166
+ // {
167
+ // prop: "alv",
168
+ // label: "客户件号",
169
+ // },
151
170
  ], // 表头
152
171
  operates: [], // 表格里面的操作按钮
153
172
  tableHeightDiff: 300,
@@ -170,7 +189,7 @@ export default {
170
189
  self.paginations.page = 1;
171
190
  this.getTable();
172
191
  },
173
- handleReset() {},
192
+ handleReset() { },
174
193
  handleSizeChange(val) {
175
194
  this.paginations.page = 1;
176
195
  this.paginations.limit = val;
@@ -180,17 +199,22 @@ export default {
180
199
  this.paginations.page = val;
181
200
  this.getTable();
182
201
  },
202
+ async handlePrint() {
203
+ // console.log(this);
204
+ // const aaa = this.$api.getApi("Stock.get_api_app_stock_stock_pages")
205
+ // console.log(6666, aaa);
206
+ }
183
207
  },
184
208
  };
185
209
  </script>
186
210
 
187
211
  <style>
188
- #app {
212
+ /* #app {
189
213
  font-family: Avenir, Helvetica, Arial, sans-serif;
190
214
  -webkit-font-smoothing: antialiased;
191
215
  -moz-osx-font-smoothing: grayscale;
192
216
  text-align: center;
193
217
  color: #2c3e50;
194
218
  margin-top: 60px;
195
- }
219
+ } */
196
220
  </style>
package/src/main.js CHANGED
@@ -2,11 +2,34 @@ 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 OldCom from "@/package/table/index";
6
5
 
6
+ import olCom, { Swagger } from "@/package/index.js";
7
+ // const swaggerInstance = new Swagger(
8
+ // "http://220.179.249.140:20019/swagger/v1/swagger.json"
9
+ // );
10
+ // Vue.prototype.$api = swaggerInstance;
11
+ // console.log(222, swaggerInstance);
12
+
13
+ // async function fetchStockData() {
14
+ // const stockApi = await swaggerInstance.getApi(
15
+ // cccccccccccccccccccc
16
+ // ); // 获取 API 函数
17
+ // const res = await stockApi({
18
+ // // 调用 API 函数并传递参数
19
+ // Page: 1,
20
+ // MaxResultCount: 30,
21
+ // });
22
+ // console.log(res); // 打印返回的结果
23
+ // }
24
+
25
+ // fetchStockData(); // 调用函数以获取数据
26
+
27
+ Vue.use(olCom);
7
28
  Vue.config.productionTip = false;
8
29
  Vue.use(ElementUI);
9
- Vue.use(OldCom);
10
- new Vue({
11
- render: (h) => h(App),
12
- }).$mount("#app");
30
+
31
+ setTimeout(() => {
32
+ new Vue({
33
+ render: (h) => h(App),
34
+ }).$mount("#app");
35
+ }, 20000);
@@ -1,17 +1,49 @@
1
1
  import OlTable from "./table";
2
2
  import OlSearch from "./formSearch";
3
3
  import Dialog from "./dialog";
4
+ import Swagger from "@/utils/swagger";
5
+
6
+ const consoleTooltip = () => {
7
+ // 定义颜色和样式
8
+ const reset = "\x1b[0m"; // 重置样式
9
+ const green = "\x1b[32m"; // 绿色
10
+ const cyan = "\x1b[36m"; // 青色
11
+ const bold = "\x1b[1m"; // 粗体
12
+ const underline = "\x1b[4m"; // 下划线
13
+
14
+ // 定义图案
15
+ const star = "⭐";
16
+ const checkMark = "✔️";
17
+
18
+ // 输出成功提示
19
+ console.log(`
20
+ ${cyan}${bold}${star.repeat(
21
+ 3
22
+ )}${green}${bold}${underline}ol-base-components 插件加载成功! ${checkMark}
23
+ ${cyan}感谢使用我们的组件库,期待你的精彩应用!${reset}
24
+ `);
25
+ };
4
26
 
5
27
  const components = [OlTable, OlSearch, Dialog];
6
28
 
7
- const install = function (Vue) {
29
+ const install = function (
30
+ Vue,
31
+ option = {
32
+ swaggerUrl: "",
33
+ }
34
+ ) {
35
+ // "http://220.179.249.140:20019/swagger/v1/swagger.json"
36
+ const swaggerInstance = new Swagger(option?.swaggerUrl);
37
+ Vue.prototype.$swagger = swaggerInstance;
8
38
  // 遍历所有组件
9
39
  components.map((item) => {
10
40
  Vue.component(`ol-${item.name}`, item);
11
41
  });
42
+
43
+ consoleTooltip();
12
44
  };
45
+
13
46
  // 判断是否引入文件
14
- export default {
15
- install,
16
- ...components,
17
- };
47
+ export default install; //全局导入
48
+ export { OlTable, OlSearch, Dialog }; //按需导入
49
+ export { Swagger };
@@ -2,15 +2,16 @@
2
2
  <div class="table_list_fix">
3
3
  <!-- 扩展性内容 -->
4
4
  <slot name="content_context" />
5
- <template
6
- v-if="
5
+ <template v-if="
7
6
  btnlist.length ||
8
7
  tableData.options.headTool ||
9
8
  tableData.options.refreshBtn ||
10
9
  tableData.options.downloadBtn
11
- "
12
- >
13
- <div v-if="showBtnBox" class="btnbox">
10
+ ">
11
+ <div
12
+ v-if="showBtnBox"
13
+ class="btnbox"
14
+ >
14
15
  <!-- 左侧按钮 -->
15
16
  <div>
16
17
  <el-button
@@ -20,7 +21,10 @@
20
21
  :type="btn.types ? btn.types : 'primary'"
21
22
  @click="btn.method"
22
23
  >
23
- <i v-if="btn.icon" :class="btn.icon" />
24
+ <i
25
+ v-if="btn.icon"
26
+ :class="btn.icon"
27
+ />
24
28
  {{ btn.title }}
25
29
  </el-button>
26
30
  </div>
@@ -36,14 +40,17 @@
36
40
  <i class="el-icon-s-operation" />
37
41
  </div>
38
42
  </div>
39
- <el-dropdown-menu slot="dropdown" style="padding: 5px">
43
+ <el-dropdown-menu
44
+ slot="dropdown"
45
+ style="padding: 5px"
46
+ >
40
47
  <el-checkbox-group v-model="checkedTableColumns">
41
48
  <el-checkbox
42
49
  v-for="column in checkedTableList"
43
50
  :key="column.prop"
44
51
  class="checkbox"
45
52
  :label="column.prop"
46
- >{{ column.label }}
53
+ >{{ column.label }}
47
54
  </el-checkbox>
48
55
  </el-checkbox-group>
49
56
  </el-dropdown-menu>
@@ -123,12 +130,21 @@
123
130
  <span>{{ item.label }}</span>
124
131
  </el-tooltip>
125
132
  </template>
126
- <template v-if="item.render" v-slot="scope">
133
+ <template
134
+ v-if="item.render"
135
+ v-slot="scope"
136
+ >
127
137
  <!-- 使用函数式组件进行dom渲染 -->
128
138
  <render-dom :render="() => item.render(scope.row)" />
129
139
  </template>
130
- <template v-else-if="item.renderSlot" v-slot="scope">
131
- <slot :row="scope.row" :name="item.prop" />
140
+ <template
141
+ v-else-if="item.renderSlot"
142
+ v-slot="scope"
143
+ >
144
+ <slot
145
+ :row="scope.row"
146
+ :name="item.prop"
147
+ />
132
148
  </template>
133
149
  </el-table-column>
134
150
  </template>
@@ -158,18 +174,23 @@
158
174
  btn.disabled && btn.disabled(scope.row, scope.$index)
159
175
  "
160
176
  @click.stop="btn.method(scope.row, scope.$index)"
161
- >{{ btn.label
177
+ >{{ btn.label
162
178
  }}{{
163
179
  tableData.operates.length >= 2 ? "&nbsp;&nbsp;" : ""
164
- }}</el-button
165
- >
180
+ }}</el-button>
166
181
  </span>
167
182
  </template>
168
- </div> </template
169
-
183
+ </div>
184
+ </template
170
185
  </el-table-column>
171
- <div slot="empty" class="empty">
172
- <img v-if="tableData.rows.length == 0" :src="nodata" />
186
+ <div
187
+ slot="empty"
188
+ class="empty"
189
+ >
190
+ <img
191
+ v-if="tableData.rows.length == 0"
192
+ :src="nodata"
193
+ />
173
194
  </div>
174
195
  </el-table>
175
196
  </div>
@@ -234,6 +255,10 @@ export default {
234
255
  event: "SelectionChange",
235
256
  },
236
257
  props: {
258
+ url: {
259
+ type: String,
260
+ default: "",
261
+ }, // 接口地址
237
262
  printListObj: {
238
263
  type: Object,
239
264
  default: () => {
@@ -329,9 +354,46 @@ export default {
329
354
  },
330
355
  computed: {
331
356
  bindTableColumns() {
332
- return this.tableData.columns.filter((column) =>
357
+ // 读取接口和类型获取表头数据
358
+
359
+ const tableColumns = this.$swagger.specification.paths[this.url].get.responses["200"].content['application/json'].schema.properties.items.items.properties
360
+ let swaggerColumns = Object.keys(tableColumns).reduce((acc, key) => {
361
+ const column = tableColumns[key];
362
+ if (column.description) {
363
+ acc.push({
364
+ prop: key,
365
+ label: column.description,
366
+ minWidth: column.minWidth || "150px",
367
+ sortable: true,
368
+ show: true,
369
+ attrs: {},
370
+ })
371
+ }
372
+ return acc;
373
+ }, []);
374
+
375
+ this.tableData.columns.filter((column) =>
333
376
  Object.keys(column).includes("show") ? column.show : true
334
377
  );
378
+
379
+ this.tableData.columns.forEach(dataColumn => {
380
+ const tempIndex = swaggerColumns.findIndex((item) => item.prop == dataColumn.prop)
381
+ if (tempIndex == -1) {
382
+ swaggerColumns.push(dataColumn)
383
+ } else {
384
+ Object.assign(swaggerColumns[tempIndex], dataColumn)
385
+ }
386
+ })
387
+
388
+ // 如果options.selection有多选框直接加
389
+ swaggerColumns.unshift({
390
+ label: "",
391
+ minWidth: "",
392
+ type: "selection",
393
+ show: true,
394
+ });
395
+ console.log('表头数据', swaggerColumns)
396
+ return swaggerColumns
335
397
  },
336
398
  checkedTableList: {
337
399
  get() {
@@ -507,13 +569,8 @@ export default {
507
569
  color: dodgerblue;
508
570
  }
509
571
 
510
- .pagination {
511
- text-align: center;
512
- }
513
-
514
572
  .tablebox {
515
573
  box-sizing: border-box;
516
- min-height: 240px;
517
574
  flex: 1;
518
575
  overflow: auto;
519
576
  }
File without changes
@@ -0,0 +1,21 @@
1
+ // index.js
2
+ import SwaggerClient from "swagger-client";
3
+ // 创建一个新的列数组
4
+ class Swagger {
5
+ constructor(swaggerUrl, options = {}) {
6
+ this.swaggerUrl = swaggerUrl;
7
+ this.options = options;
8
+ // this.apis = {};
9
+ this.specification = {}; // swagger规范
10
+ this.init();
11
+ }
12
+
13
+ async init() {
14
+ const client = await SwaggerClient({
15
+ url: this.swaggerUrl,
16
+ });
17
+ this.specification = client.spec;
18
+ }
19
+ }
20
+
21
+ export default Swagger;