开封利通水务前端

addOrEditPro.js 2.2KB

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