/** * Created by zhang on 2018/9/11. */ $(document).ready(function () { try { let tem = sortJson(JSON.parse($("#originalTemplates").val())); $("#templateList").val(JSON.stringify(tem,null,4)); }catch (err){ console.log(err); } $("#format").click( function() { try { let jsonText = $("#templateList").val(); $("#templateList").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 = $("#templateList").val(); if(jsonText.indexOf("'")!=-1){ alert("输入的格式不能包含 ' 位于:"+jsonText.substr(jsonText.indexOf("'")-15,18)); return; } let template = await ajaxPost("/calcProgram/saveLib",{query:{ID: parseInt(libID)},data:{templates:JSON.parse(jsonText)}}); }catch (err){ console.log(err); alert("保存失败,请查看输入数据"); } }); });