/** * 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("/singleInfo/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": "项目编号", "key": "projNum", "required": "true", "value": "001" }, { "dispName": "建设规模", "key": "buildScale", "required": "true", "cellType": "number", "options":"" } ], "key": "singleBuilding" } ]; try { let jsonText = JSON.stringify(explorer); $("#templateLibs").val(JSON.stringify(JSON.parse(jsonText),null,4)); }catch (err){ console.log(err); } }) }) });