暫無描述

xgWork.js 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. var typeSmall;
  2. var id = helper.request.queryString("id");
  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. $(".ns-2").remove();
  22. }
  23. }
  24. }
  25. });
  26. var groupcode = $('#groupcode', top.document).val();
  27. if (groupcode == 'SCZ') {
  28. $("#usedate").text("饮用日期:");
  29. $("#vipid").text("对接人:");
  30. $("#vipphone").text("对接人电话:");
  31. }
  32. // laydate.render({
  33. // elem: '.userDate',
  34. // theme: '#1ab394',
  35. // calendar: 'true'
  36. // });
  37. // laydate.render({
  38. // elem: '.buyDate',
  39. // theme: '#1ab394',
  40. // calendar: 'true'
  41. // });
  42. // laydate.render({
  43. // elem: '#productDate',
  44. // theme: '#1ab394',
  45. // calendar: 'true'
  46. // });
  47. $.ajaxSettings.async = false;
  48. // 产品代码
  49. getProductType();
  50. // 问题代码
  51. getProblemCode();
  52. // 重要级别
  53. getDealTimely();
  54. //产品厂家
  55. getProductFactory();
  56. // 省 办事处
  57. LAISHENG($("#source"));//省
  58. CHOUDQ($("#customer_comaddress")); //办事处
  59. //普通工单禁止选择原因
  60. $('#reason').attr("disabled", "disabled");
  61. //客诉专员
  62. ComplaintVip();
  63. //保存
  64. $('.customerSubmit').click(function() {
  65. saveCustomer();
  66. });
  67. $.ajaxSettings.async = true;
  68. var id = helper.request.queryString("id");
  69. $.ajax({
  70. type: "get",
  71. url: huayi.config.callcenter_url + "WorkOrder/GetDetails",
  72. dataType: 'json',
  73. async: true,
  74. cache: false,
  75. data: {
  76. id: id,
  77. token: $.cookie("token")
  78. },
  79. success: function(result) {
  80. if (result.rows.length > 0) {
  81. var data = result.rows[0];
  82. $("#workOrderId").val(data.F_WorkOrderId); //工单编号
  83. // $("#order_isover").val(data.F_Type); // 工单类别
  84. $("#name").val(data.F_CusName); // 姓名
  85. $("#tel").val(data.F_CusPhone); // 电话
  86. $("#productName").val(data.F_ProductName); // 产品名称
  87. $('#specification').val(data.F_Specifications); // 规格
  88. $("#productDate").val(data.F_ProductDate); // 生产日期
  89. $("#productNumber").val(data.F_BatchNumber); // 产品编码
  90. $("#productFactory").val(data.F_Manufacturer); // 产品厂家
  91. $("#problemCode option:selected").text(data.F_ProblemCode); // 问题代码
  92. $("#problemCode option:selected").val(data.F_ProblemCode); // 问题代码
  93. $("#productType option:selected").text(data.F_ProductType) //产品代码
  94. $("#productType option:selected").val(data.F_ProductType); // 产品代码
  95. $("#qualityProblem").val(data.F_QualityProblem); // 质量问题
  96. $("#duplicate").val(data.F_Duplicate); // 重复工单
  97. $("#remark").val(data.F_Content); // 备注
  98. $("#dealTimely option:selected").text(data.F_DealTimely); //重要级别
  99. $("#dealTimely option:selected").val(data.F_DealTimely); //重要级别
  100. $("#reason option:selected").text(data.F_Reason); //原因
  101. $("#reason option:selected").val(data.F_Reason); //原因
  102. //工单类型
  103. $("#order_isover input[type=radio][name=type][value="+data.F_Type+"]").attr("checked",'checked');
  104. //重复工单
  105. $("#duplicate input[type=radio][name=duplicate][value="+data.duplicate+"]").attr("checked",'checked');
  106. // 工单来源
  107. workOrderSourceDisplay(data);
  108. // 省市县
  109. provinceCity(data)
  110. }
  111. }
  112. });
  113. //获取专员手机号
  114. $("#vipName").change(function() {
  115. $("#vipTel").val($("#vipName option:selected").attr("index"));
  116. //$("#areaInps").val($("#vipName option:selected").attr("areaText"));
  117. $("#typeclass").val($("#vipName option:selected").attr("province") + "/" + $("#vipName option:selected").attr("city"));
  118. $(".inps2").val($("#vipName option:selected").attr("province"));
  119. $(".inps3").val($("#vipName option:selected").attr("city"));
  120. });
  121. })
  122. // 工单来源显示
  123. function workOrderSourceDisplay(data) {
  124. if (data.F_Source === 1) {
  125. $("#workOrderSource").val("PC")
  126. } else if (data.F_Source === 2){
  127. $("#workOrderSource").val("APP")
  128. } else if (data.F_Source === 3) {
  129. $("#workOrderSource").val("微信")
  130. } else {
  131. $("#workOrderSource").val("")
  132. }
  133. }
  134. //省市县回显
  135. function provinceCity(data){
  136. var provinceCityArr = data.F_AddRess.split("-");
  137. $("#source option:selected").text(provinceCityArr[0]);
  138. $("#source option:selected").val(provinceCityArr[0]);
  139. $("#type option:selected").text(provinceCityArr[1]);
  140. $("#type option:selected").val(provinceCityArr[1]);
  141. $("#keyid option:selected").text(provinceCityArr[2]);
  142. $("#keyid option:selected").val(provinceCityArr[2]);
  143. }
  144. //省 市 区/县
  145. //省
  146. function LAISHENG(obj) {
  147. obj.empty();
  148. obj.append('<option selected="selected" value="">请选择</option>');
  149. $.getJSON(huayi.config.callcenter_url + "RegionCategory/GetCountyList", {
  150. "token": $.cookie("token"),
  151. pid: 0,
  152. }, function (data) {
  153. if (data.state.toLowerCase() == "success") {
  154. var content = data.data;
  155. $(content).each(function (i, n) {
  156. $("<option value='" + n.F_RegionId + "'>" + n.F_RegionName + "</option>").appendTo(obj);
  157. })
  158. }
  159. })
  160. }
  161. //市
  162. function LAISHI(obj) {
  163. obj.empty();
  164. obj.append('<option selected="selected" value="">请选择</option>');
  165. $.getJSON(huayi.config.callcenter_url + "RegionCategory/GetCountyList", {
  166. "token": $.cookie("token"),
  167. pid:$('#source').val(),
  168. }, function (data) {
  169. if (data.state.toLowerCase() == "success") {
  170. var content = data.data;
  171. $(content).each(function (i, n) {
  172. $("<option value='" + n.F_RegionId + "'>" + n.F_RegionName + "</option>").appendTo(obj);
  173. })
  174. }
  175. })
  176. }
  177. //区/县
  178. function LAIQU(obj) {
  179. obj.empty();
  180. obj.append('<option selected="selected" value="">请选择</option>');
  181. $.getJSON(huayi.config.callcenter_url + "RegionCategory/GetCountyList", {
  182. "token": $.cookie("token"),
  183. pid:$('#type').val(),
  184. }, function (data) {
  185. if (data.state.toLowerCase() == "success") {
  186. var content = data.data;
  187. $(content).each(function (i, n) {
  188. $("<option value='" + n.F_RegionId + "'>" + n.F_RegionName + "</option>").appendTo(obj);
  189. })
  190. }
  191. })
  192. }
  193. $('#source').on('change',function(){
  194. LAISHI($("#type"));
  195. });
  196. $('#type').on('change',function(){
  197. LAIQU($("#keyid"));
  198. });
  199. //办事处 提交人
  200. function CHOUDQ(obj) {
  201. obj.empty();
  202. obj.append('<option selected="selected" value="">请选择</option>');
  203. $.getJSON(huayi.config.callcenter_url + "Department/GetCusAreaList", {
  204. "token": $.cookie("token"),
  205. pid: 1,
  206. F_Layer: 1,
  207. }, function (data) {
  208. if (data.state.toLowerCase() == "success") {
  209. var content = data.data;
  210. $(content).each(function (i, n) {
  211. $("<option value='" + n.F_DeptId + "'>" + n.F_DeptName + "</option>").appendTo(obj);
  212. })
  213. }
  214. })
  215. }
  216. //办事处
  217. function CHOUFEN(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. F_Layer:2,
  223. pid:$("#customer_comaddress").val(),
  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 + "</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. $("#productFactory").empty();
  354. $("#productFactory").append('<option selected="selected" value="">请选择</option>');
  355. $.getJSON(huayi.config.callcenter_url + "EquipmentNumber/GetList", {
  356. "token": $.cookie("token"),
  357. keywords: "",
  358. pageindex: "1",
  359. pagesize: "200",
  360. }, function (data) {
  361. if (data.state.toLowerCase() == "success") {
  362. var content = data.rows;
  363. $(content).each(function (i, n) {
  364. $("<option value='" + n.F_Production + "'>" + n.F_Production + "</option>").appendTo("#productFactory");
  365. })
  366. }
  367. })
  368. }
  369. // 重要级别显示原因
  370. $('#dealTimely').on('change',function(){
  371. if ($('#dealTimely').val() === 'Ⅰ级'){
  372. $('#reason').val('');
  373. $('#reason').removeAttr("disabled");
  374. getReasonOne();
  375. } else if ($('#dealTimely').val() === 'Ⅱ级' ){
  376. $('#reason').val('');
  377. $('#reason').removeAttr("disabled");
  378. getReasonTwo();
  379. } else {
  380. $('#reason').val('');
  381. $('#reason').attr("disabled", "disabled");
  382. }
  383. })
  384. // 指派事件
  385. $('#isAssign').on('change', function(){
  386. if($('#isAssign input[name="isAssign"]:checked').val() === '1'){
  387. $('.comaddressTitle').show();
  388. $('.comaddressSelect').show();
  389. $('.submitterTitle').show();
  390. $('.submitterSelect').show();
  391. } else if ($('#isAssign input[name="isAssign"]:checked').val() === '2'){
  392. $('.comaddressTitle').hide();
  393. $('.comaddressSelect').hide();
  394. $('.submitterTitle').hide();
  395. $('.submitterSelect').hide();
  396. }
  397. })
  398. // 地址(省+市+区/县)
  399. function detailedAddress() {
  400. if($('#source').val() === ""){
  401. var province = '';
  402. } else {
  403. var province = $('#source').find("option:selected").text()
  404. }
  405. if($('#type').val() === ""){
  406. var city = '';
  407. } else {
  408. var city = $('#type').find("option:selected").text()
  409. }
  410. if($('#keyid').val() === ""){
  411. var county = '';
  412. } else {
  413. var county = $('#keyid').find("option:selected").text()
  414. }
  415. var address = province + '-' + city + '-' + county;
  416. return address;
  417. }
  418. //处理状态
  419. dealState();
  420. function dealState() {
  421. $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', {
  422. "token": $.cookie("token"),
  423. flag: "CLZT"
  424. }, function(result) {
  425. result = $.parseJSON(result);
  426. var Count = result.data;
  427. $(Count).each(function(i, n) {
  428. $('<label style="font-weight: normal; margin-right: 15px;">'+
  429. '<input type="radio" value="' + n.F_DictionaryValueId
  430. + '" name="ltype"/>' + n.F_Name
  431. + '</label>').appendTo($(".disposeST"));
  432. })
  433. $('.disposeST input:radio:first').attr('checked', 'checked');
  434. });
  435. }
  436. //响应状态
  437. responseState();
  438. function responseState() {
  439. $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', {
  440. "token": $.cookie("token"),
  441. flag: "XYZT"
  442. }, function(result) {
  443. result = $.parseJSON(result);
  444. var Count = result.data;
  445. $(Count).each(function(i, n) {
  446. $('<label style="font-weight: normal; margin-right: 15px;">'+
  447. '<input type="radio" value="' + n.F_DictionaryValueId
  448. + '" name="response"/>' + n.F_Name
  449. + '</label>').appendTo($(".responseST"));
  450. })
  451. $('.responseST input:radio:first').attr('checked', 'checked');
  452. });
  453. }
  454. var setting = {
  455. data: {
  456. key: {
  457. name: "F_AreaName"
  458. },
  459. simpleData: {
  460. enable: true,
  461. idKey: "F_Id",
  462. pIdKey: "F_ParentId",
  463. rootPId: 0
  464. }
  465. },
  466. callback: {
  467. onClick: changeTreeClick
  468. }
  469. }
  470. function changeTreeClick(event, treeId, treeNode) {
  471. var areaParent = treeNode.getPath();
  472. if (areaParent[1]) {
  473. areaParent1 = areaParent[0].F_AreaName
  474. areaParent2 = areaParent[1].F_AreaName
  475. $('#typeclass').val(areaParent1 + "/" + areaParent2);
  476. $('.inps2').val(areaParent1);
  477. $('.inps3').val(areaParent2);
  478. ComplaintVip();
  479. } else {
  480. layer.msg("请选择最下级菜单");
  481. }
  482. $('.addTree1').hide();
  483. };
  484. //客诉专员
  485. function ComplaintVip() {
  486. $.ajax({
  487. type: "get",
  488. url: huayi.config.callcenter_url + "Customer/GetAllList",
  489. dataType: 'json',
  490. async: true,
  491. data: {
  492. token: $.cookie("token"),
  493. type: 2,
  494. province: $('.inps2').val(), //省
  495. city: $('.inps3').val() //市
  496. },
  497. success: function(data) {
  498. $("#vipName").empty();
  499. var Count = data.data;
  500. $('<option value="">请选择专员</option>').appendTo($("#vipName"));
  501. $(Count).each(function(i, n) {
  502. $('<option value="' + n.F_Id
  503. + '" index="' + n.F_Phone
  504. + '" areaText="' + n.F_Area
  505. + '" province="' + n.F_Province
  506. + '" city="' + n.F_City + '">' + n.F_Name
  507. + '</option>').appendTo($("#vipName"));
  508. })
  509. }
  510. });
  511. }
  512. //保存
  513. function saveCustomer() {
  514. var val = $("input[name='ltype']:checked").val();
  515. var valRes = $("input[name='response']:checked").val();
  516. var dealCost;
  517. if (isNaN($("#dealCost").val())) {
  518. dealCost="";
  519. }else{
  520. dealCost=$("#dealCost").val();
  521. }
  522. if (!$('#name').val()) {
  523. layer.confirm('请输入姓名!', {
  524. icon: 2,
  525. btn: ['确定']
  526. });
  527. return;
  528. }
  529. if (!$('#tel').val()) {
  530. layer.confirm('请输入电话!', {
  531. icon: 2,
  532. btn: ['确定']
  533. });
  534. return;
  535. }
  536. if(!$('#qualityProblem').val()) {
  537. layer.confirm('请输入质量问题!', {
  538. icon: 2,
  539. btn: ['确定']
  540. });
  541. return;
  542. }
  543. $.ajax({
  544. type: "post",
  545. url: huayi.config.callcenter_url + "WorkOrder/UpdateWorkOrder",
  546. dataType: 'json',
  547. async: true,
  548. beforeSend: function() { //触发ajax请求开始时执行
  549. $('.customerSubmit').attr("disabled", true);
  550. $('.customerSubmit').text('保存中...');
  551. },
  552. data: {
  553. token: $.cookie("token"),
  554. F_Id: id,
  555. F_Type: $('#order_isover input[name="type"]:checked').val(), //工单类型
  556. F_DealTimely: $('#dealTimely').val(), //重要级别
  557. F_Reason: $('#reason').val(), //原因
  558. F_CusName: $('#name').val(), //姓名
  559. F_CusPhone: $('#tel').val(), //号码
  560. F_AddRess: detailedAddress(),//地址
  561. F_ProductType: $('#productType').val(), //产品代码
  562. F_ProductName: $('#productName').val(), //产品名称
  563. F_Specifications: $('#specification').val(), //规格
  564. F_ProductDate: $('#productDate').val(), //生产日期
  565. F_BatchNumber: $('#productNumber').val(), //产品编码
  566. F_Manufacturer: $('#productFactory').val(), //产品厂家
  567. F_ProblemCode: $('#problemCode').val(), //问题代码
  568. F_QualityProblem: $('#qualityProblem').val(), //质量问题
  569. F_Content: $('#remark').val(), //备注
  570. F_Duplicate: $('#duplicate input[name="duplicate"]:checked').val(), //重复工单
  571. },
  572. success: function(data) {
  573. if (data.state.toLowerCase() == 'success') {
  574. $('.customerSubmit').attr("disabled", false);
  575. $('.customerSubmit').text('保存');
  576. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  577. parent.layer.close(index); //再执行关闭
  578. parent.layer.msg("保存成功!");
  579. parent.$('#workorderlist').bootstrapTable('refresh');
  580. parent.$('#orderlist').bootstrapTable('refresh');
  581. } else {
  582. $('.customerSubmit').attr("disabled", false);
  583. $('.customerSubmit').text('保存');
  584. }
  585. }
  586. });
  587. }