新手操作指南Demo - 使用双汇UI代码

xgWork.js 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  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. $("#remark").val(data.F_Content); // 备注
  97. $("#dealTimely option:selected").text(data.F_DealTimely); //重要级别
  98. $("#dealTimely option:selected").val(data.F_DealTimely); //重要级别
  99. $("#reason option:selected").text(data.F_Reason); //原因
  100. $("#reason option:selected").val(data.F_Reason); //原因
  101. //工单类型
  102. $("#order_isover input[type=radio][name=type][value="+data.F_Type+"]").attr("checked",'checked');
  103. //重复工单
  104. $("#duplicate input[type=radio][name=duplicate][value="+data.F_Duplicate+"]").attr("checked",'checked');
  105. // 工单来源
  106. workOrderSourceDisplay(data);
  107. // 省市县
  108. provinceCity(data)
  109. }
  110. }
  111. });
  112. //获取专员手机号
  113. $("#vipName").change(function() {
  114. $("#vipTel").val($("#vipName option:selected").attr("index"));
  115. //$("#areaInps").val($("#vipName option:selected").attr("areaText"));
  116. $("#typeclass").val($("#vipName option:selected").attr("province") + "/" + $("#vipName option:selected").attr("city"));
  117. $(".inps2").val($("#vipName option:selected").attr("province"));
  118. $(".inps3").val($("#vipName option:selected").attr("city"));
  119. });
  120. })
  121. // 工单来源显示
  122. function workOrderSourceDisplay(data) {
  123. if (data.F_Source === 1) {
  124. $("#workOrderSource").val("PC")
  125. } else if (data.F_Source === 2){
  126. $("#workOrderSource").val("APP")
  127. } else if (data.F_Source === 3) {
  128. $("#workOrderSource").val("微信")
  129. } else {
  130. $("#workOrderSource").val("")
  131. }
  132. }
  133. //省市县回显
  134. function provinceCity(data){
  135. var provinceCityArr = data.F_AddRess.split("-");
  136. $("#source option:selected").text(provinceCityArr[0]); //省
  137. $("#source option:selected").val(provinceCityArr[0]);
  138. $("#type option:selected").text(provinceCityArr[1]); //市
  139. $("#type option:selected").val(provinceCityArr[1]);
  140. $("#keyid option:selected").text(provinceCityArr[2]); //县
  141. $("#keyid option:selected").val(provinceCityArr[2]);
  142. $("#addressDescription").val(provinceCityArr[3]); //详细地址描述
  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. $("#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() === '2'){
  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. //处理状态
  425. dealState();
  426. function dealState() {
  427. $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', {
  428. "token": $.cookie("token"),
  429. flag: "CLZT"
  430. }, function(result) {
  431. result = $.parseJSON(result);
  432. var Count = result.data;
  433. $(Count).each(function(i, n) {
  434. $('<label style="font-weight: normal; margin-right: 15px;">'+
  435. '<input type="radio" value="' + n.F_DictionaryValueId
  436. + '" name="ltype"/>' + n.F_Name
  437. + '</label>').appendTo($(".disposeST"));
  438. })
  439. $('.disposeST input:radio:first').attr('checked', 'checked');
  440. });
  441. }
  442. //响应状态
  443. responseState();
  444. function responseState() {
  445. $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', {
  446. "token": $.cookie("token"),
  447. flag: "XYZT"
  448. }, function(result) {
  449. result = $.parseJSON(result);
  450. var Count = result.data;
  451. $(Count).each(function(i, n) {
  452. $('<label style="font-weight: normal; margin-right: 15px;">'+
  453. '<input type="radio" value="' + n.F_DictionaryValueId
  454. + '" name="response"/>' + n.F_Name
  455. + '</label>').appendTo($(".responseST"));
  456. })
  457. $('.responseST input:radio:first').attr('checked', 'checked');
  458. });
  459. }
  460. var setting = {
  461. data: {
  462. key: {
  463. name: "F_AreaName"
  464. },
  465. simpleData: {
  466. enable: true,
  467. idKey: "F_Id",
  468. pIdKey: "F_ParentId",
  469. rootPId: 0
  470. }
  471. },
  472. callback: {
  473. onClick: changeTreeClick
  474. }
  475. }
  476. function changeTreeClick(event, treeId, treeNode) {
  477. var areaParent = treeNode.getPath();
  478. if (areaParent[1]) {
  479. areaParent1 = areaParent[0].F_AreaName
  480. areaParent2 = areaParent[1].F_AreaName
  481. $('#typeclass').val(areaParent1 + "/" + areaParent2);
  482. $('.inps2').val(areaParent1);
  483. $('.inps3').val(areaParent2);
  484. ComplaintVip();
  485. } else {
  486. layer.msg("请选择最下级菜单");
  487. }
  488. $('.addTree1').hide();
  489. };
  490. //客诉专员
  491. function ComplaintVip() {
  492. $.ajax({
  493. type: "get",
  494. url: huayi.config.callcenter_url + "Customer/GetAllList",
  495. dataType: 'json',
  496. async: true,
  497. data: {
  498. token: $.cookie("token"),
  499. type: 2,
  500. province: $('.inps2').val(), //省
  501. city: $('.inps3').val() //市
  502. },
  503. success: function(data) {
  504. $("#vipName").empty();
  505. var Count = data.data;
  506. $('<option value="">请选择专员</option>').appendTo($("#vipName"));
  507. $(Count).each(function(i, n) {
  508. $('<option value="' + n.F_Id
  509. + '" index="' + n.F_Phone
  510. + '" areaText="' + n.F_Area
  511. + '" province="' + n.F_Province
  512. + '" city="' + n.F_City + '">' + n.F_Name
  513. + '</option>').appendTo($("#vipName"));
  514. })
  515. }
  516. });
  517. }
  518. //保存
  519. function saveCustomer() {
  520. var val = $("input[name='ltype']:checked").val();
  521. var valRes = $("input[name='response']:checked").val();
  522. var dealCost;
  523. if (isNaN($("#dealCost").val())) {
  524. dealCost="";
  525. }else{
  526. dealCost=$("#dealCost").val();
  527. }
  528. if (!$('#name').val()) {
  529. layer.confirm('请输入姓名!', {
  530. icon: 2,
  531. btn: ['确定']
  532. });
  533. return;
  534. }
  535. if (!$('#tel').val()) {
  536. layer.confirm('请输入电话!', {
  537. icon: 2,
  538. btn: ['确定']
  539. });
  540. return;
  541. }
  542. if(!$('#qualityProblem').val()) {
  543. layer.confirm('请输入质量问题!', {
  544. icon: 2,
  545. btn: ['确定']
  546. });
  547. return;
  548. }
  549. $.ajax({
  550. type: "post",
  551. url: huayi.config.callcenter_url + "WorkOrder/UpdateWorkOrder",
  552. dataType: 'json',
  553. async: true,
  554. beforeSend: function() { //触发ajax请求开始时执行
  555. $('.customerSubmit').attr("disabled", true);
  556. $('.customerSubmit').text('保存中...');
  557. },
  558. data: {
  559. token: $.cookie("token"),
  560. F_Id: id,
  561. F_Type: $('#order_isover input[name="type"]:checked').val(), //工单类型
  562. F_DealTimely: $('#dealTimely').val(), //重要级别
  563. F_Reason: $('#reason').val(), //原因
  564. F_CusName: $('#name').val(), //姓名
  565. F_CusPhone: $('#tel').val(), //号码
  566. F_AddRess: detailedAddress(),//地址
  567. F_ProductType: $('#productType').val(), //产品代码
  568. F_ProductName: $('#productName').val(), //产品名称
  569. F_Specifications: $('#specification').val(), //规格
  570. F_ProductDate: $('#productDate').val(), //生产日期
  571. F_BatchNumber: $('#productNumber').val(), //产品编码
  572. F_Manufacturer: $('#productFactory').val(), //产品厂家
  573. F_ProblemCode: $('#problemCode').val(), //问题代码
  574. F_QualityProblem: $('#qualityProblem').val(), //质量问题
  575. F_Content: $('#remark').val(), //备注
  576. F_Duplicate: $('#duplicate input[name="duplicate"]:checked').val(), //重复工单
  577. },
  578. success: function(data) {
  579. if (data.state.toLowerCase() == 'success') {
  580. $('.customerSubmit').attr("disabled", false);
  581. $('.customerSubmit').text('保存');
  582. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  583. parent.layer.close(index); //再执行关闭
  584. parent.layer.msg("保存成功!");
  585. parent.$('#workorderlist').bootstrapTable('refresh');
  586. parent.$('#orderlist').bootstrapTable('refresh');
  587. } else {
  588. $('.customerSubmit').attr("disabled", false);
  589. $('.customerSubmit').text('保存');
  590. }
  591. }
  592. });
  593. }