customer.js 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659
  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问题 type=1 表示为用户点击 type=2表示自动触发*/
  772. function saveQuestion(type){
  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. if(type == 1){
  813. layer.msg(data.resultMsg, {icon: 1, time: 3000});
  814. }
  815. }else{
  816. if(type == 1) {
  817. layer.msg(data.resultMsg, {icon: 5, time: 3000});
  818. }
  819. }
  820. layer.close(index);
  821. },
  822. error: function(XmlHttpRequest, textStatus, errorThrown){
  823. layer.close(index);
  824. }
  825. });
  826. }
  827. /***
  828. * 打开搜索订单框
  829. */
  830. function selectOrder(){
  831. layer_show("搜索订单",url_path + "/admin/customer/select_order","1000","500");
  832. }
  833. /**
  834. * 显示选择的订单
  835. */
  836. function setSelectOrder(orderId){
  837. if(orderId == null || orderId == "" || typeof (orderId)=="undefined"){
  838. layer.msg("未选中订单", {icon: 5, time: 3000});
  839. return false
  840. }
  841. var html = '';
  842. var addresHtml = '';
  843. var address = ''; //地址
  844. var orderItemList = {};
  845. var companyId = ''; //销售公司
  846. var storeId = ''; //店铺
  847. $.ajax({
  848. type: "POST",
  849. data: {
  850. salesId : orderId
  851. },
  852. url: url_path + "/admin/customer/select_salesOrder",
  853. async: false,
  854. success: function(data){
  855. if (data.returnCode == 200) {
  856. for(var i=0;i<data.returnMsg.salesOrderList.length;i++){
  857. var salesOrder = data.returnMsg.salesOrderList[i];
  858. companyId = salesOrder.salesCompanyId;
  859. storeId = salesOrder.salesStoreId;
  860. var productsHtml = '';
  861. var salesOrderItem = salesOrder.salesOrderItemList;
  862. orderItemList = salesOrder.salesOrderItemList;
  863. for(var j=0;j<salesOrderItem.length;j++){
  864. var item = salesOrderItem[j].itemProductName + "*" + salesOrderItem[j].itemNum;
  865. if(j==0){
  866. productsHtml += item
  867. }else{
  868. productsHtml += '<br>'+ item
  869. }
  870. }
  871. var time = formatDate(new Date(salesOrder.salesCreateTime),"yyyy-MM-dd");
  872. html += '' +
  873. ' <td style="text-align: center;">'+ convertUndefinedToEmpty(salesOrder.companyName) +'</td>' +
  874. ' <td style="text-align: center;">'+ convertUndefinedToEmpty(salesOrder.storeName) +'</td>' +
  875. ' <td style="text-align: center;">'+ salesOrder.salesId +'</td>' +
  876. ' <td style="text-align: center;">'+ salesOrder.salesAddressName +'</td>' +
  877. ' <td style="text-align: center;">'+ salesOrder.salesAddressTel +'</td>' +
  878. ' <td style="text-align: center;">'+ salesOrder.salesAmount/100 +'</td>' +
  879. ' <td style="text-align: center;">'+ productsHtml +'</td>' +
  880. ' <td style="text-align: center;">'+ time +'</td>' +
  881. '';
  882. addresHtml = '<td colspan="1" style="text-align: center;">收货地址</td><td colspan="7" class="td-manage text-c" >'+ salesOrder.salesAddressInfo +'</td>' ;
  883. address = salesOrder.salesAddressInfo;
  884. $("#sendName").val(salesOrder.salesAddressName); //收件人名称
  885. $("#sendTel").val(salesOrder.salesAddressTel); //收件人电话号码
  886. var name = $("#customerName").val();
  887. var tel = $("#customerTel").val();
  888. if(name == "" || name == null){
  889. $("#customerName").val(salesOrder.salesAddressName); //收件人名称
  890. }
  891. if(tel == "" || tel == null){
  892. $("#customerTel").val(salesOrder.salesAddressTel); //收件人电话号码
  893. }
  894. }
  895. // $("#showOrderAddress").html(address);
  896. }else{
  897. html = '';
  898. addresHtml = '';
  899. }
  900. $("#showOrder").html(html); //显示订单
  901. $("#showOrderAddress").html(addresHtml); //显示订单地址
  902. $("#showOrderAddress").show();
  903. },
  904. error: function(XmlHttpRequest, textStatus, errorThrown){
  905. }
  906. });
  907. $("#addressInfo").val(address);
  908. setAdress(); //显示地址
  909. setProduce(orderItemList); //显示产品
  910. $("#companyId").val(companyId);
  911. $("#storeId").val(storeId);
  912. $("#orderId").val(orderId);
  913. }
  914. /**
  915. * 设置地址
  916. */
  917. function setAdress(){
  918. var addres = $("#addressInfo").val();
  919. $("#addrssMsg").html("");
  920. if(addres == null){
  921. $("#addrssMsg").html("*未能获取到地址,请手动选择地址");
  922. return;
  923. }
  924. var addresList = addres.split("-");
  925. if(addresList[0] == null || addresList[1]==null || addresList[2]==null || addresList[3]==null){
  926. $("#addrssMsg").html("*未能获取到地址,请手动选择地址");
  927. return;
  928. }
  929. var proId = setPro(getAddress(addresList[0],0),1);
  930. var cityId = setCity(getAddress(addresList[1],1),proId,1);
  931. setDistrict(getAddress(addresList[2],2),cityId,1);
  932. var sendAddress = addresList[3];
  933. if(addresList.length > 4){
  934. for(var k = 4;k< addresList.length;k++){
  935. sendAddress += addresList[k];
  936. }
  937. }
  938. $("#sendAddress").val(sendAddress);
  939. }
  940. /***
  941. * 删除 “省”,“市”,“区”关键字
  942. * type : 0:省 2:市 3:区
  943. */
  944. function getAddress(addrss,type) {
  945. var abbreviation = "";
  946. if(addrss == ""){
  947. abbreviation = "";
  948. }else{
  949. switch(type)
  950. {
  951. case 0:
  952. //var proReg = new RegExp("省","g");
  953. //abbreviation = addrss.replace(proReg,"");
  954. abbreviation = addrss.substring(0,2);
  955. break;
  956. case 1:
  957. var cityReg = new RegExp("市","g");
  958. abbreviation = addrss.replace(cityReg,"");
  959. cityReg = new RegExp("区","g");
  960. abbreviation = addrss.replace(cityReg,"");
  961. break;
  962. case 2:
  963. var districtReg = new RegExp("区","g");
  964. abbreviation = addrss.replace(districtReg,"");
  965. districtReg = new RegExp("市","g");
  966. abbreviation = abbreviation.replace(districtReg,"");
  967. break;
  968. default:
  969. break;
  970. }
  971. }
  972. return abbreviation
  973. }
  974. /**
  975. * 设置省
  976. * type 1:搜索订单赋值 2:只查询全部,默认第一个
  977. */
  978. function setPro(provinceName,type) {
  979. var proId = '';
  980. var province = listProvince();
  981. var selectPro = new Array();
  982. if(type == 1){
  983. selectPro = listProvince("",provinceName);
  984. }
  985. if(province!=null){
  986. var provinceHtml = ''
  987. for(var i=0;i<province.length;i++){
  988. provinceHtml += '<option value="'+ province[i].provinceId +'">'+ province[i].province +'</option>';
  989. }
  990. $("#province").html(provinceHtml);
  991. if(selectPro != null && selectPro.length > 0 ){
  992. proId = selectPro[0].provinceId;
  993. }else{
  994. proId = province[0].provinceId;
  995. }
  996. $("#province option[value='" + proId + "']").attr("selected","true");
  997. }
  998. return proId;
  999. }
  1000. /**
  1001. * 设置市
  1002. * type 1:搜索订单赋值 2:只查询全部,默认第一个
  1003. */
  1004. function setCity(cityName,proId,type) {
  1005. var cityId = '';
  1006. var city = listCity(proId,"");
  1007. var selectCity = new Array();
  1008. if(type == 1){
  1009. selectCity = listCity(proId,cityName);
  1010. }
  1011. if(city!=null){
  1012. var cityHtml = ''
  1013. for(var i=0;i<city.length;i++){
  1014. cityHtml += '<option value="'+ city[i].cityId +'">'+ city[i].city +'</option>';
  1015. }
  1016. $("#city").html(cityHtml);
  1017. if(selectCity != null && selectCity.length > 0 ){
  1018. cityId = selectCity[0].cityId;
  1019. }else{
  1020. cityId = city[0].cityId;
  1021. }
  1022. $("#city option[value='" + cityId + "']").attr("selected","true");
  1023. }
  1024. return cityId;
  1025. }
  1026. /**
  1027. * 设置区
  1028. * type 1:搜索订单赋值 2:只查询全部,默认第一个
  1029. */
  1030. function setDistrict(districtName,cityId,type) {
  1031. var district = listDistrict(cityId,"");
  1032. var selectDistrict = new Array();
  1033. if(type == 1){
  1034. selectDistrict = listDistrict(cityId,districtName);
  1035. }
  1036. if(district!=null){
  1037. var districtHtml = ''
  1038. for(var i=0;i<district.length;i++){
  1039. districtHtml += '<option value="'+ district[i].districtId +'">'+ district[i].district +'</option>';
  1040. }
  1041. var disId = "";
  1042. $("#district").html(districtHtml);
  1043. if(selectDistrict != null && selectDistrict.length > 0 ){
  1044. disId = selectDistrict[0].districtId;
  1045. }else{
  1046. disId = district[0].districtId;
  1047. }
  1048. $("#district option[value='" + disId + "']").attr("selected","true");
  1049. }
  1050. }
  1051. /* TDS收集设置区 */
  1052. var TDSCity = '';
  1053. function linkageSetDistrict(){
  1054. var arrcity_3word = $("#arrcity_3word").val();
  1055. var cityName = '北京';
  1056. for(var i = 0;i<citys.length;i++){
  1057. for(var j=0;j<citys[i].length;j++){
  1058. if(j == 0 && arrcity_3word == citys[i][j]){
  1059. cityName = citys[i][1];
  1060. }
  1061. }
  1062. }
  1063. TDSCity = cityName;
  1064. var selectCity = listCity(null,cityName);
  1065. var cityId = selectCity[0].cityId;
  1066. var selectDistrict = listDistrict(cityId,"");
  1067. var html = '';
  1068. for(var i=0;i<selectDistrict.length;i++){
  1069. html += '<option value="'+ selectDistrict[i].districtId +'">'+ selectDistrict[i].district +'</option>';
  1070. }
  1071. $("#TDSArea").html(html);
  1072. $("#TDSArea").find("option").eq(0).prop("selected",true);
  1073. setTDSCollect();
  1074. }
  1075. /**
  1076. * 展示产品
  1077. * @param orderItemList
  1078. */
  1079. function setProduce(orderItemList) {
  1080. var productList = getProduct() ; //所有产品
  1081. var html = "";
  1082. var productTypeNo = 0;
  1083. for(var i=0;i<productList.length;i++) {
  1084. var product = productList[i];
  1085. var produceFittings = getProduceFittings(product.productId); //获取该产品的所有配件
  1086. var colorList = product.colorList; //该产品的所有颜色
  1087. var productType = product.productType;
  1088. var colorHtml = '';
  1089. if(colorList != null && colorList.length >0 ){
  1090. colorHtml += '<table style="height: 100%;">';
  1091. for(var j=0;j<colorList.length;j++){
  1092. var number = "";
  1093. var color = colorList[j];
  1094. for(var k=0;k<orderItemList.length;k++){
  1095. var item = orderItemList[k];
  1096. if(item.itemColorId == color.colorId && item.itemIsSource == 1){
  1097. number = item.itemNum;
  1098. }
  1099. }
  1100. var fristInputStyle = "border-top: 1px solid #ddd;";
  1101. if(color.colorProductId == product.productId) {
  1102. colorHtml += '<tr >' +
  1103. ' <td width="55" style="border-left: none;text-align: center;'+ fristInputStyle +'">' + color.colorName + '</td>' +
  1104. ' <td width="45" style="'+ fristInputStyle +' padding: 0px;width: 25px;">' +
  1105. ' <input type="hidden" class="input-produce-id" value="' + color.colorProductId + '">' +
  1106. ' <input type="hidden" class="input-color-id" value="' + color.colorId + '">' +
  1107. ' <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)" >' +
  1108. ' </td>' +
  1109. ' </tr>';
  1110. fristInputStyle = "";
  1111. }
  1112. }
  1113. colorHtml += '</table>';
  1114. }else{
  1115. colorHtml += '<span>暂无该产品的颜色!<span>';
  1116. }
  1117. var produceFittingsHtml = '';
  1118. if(produceFittings != null && produceFittings.length > 0){
  1119. produceFittingsHtml += '<table style="height: 100%;">';
  1120. for(var m=0;m<produceFittings.length;m++){
  1121. var number = "";
  1122. var fitt = produceFittings[m];
  1123. for(var k=0;k<orderItemList.length;k++){
  1124. var item = orderItemList[k];
  1125. if(item.itemColorId == fitt.fittingsId && item.itemIsSource == 2){
  1126. number = item.itemNum;
  1127. }
  1128. }
  1129. var produceFit = produceFittings[m];
  1130. if(produceFit.productId == product.productId) {
  1131. var fristInputStyle = "border-top: 1px solid #ddd;";
  1132. produceFittingsHtml += '<tr >' +
  1133. ' <td width="55" style="border-left: none;text-align: center; '+ fristInputStyle +'">' + produceFit.fittingsName +'</td>' +
  1134. ' <td width="45" style="'+ fristInputStyle +'padding: 0px;width: 25px;">' +
  1135. ' <input type="hidden" class="input-produce-id" value="' + produceFit.productId + '">' +
  1136. ' <input type="hidden" class="input-fittings-id" value="' + produceFit.fittingsId +'">' +
  1137. ' <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)" >' +
  1138. ' </td>' +
  1139. ' </tr>';
  1140. fristInputStyle = "";
  1141. }
  1142. }
  1143. produceFittingsHtml += '</table>';
  1144. }else{
  1145. produceFittingsHtml += '<span>暂无产品配件!<span>';
  1146. }
  1147. var produceHtml = '<input type="hidden" value="'+ product.productId +'">' +
  1148. '<span>'+ product.productName +'</span>';
  1149. html += ' <tr >' +
  1150. ' <td width="80">'+ produceHtml +'</td>' +
  1151. ' <td style="padding: 0px;text-align: center;">' +
  1152. colorHtml +
  1153. ' </td>' +
  1154. ' <td style="padding: 0px;text-align: center;">' +
  1155. produceFittingsHtml +
  1156. ' </td>' +
  1157. '</tr>';
  1158. }
  1159. $("#addProduct").html(html);
  1160. setBackProduct(html); //设置寄回产品
  1161. monitorProduct(); //监听产品变化
  1162. }
  1163. /*获取产品*/
  1164. function getProduct(){
  1165. var productList;
  1166. $.ajax({
  1167. type: "POST",
  1168. data: {
  1169. },
  1170. url: url_path + "/admin/customer/select_produce",
  1171. async: false,
  1172. success: function(data){
  1173. if (data.returnCode == 200) {
  1174. productList = data.returnMsg.productList;
  1175. }
  1176. },
  1177. error: function(XmlHttpRequest, textStatus, errorThrown){
  1178. }
  1179. });
  1180. return productList;
  1181. }
  1182. /*获取产品配件*/
  1183. function getProduceFittings(productId){
  1184. var produceFittings;
  1185. $.ajax({
  1186. type: "get",
  1187. data: {
  1188. productId : productId
  1189. },
  1190. url: url_path + "/admin/customer/select_produce_fittings",
  1191. async: false,
  1192. success: function(data){
  1193. if (data.returnCode == 200) {
  1194. produceFittings = data.returnMsg.produceFittingsList;
  1195. }
  1196. },
  1197. error: function(XmlHttpRequest, textStatus, errorThrown){
  1198. }
  1199. });
  1200. return produceFittings;
  1201. }
  1202. /*监听产品变化*/
  1203. function monitorProduct(){
  1204. /*产品数量*/
  1205. $("#addProduct").find(".input-color-number").blur(function (){
  1206. setBackProduct();
  1207. })
  1208. /*产品配件*/
  1209. $("#addProduct").find(".input-fittings-number").blur(function (){
  1210. setBackProduct();
  1211. })
  1212. }
  1213. /*设置寄回产品*/
  1214. function setBackProduct(html) {
  1215. if(html != null && html != "" && typeof(html) != "undefined"){
  1216. $("#back-product").html(html);
  1217. }else{
  1218. $("#addProduct").find(".input-color-number").each(function(){
  1219. var number = $(this).val();
  1220. var colorNodeId = $(this).attr("id");
  1221. $("#back-product").find("#"+colorNodeId).val(number);
  1222. })
  1223. $("#addProduct").find(".input-fittings-number").each(function(){
  1224. var number = $(this).val();
  1225. var fittingsNodeId = $(this).attr("id");
  1226. $("#back-product").find("#"+fittingsNodeId).val(number);
  1227. })
  1228. }
  1229. }
  1230. /*设置TDS收集信息*/
  1231. function setTDSCollect(){
  1232. var TDSArea = $("#TDSArea").find("option:selected").text();
  1233. var TDSAddress = TDSCity + '-' + TDSArea;
  1234. if(TDSAddress != null && TDSAddress != ""){
  1235. $("#DTS-address").html("地址:" + TDSAddress);
  1236. }
  1237. }
  1238. /*TDS联动处理*/
  1239. function TDSLinkage(node,maxNumber,minNumber){
  1240. setTDSCollect();
  1241. var number = 0;
  1242. var c=$(node);
  1243. if(c.val() == ""){
  1244. $(node).val("");
  1245. }else{
  1246. var temp_amount=c.val().replace(/[^\d]/g,'');
  1247. number = Number(temp_amount)
  1248. if(maxNumber!= null && maxNumber!= "" && number > maxNumber){
  1249. number = maxNumber;
  1250. }
  1251. if(minNumber!= null && minNumber!= "" && number < minNumber){
  1252. number = minNumber;
  1253. }
  1254. $(node).val(number);
  1255. }
  1256. var nodeName = $(node).attr("id");
  1257. if(nodeName == "customerInTDS" ){
  1258. $("#DTS-in").html("进水:" + number + " PPM");
  1259. }else if(nodeName == "customerOutTDS" ){
  1260. $("#DTS-out").html("出水:" + number + " PPM");
  1261. }
  1262. }
  1263. /*===============================客诉提交 -- start -- =============================== */
  1264. $(function(){
  1265. $("#form-customer-add").Validform({
  1266. tiptype: function (msg, o, cssctl) {
  1267. if (o.type == 3) {//失败
  1268. layer.msg(msg, {icon: 5, time: 3000});
  1269. $(window).scrollTop(o.obj.offset().top - 40);
  1270. }
  1271. },
  1272. datatype: {//自定义验证类型
  1273. },
  1274. ignoreHidden: true,
  1275. tipSweep: true, //若为true,则只在表单提交时验证
  1276. ajaxPost: true, //异步提交
  1277. beforeCheck: function (curform) { //验证通过之前执行的函数
  1278. },
  1279. beforeSubmit: function (curform) { //验证通过之后执行的函数
  1280. var flag = addCustomerReady();
  1281. if(!flag){
  1282. return false;
  1283. }
  1284. },
  1285. callback: function (data) {//异步回调函数
  1286. if (data) {
  1287. var index = layer.alert(data.resultMsg, function (index) {
  1288. if (data.resultCode == 200) {
  1289. location.href = url_path + "/admin/customer/select_customer_list";
  1290. } else if(data.resultCode == 505){
  1291. location.href = url_path + "/admin/customer/select_customer_list";
  1292. }else {
  1293. layer.close(index);
  1294. }
  1295. });
  1296. }
  1297. }
  1298. });
  1299. })
  1300. /* 添加客诉的准备 */
  1301. function addCustomerReady(){
  1302. //保存AQ
  1303. saveQuestion(2);
  1304. /* 录入电话号码和姓名到客诉基本信息里面 */
  1305. /*if(allCustomerType == 3 || allCustomerType == 4 || allCustomerType == 5 || allCustomerType == 6 || allCustomerType == 7){
  1306. $("#customerName").val($("#sendName").val());
  1307. $("#customerTel").val($("#sendTel").val());
  1308. }*/
  1309. /*验证来源入口*/
  1310. var customerSourceType = $("input:radio[name='customerSourceType']:checked").val();
  1311. if(customerSourceType == 3){
  1312. var customerSourceOld = $("#customerSourceOld").val();
  1313. if(customerSourceOld == null || customerSourceOld == "" || typeof(customerSourceOld)=="undefined"){
  1314. vailErrorMsg($("#customerSourceOld"),"未填写来源入口");
  1315. return false;
  1316. }else{
  1317. $("#customerSource").val(customerSourceOld);
  1318. }
  1319. }
  1320. /*根据产品类型,获取来源商城*/
  1321. var typeCompany = parseInt($("input:radio[name='typeId']:checked").attr("typeCompany"));
  1322. $("#typeCompany").val(typeCompany);
  1323. /*----TDS收集模块--start-----*/
  1324. var valicity = $(".ac_result_tip").html();
  1325. if(valicity == null || valicity == "" || typeof(valicity)=="undefined"){
  1326. $("#TDSArea").html("");
  1327. }else if(valicity.indexOf("对不起,找不到") > 0 ){
  1328. $("#TDSArea").html("");
  1329. $("#customerArea").val("");
  1330. }else{
  1331. var TDSArea = $("#TDSArea").find("option:selected").text();
  1332. if(TDSArea != null && TDSArea != ""){
  1333. var area = TDSCity + "-" + TDSArea
  1334. $("#customerArea").val(area);
  1335. }
  1336. }
  1337. /*----TDS收集模块--end-----*/
  1338. /* 地址拼接 */
  1339. var province = $("#province").find("option:selected").text();
  1340. var city = $("#city").find("option:selected").text();
  1341. var district = $("#district").find("option:selected").text();
  1342. var relationSendMergeAddress = province + "-" + city + "-" + district;
  1343. $("#relationSendMergeAddress").val(relationSendMergeAddress);
  1344. /* 地址拼接 */
  1345. /*----问题描述- start --*/
  1346. var describeContentText = UE.getEditor('describeContentText').getContent();
  1347. if(describeContentText == null || describeContentText == ""){
  1348. //layer.msg("未填写问题描述", {icon: 5, time: 3000});
  1349. vailErrorMsg($("#describeTitle"),"未填写问题描述");
  1350. return false;
  1351. }
  1352. $("#describeContent").val(describeContentText);
  1353. /*----问题描述--end-----*/
  1354. /*----处理描述- start --*/
  1355. var describeHandleDescText = UE.getEditor('describeHandleDescText').getContent();
  1356. $("#describeHandleDesc").val(describeHandleDescText);
  1357. /*----处理描述--end-----*/
  1358. /* --- 类型:售后 处理结果:维修/换新/补发/退货/无理由退货 -- 处理产品 start---- */
  1359. var sendProdcues = new Array(); //寄出产品表
  1360. var sendFittings = new Array();
  1361. var closedProdcues = new Array();
  1362. var closedFittings = new Array();
  1363. $("#addProduct").find(".input-color-number").each(function(){
  1364. var number = $(this).val();
  1365. if(number != null && number != "" && number != 0){
  1366. var product = new Object();
  1367. product.productId = $(this).parent().find(".input-produce-id").val();
  1368. product.colorId = $(this).parent().find(".input-color-id").val();
  1369. //换新、维修,退货,无理由退货,
  1370. if(allCustomerType == 3 || allCustomerType == 4 || allCustomerType == 6 || allCustomerType == 7){
  1371. product.closedProdcueNumber = number;
  1372. closedProdcues.push(product);
  1373. }else if(allCustomerType == 5){
  1374. product.sendProdcueNumber = number;
  1375. sendProdcues.push(product);
  1376. }
  1377. }
  1378. })
  1379. $("#addProduct").find(".input-fittings-number").each(function(){
  1380. var number = $(this).val();
  1381. if(number != null && number != "" && number != 0){
  1382. var fittings = new Object();
  1383. fittings.productId = $(this).parent().find(".input-produce-id").val();
  1384. fittings.fittingsId = $(this).parent().find(".input-fittings-id").val();
  1385. //换新、维修,退货,无理由退货,
  1386. if(allCustomerType == 3 || allCustomerType == 4 || allCustomerType == 6 || allCustomerType == 7){
  1387. fittings.closedFittingNumber = number;
  1388. closedFittings.push(fittings);
  1389. }else if(allCustomerType == 5){
  1390. fittings.sendFittingNumber = number;
  1391. sendFittings.push(fittings);
  1392. }
  1393. }
  1394. })
  1395. $("#back-product").find(".input-color-number").each(function(){
  1396. var number = $(this).val();
  1397. if(number != null && number != "" && number != 0){
  1398. //换新、维修,
  1399. if(allCustomerType == 3 || allCustomerType == 4){
  1400. var fittings = new Object();
  1401. fittings.productId = $(this).parent().find(".input-produce-id").val();
  1402. fittings.colorId = $(this).parent().find(".input-color-id").val();
  1403. fittings.sendProdcueNumber = number;
  1404. sendProdcues.push(fittings);
  1405. }
  1406. }
  1407. })
  1408. $("#back-product").find(".input-fittings-number").each(function(){
  1409. var number = $(this).val();
  1410. if(number != null && number != "" && number != 0){
  1411. //换新、维修
  1412. if(allCustomerType == 3 || allCustomerType == 4){
  1413. var fittings = new Object();
  1414. fittings.productId = $(this).parent().find(".input-produce-id").val();
  1415. fittings.fittingsId = $(this).parent().find(".input-fittings-id").val();
  1416. fittings.sendFittingNumber = number;
  1417. sendFittings.push(fittings);
  1418. }
  1419. }
  1420. })
  1421. var backErrorMsg = "请选择一个replace_error_msg寄回的产品或配件并填写一个以上的数量!"
  1422. var sendErrorMsg = "请选择一个replace_error_msg寄送的产品或配件并填写一个以上的数量!"
  1423. var process = true;
  1424. switch (allCustomerType){
  1425. case 3:
  1426. process = processIsEmpty([closedProdcues,closedFittings]);
  1427. if(!process){
  1428. var msg = backErrorMsg.replace("replace_error_msg","换新");
  1429. layer.msg(msg, {icon: 5, time: 3000});
  1430. return false;
  1431. }
  1432. process = processIsEmpty([sendProdcues,sendFittings]);
  1433. if(!process){
  1434. var msg = sendErrorMsg.replace("replace_error_msg","换新");
  1435. layer.msg(msg, {icon: 5, time: 3000});
  1436. return false;
  1437. }
  1438. break;
  1439. case 4:
  1440. process = processIsEmpty([closedProdcues,closedFittings]);
  1441. if(!process){
  1442. var msg = backErrorMsg.replace("replace_error_msg","维修");
  1443. layer.msg(msg, {icon: 5, time: 3000});
  1444. return false;
  1445. }
  1446. process = processIsEmpty([sendProdcues,sendFittings]);
  1447. if(!process){
  1448. var msg = sendErrorMsg.replace("replace_error_msg","维修");
  1449. layer.msg(msg, {icon: 5, time: 3000});
  1450. return false;
  1451. }
  1452. break;
  1453. case 5:
  1454. process = processIsEmpty([sendProdcues,sendFittings]);
  1455. if(!process){
  1456. var msg = sendErrorMsg.replace("replace_error_msg","补发");
  1457. layer.msg(msg, {icon: 5, time: 3000});
  1458. return false;
  1459. }
  1460. break;
  1461. case 6:
  1462. process = processIsEmpty([closedProdcues,closedFittings]);
  1463. if(!process){
  1464. var msg = backErrorMsg.replace("replace_error_msg","退货");
  1465. layer.msg(msg, {icon: 5, time: 3000});
  1466. return false;
  1467. }
  1468. break;
  1469. case 7:
  1470. process = processIsEmpty([closedProdcues,closedFittings]);
  1471. if(!process){
  1472. var msg = backErrorMsg.replace("replace_error_msg","退货");
  1473. layer.msg(msg, {icon: 5, time: 3000});
  1474. return false;
  1475. }
  1476. break;
  1477. default:
  1478. break;
  1479. }
  1480. $("#sendProdcues").val(JSON.stringify(sendProdcues));
  1481. $("#sendFittings").val(JSON.stringify(sendFittings));
  1482. $("#closedProdcues").val(JSON.stringify(closedProdcues));
  1483. $("#closedFittings").val(JSON.stringify(closedFittings));
  1484. var visitTimeSelect = $("input[name='visitTimeSelect']:checked").val();
  1485. var visit_date = $('#datemin').val();
  1486. var myDate = new Date();
  1487. var date = myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+myDate.getDate();
  1488. var hours = myDate.getHours();
  1489. //如果两个时间相等,则判断可选的回访时间
  1490. if(Date.parse(visit_date) == Date.parse(date)){
  1491. var msg = "该时间已超过当前时间,请重新选择回访时间!";
  1492. if (hours > 12 && visitTimeSelect == 1) {
  1493. vailErrorMsg($("#datemin"),msg);
  1494. return false;
  1495. } else if (hours > 14 && visitTimeSelect == 2) {
  1496. vailErrorMsg($("#datemin"),msg);
  1497. return false;
  1498. } else if (hours > 18 && visitTimeSelect == 3) {
  1499. vailErrorMsg($("#datemin"),msg);
  1500. return false;
  1501. }
  1502. }
  1503. return true;
  1504. }
  1505. /* 判断产品与配件是否填入值 */
  1506. function processIsEmpty(process){
  1507. if(process != null && process != "" && process.length > 0){
  1508. var flag = 2;
  1509. var num = 0;
  1510. if(process[0] == null || process[0].length < 1 ){
  1511. flag -- ;
  1512. }
  1513. if(process[1] == null || process[1].length < 1 ){
  1514. flag -- ;
  1515. }
  1516. for(var j=0; j<process.length;j++){
  1517. for(var i=0;i<process[j].length;i++){
  1518. if(process[j][i].sendProdcueNumber !== undefined){
  1519. num += process[j][i].sendProdcueNumber;
  1520. }
  1521. if(process[j][i].sendFittingNumber !== undefined){
  1522. num += process[j][i].sendFittingNumber;
  1523. }
  1524. if(process[j][i].closedProdcueNumber !== undefined){
  1525. num += process[j][i].closedProdcueNumber ;
  1526. }
  1527. if(process[j][i].closedFittingNumber !== undefined){
  1528. num += process[j][i].closedFittingNumber;
  1529. }
  1530. }
  1531. }
  1532. if(flag == 0){
  1533. return false;
  1534. }
  1535. if(num == 0){
  1536. return false;
  1537. }
  1538. }
  1539. return true;
  1540. }
  1541. /*===============================客诉提交 -- end -- =============================== */