ol-base-components 2.4.1 → 2.5.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/.eslintrc +59 -8
- package/.prettierignore +6 -0
- package/.prettierrc +14 -0
- package/package.json +4 -1
- package/src/App.vue +416 -457
- package/src/api/api.js +1 -2
- package/src/api/run.js +7 -7
- package/src/component/countCom.vue +105 -0
- package/src/package/formSearch/src/index.vue +53 -40
- package/src/package/table/src/TableColumn.vue +80 -0
- package/src/package/table/src/index.vue +883 -621
package/src/api/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const path = require("path");
|
|
4
4
|
const SwaggerClient = require("swagger-client");
|
|
@@ -14,7 +14,6 @@ let defaultRemark = `/**
|
|
|
14
14
|
* ⚠️ 警告:此文件由脚本自动生成,请勿手动编辑!
|
|
15
15
|
* �� 如需修改,请重新运行生成脚本
|
|
16
16
|
* 📅 生成时间: ${new Date().toLocaleString()}
|
|
17
|
-
*
|
|
18
17
|
*/\n\n`;
|
|
19
18
|
const spinnerChars = ["|", "/", "-", "\\"];
|
|
20
19
|
let spinnerIndex = 0;
|
package/src/api/run.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
const http = require("http");
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const path = require("path");
|
|
@@ -10,6 +10,11 @@ const swaggerUrl = process.argv[2]
|
|
|
10
10
|
: "";
|
|
11
11
|
const outputPath = process.argv[3] || "src/api/swagger.js";
|
|
12
12
|
|
|
13
|
+
let defaultRemark = `/**
|
|
14
|
+
* ⚠️ 警告:此文件由脚本自动生成,请勿手动编辑!
|
|
15
|
+
* �� 如需修改,请重新运行生成脚本
|
|
16
|
+
* 📅 生成时间: ${new Date().toLocaleString()}
|
|
17
|
+
*/\n\n`;
|
|
13
18
|
const spinnerChars = ["|", "/", "-", "\\"];
|
|
14
19
|
let spinnerIndex = 0;
|
|
15
20
|
let dotCount = 0;
|
|
@@ -131,12 +136,7 @@ const generateApiModules = (swagger) => {
|
|
|
131
136
|
}
|
|
132
137
|
|
|
133
138
|
// 生成最终的输出字符串
|
|
134
|
-
let output =
|
|
135
|
-
* ⚠️ 警告:此文件由脚本自动生成,请勿手动编辑!
|
|
136
|
-
* �� 如需修改,请重新运行生成脚本
|
|
137
|
-
* 📅 生成时间: ${new Date().toLocaleString()}
|
|
138
|
-
*
|
|
139
|
-
*/\n\n`;
|
|
139
|
+
let output = defaultRemark;
|
|
140
140
|
for (const [moduleName, methods] of Object.entries(apiModules)) {
|
|
141
141
|
const description = tags.find((e) => e.name === moduleName).description;
|
|
142
142
|
output += `// ${description}\n`;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="quantity-control">
|
|
3
|
+
<transition name="slide-fade">
|
|
4
|
+
<div
|
|
5
|
+
v-if="quantity > 0"
|
|
6
|
+
class="quantity-wrapper"
|
|
7
|
+
>
|
|
8
|
+
<button
|
|
9
|
+
class="btn minus"
|
|
10
|
+
@click="decrease"
|
|
11
|
+
>-</button>
|
|
12
|
+
<span class="quantity">{{ quantity }}</span>
|
|
13
|
+
</div>
|
|
14
|
+
</transition>
|
|
15
|
+
<button
|
|
16
|
+
class="btn plus addBtn"
|
|
17
|
+
@click="increase"
|
|
18
|
+
>+</button>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
export default {
|
|
24
|
+
name: 'QuantityControl',
|
|
25
|
+
props: {
|
|
26
|
+
value: {
|
|
27
|
+
type: Number,
|
|
28
|
+
default: 0
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
data() {
|
|
32
|
+
return {
|
|
33
|
+
quantity: this.value
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
watch: {
|
|
37
|
+
value(newVal) {
|
|
38
|
+
this.quantity = newVal;
|
|
39
|
+
},
|
|
40
|
+
quantity(newVal) {
|
|
41
|
+
this.$emit('input', newVal);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
methods: {
|
|
45
|
+
increase() {
|
|
46
|
+
this.quantity++;
|
|
47
|
+
},
|
|
48
|
+
decrease() {
|
|
49
|
+
if (this.quantity > 0) {
|
|
50
|
+
this.quantity--;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<style scoped>
|
|
58
|
+
.quantity-control {
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: flex-end;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.btn {
|
|
65
|
+
width: 30px;
|
|
66
|
+
height: 30px;
|
|
67
|
+
border: 1px solid #ccc;
|
|
68
|
+
background-color: #eee;
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
font-size: 16px;
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
transition: background-color 0.3s ease;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.btn:hover {
|
|
78
|
+
background-color: #f0f0f0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.addBtn {
|
|
82
|
+
z-index: 1000;
|
|
83
|
+
}
|
|
84
|
+
.quantity-wrapper {
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.quantity {
|
|
90
|
+
margin: 0 10px;
|
|
91
|
+
font-size: 16px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* 动画效果 */
|
|
95
|
+
.slide-fade-enter-active,
|
|
96
|
+
.slide-fade-leave-active {
|
|
97
|
+
transition: all 0.1s ease;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.slide-fade-enter,
|
|
101
|
+
.slide-fade-leave-to {
|
|
102
|
+
opacity: 0;
|
|
103
|
+
transform: translateX(30px);
|
|
104
|
+
}
|
|
105
|
+
</style>
|
|
@@ -149,14 +149,15 @@
|
|
|
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
|
-
|
|
159
|
+
>重置</el-button
|
|
160
|
+
>
|
|
160
161
|
<el-button
|
|
161
162
|
v-if="formSearchData.expendShow"
|
|
162
163
|
plain
|
|
@@ -164,7 +165,8 @@
|
|
|
164
165
|
:icon="expend ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"
|
|
165
166
|
@click="handleExpend('formSearch')"
|
|
166
167
|
>
|
|
167
|
-
{{ expend ? "收起" : "展开" }}</el-button
|
|
168
|
+
{{ expend ? "收起" : "展开" }}</el-button
|
|
169
|
+
>
|
|
168
170
|
</el-form-item>
|
|
169
171
|
</el-form>
|
|
170
172
|
</div>
|
|
@@ -187,7 +189,7 @@
|
|
|
187
189
|
</template>
|
|
188
190
|
|
|
189
191
|
<script>
|
|
190
|
-
import { getData } from
|
|
192
|
+
import { getData } from "../../index.js";
|
|
191
193
|
|
|
192
194
|
export default {
|
|
193
195
|
name: "search",
|
|
@@ -252,7 +254,7 @@ export default {
|
|
|
252
254
|
props: {
|
|
253
255
|
url: {
|
|
254
256
|
type: String,
|
|
255
|
-
default:
|
|
257
|
+
default: "",
|
|
256
258
|
},
|
|
257
259
|
formSearchData: {
|
|
258
260
|
type: Object,
|
|
@@ -300,7 +302,7 @@ export default {
|
|
|
300
302
|
};
|
|
301
303
|
},
|
|
302
304
|
async created() {
|
|
303
|
-
this.init()
|
|
305
|
+
this.init();
|
|
304
306
|
},
|
|
305
307
|
watch: {
|
|
306
308
|
"formSearchData.value": {
|
|
@@ -317,43 +319,51 @@ export default {
|
|
|
317
319
|
},
|
|
318
320
|
methods: {
|
|
319
321
|
async init() {
|
|
320
|
-
const swaggerData = await getData()
|
|
321
|
-
const swaggersearchColumns =
|
|
322
|
+
const swaggerData = await getData();
|
|
323
|
+
const swaggersearchColumns =
|
|
324
|
+
swaggerData.paths[this.url].get.parameters || [];
|
|
322
325
|
swaggersearchColumns.forEach((item) => {
|
|
323
|
-
let tempItem = this.formSearchData.tableSearch.find(
|
|
326
|
+
let tempItem = this.formSearchData.tableSearch.find(
|
|
327
|
+
(e) => e.value.toLowerCase() === item.name.toLowerCase()
|
|
328
|
+
);
|
|
324
329
|
if (tempItem) {
|
|
325
330
|
// 匹配到
|
|
326
|
-
tempItem = { ...item, ...tempItem }
|
|
331
|
+
tempItem = { ...item, ...tempItem };
|
|
327
332
|
} else if (item.description) {
|
|
328
333
|
// 未匹配到
|
|
329
334
|
const pushItem = {
|
|
330
335
|
value: item.name,
|
|
331
336
|
label: item.description,
|
|
332
|
-
inputType:
|
|
333
|
-
props: {}
|
|
334
|
-
}
|
|
337
|
+
inputType: "text",
|
|
338
|
+
props: {},
|
|
339
|
+
};
|
|
335
340
|
if (item.schema.enum && Array.isArray(item.schema.enum)) {
|
|
336
341
|
//枚举值
|
|
337
|
-
pushItem.inputType =
|
|
338
|
-
pushItem.children = item.schema.enum.map(e => ({
|
|
339
|
-
|
|
342
|
+
pushItem.inputType = "select";
|
|
343
|
+
pushItem.children = item.schema.enum.map((e) => ({
|
|
344
|
+
key: e,
|
|
345
|
+
value: e,
|
|
346
|
+
}));
|
|
347
|
+
} else if (item.schema.format === "date-time") {
|
|
340
348
|
//日期
|
|
341
|
-
pushItem.inputType =
|
|
342
|
-
pushItem.props.valueFormat =
|
|
343
|
-
pushItem.props.format =
|
|
344
|
-
} else if (item.schema && item.schema.type ===
|
|
345
|
-
pushItem.inputType =
|
|
349
|
+
pushItem.inputType = "picker";
|
|
350
|
+
pushItem.props.valueFormat = "yyyy-MM-dd";
|
|
351
|
+
pushItem.props.format = "yyyy/MM/dd";
|
|
352
|
+
} else if (item.schema && item.schema.type === "string") {
|
|
353
|
+
pushItem.inputType = "text";
|
|
346
354
|
}
|
|
347
|
-
this.formSearchData.tableSearch.push(pushItem)
|
|
355
|
+
this.formSearchData.tableSearch.push(pushItem);
|
|
348
356
|
}
|
|
349
|
-
})
|
|
357
|
+
});
|
|
350
358
|
|
|
351
|
-
const tableHasCreatedTime = this.formSearchData.tableSearch.some(
|
|
359
|
+
const tableHasCreatedTime = this.formSearchData.tableSearch.some(
|
|
360
|
+
(e) => e.value === "createdTime"
|
|
361
|
+
);
|
|
352
362
|
if (!tableHasCreatedTime) {
|
|
353
363
|
// 单独处理创建时间 就是BeginTime,EndTime
|
|
354
|
-
const requiredNames = [
|
|
355
|
-
const hseCreatedTime = requiredNames.every(name =>
|
|
356
|
-
swaggersearchColumns.some(item => item.name === name)
|
|
364
|
+
const requiredNames = ["BeginTime", "EndTime"];
|
|
365
|
+
const hseCreatedTime = requiredNames.every((name) =>
|
|
366
|
+
swaggersearchColumns.some((item) => item.name === name)
|
|
357
367
|
);
|
|
358
368
|
if (hseCreatedTime) {
|
|
359
369
|
this.formSearchData.tableSearch.push({
|
|
@@ -366,15 +376,19 @@ export default {
|
|
|
366
376
|
endPlaceholder: "结束时间",
|
|
367
377
|
placeholder: "选择时间范围",
|
|
368
378
|
valueFormat: "yyyy-MM-dd HH:mm:ss",
|
|
369
|
-
format: "yyyy/MM/dd HH:mm:ss"
|
|
370
|
-
}
|
|
371
|
-
})
|
|
379
|
+
format: "yyyy/MM/dd HH:mm:ss",
|
|
380
|
+
},
|
|
381
|
+
});
|
|
372
382
|
}
|
|
373
383
|
}
|
|
374
|
-
this.findTableSearch =
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
384
|
+
this.findTableSearch =
|
|
385
|
+
this.formSearchData.tableSearch.length > this.tableSearchSlice
|
|
386
|
+
? this.formSearchData.tableSearch.slice(0, this.tableSearchSlice)
|
|
387
|
+
: this.formSearchData.tableSearch;
|
|
388
|
+
console.log(
|
|
389
|
+
`\x1b[36m\x1b[4mol插件-搜索框渲染`,
|
|
390
|
+
this.formSearchData.tableSearch
|
|
391
|
+
);
|
|
378
392
|
},
|
|
379
393
|
// 树形下拉
|
|
380
394
|
getValue(val) {
|
|
@@ -389,7 +403,7 @@ export default {
|
|
|
389
403
|
this.formSearch.BeginTime = null;
|
|
390
404
|
this.formSearch.EndTime = null;
|
|
391
405
|
}
|
|
392
|
-
const tempFormSearch = Object.assign({}, this.formSearch)
|
|
406
|
+
const tempFormSearch = Object.assign({}, this.formSearch);
|
|
393
407
|
if (this.formSearchData.rules) {
|
|
394
408
|
return this.$refs[formName].validate((valid) => {
|
|
395
409
|
if (!valid) return false;
|
|
@@ -397,8 +411,7 @@ export default {
|
|
|
397
411
|
});
|
|
398
412
|
}
|
|
399
413
|
this.$emit("handleSearch", tempFormSearch, item);
|
|
400
|
-
console.log(`\x1b[36m\x1b[4mol插件-搜索框查询`, tempFormSearch)
|
|
401
|
-
|
|
414
|
+
console.log(`\x1b[36m\x1b[4mol插件-搜索框查询`, tempFormSearch);
|
|
402
415
|
},
|
|
403
416
|
loadmore(obj) {
|
|
404
417
|
this.$emit("loadmore", obj);
|
|
@@ -446,9 +459,9 @@ export default {
|
|
|
446
459
|
this.expend = !this.expend; // 展开和收起
|
|
447
460
|
this.findTableSearch = this.expend
|
|
448
461
|
? this.formSearchData.tableSearch.slice(
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
462
|
+
0,
|
|
463
|
+
this.formSearchData.tableSearch.length
|
|
464
|
+
)
|
|
452
465
|
: this.formSearchData.tableSearch.slice(0, this.tableSearchSlice);
|
|
453
466
|
|
|
454
467
|
this.$emit("btnHandleExpend", this.expend);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<!-- src/package/table/src/TableColumn.vue -->
|
|
2
|
+
<template>
|
|
3
|
+
<el-table-column
|
|
4
|
+
:key="`${column.prop}-${column.show}`"
|
|
5
|
+
v-if="shouldShow"
|
|
6
|
+
:label="column.label"
|
|
7
|
+
:prop="column.prop"
|
|
8
|
+
:min-width="column.minWidth || '150px'"
|
|
9
|
+
:show-overflow-tooltip="column.overHidden || true"
|
|
10
|
+
:type="column.type || 'normal'"
|
|
11
|
+
v-bind="{
|
|
12
|
+
align: 'center',
|
|
13
|
+
width: column.width,
|
|
14
|
+
fixed: column.fixed || false,
|
|
15
|
+
sortable: column.sortable || false,
|
|
16
|
+
...column.attrs,
|
|
17
|
+
}"
|
|
18
|
+
>
|
|
19
|
+
<!-- 表头插槽 -->
|
|
20
|
+
<template v-slot:header>
|
|
21
|
+
<el-tooltip
|
|
22
|
+
v-if="column.prop"
|
|
23
|
+
:content="`${column.label} ${column.prop} ${column.show}`"
|
|
24
|
+
placement="top"
|
|
25
|
+
>
|
|
26
|
+
<span>{{ column.label }}</span>
|
|
27
|
+
</el-tooltip>
|
|
28
|
+
<!-- 多级表头无prop无需提示 -->
|
|
29
|
+
<span v-else>{{ column.label }}</span>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<!-- 递归渲染子列 -->
|
|
33
|
+
<template v-if="column.children && column.children.length">
|
|
34
|
+
<TableColumn v-for="(child, idx) in column.children" :key="idx" :column="child">
|
|
35
|
+
<!-- 透传插槽 -->
|
|
36
|
+
<template v-for="(slotFn, name) in $scopedSlots" v-slot:[name]="slotProps">
|
|
37
|
+
<slot :name="name" v-bind="slotProps" />
|
|
38
|
+
</template>
|
|
39
|
+
</TableColumn>
|
|
40
|
+
</template>
|
|
41
|
+
<!-- 内容插槽:自定义渲染 -->
|
|
42
|
+
<template v-else-if="column.render" v-slot="scope">
|
|
43
|
+
<render-dom :render="() => column.render(scope.row)" />
|
|
44
|
+
</template>
|
|
45
|
+
<template v-else-if="column.renderSlot" v-slot="scope">
|
|
46
|
+
<slot :row="scope.row" :name="column.prop" />
|
|
47
|
+
</template>
|
|
48
|
+
</el-table-column>
|
|
49
|
+
</template>
|
|
50
|
+
<script>
|
|
51
|
+
export default {
|
|
52
|
+
name: "TableColumn",
|
|
53
|
+
components: {
|
|
54
|
+
renderDom: {
|
|
55
|
+
functional: true,
|
|
56
|
+
props: { render: Function },
|
|
57
|
+
render(h, ctx) {
|
|
58
|
+
return <div>{ctx.props.render()}</div>;
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
TableColumn: null, // 递归自身,见下方
|
|
62
|
+
},
|
|
63
|
+
props: {
|
|
64
|
+
column: { type: Object, required: true },
|
|
65
|
+
},
|
|
66
|
+
data() {
|
|
67
|
+
return {};
|
|
68
|
+
},
|
|
69
|
+
// beforeCreate() {
|
|
70
|
+
// // 递归注册自身
|
|
71
|
+
// this.$options.components.TableColumn = require("./TableColumn.vue").default;
|
|
72
|
+
// },
|
|
73
|
+
computed: {
|
|
74
|
+
shouldShow() {
|
|
75
|
+
if (this.column.hasOwnProperty("show")) return this.column.show;
|
|
76
|
+
return true;
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
</script>
|