思念食品 UI

AddWorkOrder.js 13KB

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