curing.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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. * parameter 传递参数
  106. * currentPage
  107. */
  108. $('div[pageDetail]').delegate( 'a','click', function(){
  109. // 只获取第一个选中的值
  110. var parameter = $(this).attr('parameter');
  111. var currentPage = $(this).attr('currentPage');
  112. $.ajax({
  113. cache :false,
  114. type: 'get',
  115. url: '/cloud/curing/ajax/getCuringPage/'+currentPage+parameter,
  116. dataType: 'json',
  117. success: function(data) {
  118. if (data.status == 1) {
  119. fnStructureCuringUser(data.curingList);
  120. fnPage(data.pageData);
  121. } else {
  122. alert(data.msg);
  123. }
  124. }
  125. })
  126. });
  127. /**
  128. * 编办下拉选择
  129. */
  130. $('select[curingByCompilation]').on('change', function(e){
  131. var compilation=$(this).val();
  132. var latestCompilation=$('select[curingByLatestCompilation]').val();
  133. refreshCuringPage(compilation,latestCompilation);
  134. });
  135. $('select[curingByLatestCompilation]').on('change', function(e){
  136. var latestCompilation=$(this).val();
  137. var compilation=$('select[curingByCompilation]').val();
  138. refreshCuringPage(compilation,latestCompilation);
  139. });
  140. /**
  141. * 用户列表排序相关
  142. */
  143. $('input[type=radio][name=sortField]').on('change', function(e){
  144. var sortField=$(this).attr('data');
  145. var latestCompilation=$('select[curingByLatestCompilation]').val();
  146. var compilation=$('select[curingByCompilation]').val();
  147. refreshCuringPage(compilation,latestCompilation,sortField);
  148. });
  149. $('input[type=radio][name=sort]').on('change', function(e){
  150. var sort=$(this).attr('data');
  151. var latestCompilation=$('select[curingByLatestCompilation]').val();
  152. var compilation=$('select[curingByCompilation]').val();
  153. refreshCuringPage(compilation,latestCompilation,'',sort);
  154. });
  155. /**
  156. * 通行证账号检索养护用户--缓冲300
  157. */
  158. $('input[mobile2Info]').on('keyup', function(e){
  159. if(mobile2InfoTimeout != null){
  160. clearTimeout(mobile2InfoTimeout);
  161. }
  162. mobile = $(this).val();
  163. if((/^1[34578]\d{9}$/.test(mobile))) {
  164. mobile2InfoTimeout = setTimeout(fnMobile2Info, 300);
  165. }
  166. });
  167. //--------------用户详情界面相关---------
  168. /**
  169. * 动态绑定养护用户列表 打开用户详情页面事件
  170. * ssoid
  171. * id
  172. * client_id
  173. */
  174. $('tbody[curingUser]').delegate( 'tr','click', function(){
  175. // 只获取第一个选中的值
  176. var ssoid = $(this).attr('data');
  177. var id=$(this).attr('dataId');
  178. var client_id=$(this).attr('dataCid')
  179. $(this).attr('data-toggle',' ');
  180. refreshCuringPageDetail(ssoid,client_id);
  181. });
  182. /**
  183. * 动态绑定 移除CLD客户事件
  184. */
  185. $('button[relieveClientDo]').on('click', function(e){
  186. //$('div[curinginfo]').delegate( 'a[relieveClientDo]','click', function(){
  187. // 只获取第一个选中的值
  188. var cid = $(this).attr('data');
  189. var id=$('#id').val();
  190. $('#unlinkcld').modal('hide');
  191. $.ajax({
  192. cache :false,
  193. type: 'POST',
  194. url: '/cloud/curing/ajax/relieveClientDo',
  195. data: {cid: encodeURI(cid),id:encodeURI(id)},
  196. dataType: 'json',
  197. success: function(data){
  198. if(data.status==1){
  199. //设置CLD客户信息
  200. var clientHtml=relevanceClient();
  201. $('div[curingInfo] curingClient').html(clientHtml);
  202. //设置养护日志
  203. var operateLogHtml=buildCuringOperateLog(data.operateLogList);
  204. $('div[operateLog] curingOperate').html(operateLogHtml);
  205. }else{
  206. alert(data.msg);
  207. }
  208. },
  209. error: function(xhr, type){
  210. console.log('Ajax error!')
  211. }
  212. })
  213. });
  214. //动态绑定养护用户列表 数据获得
  215. $('div[relevanceClientDo]').delegate( 'span','click', function(){
  216. // 只获取第一个选中的值
  217. var cidKey = $(this).attr('data');
  218. var id=$('#id').val();
  219. $.ajax({
  220. cache :false,
  221. type: 'POST',
  222. url: '/cloud/curing/ajax/relevanceClientDo',
  223. data: {cidKey: encodeURI(cidKey),id:encodeURI(id)},
  224. dataType: 'json',
  225. success: function(data){
  226. if(data.status==1){
  227. //设置CLD客户信息
  228. var clientHtml=relevanceClient(data.detail);
  229. $('div[curingInfo] curingClient').html(clientHtml);
  230. //设置养护日志
  231. var operateLogHtml=buildCuringOperateLog(data.operateLogList);
  232. $('div[operateLog] curingOperate').html(operateLogHtml);
  233. $('#linkcld').modal('hide');
  234. }else{
  235. alert(data.msg);
  236. }
  237. },
  238. error: function(xhr, type){
  239. console.log('Ajax error!')
  240. }
  241. })
  242. });
  243. //检索cld用户
  244. $('input[getClentList]').on('keyup', function(e){
  245. if(getClentListTimeout != null){
  246. clearTimeout(getClentListTimeout);
  247. }
  248. clientname = $(this).val();
  249. if(isExistence(clientname)){
  250. getClentListTimeout = setTimeout(getClentList, 500);
  251. }
  252. });
  253. //升级用户产品信息
  254. $('button[upCuringDo]').on('click', function(e){
  255. // 只获取第一个选中的值
  256. var compilationId = $('#_id').val();
  257. var name = $('#name').val();
  258. var curingSsoid = $('#curingSsoid').val();
  259. var mobile = $('#curingMobile').val();
  260. var client_id = $('#client_id').val();
  261. if (curingSsoid != '' && compilationId != '') {
  262. $.ajax({
  263. cache :false,
  264. type: 'post',
  265. url: '/cloud/curing/ajax/upCuringDo',
  266. data: {ssoid: curingSsoid, compilationId: compilationId, mobile: mobile, client_id: client_id, name: name},
  267. dataType: 'json',
  268. success: function(data) {
  269. if (data.status == 1) {
  270. fnGetCuringDetail(curingSsoid,client_id);
  271. } else {
  272. alert(data.msg);
  273. }
  274. }
  275. })
  276. } else {
  277. alert('请选择需要升级的版本');
  278. }
  279. });
  280. //列表 号码检索事件绑定
  281. $('div[mobile2Info]').on('click', function(e){
  282. mobile=$('input[mobile2Info]').val();
  283. if(mobile==''){
  284. location.reload()
  285. }
  286. fnMobile2Info();
  287. });
  288. $('input[fnSearchCuring]').on('keyup', function(e){
  289. if(searchCuringTimeout != null){
  290. clearTimeout(searchCuringTimeout);
  291. }
  292. mobile=$(this).val();
  293. if((/^1[34578]\d{9}$/.test(mobile))) {
  294. searchCuringTimeout = setTimeout(fnSearchCuring, 500);
  295. }
  296. });
  297. $('a[upNewClient]').on('click', function(e){
  298. $('input[fnsearchcuring]').val('');
  299. $('div[upCuringBox]').hide();
  300. $('p[upCuringBox]').hide();
  301. });
  302. $('a[upClient]').on('click', function(e){
  303. var mobile=$('b[curingMobile]').html();
  304. if(mobile==''){
  305. alert('参数错误');
  306. }
  307. $.ajax({
  308. cache :false,
  309. type: 'GET',
  310. url: '/cloud/curing/ajax/checkMobile/'+mobile,
  311. //data: { mobile: mobile },
  312. dataType: 'json',
  313. success: function(data){
  314. if(data.status==1||data.status==2){
  315. $('input[fnsearchcuring]').val(mobile);
  316. fnGetCuringDetail(data.data.id,data.data.client_id);
  317. }else if(data.status==3){
  318. $('div[upCuringBox]').hide();
  319. $('p[upCuringBox]').show();
  320. }
  321. },
  322. error: function(xhr, type){
  323. console.log('Ajax error!')
  324. }
  325. })
  326. });
  327. })