Forráskód Böngészése

ration_glj.prototype.getGLJDataPaging

zhongzewei 6 éve
szülő
commit
f0f845be00

+ 2 - 2
modules/complementary_glj_lib/models/gljModel.js

@@ -73,8 +73,8 @@ class GljDao {
         let gljs = await queryData.model.find(queryData.query).lean().sort({code: 1}).skip(data.index).limit(limitCount),
             total = await queryData.model.find(queryData.query).count();
         return data.type === gljType.stdGLJ
-            ? {stdGljs: gljs, complementaryGljs: [], total: total}
-            : {stdGljs: [], complementaryGljs: gljs, total: total}
+            ? {stdGLJ: gljs, complementaryGLJs: [], total: total}
+            : {stdGLJ: [], complementaryGLJs: gljs, total: total}
     }
 
     //获得用户的补充工料机和用户当前所在编办的标准工料机

+ 2 - 2
modules/ration_glj/controllers/ration_glj_controller.js

@@ -69,9 +69,9 @@ async function getGLJDataPaging(req, res) {
             userID: req.session.sessionUser.id,
             compilationId: req.session.sessionCompilation._id
         };
-        result.datas = await ration_glj_facade.getGLJDataPaging(info, data.condition);
+        result.data = await ration_glj_facade.getGLJDataPaging(info, data.condition);
         if (req.session.sessionCompilation.priceProperties) {
-            result.datas.priceProperties = req.session.sessionCompilation.priceProperties
+            result.data.priceProperties = req.session.sessionCompilation.priceProperties
         }
         res.json(result);
     } catch (err) {

+ 23 - 3
web/building_saas/main/js/models/ration_glj.js

@@ -501,16 +501,36 @@ let ration_glj = {
             let property = projectObj.project.projectInfo.property;
             let engineerID = property.engineering_id;
             CommonAjax.post('/rationGlj/getGLJDataPaging', {engineerID, condition}, function (data) {
-                if(data.datas.priceProperties && data.datas.priceProperties.length > 0){
-                    let tem = _.find(data.datas.priceProperties,{region:property.region,taxModel:parseInt(property.taxType)});
+                data.complementaryGLJs.forEach(glj => {
+                    glj.isComplementary = true;
+                });
+                let gljType = condition.type === gljOprObj.pagingType.stdGLJ
+                    ? 'stdGLJ'
+                    : 'complementaryGLJs';
+                if (condition.init) {
+                    gljOprObj.treeData = data.treeData;
+                    gljOprObj.distTypeTree=gljOprObj.getComboData(data.distTypeTree);
+                    gljOprObj.stdGLJ = data.stdGLJ;
+                    gljOprObj.complementaryGLJs = data.complementaryGLJs;
+                    gljOprObj.AllRecode = [...gljOprObj.stdGLJ, ...gljOprObj.complementaryGLJs];
+                } else {
+                    gljOprObj[gljType].splice(condition.index, 0, ...data[gljType]);
+                    gljOprObj.AllRecode.splice(condition.index, 0, ...data[gljType]);
+                }
+                if(data.priceProperties && data.priceProperties.length > 0){
+                    let tem = _.find(data.priceProperties,{region:property.region,taxModel:parseInt(property.taxType)});
                     if(tem){
                         let dataCode = tem.price.dataCode;
-                        for(let glj of data.datas.stdGLJ){
+                        for(let glj of data.stdGLJ){
                             if(glj.priceProperty && gljUtil.isDef(glj.priceProperty[dataCode])) glj.basePrice = glj.priceProperty[dataCode];
                         }
                     }
                 };
                 cb(data);
+            }, function () {
+                if ($.bootstrapLoading.isLoading()) {
+                    $.bootstrapLoading.end();
+                }
             });
         };
         ration_glj.prototype.getGLJData = function (cb) {

+ 15 - 12
web/building_saas/main/js/views/glj_view.js

@@ -103,6 +103,10 @@ var gljOprObj = {
         }
     },
     gljLibSheet: null,
+    pagingType: {
+        stdGLJ: 1,
+        complementaryGLJs: 2
+    },
     scopeSetting:{},
     scopeSpread:null,
     scopeSheet:null,
@@ -982,10 +986,6 @@ var gljOprObj = {
     // 获取分页查询所需要的条件数据
     // @param {Boolean}init 是否是初始化
     getPagingCondition: function (init, index) {
-        const type = {
-            stdGLJ: 1,
-            complementaryGLJs: 2
-        };
         // 初始化情况下的条件
         let condition = {
             // 开始取数据的位置
@@ -993,7 +993,7 @@ var gljOprObj = {
             // 初始化
             init: true,
             // 所在部分(标准、补充)
-            type: type.stdGLJ,
+            type: this.pagingType.stdGLJ,
             // 替换数据,替换操作下有数据:编码、名称、规格、单位、类型
             replace: null,
             // 所在分类节点
@@ -1008,7 +1008,7 @@ var gljOprObj = {
         // 标准、补充的选择
         if ($('#glj_tree_div').is(':visible')) {
             let radioType = $("input[name='glj']:checked").val();
-            condition.type = type[radioType];
+            condition.type = this.pagingType[radioType];
         }
         // 选中的分类
         if (this.treeObj) {
@@ -1439,7 +1439,7 @@ var gljOprObj = {
         if (!node) node = zTree.getNodeByTId('gljTree_1');
         zTree.selectNode(node);
         gljOprObj.gljCurTypeId = ID;
-        gljOprObj.filterLibGLJSheetData();
+        //--gljOprObj.filterLibGLJSheetData();
         gljOprObj.showLibGLJSheetData();
     },
     isExtraType:function (type) {
@@ -1573,11 +1573,13 @@ $(function () {
                 gljOprObj.GLJSelection.push(s_key);
             }*/
         }
-        for(let item of gljOprObj.gljLibSheetData){
-            let item_key = gljOprObj.getIndex(item, gljLibKeyArray);
-            if(selectMap[item_key]){
-                item.select = 1 ;
-                gljClass = item.gljClass;
+        if (Object.keys(selectMap).length) {
+            for(let item of gljOprObj.gljLibSheetData){
+                let item_key = gljOprObj.getIndex(item, gljLibKeyArray);
+                if(selectMap[item_key]){
+                    item.select = 1 ;
+                    gljClass = item.gljClass;
+                }
             }
         }
         //替换,焦点定位至当前选中人材机
@@ -1595,6 +1597,7 @@ $(function () {
             gljOprObj.gljLibSheet.setActiveCell(0, 0);
             gljOprObj.initSelection({row: 0});
         } else gljOprObj.showLibGLJSheetData();
+        console.timeEnd('getGLJData');
     });
 
     $('#mreplace_next_div').on('shown.bs.modal', function (e) {

+ 20 - 5
web/building_saas/main/js/views/glj_view_contextMenu.js

@@ -376,11 +376,26 @@ var gljContextMenu = {
 function getGLJData(actionType) {
     $('#actionType').val(actionType);
     $.bootstrapLoading.start();
-    /*let condition = gljOprObj.getPagingCondition(false, 0);
+    let condition = gljOprObj.getPagingCondition(true, 0);
+    console.time('getGLJData');
     projectObj.project.ration_glj.getGLJDataPaging(condition, function (result) {
-        gljOprObj.treeData =  result.datas.treeData;
-    });*/
-    projectObj.project.ration_glj.getGLJData(function (result) {
+        gljOprObj.initClassTree('std', gljOprObj.treeData.std);
+        $('#modalCon').width($(window).width()*0.5);
+        $("input[name='glj']").get(0).checked=true;
+        $.bootstrapLoading.end();
+        if(actionType == "m_replace"){
+            $('#glj_selected_conf').hide();
+            $('#replace_next_btn').show();
+        } else {
+            $('#glj_selected_conf').show();
+            $('#replace_next_btn').hide();
+        }
+        $("#glj_tree_div").modal({show:true});
+        setTimeout(function(){
+            gljOprObj.gljLibSpresd ? gljOprObj.gljLibSpresd.refresh() : '';
+        }, 200);
+    });
+    /*projectObj.project.ration_glj.getGLJData(function (result) {
         console.log(+new Date());
         gljOprObj.treeData =  result.datas.treeData;
         //zTreeHelper.createTree(result.datas.treeData, gljOprObj.gljTreeSetting, "gljTree", gljOprObj);
@@ -408,7 +423,7 @@ function getGLJData(actionType) {
         setTimeout(function(){
             gljOprObj.gljLibSpresd?gljOprObj.gljLibSpresd.refresh():'';
         }, 200);
-    })
+    })*/
 }
 
 function showGLJClassTree(record) {