No Description

AddWorkOrder.js 18KB

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