var data; var type; $(function() { getdata(); }); function getdata() { var param = {}; $.post("/JkEdu/Dictionary/getDictionary", param, function(result) { if (result.Code == 10000) { data = eval(result.data); type = eval(result.type); init(); } }); } function init() { var html = ''; html += '' + '' + '业务类型' + '字典ID' + '字典名称' + '备注' + '操作' + '' + '' + ''; $ .each( type, function(i, t) { var cols = 0; $.each(data, function(i, d) { if (d.typename == t.typename) { cols += 1; } }); console.log(cols); $ .each( data, function(i, d) { if (d.typename == t.typename) { html += ''; html += '' + d.typename + ''; html += '' + t.typename + ''; html += '' + d.code + '' + '' + d.codename + '' + '' + d.dictionarytext + '' + '修改' + '删除' + '' + ''; } }); }); html += ''; $("#process-demo-1").append(html); } function deleteRow(r, id) { var i = r.parentNode.parentNode.rowIndex; var artBox = art.dialog({ lock : true, artIcon : 'ask', opacity : 0.4, width : 250, title : '删除', content : '是否确定删除 ?', ok : function() { document.getElementById('process-demo-1').deleteRow(i); var param = {}; param.dictionaryid = id; $.post("/JkEdu/Dictionary/delDictionary", param, function(result) { console.log(result.Code); if (result.Code == 10000) { return true; } else { return false; } }); }, cancel : true }); } function update(r, id) { var contents = ''; $ .each( data, function(i, d) { if (d.dictionaryid == id) { contents += '' + '' + '' + '' + '' + '
业务类型:
字典ID:
字典名称:
备注
'; } }); var artBox = art .dialog({ lock : true, artIcon : 'ask', opacity : 0.4, width : 'auto', height : 'auto', overflow : true, title : '修改', content : contents, button : [ { name : '保存', callback : function() { if ($("#typename").val() == "") { return false; } if ($("#code").val() == "") { return false; } if ($("#codename").val() == "") { return false; } if ($("#dictionarytext").val() == "") { return false; } var tr = r.parentNode.parentNode; tr.cells[0].innerText = $("#typename").val(); tr.cells[1].innerText = $("#code").val(); tr.cells[2].innerText = $("#codename").val(); tr.cells[3].innerText = $("#dictionarytext") .val(); var param = {}; param.dictionaryid = id; param.typename = $("#typename").val(); param.code = $("#code").val(); param.codename = $("#codename").val(); param.dictionarytext = $("#dictionarytext") .val(); $ .post( "/JkEdu/Dictionary/updateDictionary", param, function(result) { console.log(result.Code); if (result.Code == 10000) { var param = {}; $ .post( "/JkEdu/Dictionary/getDictionary", param, function( result) { if (result.Code == 10000) { data = eval(result.data); type = eval(result.type); } }); return true; } else { return false; } }); }, focus : true }, { name : '取消', }, ] }); } function add() { var contents = ''; contents += '' + '' + '' + '' + '' + '
业务类型:
字典ID:
字典名称:
备注
'; var artBox = art.dialog({ lock : true, artIcon : 'ask', opacity : 0.4, width : 'auto', height : 'auto', overflow : true, title : '添加', content : contents, button : [ { name : '保存', callback : function() { if ($("#typename").val() == "") { return false; } if ($("#code").val() == "") { return false; } if ($("#codename").val() == "") { return false; } if ($("#dictionarytext").val() == "") { return false; } var param = {}; param.typename = $("#typename").val(); param.code = $("#code").val(); param.codename = $("#codename").val(); param.dictionarytext = $("#dictionarytext").val(); $.post("/JkEdu/Dictionary/addDictionary", param, function(result) { console.log(result.Code); if (result.Code == 10000) { $("#process-demo-1").empty(); getdata(); return true; } else { return false; } }); }, focus : true }, { name : '取消', }, ] }); }