customer.js 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646
  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. /*用于初始化监听回访信息的展示*/
  189. function initVisitEvent(){
  190. $("input[name='customerIsVisit']").change(function (){
  191. if($(this).val() == 2){
  192. $("#needToVisit").css("display","block");
  193. }else{
  194. $("#needToVisit").css("display","none");
  195. }
  196. })
  197. }
  198. /*关闭qa*/
  199. function closeQA(){
  200. $(".dalog-ask").hide(); //隐藏qa
  201. }
  202. /*初始化单选框样式*/
  203. function initCheck(){
  204. $('.skin-minimal input').iCheck({
  205. checkboxClass: 'icheckbox-blue',
  206. radioClass: 'iradio-blue',
  207. increaseArea: '20%'
  208. });
  209. }
  210. /*初始化单选框样式*/
  211. function initCheckByNode(node){
  212. node.iCheck({
  213. checkboxClass: 'icheckbox-blue',
  214. radioClass: 'iradio-blue',
  215. increaseArea: '20%'
  216. });
  217. }
  218. /*
  219. * type 1:不需要回访 2:需要回访
  220. * */
  221. function visitByType(type){
  222. if(isUpdate && customerIsVisit){
  223. customerIsVisit = false;
  224. return false;
  225. }
  226. if(1 == type){ //不需要回访
  227. $("#customer-visit-2").iCheck('check'); //设置不需要回访
  228. $("#needToVisit").css("display","none");
  229. }else{
  230. $("#customer-visit-1").iCheck('check'); //设置需要回访
  231. $("#needToVisit").css("display","block");
  232. }
  233. initVisitEvent();
  234. }
  235. function initSysAdmin() {
  236. sysAminList = getSysAdmin();
  237. var html = "";
  238. for(var i=0;i<sysAminList.length;i++){
  239. var adminList = sysAminList[i];
  240. if(adminId != null && adminId != "" && adminId != 0 && adminId == adminList.adminId ){
  241. html += '<option value="'+ adminList.adminId +'" selected>'+ adminList.adminName +'(我)</option>';
  242. }else{
  243. html += '<option value="'+ adminList.adminId +'">'+ adminList.adminName +'</option>';
  244. }
  245. }
  246. $("#adminId").html(html);
  247. }
  248. /*初始化回访客服的选择*/
  249. function initVisitSysAdmin(){
  250. var html = "";
  251. var flag = false;
  252. for(var i=0;i<sysAminList.length;i++){
  253. var adminList = sysAminList[i];
  254. if(adminId != null && adminId != "" && adminId != 0 && adminId == adminList.adminId ){
  255. html += '<option value="'+ adminList.adminId +'" selected>'+ adminList.adminName +'(我)</option>';
  256. flag = true;
  257. }else{
  258. html += '<option value="'+ adminList.adminId +'">'+ adminList.adminName +'</option>';
  259. }
  260. }
  261. $("#visitAdminId").html(html);
  262. if(flag){
  263. showVisitMsg(1);
  264. }
  265. }
  266. /**
  267. * 用于显示回访指派任务提示信息
  268. * 1 :自己
  269. * 2 :其他人
  270. */
  271. function showVisitMsg(type,adminName) {
  272. if(type == 1){
  273. $("#visitAdminIdMsg").html("您将为自己指定一个回访任务");
  274. }else{
  275. $("#visitAdminIdMsg").html("您将为"+ adminName +"指定一个回访任务");
  276. }
  277. }
  278. function getSysAdmin(){
  279. if(sysAminList != null && sysAminList.length > 0){
  280. return sysAminList
  281. }
  282. $.ajax({
  283. type: "POST",
  284. data: {
  285. },
  286. url: url_path + "/admin/customer/select_sys_admin",
  287. async: false,
  288. success: function(data){
  289. if (data.returnCode == 200) {
  290. sysAminList = data.returnMsg.adminList;
  291. adminId = data.returnMsg.adminId;
  292. }
  293. },
  294. error: function(XmlHttpRequest, textStatus, errorThrown){
  295. }
  296. });
  297. return sysAminList;
  298. }
  299. /*初始化产品类型 -- 客诉头部的产品类型单选*/
  300. function initProduceType(){
  301. var html = "";
  302. $.ajax({
  303. type: "POST",
  304. data: {
  305. },
  306. url: url_path + "/admin/customer/select_produce_type",
  307. async: false,
  308. success: function(data){
  309. if (data.returnCode == 200) {
  310. var check = "checked";
  311. for(var i=0;i<data.returnMsg.productTypeList.length;i++){
  312. var produce = data.returnMsg.productTypeList[i];
  313. html += ' <div class="radio-box">' +
  314. '<input type="radio" id="produce-type-'+ i +'" name="typeId" typeCompany="'+ produce.typeCompany +'" datatype="*" value="'+ produce.typeId +'" '+ check +' nullmsg="请选择产品类型!" >' +
  315. ' <label for="produce-type-'+ i +'">'+ produce.typeName +'</label>' +
  316. ' </div>';
  317. check = "";
  318. }
  319. }else{
  320. html = '';
  321. }
  322. },
  323. error: function(XmlHttpRequest, textStatus, errorThrown){
  324. }
  325. });
  326. $("#produceTypeHtml").html(html);
  327. initCheck();
  328. }
  329. /**
  330. * 选择处理结果-- 默认选择已解决
  331. * type : 1 :已解决 2:未解决 3:换新 4:维修 5:补发 6:退货 7:无理由退货
  332. */
  333. function initProcessResult(type){
  334. if(type == null || type == ""){
  335. type = 1;
  336. }
  337. allCustomerType = type;
  338. if(allCustomerInfoType == null || allCustomerInfoType == ""){
  339. allCustomerInfoType = $("input[name='customerCounselType']:checked").val();
  340. }
  341. var statusHtml = '<li><span class="arrow"></span><div class="number">status_index</div><div>status_html</div></li>';
  342. var resultHtml = '';
  343. var result = {};
  344. var resultProductTableTitle = {};
  345. $("#solved").show(); //已解决
  346. $("#noSolved").show();//未解决
  347. if(allCustomerInfoType == 1){ //售前
  348. $("#renewed").hide();
  349. $("#maintain").hide();
  350. $("#reissue").hide();
  351. $("#backGoods").hide();
  352. $("#noReasonBack").hide();
  353. switch(type)
  354. {
  355. case 1:
  356. otherHied();
  357. visitByType(1);
  358. break;
  359. case 2:
  360. otherHied();
  361. visitByType(2);
  362. break;
  363. default:
  364. break;
  365. }
  366. }else if(allCustomerInfoType == 2){ //售后
  367. if(!isInitSendAddressSms){
  368. initComplaintQuestionInfo("m");
  369. isInitSendAddressSms = true;
  370. }
  371. if(isUpdate){ //修改页面加载省市区
  372. setAddressInfo(); //修改页面才会调用
  373. }else{
  374. /* 在选择售后类型是,直接初始化省市区,使用isInitAddress 变量来判断 */
  375. if(isInitAddress == 0){
  376. var proId = setPro(null,2);
  377. var cityId = setCity(null,proId,2);
  378. setDistrict(null,cityId,2);
  379. isInitAddress = 1;
  380. }
  381. }
  382. $("#renewed").show();
  383. $("#maintain").show();
  384. $("#reissue").show();
  385. $("#backGoods").show();
  386. $("#noReasonBack").show();
  387. switch(type)
  388. {
  389. case 1:
  390. otherHied();
  391. visitByType(1);
  392. break;
  393. case 2:
  394. otherHied();
  395. visitByType(2); //需要回访
  396. break;
  397. case 3: //换新
  398. result = isSolve.renewed;
  399. resultProductTableTitle = isSolveTitleMsg.renewed;
  400. $("#relationProduct").html("换新产品");
  401. $("#processResultStatus").show();
  402. $("#orderHead").show();
  403. $("#order").show();
  404. //$("#recipientInfo").show();
  405. //$("#recipientInfoTitle").show();
  406. //$("#recipientAddress").show();
  407. //$("#recipientAddressText").show();
  408. //$("#renewedProduct").show();
  409. $("#TDScollect").show();
  410. $("#TDScollectShow").show();
  411. $("#sendAddressInfo").show();
  412. $("#sendAddressByPhone").show();
  413. $("#updateProduct").hide(); //换新产品
  414. $("#postageAccount").show(); //邮费转账账户
  415. visitByType(2); //需要回访
  416. break;
  417. case 4: //维修
  418. result = isSolve.maintain;
  419. resultProductTableTitle = isSolveTitleMsg.maintain;
  420. $("#relationProduct").html("维修产品");
  421. $("#processResultStatus").show();
  422. $("#orderHead").show();
  423. $("#order").show();
  424. //$("#recipientInfo").show();
  425. //$("#recipientInfoTitle").show();
  426. //$("#recipientAddress").show();
  427. //$("#recipientAddressText").show();
  428. //$("#renewedProduct").show();
  429. $("#TDScollect").show();
  430. $("#TDScollectShow").show();
  431. $("#sendAddressInfo").show();
  432. $("#sendAddressByPhone").show();
  433. $("#updateProduct").hide();//维修产品
  434. $("#postageAccount").show(); //邮费转账账户
  435. visitByType(2); //需要回访
  436. break;
  437. case 5://补发
  438. result = isSolve.reissue;
  439. resultProductTableTitle = isSolveTitleMsg.reissue;
  440. $("#relationProduct").html("补发产品");
  441. $("#processResultStatus").show();
  442. $("#orderHead").show();
  443. $("#order").show();
  444. //$("#recipientInfo").show();
  445. //$("#recipientInfoTitle").show();
  446. // $("#recipientAddress").show();
  447. // $("#recipientAddressText").show();
  448. //$("#renewedProduct").show();
  449. $("#TDScollect").show();
  450. $("#TDScollectShow").show();
  451. $("#sendAddressInfo").hide();
  452. $("#sendAddressByPhone").hide();
  453. $("#updateProduct").hide();
  454. $("#postageAccount").hide(); //邮费转账账户 -- 隐藏
  455. visitByType(2); //需要回访
  456. break;
  457. case 6: //退货
  458. result = isSolve.backGoods;
  459. resultProductTableTitle = isSolveTitleMsg.backGoods;
  460. $("#relationProduct").html("退货产品");
  461. $("#processResultStatus").show();
  462. $("#orderHead").show();
  463. $("#order").show();
  464. // $("#recipientInfo").show();
  465. //$("#recipientInfoTitle").show();
  466. //$("#recipientAddress").show();
  467. //$("#recipientAddressText").show();
  468. //$("#renewedProduct").show();
  469. $("#TDScollect").show();
  470. $("#TDScollectShow").show();
  471. $("#sendAddressInfo").show();
  472. $("#sendAddressByPhone").show();
  473. $("#updateProduct").hide();
  474. $("#postageAccount").show(); //邮费转账账户
  475. visitByType(2); //需要回访
  476. break;
  477. case 7://无理由退货
  478. result = isSolve.noReasonBack;
  479. resultProductTableTitle = isSolveTitleMsg.noReasonBack;
  480. $("#relationProduct").html("退货产品");
  481. $("#processResultStatus").show();
  482. $("#orderHead").show();
  483. $("#order").show();
  484. //$("#recipientInfo").show();
  485. //$("#recipientInfoTitle").show();
  486. //$("#recipientAddress").show();
  487. //$("#recipientAddressText").show();
  488. //$("#renewedProduct").show();
  489. $("#TDScollect").show();
  490. $("#TDScollectShow").show();
  491. $("#sendAddressInfo").show();
  492. $("#sendAddressByPhone").show();
  493. $("#updateProduct").hide();
  494. $("#postageAccount").show(); //邮费转账账户
  495. visitByType(2); //需要回访
  496. break;
  497. default:
  498. break;
  499. }
  500. }
  501. for(var i=0;i< result.length;i++){
  502. var html = statusHtml.replace("status_index",i+1);
  503. html = html.replace("status_html",result[i]);
  504. resultHtml += html;
  505. }
  506. if(resultProductTableTitle != null && resultProductTableTitle.length > 0){
  507. /* 根据处理类型来切换 产品列表的列名称 */
  508. for(var i=0;i<resultProductTableTitle[0].length;i++){
  509. $("#table1").find("th").eq(i).html(resultProductTableTitle[0][i]);
  510. }
  511. for(var i=0;i<resultProductTableTitle[1].length;i++){
  512. $("#table2").find("th").eq(i).html(resultProductTableTitle[1][i]);
  513. }
  514. }
  515. $("#processResultStatus").html(resultHtml);
  516. }
  517. /*已解决|未解决 */
  518. function otherHied(){
  519. $("#processResultStatus").hide(); //处理结果的执行状态 已解决未解决没有该信息
  520. $("#orderHead").hide();
  521. $("#order").hide();
  522. $("#recipientInfo").hide();
  523. $("#recipientInfoTitle").hide();
  524. $("#recipientAddress").hide();
  525. $("#recipientAddressText").hide();
  526. $("#renewedProduct").hide();
  527. $("#TDScollect").hide();
  528. $("#TDScollectShow").hide();
  529. $("#sendAddressInfo").hide();
  530. $("#sendAddressByPhone").hide();
  531. $("#updateProduct").hide();
  532. }
  533. /*初始化问题大类*/
  534. function initComplaintTypeInfo() {
  535. //默认为售前咨询
  536. //var customerCounselTypeOverall = allCustomerInfoType;
  537. var customerCounselTypeOverall = null;
  538. $.ajax({
  539. type: "POST",
  540. data: {
  541. complaintConsultingType : customerCounselTypeOverall
  542. },
  543. url: url_path + "/admin/complaintQuestion/list_complaintType",
  544. async: true,
  545. success: function(data){
  546. var html = '<option value="">请选择问题分类</option>';
  547. var id;
  548. if (data.returnCode == 200) {
  549. for(var i=0;i<data.returnMsg.complaintTypeInfoList.length;i++){
  550. var complaintTypeInfo = data.returnMsg.complaintTypeInfoList[i];
  551. if(i == 0 ){
  552. id = complaintTypeInfo.complaintId;
  553. }
  554. html += '<option value="'+ complaintTypeInfo.complaintId +'">'+ complaintTypeInfo.complaintClassName +'</option>';
  555. }
  556. }else{
  557. html = '';
  558. }
  559. $("[name='complaintId']").html(html);
  560. },
  561. error: function(XmlHttpRequest, textStatus, errorThrown){
  562. }
  563. });
  564. }
  565. /*显示小类*/
  566. function initComplaintSmallClassInfo(complaintId,smallId){
  567. if(complaintId == null || complaintId == ""){
  568. var html = '<option value="">请选择问题小类</option>';
  569. $("[name='smallClassId']").html(html);
  570. }else{
  571. $.ajax({
  572. type: "POST",
  573. data: {
  574. complaintId : complaintId
  575. },
  576. url: url_path + "/admin/complaintQuestion/list_complaintSmallClass",
  577. async: true,
  578. success: function(data){
  579. var html = '<option value="">请选择问题小类</option>';
  580. if (data.returnCode == 200) {
  581. for(var i=0;i<data.returnMsg.complaintSmallClassInfoList.length;i++){
  582. var ComplaintSmallClassInfo = data.returnMsg.complaintSmallClassInfoList[i];
  583. html += '<option value="'+ ComplaintSmallClassInfo.smallClassId +'">'+ ComplaintSmallClassInfo.smallClassName +'</option>';
  584. }
  585. }else{
  586. html = '';
  587. }
  588. $("[name='smallClassId']").html(html);
  589. if(smallId != null && smallId != "" && typeof(smallId)!="undefined" ){
  590. $("select[name='smallClassId']").val(smallId);
  591. }
  592. },
  593. error: function(XmlHttpRequest, textStatus, errorThrown){
  594. }
  595. });
  596. }
  597. }
  598. /**
  599. * 搜索QA 显示
  600. * type p:问题qa; m:邮寄qa
  601. */
  602. function initComplaintQuestionInfo(type){
  603. var complaintId;
  604. var smallClassId;
  605. var questionName;
  606. var customerCounselType;
  607. var questionId;
  608. if(type == "p"){
  609. complaintId = $("[name='complaintId']").val();
  610. smallClassId = $("[name='smallClassId']").val();
  611. questionName = $("[name='questionIdMsg']").val();
  612. customerCounselType = $("[name='customerCounselType']:checked").val();
  613. }else if(type == "m"){
  614. questionId = complaint_questionId;
  615. }
  616. $.ajax({
  617. type: "POST",
  618. data: {
  619. complaintId : complaintId,
  620. smallClassId : smallClassId,
  621. questionName : questionName,
  622. /*complaintType : customerCounselType,*/
  623. questionId : questionId
  624. },
  625. url: url_path + "/admin/complaintQuestion/list_complaintQuestion",
  626. async: false,
  627. success: function(data){
  628. if(type == "p"){
  629. var html = "";
  630. if (data.returnCode == 200) {
  631. for(var i=0;i<data.returnMsg.complaintQuestionInfoList.length;i++){
  632. var complaintQuestion= data.returnMsg.complaintQuestionInfoList[i];
  633. //html += '<li class="ask">'+ complaintQuestion.questionName +'' +
  634. // '</li>' +
  635. // '<li class="answer" style="height: 65px;overflow: hidden;">答:<span>'+ complaintQuestion.questionProfile +'</span><input class="quesId" type="hidden" value="'+ complaintQuestion.questionId +'"></li>';
  636. html += '' +
  637. '<li class="answer" style="height: 20px;overflow: hidden;border-bottom: 1px solid #ddd;"><span>'+ complaintQuestion.questionName +'</span>' +
  638. '<input class="QA_complaintId" type="hidden" value="'+ complaintQuestion.complaintId +'">' +
  639. '<input class="QA_smallClassId" type="hidden" value="'+ complaintQuestion.smallClassId +'">' +
  640. '<input class="quesId" type="hidden" value="'+ complaintQuestion.questionId +'">' +
  641. '<div id="questionProfile" style="display: block">'+ complaintQuestion.questionProfile +'</div>' +
  642. '</li>';
  643. }
  644. }else{
  645. html = '<span style="font-size: 12px; margin-top: 10px; display: block;">未搜索到QA信息,请更换关键字或者直接录入到系统!</span>';
  646. }
  647. $("#question").html(html);
  648. $(".dalog-ask").show();
  649. }else if(type == "m"){
  650. var msg = "";
  651. if (data.returnCode == 200) {
  652. msg = data.returnMsg.complaintQuestionInfoList[0].questionProfile;
  653. }
  654. addSmsMsg(msg);
  655. }
  656. },
  657. error: function(XmlHttpRequest, textStatus, errorThrown){
  658. }
  659. });
  660. }
  661. /*添加邮寄信息*/
  662. function addSmsMsg(msg){
  663. /*sendAddressSms.addListener("ready", function () {
  664. // editor准备好之后才可以使用
  665. sendAddressSms.setContent(msg);
  666. });*/
  667. /*邮寄信息*/
  668. $("#sendAddressSmsHtml").html(msg);
  669. }
  670. /**
  671. * 发送短信
  672. * @param type 类型: "problem" 问题处理; mailAddress:邮寄地址;
  673. * @param node 返回结果显示节点
  674. */
  675. function sendPhone(type,node){
  676. var index = layer.load(1, {
  677. shade: [0.5,'#fff'] //0.1透明度的白色背景
  678. });
  679. var desc = "";
  680. var phone = "";
  681. var questionId = "";
  682. var describeTitle = "";
  683. var smallClassId = ""; /* 客诉问题类型小类id */
  684. var typeCompany = parseInt($("input:radio[name='typeId']:checked").attr("typeCompany"));
  685. if(type == "p"){
  686. phone = $("#p-phone").val();
  687. questionId = $("#questionId").val();
  688. describeTitle = $("#describeTitle").val();
  689. desc = UE.getEditor('describeContentText').getContent();
  690. smallClassId = $("#smallClassId").val();
  691. if(smallClassId == null || smallClassId == "" ){
  692. layer.close(index);
  693. layer.msg("请选择问题分类!", {icon: 5, time: 3000});
  694. return false;
  695. }
  696. if(describeTitle==null || describeTitle == ""){
  697. layer.close(index);
  698. layer.msg("请填写问题标题!", {icon: 5, time: 3000});
  699. return false;
  700. }
  701. if(describeTitle.length > 50){
  702. layer.close(index);
  703. layer.msg("问题标题长度不能高于50个字符!", {icon: 5, time: 3000});
  704. return false;
  705. }
  706. if(desc == null || desc == ""){
  707. layer.close(index);
  708. layer.msg("请填写问题回复!", {icon: 5, time: 3000});
  709. return false;
  710. }
  711. }else if(type == "m"){
  712. phone = $("#m-phone").val();
  713. questionId = complaint_questionId;
  714. //desc = UE.getEditor('sendAddressSms').getContent();
  715. //desc = $("#sendAddressSmsHtml").html(); //取值从html填写 -- 邮寄地址不用传过去,直接后台取
  716. // if(desc == null || desc == ""){
  717. // layer.close(index);
  718. // layer.msg("请填写邮寄信息内容!", {icon: 5, time: 3000});
  719. // return false;
  720. // }
  721. }else{
  722. layer.close(index);
  723. layer.msg("发送报错!", {icon: 5, time: 3000});
  724. return false;
  725. }
  726. var reg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
  727. if(!reg.test(phone)){
  728. layer.close(index);
  729. layer.msg("请填写正确的手机号码!", {icon: 5, time: 3000});
  730. return false;
  731. }
  732. $.ajax({
  733. type: "POST",
  734. data: {
  735. type : type,
  736. typeCompany : typeCompany,
  737. phone : phone,
  738. questionId : questionId,
  739. smallClassId : smallClassId,
  740. questionName : describeTitle,
  741. questionProfile : desc //回复内容
  742. },
  743. url: url_path + "/admin/customer/send_phone_sms",
  744. async: true,
  745. success: function(data){
  746. if (data.returnCode == 200) {
  747. if(type == "p"){
  748. $("#p-msg").html(data.resultMsg);
  749. }else if(type == "m"){
  750. $("#m-msg").html(data.resultMsg);
  751. }
  752. }else{
  753. if(type == "p"){
  754. $("#p-msg").html(data.resultMsg);
  755. }else if(type == "m"){
  756. $("#m-msg").html(data.resultMsg);
  757. }
  758. }
  759. layer.close(index);
  760. },
  761. error: function(XmlHttpRequest, textStatus, errorThrown){
  762. if(type == "p"){
  763. $("#p-msg").html("发送短信失败!");
  764. }else if(type == "m"){
  765. $("#m-msg").html("发送短信失败!");
  766. }
  767. layer.close(index);
  768. }
  769. });
  770. }
  771. /*保存QA问题*/
  772. function saveQuestion(){
  773. var index = layer.load(1, {
  774. shade: [0.5,'#fff'] //0.1透明度的白色背景
  775. });
  776. var desc = "";
  777. var questionId = "";
  778. var describeTitle = "";
  779. var smallClassId = ""; /* 客诉问题类型小类id */
  780. questionId = $("#questionId").val();
  781. describeTitle = $("#describeTitle").val();
  782. desc = UE.getEditor('describeContentText').getContent();
  783. smallClassId = $("#smallClassId").val();
  784. if((smallClassId == null || smallClassId == "") && (questionId == null || questionId == "") ){
  785. layer.close(index);
  786. layer.msg("请选择问题分类!", {icon: 5, time: 3000});
  787. return false;
  788. }
  789. if(describeTitle==null || describeTitle == ""){
  790. layer.close(index);
  791. layer.msg("请填写问题标题!", {icon: 5, time: 3000});
  792. return false;
  793. }
  794. if(desc == null || desc == ""){
  795. layer.close(index);
  796. layer.msg("请填写问题回复!", {icon: 5, time: 3000});
  797. return false;
  798. }
  799. $.ajax({
  800. type: "POST",
  801. data: {
  802. questionId : questionId,
  803. smallClassId : smallClassId,
  804. questionName : describeTitle,
  805. questionProfile : desc //回复内容
  806. },
  807. url: url_path + "/admin/complaintQuestion/save_question",
  808. async: true,
  809. success: function(data){
  810. if (data.returnCode == 200) {
  811. $("#questionId").val(data.returnMsg.questionId);
  812. layer.msg(data.resultMsg, {icon: 1, time: 3000});
  813. }else{
  814. layer.msg(data.resultMsg, {icon: 5, time: 3000});
  815. }
  816. layer.close(index);
  817. },
  818. error: function(XmlHttpRequest, textStatus, errorThrown){
  819. layer.close(index);
  820. }
  821. });
  822. }
  823. /***
  824. * 打开搜索订单框
  825. */
  826. function selectOrder(){
  827. layer_show("搜索订单",url_path + "/admin/customer/select_order","1000","500");
  828. }
  829. /**
  830. * 显示选择的订单
  831. */
  832. function setSelectOrder(orderId){
  833. if(orderId == null || orderId == "" || typeof (orderId)=="undefined"){
  834. layer.msg("未选中订单", {icon: 5, time: 3000});
  835. return false
  836. }
  837. var html = '';
  838. var addresHtml = '';
  839. var address = ''; //地址
  840. var orderItemList = {};
  841. var companyId = ''; //销售公司
  842. var storeId = ''; //店铺
  843. $.ajax({
  844. type: "POST",
  845. data: {
  846. salesId : orderId
  847. },
  848. url: url_path + "/admin/customer/select_salesOrder",
  849. async: false,
  850. success: function(data){
  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. orderItemList = salesOrder.salesOrderItemList;
  859. for(var j=0;j<salesOrderItem.length;j++){
  860. var item = salesOrderItem[j].itemProductName + "*" + salesOrderItem[j].itemNum;
  861. if(j==0){
  862. productsHtml += item
  863. }else{
  864. productsHtml += '<br>'+ item
  865. }
  866. }
  867. var time = formatDate(new Date(salesOrder.salesCreateTime),"yyyy-MM-dd");
  868. html += '' +
  869. ' <td style="text-align: center;">'+ convertUndefinedToEmpty(salesOrder.companyName) +'</td>' +
  870. ' <td style="text-align: center;">'+ convertUndefinedToEmpty(salesOrder.storeName) +'</td>' +
  871. ' <td style="text-align: center;">'+ salesOrder.salesId +'</td>' +
  872. ' <td style="text-align: center;">'+ salesOrder.salesAddressName +'</td>' +
  873. ' <td style="text-align: center;">'+ salesOrder.salesAddressTel +'</td>' +
  874. ' <td style="text-align: center;">'+ salesOrder.salesAmount/100 +'</td>' +
  875. ' <td style="text-align: center;">'+ productsHtml +'</td>' +
  876. ' <td style="text-align: center;">'+ time +'</td>' +
  877. '';
  878. addresHtml = '<td colspan="1" style="text-align: center;">收货地址</td><td colspan="7" class="td-manage text-c" >'+ salesOrder.salesAddressInfo +'</td>' ;
  879. address = salesOrder.salesAddressInfo;
  880. $("#sendName").val(salesOrder.salesAddressName); //收件人名称
  881. $("#sendTel").val(salesOrder.salesAddressTel); //收件人电话号码
  882. $("#customerName").val(salesOrder.salesAddressName); //收件人名称
  883. $("#customerTel").val(salesOrder.salesAddressTel); //收件人电话号码
  884. }
  885. // $("#showOrderAddress").html(address);
  886. }else{
  887. html = '';
  888. addresHtml = '';
  889. }
  890. $("#showOrder").html(html); //显示订单
  891. $("#showOrderAddress").html(addresHtml); //显示订单地址
  892. $("#showOrderAddress").show();
  893. },
  894. error: function(XmlHttpRequest, textStatus, errorThrown){
  895. }
  896. });
  897. $("#addressInfo").val(address);
  898. setAdress(); //显示地址
  899. setProduce(orderItemList); //显示产品
  900. $("#companyId").val(companyId);
  901. $("#storeId").val(storeId);
  902. $("#orderId").val(orderId);
  903. }
  904. /**
  905. * 设置地址
  906. */
  907. function setAdress(){
  908. var addres = $("#addressInfo").val();
  909. $("#addrssMsg").html("");
  910. if(addres == null){
  911. $("#addrssMsg").html("*未能获取到地址,请手动选择地址");
  912. return;
  913. }
  914. var addresList = addres.split("-");
  915. if(addresList[0] == null || addresList[1]==null || addresList[2]==null || addresList[3]==null){
  916. $("#addrssMsg").html("*未能获取到地址,请手动选择地址");
  917. return;
  918. }
  919. var proId = setPro(getAddress(addresList[0],0),1);
  920. var cityId = setCity(getAddress(addresList[1],1),proId,1);
  921. setDistrict(getAddress(addresList[2],2),cityId,1);
  922. var sendAddress = addresList[3];
  923. if(addresList.length > 4){
  924. for(var k = 4;k< addresList.length;k++){
  925. sendAddress += addresList[k];
  926. }
  927. }
  928. $("#sendAddress").val(sendAddress);
  929. }
  930. /***
  931. * 删除 “省”,“市”,“区”关键字
  932. * type : 0:省 2:市 3:区
  933. */
  934. function getAddress(addrss,type) {
  935. var abbreviation = "";
  936. if(addrss == ""){
  937. abbreviation = "";
  938. }else{
  939. switch(type)
  940. {
  941. case 0:
  942. //var proReg = new RegExp("省","g");
  943. //abbreviation = addrss.replace(proReg,"");
  944. abbreviation = addrss.substring(0,2);
  945. break;
  946. case 1:
  947. var cityReg = new RegExp("市","g");
  948. abbreviation = addrss.replace(cityReg,"");
  949. cityReg = new RegExp("区","g");
  950. abbreviation = addrss.replace(cityReg,"");
  951. break;
  952. case 2:
  953. var districtReg = new RegExp("区","g");
  954. abbreviation = addrss.replace(districtReg,"");
  955. districtReg = new RegExp("市","g");
  956. abbreviation = abbreviation.replace(districtReg,"");
  957. break;
  958. default:
  959. break;
  960. }
  961. }
  962. return abbreviation
  963. }
  964. /**
  965. * 设置省
  966. * type 1:搜索订单赋值 2:只查询全部,默认第一个
  967. */
  968. function setPro(provinceName,type) {
  969. var proId = '';
  970. var province = listProvince();
  971. var selectPro = new Array();
  972. if(type == 1){
  973. selectPro = listProvince("",provinceName);
  974. }
  975. if(province!=null){
  976. var provinceHtml = ''
  977. for(var i=0;i<province.length;i++){
  978. provinceHtml += '<option value="'+ province[i].provinceId +'">'+ province[i].province +'</option>';
  979. }
  980. $("#province").html(provinceHtml);
  981. if(selectPro != null && selectPro.length > 0 ){
  982. proId = selectPro[0].provinceId;
  983. }else{
  984. proId = province[0].provinceId;
  985. }
  986. $("#province option[value='" + proId + "']").attr("selected","true");
  987. }
  988. return proId;
  989. }
  990. /**
  991. * 设置市
  992. * type 1:搜索订单赋值 2:只查询全部,默认第一个
  993. */
  994. function setCity(cityName,proId,type) {
  995. var cityId = '';
  996. var city = listCity(proId,"");
  997. var selectCity = new Array();
  998. if(type == 1){
  999. selectCity = listCity(proId,cityName);
  1000. }
  1001. if(city!=null){
  1002. var cityHtml = ''
  1003. for(var i=0;i<city.length;i++){
  1004. cityHtml += '<option value="'+ city[i].cityId +'">'+ city[i].city +'</option>';
  1005. }
  1006. $("#city").html(cityHtml);
  1007. if(selectCity != null && selectCity.length > 0 ){
  1008. cityId = selectCity[0].cityId;
  1009. }else{
  1010. cityId = city[0].cityId;
  1011. }
  1012. $("#city option[value='" + cityId + "']").attr("selected","true");
  1013. }
  1014. return cityId;
  1015. }
  1016. /**
  1017. * 设置区
  1018. * type 1:搜索订单赋值 2:只查询全部,默认第一个
  1019. */
  1020. function setDistrict(districtName,cityId,type) {
  1021. var district = listDistrict(cityId,"");
  1022. var selectDistrict = new Array();
  1023. if(type == 1){
  1024. selectDistrict = listDistrict(cityId,districtName);
  1025. }
  1026. if(district!=null){
  1027. var districtHtml = ''
  1028. for(var i=0;i<district.length;i++){
  1029. districtHtml += '<option value="'+ district[i].districtId +'">'+ district[i].district +'</option>';
  1030. }
  1031. var disId = "";
  1032. $("#district").html(districtHtml);
  1033. if(selectDistrict != null && selectDistrict.length > 0 ){
  1034. disId = selectDistrict[0].districtId;
  1035. }else{
  1036. disId = district[0].districtId;
  1037. }
  1038. $("#district option[value='" + disId + "']").attr("selected","true");
  1039. }
  1040. }
  1041. /* TDS收集设置区 */
  1042. var TDSCity = '';
  1043. function linkageSetDistrict(){
  1044. var arrcity_3word = $("#arrcity_3word").val();
  1045. var cityName = '北京';
  1046. for(var i = 0;i<citys.length;i++){
  1047. for(var j=0;j<citys[i].length;j++){
  1048. if(j == 0 && arrcity_3word == citys[i][j]){
  1049. cityName = citys[i][1];
  1050. }
  1051. }
  1052. }
  1053. TDSCity = cityName;
  1054. var selectCity = listCity(null,cityName);
  1055. var cityId = selectCity[0].cityId;
  1056. var selectDistrict = listDistrict(cityId,"");
  1057. var html = '';
  1058. for(var i=0;i<selectDistrict.length;i++){
  1059. html += '<option value="'+ selectDistrict[i].districtId +'">'+ selectDistrict[i].district +'</option>';
  1060. }
  1061. $("#TDSArea").html(html);
  1062. $("#TDSArea").find("option").eq(0).prop("selected",true);
  1063. setTDSCollect();
  1064. }
  1065. /**
  1066. * 展示产品
  1067. * @param orderItemList
  1068. */
  1069. function setProduce(orderItemList) {
  1070. var productList = getProduct() ; //所有产品
  1071. var html = "";
  1072. var productTypeNo = 0;
  1073. for(var i=0;i<productList.length;i++) {
  1074. var product = productList[i];
  1075. var produceFittings = getProduceFittings(product.productId); //获取该产品的所有配件
  1076. var colorList = product.colorList; //该产品的所有颜色
  1077. var productType = product.productType;
  1078. var colorHtml = '';
  1079. if(colorList != null && colorList.length >0 ){
  1080. colorHtml += '<table style="height: 100%;">';
  1081. for(var j=0;j<colorList.length;j++){
  1082. var number = "";
  1083. var color = colorList[j];
  1084. for(var k=0;k<orderItemList.length;k++){
  1085. var item = orderItemList[k];
  1086. if(item.itemColorId == color.colorId && item.itemIsSource == 1){
  1087. number = item.itemNum;
  1088. }
  1089. }
  1090. var fristInputStyle = "border-top: 1px solid #ddd;";
  1091. if(color.colorProductId == product.productId) {
  1092. colorHtml += '<tr >' +
  1093. ' <td width="55" style="border-left: none;text-align: center;'+ fristInputStyle +'">' + color.colorName + '</td>' +
  1094. ' <td width="45" style="'+ fristInputStyle +' padding: 0px;width: 25px;">' +
  1095. ' <input type="hidden" class="input-produce-id" value="' + color.colorProductId + '">' +
  1096. ' <input type="hidden" class="input-color-id" value="' + color.colorId + '">' +
  1097. ' <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)" >' +
  1098. ' </td>' +
  1099. ' </tr>';
  1100. fristInputStyle = "";
  1101. }
  1102. }
  1103. colorHtml += '</table>';
  1104. }else{
  1105. colorHtml += '<span>暂无该产品的颜色!<span>';
  1106. }
  1107. var produceFittingsHtml = '';
  1108. if(produceFittings != null && produceFittings.length > 0){
  1109. produceFittingsHtml += '<table style="height: 100%;">';
  1110. for(var m=0;m<produceFittings.length;m++){
  1111. var number = "";
  1112. var fitt = produceFittings[m];
  1113. for(var k=0;k<orderItemList.length;k++){
  1114. var item = orderItemList[k];
  1115. if(item.itemColorId == fitt.fittingsId && item.itemIsSource == 2){
  1116. number = item.itemNum;
  1117. }
  1118. }
  1119. var produceFit = produceFittings[m];
  1120. if(produceFit.productId == product.productId) {
  1121. var fristInputStyle = "border-top: 1px solid #ddd;";
  1122. produceFittingsHtml += '<tr >' +
  1123. ' <td width="55" style="border-left: none;text-align: center; '+ fristInputStyle +'">' + produceFit.fittingsName +'</td>' +
  1124. ' <td width="45" style="'+ fristInputStyle +'padding: 0px;width: 25px;">' +
  1125. ' <input type="hidden" class="input-produce-id" value="' + produceFit.productId + '">' +
  1126. ' <input type="hidden" class="input-fittings-id" value="' + produceFit.fittingsId +'">' +
  1127. ' <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)" >' +
  1128. ' </td>' +
  1129. ' </tr>';
  1130. fristInputStyle = "";
  1131. }
  1132. }
  1133. produceFittingsHtml += '</table>';
  1134. }else{
  1135. produceFittingsHtml += '<span>暂无产品配件!<span>';
  1136. }
  1137. var produceHtml = '<input type="hidden" value="'+ product.productId +'">' +
  1138. '<span>'+ product.productName +'</span>';
  1139. html += ' <tr >' +
  1140. ' <td width="80">'+ produceHtml +'</td>' +
  1141. ' <td style="padding: 0px;text-align: center;">' +
  1142. colorHtml +
  1143. ' </td>' +
  1144. ' <td style="padding: 0px;text-align: center;">' +
  1145. produceFittingsHtml +
  1146. ' </td>' +
  1147. '</tr>';
  1148. }
  1149. $("#addProduct").html(html);
  1150. setBackProduct(html); //设置寄回产品
  1151. monitorProduct(); //监听产品变化
  1152. }
  1153. /*获取产品*/
  1154. function getProduct(){
  1155. var productList;
  1156. $.ajax({
  1157. type: "POST",
  1158. data: {
  1159. },
  1160. url: url_path + "/admin/customer/select_produce",
  1161. async: false,
  1162. success: function(data){
  1163. if (data.returnCode == 200) {
  1164. productList = data.returnMsg.productList;
  1165. }
  1166. },
  1167. error: function(XmlHttpRequest, textStatus, errorThrown){
  1168. }
  1169. });
  1170. return productList;
  1171. }
  1172. /*获取产品配件*/
  1173. function getProduceFittings(productId){
  1174. var produceFittings;
  1175. $.ajax({
  1176. type: "get",
  1177. data: {
  1178. productId : productId
  1179. },
  1180. url: url_path + "/admin/customer/select_produce_fittings",
  1181. async: false,
  1182. success: function(data){
  1183. if (data.returnCode == 200) {
  1184. produceFittings = data.returnMsg.produceFittingsList;
  1185. }
  1186. },
  1187. error: function(XmlHttpRequest, textStatus, errorThrown){
  1188. }
  1189. });
  1190. return produceFittings;
  1191. }
  1192. /*监听产品变化*/
  1193. function monitorProduct(){
  1194. /*产品数量*/
  1195. $("#addProduct").find(".input-color-number").blur(function (){
  1196. setBackProduct();
  1197. })
  1198. /*产品配件*/
  1199. $("#addProduct").find(".input-fittings-number").blur(function (){
  1200. setBackProduct();
  1201. })
  1202. }
  1203. /*设置寄回产品*/
  1204. function setBackProduct(html) {
  1205. if(html != null && html != "" && typeof(html) != "undefined"){
  1206. $("#back-product").html(html);
  1207. }else{
  1208. $("#addProduct").find(".input-color-number").each(function(){
  1209. var number = $(this).val();
  1210. var colorNodeId = $(this).attr("id");
  1211. $("#back-product").find("#"+colorNodeId).val(number);
  1212. })
  1213. $("#addProduct").find(".input-fittings-number").each(function(){
  1214. var number = $(this).val();
  1215. var fittingsNodeId = $(this).attr("id");
  1216. $("#back-product").find("#"+fittingsNodeId).val(number);
  1217. })
  1218. }
  1219. }
  1220. /*设置TDS收集信息*/
  1221. function setTDSCollect(){
  1222. var TDSArea = $("#TDSArea").find("option:selected").text();
  1223. var TDSAddress = TDSCity + '-' + TDSArea;
  1224. if(TDSAddress != null && TDSAddress != ""){
  1225. $("#DTS-address").html("地址:" + TDSAddress);
  1226. }
  1227. }
  1228. /*TDS联动处理*/
  1229. function TDSLinkage(node,maxNumber,minNumber){
  1230. setTDSCollect();
  1231. var number = 0;
  1232. var c=$(node);
  1233. if(c.val() == ""){
  1234. $(node).val("");
  1235. }else{
  1236. var temp_amount=c.val().replace(/[^\d]/g,'');
  1237. number = Number(temp_amount)
  1238. if(maxNumber!= null && maxNumber!= "" && number > maxNumber){
  1239. number = maxNumber;
  1240. }
  1241. if(minNumber!= null && minNumber!= "" && number < minNumber){
  1242. number = minNumber;
  1243. }
  1244. $(node).val(number);
  1245. }
  1246. var nodeName = $(node).attr("id");
  1247. if(nodeName == "customerInTDS" ){
  1248. $("#DTS-in").html("进水:" + number + " PPM");
  1249. }else if(nodeName == "customerOutTDS" ){
  1250. $("#DTS-out").html("出水:" + number + " PPM");
  1251. }
  1252. }
  1253. /*===============================客诉提交 -- start -- =============================== */
  1254. $(function(){
  1255. $("#form-customer-add").Validform({
  1256. tiptype: function (msg, o, cssctl) {
  1257. if (o.type == 3) {//失败
  1258. layer.msg(msg, {icon: 5, time: 3000});
  1259. $(window).scrollTop(o.obj.offset().top - 40);
  1260. }
  1261. },
  1262. datatype: {//自定义验证类型
  1263. },
  1264. ignoreHidden: true,
  1265. tipSweep: true, //若为true,则只在表单提交时验证
  1266. ajaxPost: true, //异步提交
  1267. beforeCheck: function (curform) { //验证通过之前执行的函数
  1268. },
  1269. beforeSubmit: function (curform) { //验证通过之后执行的函数
  1270. var flag = addCustomerReady();
  1271. if(!flag){
  1272. return false;
  1273. }
  1274. },
  1275. callback: function (data) {//异步回调函数
  1276. if (data) {
  1277. var index = layer.alert(data.resultMsg, function (index) {
  1278. if (data.resultCode == 200) {
  1279. location.href = url_path + "/admin/customer/select_customer_list";
  1280. } else if(data.resultCode == 505){
  1281. location.href = url_path + "/admin/customer/select_customer_list";
  1282. }else {
  1283. layer.close(index);
  1284. }
  1285. });
  1286. }
  1287. }
  1288. });
  1289. })
  1290. /* 添加客诉的准备 */
  1291. function addCustomerReady(){
  1292. /* 录入电话号码和姓名到客诉基本信息里面 */
  1293. /*if(allCustomerType == 3 || allCustomerType == 4 || allCustomerType == 5 || allCustomerType == 6 || allCustomerType == 7){
  1294. $("#customerName").val($("#sendName").val());
  1295. $("#customerTel").val($("#sendTel").val());
  1296. }*/
  1297. /*验证来源入口*/
  1298. var customerSourceType = $("input:radio[name='customerSourceType']:checked").val();
  1299. if(customerSourceType == 3){
  1300. var customerSourceOld = $("#customerSourceOld").val();
  1301. if(customerSourceOld == null || customerSourceOld == "" || typeof(customerSourceOld)=="undefined"){
  1302. vailErrorMsg($("#customerSourceOld"),"未填写来源入口");
  1303. return false;
  1304. }else{
  1305. $("#customerSource").val(customerSourceOld);
  1306. }
  1307. }
  1308. /*根据产品类型,获取来源商城*/
  1309. var typeCompany = parseInt($("input:radio[name='typeId']:checked").attr("typeCompany"));
  1310. $("#typeCompany").val(typeCompany);
  1311. /*----TDS收集模块--start-----*/
  1312. var valicity = $(".ac_result_tip").html();
  1313. if(valicity == null || valicity == "" || typeof(valicity)=="undefined"){
  1314. $("#TDSArea").html("");
  1315. }else if(valicity.indexOf("对不起,找不到") > 0 ){
  1316. $("#TDSArea").html("");
  1317. $("#customerArea").val("");
  1318. }else{
  1319. var TDSArea = $("#TDSArea").find("option:selected").text();
  1320. if(TDSArea != null && TDSArea != ""){
  1321. var area = TDSCity + "-" + TDSArea
  1322. $("#customerArea").val(area);
  1323. }
  1324. }
  1325. /*----TDS收集模块--end-----*/
  1326. /* 地址拼接 */
  1327. var province = $("#province").find("option:selected").text();
  1328. var city = $("#city").find("option:selected").text();
  1329. var district = $("#district").find("option:selected").text();
  1330. var relationSendMergeAddress = province + "-" + city + "-" + district;
  1331. $("#relationSendMergeAddress").val(relationSendMergeAddress);
  1332. /* 地址拼接 */
  1333. /*----问题描述- start --*/
  1334. var describeContentText = UE.getEditor('describeContentText').getContent();
  1335. if(describeContentText == null || describeContentText == ""){
  1336. //layer.msg("未填写问题描述", {icon: 5, time: 3000});
  1337. vailErrorMsg($("#describeTitle"),"未填写问题描述");
  1338. return false;
  1339. }
  1340. $("#describeContent").val(describeContentText);
  1341. /*----问题描述--end-----*/
  1342. /*----处理描述- start --*/
  1343. var describeHandleDescText = UE.getEditor('describeHandleDescText').getContent();
  1344. $("#describeHandleDesc").val(describeHandleDescText);
  1345. /*----处理描述--end-----*/
  1346. /* --- 类型:售后 处理结果:维修/换新/补发/退货/无理由退货 -- 处理产品 start---- */
  1347. var sendProdcues = new Array(); //寄出产品表
  1348. var sendFittings = new Array();
  1349. var closedProdcues = new Array();
  1350. var closedFittings = new Array();
  1351. $("#addProduct").find(".input-color-number").each(function(){
  1352. var number = $(this).val();
  1353. if(number != null && number != "" && number != 0){
  1354. var product = new Object();
  1355. product.productId = $(this).parent().find(".input-produce-id").val();
  1356. product.colorId = $(this).parent().find(".input-color-id").val();
  1357. //换新、维修,退货,无理由退货,
  1358. if(allCustomerType == 3 || allCustomerType == 4 || allCustomerType == 6 || allCustomerType == 7){
  1359. product.closedProdcueNumber = number;
  1360. closedProdcues.push(product);
  1361. }else if(allCustomerType == 5){
  1362. product.sendProdcueNumber = number;
  1363. sendProdcues.push(product);
  1364. }
  1365. }
  1366. })
  1367. $("#addProduct").find(".input-fittings-number").each(function(){
  1368. var number = $(this).val();
  1369. if(number != null && number != "" && number != 0){
  1370. var fittings = new Object();
  1371. fittings.productId = $(this).parent().find(".input-produce-id").val();
  1372. fittings.fittingsId = $(this).parent().find(".input-fittings-id").val();
  1373. //换新、维修,退货,无理由退货,
  1374. if(allCustomerType == 3 || allCustomerType == 4 || allCustomerType == 6 || allCustomerType == 7){
  1375. fittings.closedFittingNumber = number;
  1376. closedFittings.push(fittings);
  1377. }else if(allCustomerType == 5){
  1378. fittings.sendFittingNumber = number;
  1379. sendFittings.push(fittings);
  1380. }
  1381. }
  1382. })
  1383. $("#back-product").find(".input-color-number").each(function(){
  1384. var number = $(this).val();
  1385. if(number != null && number != "" && number != 0){
  1386. //换新、维修,
  1387. if(allCustomerType == 3 || allCustomerType == 4){
  1388. var fittings = new Object();
  1389. fittings.productId = $(this).parent().find(".input-produce-id").val();
  1390. fittings.colorId = $(this).parent().find(".input-color-id").val();
  1391. fittings.sendProdcueNumber = number;
  1392. sendProdcues.push(fittings);
  1393. }
  1394. }
  1395. })
  1396. $("#back-product").find(".input-fittings-number").each(function(){
  1397. var number = $(this).val();
  1398. if(number != null && number != "" && number != 0){
  1399. //换新、维修
  1400. if(allCustomerType == 3 || allCustomerType == 4){
  1401. var fittings = new Object();
  1402. fittings.productId = $(this).parent().find(".input-produce-id").val();
  1403. fittings.fittingsId = $(this).parent().find(".input-fittings-id").val();
  1404. fittings.sendFittingNumber = number;
  1405. sendFittings.push(fittings);
  1406. }
  1407. }
  1408. })
  1409. var backErrorMsg = "请选择一个replace_error_msg寄回的产品或配件并填写一个以上的数量!"
  1410. var sendErrorMsg = "请选择一个replace_error_msg寄送的产品或配件并填写一个以上的数量!"
  1411. var process = true;
  1412. switch (allCustomerType){
  1413. case 3:
  1414. process = processIsEmpty([closedProdcues,closedFittings]);
  1415. if(!process){
  1416. var msg = backErrorMsg.replace("replace_error_msg","换新");
  1417. layer.msg(msg, {icon: 5, time: 3000});
  1418. return false;
  1419. }
  1420. process = processIsEmpty([sendProdcues,sendFittings]);
  1421. if(!process){
  1422. var msg = sendErrorMsg.replace("replace_error_msg","换新");
  1423. layer.msg(msg, {icon: 5, time: 3000});
  1424. return false;
  1425. }
  1426. break;
  1427. case 4:
  1428. process = processIsEmpty([closedProdcues,closedFittings]);
  1429. if(!process){
  1430. var msg = backErrorMsg.replace("replace_error_msg","维修");
  1431. layer.msg(msg, {icon: 5, time: 3000});
  1432. return false;
  1433. }
  1434. process = processIsEmpty([sendProdcues,sendFittings]);
  1435. if(!process){
  1436. var msg = sendErrorMsg.replace("replace_error_msg","维修");
  1437. layer.msg(msg, {icon: 5, time: 3000});
  1438. return false;
  1439. }
  1440. break;
  1441. case 5:
  1442. process = processIsEmpty([sendProdcues,sendFittings]);
  1443. if(!process){
  1444. var msg = sendErrorMsg.replace("replace_error_msg","补发");
  1445. layer.msg(msg, {icon: 5, time: 3000});
  1446. return false;
  1447. }
  1448. break;
  1449. case 6:
  1450. process = processIsEmpty([closedProdcues,closedFittings]);
  1451. if(!process){
  1452. var msg = backErrorMsg.replace("replace_error_msg","退货");
  1453. layer.msg(msg, {icon: 5, time: 3000});
  1454. return false;
  1455. }
  1456. break;
  1457. case 7:
  1458. process = processIsEmpty([closedProdcues,closedFittings]);
  1459. if(!process){
  1460. var msg = backErrorMsg.replace("replace_error_msg","退货");
  1461. layer.msg(msg, {icon: 5, time: 3000});
  1462. return false;
  1463. }
  1464. break;
  1465. default:
  1466. break;
  1467. }
  1468. $("#sendProdcues").val(JSON.stringify(sendProdcues));
  1469. $("#sendFittings").val(JSON.stringify(sendFittings));
  1470. $("#closedProdcues").val(JSON.stringify(closedProdcues));
  1471. $("#closedFittings").val(JSON.stringify(closedFittings));
  1472. var visitTimeSelect = $("input[name='visitTimeSelect']:checked").val();
  1473. var visit_date = $('#datemin').val();
  1474. var myDate = new Date();
  1475. var date = myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+myDate.getDate();
  1476. var hours = myDate.getHours();
  1477. //如果两个时间相等,则判断可选的回访时间
  1478. if(Date.parse(visit_date) == Date.parse(date)){
  1479. var msg = "该时间已超过当前时间,请重新选择回访时间!";
  1480. if (hours > 12 && visitTimeSelect == 1) {
  1481. vailErrorMsg($("#datemin"),msg);
  1482. return false;
  1483. } else if (hours > 14 && visitTimeSelect == 2) {
  1484. vailErrorMsg($("#datemin"),msg);
  1485. return false;
  1486. } else if (hours > 18 && visitTimeSelect == 3) {
  1487. vailErrorMsg($("#datemin"),msg);
  1488. return false;
  1489. }
  1490. }
  1491. return true;
  1492. }
  1493. /* 判断产品与配件是否填入值 */
  1494. function processIsEmpty(process){
  1495. if(process != null && process != "" && process.length > 0){
  1496. var flag = 2;
  1497. var num = 0;
  1498. if(process[0] == null || process[0].length < 1 ){
  1499. flag -- ;
  1500. }
  1501. if(process[1] == null || process[1].length < 1 ){
  1502. flag -- ;
  1503. }
  1504. for(var j=0; j<process.length;j++){
  1505. for(var i=0;i<process[j].length;i++){
  1506. if(process[j][i].sendProdcueNumber !== undefined){
  1507. num += process[j][i].sendProdcueNumber;
  1508. }
  1509. if(process[j][i].sendFittingNumber !== undefined){
  1510. num += process[j][i].sendFittingNumber;
  1511. }
  1512. if(process[j][i].closedProdcueNumber !== undefined){
  1513. num += process[j][i].closedProdcueNumber ;
  1514. }
  1515. if(process[j][i].closedFittingNumber !== undefined){
  1516. num += process[j][i].closedFittingNumber;
  1517. }
  1518. }
  1519. }
  1520. if(flag == 0){
  1521. return false;
  1522. }
  1523. if(num == 0){
  1524. return false;
  1525. }
  1526. }
  1527. return true;
  1528. }
  1529. /*===============================客诉提交 -- end -- =============================== */