curing.js 12 KB

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