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