ol-base-components 2.2.7 → 2.3.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/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "ol-base-components",
3
- "version": "2.2.7",
3
+ "version": "2.3.0",
4
4
  "private": false,
5
5
  "main": "src/package/index.js",
6
6
  "bin": {
7
7
  "run": "src/api/run.js",
8
- "api": "src/api/api.js"
8
+ "api": "src/api/api.js",
9
+ "init": "src/bin/init.js"
9
10
  },
10
11
  "scripts": {
11
12
  "serve": "vue-cli-service serve --no-verify",
12
13
  "build": "vue-cli-service build",
13
- "lint": "vue-cli-service lint"
14
+ "lint": "vue-cli-service lint",
15
+ "init": "node src/bin/init.js"
14
16
  },
15
17
  "dependencies": {
16
18
  "core-js": "^3.8.3",
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");
@@ -40,7 +40,7 @@ SwaggerClient(swaggerUrl)
40
40
  function createIndexFile(apiModules) {
41
41
  let str = "";
42
42
  Object.keys(apiModules).forEach((fileName) => {
43
- str += `import * from "./${fileName}.js"\n`;
43
+ str += `export * from "./${fileName}";\n`;
44
44
  });
45
45
  const outputPath = path.join(modulesDir, `index.js`);
46
46
  fs.writeFileSync(outputPath, str, "utf-8");
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");
@@ -0,0 +1,27 @@
1
+ const { Command } = require("commander");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+ const vue2Template = require("./initTemplate");
5
+ const program = new Command();
6
+
7
+ program
8
+ .version("0.1.0")
9
+ .argument("<moduleName>", "name of the module to create")
10
+ .option("-p, --path <customPath>", "custom path to create the module")
11
+ .action((moduleName, options) => {
12
+ const dir = path.join(options.path || process.cwd(), moduleName);
13
+ if (!fs.existsSync(dir)) {
14
+ fs.mkdirSync(dir);
15
+ console.log(`创建文件夹: ${dir}`);
16
+ const templateContent = vue2Template(moduleName);
17
+ fs.writeFileSync(path.join(dir, `${moduleName}.vue`), templateContent);
18
+ console.log(`创建文件: ${moduleName}.vue`);
19
+ } else {
20
+ console.log(`创建失败,文件夹 ${dir} 已存在`);
21
+ }
22
+ if (options.debug) {
23
+ console.log("调试信息:", options);
24
+ }
25
+ });
26
+
27
+ program.parse(process.argv);
@@ -0,0 +1,118 @@
1
+ const vue2Template = (moduleName) => {
2
+ return `<!--
3
+ Filename: ${moduleName}.vue
4
+ name: ${moduleName}
5
+ Created Date: ${new Date().toLocaleString()}
6
+ Author:
7
+ -->
8
+ <template>
9
+ <div>
10
+ <ol-search
11
+ :url="swaggerUrl.getAdmissioninfoPagedresult"
12
+ :form-search-data="formSearchData"
13
+ @handleSearch="handleSearch"
14
+ @handleReset="handleReset"
15
+ />
16
+ <ol-table
17
+ :url="swaggerUrl.getAdmissioninfoPagedresult"
18
+ :paginations="paginations"
19
+ :btnlist="this.hasBtn(this)"
20
+ :empty-img="tableData.emptyImg"
21
+ :table-data="tableData"
22
+ :multiple-selection="multipleSelection"
23
+ @SelectionChange="SelectionChange"
24
+ @handleSizeChange="handleSizeChange"
25
+ @handleindexChange="handleindexChange"
26
+ />
27
+ </div>
28
+ </template>
29
+ <script>
30
+ import { getAdmissioninfoPagedresult } from "@/api/modules";
31
+ import { AdmissionInfo } from '@/api/swagger'
32
+ export default {
33
+ name: "test",
34
+ data() {
35
+ return {
36
+ swaggerUrl: AdmissionInfo,
37
+ multipleSelection: [],
38
+ // 查询表单
39
+ formSearchData: {
40
+ reset: true, // 重置
41
+ expendShow: true, // 展开
42
+ value: {},
43
+ tableSearch: []
44
+ },
45
+ // 表格数据
46
+ tableData: {
47
+ loading: false,
48
+ emptyImg: true,
49
+ options: {
50
+ selection: true, // 多选框
51
+ index: null, // 序号
52
+ headTool: true, // 开启头部工具栏
53
+ refreshBtn: true, // 开启表格头部刷新按钮
54
+ downloadBtn: true // 开启表格头部下载按钮
55
+ }, // 序号和复选框
56
+ rows: [], // 表数据
57
+ columns: [],
58
+ operatesAttrs: {},
59
+ operates: [], // 表格里面的操作按钮
60
+ tableHeightDiff: 330
61
+ },
62
+ paginations: {
63
+ page: 1, // 当前位于那页面
64
+ total: 10, // 总数
65
+ limit: 30, // 一页显示多少条
66
+ pagetionShow: true
67
+ },
68
+ }
69
+ },
70
+ created() {
71
+ this.init();
72
+ },
73
+ methods: {
74
+ async init() {
75
+ const params = {
76
+ ...this.formSearchData.value,
77
+ Page: this.paginations.page,
78
+ MaxResultCount: this.paginations.limit
79
+ };
80
+ const { result: { items = [], totalCount = 0 } = {} } = await getAdmissioninfoPagedresult(params, {
81
+ isLoading: true
82
+ });
83
+ this.tableData.rows = items;
84
+ this.paginations.total = totalCount;
85
+ this.tableData.emptyImg = true;
86
+ },
87
+ handleSearch(from) {
88
+ this.formSearchData.value = { ...from };
89
+ this.paginations.page = 1;
90
+ this.init();
91
+ },
92
+ handleReset() {
93
+ for (let key in this.formSearchData.value) {
94
+ this.formSearchData.value[key] = null;
95
+ }
96
+ this.paginations.page = 1;
97
+ },
98
+ SelectionChange(row) {
99
+ this.multipleSelection = row;
100
+ },
101
+ handleSizeChange(val) {
102
+ this.paginations.page = 1;
103
+ this.paginations.limit = val;
104
+ this.init();
105
+ },
106
+ handleindexChange(val) {
107
+ this.paginations.page = val;
108
+ this.init();
109
+ },
110
+ }
111
+ }
112
+ </script>
113
+ <style lang="scss" scoped>
114
+ </style>
115
+ `;
116
+ };
117
+
118
+ module.exports = vue2Template; // Use CommonJS export