curing.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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. * ssoid
  134. * id
  135. * client_id
  136. */
  137. $('tbody[curingUser]').delegate( 'tr','click', function(){
  138. // 只获取第一个选中的值
  139. var ssoid = $(this).attr('data');
  140. var id=$(this).attr('dataId');
  141. var client_id=$(this).attr('dataCid')
  142. $(this).attr('data-toggle',' ');
  143. $.ajax({
  144. cache :false,
  145. type: 'GET',
  146. url: '/cloud/curing/ajax/getCuringBySsoid',
  147. data: {ssoid: encodeURI(ssoid),client_id:encodeURI(client_id)},
  148. dataType: 'json',
  149. context: $('body'),
  150. success: function(data){
  151. if(data.status==1||data.status==2){
  152. //设置 养护用户信息
  153. var objHtml=buildCuringInfo(data.detail.userInfo);
  154. $('div[curingInfo] curing').html(objHtml);
  155. //设置CLD客户信息
  156. if(data.detail.curingInfo.updateTotal!=0){
  157. $("#id").val(id);
  158. var clientHtml=relevanceClient(data.detail.clientInfo);
  159. $('div[curingInfo] curingClient').html(clientHtml);
  160. }
  161. //设置养护详情页里产品升级信息
  162. var upMajorBoxHtml=buildCuringCompilation(data);
  163. $('tbody[upMajorBox]').html(upMajorBoxHtml);
  164. //设置养护日志
  165. var operateLogHtml=buildCuringOperateLog(data.detail.operateLog);
  166. $('div[operateLog] curingOperate').html(operateLogHtml);
  167. setTimeout(autoHeight, 400);
  168. //autoHeight();
  169. $('#detail').modal('show');
  170. }else if(data.status==3){
  171. alert(data.msg);
  172. }
  173. },
  174. error: function(xhr, type){
  175. console.log('Ajax error!')
  176. }
  177. })
  178. });
  179. //动态绑定 移除CLD客户事件
  180. $('button[relieveClientDo]').on('click', function(e){
  181. //$('div[curinginfo]').delegate( 'a[relieveClientDo]','click', function(){
  182. // 只获取第一个选中的值
  183. var cid = $(this).attr('data');
  184. var id=$('#id').val();
  185. $('#unlinkcld').modal('hide');
  186. $.ajax({
  187. cache :false,
  188. type: 'POST',
  189. url: '/cloud/curing/ajax/relieveClientDo',
  190. data: {cid: encodeURI(cid),id:encodeURI(id)},
  191. dataType: 'json',
  192. success: function(data){
  193. if(data.status==1){
  194. //设置CLD客户信息
  195. var clientHtml=relevanceClient();
  196. $('div[curingInfo] curingClient').html(clientHtml);
  197. //设置养护日志
  198. var operateLogHtml=buildCuringOperateLog(data.operateLogList);
  199. $('div[operateLog] curingOperate').html(operateLogHtml);
  200. }else{
  201. alert(data.msg);
  202. }
  203. },
  204. error: function(xhr, type){
  205. console.log('Ajax error!')
  206. }
  207. })
  208. });
  209. //动态绑定养护用户列表 数据获得
  210. $('div[relevanceClientDo]').delegate( 'span','click', function(){
  211. // 只获取第一个选中的值
  212. var cidKey = $(this).attr('data');
  213. var id=$('#id').val();
  214. $.ajax({
  215. cache :false,
  216. type: 'POST',
  217. url: '/cloud/curing/ajax/relevanceClientDo',
  218. data: {cidKey: encodeURI(cidKey),id:encodeURI(id)},
  219. dataType: 'json',
  220. success: function(data){
  221. if(data.status==1){
  222. //设置CLD客户信息
  223. var clientHtml=relevanceClient(data.detail);
  224. $('div[curingInfo] curingClient').html(clientHtml);
  225. //设置养护日志
  226. var operateLogHtml=buildCuringOperateLog(data.operateLogList);
  227. $('div[operateLog] curingOperate').html(operateLogHtml);
  228. $('#linkcld').modal('hide');
  229. }else{
  230. alert(data.msg);
  231. }
  232. },
  233. error: function(xhr, type){
  234. console.log('Ajax error!')
  235. }
  236. })
  237. });
  238. //检索cld用户
  239. $('input[getClentList]').on('keyup', function(e){
  240. if(getClentListTimeout != null){
  241. clearTimeout(getClentListTimeout);
  242. }
  243. clientname = $(this).val();
  244. if(isExistence(clientname)){
  245. getClentListTimeout = setTimeout(getClentList, 500);
  246. }
  247. });
  248. //动态绑定分页事件
  249. $('div[pageDetail]').delegate( 'a','click', function(){
  250. // 只获取第一个选中的值
  251. var parameter = $(this).attr('parameter');
  252. var currentPage = $(this).attr('currentPage');
  253. $.ajax({
  254. cache :false,
  255. type: 'get',
  256. url: '/cloud/curing/ajax/getCuringPage/'+currentPage+parameter,
  257. dataType: 'json',
  258. success: function(data) {
  259. if (data.status == 1) {
  260. fnStructureCuringUser(data.curingList);
  261. fnPage(data.pageData);
  262. } else {
  263. alert(data.msg);
  264. }
  265. }
  266. })
  267. });
  268. //升级用户产品信息
  269. $('button[upCuringDo]').on('click', function(e){
  270. // 只获取第一个选中的值
  271. var compilationId = $('#_id').val();
  272. var name = $('#name').val();
  273. var curingSsoid = $('#curingSsoid').val();
  274. var mobile = $('#curingMobile').val();
  275. var client_id = $('#client_id').val();
  276. if (curingSsoid != '' && compilationId != '') {
  277. $.ajax({
  278. cache :false,
  279. type: 'post',
  280. url: '/cloud/curing/ajax/upCuringDo',
  281. data: {ssoid: curingSsoid, compilationId: compilationId, mobile: mobile, client_id: client_id, name: name},
  282. dataType: 'json',
  283. success: function(data) {
  284. if (data.status == 1) {
  285. fnGetCuringDetail(curingSsoid,client_id);
  286. } else {
  287. alert(data.msg);
  288. }
  289. }
  290. })
  291. } else {
  292. alert('请选择需要升级的版本');
  293. }
  294. });
  295. //列表 缓存激活号码检索
  296. $('input[mobile2Info]').on('keyup', function(e){
  297. if(mobile2InfoTimeout != null){
  298. clearTimeout(mobile2InfoTimeout);
  299. }
  300. mobile = $(this).val();
  301. if((/^1[34578]\d{9}$/.test(mobile))) {
  302. mobile2InfoTimeout = setTimeout(fnMobile2Info, 300);
  303. }
  304. });
  305. //列表 号码检索事件绑定
  306. $('div[mobile2Info]').on('click', function(e){
  307. mobile=$('input[mobile2Info]').val();
  308. if(mobile==''){
  309. location.reload()
  310. }
  311. fnMobile2Info();
  312. });
  313. $('input[fnSearchCuring]').on('keyup', function(e){
  314. if(searchCuringTimeout != null){
  315. clearTimeout(searchCuringTimeout);
  316. }
  317. mobile=$(this).val();
  318. if((/^1[34578]\d{9}$/.test(mobile))) {
  319. searchCuringTimeout = setTimeout(fnSearchCuring, 500);
  320. }
  321. });
  322. $('a[upNewClient]').on('click', function(e){
  323. $('input[fnsearchcuring]').val('');
  324. $('div[upCuringBox]').hide();
  325. $('p[upCuringBox]').hide();
  326. });
  327. $('a[upClient]').on('click', function(e){
  328. var mobile=$('b[curingMobile]').html();
  329. if(mobile==''){
  330. alert('参数错误');
  331. }
  332. $.ajax({
  333. cache :false,
  334. type: 'GET',
  335. url: '/cloud/curing/ajax/checkMobile/'+mobile,
  336. //data: { mobile: mobile },
  337. dataType: 'json',
  338. success: function(data){
  339. if(data.status==1||data.status==2){
  340. $('input[fnsearchcuring]').val(mobile);
  341. fnGetCuringDetail(data.data.id,data.data.client_id);
  342. }else if(data.status==3){
  343. $('div[upCuringBox]').hide();
  344. $('p[upCuringBox]').show();
  345. }
  346. },
  347. error: function(xhr, type){
  348. console.log('Ajax error!')
  349. }
  350. })
  351. });
  352. //编办下拉选择
  353. $('select[curingByCompilation]').on('change', function(e){
  354. var id=$(this).val();
  355. $.ajax({
  356. cache :false,
  357. type: 'GET',
  358. url: '/cloud/curing/ajax/getCuringByCompilationId/'+id,
  359. //data: { mobile: mobile },
  360. dataType: 'json',
  361. context: $('body'),
  362. success: function(data){
  363. console.log(data);
  364. if(data.status==1||data.status==2){
  365. fnStructureCuringUser(data.curingList);
  366. fnPage(data.pageData);
  367. }else if(data.status==3){
  368. //$('div[upCuringBox]').hide();
  369. //$('p[upCuringBox]').show();
  370. }
  371. },
  372. error: function(xhr, type){
  373. console.log('Ajax error!')
  374. }
  375. })
  376. });
  377. })