Geen omschrijving

addOrEditCustomer.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * 增加或编辑客户档案
  3. * */
  4. $(document).ready(function() {
  5. var cid = helper.request.queryString("cid");
  6. laydate.render({
  7. elem: '#F_AccessTime',
  8. theme: '#00479D',
  9. calendar: true
  10. });
  11. //营业部下拉
  12. $.getJSON(huayi.config.callcenter_url + 'CallOutPlan/GetDepartList', {
  13. "token": $.cookie("token")
  14. }, function(result) {
  15. if(result.state.toLowerCase() == "success") {
  16. let str = '<option value="0">请选择</option>'
  17. result.data.forEach(function(v, n) {
  18. str += '<option value="' + v.F_DeptName + '">' + v.F_DeptName + '</option>'
  19. })
  20. $('#F_SaleOffice').html(str)
  21. }
  22. })
  23. if(cid){
  24. getCustomer(cid)
  25. }
  26. //保存
  27. $('#btn_save').on('click', saveCustomer);
  28. });
  29. //添加或编辑保存
  30. function saveCustomer() {
  31. var telreg = /^\d{0,12}$/;
  32. var cid = helper.request.queryString("cid");
  33. if(!$.trim($('#t_name').val())) {
  34. layer.confirm('请输入客户姓名!', {
  35. icon: 2,
  36. btn: ['确定']
  37. });
  38. return;
  39. }
  40. if($.trim($('#t_mobile').val())){
  41. if(!telreg.test($.trim($('#t_mobile').val()))) {
  42. layer.confirm('请输入正确的手机号!', {
  43. icon: 2,
  44. btn: ['确定']
  45. });
  46. return;
  47. }
  48. }
  49. $.post(huayi.config.callcenter_url + "Customer/AddCustomer", {
  50. id: cid, //int 否 修改时不需要,默认为0
  51. cusname: $('#t_name').val(), // string 是 姓名
  52. mobile: $('#t_mobile').val(),// string 否 手机号
  53. F_SaleOffice: $('#F_SaleOffice').val(),// string 营业部
  54. F_AccessTime: $('#F_AccessTime').val(),// string 入网时间
  55. F_BroadbandAccount: $('#F_BroadbandAccount').val(),// 宽带账号
  56. F_Channel: $('#F_Channel').val(),// 入网渠道
  57. F_Fusion: $('#F_Fusion').val(),// 是否融合
  58. token: $.cookie("token")
  59. }, function(result) {
  60. result = $.parseJSON(result);
  61. if(result.state.toLowerCase() == "success") {
  62. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  63. parent.layer.close(index); //再执行关闭
  64. parent.initTable();
  65. parent.layer.msg("保存成功");
  66. }
  67. });
  68. }
  69. //获取信息
  70. function getCustomer(cid) {
  71. $.getJSON(huayi.config.callcenter_url + 'Customer/GetCustomer', {
  72. cid: cid,
  73. token: $.cookie("token")
  74. }, function(result) {
  75. if(result.state.toLowerCase() == "success") {
  76. var res = result.data;
  77. if(res) {
  78. $('#t_name').val(res.cusname); //姓名
  79. $("#t_mobile").val(res.mobile); //手机号
  80. $('#F_SaleOffice').val(res.F_SaleOffice)
  81. $('#F_AccessTime').val(res.F_AccessTime)
  82. $('#F_BroadbandAccount').val(res.F_BroadbandAccount)
  83. $('#F_Channel').val(res.F_Channel)
  84. $('#F_Fusion').val(res.F_Fusion)
  85. }
  86. }
  87. })
  88. }