customer.js 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792
  1. /**
  2. *TDS 城市加载
  3. *问题回复选择
  4. *加载三个文本域
  5. *定义全局变量以及监听事件和初始化
  6. * 客诉提交
  7. */
  8. /*===============================TDS 城市加载 -- start -- =============================== */
  9. $(function(){
  10. $("#province").ProvinceCity();
  11. $('.skin-minimal input').iCheck({
  12. checkboxClass: 'icheckbox-blue',
  13. radioClass: 'iradio-blue',
  14. increaseArea: '20%'
  15. });
  16. $("#arrcity").suggest(citys,{hot_list:commoncitys,dataContainer:'#arrcity_3word',onSelect:function(result){
  17. console.log($(this)[0].value);
  18. $("#city2").click()
  19. },
  20. attachObject:'#suggest'
  21. });
  22. $("#city2").suggest(citys,{hot_list:commoncitys,attachObject:"#suggest2"})
  23. });
  24. /*===============================TDS 城市加载 -- start -- =============================== */
  25. /*===============================问题回复选择 -- start -- =============================== */
  26. $(document).on('click', '.dalog-ask .answer', function() {
  27. var QA_complaintId = $(this).find(".QA_complaintId").val();
  28. var QA_smallClassId = $(this).find(".QA_smallClassId").val();
  29. $("select[name='complaintId']").val(QA_complaintId);
  30. initComplaintSmallClassInfo(QA_complaintId,QA_smallClassId); //初始化小类
  31. var questionId = $(this).find(".quesId").val();
  32. var title = $(this).find("span").html();
  33. var desc = $(this).find("#questionProfile").html();
  34. $("#questionId").val(questionId);
  35. $("#describeTitle").val(title);
  36. UE.getEditor('describeContentText').setContent(desc);
  37. //$("#answer-textarea").text();
  38. $(".dalog-ask").hide(); //隐藏qa
  39. });
  40. /*===============================问题回复选择 -- end -- =============================== */
  41. /*===============================加载三个文本域 -- start -- =============================== */
  42. /**
  43. * 百度富文本编辑器的 tool
  44. * 用于客诉的添加/修改 页面的配置
  45. */
  46. var tool = [
  47. 'anchor', //锚点
  48. 'undo', //撤销
  49. 'redo', //重做
  50. 'bold', //加粗
  51. 'indent', //首行缩进
  52. 'snapscreen', //截图
  53. 'italic', //斜体
  54. 'underline', //下划线
  55. 'strikethrough', //删除线
  56. 'subscript', //下标
  57. 'fontborder', //字符边框
  58. 'superscript', //上标
  59. 'formatmatch', //格式刷
  60. // 'source', //源代码 --
  61. 'blockquote', //引用
  62. 'pasteplain', //纯文本粘贴模式
  63. 'selectall', //全选
  64. 'print', //打印
  65. 'preview', //预览
  66. 'horizontal', //分隔线
  67. 'removeformat', //清除格式
  68. 'time', //时间
  69. 'date', //日期
  70. 'unlink', //取消链接
  71. 'insertrow', //前插入行
  72. 'insertcol', //前插入列
  73. 'mergeright', //右合并单元格
  74. 'mergedown', //下合并单元格
  75. 'deleterow', //删除行
  76. 'deletecol', //删除列
  77. 'splittorows', //拆分成行
  78. 'splittocols', //拆分成列
  79. 'splittocells', //完全拆分单元格
  80. 'deletecaption', //删除表格标题
  81. 'inserttitle', //插入标题
  82. 'mergecells', //合并多个单元格
  83. 'deletetable', //删除表格
  84. 'cleardoc', //清空文档
  85. 'insertparagraphbeforetable', //"表格前插入行"
  86. //'insertcode', //代码语言
  87. 'fontfamily', //字体
  88. 'fontsize', //字号
  89. 'paragraph', //段落格式
  90. 'simpleupload', //单图上传
  91. 'insertimage', //多图上传
  92. 'edittable', //表格属性
  93. 'edittd', //单元格属性
  94. 'link', //超链接
  95. 'emotion', //表情
  96. 'spechars', //特殊字符
  97. 'searchreplace', //查询替换
  98. // 'map', //Baidu地图
  99. // 'gmap', //Google地图
  100. 'insertvideo', //视频
  101. 'help', //帮助
  102. 'justifyleft', //居左对齐
  103. 'justifyright', //居右对齐
  104. 'justifycenter', //居中对齐
  105. 'justifyjustify', //两端对齐
  106. 'forecolor', //字体颜色
  107. 'backcolor', //背景色
  108. 'insertorderedlist', //有序列表
  109. 'insertunorderedlist', //无序列表
  110. 'fullscreen', //全屏
  111. 'directionalityltr', //从左向右输入
  112. 'directionalityrtl', //从右向左输入
  113. 'rowspacingtop', //段前距
  114. 'rowspacingbottom', //段后距
  115. 'pagebreak', //分页
  116. 'insertframe', //插入Iframe
  117. 'imagenone', //默认
  118. 'imageleft', //左浮动
  119. 'imageright', //右浮动
  120. 'attachment', //附件
  121. 'imagecenter', //居中
  122. 'wordimage', //图片转存
  123. 'lineheight', //行间距
  124. 'edittip ', //编辑提示
  125. 'customstyle', //自定义标题
  126. 'autotypeset', //自动排版
  127. // 'webapp', //百度应用
  128. 'touppercase', //字母大写
  129. 'tolowercase', //字母小写
  130. 'background', //背景
  131. 'template', //模板
  132. // 'scrawl', //涂鸦
  133. 'music', //音乐
  134. 'inserttable', //插入表格
  135. 'drafts', // 从草稿箱加载
  136. 'charts' // 图表
  137. ];
  138. /*问题描述*/
  139. var describeContentText = UE.getEditor('describeContentText', {
  140. toolbars: [tool],
  141. autoHeightEnabled: true,
  142. autoFloatEnabled: true,
  143. elementPathEnabled : false,/*去掉元素路径*/
  144. zIndex : 5
  145. });
  146. /*处理描述*/
  147. var describeHandleDescText = UE.getEditor('describeHandleDescText', {
  148. toolbars: [tool],
  149. autoHeightEnabled: true,
  150. autoFloatEnabled: true,
  151. elementPathEnabled : false, /*去掉元素路径*/
  152. zIndex : 5
  153. });
  154. /*邮寄地址*/
  155. // var sendAddressSms = UE.getEditor('sendAddressSms', {
  156. // toolbars: [tool],
  157. // autoHeightEnabled: true,
  158. // autoFloatEnabled: true,
  159. // elementPathEnabled : false /*去掉元素路径*/
  160. // });
  161. var isInitSendAddressSms = false;
  162. // sendAddressSms.ready(function() {
  163. // sendAddressSms.setHeight(130); //固定高度
  164. // });
  165. /*===============================加载三个文本域 -- end -- =============================== */
  166. /*===============================定义全局变量以及监听事件和初始化 -- start -- =============================== */
  167. /*处理结果的执行状态*/
  168. var isSolve = {
  169. solved : [],
  170. noSolved : [],
  171. renewed : ["录入客诉","督促用户寄回","录入快递单号","仓库收货","换新发货","发货通知用户","收货后回访"],
  172. maintain : ["录入客诉","督促用户寄回","录入快递单号","仓库收货","品质检测","产线维修","换新发货","发货通知用户","收货后回访"],
  173. reissue : ["录入客诉","生成E订单","督促仓库发货","仓库发货","发货通知用户","收货后回访"],
  174. backGoods : ["录入客诉","督促用户寄回","录入快递单号","仓库收货","品质检测","退款","退货完成"],
  175. noReasonBack : ["录入客诉","督促用户寄回","录入快递单号","仓库收货","品质检测","退款","退货完成"]
  176. }
  177. /*处理结果的变更状态 产品列表表头信息*/
  178. var isSolveTitleMsg = {
  179. solved : [[],[]],
  180. noSolved : [[],[]],
  181. renewed : [["退回产品","退回产品颜色","退回产品配件"],["更换产品","更换产品颜色","更换产品配件"]],
  182. maintain : [["需要维修的产品","需要维修的产品颜色","需要维修的产品配件"],["维修产品","维修产品颜色","维修产品配件"]],
  183. reissue : [["补发产品","补发产品颜色","补发产品配件"],[]],
  184. backGoods : [["退回产品","退回产品颜色","退回产品配件"],[]],
  185. noReasonBack : [["退回产品","退回产品颜色","退回产品配件"],[]]
  186. }
  187. /*===============================定义全局变量以及监听事件和初始化 -- end -- =============================== */
  188. /*===============================正则表达式 -- start -- =============================== */
  189. var phoneReg = /^[1][3,4,5,7,8][0-9]{9}$/;
  190. /*===============================正则表达式 -- end -- =============================== */
  191. /*=============================== 页面加载完成启动事件 -- start -- =============================== */
  192. $(function (){
  193. /* 所有trim_input 样式,input框都需要去除前后空格*/
  194. $(".trim_input").change(function(){
  195. var value = $.trim($(this).val());
  196. $(this).val(value);
  197. })
  198. /*监听销售公司选择事件*/
  199. $("#selectCompany").change(function (){
  200. var companyId = $(this).val();
  201. $("#companyId").val(companyId);
  202. setStore(companyId,$("#selectStore")); //获取店铺
  203. })
  204. /*监听店铺选择事件*/
  205. $("#selectStore").change(function (){
  206. var storeId = $(this).val();
  207. $("#storeId").val(storeId);
  208. })
  209. })
  210. /*===============================页面加载完成启动事件 -- end -- =============================== */
  211. /*用于初始化监听回访信息的展示*/
  212. function initVisitEvent(){
  213. $("input[name='customerIsVisit']").change(function (){
  214. if($(this).val() == 2){
  215. $("#needToVisit").css("display","block");
  216. }else{
  217. $("#needToVisit").css("display","none");
  218. }
  219. })
  220. }
  221. /*关闭qa*/
  222. function closeQA(){
  223. $(".dalog-ask").hide(); //隐藏qa
  224. }
  225. /*初始化单选框样式*/
  226. function initCheck(){
  227. $('.skin-minimal input').iCheck({
  228. checkboxClass: 'icheckbox-blue',
  229. radioClass: 'iradio-blue',
  230. increaseArea: '20%'
  231. });
  232. }
  233. /*初始化单选框样式*/
  234. function initCheckByNode(node){
  235. node.iCheck({
  236. checkboxClass: 'icheckbox-blue',
  237. radioClass: 'iradio-blue',
  238. increaseArea: '20%'
  239. });
  240. }
  241. /*
  242. * type 1:不需要回访 2:需要回访
  243. * */
  244. function visitByType(type){
  245. if(isUpdate && customerIsVisit){
  246. customerIsVisit = false;
  247. return false;
  248. }
  249. if(1 == type){ //不需要回访
  250. $("#customer-visit-2").iCheck('check'); //设置不需要回访
  251. $("#needToVisit").css("display","none");
  252. }else{
  253. $("#customer-visit-1").iCheck('check'); //设置需要回访
  254. $("#needToVisit").css("display","block");
  255. }
  256. initVisitEvent();
  257. }
  258. function initSysAdmin() {
  259. sysAminList = getSysAdmin();
  260. var html = "";
  261. for(var i=0;i<sysAminList.length;i++){
  262. var adminList = sysAminList[i];
  263. if(adminId != null && adminId != "" && adminId != 0 && adminId == adminList.adminId ){
  264. html += '<option value="'+ adminList.adminId +'" selected>'+ adminList.adminName +'(我)</option>';
  265. }else{
  266. html += '<option value="'+ adminList.adminId +'">'+ adminList.adminName +'</option>';
  267. }
  268. }
  269. $("#adminId").html(html);
  270. }
  271. /*初始化回访客服的选择*/
  272. function initVisitSysAdmin(){
  273. var html = "";
  274. var flag = false;
  275. for(var i=0;i<sysAminList.length;i++){
  276. var adminList = sysAminList[i];
  277. if(adminId != null && adminId != "" && adminId != 0 && adminId == adminList.adminId ){
  278. html += '<option value="'+ adminList.adminId +'" selected>'+ adminList.adminName +'(我)</option>';
  279. flag = true;
  280. }else{
  281. html += '<option value="'+ adminList.adminId +'">'+ adminList.adminName +'</option>';
  282. }
  283. }
  284. $("#visitAdminId").html(html);
  285. if(flag){
  286. showVisitMsg(1);
  287. }
  288. }
  289. /**
  290. * 用于显示回访指派任务提示信息
  291. * 1 :自己
  292. * 2 :其他人
  293. */
  294. function showVisitMsg(type,adminName) {
  295. if(type == 1){
  296. $("#visitAdminIdMsg").html("您将为自己指定一个回访任务");
  297. }else{
  298. $("#visitAdminIdMsg").html("您将为"+ adminName +"指定一个回访任务");
  299. }
  300. }
  301. function getSysAdmin(){
  302. if(sysAminList != null && sysAminList.length > 0){
  303. return sysAminList
  304. }
  305. $.ajax({
  306. type: "POST",
  307. data: {
  308. },
  309. url: url_path + "/admin/customer/select_sys_admin",
  310. async: false,
  311. success: function(data){
  312. if (data.returnCode == 200) {
  313. sysAminList = data.returnMsg.adminList;
  314. adminId = data.returnMsg.adminId;
  315. }
  316. },
  317. error: function(XmlHttpRequest, textStatus, errorThrown){
  318. }
  319. });
  320. return sysAminList;
  321. }
  322. /*初始化产品类型 -- 客诉头部的产品类型单选*/
  323. function initProduceType(){
  324. var html = "";
  325. $.ajax({
  326. type: "POST",
  327. data: {
  328. },
  329. url: url_path + "/admin/customer/select_produce_type",
  330. async: false,
  331. success: function(data){
  332. if (data.returnCode == 200) {
  333. var check = "checked";
  334. for(var i=0;i<data.returnMsg.productTypeList.length;i++){
  335. var produce = data.returnMsg.productTypeList[i];
  336. html += ' <div class="radio-box">' +
  337. '<input type="radio" id="produce-type-'+ i +'" name="typeId" typeCompany="'+ produce.typeCompany +'" datatype="*" value="'+ produce.typeId +'" '+ check +' nullmsg="请选择产品类型!" >' +
  338. ' <label for="produce-type-'+ i +'">'+ produce.typeName +'</label>' +
  339. ' </div>';
  340. check = "";
  341. }
  342. }else{
  343. html = '';
  344. }
  345. },
  346. error: function(XmlHttpRequest, textStatus, errorThrown){
  347. }
  348. });
  349. $("#produceTypeHtml").html(html);
  350. initCheck();
  351. }
  352. /**
  353. * 选择处理结果-- 默认选择已解决
  354. * type : 1 :已解决 2:未解决 3:换新 4:维修 5:补发 6:退货 7:无理由退货
  355. */
  356. function initProcessResult(type){
  357. if(type == null || type == ""){
  358. type = 1;
  359. }
  360. allCustomerType = type;
  361. if(allCustomerInfoType == null || allCustomerInfoType == ""){
  362. allCustomerInfoType = $("input[name='customerCounselType']:checked").val();
  363. }
  364. var statusHtml = '<li><span class="arrow"></span><div class="number">status_index</div><div>status_html</div></li>';
  365. var resultHtml = '';
  366. var result = {};
  367. var resultProductTableTitle = {};
  368. $("#solved").show(); //已解决
  369. $("#noSolved").show();//未解决
  370. if(allCustomerInfoType == 1){ //售前
  371. $("#renewed").hide();
  372. $("#maintain").hide();
  373. $("#reissue").hide();
  374. $("#backGoods").hide();
  375. $("#noReasonBack").hide();
  376. switch(type)
  377. {
  378. case 1:
  379. otherHied();
  380. visitByType(1);
  381. getCompany();
  382. break;
  383. case 2:
  384. otherHied();
  385. visitByType(2);
  386. getCompany();
  387. break;
  388. default:
  389. break;
  390. }
  391. }else if(allCustomerInfoType == 2){ //售后
  392. if(!isInitSendAddressSms){
  393. initComplaintQuestionInfo("m");
  394. isInitSendAddressSms = true;
  395. }
  396. if(isUpdate){ //修改页面加载省市区
  397. setAddressInfo(); //修改页面才会调用
  398. }else{
  399. /* 在选择售后类型是,直接初始化省市区,使用isInitAddress 变量来判断 */
  400. if(isInitAddress == 0){
  401. var proId = setPro(null,2);
  402. var cityId = setCity(null,proId,2);
  403. setDistrict(null,cityId,2);
  404. isInitAddress = 1;
  405. }
  406. }
  407. $("#renewed").show();
  408. $("#maintain").show();
  409. $("#reissue").show();
  410. $("#backGoods").show();
  411. $("#noReasonBack").show();
  412. switch(type)
  413. {
  414. case 1:
  415. otherHied();
  416. visitByType(1);
  417. getCompany();
  418. break;
  419. case 2:
  420. otherHied();
  421. visitByType(2); //需要回访
  422. getCompany();
  423. break;
  424. case 3: //换新
  425. result = isSolve.renewed;
  426. resultProductTableTitle = isSolveTitleMsg.renewed;
  427. $("#relationProduct").html("换新产品");
  428. $("#processResultStatus").show();
  429. $("#orderHead").show();
  430. $("#order").show();
  431. //$("#recipientInfo").show();
  432. //$("#recipientInfoTitle").show();
  433. //$("#recipientAddress").show();
  434. //$("#recipientAddressText").show();
  435. //$("#renewedProduct").show();
  436. $("#TDScollect").show();
  437. $("#TDScollectShow").show();
  438. $("#sendAddressInfo").show();
  439. $("#sendAddressByPhone").show();
  440. $("#updateProduct").hide(); //换新产品
  441. $("#postageAccount").show(); //邮费转账账户
  442. visitByType(2); //需要回访
  443. $("#salesChannelsSelect").hide(); //屏蔽销售公司
  444. break;
  445. case 4: //维修
  446. result = isSolve.maintain;
  447. resultProductTableTitle = isSolveTitleMsg.maintain;
  448. $("#relationProduct").html("维修产品");
  449. $("#processResultStatus").show();
  450. $("#orderHead").show();
  451. $("#order").show();
  452. //$("#recipientInfo").show();
  453. //$("#recipientInfoTitle").show();
  454. //$("#recipientAddress").show();
  455. //$("#recipientAddressText").show();
  456. //$("#renewedProduct").show();
  457. $("#TDScollect").show();
  458. $("#TDScollectShow").show();
  459. $("#sendAddressInfo").show();
  460. $("#sendAddressByPhone").show();
  461. $("#updateProduct").hide();//维修产品
  462. $("#postageAccount").show(); //邮费转账账户
  463. visitByType(2); //需要回访
  464. $("#salesChannelsSelect").hide(); //屏蔽销售公司
  465. break;
  466. case 5://补发
  467. result = isSolve.reissue;
  468. resultProductTableTitle = isSolveTitleMsg.reissue;
  469. $("#relationProduct").html("补发产品");
  470. $("#processResultStatus").show();
  471. $("#orderHead").show();
  472. $("#order").show();
  473. //$("#recipientInfo").show();
  474. //$("#recipientInfoTitle").show();
  475. // $("#recipientAddress").show();
  476. // $("#recipientAddressText").show();
  477. //$("#renewedProduct").show();
  478. $("#TDScollect").show();
  479. $("#TDScollectShow").show();
  480. $("#sendAddressInfo").hide();
  481. $("#sendAddressByPhone").hide();
  482. $("#updateProduct").hide();
  483. $("#postageAccount").hide(); //邮费转账账户 -- 隐藏
  484. visitByType(2); //需要回访
  485. $("#salesChannelsSelect").hide(); //屏蔽销售公司
  486. break;
  487. case 6: //退货
  488. result = isSolve.backGoods;
  489. resultProductTableTitle = isSolveTitleMsg.backGoods;
  490. $("#relationProduct").html("退货产品");
  491. $("#processResultStatus").show();
  492. $("#orderHead").show();
  493. $("#order").show();
  494. // $("#recipientInfo").show();
  495. //$("#recipientInfoTitle").show();
  496. //$("#recipientAddress").show();
  497. //$("#recipientAddressText").show();
  498. //$("#renewedProduct").show();
  499. $("#TDScollect").show();
  500. $("#TDScollectShow").show();
  501. $("#sendAddressInfo").show();
  502. $("#sendAddressByPhone").show();
  503. $("#updateProduct").hide();
  504. $("#postageAccount").show(); //邮费转账账户
  505. visitByType(2); //需要回访
  506. $("#salesChannelsSelect").hide(); //屏蔽销售公司
  507. break;
  508. case 7://无理由退货
  509. result = isSolve.noReasonBack;
  510. resultProductTableTitle = isSolveTitleMsg.noReasonBack;
  511. $("#relationProduct").html("退货产品");
  512. $("#processResultStatus").show();
  513. $("#orderHead").show();
  514. $("#order").show();
  515. //$("#recipientInfo").show();
  516. //$("#recipientInfoTitle").show();
  517. //$("#recipientAddress").show();
  518. //$("#recipientAddressText").show();
  519. //$("#renewedProduct").show();
  520. $("#TDScollect").show();
  521. $("#TDScollectShow").show();
  522. $("#sendAddressInfo").show();
  523. $("#sendAddressByPhone").show();
  524. $("#updateProduct").hide();
  525. $("#postageAccount").show(); //邮费转账账户
  526. visitByType(2); //需要回访
  527. $("#salesChannelsSelect").hide(); //屏蔽销售公司
  528. break;
  529. default:
  530. break;
  531. }
  532. }
  533. for(var i=0;i< result.length;i++){
  534. var html = statusHtml.replace("status_index",i+1);
  535. html = html.replace("status_html",result[i]);
  536. resultHtml += html;
  537. }
  538. if(resultProductTableTitle != null && resultProductTableTitle.length > 0){
  539. /* 根据处理类型来切换 产品列表的列名称 */
  540. for(var i=0;i<resultProductTableTitle[0].length;i++){
  541. $("#table1").find("th").eq(i).html(resultProductTableTitle[0][i]);
  542. }
  543. for(var i=0;i<resultProductTableTitle[1].length;i++){
  544. $("#table2").find("th").eq(i).html(resultProductTableTitle[1][i]);
  545. }
  546. }
  547. $("#processResultStatus").html(resultHtml);
  548. }
  549. /*已解决|未解决 */
  550. function otherHied(){
  551. $("#salesChannelsSelect").show(); //展示销售公司
  552. $("#processResultStatus").hide(); //处理结果的执行状态 已解决未解决没有该信息
  553. $("#orderHead").hide();
  554. $("#order").hide();
  555. $("#recipientInfo").hide();
  556. $("#recipientInfoTitle").hide();
  557. $("#recipientAddress").hide();
  558. $("#recipientAddressText").hide();
  559. $("#renewedProduct").hide();
  560. $("#TDScollect").hide();
  561. $("#TDScollectShow").hide();
  562. $("#sendAddressInfo").hide();
  563. $("#sendAddressByPhone").hide();
  564. $("#updateProduct").hide();
  565. }
  566. /*初始化问题大类*/
  567. function initComplaintTypeInfo() {
  568. //默认为售前咨询
  569. //var customerCounselTypeOverall = allCustomerInfoType;
  570. var customerCounselTypeOverall = null;
  571. $.ajax({
  572. type: "POST",
  573. data: {
  574. complaintConsultingType : customerCounselTypeOverall
  575. },
  576. url: url_path + "/admin/complaintQuestion/list_complaintType",
  577. async: true,
  578. success: function(data){
  579. var html = '<option value="">请选择问题分类</option>';
  580. var id;
  581. if (data.returnCode == 200) {
  582. for(var i=0;i<data.returnMsg.complaintTypeInfoList.length;i++){
  583. var complaintTypeInfo = data.returnMsg.complaintTypeInfoList[i];
  584. if(i == 0 ){
  585. id = complaintTypeInfo.complaintId;
  586. }
  587. html += '<option value="'+ complaintTypeInfo.complaintId +'">'+ complaintTypeInfo.complaintClassName +'</option>';
  588. }
  589. }else{
  590. html = '';
  591. }
  592. $("[name='complaintId']").html(html);
  593. },
  594. error: function(XmlHttpRequest, textStatus, errorThrown){
  595. }
  596. });
  597. }
  598. /*显示小类*/
  599. function initComplaintSmallClassInfo(complaintId,smallId){
  600. if(complaintId == null || complaintId == ""){
  601. var html = '<option value="">请选择问题小类</option>';
  602. $("[name='smallClassId']").html(html);
  603. }else{
  604. $.ajax({
  605. type: "POST",
  606. data: {
  607. complaintId : complaintId
  608. },
  609. url: url_path + "/admin/complaintQuestion/list_complaintSmallClass",
  610. async: true,
  611. success: function(data){
  612. var html = '<option value="">请选择问题小类</option>';
  613. if (data.returnCode == 200) {
  614. for(var i=0;i<data.returnMsg.complaintSmallClassInfoList.length;i++){
  615. var ComplaintSmallClassInfo = data.returnMsg.complaintSmallClassInfoList[i];
  616. html += '<option value="'+ ComplaintSmallClassInfo.smallClassId +'">'+ ComplaintSmallClassInfo.smallClassName +'</option>';
  617. }
  618. }else{
  619. html = '';
  620. }
  621. $("[name='smallClassId']").html(html);
  622. if(smallId != null && smallId != "" && typeof(smallId)!="undefined" ){
  623. $("select[name='smallClassId']").val(smallId);
  624. }
  625. },
  626. error: function(XmlHttpRequest, textStatus, errorThrown){
  627. }
  628. });
  629. }
  630. }
  631. /**
  632. * 搜索QA 显示
  633. * type p:问题qa; m:邮寄qa
  634. */
  635. function initComplaintQuestionInfo(type){
  636. var complaintId;
  637. var smallClassId;
  638. var questionName;
  639. var customerCounselType;
  640. var questionId;
  641. if(type == "p"){
  642. complaintId = $("[name='complaintId']").val();
  643. smallClassId = $("[name='smallClassId']").val();
  644. questionName = $("[name='questionIdMsg']").val();
  645. customerCounselType = $("[name='customerCounselType']:checked").val();
  646. }else if(type == "m"){
  647. questionId = complaint_questionId;
  648. }
  649. $.ajax({
  650. type: "POST",
  651. data: {
  652. complaintId : complaintId,
  653. smallClassId : smallClassId,
  654. questionName : questionName,
  655. /*complaintType : customerCounselType,*/
  656. questionId : questionId
  657. },
  658. url: url_path + "/admin/complaintQuestion/list_complaintQuestion",
  659. async: false,
  660. success: function(data){
  661. if(type == "p"){
  662. var html = "";
  663. if (data.returnCode == 200) {
  664. for(var i=0;i<data.returnMsg.complaintQuestionInfoList.length;i++){
  665. var complaintQuestion= data.returnMsg.complaintQuestionInfoList[i];
  666. //html += '<li class="ask">'+ complaintQuestion.questionName +'' +
  667. // '</li>' +
  668. // '<li class="answer" style="height: 65px;overflow: hidden;">答:<span>'+ complaintQuestion.questionProfile +'</span><input class="quesId" type="hidden" value="'+ complaintQuestion.questionId +'"></li>';
  669. html += '' +
  670. '<li class="answer" style="height: 20px;overflow: hidden;border-bottom: 1px solid #ddd;"><span>'+ complaintQuestion.questionName +'</span>' +
  671. '<input class="QA_complaintId" type="hidden" value="'+ complaintQuestion.complaintId +'">' +
  672. '<input class="QA_smallClassId" type="hidden" value="'+ complaintQuestion.smallClassId +'">' +
  673. '<input class="quesId" type="hidden" value="'+ complaintQuestion.questionId +'">' +
  674. '<div id="questionProfile" style="display: block">'+ complaintQuestion.questionProfile +'</div>' +
  675. '</li>';
  676. }
  677. }else{
  678. html = '<span style="font-size: 12px; margin-top: 10px; display: block;">未搜索到QA信息,请更换关键字或者直接录入到系统!</span>';
  679. }
  680. $("#question").html(html);
  681. $(".dalog-ask").show();
  682. }else if(type == "m"){
  683. var msg = "";
  684. if (data.returnCode == 200) {
  685. msg = data.returnMsg.complaintQuestionInfoList[0].questionProfile;
  686. }
  687. addSmsMsg(msg);
  688. }
  689. },
  690. error: function(XmlHttpRequest, textStatus, errorThrown){
  691. }
  692. });
  693. }
  694. /*添加邮寄信息*/
  695. function addSmsMsg(msg){
  696. /*sendAddressSms.addListener("ready", function () {
  697. // editor准备好之后才可以使用
  698. sendAddressSms.setContent(msg);
  699. });*/
  700. /*邮寄信息*/
  701. $("#sendAddressSmsHtml").html(msg);
  702. }
  703. /**
  704. * 发送短信
  705. * @param type 类型: "problem" 问题处理; mailAddress:邮寄地址;
  706. * @param node 返回结果显示节点
  707. */
  708. function sendPhone(type,node){
  709. var index = layer.load(1, {
  710. shade: [0.5,'#fff'] //0.1透明度的白色背景
  711. });
  712. var desc = "";
  713. var phone = "";
  714. var questionId = "";
  715. var describeTitle = "";
  716. var smallClassId = ""; /* 客诉问题类型小类id */
  717. var typeCompany = parseInt($("input:radio[name='typeId']:checked").attr("typeCompany"));
  718. if(type == "p"){
  719. phone = $("#p-phone").val();
  720. questionId = $("#questionId").val();
  721. describeTitle = $("#describeTitle").val();
  722. desc = UE.getEditor('describeContentText').getContent();
  723. smallClassId = $("#smallClassId").val();
  724. if(smallClassId == null || smallClassId == "" ){
  725. layer.close(index);
  726. layer.msg("请选择问题分类!", {icon: 5, time: 3000});
  727. return false;
  728. }
  729. if(describeTitle==null || describeTitle == ""){
  730. layer.close(index);
  731. layer.msg("请填写问题标题!", {icon: 5, time: 3000});
  732. return false;
  733. }
  734. if(describeTitle.length > 50){
  735. layer.close(index);
  736. layer.msg("问题标题长度不能高于50个字符!", {icon: 5, time: 3000});
  737. return false;
  738. }
  739. if(desc == null || desc == ""){
  740. layer.close(index);
  741. layer.msg("请填写问题回复!", {icon: 5, time: 3000});
  742. return false;
  743. }
  744. }else if(type == "m"){
  745. phone = $("#m-phone").val();
  746. questionId = complaint_questionId;
  747. //desc = UE.getEditor('sendAddressSms').getContent();
  748. //desc = $("#sendAddressSmsHtml").html(); //取值从html填写 -- 邮寄地址不用传过去,直接后台取
  749. // if(desc == null || desc == ""){
  750. // layer.close(index);
  751. // layer.msg("请填写邮寄信息内容!", {icon: 5, time: 3000});
  752. // return false;
  753. // }
  754. }else{
  755. layer.close(index);
  756. layer.msg("发送报错!", {icon: 5, time: 3000});
  757. return false;
  758. }
  759. var reg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
  760. if(!reg.test(phone)){
  761. layer.close(index);
  762. layer.msg("请填写正确的手机号码!", {icon: 5, time: 3000});
  763. return false;
  764. }
  765. $.ajax({
  766. type: "POST",
  767. data: {
  768. type : type,
  769. typeCompany : typeCompany,
  770. phone : phone,
  771. questionId : questionId,
  772. smallClassId : smallClassId,
  773. questionName : describeTitle,
  774. questionProfile : desc //回复内容
  775. },
  776. url: url_path + "/admin/customer/send_phone_sms",
  777. async: true,
  778. success: function(data){
  779. if (data.returnCode == 200) {
  780. if(type == "p"){
  781. $("#p-msg").html(data.resultMsg);
  782. }else if(type == "m"){
  783. $("#m-msg").html(data.resultMsg);
  784. }
  785. }else{
  786. if(type == "p"){
  787. $("#p-msg").html(data.resultMsg);
  788. }else if(type == "m"){
  789. $("#m-msg").html(data.resultMsg);
  790. }
  791. }
  792. layer.close(index);
  793. },
  794. error: function(XmlHttpRequest, textStatus, errorThrown){
  795. if(type == "p"){
  796. $("#p-msg").html("发送短信失败!");
  797. }else if(type == "m"){
  798. $("#m-msg").html("发送短信失败!");
  799. }
  800. layer.close(index);
  801. }
  802. });
  803. }
  804. /*保存QA问题 type=1 表示为用户点击 type=2表示自动触发*/
  805. function saveQuestion(type){
  806. var index = layer.load(1, {
  807. shade: [0.5,'#fff'] //0.1透明度的白色背景
  808. });
  809. var desc = "";
  810. var questionId = "";
  811. var describeTitle = "";
  812. var smallClassId = ""; /* 客诉问题类型小类id */
  813. questionId = $("#questionId").val();
  814. describeTitle = $("#describeTitle").val();
  815. desc = UE.getEditor('describeContentText').getContent();
  816. smallClassId = $("#smallClassId").val();
  817. if((smallClassId == null || smallClassId == "") && (questionId == null || questionId == "") ){
  818. layer.close(index);
  819. layer.msg("请选择问题分类!", {icon: 5, time: 3000});
  820. return false;
  821. }
  822. if(describeTitle==null || describeTitle == ""){
  823. layer.close(index);
  824. layer.msg("请填写问题标题!", {icon: 5, time: 3000});
  825. return false;
  826. }
  827. if(desc == null || desc == ""){
  828. layer.close(index);
  829. layer.msg("请填写问题回复!", {icon: 5, time: 3000});
  830. return false;
  831. }
  832. $.ajax({
  833. type: "POST",
  834. data: {
  835. questionId : questionId,
  836. smallClassId : smallClassId,
  837. questionName : describeTitle,
  838. questionProfile : desc //回复内容
  839. },
  840. url: url_path + "/admin/complaintQuestion/save_question",
  841. async: false,
  842. success: function(data){
  843. if (data.returnCode == 200) {
  844. $("#questionId").val(data.returnMsg.questionId);
  845. if(type == 1){
  846. layer.msg(data.resultMsg, {icon: 1, time: 3000});
  847. }
  848. }else{
  849. if(type == 1) {
  850. layer.msg(data.resultMsg, {icon: 5, time: 3000});
  851. }
  852. }
  853. layer.close(index);
  854. },
  855. error: function(XmlHttpRequest, textStatus, errorThrown){
  856. layer.close(index);
  857. }
  858. });
  859. }
  860. /***
  861. * 打开搜索订单框
  862. */
  863. function selectOrder(){
  864. layer_show("搜索订单",url_path + "/admin/customer/select_order","1000","500");
  865. }
  866. /**
  867. * 显示选择的订单
  868. */
  869. function setSelectOrder(orderId){
  870. if(orderId == null || orderId == "" || typeof (orderId)=="undefined"){
  871. layer.msg("未选中订单", {icon: 5, time: 3000});
  872. return false
  873. }
  874. var html = '';
  875. var addresHtml = '';
  876. var address = ''; //地址
  877. var orderItemList = {};
  878. var companyId = ''; //销售公司
  879. var storeId = ''; //店铺
  880. $.ajax({
  881. type: "POST",
  882. data: {
  883. salesId : orderId
  884. },
  885. url: url_path + "/admin/customer/select_salesOrder",
  886. async: false,
  887. success: function(data){
  888. if (data.returnCode == 200) {
  889. for(var i=0;i<data.returnMsg.salesOrderList.length;i++){
  890. var salesOrder = data.returnMsg.salesOrderList[i];
  891. companyId = salesOrder.salesCompanyId;
  892. storeId = salesOrder.salesStoreId;
  893. var productsHtml = '';
  894. var salesOrderItem = salesOrder.salesOrderItemList;
  895. orderItemList = salesOrder.salesOrderItemList;
  896. for(var j=0;j<salesOrderItem.length;j++){
  897. var item = salesOrderItem[j].itemProductName + "*" + salesOrderItem[j].itemNum;
  898. if(j==0){
  899. productsHtml += item
  900. }else{
  901. productsHtml += '<br>'+ item
  902. }
  903. }
  904. var time = formatDate(new Date(salesOrder.salesCreateTime),"yyyy-MM-dd");
  905. html += '' +
  906. ' <td style="text-align: center;">'+ convertUndefinedToEmpty(salesOrder.companyName) +'</td>' +
  907. ' <td style="text-align: center;">'+ convertUndefinedToEmpty(salesOrder.storeName) +'</td>' +
  908. ' <td style="text-align: center;">'+ salesOrder.salesId +'</td>' +
  909. ' <td style="text-align: center;">'+ salesOrder.salesAddressName +'</td>' +
  910. ' <td style="text-align: center;">'+ salesOrder.salesAddressTel +'</td>' +
  911. ' <td style="text-align: center;">'+ salesOrder.salesAmount/100 +'</td>' +
  912. ' <td style="text-align: center;">'+ productsHtml +'</td>' +
  913. ' <td style="text-align: center;">'+ time +'</td>' +
  914. '';
  915. addresHtml = '<td colspan="1" style="text-align: center;">收货地址</td><td colspan="7" class="td-manage text-c" >'+ salesOrder.salesAddressInfo +'</td>' ;
  916. address = salesOrder.salesAddressInfo;
  917. $("#sendName").val(salesOrder.salesAddressName); //收件人名称
  918. $("#sendTel").val(salesOrder.salesAddressTel); //收件人电话号码
  919. var name = $("#customerName").val();
  920. var tel = $("#customerTel").val();
  921. if(name == "" || name == null){
  922. $("#customerName").val(salesOrder.salesAddressName); //收件人名称
  923. }
  924. if(tel == "" || tel == null){
  925. $("#customerTel").val(salesOrder.salesAddressTel); //收件人电话号码
  926. }
  927. }
  928. // $("#showOrderAddress").html(address);
  929. }else{
  930. html = '';
  931. addresHtml = '';
  932. }
  933. $("#showOrder").html(html); //显示订单
  934. $("#showOrderAddress").html(addresHtml); //显示订单地址
  935. $("#showOrderAddress").show();
  936. },
  937. error: function(XmlHttpRequest, textStatus, errorThrown){
  938. }
  939. });
  940. $("#addressInfo").val(address);
  941. setAdress(); //显示地址
  942. setProduce(orderItemList); //显示产品
  943. $("#companyId").val(companyId);
  944. $("#storeId").val(storeId);
  945. $("#orderId").val(orderId);
  946. }
  947. /**
  948. * 设置地址
  949. */
  950. function setAdress(){
  951. var addres = $("#addressInfo").val();
  952. $("#addrssMsg").html("");
  953. if(addres == null){
  954. $("#addrssMsg").html("*未能获取到地址,请手动选择地址");
  955. return;
  956. }
  957. var addresList = addres.split("-");
  958. if(addresList[0] == null || addresList[1]==null || addresList[2]==null || addresList[3]==null){
  959. $("#addrssMsg").html("*未能获取到地址,请手动选择地址");
  960. return;
  961. }
  962. var proId = setPro(getAddress(addresList[0],0),1);
  963. var cityId = setCity(getAddress(addresList[1],1),proId,1);
  964. setDistrict(getAddress(addresList[2],2),cityId,1);
  965. var sendAddress = addresList[3];
  966. if(addresList.length > 4){
  967. for(var k = 4;k< addresList.length;k++){
  968. sendAddress += addresList[k];
  969. }
  970. }
  971. $("#sendAddress").val(sendAddress);
  972. }
  973. /***
  974. * 删除 “省”,“市”,“区”关键字
  975. * type : 0:省 2:市 3:区
  976. */
  977. function getAddress(addrss,type) {
  978. var abbreviation = "";
  979. if(addrss == ""){
  980. abbreviation = "";
  981. }else{
  982. switch(type)
  983. {
  984. case 0:
  985. //var proReg = new RegExp("省","g");
  986. //abbreviation = addrss.replace(proReg,"");
  987. abbreviation = addrss.substring(0,2);
  988. break;
  989. case 1:
  990. var cityReg = new RegExp("市","g");
  991. abbreviation = addrss.replace(cityReg,"");
  992. cityReg = new RegExp("区","g");
  993. abbreviation = addrss.replace(cityReg,"");
  994. break;
  995. case 2:
  996. var districtReg = new RegExp("区","g");
  997. abbreviation = addrss.replace(districtReg,"");
  998. districtReg = new RegExp("市","g");
  999. abbreviation = abbreviation.replace(districtReg,"");
  1000. break;
  1001. default:
  1002. break;
  1003. }
  1004. }
  1005. return abbreviation
  1006. }
  1007. /**
  1008. * 设置省
  1009. * type 1:搜索订单赋值 2:只查询全部,默认第一个
  1010. */
  1011. function setPro(provinceName,type) {
  1012. var proId = '';
  1013. var province = listProvince();
  1014. var selectPro = new Array();
  1015. if(type == 1){
  1016. selectPro = listProvince("",provinceName);
  1017. }
  1018. if(province!=null){
  1019. var provinceHtml = ''
  1020. for(var i=0;i<province.length;i++){
  1021. provinceHtml += '<option value="'+ province[i].provinceId +'">'+ province[i].province +'</option>';
  1022. }
  1023. $("#province").html(provinceHtml);
  1024. if(selectPro != null && selectPro.length > 0 ){
  1025. proId = selectPro[0].provinceId;
  1026. }else{
  1027. proId = province[0].provinceId;
  1028. }
  1029. $("#province option[value='" + proId + "']").attr("selected","true");
  1030. }
  1031. return proId;
  1032. }
  1033. /**
  1034. * 设置市
  1035. * type 1:搜索订单赋值 2:只查询全部,默认第一个
  1036. */
  1037. function setCity(cityName,proId,type) {
  1038. var cityId = '';
  1039. var city = listCity(proId,"");
  1040. var selectCity = new Array();
  1041. if(type == 1){
  1042. selectCity = listCity(proId,cityName);
  1043. }
  1044. if(city!=null){
  1045. var cityHtml = ''
  1046. for(var i=0;i<city.length;i++){
  1047. cityHtml += '<option value="'+ city[i].cityId +'">'+ city[i].city +'</option>';
  1048. }
  1049. $("#city").html(cityHtml);
  1050. if(selectCity != null && selectCity.length > 0 ){
  1051. cityId = selectCity[0].cityId;
  1052. }else{
  1053. cityId = city[0].cityId;
  1054. }
  1055. $("#city option[value='" + cityId + "']").attr("selected","true");
  1056. }
  1057. return cityId;
  1058. }
  1059. /**
  1060. * 设置区
  1061. * type 1:搜索订单赋值 2:只查询全部,默认第一个
  1062. */
  1063. function setDistrict(districtName,cityId,type) {
  1064. var district = listDistrict(cityId,"");
  1065. var selectDistrict = new Array();
  1066. if(type == 1){
  1067. selectDistrict = listDistrict(cityId,districtName);
  1068. }
  1069. if(district!=null){
  1070. var districtHtml = ''
  1071. for(var i=0;i<district.length;i++){
  1072. districtHtml += '<option value="'+ district[i].districtId +'">'+ district[i].district +'</option>';
  1073. }
  1074. var disId = "";
  1075. $("#district").html(districtHtml);
  1076. if(selectDistrict != null && selectDistrict.length > 0 ){
  1077. disId = selectDistrict[0].districtId;
  1078. }else{
  1079. disId = district[0].districtId;
  1080. }
  1081. $("#district option[value='" + disId + "']").attr("selected","true");
  1082. }
  1083. }
  1084. /* TDS收集设置区 */
  1085. var TDSCity = '';
  1086. function linkageSetDistrict(){
  1087. var arrcity_3word = $("#arrcity_3word").val();
  1088. var cityName = '北京';
  1089. for(var i = 0;i<citys.length;i++){
  1090. for(var j=0;j<citys[i].length;j++){
  1091. if(j == 0 && arrcity_3word == citys[i][j]){
  1092. cityName = citys[i][1];
  1093. }
  1094. }
  1095. }
  1096. TDSCity = cityName;
  1097. var selectCity = listCity(null,cityName);
  1098. var cityId = selectCity[0].cityId;
  1099. var selectDistrict = listDistrict(cityId,"");
  1100. var html = '';
  1101. for(var i=0;i<selectDistrict.length;i++){
  1102. html += '<option value="'+ selectDistrict[i].districtId +'">'+ selectDistrict[i].district +'</option>';
  1103. }
  1104. $("#TDSArea").html(html);
  1105. $("#TDSArea").find("option").eq(0).prop("selected",true);
  1106. setTDSCollect();
  1107. }
  1108. /**
  1109. * 展示产品
  1110. * @param orderItemList
  1111. */
  1112. function setProduce(orderItemList) {
  1113. var productList = getProduct() ; //所有产品
  1114. var html = "";
  1115. var productTypeNo = 0;
  1116. for(var i=0;i<productList.length;i++) {
  1117. var product = productList[i];
  1118. var produceFittings = getProduceFittings(product.productId); //获取该产品的所有配件
  1119. var colorList = product.colorList; //该产品的所有颜色
  1120. var productType = product.productType;
  1121. var colorHtml = '';
  1122. if(colorList != null && colorList.length >0 ){
  1123. colorHtml += '<table style="height: 100%;">';
  1124. for(var j=0;j<colorList.length;j++){
  1125. var number = "";
  1126. var color = colorList[j];
  1127. for(var k=0;k<orderItemList.length;k++){
  1128. var item = orderItemList[k];
  1129. if(item.itemColorId == color.colorId && item.itemIsSource == 1){
  1130. number = item.itemNum;
  1131. }
  1132. }
  1133. var fristInputStyle = "border-top: 1px solid #ddd;";
  1134. if(color.colorProductId == product.productId) {
  1135. colorHtml += '<tr >' +
  1136. ' <td width="55" style="border-left: none;text-align: center;'+ fristInputStyle +'">' + color.colorName + '</td>' +
  1137. ' <td width="45" style="'+ fristInputStyle +' padding: 0px;width: 25px;">' +
  1138. ' <input type="hidden" class="input-produce-id" value="' + color.colorProductId + '">' +
  1139. ' <input type="hidden" class="input-color-id" value="' + color.colorId + '">' +
  1140. ' <input type="text" class="input-text input-color-number number-input" style="width: 100%;border: none;text-align: center;" value="'+ number +'" placeholder="产品数量" id="color-' + color.colorProductId + '-' + color.colorId + '" name="" onkeyup="keyFun($(this),999)" onpaste="keyFun($(this),999)" >' +
  1141. ' </td>' +
  1142. ' </tr>';
  1143. fristInputStyle = "";
  1144. }
  1145. }
  1146. colorHtml += '</table>';
  1147. }else{
  1148. colorHtml += '<span>暂无该产品的颜色!<span>';
  1149. }
  1150. var produceFittingsHtml = '';
  1151. if(produceFittings != null && produceFittings.length > 0){
  1152. produceFittingsHtml += '<table style="height: 100%;">';
  1153. for(var m=0;m<produceFittings.length;m++){
  1154. var number = "";
  1155. var fitt = produceFittings[m];
  1156. for(var k=0;k<orderItemList.length;k++){
  1157. var item = orderItemList[k];
  1158. if(item.itemColorId == fitt.fittingsId && item.itemIsSource == 2){
  1159. number = item.itemNum;
  1160. }
  1161. }
  1162. var produceFit = produceFittings[m];
  1163. if(produceFit.productId == product.productId) {
  1164. var fristInputStyle = "border-top: 1px solid #ddd;";
  1165. produceFittingsHtml += '<tr >' +
  1166. ' <td width="55" style="border-left: none;text-align: center; '+ fristInputStyle +'">' + produceFit.fittingsName +'</td>' +
  1167. ' <td width="45" style="'+ fristInputStyle +'padding: 0px;width: 25px;">' +
  1168. ' <input type="hidden" class="input-produce-id" value="' + produceFit.productId + '">' +
  1169. ' <input type="hidden" class="input-fittings-id" value="' + produceFit.fittingsId +'">' +
  1170. ' <input type="text" class="input-text input-fittings-number" style="width: 100%;border: none;text-align: center;" value="'+ number +'" placeholder="配件数量" id="fittings-' + produceFit.productId + '-' + produceFit.fittingsId +'" name="" onkeyup="keyFun($(this),999)" onpaste="keyFun($(this),999)" >' +
  1171. ' </td>' +
  1172. ' </tr>';
  1173. fristInputStyle = "";
  1174. }
  1175. }
  1176. produceFittingsHtml += '</table>';
  1177. }else{
  1178. produceFittingsHtml += '<span>暂无产品配件!<span>';
  1179. }
  1180. var produceHtml = '<input type="hidden" value="'+ product.productId +'">' +
  1181. '<span>'+ product.productName +'</span>';
  1182. html += ' <tr >' +
  1183. ' <td width="80">'+ produceHtml +'</td>' +
  1184. ' <td style="padding: 0px;text-align: center;">' +
  1185. colorHtml +
  1186. ' </td>' +
  1187. ' <td style="padding: 0px;text-align: center;">' +
  1188. produceFittingsHtml +
  1189. ' </td>' +
  1190. '</tr>';
  1191. }
  1192. $("#addProduct").html(html);
  1193. setBackProduct(html); //设置寄回产品
  1194. monitorProduct(); //监听产品变化
  1195. }
  1196. /*获取产品*/
  1197. function getProduct(){
  1198. var productList;
  1199. $.ajax({
  1200. type: "POST",
  1201. data: {
  1202. },
  1203. url: url_path + "/admin/customer/select_produce",
  1204. async: false,
  1205. success: function(data){
  1206. if (data.returnCode == 200) {
  1207. productList = data.returnMsg.productList;
  1208. }
  1209. },
  1210. error: function(XmlHttpRequest, textStatus, errorThrown){
  1211. }
  1212. });
  1213. return productList;
  1214. }
  1215. /*获取产品配件*/
  1216. function getProduceFittings(productId){
  1217. var produceFittings;
  1218. $.ajax({
  1219. type: "get",
  1220. data: {
  1221. productId : productId
  1222. },
  1223. url: url_path + "/admin/customer/select_produce_fittings",
  1224. async: false,
  1225. success: function(data){
  1226. if (data.returnCode == 200) {
  1227. produceFittings = data.returnMsg.produceFittingsList;
  1228. }
  1229. },
  1230. error: function(XmlHttpRequest, textStatus, errorThrown){
  1231. }
  1232. });
  1233. return produceFittings;
  1234. }
  1235. /*监听产品变化*/
  1236. function monitorProduct(){
  1237. /*产品数量*/
  1238. $("#addProduct").find(".input-color-number").blur(function (){
  1239. setBackProduct();
  1240. })
  1241. /*产品配件*/
  1242. $("#addProduct").find(".input-fittings-number").blur(function (){
  1243. setBackProduct();
  1244. })
  1245. }
  1246. /*设置寄回产品*/
  1247. function setBackProduct(html) {
  1248. if(html != null && html != "" && typeof(html) != "undefined"){
  1249. $("#back-product").html(html);
  1250. }else{
  1251. $("#addProduct").find(".input-color-number").each(function(){
  1252. var number = $(this).val();
  1253. var colorNodeId = $(this).attr("id");
  1254. $("#back-product").find("#"+colorNodeId).val(number);
  1255. })
  1256. $("#addProduct").find(".input-fittings-number").each(function(){
  1257. var number = $(this).val();
  1258. var fittingsNodeId = $(this).attr("id");
  1259. $("#back-product").find("#"+fittingsNodeId).val(number);
  1260. })
  1261. }
  1262. }
  1263. /*设置TDS收集信息*/
  1264. function setTDSCollect(){
  1265. var TDSArea = $("#TDSArea").find("option:selected").text();
  1266. var TDSAddress = TDSCity + '-' + TDSArea;
  1267. if(TDSAddress != null && TDSAddress != ""){
  1268. $("#DTS-address").html("地址:" + TDSAddress);
  1269. }
  1270. }
  1271. /*TDS联动处理*/
  1272. function TDSLinkage(node,maxNumber,minNumber){
  1273. setTDSCollect();
  1274. var number = 0;
  1275. var c=$(node);
  1276. if(c.val() == ""){
  1277. $(node).val("");
  1278. }else{
  1279. var temp_amount=c.val().replace(/[^\d]/g,'');
  1280. number = Number(temp_amount)
  1281. if(maxNumber!= null && maxNumber!= "" && number > maxNumber){
  1282. number = maxNumber;
  1283. }
  1284. if(minNumber!= null && minNumber!= "" && number < minNumber){
  1285. number = minNumber;
  1286. }
  1287. $(node).val(number);
  1288. }
  1289. var nodeName = $(node).attr("id");
  1290. if(nodeName == "customerInTDS" ){
  1291. $("#DTS-in").html("进水:" + number + " PPM");
  1292. }else if(nodeName == "customerOutTDS" ){
  1293. $("#DTS-out").html("出水:" + number + " PPM");
  1294. }
  1295. }
  1296. /**
  1297. * 获取销售公司
  1298. */
  1299. function getCompany(companyId){
  1300. var currentlyCompanyId = $("#companyId").val();
  1301. if(currentlyCompanyId != null && currentlyCompanyId != ""){
  1302. companyId = currentlyCompanyId;
  1303. }
  1304. $.ajax({
  1305. type: "get",
  1306. data: {
  1307. },
  1308. url: url_path + "/admin/customer/select_company",
  1309. success: function(data){
  1310. if (data.returnCode == 200) {
  1311. var html = '<option value="">销售公司</option>';
  1312. for(var i=0;i<data.returnMsg.companyInfoList.length;i++){
  1313. var company = data.returnMsg.companyInfoList[i];
  1314. html += '<option value="'+ company.companyId +'">'+ company.companyName +'</option>';
  1315. }
  1316. $("#selectCompany").html(html);
  1317. if(typeof(companyId) != "undefined"){
  1318. $("#selectCompany option[value='" + companyId + "']").attr("selected","true");
  1319. if(isUpdate){ //修改页面需要自动获取店铺
  1320. setStore(companyId,$("#selectStore")); //获取店铺
  1321. }
  1322. }
  1323. }
  1324. },
  1325. error: function(XmlHttpRequest, textStatus, errorThrown){
  1326. }
  1327. });
  1328. }
  1329. /**
  1330. * 展示销售公司
  1331. */
  1332. function setStore(companyId,node){
  1333. var html = '<option value="">店铺</option>';
  1334. $.ajax({
  1335. type: "POST",
  1336. data: {
  1337. companyId : companyId
  1338. },
  1339. url: url_path + "/admin/customer/select_storeInfo",
  1340. success: function(data){
  1341. var id;
  1342. if (data.returnCode == 200) {
  1343. for(var i=0;i<data.returnMsg.storeInfoList.length;i++){
  1344. var storeInfo = data.returnMsg.storeInfoList[i];
  1345. html += '<option value="'+ storeInfo.storeId +'">'+ storeInfo.storeName +'</option>';
  1346. }
  1347. }else{
  1348. html = '';
  1349. }
  1350. $(node).html(html);
  1351. var currentlyStoreId = $("#storeId").val();
  1352. if(currentlyStoreId != null && currentlyStoreId != ""){
  1353. $("#selectStore option[value='" + currentlyStoreId + "']").attr("selected","true");
  1354. }
  1355. },
  1356. error: function(XmlHttpRequest, textStatus, errorThrown){
  1357. }
  1358. });
  1359. }
  1360. /*===============================客诉提交 -- start -- =============================== */
  1361. $(function(){
  1362. $("#form-customer-add").Validform({
  1363. tiptype: function (msg, o, cssctl) {
  1364. if (o.type == 3) {//失败
  1365. layer.msg(msg, {icon: 5, time: 3000});
  1366. $(window).scrollTop(o.obj.offset().top - 40);
  1367. }
  1368. },
  1369. datatype: {//自定义验证类型
  1370. },
  1371. ignoreHidden: true,
  1372. tipSweep: true, //若为true,则只在表单提交时验证
  1373. ajaxPost: true, //异步提交
  1374. beforeCheck: function (curform) { //验证通过之前执行的函数
  1375. },
  1376. beforeSubmit: function (curform) { //验证通过之后执行的函数
  1377. var flag = addCustomerReady();
  1378. if(!flag){
  1379. return false;
  1380. }
  1381. },
  1382. callback: function (data) {//异步回调函数
  1383. if (data) {
  1384. var index = layer.alert(data.resultMsg, function (index) {
  1385. if (data.resultCode == 200) {
  1386. location.href = url_path + "/admin/customer/select_customer_list";
  1387. } else if(data.resultCode == 505){
  1388. location.href = url_path + "/admin/customer/select_customer_list";
  1389. }else {
  1390. layer.close(index);
  1391. }
  1392. });
  1393. }
  1394. }
  1395. });
  1396. })
  1397. /* 添加客诉的准备 */
  1398. function addCustomerReady(){
  1399. //保存AQ
  1400. saveQuestion(2);
  1401. /* 录入电话号码和姓名到客诉基本信息里面 */
  1402. /*if(allCustomerType == 3 || allCustomerType == 4 || allCustomerType == 5 || allCustomerType == 6 || allCustomerType == 7){
  1403. $("#customerName").val($("#sendName").val());
  1404. $("#customerTel").val($("#sendTel").val());
  1405. }*/
  1406. var phoneFlag = true;
  1407. $(".associated-phone").each(function () {
  1408. var phone = $(this).val();
  1409. if(phone != null && phone != "" && typeof (phone) != "undefined"){
  1410. if(phone.length != 11){
  1411. vailErrorMsg($(this),"手机号码格式不正确");
  1412. phoneFlag = false;
  1413. }
  1414. if (!phoneReg.test(phone)) {
  1415. vailErrorMsg($(this),"手机号码格式不正确");
  1416. phoneFlag = false;
  1417. }
  1418. }
  1419. })
  1420. if(!phoneFlag){
  1421. return false;
  1422. }
  1423. /*验证来源入口*/
  1424. var customerSourceType = $("input:radio[name='customerSourceType']:checked").val();
  1425. if(customerSourceType == 3){
  1426. var customerSourceOld = $("#customerSourceOld").val();
  1427. if(customerSourceOld == null || customerSourceOld == "" || typeof(customerSourceOld)=="undefined"){
  1428. vailErrorMsg($("#customerSourceOld"),"未填写来源入口");
  1429. return false;
  1430. }else{
  1431. $("#customerSource").val(customerSourceOld);
  1432. }
  1433. }
  1434. /*根据产品类型,获取来源商城*/
  1435. var typeCompany = parseInt($("input:radio[name='typeId']:checked").attr("typeCompany"));
  1436. $("#typeCompany").val(typeCompany);
  1437. /*----TDS收集模块--start-----*/
  1438. var valicity = $(".ac_result_tip").html();
  1439. if(valicity == null || valicity == "" || typeof(valicity)=="undefined"){
  1440. $("#TDSArea").html("");
  1441. }else if(valicity.indexOf("对不起,找不到") > 0 ){
  1442. $("#TDSArea").html("");
  1443. $("#customerArea").val("");
  1444. }else{
  1445. var TDSArea = $("#TDSArea").find("option:selected").text();
  1446. if(TDSArea != null && TDSArea != ""){
  1447. var area = TDSCity + "-" + TDSArea
  1448. $("#customerArea").val(area);
  1449. }
  1450. }
  1451. /*----TDS收集模块--end-----*/
  1452. /* 地址拼接 */
  1453. var province = $("#province").find("option:selected").text();
  1454. var city = $("#city").find("option:selected").text();
  1455. var district = $("#district").find("option:selected").text();
  1456. var relationSendMergeAddress = province + "-" + city + "-" + district;
  1457. $("#relationSendMergeAddress").val(relationSendMergeAddress);
  1458. /* 地址拼接 */
  1459. /*----问题描述- start --*/
  1460. var quId = $("#questionId").val();
  1461. if(quId == null || quId == ""){
  1462. vailErrorMsg($("#questionId"),"未保存QA!");
  1463. return false;
  1464. }
  1465. var describeContentText = UE.getEditor('describeContentText').getContent();
  1466. if(describeContentText == null || describeContentText == ""){
  1467. //layer.msg("未填写问题描述", {icon: 5, time: 3000});
  1468. vailErrorMsg($("#describeTitle"),"未填写问题描述");
  1469. return false;
  1470. }
  1471. if(describeContentText.length > 3000){
  1472. vailErrorMsg($("#describeContent"),"问题回复最大支持3000个字符");
  1473. return false;
  1474. }
  1475. $("#describeContent").val(describeContentText);
  1476. /*----问题描述--end-----*/
  1477. /*----处理描述- start --*/
  1478. var describeHandleDescText = UE.getEditor('describeHandleDescText').getContent();
  1479. if(describeHandleDescText.length > 3000){
  1480. vailErrorMsg($("#describeHandleDesc"),"问题描述最大支持3000个字符");
  1481. return false;
  1482. }
  1483. $("#describeHandleDesc").val(describeHandleDescText);
  1484. /*----处理描述--end-----*/
  1485. /* --- 类型:售后 处理结果:维修/换新/补发/退货/无理由退货 -- 处理产品 start---- */
  1486. var sendProdcues = new Array(); //寄出产品表
  1487. var sendFittings = new Array();
  1488. var closedProdcues = new Array();
  1489. var closedFittings = new Array();
  1490. $("#addProduct").find(".input-color-number").each(function(){
  1491. var number = $(this).val();
  1492. if(number != null && number != "" && number != 0){
  1493. var product = new Object();
  1494. product.productId = $(this).parent().find(".input-produce-id").val();
  1495. product.colorId = $(this).parent().find(".input-color-id").val();
  1496. //换新、维修,退货,无理由退货,
  1497. if(allCustomerType == 3 || allCustomerType == 4 || allCustomerType == 6 || allCustomerType == 7){
  1498. product.closedProdcueNumber = number;
  1499. closedProdcues.push(product);
  1500. }else if(allCustomerType == 5){
  1501. product.sendProdcueNumber = number;
  1502. sendProdcues.push(product);
  1503. }
  1504. }
  1505. })
  1506. $("#addProduct").find(".input-fittings-number").each(function(){
  1507. var number = $(this).val();
  1508. if(number != null && number != "" && number != 0){
  1509. var fittings = new Object();
  1510. fittings.productId = $(this).parent().find(".input-produce-id").val();
  1511. fittings.fittingsId = $(this).parent().find(".input-fittings-id").val();
  1512. //换新、维修,退货,无理由退货,
  1513. if(allCustomerType == 3 || allCustomerType == 4 || allCustomerType == 6 || allCustomerType == 7){
  1514. fittings.closedFittingNumber = number;
  1515. closedFittings.push(fittings);
  1516. }else if(allCustomerType == 5){
  1517. fittings.sendFittingNumber = number;
  1518. sendFittings.push(fittings);
  1519. }
  1520. }
  1521. })
  1522. $("#back-product").find(".input-color-number").each(function(){
  1523. var number = $(this).val();
  1524. if(number != null && number != "" && number != 0){
  1525. //换新、维修,
  1526. if(allCustomerType == 3 || allCustomerType == 4){
  1527. var fittings = new Object();
  1528. fittings.productId = $(this).parent().find(".input-produce-id").val();
  1529. fittings.colorId = $(this).parent().find(".input-color-id").val();
  1530. fittings.sendProdcueNumber = number;
  1531. sendProdcues.push(fittings);
  1532. }
  1533. }
  1534. })
  1535. $("#back-product").find(".input-fittings-number").each(function(){
  1536. var number = $(this).val();
  1537. if(number != null && number != "" && number != 0){
  1538. //换新、维修
  1539. if(allCustomerType == 3 || allCustomerType == 4){
  1540. var fittings = new Object();
  1541. fittings.productId = $(this).parent().find(".input-produce-id").val();
  1542. fittings.fittingsId = $(this).parent().find(".input-fittings-id").val();
  1543. fittings.sendFittingNumber = number;
  1544. sendFittings.push(fittings);
  1545. }
  1546. }
  1547. })
  1548. var backErrorMsg = "请选择一个replace_error_msg寄回的产品或配件并填写一个以上的数量!"
  1549. var sendErrorMsg = "请选择一个replace_error_msg寄送的产品或配件并填写一个以上的数量!"
  1550. var process = true;
  1551. switch (allCustomerType){
  1552. case 3:
  1553. process = processIsEmpty([closedProdcues,closedFittings]);
  1554. if(!process){
  1555. var msg = backErrorMsg.replace("replace_error_msg","换新");
  1556. layer.msg(msg, {icon: 5, time: 3000});
  1557. return false;
  1558. }
  1559. process = processIsEmpty([sendProdcues,sendFittings]);
  1560. if(!process){
  1561. var msg = sendErrorMsg.replace("replace_error_msg","换新");
  1562. layer.msg(msg, {icon: 5, time: 3000});
  1563. return false;
  1564. }
  1565. break;
  1566. case 4:
  1567. process = processIsEmpty([closedProdcues,closedFittings]);
  1568. if(!process){
  1569. var msg = backErrorMsg.replace("replace_error_msg","维修");
  1570. layer.msg(msg, {icon: 5, time: 3000});
  1571. return false;
  1572. }
  1573. process = processIsEmpty([sendProdcues,sendFittings]);
  1574. if(!process){
  1575. var msg = sendErrorMsg.replace("replace_error_msg","维修");
  1576. layer.msg(msg, {icon: 5, time: 3000});
  1577. return false;
  1578. }
  1579. break;
  1580. case 5:
  1581. process = processIsEmpty([sendProdcues,sendFittings]);
  1582. if(!process){
  1583. var msg = sendErrorMsg.replace("replace_error_msg","补发");
  1584. layer.msg(msg, {icon: 5, time: 3000});
  1585. return false;
  1586. }
  1587. break;
  1588. case 6:
  1589. process = processIsEmpty([closedProdcues,closedFittings]);
  1590. if(!process){
  1591. var msg = backErrorMsg.replace("replace_error_msg","退货");
  1592. layer.msg(msg, {icon: 5, time: 3000});
  1593. return false;
  1594. }
  1595. break;
  1596. case 7:
  1597. process = processIsEmpty([closedProdcues,closedFittings]);
  1598. if(!process){
  1599. var msg = backErrorMsg.replace("replace_error_msg","退货");
  1600. layer.msg(msg, {icon: 5, time: 3000});
  1601. return false;
  1602. }
  1603. break;
  1604. default:
  1605. break;
  1606. }
  1607. $("#sendProdcues").val(JSON.stringify(sendProdcues));
  1608. $("#sendFittings").val(JSON.stringify(sendFittings));
  1609. $("#closedProdcues").val(JSON.stringify(closedProdcues));
  1610. $("#closedFittings").val(JSON.stringify(closedFittings));
  1611. var visitTimeSelect = $("input[name='visitTimeSelect']:checked").val();
  1612. var visit_date = $('#datemin').val();
  1613. var myDate = new Date();
  1614. var date = myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+myDate.getDate();
  1615. var hours = myDate.getHours();
  1616. //如果两个时间相等,则判断可选的回访时间
  1617. if(Date.parse(visit_date) == Date.parse(date)){
  1618. var msg = "该时间已超过当前时间,请重新选择回访时间!";
  1619. if (hours > 12 && visitTimeSelect == 1) {
  1620. vailErrorMsg($("#datemin"),msg);
  1621. return false;
  1622. } else if (hours > 14 && visitTimeSelect == 2) {
  1623. vailErrorMsg($("#datemin"),msg);
  1624. return false;
  1625. } else if (hours > 18 && visitTimeSelect == 3) {
  1626. vailErrorMsg($("#datemin"),msg);
  1627. return false;
  1628. }
  1629. }
  1630. return true;
  1631. }
  1632. /* 判断产品与配件是否填入值 */
  1633. function processIsEmpty(process){
  1634. if(process != null && process != "" && process.length > 0){
  1635. var flag = 2;
  1636. var num = 0;
  1637. if(process[0] == null || process[0].length < 1 ){
  1638. flag -- ;
  1639. }
  1640. if(process[1] == null || process[1].length < 1 ){
  1641. flag -- ;
  1642. }
  1643. for(var j=0; j<process.length;j++){
  1644. for(var i=0;i<process[j].length;i++){
  1645. if(process[j][i].sendProdcueNumber !== undefined){
  1646. num += process[j][i].sendProdcueNumber;
  1647. }
  1648. if(process[j][i].sendFittingNumber !== undefined){
  1649. num += process[j][i].sendFittingNumber;
  1650. }
  1651. if(process[j][i].closedProdcueNumber !== undefined){
  1652. num += process[j][i].closedProdcueNumber ;
  1653. }
  1654. if(process[j][i].closedFittingNumber !== undefined){
  1655. num += process[j][i].closedFittingNumber;
  1656. }
  1657. }
  1658. }
  1659. if(flag == 0){
  1660. return false;
  1661. }
  1662. if(num == 0){
  1663. return false;
  1664. }
  1665. }
  1666. return true;
  1667. }
  1668. /*===============================客诉提交 -- end -- =============================== */