思念食品 UI

xgWork.js 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. var typeSmall;
  2. var id = helper.request.queryString("id");
  3. $(document).ready(function () {
  4. $.ajax({
  5. type: "get",
  6. url: huayi.config.callcenter_url + "CallInScreen/GetCurrUserDep",
  7. dataType: 'json',
  8. async: false,
  9. data: {
  10. token: $.cookie("token")
  11. },
  12. success: function(data) {
  13. if(data.state.toLowerCase() == 'success') {
  14. if(data.data.groname == '思念组') {
  15. $(".snRmove").remove();
  16. $(".dkRmove").show();
  17. } else {
  18. $(".snRmove").show();
  19. $(".complainDiv2").hide();
  20. $(".dkRmove").remove();
  21. $(".ns-2").remove();
  22. }
  23. }
  24. }
  25. });
  26. var groupcode = $('#groupcode', top.document).val();
  27. if (groupcode == 'SCZ') {
  28. $("#usedate").text("饮用日期:");
  29. $("#vipid").text("对接人:");
  30. $("#vipphone").text("对接人电话:");
  31. }
  32. laydate.render({
  33. elem: '.userDate',
  34. theme: '#1ab394',
  35. calendar: 'true'
  36. });
  37. laydate.render({
  38. elem: '.buyDate',
  39. theme: '#1ab394',
  40. calendar: 'true'
  41. });
  42. laydate.render({
  43. elem: '#productDate',
  44. theme: '#1ab394',
  45. calendar: 'true'
  46. });
  47. $.ajaxSettings.async = false;
  48. //工单来源
  49. getOrderSource();
  50. //工单类型
  51. getOrderType();
  52. //投诉类型
  53. complaintType();
  54. //咨询类型
  55. consultType();
  56. //产品类别
  57. getProductType();
  58. //区域
  59. getAreaType();
  60. //客诉专员
  61. ComplaintVip();
  62. //保存
  63. $('.customerSubmit').click(function() {
  64. saveCustomer();
  65. });
  66. $.ajaxSettings.async = true;
  67. var id = helper.request.queryString("id");
  68. $.ajax({
  69. type: "get",
  70. url: huayi.config.callcenter_url + "WorkOrder/GetWorkOrder",
  71. dataType: 'json',
  72. async: true,
  73. cache: false,
  74. data: {
  75. "workid": id,
  76. "token": $.cookie("token")
  77. },
  78. success: function(result) {
  79. if (result.data.data.length > 0) {
  80. var data = result.data.data[0];
  81. $('#name').val(data.F_CusName); //姓名
  82. $('#tel').val(data.F_CusPhone); //号码
  83. $('#productDate').val(data.F_ProductDate); //购买日期
  84. $('.buyDate').val(data.F_BuyDate); //购买日期
  85. $('.orderType').val(data.F_Type + ''); //工单类型ID
  86. $('.orderType').trigger("change");
  87. $('.complaintType').val(data.F_SmallType);
  88. $('.complaintType1').val(data.F_SmallType);
  89. $('.complaintType2').val(data.F_SmallType);
  90. $('#productname').val(data.F_ProductName); //产品名称
  91. $('#buyAddress').val(data.F_BuyAddress); //购买地址 data.
  92. $('#productType').val(data.F_ProductType + ''); //产品类别ID
  93. $('#batchNumber').val(data.F_BatchNumber); //生产批号
  94. $('.userDate').val(data.F_UserDate); //使用日期
  95. $('#DicValueList').val(data.F_Source + ''); //工单来源
  96. $("#areaInps").val(data.F_Area);
  97. $('#typeclass').val(data.F_Province + "/" + data.F_City); //区域
  98. $('.inps2').val(data.F_Province); //省
  99. $('.inps3').val(data.F_City); //市
  100. $('#county').val(data.F_County); //区县
  101. $('#content').val(data.F_Content); //事件描述
  102. $('#remark').val(data.F_Remark); //备注
  103. $('#vipName').val(data.F_VIPId); //专员姓名
  104. $('#vipNameDK').val(data.F_VIPName);
  105. $('#vipTel').val(data.F_VIPPhone); //专员号码
  106. if (data.F_State=="1") {
  107. $(".deal").show();
  108. } else{
  109. $(".deal").remove();
  110. }
  111. $("input[name='sendBack'][value='" + data.F_IsBack+"']").attr("checked", true);
  112. if ($(".orderType option:selected").text() != "投诉") {
  113. $(".complainDiv2").show();
  114. $(".complainDiv").hide();
  115. typeSmall =$(".complaintType2").val();
  116. } else {
  117. $(".complainDiv2").hide();
  118. $(".complainDiv").show();
  119. typeSmall =$(".complaintType1").val();
  120. }
  121. if (data.F_DealCost=="0") {
  122. $("#dealCost").val(""); //处理费用
  123. }else{
  124. $("#dealCost").val(data.F_DealCost); //处理费用
  125. }
  126. //$("input[type=radio][value='']").prop("checked",true);
  127. $("input[type=radio][name=response][value="+data.F_DealTimely+"]").attr("checked",'checked')//响应状态
  128. $("input[type=radio][name=ltype][value="+data.F_DealState+"]").attr("checked",'checked')//响应状态
  129. $("#disposeST").text(data.DealStateName); //处理状态
  130. $("#dealCont").text(data.F_DealResult); //处理结果
  131. $("#cont").text(data.F_DealDes); //客诉进展详述
  132. }
  133. }
  134. });
  135. $(".complaintType2").change(function () {
  136. typeSmall=$(".complaintType2").val();
  137. });
  138. $(".complaintType1").change(function () {
  139. typeSmall=$(".complaintType1").val();
  140. });
  141. $('.areaDown').click(function() {
  142. if ($('.treeList1').css('display') == 'block') {
  143. $('.treeList1').css('display', 'none')
  144. } else {
  145. $('.treeList1').css('display', 'block')
  146. }
  147. })
  148. $('#typeclass').click(function() {
  149. $('.treeList1').css('display', 'block')
  150. })
  151. $('.treeList1').mouseleave(function() {
  152. $(this).css('display', 'none')
  153. })
  154. //获取专员手机号
  155. $("#vipName").change(function() {
  156. $("#vipTel").val($("#vipName option:selected").attr("index"));
  157. //$("#areaInps").val($("#vipName option:selected").attr("areaText"));
  158. $("#typeclass").val($("#vipName option:selected").attr("province") + "/" + $("#vipName option:selected").attr("city"));
  159. $(".inps2").val($("#vipName option:selected").attr("province"));
  160. $(".inps3").val($("#vipName option:selected").attr("city"));
  161. });
  162. })
  163. //处理状态
  164. dealState();
  165. function dealState() {
  166. $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', {
  167. "token": $.cookie("token"),
  168. flag: "CLZT"
  169. }, function(result) {
  170. result = $.parseJSON(result);
  171. var Count = result.data;
  172. $(Count).each(function(i, n) {
  173. $('<label style="font-weight: normal; margin-right: 15px;">'+
  174. '<input type="radio" value="' + n.F_DictionaryValueId
  175. + '" name="ltype"/>' + n.F_Name
  176. + '</label>').appendTo($(".disposeST"));
  177. })
  178. $('.disposeST input:radio:first').attr('checked', 'checked');
  179. });
  180. }
  181. //响应状态
  182. responseState();
  183. function responseState() {
  184. $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', {
  185. "token": $.cookie("token"),
  186. flag: "XYZT"
  187. }, function(result) {
  188. result = $.parseJSON(result);
  189. var Count = result.data;
  190. $(Count).each(function(i, n) {
  191. $('<label style="font-weight: normal; margin-right: 15px;">'+
  192. '<input type="radio" value="' + n.F_DictionaryValueId
  193. + '" name="response"/>' + n.F_Name
  194. + '</label>').appendTo($(".responseST"));
  195. })
  196. $('.responseST input:radio:first').attr('checked', 'checked');
  197. });
  198. }
  199. //工单类型
  200. function getOrderType() {
  201. $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', {
  202. "token": $.cookie("token"),
  203. flag: "GDLX"
  204. }, function(result) {
  205. result = $.parseJSON(result);
  206. var Count = result.data;
  207. $(Count).each(function(i, n) {
  208. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($(".orderType"));
  209. })
  210. });
  211. }
  212. //投诉类型
  213. function complaintType() {
  214. $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', {
  215. "token": $.cookie("token"),
  216. flag: "TSLX"
  217. }, function(result) {
  218. result = $.parseJSON(result);
  219. var Count = result.data;
  220. $(Count).each(function(i, n) {
  221. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($(".complaintType1"));
  222. })
  223. });
  224. }
  225. //咨询类型
  226. function consultType() {
  227. $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', {
  228. "token": $.cookie("token"),
  229. flag: "ZXLX"
  230. }, function(result) {
  231. result = $.parseJSON(result);
  232. var Count = result.data;
  233. $(Count).each(function(i, n) {
  234. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($(".complaintType2"));
  235. })
  236. });
  237. }
  238. //产品类别
  239. function getProductType() {
  240. $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', {
  241. "token": $.cookie("token"),
  242. flag: "CPLB"
  243. }, function(result) {
  244. result = $.parseJSON(result);
  245. var Count = result.data;
  246. $(Count).each(function(i, n) {
  247. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($(".productType"));
  248. })
  249. });
  250. }
  251. //区域
  252. function getAreaType() {
  253. $.get(huayi.config.callcenter_url + 'Area/GetAreaList', {
  254. "token": $.cookie("token"),
  255. }, function(result) {
  256. result = $.parseJSON(result);
  257. $.fn.zTree.init($("#TreeDemo1"), setting, result.data); //实例化树形图
  258. });
  259. }
  260. var setting = {
  261. data: {
  262. key: {
  263. name: "F_AreaName"
  264. },
  265. simpleData: {
  266. enable: true,
  267. idKey: "F_Id",
  268. pIdKey: "F_ParentId",
  269. rootPId: 0
  270. }
  271. },
  272. callback: {
  273. onClick: changeTreeClick
  274. }
  275. }
  276. function changeTreeClick(event, treeId, treeNode) {
  277. var areaParent = treeNode.getPath();
  278. if (areaParent[1]) {
  279. areaParent1 = areaParent[0].F_AreaName
  280. areaParent2 = areaParent[1].F_AreaName
  281. $('#typeclass').val(areaParent1 + "/" + areaParent2);
  282. $('.inps2').val(areaParent1);
  283. $('.inps3').val(areaParent2);
  284. ComplaintVip();
  285. } else {
  286. layer.msg("请选择最下级菜单");
  287. }
  288. $('.addTree1').hide();
  289. };
  290. //工单来源
  291. function getOrderSource(obj) {
  292. $.ajax({
  293. type: "get",
  294. url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
  295. dataType: 'json',
  296. async: true,
  297. data: {
  298. token: $.cookie("token"),
  299. flag: "GDLY"
  300. },
  301. success: function(data) {
  302. var Count = data.data;
  303. $(Count).each(function(i, n) {
  304. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#DicValueList"));
  305. })
  306. }
  307. });
  308. }
  309. //客诉专员
  310. function ComplaintVip() {
  311. $.ajax({
  312. type: "get",
  313. url: huayi.config.callcenter_url + "Customer/GetAllList",
  314. dataType: 'json',
  315. async: true,
  316. data: {
  317. token: $.cookie("token"),
  318. type: 2,
  319. province: $('.inps2').val(), //省
  320. city: $('.inps3').val() //市
  321. },
  322. success: function(data) {
  323. $("#vipName").empty();
  324. var Count = data.data;
  325. $('<option value="">请选择专员</option>').appendTo($("#vipName"));
  326. $(Count).each(function(i, n) {
  327. $('<option value="' + n.F_Id
  328. + '" index="' + n.F_Phone
  329. + '" areaText="' + n.F_Area
  330. + '" province="' + n.F_Province
  331. + '" city="' + n.F_City + '">' + n.F_Name
  332. + '</option>').appendTo($("#vipName"));
  333. })
  334. }
  335. });
  336. }
  337. //保存
  338. function saveCustomer() {
  339. var val = $("input[name='ltype']:checked").val();
  340. var valRes = $("input[name='response']:checked").val();
  341. var dealCost;
  342. if (isNaN($("#dealCost").val())) {
  343. dealCost="";
  344. }else{
  345. dealCost=$("#dealCost").val();
  346. }
  347. if (!$('#name').val()) {
  348. layer.confirm('请输入姓名!', {
  349. icon: 2,
  350. btn: ['确定']
  351. });
  352. return;
  353. }
  354. if (!$('#tel').val()) {
  355. layer.confirm('请输入电话!', {
  356. icon: 2,
  357. btn: ['确定']
  358. });
  359. return;
  360. }
  361. if (!$('#DicValueList').val()) {
  362. layer.confirm('请选择工单来源!', {
  363. icon: 2,
  364. btn: ['确定']
  365. });
  366. return;
  367. }
  368. if (!$('.orderType').val()) {
  369. layer.confirm('请选择工单类型!', {
  370. icon: 2,
  371. btn: ['确定']
  372. });
  373. return;
  374. }
  375. $.ajax({
  376. type: "post",
  377. url: huayi.config.callcenter_url + "WorkOrder/EditWorkOrder",
  378. dataType: 'json',
  379. async: true,
  380. beforeSend: function() { //触发ajax请求开始时执行
  381. $('.customerSubmit').attr("disabled", true);
  382. $('.customerSubmit').text('保存中...');
  383. },
  384. data: {
  385. token: $.cookie("token"),
  386. workid: id,
  387. cusname: $('#name').val(), //姓名
  388. cusphone: $('#tel').val(), //号码
  389. productdate: $('#productDate').val(),
  390. buydate: $('.buyDate').val(), //购买日期
  391. productname: $('#productname').val(), //产品名称
  392. buyaddress: $('#buyAddress').val(), //购买地址
  393. producttype: $('#productType').val(), //产品类别
  394. batchnumber: $('#batchNumber').val(), //生产批号
  395. userdate: $('.userDate').val(), //使用日期 userDate
  396. source: $('#DicValueList').val(), //工单来源
  397. type: $('.orderType').val(), //工单类型id
  398. smalltype: typeSmall, //投诉类型
  399. area: $('#areaInps').val(), //区域
  400. province: $('.inps2').val(), //省
  401. city: $('.inps3').val(), //市
  402. county:$('#county').val(), //区县
  403. content: $('#content').val(), //事件描述
  404. remark: $('#remark').val(), //备注
  405. vipid: $('#vipName').val(), //专员id
  406. vipname:$('#vipNameDK').val(),
  407. vipphone: $('#vipTel').val(), //专员号码
  408. isback: $('input[name="sendBack"]:checked').val(),
  409. dealcost: dealCost*1, //处理费用
  410. dealresult:$("#dealCont").val(),//处理结果
  411. dealdes: $("#cont").val(), //客诉进展详述
  412. dealstate:val, //处理状态
  413. dealtimely:valRes, //及时响应
  414. callid: $("#CallID").val()
  415. },
  416. success: function(data) {
  417. if (data.state.toLowerCase() == 'success') {
  418. $('.customerSubmit').attr("disabled", false);
  419. $('.customerSubmit').text('保存');
  420. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  421. parent.layer.close(index); //再执行关闭
  422. parent.layer.msg("保存成功!");
  423. parent.$('#workorderlist').bootstrapTable('refresh');
  424. parent.$('#workorderlist_').bootstrapTable('refresh');
  425. parent.$('#orderlist').bootstrapTable('refresh');
  426. }
  427. }
  428. });
  429. }