安图前端代码

AddWorkOrder.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  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. if (treeNode.level == 2) {
  101. var chanId = treeNode.id;
  102. var changeName = treeNode.text;
  103. $('#typeclass').val(changeName);
  104. $('#typeclass_market ').val(changeName);
  105. $('#typeclassId').val(chanId);
  106. $('#typeclassId_market').val(chanId);
  107. var pidnode = treeNode.getParentNode();
  108. $('.addTree').hide();
  109. }
  110. };
  111. $('.down').click(function() {
  112. if($('.treeList').css('display') == 'block') {
  113. $('.treeList').css('display', 'none')
  114. } else {
  115. $('.treeList').css('display', 'block')
  116. }
  117. })
  118. $('#typeclass').click(function() {
  119. $('.treeList').css('display', 'block')
  120. })
  121. $('.treeList').mouseleave(function() {
  122. $(this).css('display', 'none')
  123. })
  124. $('#typeclass_market').click(function() {
  125. $('.treeList_market').css('display', 'block')
  126. })
  127. $('.treeList_market').mouseleave(function() {
  128. $(this).css('display', 'none')
  129. })
  130. //工单状态
  131. function getOrderState() {
  132. $.ajax({
  133. url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
  134. type: 'get',
  135. async: true,
  136. data: {
  137. flag: 'GDZT',
  138. token: $.cookie("token")
  139. },
  140. dataType: "json",
  141. success: function(res) {
  142. if(res.state == "success") {
  143. //console.log(res.data);
  144. $('<option value="">全部</option>').appendTo($("#State"));
  145. $(res.data).each(function(i, n) {
  146. if(n.F_DictionaryValueId == '472') {
  147. $('<option value="' + n.F_DictionaryValueId + '" selected="selected">' + n.F_Name + '</option>').appendTo($("#State"));
  148. } else {
  149. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#State"));
  150. }
  151. })
  152. //
  153. }
  154. }
  155. })
  156. }
  157. //工单来源
  158. function getOrderSource(obj) {
  159. $.ajax({
  160. type: "get",
  161. url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
  162. dataType: 'json',
  163. async: true,
  164. data: {
  165. token: $.cookie("token"),
  166. flag: "GDLY"
  167. },
  168. success: function(data) {
  169. var Count = data.data;
  170. $('<option value="">全部</option>').appendTo($("#DicValueList"));
  171. $(Count).each(function(i, n) {
  172. if(n.F_DictionaryValueId == "468") {
  173. $('<option value="' + n.F_DictionaryValueId + '" selected="selected">' + n.F_Name + '</option>').appendTo($("#DicValueList"));
  174. $('<option value="' + n.F_DictionaryValueId + '" selected="selected">' + n.F_Name + '</option>').appendTo($("#DicValueList_market"));
  175. } else {
  176. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#DicValueList"));
  177. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#DicValueList_market"));
  178. }
  179. })
  180. }
  181. });
  182. }
  183. function BindLDdep(obj1,obj2,obj3,obj4,res1) {
  184. $.ajax({
  185. type: "get",
  186. url: huayi.config.callcenter_url + "Customer/BindLDdep",
  187. dataType: 'json',
  188. async: true,
  189. data: {
  190. // keypara: str,
  191. token: $.cookie("token")
  192. },
  193. success: function(data) {
  194. var Count = data.data.dep;
  195. var html = '',html2 = '';
  196. if(res1){
  197. $("<option value='" + res1 + "' selected>" + res1 + "</option>").appendTo(obj1);
  198. $("<option value='" + res1 + "' selected>" + res1 + "</option>").appendTo(obj3);
  199. }
  200. $(Count).each(function(i, n) {
  201. html = "<option value='" + n + "'>" + n + "</option>";
  202. if(n!==res1){
  203. html2 = "<option value='" + n + "'>" + n + "</option>";
  204. }
  205. $(html2).appendTo(obj1);
  206. $(html2).appendTo(obj3);
  207. $(html).appendTo(obj2);
  208. $(html).appendTo(obj4);
  209. });
  210. obj1.comboSelect();
  211. obj2.comboSelect();
  212. obj3.comboSelect();
  213. obj4.comboSelect();
  214. }
  215. });
  216. };
  217. //客服部保存
  218. console.log(window.name)
  219. function saveCustomer() {
  220. console.log(parent.layer.getFrameIndex);
  221. //var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  222. //parent.layer.close(); //再执行关闭
  223. parent.$('#list').bootstrapTable('refresh');
  224. return
  225. if($('#name').val() == '') {
  226. layer.confirm('请输入姓名!', {
  227. icon: 2,
  228. btn: ['确定']
  229. });
  230. return;
  231. }
  232. if($('#tel').val() == '') {
  233. layer.confirm('请输入电话!', {
  234. icon: 2,
  235. btn: ['确定']
  236. });
  237. return;
  238. }
  239. if($.trim($('#testInput1_input').val()) == '') {
  240. layer.confirm('请选择来电单位!', {
  241. icon: 2,
  242. btn: ['确定']
  243. });
  244. return;
  245. }
  246. if($.trim($('#testInput2_input').val()) == '') {
  247. layer.confirm('请选择反馈单位!', {
  248. icon: 2,
  249. btn: ['确定']
  250. });
  251. return;
  252. }
  253. if($('#DicValueList').val() == '') {
  254. layer.confirm('请选择工单来源!', {
  255. icon: 2,
  256. btn: ['确定']
  257. });
  258. return;
  259. }
  260. if($('#State').val() == '') {
  261. layer.confirm('请选择工单状态!', {
  262. icon: 2,
  263. btn: ['确定']
  264. });
  265. return;
  266. }
  267. if($('#typeclassId').val() == '') {
  268. layer.confirm('请选择工单类型!', {
  269. icon: 2,
  270. btn: ['确定']
  271. });
  272. return;
  273. }
  274. $.ajax({
  275. type: "post",
  276. url: huayi.config.callcenter_url + "CallInScreen/AddWorkOrder",
  277. dataType: 'json',
  278. async: true,
  279. beforeSend: function() { //触发ajax请求开始时执行
  280. $('.customerSubmit').attr("disabled", true);
  281. $('.customerSubmit').text('保存中...');
  282. },
  283. data: {
  284. token: $.cookie("token"),
  285. callCustomer: $('#name').val(), //姓名
  286. tel: $('#tel').val(), //号码
  287. lddep: $('#testInput1_input').val(), //来电单位
  288. fkdep: $('#testInput2_input').val(), //反馈单位
  289. gdly: $('#DicValueList').val(), //工单来源
  290. gdlx: $('#typeclassId').val(), //工单类型id
  291. gdzt: $('#State').val(), //工单状态id
  292. province: $("#Province").val(),
  293. fkcont: helper.HtmlUtil.htmlEncodeByRegExp(changeEditor.html()), //反馈内容
  294. sendmsg: $('#express').val(), //快递信息
  295. note1: $('#remark1').val(), //备注一
  296. note2: $('#remark2').val(), //备注二
  297. note3: $('#remark3').val(), //备注三
  298. callid: $("#CallID").val()
  299. },
  300. success: function(data) {
  301. if(data.state.toLowerCase() == 'success') {
  302. if (id) {
  303. var savemsgs = '保存成功';
  304. clear();
  305. $('.customerSubmit').attr("disabled", false);
  306. $('.customerSubmit').text('保存');
  307. parent.layer.msg(savemsgs);
  308. }else{
  309. layer.msg("保存成功!");
  310. clear();
  311. $('.customerSubmit').attr("disabled", false);
  312. $('.customerSubmit').text('保存');
  313. }
  314. }
  315. }
  316. });
  317. }
  318. // 市场部保存
  319. function saveMarket() {
  320. if($('#name_market').val() == '') {
  321. layer.confirm('请输入姓名!', {
  322. icon: 2,
  323. btn: ['确定']
  324. });
  325. return;
  326. }
  327. if($('#tel_market').val() == '') {
  328. layer.confirm('请输入电话!', {
  329. icon: 2,
  330. btn: ['确定']
  331. });
  332. return;
  333. }
  334. if($.trim($('#testInput3_input').val()) == '') {
  335. layer.confirm('请选择来电单位!', {
  336. icon: 2,
  337. btn: ['确定']
  338. });
  339. return;
  340. }
  341. if($.trim($('#testInput4_input').val()) == '') {
  342. layer.confirm('请选择反馈单位!', {
  343. icon: 2,
  344. btn: ['确定']
  345. });
  346. return;
  347. }
  348. if($('#DicValueList_market').val() == '') {
  349. layer.confirm('请选择工单来源!', {
  350. icon: 2,
  351. btn: ['确定']
  352. });
  353. return;
  354. }
  355. if($('#typeclassId_market').val() == '') {
  356. layer.confirm('请选择工单类型!', {
  357. icon: 2,
  358. btn: ['确定']
  359. });
  360. return;
  361. }
  362. $.ajax({
  363. type: "post",
  364. url: huayi.config.callcenter_url + "CallInScreen/AddWorkOrder",
  365. dataType: 'json',
  366. async: true,
  367. beforeSend: function() { //触发ajax请求开始时执行
  368. $('.marketSubmit').attr("disabled", true);
  369. $('.marketSubmit').text('保存中...');
  370. },
  371. data: {
  372. token: $.cookie("token"),
  373. callCustomer: $('#name_market').val(), //姓名
  374. tel: $('#tel_market').val(), //号码
  375. lddep: $('#testInput3_input').val(), //来电单位
  376. fkdep: $('#testInput4_input').val(), //反馈单位
  377. gdly: $('#DicValueList_market').val(), //工单来源
  378. gdlx: $('#typeclassId_market').val(), //工单类型id
  379. fkcont: helper.HtmlUtil.htmlEncodeByRegExp(marketEditor.html()), //反馈内容
  380. callid: $("#CallID").val()
  381. },
  382. success: function(data) {
  383. if(data.state.toLowerCase() == 'success') {
  384. layer.msg("保存成功!");
  385. clear();
  386. $('.marketSubmit').attr("disabled", false);
  387. $('.marketSubmit').text('保存');
  388. }
  389. }
  390. });
  391. }
  392. function clear() {
  393. if(ns == 1) {
  394. $('#name').val('');
  395. $('#tel').val(''); //号码
  396. $('#testInput1_input').val(''); //来电单位
  397. $('#testInput2_input').val(''); //反馈单位
  398. $('#orderSource').val(''); //工单来源
  399. $('#typeclassId').val(''); //工单类型id
  400. $('#State').val(''); //工单状态id
  401. $('#feedBackCon').val(''); //反馈内容
  402. $('#express').val(''); //快递信息
  403. $('#remark1').val(''); //备注一
  404. $('#remark2').val(''); //备注二
  405. $('#remark3').val(''); //备注三
  406. $('#typeclass').val('');
  407. changeEditor.html('');
  408. } else {
  409. $('#name_market').val('');
  410. $('#tel_market').val(''); //号码
  411. $('#testInput3_input').val(''); //来电单位
  412. $('#testInput4_input').val(''); //反馈单位
  413. $('#remark_market').val(''); //备注内容
  414. marketEditor.html('');
  415. }
  416. }