ol-base-components 2.8.6 → 2.8.8

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.
@@ -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
  // 注册一个测试命令