思念食品 UI

AddWorkOrder.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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: false,
  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. $('.market').remove();
  21. ns = 1;
  22. } else {
  23. $('.market').show();
  24. $('.customerService').remove();
  25. ns = 2;
  26. }
  27. }
  28. }
  29. });
  30. $(document).ready(function() {
  31. laydate.render({
  32. elem: '.userDate',
  33. theme: '#1ab394',
  34. calendar: 'true'
  35. });
  36. laydate.render({
  37. elem: '.buyDate',
  38. theme: '#1ab394',
  39. calendar: 'true'
  40. //type: 'datetime',
  41. //max : 31,
  42. //min: 0,
  43. });
  44. laydate.render({
  45. elem: '#proDuctdate',
  46. theme: '#1ab394',
  47. calendar: 'true'
  48. //type: 'datetime',
  49. //max : 31,
  50. //min: 0,
  51. });
  52. //工单来源
  53. getOrderSource();
  54. //工单类型
  55. getOrderType();
  56. //工单类型
  57. getOrderType1();
  58. //工单状态
  59. getOrderState();
  60. //客诉专员
  61. ComplaintVip();
  62. //来电单位
  63. $('#testInput1').comboSelect();
  64. $('#testInput2').comboSelect();
  65. $('#testInput3').comboSelect();
  66. $('#testInput4').comboSelect();
  67. //编辑器配置 客服部
  68. KindEditor.ready(function(K) {
  69. window.changeEditor = K.create('#feedBackCon'); //修改弹出框编辑器
  70. })
  71. //编辑器配置 市场部 备注
  72. KindEditor.ready(function(K) {
  73. window.marketEditor = K.create('#remark_market');
  74. })
  75. //保存
  76. $('.customerSubmit').click(function() {
  77. saveCustomer();
  78. })
  79. $('.marketSubmit').click(function() {
  80. saveMarket();
  81. })
  82. if(id) {
  83. $("#CallID").val(id);
  84. $("#tel").val(phone);
  85. $("#tel_market").val(phone);
  86. if(unescape(decodeURI(name)) != 'null' && unescape(decodeURI(name)) != 'undefined') {
  87. $("#name_market").val(unescape(decodeURI(name)));
  88. $("#name").val(unescape(decodeURI(name)));
  89. }
  90. if(unescape(decodeURI(depName)) != 'null' && unescape(decodeURI(depName)) != 'undefined') {
  91. $("#testInput1_input").val(unescape(decodeURI(depName)));
  92. $("#testInput3_input").val(unescape(decodeURI(depName)));
  93. }
  94. }
  95. })
  96. //工单类型
  97. function getOrderType() {
  98. $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', {
  99. "token": $.cookie("token"),
  100. flag: "GDLX"
  101. }, function(result) {
  102. result = $.parseJSON(result);
  103. var Count = result.data;
  104. $(Count).each(function(i, n) {
  105. if(ns==1){
  106. if(n.F_DictionaryValueId == "468") {
  107. $('<option value="' + n.F_DictionaryValueId + '" selected="selected">' + n.F_Name + '</option>').appendTo($(".orderType1"));
  108. } else {
  109. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($(".orderType1"));
  110. }
  111. }else if(ns==2){
  112. if(n.F_DictionaryValueId == "468") {
  113. $('<option value="' + n.F_DictionaryValueId + '" selected="selected">' + n.F_Name + '</option>').appendTo($(".orderType2"));
  114. } else {
  115. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($(".orderType2"));
  116. }
  117. }
  118. })
  119. });
  120. }
  121. //区域
  122. function getOrderType1() {
  123. $.get(huayi.config.callcenter_url + 'Area/GetAreaList', {
  124. // $.get('http://192.168.4.18:4625/Area/GetAreaList', {
  125. "token": $.cookie("token"),
  126. }, function(result) {
  127. result = $.parseJSON(result);
  128. $.fn.zTree.init($("#TreeDemo1"), setting4, result.data); //实例化树形图
  129. $.fn.zTree.init($("#TreeDemo_market1"), setting4, result.data); //实例化树形图
  130. });
  131. }
  132. var setting4 = {
  133. data: {
  134. key: {
  135. name: "F_AreaName"
  136. },
  137. simpleData: {
  138. enable: true,
  139. idKey: "F_Id",
  140. pIdKey: "F_ParentId",
  141. rootPId: 0
  142. }
  143. },
  144. callback: {
  145. onClick: changeTreeClick
  146. }
  147. }
  148. function changeTreeClick(event, treeId, treeNode) {
  149. chanId=treeNode.F_Id;
  150. changeName = treeNode.F_AreaName;
  151. areaParent=treeNode.getPath();
  152. if (areaParent[2]) {
  153. areaParent1=areaParent[0].F_AreaName
  154. areaParent2=areaParent[1].F_AreaName
  155. areaParent3=areaParent[2].F_AreaName
  156. $('#typeclass1').val(areaParent1+"/"+areaParent2+"/"+areaParent3);
  157. $('#typeclass_market1').val(areaParent1+"/"+areaParent2+"/"+areaParent3);
  158. $('.inps2').val(areaParent1);
  159. $('.inps3').val(areaParent2);
  160. $('.inps4').val(areaParent3);
  161. }else{
  162. layer.msg("请选择最下级菜单");
  163. }
  164. $('.addTree1').hide();
  165. };
  166. $('.areaDown').click(function() {
  167. if($('.treeList1').css('display') == 'block') {
  168. $('.treeList1').css('display', 'none')
  169. } else {
  170. $('.treeList1').css('display', 'block')
  171. }
  172. })
  173. $('#typeclass1').click(function() {
  174. $('.treeList1').css('display', 'block')
  175. })
  176. $('.treeList1').mouseleave(function() {
  177. $(this).css('display', 'none')
  178. })
  179. $('#typeclass_market1').click(function() {
  180. $('.treeList_market1').css('display', 'block')
  181. })
  182. $('.treeList_market1').mouseleave(function() {
  183. $(this).css('display', 'none')
  184. })
  185. //工单状态
  186. function getOrderState() {
  187. $.ajax({
  188. url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
  189. type: 'get',
  190. async: true,
  191. data: {
  192. flag: 'GDZT',
  193. token: $.cookie("token")
  194. },
  195. dataType: "json",
  196. success: function(res) {
  197. if(res.state == "success") {
  198. //console.log(res.data);
  199. $('<option value="">全部</option>').appendTo($("#State"));
  200. $(res.data).each(function(i, n) {
  201. if(n.F_DictionaryValueId == '472') {
  202. $('<option value="' + n.F_DictionaryValueId + '" selected="selected">' + n.F_Name + '</option>').appendTo($("#State"));
  203. } else {
  204. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#State"));
  205. }
  206. })
  207. //
  208. }
  209. }
  210. })
  211. }
  212. //工单来源
  213. function getOrderSource(obj) {
  214. $.ajax({
  215. type: "get",
  216. url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
  217. dataType: 'json',
  218. async: true,
  219. data: {
  220. token: $.cookie("token"),
  221. flag: "GDLY"
  222. },
  223. success: function(data) {
  224. var Count = data.data;
  225. $('<option value="">全部</option>').appendTo($("#DicValueList"));
  226. $(Count).each(function(i, n) {
  227. if(n.F_DictionaryValueId == "468") {
  228. $('<option value="' + n.F_DictionaryValueId + '" selected="selected">' + n.F_Name + '</option>').appendTo($("#DicValueList"));
  229. $('<option value="' + n.F_DictionaryValueId + '" selected="selected">' + n.F_Name + '</option>').appendTo($("#DicValueList_market"));
  230. } else {
  231. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#DicValueList"));
  232. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#DicValueList_market"));
  233. }
  234. })
  235. }
  236. });
  237. }
  238. //客诉专员
  239. function ComplaintVip() {
  240. var customerType;
  241. $.ajax({
  242. type: "get",
  243. url: huayi.config.callcenter_url + "Customer/GetAllList",
  244. dataType: 'json',
  245. async: true,
  246. data: {
  247. token: $.cookie("token"),
  248. type: 2
  249. },
  250. success: function(data) {
  251. var Count = data.data;
  252. if (ns==1) {
  253. $('<option value="">全部</option>').appendTo($("#vipName"));
  254. $(Count).each(function(i, n) {
  255. $('<option value="' + n.F_Id
  256. + '" index="'+n.F_Phone+'">' + n.F_Name
  257. + '</option>').appendTo($("#vipName"));
  258. })
  259. } else if(ns==2){
  260. $('<option value="">全部</option>').appendTo($("#customerName"));
  261. $(Count).each(function(i, n) {
  262. $('<option value="' + n.F_Id
  263. + '" index="'+n.F_Phone+'">' + n.F_Name
  264. + '</option>').appendTo($("#customerName"));
  265. })
  266. }
  267. }
  268. });
  269. }
  270. //获取专员手机号
  271. $("#vipName").change(function() {
  272. $("#vipTel").val($("#vipName option:selected").attr("index"));
  273. });
  274. $("#customerName").change(function() {
  275. $("#customerTel").val($("#customerName option:selected").attr("index"));
  276. });
  277. var orderType
  278. var staffId
  279. var stafftel
  280. //思念组保存
  281. function saveCustomer() {
  282. if($('#name').val() == '') {
  283. layer.confirm('请输入姓名!', {
  284. icon: 2,
  285. btn: ['确定']
  286. });
  287. return;
  288. }
  289. if($('#tel').val() == '') {
  290. layer.confirm('请输入电话!', {
  291. icon: 2,
  292. btn: ['确定']
  293. });
  294. return;
  295. }
  296. if($('#DicValueList').val() == '') {
  297. layer.confirm('请选择工单来源!', {
  298. icon: 2,
  299. btn: ['确定']
  300. });
  301. return;
  302. }
  303. if($('#typeclassId').val() == '') {
  304. layer.confirm('请选择工单类型!', {
  305. icon: 2,
  306. btn: ['确定']
  307. });
  308. return;
  309. }
  310. if (ns==1) {
  311. orderType=$('.orderType1').val();
  312. staffId=$('#vipName').val();
  313. stafftel=$('#vipTel').val();
  314. } else if(ns==2){
  315. orderType=$('.orderType2').val();
  316. staffId=$('#customerName').val();
  317. stafftel=$('#customerTel').val();
  318. }
  319. $.ajax({
  320. type: "post",
  321. url: huayi.config.callcenter_url + "WorkOrder/AddWorkOrder",
  322. dataType: 'json',
  323. async: true,
  324. // beforeSend: function() { //触发ajax请求开始时执行
  325. // $('.customerSubmit').attr("disabled", true);
  326. // $('.customerSubmit').text('保存中...');
  327. // },
  328. data: {
  329. token: $.cookie("token"),
  330. cusname: $('#name').val(), //姓名
  331. cusphone: $('#tel').val(), //号码
  332. buydate: $('.buyDate').val(), //购买日期
  333. productname: $('#productname').val(), //产品名称
  334. buyaddress: $('#buyAddress').val(), //购买地址
  335. producttype: $('#productType').val(), //产品类别
  336. batchnumber: $('#batchNumber').val(), //生产批号
  337. userdate: $('.userDate').val(), //使用日期 userDate
  338. source: $('#DicValueList').val(), //工单来源
  339. type: orderType, //工单类型id
  340. area: $('.inps2').val(), //区域
  341. province: $('.inps3').val(), //省
  342. city: $('.inps4').val(), //市
  343. content:$('#content').val(), //事件描述
  344. vipid: staffId, //专员id
  345. vipphone: stafftel, //专员号码
  346. callid: $("#CallID").val()
  347. },
  348. success: function(data) {
  349. if(data.state.toLowerCase() == 'success') {
  350. layer.msg("保存成功!");
  351. window.location.reload()
  352. // $('.customerSubmit').attr("disabled", false);
  353. // $('.customerSubmit').text('保存');
  354. }
  355. }
  356. });
  357. }
  358. // 市场部保存
  359. function saveMarket() {
  360. if (ns==1) {
  361. orderType=$('.orderType1').val();
  362. staffId=$('#vipName').val();
  363. stafftel=$('#vipTel').val();
  364. } else if(ns==2){
  365. orderType=$('.orderType2').val();
  366. staffId=$('#customerName').val();
  367. stafftel=$('#customerTel').val();
  368. }
  369. $.ajax({
  370. type: "post",
  371. url: huayi.config.callcenter_url + "WorkOrder/AddWorkOrder",
  372. dataType: 'json',
  373. async: true,
  374. // beforeSend: function() { //触发ajax请求开始时执行
  375. // $('.marketSubmit').attr("disabled", true);
  376. // $('.marketSubmit').text('保存中...');
  377. // },
  378. data: {
  379. token: $.cookie("token"),
  380. cusname: $('#name').val(), //姓名
  381. cusphone: $('#tel').val(), //号码
  382. area: $('.inps2').val(), //区域
  383. vipid: staffId, //专员id
  384. vipphone: stafftel, //专员号码
  385. source: $('#DicValueList').val(), //工单来源
  386. productname: $('#productname').val(), //产品名称
  387. batchnumber: $('#batchNumber').val(), //生产批号
  388. buyaddress: $('#buyAddress').val(), //购买地址
  389. productdate: $('#proDuctdate').val(),
  390. buydate: $('.buyDate').val(), //购买日期
  391. userdate: $('.userDate').val(), //使用日期 userDate
  392. type: orderType, //工单类型id
  393. province: $('.inps3').val(), //省
  394. city: $('.inps4').val(), //市
  395. content:$('#content').val(), //事件描述
  396. isback:$("#sendBack").val(),
  397. callid: $("#CallID").val()
  398. },
  399. success: function(data) {
  400. if(data.state.toLowerCase() == 'success') {
  401. layer.msg("保存成功!");
  402. debugger
  403. window.location.reload()
  404. // clear();
  405. $('.marketSubmit').attr("disabled", false);
  406. $('.marketSubmit').text('保存');
  407. }
  408. }
  409. });
  410. }
  411. function clear() {
  412. if(ns == 1) {
  413. $('#name').val('');
  414. $('#tel').val(''); //号码
  415. $('#testInput1_input').val(''); //来电单位
  416. $('#testInput2_input').val(''); //反馈单位
  417. $('#orderSource').val(''); //工单来源
  418. $('#typeclassId').val(''); //工单类型id
  419. $('#State').val(''); //工单状态id
  420. $('#feedBackCon').val(''); //反馈内容
  421. $('#express').val(''); //快递信息
  422. $('#remark1').val(''); //备注一
  423. $('#remark2').val(''); //备注二
  424. $('#remark3').val(''); //备注三
  425. $('#typeclass').val('');
  426. } else {
  427. $('#name_market').val('');
  428. $('#tel_market').val(''); //号码
  429. $('#testInput3_input').val(''); //来电单位
  430. $('#testInput4_input').val(''); //反馈单位
  431. $('#remark_market').val(''); //备注内容
  432. }
  433. }