Geen omschrijving

WorkOrderTransfer.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. var id = helper.request.queryString("id");
  2. var type = helper.request.queryString("type");
  3. $(document).ready(function () {
  4. // 获取部门
  5. getDepartment($("#customer_department"));
  6. //保存
  7. $('.customerSubmit').click(function() {
  8. saveCustomer();
  9. });
  10. })
  11. //办事处 提交人
  12. function getDepartment(obj) {
  13. obj.empty();
  14. obj.append('<option selected="selected" value="">请选择</option>');
  15. $.getJSON(huayi.config.callcenter_url + "Department/GetCusAreaList", {
  16. "token": $.cookie("token"),
  17. pid: 1,
  18. F_Layer: 1,
  19. }, function (data) {
  20. if (data.state.toLowerCase() == "success") {
  21. var content = data.data;
  22. $(content).each(function (i, n) {
  23. $("<option value='" + n.F_DeptId + "'>" + n.F_DeptName + "</option>").appendTo(obj);
  24. })
  25. }
  26. })
  27. }
  28. //部门
  29. //function getDepartment(obj) {
  30. // obj.empty();
  31. // obj.append('<option selected="selected" value="">请选择</option>');
  32. // $.getJSON(huayi.config.callcenter_url + "Department/GetSubordinate", {
  33. // "token": $.cookie("token"),
  34. // }, function (data) {
  35. // if (data.state.toLowerCase() == "success") {
  36. // var content = data.data[0].children;
  37. // $(content).each(function (i, n) {
  38. // $("<option value='" + n.id + "'>" + n.text + "</option>").appendTo(obj);
  39. // })
  40. // }
  41. // })
  42. //}
  43. //业务员
  44. function getSalesman(obj) {
  45. obj.empty();
  46. obj.append('<option selected="selected" value="" deptId="">请选择</option>');
  47. $.getJSON(huayi.config.callcenter_url + "UserAccount/GetList", {
  48. "token": $.cookie("token"),
  49. type: 2,
  50. dptid: $("#customer_department").val(),
  51. }, function (data) {
  52. var content = data.rows;
  53. $(content).each(function (i, n) {
  54. $("<option value='" + n.F_UserId + "'deptId='" + n.F_DeptId + "'>" + n.F_UserName + "</option>").appendTo(obj);
  55. })
  56. })
  57. }
  58. //获取经理
  59. function getManager(obj) {
  60. obj.empty();
  61. obj.append('<option selected="selected" value="" deptId="">请选择</option>');
  62. $.getJSON(huayi.config.callcenter_url + "UserAccount/GetList", {
  63. "token": $.cookie("token"),
  64. type: 1,
  65. dptid: $("#customer_department").val(),
  66. }, function (data) {
  67. var content = data.rows;
  68. $(content).each(function (i, n) {
  69. $("<option value='" + n.F_UserId + "'deptId='" + n.F_DeptId + "'>" + n.F_UserName + "</option>").appendTo(obj);
  70. })
  71. })
  72. }
  73. // 获取提交人
  74. $('#customer_department').on('change',function(){
  75. console.log('type',type,typeof(type))
  76. if (type === "1") {
  77. getManager($('#customer_submitter'));
  78. } else if (type === "2") {
  79. getSalesman($('#customer_submitter'));
  80. }
  81. });
  82. //保存
  83. function saveCustomer() {
  84. $.ajax({
  85. type: "post",
  86. url: huayi.config.callcenter_url + "WorkOrder/Submission",
  87. dataType: 'json',
  88. async: true,
  89. beforeSend: function() { //触发ajax请求开始时执行
  90. $('.customerSubmit').attr("disabled", true);
  91. $('.customerSubmit').text('保存中...');
  92. },
  93. data: {
  94. token: $.cookie("token"),
  95. id: id,
  96. cont: $('#cont').val(), //提交内容
  97. clid: $('#customer_submitter').val(), // 提交人
  98. type: type,
  99. },
  100. success: function(data) {
  101. if (data.state.toLowerCase() == 'success') {
  102. $('.customerSubmit').attr("disabled", false);
  103. $('.customerSubmit').text('确定');
  104. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  105. parent.layer.close(index); //再执行关闭
  106. parent.layer.msg("保存成功!");
  107. // parent.$('#workorderlist').bootstrapTable('refresh');
  108. parent.initTable();
  109. } else {
  110. $('.customerSubmit').attr("disabled", false);
  111. $('.customerSubmit').text('确定');
  112. }
  113. }
  114. });
  115. }