安图前端代码

AddWorkOrder.js 10KB

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