main
黄海 2 years ago
parent c86dc5c0e2
commit 0d5dbc236d

@ -0,0 +1,11 @@
package UnitTest;
import cn.hutool.core.io.FileUtil;
public class TestGrid {
public static void main(String[] args) {
String path = "D:\\dsWork\\QingLong\\src\\main\\java\\UnitTest\\TestGrid.json";
String content = FileUtil.readUtf8String(path);
}
}

@ -0,0 +1,96 @@
[
{
"id": "input_6",
"index": 0,
"label": "单行文本",
"tag": "input",
"tagIcon": "input",
"placeholder": "请输入",
"defaultValue": null,
"labelWidth": 110,
"width": "100%",
"clearable": true,
"maxlength": null,
"showWordLimit": false,
"readonly": false,
"disabled": false,
"required": true,
"expression": "",
"document": ""
},
{
"id": "grid_8",
"index": 1,
"tag": "grid",
"span": 2,
"columns": [
{
"span": 12,
"list": [
{
"id": "input_9",
"index": 0,
"label": "单行文本",
"tag": "input",
"tagIcon": "input",
"placeholder": "请输入",
"defaultValue": null,
"labelWidth": 110,
"width": "100%",
"clearable": true,
"maxlength": null,
"showWordLimit": false,
"readonly": false,
"disabled": false,
"required": true,
"expression": "",
"document": ""
},
{
"id": "input_11",
"index": 1,
"label": "单行文本",
"tag": "input",
"tagIcon": "input",
"placeholder": "请输入",
"defaultValue": null,
"labelWidth": 110,
"width": "100%",
"clearable": true,
"maxlength": null,
"showWordLimit": false,
"readonly": false,
"disabled": false,
"required": true,
"expression": "",
"document": ""
}
]
},
{
"span": 12,
"list": [
{
"id": "input_10",
"index": 0,
"label": "单行文本",
"tag": "input",
"tagIcon": "input",
"placeholder": "请输入",
"defaultValue": null,
"labelWidth": 110,
"width": "100%",
"clearable": true,
"maxlength": null,
"showWordLimit": false,
"readonly": false,
"disabled": false,
"required": true,
"expression": "",
"document": ""
}
]
}
]
}
]

@ -1403,7 +1403,7 @@ public class CollectModel {
*/
private void createTable(String job_name, String table_name, String json) {
table_name = table_name.toLowerCase();
JSONArray ja = JSONArray.parseArray(json);
JSONArray ja = parseGridJson(json);
String colSql = "", commentSql = "";
for (Object o : ja) {
JSONObject jo = (JSONObject) o;
@ -2261,4 +2261,35 @@ public class CollectModel {
return Db.findFirst(sql, job_id, person_id);
}
/**
* JSONJsonObject
*
* @param content
* @return
*/
public static JSONArray parseGridJson(String content) {
JSONArray ja = JSONArray.parseArray(content);
List<JSONObject> res = new ArrayList<>();
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = ja.getJSONObject(i);
if (jo.containsKey("columns")) {
JSONArray jaColumns = jo.getJSONArray("columns");
for (int j = 0; j < jaColumns.size(); j++) {
JSONArray jaList = jaColumns.getJSONObject(j).getJSONArray("list");
for (int k = 0; k < jaList.size(); k++) {
res.add(jaList.getJSONObject(k));
}
}
} else {
res.add(jo);
}
}
ja.clear();
for (JSONObject re : res) {
ja.add(re);
}
return ja;
}
}
Loading…
Cancel
Save