Нет описания

addOrEditDictionaryType.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * 添加或修改字典类别
  3. * */
  4. $(function() {
  5. autosize($('textarea'));
  6. var fid = helper.request.queryString("fid");
  7. if(fid) {
  8. getInfo(fid);
  9. }
  10. //添加或编辑保存按钮点击
  11. $('#save_btns').on('click', saveInfo);
  12. });
  13. //获取
  14. function getInfo(fid) {
  15. $.getJSON(huayi.config.callcenter_url + "configurationapi/api/dictionary/getdetailes", {
  16. id: fid,
  17. }, function(data) {
  18. if(data.state == "success") {
  19. var con = data.data;
  20. if(con) {
  21. $('#dic_ids').prop('disabled', true);
  22. $('#dic_ids').val(con.dictionarycode);
  23. $('#dic_title').val(con.dictionaryname);
  24. $('#dic_sort').val(con.sort);
  25. }
  26. }
  27. });
  28. }
  29. //保存
  30. function saveInfo() {
  31. var fid = helper.request.queryString("fid");
  32. if(!$.trim($('#dic_ids').val())) {
  33. layer.confirm('字典标识不能为空', {
  34. icon: 2,
  35. btn: ['确定'] //按钮
  36. });
  37. return;
  38. }
  39. if(!$.trim($('#dic_title').val())) {
  40. layer.confirm('字典名称不能为空', {
  41. icon: 2,
  42. btn: ['确定'] //按钮
  43. });
  44. return;
  45. }
  46. if($.trim($('#dic_sort').val())){
  47. if(!regexs.phoneNum.test($.trim($('#dic_sort').val()))) {
  48. layer.confirm('排序编号必须是正整数', {
  49. icon: 2,
  50. btn: ['确定'] //按钮
  51. });
  52. return;
  53. }
  54. }
  55. var wUrl;
  56. if(fid) {
  57. wUrl = "configurationapi/api/dictionary/update"; //修改
  58. } else {
  59. wUrl = "configurationapi/api/dictionary/add"; //添加
  60. }
  61. $.post(huayi.config.callcenter_url + wUrl, {
  62. id: fid, //为空或null表示需要添加,有数值表示需要更新
  63. dictionarycode: $('#dic_ids').val(), //字典标识
  64. dictionaryname: $('#dic_title').val(), //字典名称
  65. sort: $('#dic_sort').val(), //排序
  66. }, function(data) {
  67. var data = JSON.parse(data);
  68. if(data.state == "success") {
  69. var index = parent.layer.getFrameIndex(window.name);
  70. parent.layer.close(index);
  71. parent.table.bootstrapTable('refresh');
  72. parent.layer.msg("保存成功");
  73. }
  74. });
  75. }