ol-base-components 2.5.0 → 2.6.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/.eslintrc CHANGED
@@ -1,8 +1,59 @@
1
- // {
2
- // "rules": {
3
- // "no-console": "off", // 关闭 console 相关的警告
4
- // "no-unused-vars": "off", // 关闭未使用变量的警告
5
- // "vue/no-mutating-props": "off", // 关闭对 props 的修改警告
6
- // "no-undef": "off" // 关闭未定义变量的警告
7
- // }
8
- // }
1
+ {
2
+ "extends": [
3
+ "plugin:vue/essential", // Vue规则 官方 ESLint 插件 eslint-plugin-vue
4
+ "eslint:recommended", // 基础规则 ESLint 自带的推荐规则
5
+ "prettier", // 关闭所有和 Prettier 冲突的 ESLint 规则
6
+ "plugin:prettier/recommended" //启用 prettier 插件,让 ESLint 把 Prettier 的格式问题当成 ESLint 报错
7
+ ],
8
+ "parserOptions": {
9
+ "parser": "@babel/eslint-parser",
10
+ "requireConfigFile": false,
11
+ "ecmaVersion": 2020,
12
+ "sourceType": "module"
13
+ },
14
+ "env": {
15
+ "browser": true,
16
+ "node": true,
17
+ "es6": true
18
+ },
19
+ "rules": {
20
+ "no-console": "warn",
21
+ "no-debugger": "warn",
22
+ "no-unused-vars": "warn",
23
+ "vue/no-unused-components": "warn",
24
+ "vue/no-unused-vars": "warn",
25
+ "vue/multi-word-component-names": "off",
26
+ "vue/no-v-html": "off",
27
+ "vue/require-default-prop": "off",
28
+ "vue/require-prop-types": "off",
29
+ "vue/no-mutating-props": "warn",
30
+ "vue/no-side-effects-in-computed-properties": "warn",
31
+ "vue/valid-v-for": "error",
32
+ "vue/valid-v-if": "error",
33
+ "vue/valid-v-model": "error",
34
+ "vue/valid-template-root": "error",
35
+ "vue/no-duplicate-attributes": "error",
36
+ "vue/no-parsing-error": "error",
37
+ "vue/require-v-for-key": "error",
38
+ "vue/valid-v-bind": "error",
39
+ "vue/valid-v-on": "error",
40
+ "vue/valid-v-slot": "error",
41
+ "vue/valid-v-text": "error",
42
+ "vue/valid-v-html": "error",
43
+ "vue/valid-v-pre": "error",
44
+ "vue/valid-v-cloak": "error",
45
+ "vue/valid-v-once": "error",
46
+ "vue/valid-v-show": "error",
47
+ "vue/valid-v-else": "error",
48
+ "vue/valid-v-else-if": "error",
49
+ "prefer-const": "warn",
50
+ "no-var": "error",
51
+ "eqeqeq": "error",
52
+ "no-undef": "error",
53
+ "no-redeclare": "error",
54
+ "no-unreachable": "error",
55
+ "strict": ["error", "global"],
56
+ "no-implicit-globals": "error",
57
+ "no-unused-expressions": "error"
58
+ }
59
+ }
@@ -0,0 +1,6 @@
1
+ node_modules
2
+ dist
3
+ .git
4
+ *.min.js
5
+ *.min.css
6
+ package-lock.json
package/.prettierrc ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "semi": true,
3
+ "singleQuote": false,
4
+ "tabWidth": 2,
5
+ "printWidth": 100,
6
+ "trailingComma": "es5",
7
+ "bracketSpacing": true,
8
+ "arrowParens": "avoid",
9
+ "endOfLine": "lf",
10
+ "vueIndentScriptAndStyle": true,
11
+ "htmlWhitespaceSensitivity": "css",
12
+ "singleAttributePerLine": false,
13
+ "trimTrailingWhitespace": true
14
+ }
package/README.md CHANGED
@@ -35,7 +35,7 @@ import OlBaseComponents from "ol-base-components"; // 导入组件库
35
35
  Vue.use(OlBaseComponents);
36
36
 
37
37
  new Vue({
38
- render: (h) => h(App),
38
+ render: h => h(App),
39
39
  }).$mount("#app");
40
40
  ```
41
41
 
@@ -52,11 +52,9 @@ Vue.use(OlBaseComponents);
52
52
 
53
53
  //安装,可以在登录
54
54
  import { swaggerInstall } from "ol-base-components";
55
- swaggerInstall("http://192.168.xxx.xxx:20019/swagger/v1/swagger.json").then(
56
- () => {
57
- // 成功获取swagger数据后加载页面, 这里可以写登录接口成功后执行的逻辑
58
- }
59
- );
55
+ swaggerInstall("http://192.168.xxx.xxx:20019/swagger/v1/swagger.json").then(() => {
56
+ // 成功获取swagger数据后加载页面, 这里可以写登录接口成功后执行的逻辑
57
+ });
60
58
 
61
59
  // 卸载
62
60
  import { swaggerUnload } from "ol-base-components";
@@ -164,58 +162,58 @@ npx add aaa -p src/view -u /api/app/business-report/stock-bIPaged-result -e /api
164
162
  </template>
165
163
 
166
164
  <script>
167
- export default {
168
- data() {
169
- return {
170
- formSearchData: {
171
- reset: true,
172
- expendShow: false,
173
- value: {
174
- WarehouseCode: null,
175
- WarehouseName: null,
176
- },
177
- tableSearch: [
178
- {
179
- label: "仓库编码",
180
- value: "WarehouseCode",
181
- inputType: "text",
165
+ export default {
166
+ data() {
167
+ return {
168
+ formSearchData: {
169
+ reset: true,
170
+ expendShow: false,
171
+ value: {
172
+ WarehouseCode: null,
173
+ WarehouseName: null,
182
174
  },
183
- {
184
- label: "仓库名称",
185
- value: "WarehouseName",
186
- inputType: "text",
187
- },
188
- ],
189
- },
190
- };
191
- },
192
- mounted() {
193
- this.getTable();
194
- },
195
- method: {
196
- getTable() {
197
- // this.get({
198
- // url: Basic.getWarehoseList,
199
- // isLoading: true,
200
- // data: Object.assign(this.formSearchData.value, {
201
- // Page: this.paginations.page,
202
- // MaxResultCount: this.paginations.limit,
203
- // }),
204
- // }).then((res) => {
205
- // this.tableData.rows = res.result.items;
206
- // this.paginations.total = res.result.totalCount;
207
- // this.tableData.emptyImg = true;
208
- // });
175
+ tableSearch: [
176
+ {
177
+ label: "仓库编码",
178
+ value: "WarehouseCode",
179
+ inputType: "text",
180
+ },
181
+ {
182
+ label: "仓库名称",
183
+ value: "WarehouseName",
184
+ inputType: "text",
185
+ },
186
+ ],
187
+ },
188
+ };
209
189
  },
210
- handleSearch(from) {
211
- var self = this;
212
- self.formSearchData.value = { ...from };
213
- self.paginations.page = 1;
214
- this.getTable(); // 获取表格数据
190
+ mounted() {
191
+ this.getTable();
215
192
  },
216
- handleReset() {},
217
- },
218
- };
193
+ method: {
194
+ getTable() {
195
+ // this.get({
196
+ // url: Basic.getWarehoseList,
197
+ // isLoading: true,
198
+ // data: Object.assign(this.formSearchData.value, {
199
+ // Page: this.paginations.page,
200
+ // MaxResultCount: this.paginations.limit,
201
+ // }),
202
+ // }).then((res) => {
203
+ // this.tableData.rows = res.result.items;
204
+ // this.paginations.total = res.result.totalCount;
205
+ // this.tableData.emptyImg = true;
206
+ // });
207
+ },
208
+ handleSearch(from) {
209
+ var self = this;
210
+ self.formSearchData.value = { ...from };
211
+ self.paginations.page = 1;
212
+ this.getTable(); // 获取表格数据
213
+ },
214
+ handleReset() {},
215
+ },
216
+ };
219
217
  </script>
220
218
  ```
221
219
 
@@ -241,111 +239,109 @@ export default {
241
239
  @handleindexChange="handleindexChange"
242
240
  >
243
241
  <template slot="classes" slot-scope="scope">
244
- <div style="color: #1682e6; cursor: pointer" @click="config(scope)">
245
- 设置
246
- </div>
242
+ <div style="color: #1682e6; cursor: pointer" @click="config(scope)">设置</div>
247
243
  </template>
248
244
  </ol-table>
249
245
  </div>
250
246
  </template>
251
247
 
252
248
  <script>
253
- export default {
254
- data() {
255
- return {
256
- multipleSelection: [],
257
- tableData: {
258
- loading: false,
259
- emptyImg: true,
260
- options: {
261
- selection: true, //多选框
262
- index: null, //序号
263
- headTool: true, //开启头部工具栏
264
- refreshBtn: true, //开启表格头部刷新按钮
265
- downloadBtn: true, //开启表格头部下载按钮
266
- }, //序号和复选框
267
- rows: [], //表数据
268
- columns: [
269
- {
270
- label: "",
271
- minWidth: "",
272
- type: "selection",
273
- show: true,
274
- },
275
- {
276
- prop: "warehouseCode",
277
- label: "仓库编码",
278
- minWidth: "",
279
- sortable: false,
280
- show: true,
281
- },
282
- {
283
- prop: "warehouseName",
284
- label: "仓库名称",
285
- minWidth: "",
286
- sortable: false,
287
- show: true,
288
- },
289
- {
290
- prop: "enabledDesc",
291
- label: "状态",
292
- minWidth: "",
293
- sortable: false,
294
- show: true,
295
- },
296
- {
297
- prop: "createdUser",
298
- label: "创建人",
299
- minWidth: "",
300
- sortable: false,
301
- show: true,
302
- },
303
- {
304
- prop: "createTime",
305
- label: "创建时间",
306
- minWidth: "",
307
- show: true,
308
- },
309
- {
310
- prop: "classes",
311
- label: "班次",
312
- minWidth: "",
313
- show: true,
314
- renderSlot: true,
315
- },
316
- {
317
- prop: "remark",
318
- label: "备注",
319
- minWidth: "",
320
- show: true,
321
- },
322
- ], //表头
323
- operates: [], //表格里面的操作按钮
324
- tableHeightDiff: 300,
249
+ export default {
250
+ data() {
251
+ return {
252
+ multipleSelection: [],
253
+ tableData: {
254
+ loading: false,
255
+ emptyImg: true,
256
+ options: {
257
+ selection: true, //多选框
258
+ index: null, //序号
259
+ headTool: true, //开启头部工具栏
260
+ refreshBtn: true, //开启表格头部刷新按钮
261
+ downloadBtn: true, //开启表格头部下载按钮
262
+ }, //序号和复选框
263
+ rows: [], //表数据
264
+ columns: [
265
+ {
266
+ label: "",
267
+ minWidth: "",
268
+ type: "selection",
269
+ show: true,
270
+ },
271
+ {
272
+ prop: "warehouseCode",
273
+ label: "仓库编码",
274
+ minWidth: "",
275
+ sortable: false,
276
+ show: true,
277
+ },
278
+ {
279
+ prop: "warehouseName",
280
+ label: "仓库名称",
281
+ minWidth: "",
282
+ sortable: false,
283
+ show: true,
284
+ },
285
+ {
286
+ prop: "enabledDesc",
287
+ label: "状态",
288
+ minWidth: "",
289
+ sortable: false,
290
+ show: true,
291
+ },
292
+ {
293
+ prop: "createdUser",
294
+ label: "创建人",
295
+ minWidth: "",
296
+ sortable: false,
297
+ show: true,
298
+ },
299
+ {
300
+ prop: "createTime",
301
+ label: "创建时间",
302
+ minWidth: "",
303
+ show: true,
304
+ },
305
+ {
306
+ prop: "classes",
307
+ label: "班次",
308
+ minWidth: "",
309
+ show: true,
310
+ renderSlot: true,
311
+ },
312
+ {
313
+ prop: "remark",
314
+ label: "备注",
315
+ minWidth: "",
316
+ show: true,
317
+ },
318
+ ], //表头
319
+ operates: [], //表格里面的操作按钮
320
+ tableHeightDiff: 300,
321
+ },
322
+ paginations: {
323
+ page: 1, //当前位于那页面
324
+ total: 10, //总数
325
+ limit: 30, //一页显示多少条
326
+ pagetionShow: true,
327
+ },
328
+ };
329
+ },
330
+ methods: {
331
+ SelectionChange(row) {
332
+ this.multipleSelection = row;
325
333
  },
326
- paginations: {
327
- page: 1, //当前位于那页面
328
- total: 10, //总数
329
- limit: 30, //一页显示多少条
330
- pagetionShow: true,
334
+ handleSizeChange(val) {
335
+ this.paginations.page = 1;
336
+ this.paginations.limit = val;
337
+ this.getTable();
338
+ },
339
+ handleindexChange(val) {
340
+ this.paginations.page = val;
341
+ this.getTable();
331
342
  },
332
- };
333
- },
334
- methods: {
335
- SelectionChange(row) {
336
- this.multipleSelection = row;
337
- },
338
- handleSizeChange(val) {
339
- this.paginations.page = 1;
340
- this.paginations.limit = val;
341
- this.getTable();
342
- },
343
- handleindexChange(val) {
344
- this.paginations.page = val;
345
- this.getTable();
346
343
  },
347
- },
348
- };
344
+ };
349
345
  </script>
350
346
  ```
351
347
 
@@ -405,13 +401,90 @@ export default {
405
401
  url: PublicAggregate.dictionaries,
406
402
  fn: this.getTable,
407
403
  },
408
- ,
404
+ }
409
405
  };
410
406
  },
411
407
  };
412
408
  </script>
413
409
  ```
414
410
 
411
+ # 表格组件多级表头使用说明
412
+
413
+ ## 功能简介
414
+
415
+ 本表格组件基于 Element-UI,支持:
416
+
417
+ - 多级表头(嵌套 children)
418
+ - 多级表头顺序可通过 `beforeProp` 字段灵活控制
419
+ - 表头字段顺序优先以 `columns` 配置为准,后补充 swagger 字段
420
+ - 目前 `beforeProp` 仅支持多级表头,普通字段暂不支持
421
+
422
+ #### 效果图
423
+
424
+ ![Local demo](./src/assets/duojibiaotou.png "Local demo")
425
+
426
+ ## 1. 多级表头配置方法
427
+
428
+ ### 基本结构
429
+
430
+ ```js
431
+ tableData: {
432
+ columns: [
433
+ // 普通字段
434
+ { prop: "unit", show: false },
435
+ // 多级表头
436
+ {
437
+ label: "一级表头",
438
+ beforeProp: "qty", // 该多级表头会插入到 qty 字段之后
439
+ show: true,
440
+ children: [
441
+ {
442
+ label: "二级表头",
443
+ children: [
444
+ { prop: "creationTime" },
445
+ { prop: "orginalBillNo" }
446
+ ]
447
+ },
448
+ { prop: "tagNumber" },
449
+ { prop: "batch" }
450
+ ]
451
+ },
452
+ // 另一个多级表头
453
+ {
454
+ label: "一级表头-1",
455
+ beforeProp: "containerType", // 插入到 containerType 字段之后
456
+ children: [
457
+ { prop: "regionCode" },
458
+ { prop: "taskNo" }
459
+ ]
460
+ }
461
+ // ... 其它字段
462
+ ],
463
+ rows: [
464
+ // 数据行
465
+ ],
466
+ // 其它配置
467
+ }
468
+ ```
469
+
470
+ ### 说明
471
+
472
+ - **多级表头**通过 `children` 字段递归嵌套实现。
473
+ - 每个多级表头对象可包含:
474
+ - `label`:表头名称
475
+ - `beforeProp`:插入到指定字段(prop)之后
476
+ - `show`:是否显示
477
+ - `children`:子表头数组
478
+ - **beforeProp** 仅支持在多级表头对象上设置,用于指定该多级表头插入到哪个字段(prop)之后。
479
+ - 普通字段(非多级表头)暂不支持 `beforeProp`,只能手动在 `columns` 中调整顺序。
480
+
481
+ ## 2. 字段顺序规则
482
+
483
+ - 表头字段顺序优先以 `columns` 配置为准。
484
+ - 如果有 swagger 字段未在 `columns` 中出现,会自动补充到表头最后。
485
+ - 多级表头的位置可通过 `beforeProp` 字段灵活调整。
486
+ - 普通字段顺序只能通过手动调整 `columns` 数组顺序实现。
487
+
415
488
  ## 贡献
416
489
 
417
490
  欢迎任何形式的贡献!如果您有建议或发现问题,请提交 issue 或 pull request。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol-base-components",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "private": false,
5
5
  "main": "src/package/index.js",
6
6
  "bin": {
@@ -30,6 +30,9 @@
30
30
  "@vue/cli-plugin-babel": "~5.0.0",
31
31
  "@vue/cli-plugin-eslint": "~5.0.0",
32
32
  "@vue/cli-service": "~5.0.0",
33
+ "eslint-config-prettier": "^8.8.0",
34
+ "eslint-plugin-prettier": "^4.2.1",
35
+ "prettier": "^2.8.8",
33
36
  "sass": "^1.89.2",
34
37
  "sass-loader": "^16.0.5",
35
38
  "vue-template-compiler": "^2.6.14"