安图前端代码

AddWorkOrder.js 11KB

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