/** * Created by zhang on 2018/9/3. */ $(document).ready(function () { try { let tem = sortJson(JSON.parse($("#originalInterval").val())); $("#progressiveList").val(JSON.stringify(tem,null,4)); }catch (err){ console.log(err); } $("#format").click( function() { try { let jsonText = $("#progressiveList").val(); $("#progressiveList").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 = $("#progressiveList").val(); if(jsonText.indexOf("'")!=-1){ alert("输入的格式不能包含 ' 位于:"+jsonText.substr(jsonText.indexOf("'")-15,18)); return; } await ajaxPost("/progressive/saveLib",{query:{ID:libID},data:{data:JSON.parse(jsonText)}}); }catch (err){ console.log(err); alert("保存失败,请查看输入数据"); } }); $("#createNormal").click(async function() { let progressive = [ { name: '施工场地建设费', progression: [ {feeRate: 5.570, interval: '(0,200]'}, {feeRate: 4.581, interval: '(200,500]'}, {feeRate: 3.627, interval: '(500,1000]'}, {feeRate: 2.707, interval: '(1000,+)'}, ] } ]; try { let jsonText = JSON.stringify(progressive); $("#progressiveList").val(JSON.stringify(JSON.parse(jsonText),null,4)); }catch (err){ console.log(err); } }) });