curing.js 12 KB

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