Browse Source

项目人材机页面,添加组成物bug

vian 5 years ago
parent
commit
22d48ca4e1

+ 16 - 1
modules/complementary_glj_lib/models/gljModel.js

@@ -46,7 +46,18 @@ class GljDao {
         }
     }
 
-    async getQueryByType ({userID, compilationId, gljLibId, code, type, replace, location, classList, search}) {
+    async getQueryByType (condition) {
+        const {
+            userID, 
+            compilationId, 
+            gljLibId, code, 
+            type,
+            queryExtend,
+            replace, 
+            location, 
+            classList, 
+            search
+        } = condition;
         let model = null,
             query = {},
             countQuery = {},
@@ -79,6 +90,10 @@ class GljDao {
             const materialTypes = [202, 203, 204, 205, 206];
             query.gljType = materialTypes.includes(replace.gljType) ? {$in: materialTypes} : replace.gljType;
         }
+        // 添加组成物时的查询扩展
+        if (queryExtend) {
+            Object.assign(query, queryExtend);
+        }
         // 搜索关键字
         if (search) {
             query.$or = [{code: {'$regex': search, $options: '$i'}}, {name: {'$regex': search, $options: '$i'}}];

+ 0 - 7
modules/main/facade/project_facade.js

@@ -231,13 +231,6 @@ async function calcOverHeightFee(data) {
         if (completeRationGLJList.length) {
             tasks.push(ration_glj_model.insertMany(completeRationGLJList))
         }
-        // if (rationGLJ.length) {
-        //     // 定额人材机需要新增项目人材机、单价文件、且返回完整的定额人材机数据
-        //     const rationGLJTasks = rationGLJ.map(glj => createRationGLJData(glj));
-        //     completeRationGLJList = await Promise.all(rationGLJTasks);
-        //     // 新增定额人材机
-        //     tasks.push(ration_glj_model.insertMany(completeRationGLJList));
-        // }
         // 返回新的清单、定额人材机、项目人材机数据数据
         const rst = {
             bills,

+ 1 - 1
web/building_saas/main/js/models/overHeight.js

@@ -65,7 +65,7 @@ const OVER_HEIGHT = (() => {
     const fixedCodeReg = new RegExp(`^${fixedCode}`);
 
     // 取费专业名称
-     const programName = '超高降效';
+    const programName = '超高降效';
     //const programName = '公共建筑工程'; // for Test
 
     // 指定清单表格

+ 9 - 0
web/building_saas/main/js/models/ration_glj.js

@@ -503,6 +503,7 @@ let ration_glj = {
             gljOprObj.loadingPagination = true;
             const property = projectObj.project.projectInfo.property;
             const engineerID = property.engineering_id;
+            const actionType = $('#actionType').val();
             CommonAjax.post('/rationGlj/getGLJDataPaging', {engineerID, condition}, function (data) {
                 gljOprObj.curPageTotal = data.total;
                 data.complementaryGLJs.forEach(glj => {
@@ -512,6 +513,14 @@ let ration_glj = {
                     ? 'stdGLJ'
                     : 'complementaryGLJs';
                 const newData = data[gljType];
+                // 添加组成物,类型为主材时,需要排除自身
+                if (actionType === 'addMix' && projectGljObject.selectedProjectGLJ.type === gljType.MAIN_MATERIAL) {
+                    const pIndex = gljOprObj.getIndex(projectGljObject.selectedProjectGLJ, gljKeyArray);
+                    const delIndex = newData.findIndex(item => gljOprObj.getIndex(item, gljLibKeyArray) === pIndex);
+                    if (!~delIndex) {
+                        newData.splice(delIndex, 1);
+                    }
+                }
                 if (condition.init) {
                     gljOprObj.treeData = data.treeData;
                     gljOprObj.distTypeTree = gljOprObj.getComboData(data.distTypeTree);

+ 11 - 7
web/building_saas/main/js/views/glj_view.js

@@ -1056,6 +1056,8 @@ var gljOprObj = {
             type: this.pagingType.stdGLJ,
             // 替换数据,替换操作下有数据:编码、名称、规格、单位、类型
             replace: null,
+            // 添加组成物的查询扩展
+            queryExtend: {},
             // 所在分类节点
             classList: [],
             // 搜索文本
@@ -1075,6 +1077,8 @@ var gljOprObj = {
                 unit: selected.unit,
                 gljType: selected.type
             };
+        } else if (actionType === 'addMix') {
+            condition.queryExtend = projectGljObject.getQueryExtForMixRatio();
         }
         if (init) {
             return condition;
@@ -1640,9 +1644,12 @@ $(function () {
         let gljClass = 0,
             selected,
             connect_key;
-        if ($('#actionType').val() == 'add' || $('#actionType').val() == 'insert') {//插入,添加
+        const actionType = $('#actionType').val();
+        const addActions = ['add', 'insert', 'addMix'];
+        const replaceActions = ['m_replace', 'replace'];
+        if (addActions.includes(actionType)) {//插入,添加,添加组成物(项目人材机页面)
             gljOprObj.GLJSelection = [];
-        } else if($('#actionType').val() =='m_replace' || $('#actionType').val() == 'replace'){//替换、批量替换
+        } else if(replaceActions.includes(actionType)){//替换、批量替换
             selected = gljOprObj.sheetData[gljContextMenu.selectedRow];
             connect_key = gljOprObj.getIndex(selected, gljKeyArray);
             gljOprObj.GLJSelection = [connect_key];
@@ -1652,12 +1659,9 @@ $(function () {
                 gljClass = locatedItem.gljClass;
                 locatedItem.select = 1;
             }
-        } else if($('#actionType').val() =='addMix'){//添加组成物
-            gljOprObj.GLJSelection = [];
-            projectGljObject.filterLibGLJForMixRatio();
         }
         //替换,焦点定位至当前选中人材机
-        if ($('#actionType').val() =='m_replace' || $('#actionType').val() == 'replace') {
+        if (replaceActions.includes(actionType)) {
             gljOprObj.locateZTree(gljClass);
             sheetCommonObj.appendData(gljOprObj.gljLibSheet, 0, 0, gljOprObj.gljLibSheetSetting, gljOprObj.AllRecode);
             const index = gljOprObj.AllRecode.findIndex(item => gljOprObj.getIndex(item, gljLibKeyArray) === connect_key);
@@ -1665,7 +1669,7 @@ $(function () {
             gljOprObj.gljLibSheet.setActiveCell(index, 0);
             gljOprObj.initSelection({row: index});
             gljOprObj.gljLibSpresd.focus(true);
-        } else if ($('#actionType').val() === 'add') {
+        } else if (actionType === 'add' || actionType === 'addMix') {
             gljOprObj.locateZTree(null);
             sheetCommonObj.appendData(gljOprObj.gljLibSheet, 0, 0, gljOprObj.gljLibSheetSetting, gljOprObj.AllRecode);
             gljOprObj.gljLibSheet.showRow(0, GC.Spread.Sheets.VerticalPosition.top);

+ 3 - 2
web/building_saas/main/js/views/glj_view_contextMenu.js

@@ -383,8 +383,9 @@ function getGLJData(actionType) {
     gljOprObj.GLJSelection = [];
     $.bootstrapLoading.start();
     let location = false;
-    const replaceActions = ['replace', 'm_replace'];
-    if (replaceActions.includes(actionType)) {
+    // 需要定位
+    const locateActions = ['replace', 'm_replace'];
+    if (locateActions.includes(actionType)) {
         location = true;
     }
     const init = true;

+ 16 - 0
web/building_saas/main/js/views/project_glj_view.js

@@ -137,6 +137,22 @@ let projectGljObject={
     getUsedTenderInfo:function() {
         return "人材机单价的变化,将自动影响以下单位工程造价:<br>"+projectGljObject.usedTenderList.join("<br>");
     },
+    // 获取选中人材机,添加组成物时,分页查询语句的扩展
+    getQueryExtForMixRatio: function () {
+        const extend = {};
+        if (!this.selectedProjectGLJ) {
+            return extend;
+        }
+        if (this.selectedProjectGLJ.type === gljType.MAIN_MATERIAL) {//对于主材,只显示没有组成物并且除了自已的主材
+            extend['component.0'] = {$exists: false};
+            extend.gljType = gljType.MAIN_MATERIAL;
+        } else if (_.includes(gljUtil.hasCompMaterial, this.selectedProjectGLJ.type)) {//混凝土、砂浆、配合比
+            extend.gljType = gljType.GENERAL_MATERIAL;
+        } else if (_.includes(gljUtil.hasCompMachine, this.selectedProjectGLJ.type)) {//me.selectedProjectGLJ.type == gljType.GENERAL_MACHINE//机械中有组成物的类型
+            extend.gljType = {$in: gljUtil.machineComposition};
+        }
+        return extend;
+    },
     filterLibGLJForMixRatio:function () {
         let me = this;
         if(me.selectedProjectGLJ){