安图前端代码

AddWorkOrder.js 8.8KB

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