curing.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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. $('#linkcld').modal('hide');
  199. }else{
  200. alert(data.msg);
  201. }
  202. },
  203. error: function(xhr, type){
  204. console.log('Ajax error!')
  205. }
  206. })
  207. });
  208. /**
  209. * 用户取消关联CLD客户--用户详情页
  210. */
  211. $('button[relieveClientDo]').on('click', function(e){
  212. // 只获取第一个选中的值
  213. var cid = $(this).attr('data');
  214. var ssoId = $('#curingSsoid').val();
  215. //var id=$('#id').val();
  216. $('#unlinkcld').modal('hide');
  217. $.ajax({
  218. cache :false,
  219. type: 'POST',
  220. url: '/cloud/curing/ajax/relieveClientDo',
  221. data: {cid: encodeURI(cid),ssoId:encodeURI(ssoId)},
  222. dataType: 'json',
  223. success: function(data){
  224. if(data.status==1){
  225. refreshCuringPageDetail(ssoId,cid);
  226. /*
  227. //设置CLD客户信息
  228. var clientHtml=relevanceClient();
  229. $('div[curingInfo] curingClient').html(clientHtml);
  230. //设置养护日志
  231. var operateLogHtml=buildCuringOperateLog(data.operateLogList);
  232. $('div[operateLog] curingOperate').html(operateLogHtml);*/
  233. }else{
  234. alert(data.msg);
  235. }
  236. },
  237. error: function(xhr, type){
  238. console.log('Ajax error!')
  239. }
  240. })
  241. });
  242. //检索cld用户
  243. $('input[getClentList]').on('keyup', function(e){
  244. if(getClentListTimeout != null){
  245. clearTimeout(getClentListTimeout);
  246. }
  247. clientname = $(this).val();
  248. if(isExistence(clientname)){
  249. getClentListTimeout = setTimeout(getClentList, 500);
  250. }
  251. });
  252. //列表 号码检索事件绑定
  253. $('div[mobile2Info]').on('click', function(e){
  254. mobile=$('input[mobile2Info]').val();
  255. if(mobile==''){
  256. location.reload()
  257. }
  258. fnMobile2Info();
  259. });
  260. $('input[fnSearchCuring]').on('keyup', function(e){
  261. if(searchCuringTimeout != null){
  262. clearTimeout(searchCuringTimeout);
  263. }
  264. mobile=$(this).val();
  265. if((/^1[34578]\d{9}$/.test(mobile))) {
  266. searchCuringTimeout = setTimeout(fnSearchCuring, 500);
  267. }
  268. });
  269. $('a[upNewClient]').on('click', function(e){
  270. $('input[fnsearchcuring]').val('');
  271. $('div[upCuringBox]').hide();
  272. $('p[upCuringBox]').hide();
  273. });
  274. $('a[upClient]').on('click', function(e){
  275. var mobile=$('b[curingMobile]').html();
  276. if(mobile==''){
  277. alert('参数错误');
  278. }
  279. $.ajax({
  280. cache :false,
  281. type: 'GET',
  282. url: '/cloud/curing/ajax/checkMobile/'+mobile,
  283. //data: { mobile: mobile },
  284. dataType: 'json',
  285. success: function(data){
  286. if(data.status==1||data.status==2){
  287. $('input[fnsearchcuring]').val(mobile);
  288. fnGetCuringDetail(data.data.id,data.data.client_id);
  289. }else if(data.status==3){
  290. $('div[upCuringBox]').hide();
  291. $('p[upCuringBox]').show();
  292. }
  293. },
  294. error: function(xhr, type){
  295. console.log('Ajax error!')
  296. }
  297. })
  298. });
  299. })
  300. //构建升级用户信息--预计废弃
  301. function fnGetCuringDetail(ssoid,client_id){
  302. $('tbody[upMajorBox]').html('');
  303. $('#curingSsoid').val('');
  304. $('#curingMobile').val('');
  305. $('#client_id').val('');
  306. $('#name').val('');
  307. $('#_id').val('');
  308. $.ajax({
  309. cache :false,
  310. type: 'GET',
  311. url: '/cloud/curing/ajax/getCuringBySsoid',
  312. data: {ssoid: ssoid, client_id: client_id},
  313. dataType: 'json',
  314. context: $('body'),
  315. success: function(data){
  316. if(data.status==1||data.status==2){
  317. $('div[upCuringBox]').show();
  318. $('p[upCuringBox]').hide();
  319. var objHtml=buildCuringInfo(data.detail.userInfo);
  320. $('div[curingInfo] curing').html(objHtml);
  321. var upMajorBoxHtml=buildCuringCompilation(data);
  322. $('tbody[upMajorBox]').html(upMajorBoxHtml);
  323. var operateLogHtml=buildCuringOperateLog(data.detail.operateLog);
  324. $('div[operateLog] curingOperate').html(operateLogHtml);
  325. }else if(data.status==3){
  326. $('div[upCuringBox]').hide();
  327. $('p[upCuringBox]').show();
  328. }
  329. },
  330. error: function(xhr, type){
  331. console.log('Ajax error!')
  332. }
  333. })
  334. }