/** * Created by zhang on 2018/9/3. */ $(document).ready(function () { const locked = lockUtil.getLocked(); lockUtil.lockTools($(document.body), locked); try { let tem = sortJson(JSON.parse($("#originalFeature").val())); $("#templateLibs").val(JSON.stringify(tem.data,null,4)); }catch (err){ console.log(err); } $("#format").click( function() { try { let jsonText = $("#templateLibs").val(); $("#templateLibs").val(JSON.stringify(JSON.parse(jsonText),null,4)); }catch (err){ console.log(err); alert("输入的JSON格式有误,请重新输入!"); } }); $("#save").click(async function() { try { let libID = $("#libID").val(); let jsonText = $("#templateLibs").val(); if(jsonText.indexOf("'")!=-1){ alert("输入的格式不能包含 ' 位于:"+jsonText.substr(jsonText.indexOf("'")-15,18)); return; } let newFeature = await ajaxPost("/monomerTemplate/saveLib",{query:{ID:libID},data:{data:JSON.parse(jsonText)}}); }catch (err){ console.log(err); alert("保存失败,请查看输入数据"); } }); $("#createNormal").click(()=>{ $("#createNormal").click(async function() { let explorer =[ { "dispName": "学校", "items": [ { "dispName": "教学楼", "isHaveStructuralSegment": "true", "key": "academicBuilding", "monomerType": "building" }, { "dispName": "体育馆", "isHaveStructuralSegment": "true", "key": "gymnasium", "monomerType": "building" }, { "dispName": "食堂", "isHaveStructuralSegment": "true", "key": "Canteen", "monomerType": "building" }, { "dispName": "集体宿舍", "isHaveStructuralSegment": "true", "key": "collectiveDormitory", "monomerType": "building" } ], "key": "school" }, { "dispName": "医院", "items": [ { "dispName": "门诊楼", "isHaveStructuralSegment": "true", "key": "outpatientBuilding", "monomerType": "building" }, { "dispName": "住院楼", "isHaveStructuralSegment": "true", "key": "inpatientBuilding", "monomerType": "building" }, { "dispName": "集体宿舍", "isHaveStructuralSegment": "true", "key": "collectiveDormitory", "monomerType": "building" } ], "key": "hospital" }, { "dispName": "市政工程", "items": [ { "dispName": "新建改建扩建", "isHaveStructuralSegment": "true", "key": "newConstruction", "monomerType": "civil" }, { "dispName": "景观提升", "isHaveStructuralSegment": "true", "key": "landscapeImprovement", "monomerType": "civil" }, { "dispName": "养护大中修", "isHaveStructuralSegment": "true", "key": "curing", "monomerType": "civil" }, { "dispName": "小修保养", "isHaveStructuralSegment": "true", "key": "routineMaintenance", "monomerType": "civil" } ], "key": "municipalConstruction" } ]; try { let jsonText = JSON.stringify(explorer); $("#templateLibs").val(JSON.stringify(JSON.parse(jsonText),null,4)); }catch (err){ console.log(err); } }) }) });