Bez popisu

AddWorkOrder.js 18KB

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