caipin 5 anos atrás
pai
commit
7c2c2d38df

+ 3 - 0
app/controller/cloudEditionAjaxController.js

@@ -89,6 +89,9 @@ checkMobile: async function(req, res){
     }
 },
 
+/**
+ * 异步获得养护用户信息详情
+ */
 getCuringBySsoid: async function(req, res){
     var params = url.parse(req.url, true).query;
 

+ 113 - 13
app/service/cloudEditionService.js

@@ -15,13 +15,20 @@ var buildUrl = 'https://yun.smartcost.com.cn/cld';
  * modelsTable 数据表对象
  * parameter 设置传的参数
  */
-var getPage= async function(modelsTable,where,currentPage,pageSize,parameter){
-    var totalCount=await modelsTable.count();
+var getPage= async function(modelsTable,where,currentPage,pageSize,parameter,totalCount){
+	
+	if(!hash.isExistence(totalCount)){
+		if(hash.isExistence(where)){
+	        totalCount=await modelsTable.count({where});
+	    }else{
+	    	totalCount=await modelsTable.count();
+	    }
+	}
     currentPage=parseInt(currentPage);
-    if(hash.isExistence(where)){
-        totalCount=await modelsTable.count({where});
+    var total =0;
+    if(totalCount!=0){
+    	total = Math.trunc ( totalCount / pageSize );
     }
-    var total = Math.trunc ( totalCount / pageSize );
     var totalPage = (totalCount % pageSize) == 0 ? total : total + 1;
 
     var page={
@@ -42,18 +49,104 @@ var cloudService={
 	 * compilation_id 编办ID
 	 */
     getCuringList: async function(compilation_id,page=1){
-        
+       
     	//获得远程养护用户
-        //数据组合
+    	//分页数据
+    	var limit=12;
+        var offset=0;
+        if(page!=1){
+            var pg=page-1;
+            offset=pg*limit;
+        }
+    	var url= curingUrl+'/getCompilationList';
+        var curingCloudList={}; //await curlRequest(url);
+        
+        //console.log(curingCloudList);
+        
+    	//组合数据以获得本地扩展数据
+        var mobile=[];
+        curingCloudList.forEach(function(v,i){
+        	mobile.push(v.mobile);
+        });
+        //获得指定数据
+        var option={
+        		where: {
+        			mobile: {
+                        [Op.or]: [mobile]
+        					}
+        				},
+                raw:true,
+                };
+        if(hash.isExistence(compilation_id)){
+            option.where={compilation_id: compilation_id};
+        }
+        var curingList = await models.cloud_curing.findAll(option);
+        //组合同步云版数据
+        var falg=false;
+        curingCloudList.forEach(function(cclValue,cclKey){
+        	curingCloudList[cclKey].client_id=0
+        	
+        	falg=false;
+        	curingList.forEach(function(clValue,clKey){
+            	if(cclValue.mobile==clValue.mobile){
+            		curingCloudList[cclKey].client_id=clValue.client_id;
+            		falg=true;break;
+            	}
+            });
+        	if(falg){//新增本地扩展信息
+        		sid=hash.hashDecode(STAFF.sid);
+        		var obj = {
+                        mobile: cclValue.mobile,
+                        sso_id: cclValue.ssoid,
+                        compilation_id: cclValue.compilationId,
+                        curingCompany: cclValue.name,
+                        sid: sid,
+                        cid: STAFF.cid,
+                        status: 2,
+                        addtime: new Date().getTime(),
+                        updateTotal: 1
+                    };
+                var detail=await models.cloud_curing.create(obj);
+        	}
+        	
+        });
+    	
+        
+        
+        //数据组合--cld客户数据
         var cid=[];
-        curingList.forEach(function(v,i){
+        curingCloudList.forEach(function(v,i){
             cid.push(v.client_id);
         });
         var attributes= ['cid', 'clientname', 'companyid', 'companyname'];
         var clientList = await models.CLD_client.findAllInCid(cid,attributes);
-    	
-    	
-    	
+
+        
+        //组合页面需要展示的数据
+        curingCloudList.forEach(function(v,i){
+        	curingCloudList[i].clientInfo={};
+            clientList.forEach(function(clientVal,clientI){
+                if(v.client_id==clientVal.cid){
+                	curingCloudList[i].clientInfo=clientVal;
+                }
+            });
+
+            curingCloudList[i].addtime=moment.unix(v.addtime).format('YYYY-MM-DD HH:mm');
+            curingCloudList[i].id=hash.hashEncode(v.id.toString());
+            curingCloudList[i].client_id=hash.hashEncode(v.client_id.toString());
+            curingCloudList[i].sso_id=v.sso_id;
+        });
+        
+        var parameter='?compilation_id='+compilation_id;
+        //分页计算
+        var pageData = await getPage('','',page,limit,parameter,50);
+        
+        return {curingList:curingCloudList,pageData:pageData};
+        
+        
+        
+        
+        
     	
     	//获得本地用户
     	var limit=12;
@@ -73,10 +166,17 @@ var cloudService={
 
         var curingList = await models.cloud_curing.findAll(option);
         var parameter='?compilation_id='+compilation_id;
+        //分页计算
         var pageData = await getPage(models.cloud_curing,option.where,page,limit,parameter);
         
         
-        
+        //数据组合--cld客户数据
+        var cid=[];
+        curingList.forEach(function(v,i){
+            cid.push(v.client_id);
+        });
+        var attributes= ['cid', 'clientname', 'companyid', 'companyname'];
+        var clientList = await models.CLD_client.findAllInCid(cid,attributes);
 
         
         //组合页面需要展示的数据
@@ -241,7 +341,7 @@ var cloudService={
                 await models.cloud_curing.update(values,where);
                 id=curingDetail['id'];
             }else{
-                sid=hash.hashDecode(STAFF.sid);
+                cc
                 //获得登陆用户相关信息
                 var obj = {
                     mobile: data.mobile,

+ 60 - 47
global/js/cloud/curing.js

@@ -149,6 +149,64 @@ function getClentList(){
 
 $(function() {
 
+	/**
+     * 动态绑定养护用户列表 打开用户详情页面事件 
+     * ssoid
+     * id
+     * client_id
+     */
+    $('tbody[curingUser]').delegate( 'tr','click', function(){
+        // 只获取第一个选中的值
+        var ssoid = $(this).attr('data');
+        var id=$(this).attr('dataId');
+        var client_id=$(this).attr('dataCid')
+        $(this).attr('data-toggle',' ');
+        $.ajax({
+            cache :false,
+            type: 'GET',
+            url: '/cloud/curing/ajax/getCuringBySsoid',
+            data: {ssoid: encodeURI(ssoid),client_id:encodeURI(client_id)},
+            dataType: 'json',
+            context: $('body'),
+            success: function(data){
+                if(data.status==1||data.status==2){
+                    //设置 养护用户信息
+                    var objHtml=buildCuringInfo(data.detail.userInfo);
+                    $('div[curingInfo] curing').html(objHtml);
+
+                    //设置CLD客户信息
+                    if(data.detail.curingInfo.updateTotal!=0){
+                    	 $("#id").val(id);
+                         var clientHtml=relevanceClient(data.detail.clientInfo);
+                         $('div[curingInfo] curingClient').html(clientHtml);
+                    }
+                   
+
+                    //设置养护详情页里产品升级信息
+                    var upMajorBoxHtml=buildCuringCompilation(data);
+                    $('tbody[upMajorBox]').html(upMajorBoxHtml);
+
+                    //设置养护日志
+                    var operateLogHtml=buildCuringOperateLog(data.detail.operateLog);
+                    $('div[operateLog] curingOperate').html(operateLogHtml);
+
+                    setTimeout(autoHeight, 400);
+
+                    //autoHeight();
+                    $('#detail').modal('show');
+                }else if(data.status==3){
+                    alert(data.msg);
+                }
+            },
+            error: function(xhr, type){
+                console.log('Ajax error!')
+            }
+        })
+
+    });
+	
+	
+	
     //动态绑定 移除CLD客户事件
     $('button[relieveClientDo]').on('click', function(e){
     //$('div[curinginfo]').delegate( 'a[relieveClientDo]','click', function(){
@@ -231,53 +289,8 @@ $(function() {
 
     });
 
-    //动态绑定养护用户列表 数据获得
-    $('tbody[curingUser]').delegate( 'tr','click', function(){
-        // 只获取第一个选中的值
-        var ssoid = $(this).attr('data');
-        var id=$(this).attr('dataId');
-        var client_id=$(this).attr('dataCid')
-        $(this).attr('data-toggle',' ');
-        $.ajax({
-            cache :false,
-            type: 'GET',
-            url: '/cloud/curing/ajax/getCuringBySsoid',
-            data: {ssoid: encodeURI(ssoid),client_id:encodeURI(client_id)},
-            dataType: 'json',
-            context: $('body'),
-            success: function(data){
-                if(data.status==1||data.status==2){
-                    //设置 养护用户信息
-                    var objHtml=buildCuringInfo(data.detail.userInfo);
-                    $('div[curingInfo] curing').html(objHtml);
-
-                    //设置CLD客户信息
-                    $("#id").val(id);
-                    var clientHtml=relevanceClient(data.detail.clientInfo);
-                    $('div[curingInfo] curingClient').html(clientHtml);
-
-                    //设置养护详情页里产品升级信息
-                    var upMajorBoxHtml=buildCuringCompilation(data);
-                    $('tbody[upMajorBox]').html(upMajorBoxHtml);
-
-                    //设置养护日志
-                    var operateLogHtml=buildCuringOperateLog(data.detail.operateLog);
-                    $('div[operateLog] curingOperate').html(operateLogHtml);
-
-                    setTimeout(autoHeight, 400);
-
-                    //autoHeight();
-                    $('#detail').modal('show');
-                }else if(data.status==3){
-                    alert(data.msg);
-                }
-            },
-            error: function(xhr, type){
-                console.log('Ajax error!')
-            }
-        })
-
-    });
+    
+    
 
     //动态绑定分页事件
     $('ul[curingPage]').delegate( 'a','click', function(){

+ 4 - 1
views/cloud/curing.html

@@ -115,7 +115,7 @@
                                 </div>
                                 <div class="col-auto pr-0">
                                     <select curingByCompilation class="custom-select form-control custom-select-sm">
-
+										<option value="">所有</option>
                                         <% compilationList.forEach(function(compilation) { %>
                                         <option value="<%= compilation._id %>"><%= compilation.name %></option>
                                         <% }); %>
@@ -209,6 +209,9 @@
         </div>
     </div>
 </div>
+
+
+
 <!-- END Page Wrapper -->
 <!-- BEGIN 账号弹窗-->
 <div class="modal fade" id="detail" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">