123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- 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 += '<thead>' + '<tr>' + '<th>业务类型</th>' + '<th>字典ID</th>'
- + '<th>字典名称</th>' + '<th>备注</th>' + '<th>操作</th>' + '</tr>'
- + '</thead>' + '<tbody>';
- $
- .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 += '<tr>';
- html += '<td>' + d.typename
- + '</td>';
- html += '<td">' + t.typename
- + '</td>';
- html += '<td>'
- + d.code
- + '</td>'
- + '<td>'
- + d.codename
- + '</td>'
- + '<td>'
- + d.dictionarytext
- + '<td>'
- + '<a id="Edit" href="javascript:;" class="c-btn c-btn-green" onclick="update(this,'
- + d.dictionaryid
- + ')">修改</a>'
- + '<a id="Delete" href="javascript:;" class="c-btn c-btn-red ml10" onclick="deleteRow(this,'
- + d.dictionaryid
- + ')">删除</a>' + '</td>'
- + '</tr>';
- }
- });
- });
- html += '</tbody>';
- $("#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 += '<table class="tb tb-b c-100 c-t-center">'
- + '<tr><td>业务类型:</td><td><input id="typename" type="text" class="cus-input" value="'
- + d.typename
- + '" placeholder=""/></td></tr>'
- + '<tr><td>字典ID:</td><td><input id="code" type="text" class="cus-input" value="'
- + d.code
- + '" placeholder=""/></td></tr>'
- + '<tr><td>字典名称:</td><td><input id="codename" type="text" class="cus-input" value="'
- + d.codename
- + '" placeholder=""/></td></tr>'
- + '<tr><td>备注</td><td><input id="dictionarytext" type="text" class="cus-input" value="'
- + d.dictionarytext
- + '" placeholder=""/></td></tr>'
- + '</table>';
- }
- });
- 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 += '<table class="tb tb-b c-100 c-t-center">'
- + '<tr><td>业务类型:</td><td><input id="typename" type="text" class="cus-input"'
- + ' placeholder="请输入内容"/></td></tr>'
- + '<tr><td>字典ID:</td><td><input id="code" type="text" class="cus-input"'
- + ' placeholder="请输入内容"/></td></tr>'
- + '<tr><td>字典名称:</td><td><input id="codename" type="text" class="cus-input"'
- + ' placeholder="请输入内容"/></td></tr>'
- + '<tr><td>备注</td><td><input id="dictionarytext" type="text" class="cus-input"'
- + ' placeholder="请输入内容"/></td></tr>' + '</table>';
- 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 : '取消',
- }, ]
- });
- }
|