customer.js 79 KB

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