Nav apraksta

AddWorkOrder.js 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. var typeSmall;
  2. $(document).ready(function () {
  3. $.ajax({
  4. type: "get",
  5. url: huayi.config.callcenter_url + "CallInScreen/GetCurrUserDep",
  6. dataType: 'json',
  7. async: false,
  8. data: {
  9. token: $.cookie("token")
  10. },
  11. success: function(data) {
  12. if(data.state.toLowerCase() == 'success') {
  13. if(data.data.groname == '思念组') {
  14. $(".snRmove").remove();
  15. $(".dkRmove").show();
  16. } else {
  17. $(".snRmove").show();
  18. $(".complainDiv2").hide();
  19. $(".dkRmove").remove();
  20. }
  21. }
  22. }
  23. });
  24. var groupcode = $('#groupcode', top.document).val();
  25. if (groupcode == 'SCZ') {
  26. $("#usedate").text("饮用日期:");
  27. $("#vipid").text("对接人:");
  28. $("#vipphone").text("对接人电话:");
  29. }
  30. var id = helper.request.queryString("id");
  31. var phone = helper.request.queryString("phone");
  32. var name = helper.request.queryString("name");
  33. // laydate.render({
  34. // elem: '#productDate',
  35. // theme: '#1ab394',
  36. // calendar: 'true'
  37. // });
  38. // 产品代码
  39. getProductType();
  40. // 问题代码
  41. getProblemCode();
  42. // 重要级别
  43. getDealTimely();
  44. // 重要级别原因
  45. getReason();
  46. // 区域
  47. getArea($("#customer_area"));
  48. // 省 办事处
  49. LAISHENG($("#source"));//省
  50. CHOUDQ($("#customer_comaddress")); //办事处
  51. // 隐藏重要级别原因
  52. $('.reasonTitle').hide();
  53. $('.reasonInput').hide();
  54. ////编辑器配置 客服部
  55. //KindEditor.ready(function(K) {
  56. // window.changeEditor = K.create('#feedBackCon'); //修改弹出框编辑器
  57. //})
  58. ////编辑器配置 市场部 备注
  59. //KindEditor.ready(function(K) {
  60. // window.marketEditor = K.create('#remark_market');
  61. //})
  62. //保存
  63. $('.customerSubmit').click(function() {
  64. saveCustomer();
  65. })
  66. if(id) {
  67. $("#CallID").val(id);
  68. $("#tel").val(phone);
  69. $("#tel_market").val(phone);
  70. if(unescape(decodeURI(name)) != 'null' && unescape(decodeURI(name)) != 'undefined') {
  71. $("#name_market").val(unescape(decodeURI(name)));
  72. $("#name").val(unescape(decodeURI(name)));
  73. }
  74. }
  75. $('.areaDown').click(function () {
  76. if ($('.treeList1').css('display') == 'block') {
  77. $('.treeList1').css('display', 'none')
  78. } else {
  79. $('.treeList1').css('display', 'block')
  80. }
  81. })
  82. $('#typeclass').click(function () {
  83. $('.treeList1').css('display', 'block')
  84. })
  85. $('.treeList1').mouseleave(function () {
  86. $(this).css('display', 'none')
  87. })
  88. $(".orderType").change(function () {
  89. if ($(".orderType option:selected").text() != "投诉") {
  90. $(".complainDiv2").show();
  91. typeSmall =$(".complaintType2").val();
  92. $(".complainDiv").hide();
  93. } else {
  94. $(".complainDiv2").hide();
  95. $(".complainDiv").show();
  96. typeSmall =$(".complaintType1").val();
  97. }
  98. });
  99. $(".complaintType2").change(function () {
  100. typeSmall=$(".complaintType2").val();
  101. });
  102. $(".complaintType1").change(function () {
  103. typeSmall=$(".complaintType1").val();
  104. });
  105. //获取专员手机号
  106. $("#vipName").change(function () {
  107. $("#vipTel").val($("#vipName option:selected").attr("index"));
  108. if ($("#vipName option:selected").attr("province")==undefined) {
  109. $("#typeclass").val("");
  110. }else{
  111. $("#typeclass").val($("#vipName option:selected").attr("province") + "/" + $("#vipName option:selected").attr("city"));
  112. $(".inps2").val($("#vipName option:selected").attr("province"));
  113. $(".inps3").val($("#vipName option:selected").attr("city"));
  114. }
  115. });
  116. })
  117. //大区
  118. function getArea(obj) {
  119. obj.empty();
  120. obj.append('<option selected="selected" value="">请选择</option>');
  121. $.getJSON(huayi.config.callcenter_url + "Department/GetCusAreaList", {
  122. "token": $.cookie("token"),
  123. pid: 1,
  124. F_Layer: 1,
  125. }, function (data) {
  126. if (data.state.toLowerCase() == "success") {
  127. var content = data.data;
  128. $(content).each(function (i, n) {
  129. $("<option value='" + n.F_DeptId + "'>" + n.F_DeptName + "</option>").appendTo(obj);
  130. })
  131. }
  132. })
  133. }
  134. //办事处
  135. function getOffice(obj) {
  136. obj.empty();
  137. obj.append('<option selected="selected" value="">请选择</option>');
  138. $.getJSON(huayi.config.callcenter_url + "Department/GetCusAreaList", {
  139. "token": $.cookie("token"),
  140. F_Layer:2,
  141. pid:$("#customer_area").val(),
  142. }, function (data) {
  143. if (data.state.toLowerCase() == "success") {
  144. var content = data.data;
  145. $(content).each(function (i, n) {
  146. $("<option value='" + n.F_DeptId + "'>" + n.F_DeptName + "</option>").appendTo(obj);
  147. })
  148. }
  149. })
  150. }
  151. // 获取所在区域办事处
  152. $("#customer_area").on("change", function() {
  153. getOffice($("#customer_office"))
  154. })
  155. //省 市 区/县
  156. //省
  157. function LAISHENG(obj) {
  158. obj.empty();
  159. obj.append('<option selected="selected" value="">请选择</option>');
  160. $.getJSON(huayi.config.callcenter_url + "RegionCategory/GetCountyList", {
  161. "token": $.cookie("token"),
  162. pid: 0,
  163. }, function (data) {
  164. if (data.state.toLowerCase() == "success") {
  165. var content = data.data;
  166. $(content).each(function (i, n) {
  167. $("<option value='" + n.F_RegionId + "'>" + n.F_RegionName + "</option>").appendTo(obj);
  168. })
  169. }
  170. })
  171. }
  172. //市
  173. function LAISHI(obj) {
  174. obj.empty();
  175. obj.append('<option selected="selected" value="">请选择</option>');
  176. $.getJSON(huayi.config.callcenter_url + "RegionCategory/GetCountyList", {
  177. "token": $.cookie("token"),
  178. pid:$('#source').val(),
  179. }, function (data) {
  180. if (data.state.toLowerCase() == "success") {
  181. var content = data.data;
  182. $(content).each(function (i, n) {
  183. $("<option value='" + n.F_RegionId + "'>" + n.F_RegionName + "</option>").appendTo(obj);
  184. })
  185. }
  186. })
  187. }
  188. // 区/县
  189. function LAIQU(obj) {
  190. obj.empty();
  191. obj.append('<option selected="selected" value="">请选择</option>');
  192. $.getJSON(huayi.config.callcenter_url + "RegionCategory/GetCountyList", {
  193. "token": $.cookie("token"),
  194. pid:$('#type').val(),
  195. }, function (data) {
  196. if (data.state.toLowerCase() == "success") {
  197. var content = data.data;
  198. $(content).each(function (i, n) {
  199. $("<option value='" + n.F_RegionId + "'>" + n.F_RegionName + "</option>").appendTo(obj);
  200. })
  201. }
  202. })
  203. }
  204. $('#source').on('change',function(){
  205. $.getJSON(huayi.config.callcenter_url + "RegionCategory/GetCountyList", {
  206. "token": $.cookie("token"),
  207. F_Layer: 2,
  208. F_RegionName:$('#source').val(),
  209. }, function (data) {
  210. if (data.state.toLowerCase() == "success") {
  211. var content = data.data;
  212. $(content).each(function (i, n) {
  213. $("<option value='" + n.F_RegionId + "'>" + n.F_RegionName + "</option>").appendTo("#type");
  214. })
  215. LAISHI($("#type"));
  216. }
  217. })
  218. });
  219. $('#type').on('change',function(){
  220. $.getJSON(huayi.config.callcenter_url + "RegionCategory/GetCountyList", {
  221. "token": $.cookie("token"),
  222. F_Layer: 3,
  223. F_RegionName:$('#type').val()
  224. }, function (data) {
  225. if (data.state.toLowerCase() == "success") {
  226. var content = data.data;
  227. $(content).each(function (i, n) {
  228. $("<option value='" + n.F_RegionId + "'>" + n.F_RegionName + "</option>").appendTo("#keyid");
  229. })
  230. LAIQU($("#keyid"));
  231. }
  232. })
  233. });
  234. $('#keyid').on('change',function(){
  235. $.getJSON(huayi.config.callcenter_url + "RegionCategory/GetCountyList", {
  236. "token": $.cookie("token"),
  237. F_Layer: 4,
  238. F_RegionName:$('#keyid').val()
  239. }, function (data) {
  240. if (data.state.toLowerCase() == "success") {
  241. var content = data.data;
  242. $(content).each(function (i, n) {
  243. $("<option value='" + n.F_RegionId + "'>" + n.F_RegionName + "</option>").appendTo("#input_area");
  244. })
  245. LAIQU($('#input_area'));
  246. }
  247. })
  248. });
  249. //办事处 提交人
  250. function CHOUDQ(obj) {
  251. obj.empty();
  252. obj.append('<option selected="selected" value="">请选择</option>');
  253. $.getJSON(huayi.config.callcenter_url + "Department/GetCusAreaList", {
  254. "token": $.cookie("token"),
  255. pid: 1,
  256. F_Layer: 1,
  257. }, function (data) {
  258. if (data.state.toLowerCase() == "success") {
  259. var content = data.data;
  260. $(content).each(function (i, n) {
  261. $("<option value='" + n.F_DeptId + "'>" + n.F_DeptName + "</option>").appendTo(obj);
  262. })
  263. }
  264. })
  265. }
  266. // 提交人
  267. function getSubmitter(obj) {
  268. obj.empty();
  269. obj.append('<option selected="selected" value="" deptId="">请选择</option>');
  270. $.getJSON(huayi.config.callcenter_url + "UserAccount/GetList", {
  271. "token": $.cookie("token"),
  272. type: 1,
  273. dptid: $("#customer_comaddress").val(),
  274. }, function (data) {
  275. var content = data.rows;
  276. $(content).each(function (i, n) {
  277. $("<option value='" + n.F_UserId + "'deptId='" + n.F_DeptId + "'>" + n.F_UserName + "</option>").appendTo(obj);
  278. })
  279. })
  280. }
  281. // 获取提交人
  282. $('#customer_comaddress').on('change',function(){
  283. getSubmitter($('#customer_submitter'));
  284. });
  285. //产品代码
  286. function getProductType() {
  287. $.ajax({
  288. type: "get",
  289. url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
  290. dataType: 'json',
  291. async: true,
  292. data: {
  293. token: $.cookie("token"),
  294. flag: "CPDM"
  295. },
  296. success: function(data) {
  297. var Count = data.data;
  298. $(Count).each(function(i, n) {
  299. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#productType"));
  300. })
  301. }
  302. });
  303. }
  304. // 问题代码
  305. function getProblemCode() {
  306. $.ajax({
  307. type: "get",
  308. url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
  309. dataType: 'json',
  310. async: true,
  311. data: {
  312. token: $.cookie("token"),
  313. flag: "WTDM"
  314. },
  315. success: function(data) {
  316. var Count = data.data;
  317. $(Count).each(function(i, n) {
  318. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#problemCode"));
  319. })
  320. }
  321. });
  322. }
  323. // 重要级别
  324. function getDealTimely() {
  325. $.ajax({
  326. type: "get",
  327. url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
  328. dataType: 'json',
  329. async: true,
  330. data: {
  331. token: $.cookie("token"),
  332. flag: "GDDJ"
  333. },
  334. success: function(data) {
  335. var Count = data.data;
  336. $(Count).each(function(i, n) {
  337. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#dealTimely"));
  338. })
  339. }
  340. });
  341. }
  342. // 重要级别原因
  343. function getReason() {
  344. $.ajax({
  345. type: "get",
  346. url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
  347. dataType: 'json',
  348. async: true,
  349. data: {
  350. token: $.cookie("token"),
  351. flag: "YJYY"
  352. },
  353. success: function(data) {
  354. var Count = data.data;
  355. $(Count).each(function(i, n) {
  356. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#reason"));
  357. })
  358. }
  359. });
  360. }
  361. // 重要级别为一级时显示原因
  362. $('#dealTimely').on('change',function(){
  363. console.log('1111',$('#dealTimely').val());
  364. if ($('#dealTimely').val() !== '506'){
  365. $('#reason').val('');
  366. $('.reasonTitle').hide();
  367. $('.reasonInput').hide();
  368. } else {
  369. $('.reasonTitle').show();
  370. $('.reasonInput').show();
  371. }
  372. })
  373. // 指派事件
  374. $('#isAssign').on('change', function(){
  375. if($('#isAssign input[name="isAssign"]:checked').val() === '1'){
  376. $('.comaddressTitle').show();
  377. $('.comaddressSelect').show();
  378. $('.submitterTitle').show();
  379. $('.submitterSelect').show();
  380. } else if ($('#isAssign input[name="isAssign"]:checked').val() === '0'){
  381. $('.comaddressTitle').hide();
  382. $('.comaddressSelect').hide();
  383. $('.submitterTitle').hide();
  384. $('.submitterSelect').hide();
  385. }
  386. })
  387. // 地址(省+市+区/县)
  388. function detailedAddress() {
  389. if($('#source').val() === ""){
  390. var province = '';
  391. } else {
  392. var province = $('#source').find("option:selected").text()
  393. }
  394. if($('#type').val() === ""){
  395. var city = '';
  396. } else {
  397. var city = $('#type').find("option:selected").text()
  398. }
  399. if($('#keyid').val() === ""){
  400. var county = '';
  401. } else {
  402. var county = $('#keyid').find("option:selected").text()
  403. }
  404. var address = province + '-' + city + '-' + county;
  405. return address;
  406. }
  407. var setting = {
  408. data: {
  409. key: {
  410. name: "F_AreaName"
  411. },
  412. simpleData: {
  413. enable: true,
  414. idKey: "F_Id",
  415. pIdKey: "F_ParentId",
  416. rootPId: 0
  417. }
  418. },
  419. callback: {
  420. onClick: changeTreeClick
  421. }
  422. }
  423. function changeTreeClick(event, treeId, treeNode) {
  424. var areaParent = treeNode.getPath();
  425. if (areaParent[1]) {
  426. areaParent1=areaParent[0].F_AreaName
  427. areaParent2=areaParent[1].F_AreaName
  428. $('#typeclass').val(areaParent1+"/"+areaParent2);
  429. $('.inps2').val(areaParent1);
  430. $('.inps3').val(areaParent2);
  431. ComplaintVip();
  432. }else{
  433. layer.msg("请选择最下级菜单");
  434. }
  435. $('.addTree1').hide();
  436. };
  437. //工单来源
  438. function getOrderSource(obj) {
  439. $.ajax({
  440. type: "get",
  441. url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
  442. dataType: 'json',
  443. async: true,
  444. data: {
  445. token: $.cookie("token"),
  446. flag: "GDLY"
  447. },
  448. success: function(data) {
  449. var Count = data.data;
  450. $(Count).each(function(i, n) {
  451. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#DicValueList"));
  452. })
  453. }
  454. });
  455. }
  456. //客诉专员
  457. function ComplaintVip() {
  458. $.ajax({
  459. type: "get",
  460. url: huayi.config.callcenter_url + "Customer/GetAllList",
  461. dataType: 'json',
  462. async: true,
  463. data: {
  464. token: $.cookie("token"),
  465. type: 2,
  466. province: $('.inps2').val(), //省
  467. city: $('.inps3').val() //市
  468. },
  469. success: function(data) {
  470. $("#vipName").empty();
  471. var Count = data.data;
  472. $('<option value="">请选择专员</option>').appendTo($("#vipName"));
  473. $(Count).each(function (i, n) {
  474. $('<option value="' + n.F_Id
  475. + '" index="' + n.F_Phone
  476. + '" areaText="' + n.F_Area
  477. + '" province="' + n.F_Province
  478. + '" city="' + n.F_City + '">' + n.F_Name
  479. + '</option>').appendTo($("#vipName"));
  480. })
  481. }
  482. });
  483. }
  484. //保存
  485. function saveCustomer() {
  486. if(!$('#name').val()) {
  487. layer.confirm('请输入姓名!', {
  488. icon: 2,
  489. btn: ['确定']
  490. });
  491. return;
  492. }
  493. if(!$('#tel').val()) {
  494. layer.confirm('请输入电话!', {
  495. icon: 2,
  496. btn: ['确定']
  497. });
  498. return;
  499. }
  500. if(!$('#qualityProblem').val()) {
  501. layer.confirm('请输入质量问题!', {
  502. icon: 2,
  503. btn: ['确定']
  504. });
  505. return;
  506. }
  507. $.ajax({
  508. type: "post",
  509. url: huayi.config.callcenter_url + "WorkOrder/AddWorkOrder",
  510. dataType: 'json',
  511. async: true,
  512. beforeSend: function() { //触发ajax请求开始时执行
  513. $('.customerSubmit').attr("disabled", true);
  514. $('.customerSubmit').text('保存中...');
  515. },
  516. data: {
  517. token: $.cookie("token"),
  518. IsAssign: $('#isAssign input[name="isAssign"]:checked').val(),//是否指派
  519. clbm: $('#customer_submitter').find("option:selected").attr("deptId"), //提交部门
  520. clid: $('#customer_submitter').val(), //提交人
  521. cont: $('#cont').val(), //提交内容
  522. F_Type: $('#order_isover input[name="type"]:checked').val(), //工单类型
  523. F_Area: $('#customer_area').val(), //大区
  524. F_Office: $('#customer_office').val(), //办事处
  525. F_DealTimely: $('#dealTimely').val(), //重要级别
  526. F_Reason: $('#reason').val(), //原因
  527. F_CusName: $('#name').val(), //姓名
  528. F_CusPhone: $('#tel').val(), //号码
  529. F_AddRess: detailedAddress(),//地址
  530. F_ProductType: $('#productType').find("option:selected").text() === '请选择' ? '' : $('#productType').find("option:selected").text(), //产品代码
  531. F_ProductName: $('#productName').val(), //产品名称
  532. F_Specifications: $('#specification').val(), //规格
  533. F_ProductDate: $('#productDate').val(), //生产日期
  534. F_BatchNumber: $('#productNumber').val(), //产品编码
  535. F_Manufacturer: $('#productFactory').val(), //产品厂家
  536. F_ProblemCode: $('#problemCode').find("option:selected").text() === '请选择' ? '' : $('#problemCode').find("option:selected").text(), //问题代码
  537. F_QualityProblem: $('#qualityProblem').val(), //质量问题
  538. F_Content: $('#remark').val(), //备注
  539. F_Duplicate: $('#duplicate input[name="duplicate"]:checked').val(), //重复工单
  540. },
  541. success: function(data) {
  542. if(data.state.toLowerCase() == 'success') {
  543. $('.customerSubmit').attr("disabled", false);
  544. $('.customerSubmit').text('保存');
  545. layer.msg("保存成功!");
  546. window.location.reload()
  547. } else {
  548. $('.customerSubmit').attr("disabled", false);
  549. $('.customerSubmit').text('保存');
  550. }
  551. }
  552. });
  553. }
  554. function clear() {
  555. $('#name').val('');
  556. $('#tel').val(''); //号码
  557. $('#customer_area').val('');
  558. $('#source').val('');
  559. $('#type').val('');
  560. $('#keyid').val('');
  561. $('#productType').val('');
  562. $('#productName').val('');
  563. $('#specification').val('');
  564. $('#productDate').val('');
  565. $('#productNumber').val('');
  566. $('#productFactory').val('');
  567. $('#problemCode').val('');
  568. $('#qualityProblem').val('');
  569. $('#dealTimely').val('');
  570. $('#reason').val('');
  571. $('#customer_comaddress').val('');
  572. $('#customer_submitter').val('');
  573. $('#cont').val('');
  574. $('#remark').val('');
  575. }