curing.js 13 KB

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