ol-base-components 1.5.6 → 2.0.1

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/README.md CHANGED
@@ -49,7 +49,7 @@ Vue.use(OlBaseComponents);
49
49
 
50
50
  //安装,可以在登录
51
51
  import {swaggerInstall} from "ol-base-components";
52
- swaggerInstall("http://220.179.249.140:20019/swagger/v1/swagger.json").then(() => {
52
+ swaggerInstall("http://192.168.xxx.xxx:20019/swagger/v1/swagger.json").then(() => {
53
53
  // 成功获取swagger数据后加载页面, 这里可以写登录接口成功后执行的逻辑
54
54
  })
55
55
 
@@ -134,7 +134,9 @@ export default {
134
134
 
135
135
  ### 表格组件
136
136
 
137
- 您可以在您的组件中使用表格组件组件,例如:
137
+ ##### 1. 您可以在您的组件中使用表格组件组件
138
+ ##### 2. 您可以在ol-table添加url参数接收完整的swagger地址,会自动帮您生成tableData.columns。您也可以在columns中添加,当prop相同时候,会自动合并,且columns权限大。
139
+ 例如:
138
140
 
139
141
  ```vue
140
142
  <template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol-base-components",
3
- "version": "1.5.6",
3
+ "version": "2.0.1",
4
4
  "private": false,
5
5
  "main": "src/package/index.js",
6
6
  "scripts": {
@@ -9,8 +9,6 @@
9
9
  "lint": "vue-cli-service lint"
10
10
  },
11
11
  "dependencies": {
12
- "@swagger-api/apidom-json-pointer": "^1.0.0-beta.44",
13
- "@swagger-api/apidom-reference": "^1.0.0-beta.44",
14
12
  "core-js": "^3.8.3",
15
13
  "element-ui": "^2.15.14",
16
14
  "eslint": "^8.57.1",
package/src/App.vue CHANGED
@@ -13,7 +13,13 @@
13
13
  <!-- url="/api/app/admission-info/paged-result" -->
14
14
 
15
15
  <div>table组件案例</div>
16
- <ol-table
16
+ <ol-search
17
+ :form-search-data="formSearchData"
18
+ @handleSearch="handleSearch"
19
+ @handleReset="handleReset"
20
+ url="/api/app/admission-info/paged-result"
21
+ />
22
+ <!-- <ol-table
17
23
  :paginations="paginations"
18
24
  :empty-img="tableData.emptyImg"
19
25
  :btnlist="[]"
@@ -23,17 +29,17 @@
23
29
  @SelectionChange="SelectionChange"
24
30
  @handleSizeChange="handleSizeChange"
25
31
  @handleindexChange="handleindexChange"
26
- ></ol-table>
32
+ ></ol-table> -->
27
33
  <el-button @click="handlePrint">接口</el-button>
28
34
  </div>
29
35
  </template>
30
36
 
31
37
  <script>
32
- import MyTable from "@/package/table/src/index.vue";
38
+ // import MyTable from "@/package/table/src/index.vue";
33
39
  export default {
34
40
  name: "App",
35
41
  components: {
36
- MyTable,
42
+ // MyTable,
37
43
  },
38
44
  data() {
39
45
  return {
@@ -177,6 +183,137 @@ export default {
177
183
  limit: 30, // 一页显示多少条
178
184
  pagetionShow: true,
179
185
  },
186
+
187
+ formSearchData: {
188
+ reset: true, // 重置
189
+ expendShow: true, // 展开
190
+ tableSearchSlice: 5,
191
+ value: {
192
+ DocNo: null, // 对应输入框的value字段
193
+ QualityCheckStateType: null,
194
+ QualityCheckState: null,
195
+ timer: []
196
+ },
197
+ tableSearch: [
198
+ // {
199
+ // label: "标签号",
200
+ // value: "carBodyTagNumber",
201
+ // inputType: "text"
202
+ // },
203
+ // {
204
+ // label: "车架号",
205
+ // value: "frameNumber",
206
+ // inputType: "text"
207
+ // // value: "QualityCheckStateType",
208
+ // // inputType: "select",
209
+ // // children: this.SET_enumsSelect({
210
+ // // keyword: "qualityCheckTypeEnum",
211
+ // // }),
212
+ // },
213
+ // {
214
+ // label: "项目号",
215
+ // value: "projectCode",
216
+ // inputType: "text"
217
+ // },
218
+ // {
219
+ // label: "状态描述",
220
+ // value: "statusDescription",
221
+ // inputType: "select",
222
+ // // 0整车/1白车身/2碰撞加固车身/3爆破切割车身/4侧面切割下车身
223
+ // children: [
224
+ // {
225
+ // key: 0,
226
+ // value: "整车"
227
+ // },
228
+ // {
229
+ // key: 1,
230
+ // value: "白车身"
231
+ // },
232
+ // {
233
+ // key: 2,
234
+ // value: "碰撞加固车身"
235
+ // },
236
+ // {
237
+ // key: 3,
238
+ // value: "爆破切割车身"
239
+ // },
240
+ // {
241
+ // key: 4,
242
+ // value: "侧面切割下车身"
243
+ // }
244
+ // ]
245
+ // },
246
+ // {
247
+ // label: "实验状态",
248
+ // value: "experimentStatus",
249
+ // inputType: "select",
250
+ // // 0实验前 1实验中 2实验后
251
+ // children: [
252
+ // {
253
+ // key: 0,
254
+ // value: "实验前"
255
+ // },
256
+ // {
257
+ // key: 1,
258
+ // value: "实验中"
259
+ // },
260
+ // {
261
+ // key: 2,
262
+ // value: "实验后"
263
+ // }
264
+ // ]
265
+ // },
266
+ // {
267
+ // label: "状态",
268
+ // value: "tagStatus",
269
+ // inputType: "select",
270
+ // children: []
271
+ // },
272
+ // {
273
+ // label: "车身类型",
274
+ // value: "bodyWorkType",
275
+ // inputType: "select",
276
+ // children: []
277
+ // },
278
+ // {
279
+ // label: "项目名称",
280
+ // value: "projectName",
281
+ // inputType: "text"
282
+ // },
283
+ // {
284
+ // label: "入场日期",
285
+ // inputType: "picker",
286
+ // value: "admissionDate",
287
+ // props: {
288
+ // valueFormat: "yyyy-MM-dd",
289
+ // format: "yyyy/MM/dd"
290
+ // }
291
+ // },
292
+ // {
293
+ // label: "打印次数",
294
+ // value: "tagPrintNumber",
295
+ // inputType: "number"
296
+ // },
297
+ // {
298
+ // label: "创建时间",
299
+ // value: "createdTime",
300
+ // inputType: "picker",
301
+ // props: {
302
+ // type: "datetimerange",
303
+ // startPlaceholder: "开始时间",
304
+ // endPlaceholder: "结束时间",
305
+ // placeholder: "选择时间范围",
306
+ // valueFormat: "yyyy-MM-dd HH:mm:ss",
307
+ // format: "yyyy/MM/dd HH:mm:ss"
308
+ // }
309
+ // },
310
+ // {
311
+ // label: "虚拟项目",
312
+ // value: "tempProject",
313
+ // inputType: "text"
314
+ // }
315
+ ]
316
+ },
180
317
  };
181
318
  },
182
319
  methods: {
@@ -184,9 +321,8 @@ export default {
184
321
  this.multipleSelection = row;
185
322
  },
186
323
  handleSearch(from) {
187
- var self = this;
188
- self.formSearchData.value = { ...from };
189
- self.paginations.page = 1;
324
+ this.formSearchData.value = { ...from };
325
+ this.paginations.page = 1;
190
326
  this.getTable();
191
327
  },
192
328
  handleReset() { },
@@ -203,7 +339,21 @@ export default {
203
339
  // console.log(this);
204
340
  // const aaa = this.$api.getApi("Stock.get_api_app_stock_stock_pages")
205
341
  // console.log(6666, aaa);
206
- }
342
+ },
343
+ // ================
344
+ getTable() { },
345
+ handleSearch(from) {
346
+
347
+ this.formSearchData.value = { ...from };
348
+ this.paginations.page = 1;
349
+ this.getTable();
350
+ },
351
+ handleReset() {
352
+ for (let key in this.formSearchData.value) {
353
+ this.formSearchData.value[key] = null;
354
+ }
355
+ this.paginations.page = 1;
356
+ },
207
357
  },
208
358
  };
209
359
  </script>
package/src/main.js CHANGED
@@ -6,10 +6,10 @@ import OlCom from "@/package/index.js";
6
6
 
7
7
  Vue.use(ElementUI);
8
8
 
9
- Vue.use(OlCom, {
10
- swaggerUrl: "http://220.179.249.140:20019/swagger/v1/swagger.json",
11
- });
12
-
9
+ Vue.use(OlCom);
10
+ // swaggerInstall("http://220.179.249.140:20019/swagger/v1/swagger.json").then(
11
+ // () => {}
12
+ // );
13
13
  new Vue({
14
14
  render: (h) => h(App),
15
15
  }).$mount("#app");
@@ -149,15 +149,14 @@
149
149
  size="small"
150
150
  type="primary"
151
151
  @click="handleSearch('formSearch')"
152
- >查询
152
+ >查询
153
153
  </el-button>
154
154
  <el-button
155
155
  v-if="formSearchData.reset"
156
156
  plain
157
157
  size="small"
158
158
  @click="handleReset('formSearch')"
159
- >重置</el-button
160
- >
159
+ >重置</el-button>
161
160
  <el-button
162
161
  v-if="formSearchData.expendShow"
163
162
  plain
@@ -165,8 +164,7 @@
165
164
  :icon="expend ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"
166
165
  @click="handleExpend('formSearch')"
167
166
  >
168
- {{ expend ? "收起" : "展开" }}</el-button
169
- >
167
+ {{ expend ? "收起" : "展开" }}</el-button>
170
168
  </el-form-item>
171
169
  </el-form>
172
170
  </div>
@@ -189,6 +187,8 @@
189
187
  </template>
190
188
 
191
189
  <script>
190
+ import { getData } from '../../index.js'
191
+
192
192
  export default {
193
193
  name: "search",
194
194
  directives: {
@@ -250,6 +250,10 @@ export default {
250
250
  },
251
251
  },
252
252
  props: {
253
+ url: {
254
+ type: String,
255
+ default: '',
256
+ },
253
257
  formSearchData: {
254
258
  type: Object,
255
259
  default: () => {
@@ -298,11 +302,13 @@ export default {
298
302
  optionBox: [],
299
303
  };
300
304
  },
305
+ async created() {
306
+ this.init()
307
+ },
301
308
  watch: {
302
309
  "formSearchData.value": {
303
310
  handler: function (newVal, OldVal) {
304
311
  if (newVal) {
305
- console.log(newVal, "newVal");
306
312
  return (this.formSearch = {
307
313
  ...newVal,
308
314
  });
@@ -313,20 +319,84 @@ export default {
313
319
  },
314
320
  },
315
321
  methods: {
322
+ async init() {
323
+ const swaggerData = await getData()
324
+ const swaggersearchColumns = swaggerData.paths[this.url].get.parameters || []
325
+ swaggersearchColumns.forEach((item) => {
326
+ let tempItem = this.formSearchData.tableSearch.find(e => e.value.toLowerCase() === item.name.toLowerCase())
327
+ if (tempItem) {
328
+ // 匹配到
329
+ tempItem = { ...item, ...tempItem }
330
+ } else if (item.description) {
331
+ // 未匹配到
332
+ const pushItem = {
333
+ value: item.name,
334
+ label: item.description,
335
+ inputType: 'text',
336
+ props: {}
337
+ }
338
+ if (item.schema.enum && Array.isArray(item.schema.enum)) {
339
+ //枚举值
340
+ pushItem.inputType = 'select'
341
+ pushItem.children = item.schema.enum.map(e => ({ key: e, value: e }))
342
+ } else if (item.schema.format === 'date-time') {
343
+ //日期
344
+ pushItem.inputType = 'picker'
345
+ pushItem.props.valueFormat = 'yyyy-MM-dd'
346
+ pushItem.props.format = 'yyyy/MM/dd'
347
+ } else if (item.schema && item.schema.type === 'string') {
348
+ pushItem.inputType = 'text'
349
+ }
350
+ this.formSearchData.tableSearch.push(pushItem)
351
+ }
352
+ })
353
+
354
+ const tableHasCreatedTime = this.formSearchData.tableSearch.some((e) => e.value === 'createdTime')
355
+ if (!tableHasCreatedTime) {
356
+ // 单独处理创建时间 就是BeginTime,EndTime
357
+ const requiredNames = ['BeginTime', 'EndTime'];
358
+ const hseCreatedTime = requiredNames.every(name =>
359
+ swaggersearchColumns.some(item => item.name === name)
360
+ );
361
+ if (hseCreatedTime) {
362
+ this.formSearchData.tableSearch.push({
363
+ label: "创建时间",
364
+ value: "createdTime",
365
+ inputType: "picker",
366
+ props: {
367
+ type: "datetimerange",
368
+ startPlaceholder: "开始时间",
369
+ endPlaceholder: "结束时间",
370
+ placeholder: "选择时间范围",
371
+ valueFormat: "yyyy-MM-dd HH:mm:ss",
372
+ format: "yyyy/MM/dd HH:mm:ss"
373
+ }
374
+ })
375
+ }
376
+ }
377
+
378
+ console.log(`\x1b[36m\x1b[4mol插件-搜索框渲染`, this.formSearchData.tableSearch)
379
+ },
316
380
  // 树形下拉
317
381
  getValue(val) {
318
382
  this.$emit("getTreeSelectValue", val);
319
383
  },
320
384
  // 搜索查询按钮
321
385
  handleSearch(formName, item) {
386
+ if (this.formSearch.createdTime) {
387
+ this.formSearch.BeginTime = this.formSearch.createdTime[0];
388
+ this.formSearch.EndTime = this.formSearch.createdTime[1];
389
+ }
390
+ const tempFormSearch = Object.assign({}, this.formSearch)
322
391
  if (this.formSearchData.rules) {
323
392
  return this.$refs[formName].validate((valid) => {
324
393
  if (!valid) return false;
325
-
326
- this.$emit("handleSearch", Object.assign({}, this.formSearch), item);
394
+ this.$emit("handleSearch", tempFormSearch, item);
327
395
  });
328
396
  }
329
- this.$emit("handleSearch", Object.assign({}, this.formSearch), item);
397
+ this.$emit("handleSearch", tempFormSearch, item);
398
+ console.log(`\x1b[36m\x1b[4mol插件-搜索框查询`, tempFormSearch)
399
+
330
400
  },
331
401
  loadmore(obj) {
332
402
  this.$emit("loadmore", obj);
@@ -374,9 +444,9 @@ export default {
374
444
  this.expend = !this.expend; // 展开和收起
375
445
  this.findTableSearch = this.expend
376
446
  ? this.formSearchData.tableSearch.slice(
377
- 0,
378
- this.formSearchData.tableSearch.length
379
- )
447
+ 0,
448
+ this.formSearchData.tableSearch.length
449
+ )
380
450
  : this.formSearchData.tableSearch.slice(0, this.tableSearchSlice);
381
451
 
382
452
  this.$emit("btnHandleExpend", this.expend);
@@ -97,25 +97,25 @@ function clearData() {
97
97
  const swaggerInstall = async (swaggerUrl) => {
98
98
  if (!swaggerUrl) return Promise.reject(new Error("Swagger URL is required.")); // 检查 Swagger URL
99
99
 
100
- // 尝试从 IndexedDB 获取 Swagger 数据
100
+ // IndexedDB 获取 Swagger 数据
101
101
  const cachedData = await getData();
102
102
  if (cachedData) {
103
103
  consoleTooltip();
104
- return Promise.resolve(cachedData); // 返回已解析的 Promise
104
+ return Promise.resolve(cachedData);
105
105
  } else {
106
106
  // 如果没有缓存数据,重新请求 Swagger 数据
107
107
  try {
108
108
  showLoading();
109
109
  const client = await SwaggerClient(swaggerUrl);
110
- const swaggerData = client.spec; // 获取 Swagger 数据
111
- await storeData(swaggerData); // 缓存数据到 IndexedDB
110
+ const swaggerData = client.spec;
111
+ await storeData(swaggerData);
112
112
  hideLoading();
113
113
  consoleTooltip();
114
- return Promise.resolve(swaggerData); // 返回已解析的 Promise
114
+ return Promise.resolve(swaggerData);
115
115
  } catch (error) {
116
116
  hideLoading();
117
117
  console.error("获取 Swagger 数据失败:", error);
118
- return Promise.reject(error); // 返回拒绝的 Promise
118
+ return Promise.reject(error);
119
119
  }
120
120
  }
121
121
  };
@@ -128,7 +128,6 @@ const components = [OlTable, OlSearch, Dialog];
128
128
 
129
129
  // 自定义加载指示器
130
130
  function showLoading() {
131
- // 创建样式
132
131
  const style = document.createElement("style");
133
132
  style.innerHTML = `
134
133
  @keyframes spin {
@@ -160,10 +159,10 @@ function showLoading() {
160
159
  loadingDiv.style.left = "0";
161
160
  loadingDiv.style.width = "100%";
162
161
  loadingDiv.style.height = "100%";
163
- loadingDiv.style.display = "flex"; // 使用 flexbox
164
- loadingDiv.style.flexDirection = "column"; // 设置为上下排列
165
- loadingDiv.style.justifyContent = "center"; // 垂直居中
166
- loadingDiv.style.alignItems = "center"; // 水平居中
162
+ loadingDiv.style.display = "flex";
163
+ loadingDiv.style.flexDirection = "column";
164
+ loadingDiv.style.justifyContent = "center";
165
+ loadingDiv.style.alignItems = "center";
167
166
 
168
167
  // 创建旋转的加载图标
169
168
  const spinner = document.createElement("div");
@@ -186,14 +185,12 @@ function hideLoading() {
186
185
  }
187
186
 
188
187
  const install = async function (Vue) {
189
- // 遍历所有组件
190
188
  components.map((item) => {
191
189
  Vue.component(`ol-${item.name}`, item);
192
190
  });
193
191
  consoleTooltip();
194
192
  };
195
193
 
196
- // 判断是否引入文件
197
- export default install; //全局导入
198
- export { OlTable, OlSearch, Dialog }; //按需导入
194
+ export default install;
195
+ export { OlTable, OlSearch, Dialog };
199
196
  export { swaggerInstall, swaggerUnload };
@@ -318,10 +318,6 @@ export default {
318
318
  type: Boolean,
319
319
  default: true,
320
320
  },
321
- displayDetail: {
322
- type: Boolean,
323
- default: true,
324
- },
325
321
  pageSizes: {
326
322
  type: Array,
327
323
  default: () => {
@@ -399,17 +395,10 @@ export default {
399
395
  this.$set(column, "show", false);
400
396
  }
401
397
  });
402
- },
403
- },
404
- },
405
- watch: {
406
- displayDetail: {
407
- handler() {
408
398
  this.$nextTick(() => {
409
- this.$refs[this.tableRef].doLayout();
410
- });
399
+ this.$refs.tableRef.doLayout()
400
+ })
411
401
  },
412
- deep: true,
413
402
  },
414
403
  },
415
404
  methods: {