No Description

addOrEditProL.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * 区域增加或编辑
  3. * */
  4. $(function() {
  5. var pro_Id = helper.request.queryString("edit_id");
  6. if(pro_Id) { //修改
  7. getProject(pro_Id);
  8. }
  9. //添加编辑保存按钮点击
  10. $('#pro_save').on('click', saveProject);
  11. });
  12. //获取单个区域
  13. function getProject(ids) {
  14. $.getJSON(huayi.config.callcenter_url + "CusRegionCategory/GetInfo", {
  15. id: ids,
  16. token: $.cookie("token")
  17. }, function(data) {
  18. if(data.state == "success") {
  19. var res = data.data;
  20. $('#pro_title').val(res.F_RegionName); // 是 string 名称
  21. $('#pro_sort').val(res.F_Sort); // 是 int 排序
  22. }
  23. });
  24. }
  25. //保存区域
  26. function saveProject() {
  27. var pro_Id = helper.request.queryString("edit_id");
  28. var wUrl;
  29. if(!$.trim($('#pro_title').val())) {
  30. layer.confirm('区域名称不能为空', {
  31. icon: 2,
  32. btn: ['确定'] //按钮
  33. });
  34. return;
  35. }
  36. if(!regexs.nums.test($.trim($('#pro_sort').val()))) {
  37. layer.confirm('排序只能输入数字', {
  38. icon: 2,
  39. btn: ['确定'] //按钮
  40. });
  41. return;
  42. }
  43. if(pro_Id) {
  44. wURL = "CusRegionCategory/Update";
  45. } else {
  46. wURL = "CusRegionCategory/Add";
  47. }
  48. $.post(huayi.config.callcenter_url + wURL, {
  49. F_RegionId: pro_Id, // 是 int 区域项目id
  50. F_RegionName: $('#pro_title').val(), // 是 string 名称
  51. F_ParentId: 0, // 是 int 父级id
  52. F_AreaId: 1,// 是 int 分类 区域默认1
  53. F_Sort: $('#pro_sort').val(), // 是 int 排序
  54. token: $.cookie("token")
  55. }, function(data) {
  56. data = JSON.parse(data);
  57. if(data.state == "success") {
  58. var index = parent.layer.getFrameIndex(window.name);
  59. parent.layer.close(index);
  60. parent.$('#table').bootstrapTable('refresh');
  61. parent.layer.msg("保存成功");
  62. }
  63. });
  64. }