customer.js 59 KB

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