ol-base-components 2.8.6 → 2.8.7

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,6 +1,6 @@
1
1
  {
2
2
  "name": "ol-base-components",
3
- "version": "2.8.6",
3
+ "version": "2.8.7",
4
4
  "private": false,
5
5
  "main": "src/package/index.js",
6
6
  "bin": {
@@ -150,7 +150,7 @@ function autoInstallVSCodeExtension() {
150
150
  };
151
151
 
152
152
  const packageJsonPath = path.join(extensionDir, "package.json");
153
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
153
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
154
154
  console.log("✅ 创建文件: package.json");
155
155
 
156
156
  console.log(`\n�� VSCode/Cursor 扩展自动安装成功!`);
@@ -150,7 +150,7 @@ function installVSCodeExtension() {
150
150
  };
151
151
 
152
152
  const packageJsonPath = path.join(extensionDir, "package.json");
153
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
153
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
154
154
  console.log("✅ 创建文件: package.json");
155
155
 
156
156
  console.log(`\n�� VSCode/Cursor 扩展安装成功!`);
Binary file
@@ -176,6 +176,7 @@
176
176
 
177
177
  <script>
178
178
  import { getData } from "../../index.js";
179
+ import { getEnum } from "../../../utils/getEnum.js";
179
180
 
180
181
  export default {
181
182
  name: "search",
@@ -318,10 +319,15 @@ export default {
318
319
  if (item.schema.enum && Array.isArray(item.schema.enum)) {
319
320
  //枚举值
320
321
  pushItem.inputType = "select";
321
- pushItem.children = item.schema.enum.map(e => ({
322
- key: e,
323
- value: e,
324
- }));
322
+ const ref = item.schema["$$ref"].split("/");
323
+ const enumName = ref[ref.length - 1];
324
+ const tempEnum = getEnum(enumName);
325
+ pushItem.children = tempEnum.length
326
+ ? tempEnum
327
+ : item.schema.enum.map(e => ({
328
+ key: e,
329
+ value: e,
330
+ }));
325
331
  } else if (item.schema.format === "date-time") {
326
332
  //日期
327
333
  pushItem.inputType = "picker";
@@ -634,14 +640,17 @@ export default {
634
640
 
635
641
  padding: 10px;
636
642
  }
643
+
637
644
  //解决type=number的上下箭头
638
645
  ::v-deep .numrule input::-webkit-outer-spin-button,
639
646
  ::v-deep .numrule input::-webkit-inner-spin-button {
640
647
  -webkit-appearance: none !important;
641
648
  }
649
+
642
650
  ::v-deep .numrule input[type="number"] {
643
651
  -moz-appearance: textfield !important;
644
652
  }
653
+
645
654
  // 解决type=number输入中文后光标上移的问题
646
655
  ::v-deep .numrule .el-input__inner {
647
656
  line-height: 1px !important;
@@ -0,0 +1,8 @@
1
+ // 1缓存获取 2如果没有就全局接口获取
2
+ export const getEnum = enumName => {
3
+ const local = localStorage.getItem("wms");
4
+ if (!local) return [];
5
+ // enumName首字母转成小写
6
+ const enumStr = enumName[0].toLowerCase() + enumName.slice(1);
7
+ return JSON.parse(local).SET_enumsSelect[enumStr].enums || [];
8
+ };
@@ -1,4 +1,5 @@
1
1
  import { getData } from "../package/index.js";
2
+ import { getEnum } from "./getEnum.js";
2
3
  // java数据类型转成js数据类型
3
4
  const javaTypeToJsType = javaType => {
4
5
  switch (javaType) {
@@ -26,6 +27,40 @@ const javaTypeToformType = javaType => {
26
27
  }
27
28
  };
28
29
 
30
+ const setModelItemByProperty = (prop, property) => {
31
+ const temp = {
32
+ prop: prop,
33
+ label: property.description,
34
+ type: "input",
35
+ hidden: false,
36
+ listeners: () => {},
37
+ props: {},
38
+ };
39
+ if (property.enum || Array.isArray(property.enum)) {
40
+ temp.type = "select";
41
+ const ref = property["$$ref"].split("/");
42
+ const enumName = ref[ref.length - 1];
43
+ const tempEnum = getEnum(enumName);
44
+ temp.children = tempEnum.length
45
+ ? tempEnum
46
+ : property.enum.map(e => ({
47
+ key: e,
48
+ value: e,
49
+ }));
50
+ } else if (property.format === "date-time") {
51
+ temp.type = "date";
52
+ temp.props.valueFormat = "yyyy-MM-dd";
53
+ temp.props.format = "yyyy/MM/dd";
54
+ } else if (property.type == "boolean") {
55
+ temp.type = "switch";
56
+ } else if (property.type == "integer") {
57
+ temp.type = "number";
58
+ } else {
59
+ temp.type = "input";
60
+ }
61
+ return temp;
62
+ };
63
+
29
64
  // 弹框接口数据来源判断 优先级:新增接口>编辑接口>详情接口
30
65
  const getDialogSwaggerData = (url, swaggerData) => {
31
66
  try {
@@ -63,31 +98,26 @@ export const initForm = options => {
63
98
  form.model.forEach(item => {
64
99
  const property = properties[item.prop];
65
100
  if (property) {
66
- Object.assign(item, {
67
- prop: item.prop,
68
- label: property.description,
69
- type: javaTypeToformType(property.type),
70
- hidden: false,
71
- listeners: () => {},
72
- props: {},
73
- ...item,
74
- });
101
+ const modelItem = setModelItemByProperty(item.prop, property);
102
+ item = { ...modelItem, ...item };
103
+ // Object.assign(item, {
104
+ // prop: item.prop,
105
+ // label: property.description,
106
+ // type: javaTypeToformType(property.type),
107
+ // hidden: false,
108
+ // listeners: () => {},
109
+ // props: {},
110
+ // ...item,
111
+ // });
75
112
  }
76
113
  });
77
114
  // 2.将properties都push到model中(只提取swagger中有的type和description)
78
115
  Object.keys(properties).forEach(key => {
79
116
  const property = properties[key];
80
- if (!form.model.find(item => item.prop == key) && property.description) {
117
+ if (!form.model.find(item => item.prop === key) && property.description) {
81
118
  // 删除对象的某些属性
82
- const temp = {
83
- prop: key,
84
- label: property.description,
85
- type: javaTypeToformType(property.type),
86
- hidden: false,
87
- listeners: () => {},
88
- props: {},
89
- };
90
- form.model.push(temp);
119
+ const modelItem = setModelItemByProperty(key, property);
120
+ form.model.push(modelItem);
91
121
  }
92
122
  });
93
123
 
@@ -7,13 +7,14 @@ function activate(context) {
7
7
  // 显示通知确认扩展已激活
8
8
  vscode.window.showInformationMessage("Vue 页面生成器扩展已激活!");
9
9
 
10
- // 注册右键菜单命令
10
+ // 注册右键菜单命令 (registerCommand就是注册命令,第一个参数是名称,第二个就是具体逻辑)
11
11
  const disposable = vscode.commands.registerCommand("vue-generator.createPage", uri => {
12
12
  console.log("命令被调用,URI:", uri);
13
- vscode.window.showInformationMessage("生成 Vue 页面命令被调用!");
13
+ vscode.window.showInformationMessage("生成 Vue 页面命令被调用!"); //右下角会弹出的信息
14
14
  GeneratorPanel.createOrShow(context.extensionUri, uri);
15
15
  });
16
16
 
17
+ //subscriptions是vscode的所有命令的一个注册列表
17
18
  context.subscriptions.push(disposable);
18
19
 
19
20
  // 注册一个测试命令