安图前端代码

AddWorkOrder.js 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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('#orderSource');
  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. });
  76. }
  77. var setting3 = {
  78. data: {
  79. key: {
  80. name: "text"
  81. },
  82. simpleData: {
  83. enable: true,
  84. idKey: "id",
  85. rootPId: 0
  86. }
  87. },
  88. callback: {
  89. onClick: changeTreeClick
  90. }
  91. }
  92. function changeTreeClick(event, treeId, treeNode) {
  93. var chanId = treeNode.id;
  94. var changeName = treeNode.text;
  95. $('#typeclass').val(changeName);
  96. $('#typeclassId').val(chanId);
  97. var pidnode = treeNode.getParentNode();
  98. $('.addTree').hide();
  99. };
  100. $('.down').click(function() {
  101. if($('.treeList').css('display') == 'block') {
  102. $('.treeList').css('display', 'none')
  103. } else {
  104. $('.treeList').css('display', 'block')
  105. }
  106. })
  107. $('#typeclass').click(function() {
  108. $('.treeList').css('display', 'block')
  109. })
  110. $('.treeList').mouseleave(function() {
  111. $(this).css('display', 'none')
  112. })
  113. //工单状态
  114. function getOrderState() {
  115. $.ajax({
  116. url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
  117. type: 'get',
  118. async: true,
  119. data: {
  120. flag: 'GDZT',
  121. token: $.cookie("token")
  122. },
  123. dataType: "json",
  124. success: function(res) {
  125. if(res.state == "success") {
  126. //console.log(res.data);
  127. $('<option value="">全部</option>').appendTo($("#State"));
  128. $(res.data).each(function(i, n) {
  129. if(n.F_DictionaryValueId == '472') {
  130. $('<option value="' + n.F_DictionaryValueId + '" selected="selected">' + n.F_Name + '</option>').appendTo($("#State"));
  131. } else {
  132. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#State"));
  133. }
  134. })
  135. //
  136. }
  137. }
  138. })
  139. }
  140. //工单来源
  141. function getOrderSource(obj) {
  142. $.ajax({
  143. type: "get",
  144. url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
  145. dataType: 'json',
  146. async: true,
  147. data: {
  148. token: $.cookie("token"),
  149. flag: "GDLY"
  150. },
  151. success: function(data) {
  152. var Count = data.data;
  153. $('<option value="">全部</option>').appendTo($("#DicValueList"));
  154. $(Count).each(function(i, n) {
  155. if(n.F_DictionaryValueId == "468") {
  156. $('<option value="' + n.F_DictionaryValueId + '" selected="selected">' + n.F_Name + '</option>').appendTo($("#DicValueList"));
  157. } else {
  158. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#DicValueList"));
  159. }
  160. })
  161. }
  162. });
  163. }
  164. //来电单位
  165. $('#testInput1').comboSelect();
  166. $('#testInput2').comboSelect();
  167. $('#testInput3').comboSelect();
  168. $('#testInput4').comboSelect();
  169. function BindLDdep(obj1,obj2,obj3,obj4) {
  170. $.ajax({
  171. type: "get",
  172. url: huayi.config.callcenter_url + "Customer/BindLDdep",
  173. dataType: 'json',
  174. async: false,
  175. data: {
  176. // keypara: str,
  177. token: $.cookie("token")
  178. },
  179. success: function(data) {
  180. var Count = data.data.dep;
  181. var html = '';
  182. $(Count).each(function(i, n) {
  183. html = "<option value='" + n + "'>" + n + "</option>";
  184. $(html).appendTo(obj1);
  185. $(html).appendTo(obj2);
  186. $(html).appendTo(obj3);
  187. $(html).appendTo(obj4);
  188. });
  189. obj1.comboSelect();
  190. obj2.comboSelect();
  191. obj3.comboSelect();
  192. obj4.comboSelect();
  193. }
  194. });
  195. };
  196. function saveCustomer() {
  197. if($('#name').val() == '') {
  198. layer.confirm('请输入姓名!', {
  199. icon: 2,
  200. btn: ['确定']
  201. });
  202. return;
  203. }
  204. if($('#tel').val() == '') {
  205. layer.confirm('请输入电话!', {
  206. icon: 2,
  207. btn: ['确定']
  208. });
  209. return;
  210. }
  211. if($.trim($('#testInput1_input').val()) == '') {
  212. layer.confirm('请选择来电单位!', {
  213. icon: 2,
  214. btn: ['确定']
  215. });
  216. return;
  217. }
  218. if($.trim($('#testInput2_input').val()) == '') {
  219. layer.confirm('请选择反馈单位!', {
  220. icon: 2,
  221. btn: ['确定']
  222. });
  223. return;
  224. }
  225. if($('#orderSource').val() == '') {
  226. layer.confirm('请选择工单来源!', {
  227. icon: 2,
  228. btn: ['确定']
  229. });
  230. return;
  231. }
  232. if($('#State').val() == '') {
  233. layer.confirm('请选择工单状态!', {
  234. icon: 2,
  235. btn: ['确定']
  236. });
  237. return;
  238. }
  239. if($('#typeclassId').val() == '') {
  240. layer.confirm('请选择工单类型!', {
  241. icon: 2,
  242. btn: ['确定']
  243. });
  244. return;
  245. }
  246. $.ajax({
  247. type: "post",
  248. url: huayi.config.callcenter_url + "CallInScreen/AddWorkOrder",
  249. dataType: 'json',
  250. async: true,
  251. beforeSend: function() { //触发ajax请求开始时执行
  252. $('.customerSubmit').attr("disabled", true);
  253. $('.customerSubmit').text('保存中...');
  254. },
  255. data: {
  256. token: $.cookie("token"),
  257. callCustomer: $('#name').val(), //姓名
  258. tel: $('#tel').val(), //号码
  259. lddep: $('#testInput1_input').val(), //来电单位
  260. fkdep: $('#testInput2_input').val(), //反馈单位
  261. gdly: $('#DicValueList').val(), //工单来源
  262. gdlx: $('#typeclassId').val(), //工单类型id
  263. gdzt: $('#State').val(), //工单状态id
  264. province: $("#Province").val(),
  265. fkcont: encodeURIComponent(changeEditor.html()), //反馈内容
  266. sendmsg: $('#express').val(), //快递信息
  267. note1: $('#remark1').val(), //备注一
  268. note2: $('#remark2').val(), //备注二
  269. note3: $('#remark3').val(), //备注三
  270. callid: $("#CallID").val()
  271. },
  272. success: function(data) {
  273. if(data.state.toLowerCase() == 'success') {
  274. layer.msg("保存成功!");
  275. clear();
  276. $('.customerSubmit').attr("disabled", false);
  277. $('.customerSubmit').text('保存');
  278. }
  279. }
  280. });
  281. }
  282. function saveMarket() {
  283. if($('#name_market').val() == '') {
  284. layer.confirm('请输入姓名!', {
  285. icon: 2,
  286. btn: ['确定']
  287. });
  288. return;
  289. }
  290. if($('#tel_market').val() == '') {
  291. layer.confirm('请输入电话!', {
  292. icon: 2,
  293. btn: ['确定']
  294. });
  295. return;
  296. }
  297. if($.trim($('#testInput3_input').val()) == '') {
  298. layer.confirm('请选择来电单位!', {
  299. icon: 2,
  300. btn: ['确定']
  301. });
  302. return;
  303. }
  304. $.ajax({
  305. type: "post",
  306. url: huayi.config.callcenter_url + "CallInScreen/AddWorkOrder",
  307. dataType: 'json',
  308. async: true,
  309. beforeSend: function() { //触发ajax请求开始时执行
  310. $('.marketSubmit').attr("disabled", true);
  311. $('.marketSubmit').text('保存中...');
  312. },
  313. data: {
  314. token: $.cookie("token"),
  315. callCustomer: $('#name_market').val(), //姓名
  316. tel: $('#tel_market').val(), //号码
  317. lddep: $('#LDunit_').val(), //来电单位
  318. fkdep: $('#FKunit_').val(), //反馈单位
  319. fkcont: encodeURIComponent(marketEditor.html()), //反馈内容
  320. callid: $("#CallID").val()
  321. },
  322. success: function(data) {
  323. if(data.state.toLowerCase() == 'success') {
  324. layer.msg("保存成功!");
  325. clear();
  326. $('.marketSubmit').attr("disabled", false);
  327. $('.marketSubmit').text('保存');
  328. }
  329. }
  330. });
  331. }
  332. function clear() {
  333. if(ns == 1) {
  334. $('#name').val('');
  335. $('#tel').val(''); //号码
  336. $('#testInput1_input').val(''); //来电单位
  337. $('#testInput2_input').val(''); //反馈单位
  338. $('#orderSource').val(''); //工单来源
  339. $('#typeclassId').val(''); //工单类型id
  340. $('#State').val(''); //工单状态id
  341. $('#feedBackCon').val(''); //反馈内容
  342. $('#express').val(''); //快递信息
  343. $('#remark1').val(''); //备注一
  344. $('#remark2').val(''); //备注二
  345. $('#remark3').val(''); //备注三
  346. $('#typeclass').val('');
  347. changeEditor.html('');
  348. } else {
  349. $('#name_market').val('');
  350. $('#tel_market').val(''); //号码
  351. $('#testInput3_input').val(''); //来电单位
  352. $('#testInput4_input').val(''); //反馈单位
  353. $('#remark_market').val(''); //备注内容
  354. marketEditor.html('');
  355. }
  356. }