ol-base-components 2.7.5 → 2.7.6
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 +1 -1
- package/src/bin/initTemplate.js +0 -1
- package/src/utils/initData.js +28 -8
package/package.json
CHANGED
package/src/bin/initTemplate.js
CHANGED
|
@@ -51,7 +51,6 @@ const vue2Template = (moduleName, config = {}) => {
|
|
|
51
51
|
const generateImports = () => {
|
|
52
52
|
const imports = [];
|
|
53
53
|
if (config.pageUrl) imports.push(`${pageUrlKey}`);
|
|
54
|
-
if (config.baseUrl) imports.push(`${baseUrlKey}`);
|
|
55
54
|
if (config.addUrl) imports.push(`${addUrlKey}`);
|
|
56
55
|
if (config.editUrl) imports.push(`${editUrlKey}`);
|
|
57
56
|
if (config.detailUrl) imports.push(`${detailUrlKey}`);
|
package/src/utils/initData.js
CHANGED
|
@@ -26,18 +26,38 @@ const javaTypeToformType = javaType => {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
+
// 弹框接口数据来源判断 优先级:新增接口>编辑接口>详情接口
|
|
30
|
+
const getDialogSwaggerData = (url, swaggerData) => {
|
|
31
|
+
try {
|
|
32
|
+
// 新增 post
|
|
33
|
+
const entity = swaggerData.paths[url].post;
|
|
34
|
+
const schema = entity.requestBody.content["application/json"].schema;
|
|
35
|
+
const properties = schema.properties;
|
|
36
|
+
|
|
37
|
+
return [schema, properties];
|
|
38
|
+
} catch (err) {
|
|
39
|
+
try {
|
|
40
|
+
//编辑 put
|
|
41
|
+
const entity = swaggerData.paths[url].put;
|
|
42
|
+
const schema = entity.requestBody.content["application/json"].schema;
|
|
43
|
+
const properties = schema.properties;
|
|
44
|
+
return [schema, properties];
|
|
45
|
+
} catch (err) {
|
|
46
|
+
// 详情 get
|
|
47
|
+
const entity = swaggerData.paths[url].get;
|
|
48
|
+
const schema = entity.responses[200].content["application/json"].schema;
|
|
49
|
+
const properties = schema.properties;
|
|
50
|
+
return [schema, properties];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
29
55
|
export const initForm = options => {
|
|
30
56
|
const { url, form } = options;
|
|
31
57
|
getData().then(swaggerData => {
|
|
32
58
|
// swagger数据可以来源于,新增接口/编辑接口/详情接口(优先级:新增接口>编辑接口>详情接口)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
properties = {};
|
|
36
|
-
entity = swaggerData.paths[url].post;
|
|
37
|
-
// 添加title
|
|
38
|
-
// if (!form.title) form.title = entity.summary;
|
|
39
|
-
schema = entity.requestBody.content["application/json"].schema;
|
|
40
|
-
properties = schema.properties;
|
|
59
|
+
const [schema, properties] = getDialogSwaggerData(url, swaggerData);
|
|
60
|
+
if (!schema || !properties) return console.log(`\x1b[36m\x1b[4mol插件-弹框数据异常`);
|
|
41
61
|
// 生成model
|
|
42
62
|
// 1.循环model,将properties中prop相同的匹配,属性合并,model权限大,properties权限小,且保持响应式
|
|
43
63
|
form.model.forEach(item => {
|