customer.js 82 KB

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