constant.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // var page_size=10;
  2. function queryConstant(){
  3. var data = {
  4. "flag_name": $("#keywords").val()
  5. }
  6. var cols = [
  7. {width: 40, text: '序号', type: 'number', flex: true, field: 'num'},
  8. {width: 40, text: '字典值', type: 'string', flex: true, field: 'code_value'},
  9. {width: 80, text: '字典名称', type: 'string', flex: true, field: 'code_name'},
  10. {width: 60, text: '有效标志', type: 'string', flex: true, field: 'valid'},
  11. {width: 160, text: '字典标识', type: 'string', flex: true, field: 'code_flag'},
  12. {width: 160, text: '标识名称', type: 'string', flex: true, field: 'flag_name'},
  13. {width: 80, text: '备注', type: 'string', flex: true, field: 'remark'},
  14. {width: 80, text: '操作', type: 'string', flex: true, field: 'id',
  15. oper:[
  16. {func:'showEditConstant',text:'修改',icon_class:'icon-edit'},
  17. {func:'deleteConstant',text:'删除',icon_class:'icon-remove-circle'}
  18. ]
  19. }
  20. ];
  21. // var pager = {
  22. // page_size:10
  23. // }
  24. $('.datatable').mytable({'cols':cols,
  25. 'url':"/constant/getConstantByName/",
  26. 'param':data}
  27. );
  28. }
  29. function showAddConstant(){
  30. $('#code_flag').val('');
  31. $('#flag_name').val('');
  32. $('#code_value').val('');
  33. $('#code_name').val('');
  34. $('#sort_no').val('');
  35. $('#remark').val('');
  36. $("#valid").attr('checked','true');
  37. showPopup4Common('添加常量',function(){
  38. addOrUpdateConstant("/constant/add/");
  39. },'400px');
  40. }
  41. var cur_id;
  42. function addOrUpdateConstant(url){
  43. var valid=1;
  44. if(!$("#valid").is(':checked')) valid=0;
  45. var param ={
  46. 'id':cur_id,
  47. 'code_flag':$('#code_flag').val(),
  48. 'flag_name':$('#flag_name').val(),
  49. 'code_value':Number($('#code_value').val()),
  50. 'code_name':$('#code_name').val(),
  51. 'sort_no':Number($('#sort_no').val()),
  52. 'remark':$('#remark').val(),
  53. 'valid':valid
  54. };
  55. addOrUpdateItem4Common(param,url,queryConstant);
  56. }
  57. function showEditConstant(id){
  58. cur_id='';
  59. var rowData=getItemByIdFromArr(id,$('.datatable').mytable('getTableData'));
  60. if(rowData) {
  61. cur_id = rowData.id;
  62. $('#code_flag').val(rowData.code_flag);
  63. $('#flag_name').val(rowData.flag_name);
  64. $('#code_value').val(rowData.code_value);
  65. $('#code_name').val(rowData.code_name);
  66. $('#sort_no').val(rowData.sort_no);
  67. $('#remark').val(rowData.remark);
  68. if(rowData.valid==1){
  69. $("#valid").attr('checked','true');
  70. }else{
  71. $("#valid").attr('checked','false');
  72. }
  73. showPopup4Common('修改常量',function(){
  74. addOrUpdateConstant("/constant/update/");
  75. },'400px');
  76. }
  77. }
  78. function deleteConstant(id){
  79. deleteItem4Common(id,"/constant/delete/",queryConstant);
  80. }