curing.js 13 KB

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