curing.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. /**
  2. * Created by MyPC on 2019/11/11.
  3. */
  4. var mobile2InfoTimeout = null;
  5. var searchCuringTimeout = null;
  6. var mobile='';
  7. var getClentListTimeout = null;
  8. var clientname='';
  9. //列表 手机号码检索功能
  10. function fnMobile2Info(){
  11. mobile2InfoTimeout = null;
  12. if((/^1[34578]\d{9}$/.test(mobile))) {
  13. $.ajax({
  14. cache :false,
  15. type: 'GET',
  16. url: '/cloud/curing/ajax/curingInfo/' + mobile,
  17. //data: { mobile: mobile },
  18. dataType: 'json',
  19. context: $('body'),
  20. success: function (data) {
  21. if (data.status == 1) {
  22. fnStructureCuringUser([data.detail]);
  23. $('div[page]').hide();
  24. } else if (data.status == 2) {
  25. $('div[curingListBox]').hide();
  26. $('p[upClientBox]').show();
  27. $('b[curingMobile]').html(mobile);
  28. } else if (data.status == 3) {
  29. alert(data.msg);
  30. }
  31. },
  32. error: function (xhr, type) {
  33. console.log('Ajax error!')
  34. }
  35. })
  36. }
  37. }
  38. function fnSearchCuring(){
  39. searchCuringTimeout = null;
  40. if((/^1[34578]\d{9}$/.test(mobile))){
  41. $.ajax({
  42. cache :false,
  43. type: 'GET',
  44. url: '/cloud/curing/ajax/checkMobile/'+mobile,
  45. //data: { mobile: mobile },
  46. dataType: 'json',
  47. context: $('body'),
  48. success: function(data){
  49. if(data.status==1||data.status==2){
  50. fnGetCuringDetail(data.data.id,data.data.client_id);
  51. }else if(data.status==3){
  52. $('div[upCuringBox]').hide();
  53. $('p[upCuringBox]').show();
  54. }
  55. },
  56. error: function(xhr, type){
  57. console.log('Ajax error!')
  58. }
  59. })
  60. }
  61. }
  62. //构建升级用户信息
  63. function fnGetCuringDetail(ssoid,client_id){
  64. $('tbody[upMajorBox]').html('');
  65. $('#curingSsoid').val('');
  66. $('#curingMobile').val('');
  67. $('#client_id').val('');
  68. $('#name').val('');
  69. $('#_id').val('');
  70. $.ajax({
  71. cache :false,
  72. type: 'GET',
  73. url: '/cloud/curing/ajax/getCuringBySsoid',
  74. data: {ssoid: ssoid, client_id: client_id},
  75. dataType: 'json',
  76. context: $('body'),
  77. success: function(data){
  78. if(data.status==1||data.status==2){
  79. $('div[upCuringBox]').show();
  80. $('p[upCuringBox]').hide();
  81. var objHtml=buildCuringInfo(data.detail.userInfo);
  82. $('div[curingInfo] curing').html(objHtml);
  83. var upMajorBoxHtml=buildCuringCompilation(data);
  84. $('tbody[upMajorBox]').html(upMajorBoxHtml);
  85. var operateLogHtml=buildCuringOperateLog(data.detail.operateLog);
  86. $('div[operateLog] curingOperate').html(operateLogHtml);
  87. }else if(data.status==3){
  88. $('div[upCuringBox]').hide();
  89. $('p[upCuringBox]').show();
  90. }
  91. },
  92. error: function(xhr, type){
  93. console.log('Ajax error!')
  94. }
  95. })
  96. }
  97. //设置可升级用户信息
  98. function upCuring(name,_id,username){
  99. $('#name').val(name);
  100. $('#_id').val(_id);
  101. var curingMobile=$('#curingMobile').val();
  102. var html='为用户 <b>'+curingMobile+','+username+'</b> 升级 <b>'+name+'</b>';
  103. $('div[upCuring] span').html(html);
  104. }
  105. //获得客户list数据
  106. function getClentList(){
  107. if(!isExistence(clientname)){
  108. console.log('参数错误');
  109. return ;
  110. }
  111. $.ajax({
  112. cache :false,
  113. type: 'GET',
  114. url: '/contacts/client/ajax/getClentList',
  115. data: { clientname: encodeURI(clientname) },
  116. dataType: 'json',
  117. success: function(data){
  118. if(data.status==1){
  119. var html=buildClientBySearch(data.list);
  120. $('div[searchClient] curingClient').html(html);
  121. }else {
  122. console.log(data.msg);
  123. }
  124. },
  125. error: function(xhr, type){
  126. console.log('Ajax error!')
  127. }
  128. })
  129. }
  130. $(function() {
  131. //------用户列表界面相关----------
  132. /**
  133. * 动态绑定养护用户列表 打开用户详情页面事件
  134. * ssoid
  135. * id
  136. * client_id
  137. */
  138. $('tbody[curingUser]').delegate( 'tr','click', function(){
  139. // 只获取第一个选中的值
  140. var ssoid = $(this).attr('data');
  141. var id=$(this).attr('dataId');
  142. var client_id=$(this).attr('dataCid')
  143. $(this).attr('data-toggle',' ');
  144. $.ajax({
  145. cache :false,
  146. type: 'GET',
  147. url: '/cloud/curing/ajax/getCuringBySsoid',
  148. data: {ssoid: encodeURI(ssoid),client_id:encodeURI(client_id)},
  149. dataType: 'json',
  150. context: $('body'),
  151. success: function(data){
  152. if(data.status==1||data.status==2){
  153. //设置 养护用户信息
  154. var objHtml=buildCuringInfo(data.detail.userInfo);
  155. $('div[curingInfo] curing').html(objHtml);
  156. //设置CLD客户信息
  157. if(data.detail.curingInfo.updateTotal!=0){
  158. $("#id").val(id);
  159. var clientHtml=relevanceClient(data.detail.clientInfo);
  160. $('div[curingInfo] curingClient').html(clientHtml);
  161. }
  162. //设置养护详情页里产品升级信息
  163. var upMajorBoxHtml=buildCuringCompilation(data);
  164. $('tbody[upMajorBox]').html(upMajorBoxHtml);
  165. //设置养护日志
  166. var operateLogHtml=buildCuringOperateLog(data.detail.operateLog);
  167. $('div[operateLog] curingOperate').html(operateLogHtml);
  168. setTimeout(autoHeight, 400);
  169. //autoHeight();
  170. $('#detail').modal('show');
  171. }else if(data.status==3){
  172. alert(data.msg);
  173. }
  174. },
  175. error: function(xhr, type){
  176. console.log('Ajax error!')
  177. }
  178. })
  179. });
  180. /**
  181. * 绑定分页-点击事件-刷新用户列表和分页列表
  182. * parameter 传递参数
  183. * currentPage
  184. */
  185. $('div[pageDetail]').delegate( 'a','click', function(){
  186. // 只获取第一个选中的值
  187. var parameter = $(this).attr('parameter');
  188. var currentPage = $(this).attr('currentPage');
  189. $.ajax({
  190. cache :false,
  191. type: 'get',
  192. url: '/cloud/curing/ajax/getCuringPage/'+currentPage+parameter,
  193. dataType: 'json',
  194. success: function(data) {
  195. if (data.status == 1) {
  196. fnStructureCuringUser(data.curingList);
  197. fnPage(data.pageData);
  198. } else {
  199. alert(data.msg);
  200. }
  201. }
  202. })
  203. });
  204. /**
  205. * 编办下拉选择
  206. */
  207. $('select[curingByCompilation]').on('change', function(e){
  208. var compilation=$(this).val();
  209. var latestCompilation=$('select[curingByLatestCompilation]').val();
  210. curingByCompilation(compilation,latestCompilation);
  211. });
  212. $('select[curingByLatestCompilation]').on('change', function(e){
  213. var latestCompilation=$(this).val();
  214. var compilation=$('select[curingByCompilation]').val();
  215. curingByCompilation(compilation,latestCompilation);
  216. });
  217. /**
  218. * 用户列表排序相关
  219. */
  220. $('input[type=radio][name=sortField]').on('change', function(e){
  221. var sortField=$(this).attr('data');
  222. var latestCompilation=$('select[curingByLatestCompilation]').val();
  223. var compilation=$('select[curingByCompilation]').val();
  224. console.log(sortField);
  225. $.ajax({
  226. cache :false,
  227. type: 'get',
  228. url: '/cloud/curing/ajax/refreshCuringPage?sortField='+sortField+'&compilation='+compilation+'&latestCompilation='+latestCompilation,
  229. dataType: 'json',
  230. success: function(data) {
  231. if (data.status == 1) {
  232. fnStructureCuringUser(data.curingList);
  233. fnPage(data.pageData);
  234. } else {
  235. alert(data.msg);
  236. }
  237. }
  238. })
  239. });
  240. //动态绑定 移除CLD客户事件
  241. $('button[relieveClientDo]').on('click', function(e){
  242. //$('div[curinginfo]').delegate( 'a[relieveClientDo]','click', function(){
  243. // 只获取第一个选中的值
  244. var cid = $(this).attr('data');
  245. var id=$('#id').val();
  246. $('#unlinkcld').modal('hide');
  247. $.ajax({
  248. cache :false,
  249. type: 'POST',
  250. url: '/cloud/curing/ajax/relieveClientDo',
  251. data: {cid: encodeURI(cid),id:encodeURI(id)},
  252. dataType: 'json',
  253. success: function(data){
  254. if(data.status==1){
  255. //设置CLD客户信息
  256. var clientHtml=relevanceClient();
  257. $('div[curingInfo] curingClient').html(clientHtml);
  258. //设置养护日志
  259. var operateLogHtml=buildCuringOperateLog(data.operateLogList);
  260. $('div[operateLog] curingOperate').html(operateLogHtml);
  261. }else{
  262. alert(data.msg);
  263. }
  264. },
  265. error: function(xhr, type){
  266. console.log('Ajax error!')
  267. }
  268. })
  269. });
  270. //动态绑定养护用户列表 数据获得
  271. $('div[relevanceClientDo]').delegate( 'span','click', function(){
  272. // 只获取第一个选中的值
  273. var cidKey = $(this).attr('data');
  274. var id=$('#id').val();
  275. $.ajax({
  276. cache :false,
  277. type: 'POST',
  278. url: '/cloud/curing/ajax/relevanceClientDo',
  279. data: {cidKey: encodeURI(cidKey),id:encodeURI(id)},
  280. dataType: 'json',
  281. success: function(data){
  282. if(data.status==1){
  283. //设置CLD客户信息
  284. var clientHtml=relevanceClient(data.detail);
  285. $('div[curingInfo] curingClient').html(clientHtml);
  286. //设置养护日志
  287. var operateLogHtml=buildCuringOperateLog(data.operateLogList);
  288. $('div[operateLog] curingOperate').html(operateLogHtml);
  289. $('#linkcld').modal('hide');
  290. }else{
  291. alert(data.msg);
  292. }
  293. },
  294. error: function(xhr, type){
  295. console.log('Ajax error!')
  296. }
  297. })
  298. });
  299. //检索cld用户
  300. $('input[getClentList]').on('keyup', function(e){
  301. if(getClentListTimeout != null){
  302. clearTimeout(getClentListTimeout);
  303. }
  304. clientname = $(this).val();
  305. if(isExistence(clientname)){
  306. getClentListTimeout = setTimeout(getClentList, 500);
  307. }
  308. });
  309. //升级用户产品信息
  310. $('button[upCuringDo]').on('click', function(e){
  311. // 只获取第一个选中的值
  312. var compilationId = $('#_id').val();
  313. var name = $('#name').val();
  314. var curingSsoid = $('#curingSsoid').val();
  315. var mobile = $('#curingMobile').val();
  316. var client_id = $('#client_id').val();
  317. if (curingSsoid != '' && compilationId != '') {
  318. $.ajax({
  319. cache :false,
  320. type: 'post',
  321. url: '/cloud/curing/ajax/upCuringDo',
  322. data: {ssoid: curingSsoid, compilationId: compilationId, mobile: mobile, client_id: client_id, name: name},
  323. dataType: 'json',
  324. success: function(data) {
  325. if (data.status == 1) {
  326. fnGetCuringDetail(curingSsoid,client_id);
  327. } else {
  328. alert(data.msg);
  329. }
  330. }
  331. })
  332. } else {
  333. alert('请选择需要升级的版本');
  334. }
  335. });
  336. //列表 缓存激活号码检索
  337. $('input[mobile2Info]').on('keyup', function(e){
  338. if(mobile2InfoTimeout != null){
  339. clearTimeout(mobile2InfoTimeout);
  340. }
  341. mobile = $(this).val();
  342. if((/^1[34578]\d{9}$/.test(mobile))) {
  343. mobile2InfoTimeout = setTimeout(fnMobile2Info, 300);
  344. }
  345. });
  346. //列表 号码检索事件绑定
  347. $('div[mobile2Info]').on('click', function(e){
  348. mobile=$('input[mobile2Info]').val();
  349. if(mobile==''){
  350. location.reload()
  351. }
  352. fnMobile2Info();
  353. });
  354. $('input[fnSearchCuring]').on('keyup', function(e){
  355. if(searchCuringTimeout != null){
  356. clearTimeout(searchCuringTimeout);
  357. }
  358. mobile=$(this).val();
  359. if((/^1[34578]\d{9}$/.test(mobile))) {
  360. searchCuringTimeout = setTimeout(fnSearchCuring, 500);
  361. }
  362. });
  363. $('a[upNewClient]').on('click', function(e){
  364. $('input[fnsearchcuring]').val('');
  365. $('div[upCuringBox]').hide();
  366. $('p[upCuringBox]').hide();
  367. });
  368. $('a[upClient]').on('click', function(e){
  369. var mobile=$('b[curingMobile]').html();
  370. if(mobile==''){
  371. alert('参数错误');
  372. }
  373. $.ajax({
  374. cache :false,
  375. type: 'GET',
  376. url: '/cloud/curing/ajax/checkMobile/'+mobile,
  377. //data: { mobile: mobile },
  378. dataType: 'json',
  379. success: function(data){
  380. if(data.status==1||data.status==2){
  381. $('input[fnsearchcuring]').val(mobile);
  382. fnGetCuringDetail(data.data.id,data.data.client_id);
  383. }else if(data.status==3){
  384. $('div[upCuringBox]').hide();
  385. $('p[upCuringBox]').show();
  386. }
  387. },
  388. error: function(xhr, type){
  389. console.log('Ajax error!')
  390. }
  391. })
  392. });
  393. })