思念食品 UI

AddWorkOrder.js 12KB

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