Нет описания

AddWorkOrder.js 18KB

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