ol-base-components 2.8.14 → 2.8.16
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/api/api.js +43 -30
- package/src/api/run.js +4 -3
- package/src/bin/initTemplate.js +3 -7
- package/src/package/formSearch/src/index.vue +15 -0
package/package.json
CHANGED
package/src/api/api.js
CHANGED
|
@@ -10,9 +10,9 @@ const modulesDir = process.argv[3] ? process.argv[3] : "src/api/modules";
|
|
|
10
10
|
|
|
11
11
|
const defaultRemark = `/**
|
|
12
12
|
* ⚠️ 警告:此文件由脚本自动生成,请勿手动编辑!
|
|
13
|
-
* ��
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
* �� swagger更新后请重新运行生成脚本
|
|
14
|
+
*/\n\n`;
|
|
15
|
+
// * 📅 生成时间: ${new Date().toLocaleString()}
|
|
16
16
|
const spinnerChars = ["|", "/", "-", "\\"];
|
|
17
17
|
let spinnerIndex = 0;
|
|
18
18
|
let dotCount = 0;
|
|
@@ -200,35 +200,48 @@ const generateApiModules = swagger => {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
// 如果有requestBody
|
|
203
|
-
if (
|
|
204
|
-
|
|
205
|
-
requestBody.content
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (type === "object") {
|
|
213
|
-
functionDoc += ` * @param {Object} body - 请求参数\n`;
|
|
203
|
+
if (Object.keys(requestBody).length > 0 && requestBody.content) {
|
|
204
|
+
// 兼容常见 json contentType
|
|
205
|
+
const content = requestBody.content;
|
|
206
|
+
const jsonCT =
|
|
207
|
+
content["application/json"] ||
|
|
208
|
+
content["application/*+json"] ||
|
|
209
|
+
content["text/json"] ||
|
|
210
|
+
content["*/*"];
|
|
211
|
+
const schema = jsonCT && jsonCT.schema;
|
|
214
212
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
schema.required.includes(key);
|
|
213
|
+
if (schema) {
|
|
214
|
+
const { type, properties } = schema;
|
|
215
|
+
// 目前只有这两种入参结构
|
|
216
|
+
if (type === "object") {
|
|
217
|
+
functionDoc += ` * @param {Object} body - 请求参数\n`;
|
|
221
218
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
219
|
+
if (properties && typeof properties === "object") {
|
|
220
|
+
Object.keys(properties).forEach(key => {
|
|
221
|
+
// 是否必填
|
|
222
|
+
const isRequired =
|
|
223
|
+
schema.required &&
|
|
224
|
+
Array.isArray(schema.required) &&
|
|
225
|
+
schema.required.includes(key);
|
|
226
|
+
|
|
227
|
+
const temp = isRequired ? `body.${key}` : `[body.${key}]`;
|
|
228
|
+
functionDoc += ` * @param {${javaTypeToJsType(
|
|
229
|
+
properties[key].type
|
|
230
|
+
)}} ${temp} - ${properties[key].description || ""}\n`;
|
|
231
|
+
});
|
|
232
|
+
if (Object.keys(properties).length > 0) hasBody = true;
|
|
233
|
+
} else {
|
|
234
|
+
// 无 properties(可能是 $ref 或标量),仍然认为有 body
|
|
235
|
+
hasBody = true;
|
|
236
|
+
}
|
|
237
|
+
} else if (type === "array") {
|
|
238
|
+
// 公司入参是数组的swagger一定是接收id数组的
|
|
239
|
+
functionDoc += ` * @param {Array<string>} body - 数组类型的入参\n`;
|
|
240
|
+
hasBody = true;
|
|
241
|
+
} else {
|
|
242
|
+
// 其他类型(string/number/boolean 或 $ref 未解析)
|
|
243
|
+
hasBody = true;
|
|
244
|
+
}
|
|
232
245
|
}
|
|
233
246
|
}
|
|
234
247
|
|
package/src/api/run.js
CHANGED
|
@@ -10,9 +10,10 @@ const outputPath = process.argv[3] || "src/api/swagger.js";
|
|
|
10
10
|
|
|
11
11
|
const defaultRemark = `/**
|
|
12
12
|
* ⚠️ 警告:此文件由脚本自动生成,请勿手动编辑!
|
|
13
|
-
* ��
|
|
14
|
-
*
|
|
15
|
-
|
|
13
|
+
* �� swagger更新后请重新运行生成脚本
|
|
14
|
+
*
|
|
15
|
+
*/\n\n`;
|
|
16
|
+
// * 📅 生成时间: ${new Date().toLocaleString()}
|
|
16
17
|
const spinnerChars = ["|", "/", "-", "\\"];
|
|
17
18
|
let spinnerIndex = 0;
|
|
18
19
|
let dotCount = 0;
|
package/src/bin/initTemplate.js
CHANGED
|
@@ -203,9 +203,7 @@ const vue2Template = (moduleName, config = {}) => {
|
|
|
203
203
|
@handleSizeChange="handleSizeChange"
|
|
204
204
|
@handleindexChange="handleindexChange"
|
|
205
205
|
/>
|
|
206
|
-
${
|
|
207
|
-
config.hasDialog
|
|
208
|
-
? `<el-dialog :title="formConfig.title" :visible.sync="formConfig.dialogVisible" width="80%">
|
|
206
|
+
${config.hasDialog ? ` <el-dialog :title="formConfig.title" :visible.sync="formConfig.dialogVisible" width="80%">
|
|
209
207
|
<FormModule
|
|
210
208
|
v-if="formConfig.dialogVisible"
|
|
211
209
|
:formData="formConfig.formData"
|
|
@@ -213,10 +211,8 @@ const vue2Template = (moduleName, config = {}) => {
|
|
|
213
211
|
@onCancel="onCancel"
|
|
214
212
|
@onSubmit="onSubmit"
|
|
215
213
|
/>
|
|
216
|
-
</el-dialog
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
</div>
|
|
214
|
+
</el-dialog>
|
|
215
|
+
</div>` : "</div>"}
|
|
220
216
|
</template>
|
|
221
217
|
<script>
|
|
222
218
|
import { ${generateImports()} } from "@/api/modules";
|
|
@@ -466,6 +466,21 @@ export default {
|
|
|
466
466
|
this.formSearch.BeginTime = null;
|
|
467
467
|
this.formSearch.EndTime = null;
|
|
468
468
|
}
|
|
469
|
+
// 有originalFields字段的就是范围时间,查询时候转回接口需要的字段
|
|
470
|
+
Object.keys(this.formSearch).forEach(key => {
|
|
471
|
+
const fieldConfig = this.formSearchData.tableSearch.find(item => item.value === key);
|
|
472
|
+
if (fieldConfig && fieldConfig.originalFields) {
|
|
473
|
+
const { begin, end } = fieldConfig.originalFields;
|
|
474
|
+
if (this.formSearch[key] && Array.isArray(this.formSearch[key])) {
|
|
475
|
+
this.formSearch[begin] = this.formSearch[key][0];
|
|
476
|
+
this.formSearch[end] = this.formSearch[key][1];
|
|
477
|
+
} else {
|
|
478
|
+
this.formSearch[begin] = null;
|
|
479
|
+
this.formSearch[end] = null;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
|
|
469
484
|
const tempFormSearch = Object.assign({}, this.formSearch);
|
|
470
485
|
if (this.formSearchData.rules) {
|
|
471
486
|
return this.$refs[formName].validate(valid => {
|