Bläddra i källkod

项目管理升降级、上下移

zhongzewei 7 år sedan
förälder
incheckning
41d22f4167

+ 2 - 2
modules/pm/models/project_property_template.js

@@ -4,8 +4,8 @@
 
 //默认的小数位数,用于定义用户可编辑的字段(入库),用户不可编辑的字段在前端defaultDecima._def中定义即可
 const defaultDecimal = {
-    bills: {unitPrice: 2, totalPrice: 2},
-    ration: {quantity: 4, unitPrice: 2, totalPrice: 2},
+    bills: {unitPrice: 2, totalPrice: 0},
+    ration: {quantity: 4, unitPrice: 2, totalPrice: 0},
     glj: {quantity: 4, unitPriceHasMix: 2, unitPrice: 3},
     feeRate: 3,
     quantity_detail: 4,

+ 4 - 4
web/building_saas/main/html/main.html

@@ -874,7 +874,7 @@
                                                 <div class="col-sm-3">
                                                     <div class="input-group input-group-sm mb-2">
                                                         <div class="input-group-prepend">
-                                                            <span class="input-group-text">合价</span>
+                                                            <span class="input-group-text">金额</span>
                                                         </div>
                                                         <input type="number" name="bills-totalPrice" class="form-control" value="2" step="1" max="6" min="0">
                                                     </div>
@@ -901,7 +901,7 @@
                                                 <div class="col-sm-3">
                                                     <div class="input-group input-group-sm mb-2">
                                                         <div class="input-group-prepend">
-                                                            <span class="input-group-text">合价</span>
+                                                            <span class="input-group-text">金额</span>
                                                         </div>
                                                         <input type="number" name="ration-totalPrice" class="form-control" value="2" step="1" max="6" min="0">
                                                     </div>
@@ -977,12 +977,12 @@
                                                     定额子目自动调整行高
                                                 </label>
                                             </div>
-                                            <div class="form-check">
+                                            <!--<div class="form-check">
                                                 <label class="form-check-label">
                                                     <input class="form-check-input" id="disPlayMainMaterial" type="checkbox">
                                                     定额下显示主材、设备
                                                 </label>
-                                            </div>
+                                            </div>-->
                                         </fieldset>
                                         <div id="col_setting_spread" style="height:280px;overflow:hidden">
                                         </div>

+ 2 - 5
web/building_saas/main/js/views/project_info.js

@@ -8,15 +8,12 @@ var projectInfoObj = {
         let fullPath = [], i, pm = '<span class="text-truncate"><a href="/pm">项目管理</a></span>', angleRight = '<span class="text-truncate"><i class="fa fa-angle-right fa-fw"></i></span>';
         if (proj) {
             let pathArr = proj.fullPath;
-            let engName = pathArr[pathArr.length -2] || '',
-                projectName = pathArr[pathArr.length -3] || '',
-                folderName = pathArr[pathArr.length -4] || '';
+            let projectName = pathArr[pathArr.length -2] || '',
+                folderName = pathArr[pathArr.length -3] || '';
             let newHtml = `   <span data-toggle="tooltip" data-placement="bottom" data-original-title="${folderName}"><i class="fa fa-folder-open-o"></i>...</span>
                 <span class="text-muted px-1">\</span>
                 <span data-toggle="tooltip" data-placement="bottom" data-original-title="${projectName}"><i class="fa fa-cubes"></i>...</span>
                 <span class="text-muted px-1">\</span>
-                <span data-toggle="tooltip" data-placement="bottom" data-original-title="${engName}"><i class="fa fa-cube"></i>...</span>
-                <span class="text-muted px-1">\</span>
                  <span><i class="fa fa-sticky-note-o"></i></span>
                 <span class="text-truncate"  data-toggle="tooltip" data-placement="bottom" data-original-title="${proj.name}">&nbsp;${proj.name}</span>
                 ${projectReadOnly ?

+ 7 - 7
web/building_saas/pm/html/project-management.html

@@ -100,13 +100,13 @@
                 <div class="tab-content">
                     <div class="tab-pane active" id="pm_all" role="tabpanel">
                         <div class="toolsbar">
-                            <legend class="m-0 px-4 pb-1">项目管理
-                                <div class="tools-btn btn-group align-top px-3 ">
-                                    <div class="dropdown">
-                                        <a id="startA" class="btn btn-sm" href="javascript:void(0);" role="button" data-toggle="modal" aria-haspopup="true" aria-expanded="false">
-                                            新建
-                                        </a>
-                                    </div>
+                            <legend class="m-0 px-4">项目管理
+                                <div class="tools-btn btn-group align-top px-3 mt-2">
+                                    <a id="startA" href="javascript:void(0);" data-toggle="modal" data-target="#addPoj3" class="btn btn-sm"><i class="fa fa-sticky-note-o"></i> 新建</a>
+                                    <a id="upLevel" href="javascript:void(0);" class="btn btn-light btn-sm disabled" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
+                                    <a id="downLevel" href="javascript:void(0);" class="btn btn-light btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
+                                    <a id="upMove" href="javascript:void(0);" class="btn btn-light btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
+                                    <a id="downMove" href="javascript:void(0);" class="btn btn-light btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
                                 </div>
                             </legend>
                         </div>

+ 138 - 0
web/building_saas/pm/js/pm_newMain.js

@@ -184,6 +184,7 @@ const projTreeObj = {
             this.bindEvent(newWorkBook);
             this.loadContextMenu();
             this.loadStartMenu();
+            this.loadBtn();
         }
         return newWorkBook;
     },
@@ -371,6 +372,142 @@ const projTreeObj = {
             }
         });
     },
+    //刷新按钮有效性(升降级、上下移)
+    refreshBtn: function (selected) {
+        const upLevel = $('#upLevel');
+        const downLevel = $('#downLevel');
+        const upMove = $('#upMove');
+        const downMove = $('#downMove');
+        if (!selected) {
+            upLevel.addClass('disabled');
+            downLevel.addClass('disabled');
+            upMove.addClass('disabled');
+            downMove.addClass('disabled');
+            return;
+        }
+        /* 升级有效
+         * 当前选中文件夹,且文件夹有父项,且父项是文件夹
+         * 当前选中建设项目,且建设项目有父项,且父项是文件夹
+         */
+        if ([projectType.project, projectType.folder].includes(selected.data.projType)
+            && selected.parent && selected.parent.data && selected.parent.data.projType === projectType.folder) {
+            upLevel.removeClass('disabled');
+        } else {
+            upLevel.addClass('disabled');
+        }
+        /*
+         * 降级有效
+         * 当前选中文件夹,且文件夹有前兄弟,且前兄弟是文件夹
+         * 当前选中建设项目,且建设项目有前兄弟,且前兄弟是文件夹
+         * */
+        if ([projectType.project, projectType.folder].includes(selected.data.projType)
+            && selected.preSibling() && selected.preSibling().data.projType === projectType.folder) {
+            downLevel.removeClass('disabled');
+        } else {
+            downLevel.addClass('disabled');
+        }
+        /*
+         * 上移有效
+         * 当前选中行有前兄弟,不论前兄弟类型
+         * */
+        selected.preSibling() ? upMove.removeClass('disabled') : upMove.addClass('disabled');
+        /*
+         * 后移有效
+         * 当前选中行有后兄弟,不论后兄弟类型
+         * */
+        selected.nextSibling ? downMove.removeClass('disabled') : downMove.addClass('disabled');
+
+    },
+    doAfterTreeOpr: function ({selected, parent, next, projectMap}) {
+        $.bootstrapLoading.start();
+        moveProjects({"user_id": userID, rootProjectID: null, projectMap: projectMap, feeRateMap: {}, unitPriceMap: {}},function (result) {
+            for (let key in result) {//更新前端节点数据
+                let updateData = result[key].update;
+                let node = projTreeObj.tree.findNode(result[key].query.ID);
+                if (node) {
+                    for (let ukey in updateData) {
+                        _.set(node.data,ukey,updateData[ukey]);
+                    }
+                }
+            }
+            projTreeObj.moveTo(selected, null, parent, next, null);
+            $.bootstrapLoading.end();
+        });
+    },
+    //升级后选中节点的后兄弟节点不成为其子节点,因为有层级类型限制(相当于选中节点移动到父项后成为其后兄弟)
+    upLevel: function () {
+        let selected = projTreeObj.tree.selected,
+            parent = selected.parent.parent,
+            next = selected.parent.nextSibling,
+            projectMap = {};
+        //更新父节点
+        projectMap[selected.pid()] = {query: {ID: selected.pid()}, update: {NextSiblingID: selected.id()}};
+        //更新选中节点前兄弟节点
+        let orgPre = selected.preSibling();
+        if (orgPre) {
+            projectMap[orgPre.id()] = {query: {ID: orgPre.id()}, update: {NextSiblingID: selected.nid()}};
+        }
+        //更新选中节点
+        projectMap[selected.id()] = {query: {ID: selected.id()}, update: {ParentID: selected.parent.pid(), NextSiblingID: selected.parent.nid()}};
+        this.doAfterTreeOpr({selected, parent, next, projectMap});
+    },
+    downLevel: function () {
+        let selected = projTreeObj.tree.selected,
+            parent = null,
+            next = null,
+            projectMap = {};
+        //更新前兄弟节点
+        let orgPre = selected.preSibling();
+        parent = orgPre;
+        projectMap[orgPre.id()] = {query: {ID: orgPre.id()}, update: {NextSiblingID: selected.nid()}};
+        //更新前兄弟最后子节点
+        if (orgPre.children.length > 0) {
+            let lastChild = orgPre.lastChild();
+            projectMap[lastChild.id()] = {query: {ID: lastChild.id()}, update: {NextSiblingID: selected.id()}};
+        }
+        //更新选中节点
+        projectMap[selected.id()] = {query: {ID: selected.id()}, update: {ParentID: orgPre.id(), NextSiblingID: -1}};
+        this.doAfterTreeOpr({selected, parent, next, projectMap});
+    },
+    upMove: function () {
+        let selected = projTreeObj.tree.selected,
+            parent = selected.parent,
+            next = selected.preSibling(),
+            projectMap = {};
+        //更新前前兄弟
+        let prepre = selected.preSibling().preSibling();
+        if (prepre) {
+            projectMap[prepre.id()] = {query: {ID: prepre.id()}, update: {NextSiblingID: selected.id()}};
+        }
+        //更新前兄弟
+        let pre = selected.preSibling();
+        projectMap[pre.id()] = {query: {ID: pre.id()}, update: {NextSiblingID: selected.nid()}};
+        //更新选中节点
+        projectMap[selected.id()] = {query: {ID: selected.id()}, update: {NextSiblingID: pre.id()}};
+        this.doAfterTreeOpr({selected, parent, next, projectMap});
+    },
+    downMove: function () {
+        let selected = projTreeObj.tree.selected,
+            parent = selected.parent,
+            next = selected.nextSibling.nextSibling,
+            projectMap = {};
+        //更新前兄弟
+        let pre = selected.preSibling();
+        if (pre) {
+            projectMap[pre.id()] = {query: {ID: pre.id()}, update: {NextSiblingID: selected.nid()}};
+        }
+        //更新后兄弟
+        projectMap[selected.nid()] = {query: {ID: selected.nid()}, update: {NextSiblingID: selected.id()}};
+        //更新选中节点
+        projectMap[selected.id()] = {query: {ID: selected.id()}, update: {NextSiblingID: selected.nextSibling.nid()}};
+        this.doAfterTreeOpr({selected, parent, next, projectMap});
+    },
+    loadBtn: function () {
+        $('#upLevel').click(this.upLevel.bind(this));
+        $('#downLevel').click(this.downLevel.bind(this));
+        $('#upMove').click(this.upMove.bind(this));
+        $('#downMove').click(this.downMove.bind(this));
+    },
     getSelStyle: function (backColor) {
         let style = new GC.Spread.Sheets.Style();
         style.backColor = backColor;
@@ -397,6 +534,7 @@ const projTreeObj = {
         let me = this;
         let node = me.tree.items[newSel.row];
         node = node ? node : null;
+        me.refreshBtn(node);
         //恢复底色
         if(oldSel){
             me.setSelStyle(oldSel, me.setting.style.defalutBackColor,sheet);