思念食品 UI

AddWorkOrder.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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. if(unescape(decodeURI(depName)) != 'null' && unescape(decodeURI(depName)) != 'undefined') {
  64. $("#testInput1_input").val(unescape(decodeURI(depName)));
  65. $("#testInput3_input").val(unescape(decodeURI(depName)));
  66. BindLDdep($("#testInput1"),$("#testInput2"),$("#testInput3"),$("#testInput4"),unescape(decodeURI(depName)))
  67. }else{
  68. BindLDdep($("#testInput1"),$("#testInput2"),$("#testInput3"),$("#testInput4"),'')
  69. }
  70. }else{
  71. BindLDdep($("#testInput1"),$("#testInput2"),$("#testInput3"),$("#testInput4"),'');
  72. }
  73. })
  74. //工单类型
  75. function getOrderType() {
  76. $.get(huayi.config.callcenter_url + 'WorkType/GetTreeList', {
  77. "token": $.cookie("token"),
  78. }, function(result) {
  79. result = $.parseJSON(result);
  80. $.fn.zTree.init($("#TreeDemo"), setting3, result.data); //实例化树形图
  81. $.fn.zTree.init($("#TreeDemo_market"), setting3, result.data); //实例化树形图
  82. });
  83. }
  84. var setting3 = {
  85. data: {
  86. key: {
  87. name: "text"
  88. },
  89. simpleData: {
  90. enable: true,
  91. idKey: "id",
  92. rootPId: 0
  93. }
  94. },
  95. callback: {
  96. onClick: changeTreeClick
  97. }
  98. }
  99. function changeTreeClick(event, treeId, treeNode) {
  100. var chanId = treeNode.id;
  101. var changeName = treeNode.text;
  102. $('#typeclass').val(changeName);
  103. $('#typeclass_market ').val(changeName);
  104. $('#typeclassId').val(chanId);
  105. $('#typeclassId_market').val(chanId);
  106. var pidnode = treeNode.getParentNode();
  107. $('.addTree').hide();
  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,res1) {
  182. $.ajax({
  183. type: "get",
  184. url: huayi.config.callcenter_url + "Customer/BindLDdep",
  185. dataType: 'json',
  186. async: true,
  187. data: {
  188. // keypara: str,
  189. token: $.cookie("token")
  190. },
  191. success: function(data) {
  192. var Count = data.data.dep;
  193. var html = '',html2 = '';
  194. if(res1){
  195. $("<option value='" + res1 + "' selected>" + res1 + "</option>").appendTo(obj1);
  196. $("<option value='" + res1 + "' selected>" + res1 + "</option>").appendTo(obj3);
  197. }
  198. $(Count).each(function(i, n) {
  199. html = "<option value='" + n + "'>" + n + "</option>";
  200. if(n!==res1){
  201. html2 = "<option value='" + n + "'>" + n + "</option>";
  202. }
  203. $(html2).appendTo(obj1);
  204. $(html2).appendTo(obj3);
  205. $(html).appendTo(obj2);
  206. $(html).appendTo(obj4);
  207. });
  208. obj1.comboSelect();
  209. obj2.comboSelect();
  210. obj3.comboSelect();
  211. obj4.comboSelect();
  212. }
  213. });
  214. };
  215. //客服部保存
  216. function saveCustomer() {
  217. if($('#name').val() == '') {
  218. layer.confirm('请输入姓名!', {
  219. icon: 2,
  220. btn: ['确定']
  221. });
  222. return;
  223. }
  224. if($('#tel').val() == '') {
  225. layer.confirm('请输入电话!', {
  226. icon: 2,
  227. btn: ['确定']
  228. });
  229. return;
  230. }
  231. if($.trim($('#testInput1_input').val()) == '') {
  232. layer.confirm('请选择来电单位!', {
  233. icon: 2,
  234. btn: ['确定']
  235. });
  236. return;
  237. }
  238. if($.trim($('#testInput2_input').val()) == '') {
  239. layer.confirm('请选择反馈单位!', {
  240. icon: 2,
  241. btn: ['确定']
  242. });
  243. return;
  244. }
  245. if($('#DicValueList').val() == '') {
  246. layer.confirm('请选择工单来源!', {
  247. icon: 2,
  248. btn: ['确定']
  249. });
  250. return;
  251. }
  252. if($('#State').val() == '') {
  253. layer.confirm('请选择工单状态!', {
  254. icon: 2,
  255. btn: ['确定']
  256. });
  257. return;
  258. }
  259. if($('#typeclassId').val() == '') {
  260. layer.confirm('请选择工单类型!', {
  261. icon: 2,
  262. btn: ['确定']
  263. });
  264. return;
  265. }
  266. $.ajax({
  267. type: "post",
  268. url: huayi.config.callcenter_url + "CallInScreen/AddWorkOrder",
  269. dataType: 'json',
  270. async: true,
  271. beforeSend: function() { //触发ajax请求开始时执行
  272. $('.customerSubmit').attr("disabled", true);
  273. $('.customerSubmit').text('保存中...');
  274. },
  275. data: {
  276. token: $.cookie("token"),
  277. callCustomer: $('#name').val(), //姓名
  278. tel: $('#tel').val(), //号码
  279. lddep: $('#testInput1_input').val(), //来电单位
  280. fkdep: $('#testInput2_input').val(), //反馈单位
  281. gdly: $('#DicValueList').val(), //工单来源
  282. gdlx: $('#typeclassId').val(), //工单类型id
  283. gdzt: $('#State').val(), //工单状态id
  284. province: $("#Province").val(),
  285. fkcont: helper.HtmlUtil.htmlEncodeByRegExp(changeEditor.html()), //反馈内容
  286. sendmsg: $('#express').val(), //快递信息
  287. note1: $('#remark1').val(), //备注一
  288. note2: $('#remark2').val(), //备注二
  289. note3: $('#remark3').val(), //备注三
  290. callid: $("#CallID").val()
  291. },
  292. success: function(data) {
  293. if(data.state.toLowerCase() == 'success') {
  294. layer.msg("保存成功!");
  295. clear();
  296. $('.customerSubmit').attr("disabled", false);
  297. $('.customerSubmit').text('保存');
  298. }
  299. }
  300. });
  301. }
  302. // 市场部保存
  303. function saveMarket() {
  304. if($('#name_market').val() == '') {
  305. layer.confirm('请输入姓名!', {
  306. icon: 2,
  307. btn: ['确定']
  308. });
  309. return;
  310. }
  311. if($('#tel_market').val() == '') {
  312. layer.confirm('请输入电话!', {
  313. icon: 2,
  314. btn: ['确定']
  315. });
  316. return;
  317. }
  318. if($.trim($('#testInput3_input').val()) == '') {
  319. layer.confirm('请选择来电单位!', {
  320. icon: 2,
  321. btn: ['确定']
  322. });
  323. return;
  324. }
  325. if($.trim($('#testInput4_input').val()) == '') {
  326. layer.confirm('请选择反馈单位!', {
  327. icon: 2,
  328. btn: ['确定']
  329. });
  330. return;
  331. }
  332. if($('#DicValueList_market').val() == '') {
  333. layer.confirm('请选择工单来源!', {
  334. icon: 2,
  335. btn: ['确定']
  336. });
  337. return;
  338. }
  339. if($('#typeclassId_market').val() == '') {
  340. layer.confirm('请选择工单类型!', {
  341. icon: 2,
  342. btn: ['确定']
  343. });
  344. return;
  345. }
  346. $.ajax({
  347. type: "post",
  348. url: huayi.config.callcenter_url + "CallInScreen/AddWorkOrder",
  349. dataType: 'json',
  350. async: true,
  351. beforeSend: function() { //触发ajax请求开始时执行
  352. $('.marketSubmit').attr("disabled", true);
  353. $('.marketSubmit').text('保存中...');
  354. },
  355. data: {
  356. token: $.cookie("token"),
  357. callCustomer: $('#name_market').val(), //姓名
  358. tel: $('#tel_market').val(), //号码
  359. lddep: $('#testInput3_input').val(), //来电单位
  360. fkdep: $('#testInput4_input').val(), //反馈单位
  361. gdly: $('#DicValueList_market').val(), //工单来源
  362. gdlx: $('#typeclassId_market').val(), //工单类型id
  363. fkcont: helper.HtmlUtil.htmlEncodeByRegExp(marketEditor.html()), //反馈内容
  364. callid: $("#CallID").val()
  365. },
  366. success: function(data) {
  367. if(data.state.toLowerCase() == 'success') {
  368. layer.msg("保存成功!");
  369. clear();
  370. $('.marketSubmit').attr("disabled", false);
  371. $('.marketSubmit').text('保存');
  372. }
  373. }
  374. });
  375. }
  376. function clear() {
  377. if(ns == 1) {
  378. $('#name').val('');
  379. $('#tel').val(''); //号码
  380. $('#testInput1_input').val(''); //来电单位
  381. $('#testInput2_input').val(''); //反馈单位
  382. $('#orderSource').val(''); //工单来源
  383. $('#typeclassId').val(''); //工单类型id
  384. $('#State').val(''); //工单状态id
  385. $('#feedBackCon').val(''); //反馈内容
  386. $('#express').val(''); //快递信息
  387. $('#remark1').val(''); //备注一
  388. $('#remark2').val(''); //备注二
  389. $('#remark3').val(''); //备注三
  390. $('#typeclass').val('');
  391. changeEditor.html('');
  392. } else {
  393. $('#name_market').val('');
  394. $('#tel_market').val(''); //号码
  395. $('#testInput3_input').val(''); //来电单位
  396. $('#testInput4_input').val(''); //反馈单位
  397. $('#remark_market').val(''); //备注内容
  398. marketEditor.html('');
  399. }
  400. }