curing.js 11 KB

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