/** * 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("/structuralSegment/saveLib",{query:{ID:libID},data:{data:JSON.parse(jsonText)}}); }catch (err){ console.log(err); alert("保存失败,请查看输入数据"); } }); $("#createNormal").click( function() { let explorer = [ { "valuationName" : "粤建市[2019]6号", "monomerType" : "building", "items" : [ { "type" : "单项工程", "key" : "basicEngineering", "dispName" : "基础工程", "subItems" : [ { "type" : "单位工程", "key" : "foundationTreatment", "feeType" : "建筑工程", "engineering" : "房屋建筑与装饰工程", "dispName" : "基础处理与基坑支护工程", "calcProgram" : "计算程序2018一般/简易计税(标准)-粤建市[2019]6号", "IndicatorSegment" : "基础工程" } ], } ] } ]; try { let jsonText = JSON.stringify(explorer); $("#templateLibs").val(JSON.stringify(JSON.parse(jsonText),null,4)); }catch (err){ console.log(err); } }) });