Browse Source

超高降效相关

vian 6 years atrás
parent
commit
b17e418b83

+ 1 - 0
config/gulpConfig.js

@@ -115,6 +115,7 @@ module.exports = {
         'web/building_saas/main/js/models/exportStdInterfaceBase.js',
         'web/building_saas/main/js/models/exportStandardInterface.js',
         'web/building_saas/main/js/models/exportSEIInterface.js',
+        'web/building_saas/main/js/models/overHeight.js',
         // 'web/building_saas/main/js/calc/ration_calc.js',
         // 'web/building_saas/main/js/calc/bills_calc.js',
         // 'public/calc_util.js',

+ 4 - 0
modules/pm/models/project_model.js

@@ -192,6 +192,10 @@ ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId
                      //添加重庆经济指标数据
                     await projectFacade.setSEILibData(data.updateData.property);
                     data.updateData.property.overHeight = await pmFacade.initOverHeightItems(data.updateData.property.engineering_id);
+                    if (data.updateData.property.overHeight.length) {
+                        // 对应清单或分部下
+                        data.updateData.property.overHeightOption = 1;
+                    }
                 }else if (data.updateData.projType === projectType.project) {
                     //更新基本信息
                     data.updateData.property.basicInformation.forEach(function (pData) {

+ 94 - 0
web/building_saas/main/html/main.html

@@ -2181,6 +2181,99 @@
         </div>
     </div>
 </div>
+<!--超高降效-->
+<div class="modal fade" id="overHeight" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">超高降效选项设置</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <div class="mb-2">
+                    <div class="form-check">
+                        <input class="form-check-input" type="radio" name="cgx" id="cgx1">
+                        <label class="form-check-label" for="cgx1">
+                            对应清单或分项下
+                        </label>
+                    </div>
+                    <div class="form-check">
+                        <input class="form-check-input" type="radio" name="cgx" id="cgx2">
+                        <label class="form-check-label" for="cgx2">
+                            指定措施清单:“011704001”
+                        </label>
+                    </div>
+                    <div class="form-check">
+                        <input class="form-check-input" type="radio" name="cgx" id="cgx3">
+                        <label class="form-check-label" for="cgx3">
+                            指定具体位置
+                        </label>
+                    </div>
+                </div>
+                <div class="alert alert-warning" role="alert">
+                    软件自动默认13清单的超高清单下,如若与实际工程不一致,可以自行指定具体位置。
+                </div>
+                <!--指定具体位置-->
+                <div class="modal-fixed-height">
+                </div>
+            </div>
+            <div class="modal-footer">
+                <a href="javascript:;" class="btn btn-primary">确定</a>
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
+            </div>
+        </div>
+    </div>
+</div>
+<!--超高降效默认清单位置-->
+<div class="modal fade" id="overHeightMeasure" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">确认</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <div class="form-group">
+                    <p>未找到对应清单,是否需要自动生成?</p>
+                    <p>【是】:软件自动生成清单</p>
+                    <p>【否】:取消本次操作</p>
+                </div>
+            </div>
+            <div class="modal-footer" style="justify-content: center">
+                <button type="button" class="btn btn-primary"  data-dismiss="modal" id="overHeightMeasureY" >是</button>
+                <button type="button" class="btn btn-primary"  data-dismiss="modal" id="overHeightMeasureN">否</button>
+            </div>
+        </div>
+    </div>
+</div>
+<!--超高降效指定位置-->
+<div class="modal fade" id="overHeightSpecific" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">确认</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <div class="form-group">
+                    <p>指定清单已不存在,请重新指定</p>
+                    <p>【是】:指定清单</p>
+                    <p>【否】:取消本次操作</p>
+                </div>
+            </div>
+            <div class="modal-footer" style="justify-content: center">
+                <button type="button" class="btn btn-primary"  data-dismiss="modal" id="overHeightSpecificY" >是</button>
+                <button type="button" class="btn btn-primary"  data-dismiss="modal" id="overHeightSpecificN">否</button>
+            </div>
+        </div>
+    </div>
+</div>
 
     <img src="/web/dest/css/img/folder_open.png" id="folder_open_pic" style="display: none">
     <img src="/web/dest/css/img/folder_close.png" id="folder_close_pic" style="display: none">
@@ -2276,6 +2369,7 @@
     <script type="text/javascript" src="/web/building_saas/main/js/models/exportStdInterfaceBase.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/models/exportStandardInterface.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/models/exportSEIInterface.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/models/overHeight.js"></script>
     <!--<script type="text/javascript" src="/web/building_saas/main/js/calc/ration_calc.js"></script>-->
     <!--<script type="text/javascript" src="/web/building_saas/main/js/calc/bills_calc.js"></script>-->
     <!--<script type="text/javascript" src="/public/calc_util.js"></script>-->

+ 229 - 0
web/building_saas/main/js/models/overHeight.js

@@ -0,0 +1,229 @@
+const OVER_HEIGHT = (() => {
+    // 选项类型,生成的超高子目所在位置
+    const Option = {
+        // 对应清单或分部下(默认)
+        SEPARATION: 1,
+        // 指定措施清单011704001
+        MEASURE: 2,
+        // 指定具体位置,显示分部分项以及措施项目的树结构显示叶子清单(分项)供勾选
+        SPECIFIC: 3,
+    };
+
+    // 选项二时的前九位清单编号
+    const fixedCodeReg = /^011704001/;
+
+    // 源数据
+    let sourceData;
+    // 下拉项
+    let comboData;
+
+    function init(source) {
+        sourceData = source || [];
+        comboData = sourceData
+            ? sourceData
+                .filter(item => !item.extra)
+                .map(item => item.name)
+            : [];
+    }
+    // 获取下拉项
+    function getComboData() {
+        return comboData;
+    }
+    function getOverHeightItem(value) {
+        return sourceData.find(item => item.name === value);
+    }
+    // 获取系数
+    function getRate(overHeightItem) {
+        return overHeightItem.labourRate
+            || overHeightItem.machineRate
+            || overHeightItem.labourMachineRate
+            || null;
+    }
+    // 下拉项是否需要计算(生成子目)
+    function isNeedToCalc(overHeightItem) {
+        if (!overHeightItem) {
+            return false;
+        }
+        const rate = getRate(overHeightItem);
+        return !!rate;
+    }
+    // 是否是超高子目
+    function isOverHeight(node) {
+        return node
+            && node.sourceType === projectObj.project.Ration.getSourceType()
+            && node.data.type === rationType.overHeight;
+    }
+
+    function overHeightCol() {
+        return projectObj.project.projSetting.main_tree_col.cols.findIndex(item => item.data.field === 'overHeight');
+    }
+
+    // 有效化变化节点的值,若值为无效值(下拉项中不存在),则将变化节点的值设成原值
+    function validateData(changedData) {
+        changedData.forEach(item => {
+            if (!comboData.includes(item.value)) {
+                item.value = item.node.data.overHeight;
+            }
+        });
+    }
+
+    // 简化变化节点:由于子项值继承父项,且变更节点中可能存在父子关系,因此需要去除子项节点
+    function simplifyData(changedData) {
+        const rst = [];
+        const nodes = changedData.map(item => item.node);
+        changedData.forEach(item => {
+            let parent = item.parent;
+            // 父项不存在变化节点中才将此数据放入返回数组中
+            while (parent) {
+                if (nodes.includes(parent)) {
+                    return;
+                }
+                parent = parent.parent;
+            }
+            rst.push(item);
+        });
+        return rst;
+    }
+
+    // 设置单元格文本,单元格文本数据为暂存数据,方便后续获取更新、新增数据,若后续操作失败,则可用节点数据恢复单元格文本内容。
+    function setTexts(changedData) {
+        const sheet = projectObj.project.mainController.sheet;
+        const func = () => {
+            const overHeightCol = overHeightCol();
+            changedData.forEach(item => {
+                // 子项值随父项
+                const nodes = [item.node, ...item.node.getPosterity()];
+                nodes.forEach(node => sheet.setText(node.serialNo(), overHeightCol, item.value));
+            });
+        };
+        TREE_SHEET_HELPER.massOperationSheet(sheet, func);
+    }
+
+    // 获取措施项目固定的节点: 选项二时
+    function getMeasureFixedNode() {
+        const measureNode = projectObj.project.mainTree.items.find(node => node.getFlag() === fixedFlag.MEASURE);
+        const measureChildren = measureNode.getPosterity();
+        return measureChildren.find(node => node.data.code && fixedCodeReg.test(node.data.code));
+    }
+
+    // 获取指定清单节点:选项三时
+    function getSpecificNode() {
+        // 选项三指定清单时,指定的清单ID会存在项目属性中
+        const specificID = projectObj.project.projectInfo.property.overHeightSpecificID;
+        return specificID
+            ? projectObj.project.mainTree.nodes[`id_${specificID}`]
+            : null;
+    }
+
+    // 操作检验,若选项为2、3时,需检验指定清单是否还存在,不存在则取消操作和提示
+    function checkAction(option = Option.SEPARATION) {
+        if (option === Option.SEPARATION) {
+            return true;
+        } else if (option === Option.MEASURE) {
+            const isValid = !!getMeasureFixedNode();
+            if (!isValid) {
+                $('#overHeightMeasure').modal('show');
+            }
+            return isValid;
+        } else {
+            const isValid = !!getSpecificNode();
+            if (!isValid) {
+                $('#overHeightSpecific').modal('show');
+            }
+            return isValid;
+        }
+    }
+
+    // 超高降效下拉项或选项是否改变了
+    function isValueChanged() {
+        const updateData = getUpdateData();
+        return updateData.bills.length || updateData.ration.length;
+    }
+
+    /*
+    * 获取更新数据:对比项目节点中超高降效的新旧值,新值为暂存的单元格文本,旧值为节点data数据
+    * @return {Object} {bills: [{ID: Number, overHeight: String}], ration: [{ID: Number, overHeight: String}]}
+    * */
+    function getUpdateData() {
+        const rst = {
+            bills: [],
+            ration: [],
+        };
+        const nodes = projectObj.project.mainTree.items;
+        const sheet = projectObj.project.mainController.sheet;
+        const overHeightCol = overHeightCol();
+        nodes.forEach((node, index) => {
+            const newValue = node.data.overHeight;
+            const oldValue = sheet.getText(index, overHeightCol);
+            // 非严等
+            if (newValue != oldValue) {
+                const type = node.sourceType === projectObj.project.Bills.getSourceType()
+                    ? 'bills'
+                    : 'ration';
+                rst[type].push({
+                    ID: node.data.ID,
+                    overHeight: newValue
+                });
+            }
+        });
+        return rst;
+    }
+
+    /*
+    * 获取删除数据:项目中所有超高子目
+    * @return {Array} [{ID: Number}]
+    * */
+    function getDeleteData() {
+        const rations = projectObj.project.Ration.datas;
+        return rations
+            .filter(ration => ration.type === rationType.overHeight)
+            .map(ration => ({ ID: ration.ID }));
+    }
+
+    // 更改了超高降效列(edited、rangeChanged),触发事件
+    function handleValueChanged(changedData) {
+        validateData(changedData);
+        changedData = simplifyData(changedData);
+        setTexts(changedData);
+        const valuedChanged = isValueChanged();
+        if (!valuedChanged) {
+            return;
+        }
+        // 选项2、选项3情况下下拉可能会遇到,相关清单已经被删除,需要检测
+        const actionValid = checkAction(projectObj.project.projectInfo.property.overHeightOption);
+        // actionValid为false的时候,可能后续需要恢复单元格文本值,根据后续用户在弹窗中的选择 todo
+        if (!actionValid) {
+            return;
+        }
+    }
+
+    // 获取需要生成超高子目的定额节点
+    function getNeedCalcRationItems() {
+        // 从整个项目中筛选当前下拉项单元格的文本是需要计算的定额节点
+        const nodes = projectObj.project.mainTree.items;
+        const sheet = projectObj.project.mainController.sheet;
+        const overHeightCol = overHeightCol();
+        const rst = [];
+        nodes.forEach(node => {
+            if (node.sourceType !== projectObj.project.Ration.getSourceType() || node.data.type === rationType.overHeight) {
+                return;
+            }
+            const overHeight = sheet.getText(node.serialNo(), overHeightCol);
+            const overHeightItem = getOverHeightItem(overHeight);
+            if (isNeedToCalc(overHeightItem)) {
+                rst.push({ node, overHeightItem});
+            }
+        });
+        return rst;
+    }
+
+    function handleConfirmed(option = Option.SEPARATION) {
+
+    }
+
+    return {
+        init,
+        getComboData,
+        isOverHeight
+    }
+})();

+ 2 - 1
web/building_saas/main/js/models/project.js

@@ -36,6 +36,7 @@ var PROJECT = {
             let projectInfoModule = result.find(data => data.moduleName === ModuleNames.projectInfo);
             if (projectInfoModule) {
                 me._project.projectInfo = projectInfoModule.data;
+                OVER_HEIGHT.init(me._project.projectInfo.property.overHeight);
             }
             result.forEach(function(item){
                 if (item.moduleName !== ModuleNames.projectInfo) {
@@ -582,7 +583,7 @@ var PROJECT = {
                     // unitFeeCalcFlag
                     if (field.type === 'zangu') {
                         field.unitFeeFlag = converseUnitFeeFlag;
-                    } else {   
+                    } else {
                         // if (this.projSetting.billsCalcMode === settingConst.billsCalcMode.rationContent) {
                         if (this.property.billsCalcMode === leafBillGetFeeType.rationContent) {
                             field.unitFeeFlag = rationContentUnitFeeFlag;

+ 15 - 10
web/building_saas/main/js/views/main_tree_col.js

@@ -312,10 +312,10 @@ let MainTreeCol = {
         },
         // 超高降效
         forOverHeight: function (node) {
-            const isOverHeight = node
-                && node.sourceType === projectObj.project.Ration.getSourceType()
-                && node.data.type === rationType.overHeight;
-            return isOverHeight;
+            const isOverHeight = OVER_HEIGHT.isOverHeight(node);
+            const notFBFXAndMeasure = !projectObj.project.Bills.isFBFX(node)
+                && !projectObj.project.Bills.isMeasure(node);
+            return isOverHeight || notFBFXAndMeasure;
         }
     },
     cellType: {
@@ -429,12 +429,17 @@ let MainTreeCol = {
             }
         },
         overHeight: function (node) {
-            const isOverHeight = node
-                && node.sourceType === projectObj.project.Ration.getSourceType()
-                && node.data.type === rationType.overHeight;
-            if (isOverHeight) {
-
-            }
+            const isOverHeight = OVER_HEIGHT.isOverHeight(node);
+            const notFBFXAndMeasure = !projectObj.project.Bills.isFBFX(node)
+                && !projectObj.project.Bills.isMeasure(node);
+            if (isOverHeight || notFBFXAndMeasure) {
+                return;
+            }
+            const dynamicCombo = sheetCommonObj.getDynamicCombo();
+            const items = OVER_HEIGHT.getComboData();
+            dynamicCombo._maxDropDownItems = 10;
+            dynamicCombo.items(items);
+            return dynamicCombo;
         }
     },
     mainBillsEnable:function (node) {

+ 12 - 3
web/building_saas/main/js/views/project_view.js

@@ -209,7 +209,7 @@ var projectObj = {
         }
         if (value!=undefined||value!=null) {
             if (colSetting.data.decimal) {
-                value = value.toDecimal(colSetting.data.decimal);   
+                value = value.toDecimal(colSetting.data.decimal);
             }
         } else if (editingText && editingText !== '') {
             value = null;
@@ -459,6 +459,10 @@ var projectObj = {
         if(node.sourceType==project.ration_glj.getSourceType()){
             project.ration_glj.updateFromMainSpread(value,node,fieldName);
         }
+        else if (fieldName === 'overHeight') {
+            debugger;
+            return;
+        }
         else if(fieldName === 'remark'){
             projectObj.updateNodeField(node,value,'remark');
         }
@@ -865,14 +869,19 @@ var projectObj = {
             refreshNodes.push(project.mainTree.items[row]);
         }
         let updateRationCodes = [];//更新定额编码时要用同步的方式
+        // 超高降效的操作比较耗时,需要减少触发
+        const updateOverHeights = [];
         if(changedObj.changedCells.length > 0){
+            console.log(changedObj.changedCells);
             for (let changedCell of changedObj.changedCells) {
                 let node = project.mainTree.items[changedCell.row];
                 let colSetting = setting.cols[changedCell.col];
                 let value = projectObj.checkSpreadEditingText(changedCell.text, colSetting);
                 if(colSetting.data.field=='code' && node.sourceType == project.Ration.getSourceType()&&node.data.type==rationType.ration){//如果是更新定额的编码
                     updateRationCodes.push({'node':node,value:value});
-                }else {
+                } else if (colSetting.data.field === 'overHeight') {
+                    updateOverHeights.push({node, value});
+                } else {
                     projectObj.updateCellValue(node, value, colSetting,changedCell.text);
                 }
             }
@@ -3422,4 +3431,4 @@ $('#menu_index_info').click(function () {
 });
 
 //导出接口
-ExportView.exportListener();
+ExportView.exportListener();