Keine Beschreibung

AddWorkOrder.js 18KB

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