No Description

AddWorkOrder.js 18KB

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