customer.js 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770
  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); //获取店铺
  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 typeCompany = parseInt($("input:radio[name='typeId']:checked").attr("typeCompany"));
  352. $("#selectCompany").val(typeCompany);
  353. $("#companyId").val(typeCompany);
  354. var isOrder = 1;
  355. var isShowTDS = 2;//是否展示tds 1是 2否
  356. switch (typeId){ //1:Soodo电动牙刷 6:WaterO净水机 7:Aiberle净水机 9 :YULIA净水机
  357. case 1:
  358. setStore(typeCompany,null);
  359. isOrder = 2;
  360. break;
  361. case 6:
  362. setStore(typeCompany,null);
  363. isOrder = 1;
  364. isShowTDS = 1;
  365. break;
  366. case 7:
  367. setStore(typeCompany,null);
  368. isOrder = 1;
  369. isShowTDS = 1;
  370. break;
  371. case 9:
  372. setStore(typeCompany,null);
  373. isOrder = 1;
  374. isShowTDS = 1;
  375. break;
  376. case 16://诺米克净水机
  377. isOrder = 1;
  378. isShowTDS = 1;
  379. setStore(typeCompany,"73");
  380. break;
  381. case 17://花作净水机
  382. isOrder = 1;
  383. isShowTDS = 1;
  384. setStore(typeCompany,"75");
  385. break;
  386. default:
  387. setStore(typeCompany,null);
  388. break;
  389. }
  390. isNeedSelectOrder = isOrder ;
  391. initProcessResult(allProcMethodIsBack,allProcMethodIsSend);
  392. if(isShowTDS == 1){
  393. $("#tdsId").show();
  394. }else{
  395. $("#tdsId").hide();
  396. }
  397. })
  398. /*当前第一个默认选中上朵电动牙刷 isNeedSelectOrder = 2 默认不需要选择订单*/
  399. // isNeedSelectOrder = 2 ;
  400. // initProcessResult(allProcMethodIsBack,allProcMethodIsSend);
  401. },
  402. error: function(XmlHttpRequest, textStatus, errorThrown){
  403. }
  404. });
  405. }
  406. /**
  407. *
  408. */
  409. function ulcProcessResult(data){
  410. initProcessResult(data[1].procMethodIsBack,data[1].procMethodIsSend);
  411. $("#procMethodDesc").html("补充说明:"+data[1].procMethodDesc);
  412. }
  413. /**
  414. * 选择处理结果-- 默认选择已解决
  415. * type : 1 :已解决 2:未解决 3:换新 4:维修 5:补发 6:退货 7:无理由退货 -- 删除
  416. * procMethodIsBack : 是否需要寄回 1:需要寄回 2:不需要寄回
  417. * procMethodIsSend : 是否需要寄出 1:需要寄出 2:不需要寄出
  418. */
  419. function initProcessResult(procMethodIsBack,procMethodIsSend){
  420. if(procMethodIsBack == null || procMethodIsBack == ""){
  421. procMethodIsBack = 1;
  422. }
  423. if(procMethodIsSend == null || procMethodIsSend == ""){
  424. procMethodIsSend = 1;
  425. }
  426. allProcMethodIsBack=procMethodIsBack;
  427. allProcMethodIsSend=procMethodIsSend;
  428. var customerInfoType = allCustomerInfoType; //售前售后
  429. if(allCustomerInfoType == null || allCustomerInfoType == ""){
  430. allCustomerInfoType = $("input[name='customerCounselType']:checked").val();
  431. }
  432. otherHied(); //全部隐藏
  433. if(allCustomerInfoType == 1){ //售前
  434. $("#customerCostsDiv").hide();
  435. }else if(allCustomerInfoType == 2){ //售后
  436. $("#customerCostsDiv").hide();
  437. if(!isInitSendAddressSms){
  438. initComplaintQuestionInfo("m");
  439. isInitSendAddressSms = true;
  440. }
  441. if(isUpdate){ //修改页面加载省市区
  442. setAddressInfo(); //修改页面才会调用
  443. }else{
  444. /* 在选择售后类型是,直接初始化省市区,使用isInitAddress 变量来判断 */
  445. // if(isInitAddress == 0){
  446. // var proId = setPro(null,2);
  447. // var cityId = setCity(null,proId,2);
  448. // setDistrict(null,cityId,2);
  449. // isInitAddress = 1;
  450. // }
  451. }
  452. $("#salesChannelsSelect").show(); //展示销售公司
  453. $("#TDScollect").show();
  454. if((procMethodIsBack == 2 && procMethodIsSend == 2)){ //不需要寄回,不需要寄出就是 已解决,未解决
  455. visitByType(1);
  456. isNeedSelectOrder = 2;
  457. }else{
  458. isNeedSelectOrder = 1;
  459. }
  460. if(procMethodIsBack == 1 || procMethodIsSend == 1){
  461. var produceType = $("input[name='typeId']:checked").val();
  462. if(produceType == 1){
  463. isNeedSelectOrder = 2;
  464. }
  465. }
  466. var promType = $("#procTypeId").val() //查看是否为维修
  467. if(promType == 3){
  468. $("#customerCostsDiv").show(); //工厂报价
  469. }
  470. if((procMethodIsBack == 1 || procMethodIsSend == 1) && isNeedSelectOrder == 1){ //是否有订单
  471. if(procMethodIsBack == 1 ){ //需要寄回
  472. $(".renewedProduct").show();
  473. }
  474. if(procMethodIsSend == 1){ //需要寄出
  475. $(".updateProduct").show();
  476. }
  477. //订单信息
  478. $(".orderHead").show();
  479. $(".sendAddressInfo").show();
  480. $("#postageAccount").show(); //邮费转账账户
  481. //地址信息
  482. $(".recipientInfo").show();
  483. $(".recipientAddress").show();
  484. visitByType(2); //需要回访
  485. if(customerInfoType == 1){
  486. $("#salesChannelsSelect").hide(); //展示销售公司
  487. $("#TDScollect").hide();
  488. }else{
  489. $("#salesChannelsSelect").show(); //展示销售公司
  490. $("#TDScollect").show();
  491. }
  492. }
  493. }
  494. }
  495. /*已解决|未解决 */
  496. function otherHied(customerInfoType){
  497. $(".orderHead").hide();
  498. $(".recipientInfo").hide();
  499. $(".recipientAddress").hide();
  500. $(".sendAddressInfo").hide();
  501. $(".renewedProduct").hide();
  502. $(".updateProduct").hide();
  503. }
  504. /*初始化问题大类*/
  505. function initComplaintTypeInfo() {
  506. //默认为售前咨询
  507. //var customerCounselTypeOverall = allCustomerInfoType;
  508. var customerCounselTypeOverall = null;
  509. $.ajax({
  510. type: "POST",
  511. data: {
  512. complaintConsultingType : customerCounselTypeOverall
  513. },
  514. url: url_path + "/admin/complaintQuestion/list_complaintType",
  515. async: true,
  516. success: function(data){
  517. var html = '<option value="">请选择问题分类</option>';
  518. var id;
  519. if (data.returnCode == 200) {
  520. for(var i=0;i<data.returnMsg.complaintTypeInfoList.length;i++){
  521. var complaintTypeInfo = data.returnMsg.complaintTypeInfoList[i];
  522. if(i == 0 ){
  523. id = complaintTypeInfo.complaintId;
  524. }
  525. html += '<option value="'+ complaintTypeInfo.complaintId +'">'+ complaintTypeInfo.complaintClassName +'</option>';
  526. }
  527. }else{
  528. html = '';
  529. }
  530. $("[name='complaintId']").html(html);
  531. },
  532. error: function(XmlHttpRequest, textStatus, errorThrown){
  533. }
  534. });
  535. }
  536. /*显示小类*/
  537. function initComplaintSmallClassInfo(complaintId,smallId){
  538. if(complaintId == null || complaintId == ""){
  539. var html = '<option value="">请选择问题小类</option>';
  540. $("[name='smallClassId']").html(html);
  541. }else{
  542. $.ajax({
  543. type: "POST",
  544. data: {
  545. complaintId : complaintId
  546. },
  547. url: url_path + "/admin/complaintQuestion/list_complaintSmallClass",
  548. async: true,
  549. success: function(data){
  550. var html = '<option value="">请选择问题小类</option>';
  551. if (data.returnCode == 200) {
  552. for(var i=0;i<data.returnMsg.complaintSmallClassInfoList.length;i++){
  553. var ComplaintSmallClassInfo = data.returnMsg.complaintSmallClassInfoList[i];
  554. html += '<option value="'+ ComplaintSmallClassInfo.smallClassId +'">'+ ComplaintSmallClassInfo.smallClassName +'</option>';
  555. }
  556. }else{
  557. html = '';
  558. }
  559. $("[name='smallClassId']").html(html);
  560. if(smallId != null && smallId != "" && typeof(smallId)!="undefined" ){
  561. $("select[name='smallClassId']").val(smallId);
  562. }
  563. },
  564. error: function(XmlHttpRequest, textStatus, errorThrown){
  565. }
  566. });
  567. }
  568. }
  569. var pageNo = 0;//当前页数
  570. var pages = 1;//总页数
  571. /*var previousPage = 0;//上一页
  572. var nextPage = 0;//下一页*/
  573. /**
  574. * 搜索QA 显示
  575. * type p:问题qa; m:邮寄qa
  576. */
  577. function initComplaintQuestionInfo(type){
  578. var complaintId;
  579. var smallClassId;
  580. var questionName;
  581. var customerCounselType;
  582. var questionId;
  583. if(type == "p"){
  584. pageNo = 0;//当前页数
  585. pages = 1;//总页数
  586. complaintId = $("[name='complaintId']").val();
  587. smallClassId = $("[name='smallClassId']").val();
  588. questionName = $("[name='questionIdMsg']").val();
  589. customerCounselType = $("[name='customerCounselType']:checked").val();
  590. }else if(type == "m"){
  591. pageNo = 0;//当前页数
  592. pages = 1;//总页数
  593. questionId = complaint_questionId;
  594. }else if(type == "pr"){
  595. if(pageNo - 1 < 1){
  596. layer.alert("已经到第一页了");
  597. return;
  598. }
  599. complaintId = $("[name='complaintId']").val();
  600. smallClassId = $("[name='smallClassId']").val();
  601. questionName = $("[name='questionIdMsg']").val();
  602. customerCounselType = $("[name='customerCounselType']:checked").val();
  603. pageNo = pageNo - 1;
  604. }else if(type == "ne"){
  605. if(pageNo + 1 > pages){
  606. layer.alert("已经是最后一页了");
  607. return;
  608. }
  609. complaintId = $("[name='complaintId']").val();
  610. smallClassId = $("[name='smallClassId']").val();
  611. questionName = $("[name='questionIdMsg']").val();
  612. customerCounselType = $("[name='customerCounselType']:checked").val();
  613. pageNo = pageNo + 1;
  614. }
  615. $.ajax({
  616. type: "POST",
  617. data: {
  618. complaintId : complaintId,
  619. smallClassId : smallClassId,
  620. questionName : questionName,
  621. /*complaintType : customerCounselType,*/
  622. questionId : questionId,
  623. pageNo : pageNo
  624. },
  625. url: url_path + "/admin/complaintQuestion/list_complaintQuestion",
  626. async: false,
  627. success: function(data){
  628. if(type == "p" || type == "pr" || type == "ne"){
  629. var html = "";
  630. if (data.returnCode == 200) {
  631. for(var i=0;i<data.returnMsg.complaintQuestionInfoList.length;i++){
  632. var complaintQuestion= data.returnMsg.complaintQuestionInfoList[i];
  633. //html += '<li class="ask">'+ complaintQuestion.questionName +'' +
  634. // '</li>' +
  635. // '<li class="answer" style="height: 65px;overflow: hidden;">答:<span>'+ complaintQuestion.questionProfile +'</span><input class="quesId" type="hidden" value="'+ complaintQuestion.questionId +'"></li>';
  636. html += '' +
  637. '<li class="answer" style="height: 20px;overflow: hidden;border-bottom: 1px solid #ddd;"><span>'+ complaintQuestion.questionName +'</span>' +
  638. '<input class="QA_complaintId" type="hidden" value="'+ complaintQuestion.complaintId +'">' +
  639. '<input class="QA_smallClassId" type="hidden" value="'+ complaintQuestion.smallClassId +'">' +
  640. '<input class="quesId" type="hidden" value="'+ complaintQuestion.questionId +'">' +
  641. '<div id="questionProfile" style="display: block">'+ complaintQuestion.questionProfile +'</div>' +
  642. '</li>';
  643. }
  644. }else{
  645. html = '<span style="font-size: 12px; margin-top: 10px; display: block;">未搜索到QA信息,请更换关键字或者直接录入到系统!</span>';
  646. }
  647. pages = data.returnMsg.pagedResult.pages;
  648. pageNo = data.returnMsg.pagedResult.pageNo;
  649. $("#question").find("li").remove();
  650. $("#question").html(html);
  651. $(".dalog-ask").show();
  652. }else if(type == "m"){
  653. var msg = "";
  654. if (data.returnCode == 200) {
  655. msg = data.returnMsg.complaintQuestionInfoList[0].questionProfile;
  656. }
  657. addSmsMsg(msg);
  658. }
  659. },
  660. error: function(XmlHttpRequest, textStatus, errorThrown){
  661. }
  662. });
  663. }
  664. /*添加邮寄信息*/
  665. function addSmsMsg(msg){
  666. /*sendAddressSms.addListener("ready", function () {
  667. // editor准备好之后才可以使用
  668. sendAddressSms.setContent(msg);
  669. });*/
  670. /*邮寄信息*/
  671. $("#sendAddressSmsHtml").html(msg);
  672. }
  673. /**
  674. * 发送短信
  675. * @param type 类型: "problem" 问题处理; mailAddress:邮寄地址;
  676. * @param node 返回结果显示节点
  677. */
  678. function sendPhone(type,node){
  679. var index = layer.load(1, {
  680. shade: [0.5,'#fff'] //0.1透明度的白色背景
  681. });
  682. var desc = "";
  683. var phone = "";
  684. var questionId = "";
  685. var describeTitle = "";
  686. var smallClassId = ""; /* 客诉问题类型小类id */
  687. var typeCompany = parseInt($("input:radio[name='typeId']:checked").attr("typeCompany"));
  688. if(type == "p"){
  689. phone = $("#p-phone").val();
  690. questionId = $("#questionId").val();
  691. describeTitle = $("#describeTitle").val();
  692. desc = UE.getEditor('describeContentText').getContent();
  693. smallClassId = $("#smallClassId").val();
  694. if(smallClassId == null || smallClassId == "" ){
  695. layer.close(index);
  696. layer.msg("请选择问题分类!", {icon: 5, time: 3000});
  697. return false;
  698. }
  699. if(describeTitle==null || describeTitle == ""){
  700. layer.close(index);
  701. layer.msg("请填写问题标题!", {icon: 5, time: 3000});
  702. return false;
  703. }
  704. if(describeTitle.length > 50){
  705. layer.close(index);
  706. layer.msg("问题标题长度不能高于50个字符!", {icon: 5, time: 3000});
  707. return false;
  708. }
  709. if(desc == null || desc == ""){
  710. layer.close(index);
  711. layer.msg("请填写问题回复!", {icon: 5, time: 3000});
  712. return false;
  713. }
  714. }else if(type == "m"){
  715. phone = $("#m-phone").val();
  716. questionId = complaint_questionId;
  717. }else{
  718. layer.close(index);
  719. layer.msg("发送报错!", {icon: 5, time: 3000});
  720. return false;
  721. }
  722. var reg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
  723. if(!reg.test(phone)){
  724. layer.close(index);
  725. layer.msg("请填写正确的手机号码!", {icon: 5, time: 3000});
  726. return false;
  727. }
  728. $.ajax({
  729. type: "POST",
  730. data: {
  731. type : type,
  732. typeCompany : typeCompany,
  733. phone : phone,
  734. questionId : questionId,
  735. smallClassId : smallClassId,
  736. questionName : describeTitle,
  737. questionProfile : desc //回复内容
  738. },
  739. url: url_path + "/admin/customer/send_phone_sms",
  740. async: true,
  741. success: function(data){
  742. if (data.returnCode == 200) {
  743. if(type == "p"){
  744. $("#p-msg").html(data.resultMsg);
  745. }else if(type == "m"){
  746. $("#m-msg").html(data.resultMsg);
  747. }
  748. }else{
  749. if(type == "p"){
  750. $("#p-msg").html(data.resultMsg);
  751. }else if(type == "m"){
  752. $("#m-msg").html(data.resultMsg);
  753. }
  754. }
  755. layer.close(index);
  756. },
  757. error: function(XmlHttpRequest, textStatus, errorThrown){
  758. if(type == "p"){
  759. $("#p-msg").html("发送短信失败!");
  760. }else if(type == "m"){
  761. $("#m-msg").html("发送短信失败!");
  762. }
  763. layer.close(index);
  764. }
  765. });
  766. }
  767. /*保存QA问题 type=1 表示为用户点击 type=2表示自动触发*/
  768. function saveQuestion(type){
  769. var index = layer.load(1, {
  770. shade: [0.5,'#fff'] //0.1透明度的白色背景
  771. });
  772. var desc = "";
  773. var questionId = "";
  774. var describeTitle = "";
  775. var smallClassId = ""; /* 客诉问题类型小类id */
  776. questionId = $("#questionId").val();
  777. describeTitle = $("#describeTitle").val();
  778. desc = UE.getEditor('describeContentText').getContent();
  779. smallClassId = $("#smallClassId").val();
  780. if((smallClassId == null || smallClassId == "") && (questionId == null || questionId == "") ){
  781. layer.close(index);
  782. layer.msg("请选择问题分类!", {icon: 5, time: 3000});
  783. return false;
  784. }
  785. if(describeTitle==null || describeTitle == ""){
  786. layer.close(index);
  787. layer.msg("请填写问题标题!", {icon: 5, time: 3000});
  788. return false;
  789. }
  790. if(desc == null || desc == ""){
  791. layer.close(index);
  792. layer.msg("请填写问题回复!", {icon: 5, time: 3000});
  793. return false;
  794. }
  795. $.ajax({
  796. type: "POST",
  797. data: {
  798. questionId : questionId,
  799. smallClassId : smallClassId,
  800. questionName : describeTitle,
  801. questionProfile : desc //回复内容
  802. },
  803. url: url_path + "/admin/complaintQuestion/save_question",
  804. async: false,
  805. success: function(data){
  806. if (data.returnCode == 200) {
  807. $("#questionId").val(data.returnMsg.questionId);
  808. if(type == 1){
  809. layer.msg(data.resultMsg, {icon: 1, time: 3000});
  810. }
  811. }else{
  812. if(type == 1) {
  813. layer.msg(data.resultMsg, {icon: 5, time: 3000});
  814. }
  815. }
  816. layer.close(index);
  817. },
  818. error: function(XmlHttpRequest, textStatus, errorThrown){
  819. layer.close(index);
  820. }
  821. });
  822. }
  823. /***
  824. * 打开搜索订单框
  825. */
  826. function selectOrder(){
  827. layer_show("搜索订单",url_path + "/admin/customer/select_order","1000","500");
  828. }
  829. /**
  830. * 显示选择的订单
  831. */
  832. function setSelectOrder(orderId){
  833. var index = layer.load(1, {
  834. shade: [0.5,'#fff'] //0.1透明度的白色背景
  835. });
  836. if(orderId == null || orderId == "" || typeof (orderId)=="undefined"){
  837. layer.msg("未选中订单", {icon: 5, time: 3000});
  838. return false
  839. }
  840. $.ajax({
  841. type: "POST",
  842. data: {
  843. ids : orderId
  844. },
  845. url: url_path + "/admin/customer/select_salesOrder",
  846. async: true,
  847. success: function(data){
  848. var html = '';
  849. var addresHtml = '';
  850. var address = ''; //地址
  851. var orderItemList = {};
  852. var companyId = ''; //销售公司
  853. var storeId = ''; //店铺
  854. var salesAddressName,salesAddressTel; //名称赋值
  855. if (data.returnCode == 200) {
  856. for(var i=0;i<data.returnMsg.salesOrderList.length;i++){
  857. var salesOrder = data.returnMsg.salesOrderList[i];
  858. companyId = salesOrder.salesCompanyId;
  859. storeId = salesOrder.salesStoreId;
  860. var productsHtml = '';
  861. var salesOrderItem = salesOrder.salesOrderItemList;
  862. if(orderItemList.length > 0){
  863. $(salesOrder.salesOrderItemList).each(function(index,element){
  864. orderItemList.push(this);
  865. })
  866. }else{
  867. orderItemList = salesOrder.salesOrderItemList;
  868. }
  869. for(var j=0;j<salesOrderItem.length;j++){
  870. var item = salesOrderItem[j].itemProductName+ "("+ salesOrderItem[j].itemProductColor +")" + "*" + salesOrderItem[j].itemNum;
  871. if(j==0){
  872. productsHtml += item
  873. }else{
  874. productsHtml += '<br>'+ item
  875. }
  876. }
  877. var time = formatDate(new Date(salesOrder.salesPayTime),"yyyy-MM-dd");
  878. html += '<tr>' +
  879. ' <td style="text-align: center;">'+ convertUndefinedToEmpty(salesOrder.companyName) +'</td>' +
  880. ' <td style="text-align: center;">'+ convertUndefinedToEmpty(salesOrder.storeName) +'</td>' +
  881. ' <td style="text-align: center;">'+ salesOrder.salesOrderId +'</td>' +
  882. ' <td style="text-align: center;">'+ salesOrder.salesAddressName +'</td>' +
  883. ' <td style="text-align: center;">'+ salesOrder.salesAddressTel +'</td>' +
  884. ' <td style="text-align: center;">'+ salesOrder.salesAmount/100 +'</td>' +
  885. ' <td style="text-align: center;">'+ productsHtml +'</td>' +
  886. ' <td style="text-align: center;">'+ time +'</td>' +
  887. ' <td style="text-align: center;">'+ salesOrder.salesAddressInfo +'</td>' +
  888. '</tr>';
  889. address = salesOrder.salesAddressInfo;
  890. salesAddressName = salesOrder.salesAddressName;
  891. salesAddressTel = salesOrder.salesAddressTel;
  892. }
  893. }else{
  894. html = '';
  895. }
  896. $("#sendName").val(salesAddressName); //收件人名称
  897. $("#sendTel").val(salesAddressTel); //收件人电话号码
  898. var name = $("#customerName").val();
  899. var tel = $("#customerTel").val();
  900. if(name == "" || name == null){
  901. $("#customerName").val(salesAddressName); //收件人名称
  902. }
  903. if(tel == "" || tel == null){
  904. $("#customerTel").val(salesAddressTel); //收件人电话号码
  905. }
  906. $("#showSalesOrderId").html(html); //显示订单
  907. $("#addressInfo").val(address);
  908. setAdress(address); //显示地址
  909. setProduce(orderItemList); //显示产品
  910. $("#companyId").val(companyId);
  911. $("#storeId").val(storeId);
  912. $("#ids").val(orderId);
  913. /*getCompany();*/
  914. layer.close(index);
  915. },
  916. error: function(XmlHttpRequest, textStatus, errorThrown){
  917. layer.close(index);
  918. }
  919. });
  920. }
  921. /**
  922. * 设置地址
  923. */
  924. function setAdress(addres){
  925. $("#addrssMsg").html("");
  926. if(addres == null){
  927. $("#addrssMsg").html("*未能获取到地址,请手动选择地址");
  928. return;
  929. }
  930. var addresList = addres.split("-");
  931. if(addresList == null || addresList.length < 3){
  932. addresList = addres.split(" ");
  933. if(addresList == null || addresList.length < 3){
  934. addresList = addres.split("_");
  935. if(addresList == null || addresList.length < 3){
  936. addresList = addres.split("@");
  937. if(addresList == null || addresList.length < 3){
  938. $("#addrssMsg").html("*未能获取到地址,请手动选择地址:"+addres);
  939. return;
  940. }
  941. }
  942. }
  943. }
  944. ulcRelationAddress.setUlcByName(0,addresList[0],addresList[1],addresList[2]);
  945. $("#sendAddress").val(addresList[3]);
  946. // var proId = setPro(getAddress(addresList[0],0),1);
  947. // var cityId = setCity(getAddress(addresList[1],1),proId,1);
  948. // setDistrict(getAddress(addresList[2],2),cityId,1);
  949. // var sendAddress = addresList[3];
  950. // if(addresList.length > 4){
  951. // for(var k = 4;k< addresList.length;k++){
  952. // sendAddress += addresList[k];
  953. // }
  954. // }
  955. }
  956. /***
  957. * 删除 “省”,“市”,“区”关键字
  958. * type : 0:省 2:市 3:区
  959. */
  960. function getAddress(addrss,type) {
  961. var abbreviation = "";
  962. if(addrss == ""){
  963. abbreviation = "";
  964. }else{
  965. switch(type)
  966. {
  967. case 0:
  968. //var proReg = new RegExp("省","g");
  969. //abbreviation = addrss.replace(proReg,"");
  970. abbreviation = addrss.substring(0,2);
  971. break;
  972. case 1:
  973. var cityReg = new RegExp("市","g");
  974. abbreviation = addrss.replace(cityReg,"");
  975. cityReg = new RegExp("区","g");
  976. abbreviation = addrss.replace(cityReg,"");
  977. break;
  978. case 2:
  979. var districtReg = new RegExp("区","g");
  980. abbreviation = addrss.replace(districtReg,"");
  981. districtReg = new RegExp("市","g");
  982. abbreviation = abbreviation.replace(districtReg,"");
  983. break;
  984. default:
  985. break;
  986. }
  987. }
  988. return abbreviation
  989. }
  990. /**
  991. * 设置省
  992. * type 1:搜索订单赋值 2:只查询全部,默认第一个
  993. */
  994. function setPro(provinceName,type) {
  995. var proId = '';
  996. var province = listProvince();
  997. var selectPro = new Array();
  998. if(type == 1){
  999. selectPro = listProvince("",provinceName);
  1000. }
  1001. if(province!=null){
  1002. var provinceHtml = ''
  1003. provinceHtml += '<option value="">请选择省份</option>';
  1004. for(var i=0;i<province.length;i++){
  1005. provinceHtml += '<option value="'+ province[i].provinceId +'">'+ province[i].province +'</option>';
  1006. }
  1007. $("#province").html(provinceHtml);
  1008. if(selectPro != null && selectPro.length > 0 ){
  1009. proId = selectPro[0].provinceId;
  1010. }else{
  1011. proId = province[0].provinceId;
  1012. }
  1013. $("#province option[value='" + proId + "']").attr("selected","true");
  1014. }
  1015. return proId;
  1016. }
  1017. /**
  1018. * 设置市
  1019. * type 1:搜索订单赋值 2:只查询全部,默认第一个
  1020. */
  1021. function setCity(cityName,proId,type) {
  1022. var cityId = '';
  1023. var city = listCity(proId,"");
  1024. var selectCity = new Array();
  1025. if(type == 1){
  1026. selectCity = listCity(proId,cityName);
  1027. }
  1028. if(city!=null){
  1029. var cityHtml = ''
  1030. for(var i=0;i<city.length;i++){
  1031. cityHtml += '<option value="'+ city[i].cityId +'">'+ city[i].city +'</option>';
  1032. }
  1033. $("#city").html(cityHtml);
  1034. if(selectCity != null && selectCity.length > 0 ){
  1035. cityId = selectCity[0].cityId;
  1036. }else{
  1037. cityId = city[0].cityId;
  1038. }
  1039. $("#city option[value='" + cityId + "']").attr("selected","true");
  1040. }
  1041. return cityId;
  1042. }
  1043. /**
  1044. * 设置区
  1045. * type 1:搜索订单赋值 2:只查询全部,默认第一个
  1046. */
  1047. function setDistrict(districtName,cityId,type) {
  1048. var district = listDistrict(cityId,"");
  1049. var selectDistrict = new Array();
  1050. if(type == 1){
  1051. selectDistrict = listDistrict(cityId,districtName);
  1052. }
  1053. if(district!=null){
  1054. var districtHtml = ''
  1055. for(var i=0;i<district.length;i++){
  1056. districtHtml += '<option value="'+ district[i].districtId +'">'+ district[i].district +'</option>';
  1057. }
  1058. var disId = "";
  1059. $("#district").html(districtHtml);
  1060. if(selectDistrict != null && selectDistrict.length > 0 ){
  1061. disId = selectDistrict[0].districtId;
  1062. }else{
  1063. disId = district[0].districtId;
  1064. }
  1065. $("#district option[value='" + disId + "']").attr("selected","true");
  1066. }
  1067. }
  1068. /* TDS收集设置区 */
  1069. var TDSCity = '';
  1070. function linkageSetDistrict(){
  1071. var arrcity_3word = $("#arrcity_3word").val();
  1072. var cityName = '北京';
  1073. for(var i = 0;i<citys.length;i++){
  1074. for(var j=0;j<citys[i].length;j++){
  1075. if(j == 0 && arrcity_3word == citys[i][j]){
  1076. cityName = citys[i][1];
  1077. }
  1078. }
  1079. }
  1080. TDSCity = cityName;
  1081. var selectCity = listCity(null,cityName);
  1082. var cityId = selectCity[0].cityId;
  1083. var selectDistrict = listDistrict(cityId,"");
  1084. var html = '';
  1085. for(var i=0;i<selectDistrict.length;i++){
  1086. html += '<option value="'+ selectDistrict[i].districtId +'">'+ selectDistrict[i].district +'</option>';
  1087. }
  1088. $("#TDSArea").html(html);
  1089. $("#TDSArea").find("option").eq(0).prop("selected",true);
  1090. setTDSCollect();
  1091. }
  1092. /**
  1093. * 展示产品 -
  1094. * todo 20180417
  1095. * @param orderItemList
  1096. */
  1097. function setProduce(orderItemList) {
  1098. var productList = getProduct() ; //所有产品
  1099. var html = "";
  1100. var productTypeNo = 0;
  1101. var colorHtml = '';
  1102. for(var k=0;k<orderItemList.length;k++){
  1103. var item = orderItemList[k];
  1104. var fiHtml = "-";
  1105. colorHtml += '<tr >'
  1106. + '<td style="text-align: center;" >' + item.itemProductName + '</td>'
  1107. + '<td style="text-align: center;" >' + item.itemProductColor + '</td>'
  1108. + '<td style="text-align: center;"><input type="text" style="width: 100%;border: none;text-align: center;" class="input-text input-number input-itemNum" value="' + (item.itemNum-item.itemReturnNum) + '" placeholder="产品数量" onkeyup="keyFun($(this),999,0)" onpaste="keyFun($(this),999,0)"></td>'
  1109. + '<td style="text-align: center;" >'
  1110. + '<input type="hidden" class="input-item-id" value="' + item.itemId + '">'
  1111. + '<input type="hidden" class="input-produce-id" value="' + item.itemProductId + '">'
  1112. + '<input type="hidden" class="input-fc-id" value="' + item.itemColorId +'">'
  1113. + '<input type="hidden" class="input-69code" value="' + item.itemColorBar +'">'
  1114. + '<input type="" class="input-text input-number input-code" style="width: 100%;border: none;text-align: center;" value="" placeholder="机器编号" name="" id="item-' + item.itemProductId + '-' + item.itemColorId +'" number="'+ (item.itemNum-item.itemReturnNum) +'" " onkeyup="keyFunString($(this),30)" onpaste="keyFunString($(this),30)" >'
  1115. + '</td>'
  1116. + '<td style="text-align: center;" ><a href="javascript:void(0)" onclick="delColor(this)" >删除</a></td>'
  1117. + '</tr>';
  1118. }
  1119. if(allProcMethodIsBack == 1 ){ //需要寄回
  1120. $("#addBackProduct").html(colorHtml);
  1121. }
  1122. if(allProcMethodIsSend == 1){ //需要寄出
  1123. $("#addSendProduct").html(colorHtml);
  1124. }
  1125. }
  1126. /**
  1127. * 删除颜色
  1128. */
  1129. function delColor(node) {
  1130. $(node).parent().parent().remove();
  1131. }
  1132. /*获取产品*/
  1133. function getProduct(){
  1134. var productList;
  1135. $.ajax({
  1136. type: "POST",
  1137. data: {
  1138. },
  1139. url: url_path + "/admin/customer/select_produce",
  1140. async: false,
  1141. success: function(data){
  1142. if (data.returnCode == 200) {
  1143. productList = data.returnMsg.productList;
  1144. }
  1145. },
  1146. error: function(XmlHttpRequest, textStatus, errorThrown){
  1147. }
  1148. });
  1149. return productList;
  1150. }
  1151. /*设置TDS收集信息*/
  1152. function setTDSCollect(){
  1153. var TDSArea = $("#TDSArea").find("option:selected").text();
  1154. var TDSAddress = TDSCity + '-' + TDSArea;
  1155. if(TDSAddress != null && TDSAddress != ""){
  1156. $("#DTS-address").html("地址:" + TDSAddress);
  1157. }
  1158. }
  1159. /*TDS联动处理*/
  1160. function TDSLinkage(node,maxNumber,minNumber){
  1161. setTDSCollect();
  1162. var number = 0;
  1163. var c=$(node);
  1164. if(c.val() == ""){
  1165. $(node).val("");
  1166. }else{
  1167. var temp_amount=c.val().replace(/[^\d]/g,'');
  1168. number = Number(temp_amount)
  1169. if(maxNumber!= null && maxNumber!= "" && number > maxNumber){
  1170. number = maxNumber;
  1171. }
  1172. if(minNumber!= null && minNumber!= "" && number < minNumber){
  1173. number = minNumber;
  1174. }
  1175. $(node).val(number);
  1176. }
  1177. var nodeName = $(node).attr("id");
  1178. if(nodeName == "customerInTDS" ){
  1179. $("#DTS-in").html("进水:" + number + " PPM");
  1180. }else if(nodeName == "customerOutTDS" ){
  1181. $("#DTS-out").html("出水:" + number + " PPM");
  1182. }
  1183. }
  1184. /*获取销售公司*/
  1185. /*function getCompany(companyId){
  1186. var currentlyCompanyId = $("#companyId").val();
  1187. if(currentlyCompanyId != null && currentlyCompanyId != ""){
  1188. companyId = currentlyCompanyId;
  1189. }
  1190. $.ajax({
  1191. type: "get",
  1192. data: {
  1193. },
  1194. url: url_path + "/admin/customer/select_company",
  1195. success: function(data){
  1196. if (data.returnCode == 200) {
  1197. var html = '<option value="">销售公司</option>';
  1198. for(var i=0;i<data.returnMsg.companyInfoList.length;i++){
  1199. var company = data.returnMsg.companyInfoList[i];
  1200. html += '<option value="'+ company.companyId +'">'+ company.companyName +'</option>';
  1201. }
  1202. $("#selectCompany").html(html);
  1203. if(typeof(companyId) != "undefined"){
  1204. $("#selectCompany option[value='" + companyId + "']").attr("selected","true");
  1205. setStore(companyId,$("#selectStore")); //获取店铺
  1206. }
  1207. }
  1208. },
  1209. error: function(XmlHttpRequest, textStatus, errorThrown){
  1210. }
  1211. });
  1212. }*/
  1213. /*获取销售店铺*/
  1214. function setStore(companyId,storeId){
  1215. $.ajax({
  1216. type: "POST",
  1217. data: {
  1218. companyId : companyId
  1219. },
  1220. url: url_path + "/admin/customer/select_storeInfo",
  1221. success: function(data){
  1222. $("#datalist_1").empty(); //清空下拉框
  1223. if (data.returnCode == 200) {
  1224. for(var i=0;i<data.returnMsg.storeInfoList.length;i++){
  1225. var storeInfo = data.returnMsg.storeInfoList[i];
  1226. if(storeId == null){
  1227. if(i == 0){
  1228. $("#store_1").val(storeInfo.storeName);
  1229. $("#storeId").val(storeInfo.storeId);
  1230. }
  1231. }
  1232. if(storeId == storeInfo.storeId) {
  1233. if (storeInfo.storeId == storeId) {
  1234. $("#store_1").val(storeInfo.storeName);
  1235. $("#storeId").val(storeInfo.storeId);
  1236. }
  1237. }
  1238. $("#datalist_1").append("<option data-id='"+storeInfo.storeId+"' value='"+ storeInfo.storeName +"'>"+ storeInfo.storeName +"</option>");
  1239. }
  1240. }
  1241. },
  1242. error: function(XmlHttpRequest, textStatus, errorThrown){
  1243. }
  1244. });
  1245. }
  1246. /**
  1247. * 控制展示订单
  1248. * 1:需要有订单 2:不需要有订单
  1249. */
  1250. function opentionSelectOrder(){
  1251. // opentionSelectOrderDiv();
  1252. }
  1253. /**
  1254. * 展示订单
  1255. */
  1256. // function opentionSelectOrderDiv(){
  1257. // if(isNeedSelectOrder == 2 || (allProcMethodIsBack == 2 && allProcMethodIsSend == 2) ){ //不展示
  1258. // $(".orderHead").hide();
  1259. // $(".renewedProduct").hide();
  1260. // $(".updateProduct").hide();
  1261. // }else{ //展示
  1262. // $(".orderHead").show();
  1263. // if(allProcMethodIsBack == 1){
  1264. // $(".renewedProduct").show();
  1265. // $(".updateProduct").show();
  1266. // }else{
  1267. // $(".renewedProduct").hide();
  1268. // $(".updateProduct").hide();
  1269. // }
  1270. // }
  1271. // };
  1272. /*===============================客诉提交 -- start -- =============================== */
  1273. $(function(){
  1274. $("#form-customer-add").Validform({
  1275. tiptype: function (msg, o, cssctl) {
  1276. if (o.type == 3) {//失败
  1277. layer.msg(msg, {icon: 5, time: 3000});
  1278. $(window).scrollTop(o.obj.offset().top - 40);
  1279. }
  1280. },
  1281. datatype: {//自定义验证类型
  1282. },
  1283. ignoreHidden: true,
  1284. tipSweep: true, //若为true,则只在表单提交时验证
  1285. ajaxPost: true, //异步提交
  1286. beforeCheck: function (curform) { //验证通过之前执行的函数
  1287. },
  1288. beforeSubmit: function (curform) { //验证通过之后执行的函数
  1289. var flag = addCustomerReady();
  1290. if(!flag){
  1291. return false;
  1292. }
  1293. },
  1294. callback: function (data) {//异步回调函数
  1295. if (data) {
  1296. var index = layer.alert(data.resultMsg, function (index) {
  1297. if (data.resultCode == 200) {
  1298. location.href = url_path + "/admin/customer/select_customer_list";
  1299. } else if(data.resultCode == 505){
  1300. location.href = url_path + "/admin/customer/select_customer_list";
  1301. }else {
  1302. layer.close(index);
  1303. }
  1304. });
  1305. }
  1306. }
  1307. });
  1308. })
  1309. /* 添加客诉的准备 */
  1310. function addCustomerReady(){
  1311. $("#customerIsSolve").val($("#procMethodId").val());
  1312. /* 是否需要添加订单,赋值 */
  1313. $("#isNeedSelectOrder").val(isNeedSelectOrder);
  1314. if(isNeedSelectOrder == 1){
  1315. var post_ids = $("#ids").val();
  1316. if(post_ids == null || post_ids == ""){
  1317. layer.msg("请重新选择订单", {icon: 5, time: 3000});
  1318. return false;
  1319. }
  1320. }
  1321. /*验证手机号码*/
  1322. var phoneFlag = true;
  1323. $(".associated-phone").each(function () {
  1324. var phone = $(this).val();
  1325. if(phone != null && phone != "" && typeof (phone) != "undefined"){
  1326. if(phone.length != 11){
  1327. vailErrorMsg($(this),"手机号码格式不正确");
  1328. phoneFlag = false;
  1329. }
  1330. }
  1331. })
  1332. if(!phoneFlag){
  1333. return false;
  1334. }
  1335. /*验证手机号码*/
  1336. /*根据产品类型,获取来源商城*/
  1337. var typeCompany = parseInt($("input:radio[name='typeId']:checked").attr("typeCompany"));
  1338. $("#typeCompany").val(typeCompany);
  1339. /*----TDS收集模块--start-----*/
  1340. var valicity = $(".ac_result_tip").html();
  1341. if(valicity == null || valicity == "" || typeof(valicity)=="undefined"){
  1342. $("#TDSArea").html("");
  1343. }else if(valicity.indexOf("对不起,找不到") > 0 ){
  1344. $("#TDSArea").html("");
  1345. $("#customerArea").val("");
  1346. }else{
  1347. var TDSArea = $("#TDSArea").find("option:selected").text();
  1348. if(TDSArea != null && TDSArea != ""){
  1349. if(TDSArea == "请搜索城市"){
  1350. TDSArea = "";
  1351. }
  1352. var area = TDSCity + "-" + TDSArea
  1353. $("#customerArea").val(area);
  1354. }
  1355. }
  1356. /*----TDS收集模块--end-----*/
  1357. /* 地址拼接 */
  1358. var province = $("#province").find("option:selected").text();
  1359. var city = $("#city").find("option:selected").text();
  1360. var district = $("#district").find("option:selected").text();
  1361. if(district != null && district != "请选择区/县"){
  1362. var relationSendMergeAddress = province + "-" + city + "-" + district;
  1363. $("#relationSendMergeAddress").val(relationSendMergeAddress);
  1364. }
  1365. /* 地址拼接 */
  1366. /*----问题描述- start --*/
  1367. var quId = $("#questionId").val();
  1368. if(quId == null || quId == ""){
  1369. vailErrorMsg($("#questionId"),"未保存QA!");
  1370. return false;
  1371. }
  1372. var describeContentText = UE.getEditor('describeContentText').getContent();
  1373. if(describeContentText == null || describeContentText == ""){
  1374. //layer.msg("未填写问题描述", {icon: 5, time: 3000});
  1375. vailErrorMsg($("#describeTitle"),"未填写问题描述");
  1376. return false;
  1377. }
  1378. if(describeContentText.length > 3000){
  1379. vailErrorMsg($("#describeContent"),"问题回复最大支持3000个字符");
  1380. return false;
  1381. }
  1382. $("#describeContent").val(describeContentText);
  1383. /*----问题描述--end-----*/
  1384. /*----处理描述- start --*/
  1385. var describeHandleDescText = UE.getEditor('describeHandleDescText').getContent();
  1386. if(describeHandleDescText.length > 3000){
  1387. vailErrorMsg($("#describeHandleDesc"),"问题描述最大支持3000个字符");
  1388. return false;
  1389. }
  1390. $("#describeHandleDesc").val(describeHandleDescText);
  1391. /*----处理描述--end-----*/
  1392. /* --- 类型:售后 处理结果:维修/换新/补发/退货/无理由退货 -- 处理产品 start---- */
  1393. if(isNeedSelectOrder == 1 && (allProcMethodIsBack == 1 || allProcMethodIsSend == 1 ) ) { //需要订单
  1394. // 寄回
  1395. var closedProdcues = new Array(); //获取寄回,寄出直接复制寄回
  1396. $("#addBackProduct").find(".input-code").each(function () {
  1397. var machineNo = $(this).val(); //机器编号
  1398. var number = $(this).parents("tr").find(".input-itemNum").eq(0).val(); //数量
  1399. var itemId = $(this).parents("tr").find(".input-item-id").val(); //数量
  1400. if (number != null && number != "" && number != 0) {
  1401. var product = new Object();
  1402. product.colorBar = $(this).parent().find(".input-69code").val();
  1403. product.sendProdcueNumber = number;
  1404. product.closedProdcueNumber = number;
  1405. product.closedProdcueMachineNo = machineNo;
  1406. product.itemId = itemId;
  1407. closedProdcues.push(product);
  1408. }
  1409. });
  1410. //寄出
  1411. var sendProdcues = new Array(); //寄出产品表
  1412. $("#addSendProduct").find(".input-code").each(function () {
  1413. var machineNo = $(this).val(); //机器编号
  1414. var number = $(this).parents("tr").find(".input-itemNum").eq(0).val(); //数量
  1415. if (number != null && number != "" && number != 0) {
  1416. var product = new Object();
  1417. product.colorBar = $(this).parent().find(".input-69code").val();
  1418. product.sendProdcueNumber = number;
  1419. product.closedProdcueNumber = number;
  1420. product.closedProdcueMachineNo = machineNo;
  1421. sendProdcues.push(product);
  1422. }
  1423. });
  1424. $("#sendProdcues").val(JSON.stringify(sendProdcues));
  1425. $("#closedProdcues").val(JSON.stringify(closedProdcues));
  1426. }
  1427. var visitTimeSelect = $("input[name='visitTimeSelect']:checked").val();
  1428. var visit_date = $('#datemin').val();
  1429. var myDate = new Date();
  1430. var date = myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+myDate.getDate();
  1431. var hours = myDate.getHours();
  1432. //如果两个时间相等,则判断可选的回访时间
  1433. if(Date.parse(visit_date) == Date.parse(date)){
  1434. var msg = "该时间已超过当前时间,请重新选择回访时间!";
  1435. if (hours > 12 && visitTimeSelect == 1) {
  1436. vailErrorMsg($("#datemin"),msg);
  1437. return false;
  1438. } else if (hours > 14 && visitTimeSelect == 2) {
  1439. vailErrorMsg($("#datemin"),msg);
  1440. return false;
  1441. } else if (hours > 18 && visitTimeSelect == 3) {
  1442. vailErrorMsg($("#datemin"),msg);
  1443. return false;
  1444. }
  1445. }
  1446. return true;
  1447. }
  1448. /*===============================客诉提交 -- end -- =============================== */
  1449. $("#customerWechatName").blur(function(){
  1450. selectOnCustomer();
  1451. });
  1452. $("#customerName").blur(function(){
  1453. selectOnCustomer();
  1454. });
  1455. $("#customerTel").blur(function(){
  1456. selectOnCustomer();
  1457. });
  1458. /*根据客户信息查询老的客诉---start--*/
  1459. function selectOnCustomer() {
  1460. var customerWechatName = $("#customerWechatName").val();
  1461. var customerName = $("#customerName").val();
  1462. var customerTel = $("#customerTel").val();
  1463. if((customerWechatName == null || customerWechatName == "") &&
  1464. (customerName == null || customerName == "") &&
  1465. (customerTel == null || customerTel == "")){
  1466. $("#onCustomerTable").hide();
  1467. return;
  1468. }
  1469. $.ajax({
  1470. type: "POST",
  1471. data: {"customerWechatName" :customerWechatName,
  1472. "customerName":customerName,
  1473. "customerTel":customerTel},
  1474. url: url_path + "/admin/customer/selectOnCustomer",
  1475. async: false,
  1476. success: function(data){
  1477. if (data.returnCode == 200) {
  1478. var onCustomerList = data.returnMsg.onCustomerList;
  1479. if(onCustomerList != null && onCustomerList.length >0 ){
  1480. $("#onCustomerTable").show();
  1481. var onCustomerTd = "";
  1482. for(var i = 0;i < onCustomerList.length; i++){
  1483. var onCustomer = onCustomerList[i];
  1484. //客诉时间
  1485. var time = formatDate(new Date(onCustomer.customerCreateTime),"yyyy-MM-dd");
  1486. //处理方式
  1487. var customerIsSolve = "";
  1488. switch (onCustomer.customerIsSolve){
  1489. case 1:
  1490. customerIsSolve = "已解决";
  1491. break;
  1492. case 2:
  1493. customerIsSolve = "未解决";
  1494. break;
  1495. case 3:
  1496. customerIsSolve = "换新"+ backStatus(onCustomer.backStatus)+sendStatus(onCustomer.sendStatus);
  1497. break;
  1498. case 4:
  1499. customerIsSolve = "维修"+ backStatus(onCustomer.backStatus)+sendStatus(onCustomer.sendStatus);
  1500. break;
  1501. case 5:
  1502. customerIsSolve = "补发"+ sendStatus(onCustomer.sendStatus);
  1503. break;
  1504. case 6:
  1505. customerIsSolve = "退货"+ backStatus(onCustomer.backStatus);
  1506. break;
  1507. case 7:
  1508. customerIsSolve = "无理由退货"+ backStatus(onCustomer.backStatus);
  1509. break;
  1510. }
  1511. var customerWechatName = onCustomer.customerWechatName;
  1512. //微信昵称
  1513. if(typeof(onCustomer.customerWechatName)=="undefined"){
  1514. customerWechatName = "";
  1515. }
  1516. var customerName = onCustomer.customerName;
  1517. //姓名
  1518. if(typeof(onCustomer.customerName)=="undefined"){
  1519. customerName = "";
  1520. }
  1521. onCustomerTd += '' +
  1522. ' <tr>' +
  1523. ' <td style="text-align: center;">'+ time+'</td>' +
  1524. ' <td style="text-align: center;">'+onCustomer.adminName +'</td>' +
  1525. ' <td style="text-align: center;">'+customerName +'</td>' +
  1526. ' <td style="text-align: center;">'+customerWechatName +'</td>' +
  1527. ' <td style="text-align: center;">'+onCustomer.customerTel +'</td>' +
  1528. ' <td style="text-align: center;">'+customerIsSolve +'</td>' +
  1529. ' <td style="text-align: center;">'+onCustomer.describeTitle +'</td>' +
  1530. ' <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>' +
  1531. ' <td style="text-align: center;"><a onclick="admin_update_customer('+onCustomer.customerId +')">继续跟进</a>' +
  1532. '<br><a onclick="markedSecondary('+onCustomer.customerId +','+onCustomer.customerInitialId +',this)">标记为二次售后</a>' +
  1533. '<a style="display: none;" onclick="cancelMarkedSecondary('+onCustomer.customerId+','+onCustomer.customerInitialId +',this)">取消二次售后标记</a></td>' +
  1534. ' </tr>' +
  1535. '';
  1536. }
  1537. $("#onCustomer").html(onCustomerTd);
  1538. }
  1539. }
  1540. },
  1541. error: function(XmlHttpRequest, textStatus, errorThrown){
  1542. }
  1543. });
  1544. function backStatus(status) {
  1545. if(status == 1){
  1546. return "(未寄回)";
  1547. }
  1548. if(status == 2){
  1549. return "(已寄回)";
  1550. }
  1551. if(status == 3){
  1552. return "(已收货)";
  1553. }
  1554. }
  1555. function sendStatus(status) {
  1556. if(status == 1){
  1557. return "(未寄送)";
  1558. }
  1559. if(status == 2){
  1560. return "(已寄送)";
  1561. }
  1562. if(status == 3){
  1563. return "(已收货)";
  1564. }
  1565. }
  1566. }
  1567. /*根据客户信息查询老的客诉---end--*/
  1568. /**
  1569. * 添加产品
  1570. */
  1571. function addProduct(type) {
  1572. productAddType = type;
  1573. layer_show("商品列表",url_path + "/admin/salesOrder/to_add_product","1000","500");
  1574. }
  1575. /**
  1576. * 选择商品回调
  1577. * @param colorIds
  1578. */
  1579. function setSelectProduct(colorIds){
  1580. var index = layer.load(1, {
  1581. shade: [0.5,'#fff'] //0.1透明度的白色背景
  1582. });
  1583. var colorIdArray = colorIds.split("_");
  1584. for(var i=0;i<colorIdArray.length;i++){
  1585. var colorId = colorIdArray[i];
  1586. if(colorId == ""){
  1587. break;
  1588. }
  1589. var flag = true;
  1590. $("#add_product").find("tr").each(function (){
  1591. var colId = $(this).find(".color_id").eq(0).val();
  1592. if(colId == colorId){
  1593. flag = false;
  1594. }
  1595. });
  1596. if(!flag){
  1597. continue;
  1598. }
  1599. $.ajax({
  1600. type: "POST",
  1601. data: { colorId : colorId},
  1602. url: url_path +"/admin/product/get_product",
  1603. success: function(data){
  1604. var html = "";
  1605. if (data.returnCode == 200 && data.returnMsg.productColorList.length > 0 ) {
  1606. for(var i=0;i<data.returnMsg.productColorList.length;i++){
  1607. var productColor = data.returnMsg.productColorList[i];
  1608. html += '<tr >'
  1609. + '<td width="80" style="text-align: center;" >' + cufte(productColor.productName) + '</td>'
  1610. + '<td width="40" style="text-align: center;" >' + cufte(productColor.colorName) + '</td>'
  1611. + '<td width="20" style="text-align: center;"><input type="text" style="width: 100%;border: none;text-align: center;" class="input-text input-number input-itemNum" value="1" placeholder="产品数量" onkeyup="keyFun($(this),999,1)" onpaste="keyFun($(this),999,1)"></td>'
  1612. + '<td width="100" style="text-align: center;" >'
  1613. + '<input type="hidden" class="input-produce-id" value="' + productColor.colorProductId + '">'
  1614. + '<input type="hidden" class="input-fc-id" value="' + productColor.colorId +'">'
  1615. + '<input type="hidden" class="input-69code" value="' + productColor.colorBar +'">'
  1616. + '<input type="" class="input-text input-number input-code" style="width: 100%;border: none;text-align: center;" value="" placeholder="机器编号" name="" id="item-' + productColor.colorProductId + '-' + productColor.colorId +'" number="1" " onkeyup="keyFunString($(this),30)" onpaste="keyFunString($(this),30)" >'
  1617. + '</td>'
  1618. + '<td width="20" style="text-align: center;" ><a href="javascript:void(0)" onclick="delColor(this)" >删除</a></td>'
  1619. + '</tr>';
  1620. }
  1621. }else{
  1622. layer.msg("添加产品失败!", {icon: 5, time: 3000});
  1623. }
  1624. var notSelectOrderHtml = $("#addSendProduct").find(".notSelectOrder").html();
  1625. if(!isEmpty(notSelectOrderHtml)){
  1626. if(productAddType == 2){
  1627. $("#addSendProduct").append(html);
  1628. }else if(productAddType == 1){
  1629. $("#addBackProduct").append(html);
  1630. }
  1631. }else{
  1632. if(productAddType == 2){
  1633. $("#addSendProduct").html(html);
  1634. }else if(productAddType == 1){
  1635. $("#addBackProduct").html(html);
  1636. }
  1637. }
  1638. }
  1639. });
  1640. }
  1641. layer.close(index);
  1642. }