安图前端代码

AddWorkOrder.js 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. var ns;
  2. var id = helper.request.queryString("id");
  3. var phone = helper.request.queryString("phone");
  4. var depName = helper.request.queryString("depName");
  5. var name = helper.request.queryString("name");
  6. var objs = {};
  7. $.ajax({
  8. type: "get",
  9. url: huayi.config.callcenter_url + "CallInScreen/GetCurrUserDep",
  10. dataType: 'json',
  11. async: true,
  12. data: {
  13. token: $.cookie("token")
  14. },
  15. success: function(data) {
  16. if(data.state.toLowerCase() == 'success') {
  17. if(data.data.groname == '客服组') {
  18. //console.log(data.data.groname)
  19. $('.customerService').show();
  20. ns = 1;
  21. } else {
  22. $('.market').show();
  23. ns = 2;
  24. }
  25. }
  26. }
  27. });
  28. if(id) {
  29. $("#CallID").val(id);
  30. $("#tel").val(phone);
  31. $("#tel_market").val(phone);
  32. if(unescape(decodeURI(name)) != 'null' && unescape(decodeURI(name)) != 'undefined') {
  33. $("#name_market").val(unescape(decodeURI(name)));
  34. $("#name").val(unescape(decodeURI(name)));
  35. }
  36. if(unescape(decodeURI(depName)) != 'null' && unescape(decodeURI(depName)) != 'undefined') {
  37. $("#testInput1").val(unescape(decodeURI(depName)));
  38. $("#testInput3").val(unescape(decodeURI(depName)));
  39. }
  40. }
  41. $(document).ready(function() {
  42. //工单来源
  43. getOrderSource('#orderSource');
  44. //工单类型
  45. getOrderType();
  46. //工单状态
  47. getOrderState();
  48. //来电单位
  49. getAccount('#comeCall_dep');
  50. // getAccount('#comeCall_dep_market');
  51. getAccount('#feedbackDep');
  52. // getAccount('#feedbackDep_market');
  53. //编辑器配置 客服部
  54. KindEditor.ready(function(K) {
  55. window.changeEditor = K.create('#feedBackCon'); //修改弹出框编辑器
  56. })
  57. //编辑器配置 市场部 备注
  58. KindEditor.ready(function(K) {
  59. window.marketEditor = K.create('#remark_market');
  60. })
  61. //保存
  62. $('.customerSubmit').click(function() {
  63. saveCustomer();
  64. })
  65. $('.marketSubmit').click(function() {
  66. saveMarket();
  67. })
  68. })
  69. //工单类型
  70. function getOrderType() {
  71. $.get(huayi.config.callcenter_url + 'WorkType/GetTreeList', {
  72. "token": $.cookie("token"),
  73. }, function(result) {
  74. result = $.parseJSON(result);
  75. $.fn.zTree.init($("#TreeDemo"), setting3, result.data); //实例化树形图
  76. });
  77. }
  78. var setting3 = {
  79. data: {
  80. key: {
  81. name: "text"
  82. },
  83. simpleData: {
  84. enable: true,
  85. idKey: "id",
  86. rootPId: 0
  87. }
  88. },
  89. callback: {
  90. onClick: changeTreeClick
  91. }
  92. }
  93. function changeTreeClick(event, treeId, treeNode) {
  94. var chanId = treeNode.id;
  95. var changeName = treeNode.text;
  96. $('#typeclass').val(changeName);
  97. $('#typeclassId').val(chanId);
  98. var pidnode = treeNode.getParentNode();
  99. $('.addTree').hide();
  100. };
  101. $('.down').click(function() {
  102. if($('.treeList').css('display') == 'block') {
  103. $('.treeList').css('display', 'none')
  104. } else {
  105. $('.treeList').css('display', 'block')
  106. }
  107. })
  108. $('#typeclass').click(function() {
  109. $('.treeList').css('display', 'block')
  110. })
  111. $('.treeList').mouseleave(function() {
  112. $(this).css('display', 'none')
  113. })
  114. //工单状态
  115. function getOrderState() {
  116. $.ajax({
  117. url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
  118. type: 'get',
  119. async: true,
  120. data: {
  121. flag: 'GDZT',
  122. token: $.cookie("token")
  123. },
  124. dataType: "json",
  125. success: function(res) {
  126. if(res.state == "success") {
  127. //console.log(res.data);
  128. $('<option value="">全部</option>').appendTo($("#State"));
  129. $(res.data).each(function(i, n) {
  130. if(n.F_DictionaryValueId == '472') {
  131. $('<option value="' + n.F_DictionaryValueId + '" selected="selected">' + n.F_Name + '</option>').appendTo($("#State"));
  132. } else {
  133. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#State"));
  134. }
  135. })
  136. //
  137. }
  138. }
  139. })
  140. }
  141. //工单来源
  142. function getOrderSource(obj) {
  143. $.ajax({
  144. type: "get",
  145. url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
  146. dataType: 'json',
  147. async: true,
  148. data: {
  149. token: $.cookie("token"),
  150. flag: "GDLY"
  151. },
  152. success: function(data) {
  153. var Count = data.data;
  154. $('<option value="">全部</option>').appendTo($("#DicValueList"));
  155. $(Count).each(function(i, n) {
  156. if(n.F_DictionaryValueId == "468") {
  157. $('<option value="' + n.F_DictionaryValueId + '" selected="selected">' + n.F_Name + '</option>').appendTo($("#DicValueList"));
  158. } else {
  159. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#DicValueList"));
  160. }
  161. })
  162. }
  163. });
  164. }
  165. //来电单位
  166. function getAccount(obj) {
  167. $.ajax({
  168. type: "get",
  169. url: huayi.config.callcenter_url + "Customer/BindLDdep",
  170. dataType: 'json',
  171. async: true,
  172. data: {
  173. token: $.cookie("token")
  174. },
  175. success: function(data) {
  176. var Count = data.data.dep;
  177. $(Count).each(function(i, n) {
  178. $("<option value='" + n + "'>" + n + "</option>").appendTo($(obj));
  179. })
  180. // $(obj).selectpicker('refresh');
  181. }
  182. });
  183. }
  184. function saveCustomer() {
  185. if($('#name').val() == '') {
  186. layer.confirm('请输入姓名!', {
  187. icon: 2,
  188. btn: ['确定']
  189. });
  190. return;
  191. }
  192. if($('#tel').val() == '') {
  193. layer.confirm('请输入电话!', {
  194. icon: 2,
  195. btn: ['确定']
  196. });
  197. return;
  198. }
  199. if($.trim($('#testInput1').val()) == '') {
  200. layer.confirm('请选择来电单位!', {
  201. icon: 2,
  202. btn: ['确定']
  203. });
  204. return;
  205. }
  206. if($.trim($('#testInput2').val()) == '') {
  207. layer.confirm('请选择反馈单位!', {
  208. icon: 2,
  209. btn: ['确定']
  210. });
  211. return;
  212. }
  213. if($('#orderSource').val() == '') {
  214. layer.confirm('请选择工单来源!', {
  215. icon: 2,
  216. btn: ['确定']
  217. });
  218. return;
  219. }
  220. if($('#State').val() == '') {
  221. layer.confirm('请选择工单状态!', {
  222. icon: 2,
  223. btn: ['确定']
  224. });
  225. return;
  226. }
  227. if($('#typeclassId').val() == '') {
  228. layer.confirm('请选择工单类型!', {
  229. icon: 2,
  230. btn: ['确定']
  231. });
  232. return;
  233. }
  234. $.ajax({
  235. type: "post",
  236. url: huayi.config.callcenter_url + "CallInScreen/AddWorkOrder",
  237. dataType: 'json',
  238. async: true,
  239. beforeSend: function() { //触发ajax请求开始时执行
  240. $('.customerSubmit').attr("disabled", true);
  241. $('.customerSubmit').text('保存中...');
  242. },
  243. data: {
  244. token: $.cookie("token"),
  245. callCustomer: $('#name').val(), //姓名
  246. tel: $('#tel').val(), //号码
  247. lddep: $('#testInput1').val(), //来电单位
  248. fkdep: $('#testInput2').val(), //反馈单位
  249. gdly: $('#DicValueList').val(), //工单来源
  250. gdlx: $('#typeclassId').val(), //工单类型id
  251. gdzt: $('#State').val(), //工单状态id
  252. province: $("#Province").val(),
  253. fkcont: encodeURIComponent(changeEditor.html()), //反馈内容
  254. sendmsg: $('#express').val(), //快递信息
  255. note1: $('#remark1').val(), //备注一
  256. note2: $('#remark2').val(), //备注二
  257. note3: $('#remark3').val(), //备注三
  258. callid: $("#CallID").val()
  259. },
  260. success: function(data) {
  261. if(data.state.toLowerCase() == 'success') {
  262. layer.msg("保存成功!");
  263. clear();
  264. $('.customerSubmit').attr("disabled", false);
  265. $('.customerSubmit').text('保存');
  266. }
  267. }
  268. });
  269. }
  270. function saveMarket() {
  271. if($('#name_market').val() == '') {
  272. layer.confirm('请输入姓名!', {
  273. icon: 2,
  274. btn: ['确定']
  275. });
  276. return;
  277. }
  278. if($('#tel_market').val() == '') {
  279. layer.confirm('请输入电话!', {
  280. icon: 2,
  281. btn: ['确定']
  282. });
  283. return;
  284. }
  285. if($.trim($('#testInput3').val()) == '') {
  286. layer.confirm('请选择来电单位!', {
  287. icon: 2,
  288. btn: ['确定']
  289. });
  290. return;
  291. }
  292. $.ajax({
  293. type: "post",
  294. url: huayi.config.callcenter_url + "CallInScreen/AddWorkOrder",
  295. dataType: 'json',
  296. async: true,
  297. beforeSend: function() { //触发ajax请求开始时执行
  298. $('.marketSubmit').attr("disabled", true);
  299. $('.marketSubmit').text('保存中...');
  300. },
  301. data: {
  302. token: $.cookie("token"),
  303. callCustomer: $('#name_market').val(), //姓名
  304. tel: $('#tel_market').val(), //号码
  305. lddep: $('#LDunit_').val(), //来电单位
  306. fkdep: $('#FKunit_').val(), //反馈单位
  307. fkcont: encodeURIComponent(marketEditor.html()), //反馈内容
  308. callid: $("#CallID").val()
  309. },
  310. success: function(data) {
  311. if(data.state.toLowerCase() == 'success') {
  312. layer.msg("保存成功!");
  313. clear();
  314. $('.marketSubmit').attr("disabled", false);
  315. $('.marketSubmit').text('保存');
  316. }
  317. }
  318. });
  319. }
  320. function clear() {
  321. if(ns == 1) {
  322. $('#name').val('');
  323. $('#tel').val(''); //号码
  324. $('#testInput1').val(''); //来电单位
  325. $('#testInput2').val(''); //反馈单位
  326. $('#orderSource').val(''); //工单来源
  327. $('#typeclassId').val(''); //工单类型id
  328. $('#State').val(''); //工单状态id
  329. $('#feedBackCon').val(''); //反馈内容
  330. $('#express').val(''); //快递信息
  331. $('#remark1').val(''); //备注一
  332. $('#remark2').val(''); //备注二
  333. $('#remark3').val(''); //备注三
  334. $('#typeclass').val('');
  335. changeEditor.html('');
  336. } else {
  337. $('#name_market').val('');
  338. $('#tel_market').val(''); //号码
  339. $('#testInput3').val(''); //来电单位
  340. $('#testInput4').val(''); //反馈单位
  341. $('#remark_market').val(''); //备注内容
  342. marketEditor.html('');
  343. }
  344. }