fix(数据源): api 数据集预览错误

This commit is contained in:
taojinlong 2022-08-01 16:18:18 +08:00
parent bcfaf4d4e1
commit 0bdbb72253
2 changed files with 8 additions and 13 deletions

View File

@ -317,15 +317,15 @@ public class ApiProvider extends Provider {
}
}
static void mergeValue(JSONObject object, ApiDefinition apiDefinition, JSONObject item) {
static void mergeValue(JSONObject field, ApiDefinition apiDefinition, JSONObject item) {
JSONArray array = object.getJSONArray("value");
JSONArray array = field.getJSONArray("value");
if (array != null && item.getString("value") != null && array.size() < apiDefinition.getPreviewNum()) {
array.add(item.getJSONArray("value").get(0).toString());
object.put("value", array);
field.put("value", array);
}
if(object.getJSONArray("children") != null && item.getJSONArray("children") != null){
JSONArray objectChildren = object.getJSONArray("children");
if(CollectionUtils.isNotEmpty(field.getJSONArray("children"))&& CollectionUtils.isNotEmpty(item.getJSONArray("children"))){
JSONArray objectChildren = field.getJSONArray("children");
JSONArray jsonArrayChildren = new JSONArray();
JSONArray itemChildren = item.getJSONArray("children");
for (Object objectChild : objectChildren) {
@ -338,7 +338,7 @@ public class ApiProvider extends Provider {
}
}
}
object.put("children", jsonArrayChildren);
field.put("children", jsonArrayChildren);
}
}

View File

@ -676,13 +676,7 @@ export default {
required: true,
message: i18n.t("datasource.input_name"),
trigger: "blur",
},
{
min: 2,
max: 25,
message: i18n.t("datasource.input_limit_2_25", [2, 25]),
trigger: "blur",
},
}
],
desc: [
{
@ -938,6 +932,7 @@ export default {
return;
}
this.$refs.apiItem.validate((valid) => {
console.log(valid)
if (valid) {
const data = JSON.parse(JSON.stringify(this.apiItem));
this.loading = true;