소스 검색

feat: 分部行的项目名称,可下拉选择,快速输入。

zhangweicheng 4 년 전
부모
커밋
97fa1fe376

+ 1 - 0
config/gulpConfig.js

@@ -186,6 +186,7 @@ module.exports = {
         'web/building_saas/main/js/views/fee_rate_view.js',
         'web/building_saas/main/js/views/quantity_edit_view.js',
         'web/building_saas/main/js/views/sub_fee_rate_views.js',
+        'web/building_saas/main/js/views/select_FB_view.js',
         'web/building_saas/main/js/views/calc_base_view.js',
         'web/building_saas/main/js/views/project_property_labour_coe_view.js',
         'web/building_saas/main/js/views/locate_view.js',

+ 33 - 37
public/web/sheet/sheet_common.js

@@ -685,42 +685,6 @@ var sheetCommonObj = {
         }
         //sheet.setCellType(row, col,this.getSelectButton(header.headerWidth),GC.Spread.Sheets.SheetArea.viewport);
     },
-
-    paintCusButtonImage:function(ctx, value, x, y, w, h, style, options){
-        if (options.sheet.getActiveRowIndex() == options.row && options.sheet.getActiveColumnIndex() == options.col) {
-            var image = document.getElementById('f_btn'), imageMagin = 3;
-            var imageHeight = 15;
-            var imageWidth = 25;
-            var imageX = x + w - imageWidth - imageMagin, imageY = y + h / 2 - imageHeight / 2;
-            ctx.save();
-           /* 2020-12-16 这里原先是还原背景色的,发现不需要了,先观察 
-            if (style.backColor) {
-                ctx.fillStyle = style.backColor;
-                ctx.fillRect(x, y, w, h);
-            } 
-            */
-            ctx.drawImage(image, imageX, imageY, imageWidth, imageHeight);
-            ctx.beginPath();
-            ctx.arc(imageX + imageWidth / 2, imageY + imageHeight / 2, 1, 0, 360, false);
-            ctx.arc(imageX + imageWidth / 2 - 4, imageY + imageHeight / 2, 1, 0, 360, false);
-            ctx.arc(imageX + imageWidth / 2 + 4, imageY + imageHeight / 2, 1, 0, 360, false);
-            ctx.fillStyle = "black";//填充颜色,默认是黑色
-            ctx.fill();//画实心圆
-            ctx.closePath();
-            ctx.restore();
-            w = w - imageWidth - imageMagin;
-            //这里的左对齐的,当显示的字长度超过空白地方时,要改成右对齐
-            if (style.hAlign == 0) {
-                if (value) {
-                    let textWidth = ctx.measureText(value).width;
-                    let spaceWidth = w;
-                    if (spaceWidth < textWidth) {
-                        style.hAlign = 2;
-                    }
-                }
-            }
-        }
-    },
     getCusButtonCellType: function (callback, readOnly = false, ostyle) {
         var ns = GC.Spread.Sheets;
 
@@ -730,7 +694,39 @@ var sheetCommonObj = {
         CusButtonCellType.prototype = new ns.CellTypes.Text();
         CusButtonCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
             if (!readOnly) {
-                sheetCommonObj.paintCusButtonImage(ctx, value, x, y, w, h, style, options);
+                if (options.sheet.getActiveRowIndex() == options.row && options.sheet.getActiveColumnIndex() == options.col) {
+                    var image = document.getElementById('f_btn'), imageMagin = 3;
+                    var imageHeight = 15;
+                    var imageWidth = 25;
+                    var imageX = x + w - imageWidth - imageMagin, imageY = y + h / 2 - imageHeight / 2;
+                    ctx.save();
+                   /* 2020-12-16 这里原先是还原背景色的,发现不需要了,先观察 
+                    if (style.backColor) {
+                        ctx.fillStyle = style.backColor;
+                        ctx.fillRect(x, y, w, h);
+                    } 
+                    */
+                    ctx.drawImage(image, imageX, imageY, imageWidth, imageHeight);
+                    ctx.beginPath();
+                    ctx.arc(imageX + imageWidth / 2, imageY + imageHeight / 2, 1, 0, 360, false);
+                    ctx.arc(imageX + imageWidth / 2 - 4, imageY + imageHeight / 2, 1, 0, 360, false);
+                    ctx.arc(imageX + imageWidth / 2 + 4, imageY + imageHeight / 2, 1, 0, 360, false);
+                    ctx.fillStyle = "black";//填充颜色,默认是黑色
+                    ctx.fill();//画实心圆
+                    ctx.closePath();
+                    ctx.restore();
+                    w = w - imageWidth - imageMagin;
+                    //这里的左对齐的,当显示的字长度超过空白地方时,要改成右对齐
+                    if (style.hAlign == 0) {
+                        if (value) {
+                            let textWidth = ctx.measureText(value).width;
+                            let spaceWidth = w;
+                            if (spaceWidth < textWidth) {
+                                style.hAlign = 2;
+                            }
+                        }
+                    }
+                }
             }
             if (ostyle) gljUtil.setProperty(style, ostyle);
             GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);

+ 6 - 1
public/web/tree_sheet/tree_sheet_helper.js

@@ -191,6 +191,9 @@ var TREE_SHEET_HELPER = {
                 if(colSetting.data.autoHeight == true){
                     colSetting.setAutoHeight(cell,node);
                 }
+                //主界面分部名称点击弹窗    
+                if(sheet.name()=="mainSheet" && colSetting.data.field=="name") MainTreeCol.setNameCusButton(cell,node);   
+
                 if(colSetting.editChecking&&colSetting.editChecking(node,colSetting.data.field)){
                     cell.locked(true);
                 }else if (colSetting.readOnly) {
@@ -313,6 +316,8 @@ var TREE_SHEET_HELPER = {
         let halfExpandLength = 3;
     
         let isRationNode = sheet.name()=="mainSheet" && initNode.sourceType == ModuleNames.ration&&initNode.data.type == rationType.ration;
+
+
         let questionImg = document.getElementById('question_pic'),
             questionImgWidth = 16,
             questionImgHeight = 16;
@@ -330,6 +335,7 @@ var TREE_SHEET_HELPER = {
             } else {
                 ctx.clearRect(x, y, w, h);
             }
+
             // ������(x1, y1)���(��, ��), (x2, y2)�յ�(��, ��), ��ɫ
             let drawLine = function (canvas, x1, y1, x2, y2, color) {
                 ctx.save();
@@ -438,7 +444,6 @@ var TREE_SHEET_HELPER = {
                 let centerY = Math.floor((y + (y + h)) / 2);
                 ctx.drawImage(questionImg, centerX + 3, centerY - 7, questionImgWidth,questionImgHeight);
             }
-
         };
         TreeNodeCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
             return {

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

@@ -2694,6 +2694,29 @@
     </div>
   </div>
 
+  
+<!--弹出 选择分部窗口-->
+<div class="modal fade" id="selectFBDiv" 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" style="height: 450px;padding: 0px">
+              <div class="ovf-hidden full-h" id="selectFBSheet" style="height: 100%;"></div>
+          </div>
+          <div class="modal-footer">
+              <button type="button" class="btn btn-primary" data-dismiss="modal" id="selectFBConfirm">确定</button>
+              <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+          </div>
+      </div>
+  </div>
+</div>
+
+
 
   <%include ../../../common/components/share/index.html %>
 
@@ -2861,6 +2884,7 @@
   <script type="text/javascript" src="/web/building_saas/main/js/views/fee_rate_view.js"></script>
   <script type="text/javascript" src="/web/building_saas/main/js/views/quantity_edit_view.js"></script>
   <script type="text/javascript" src="/web/building_saas/main/js/views/sub_fee_rate_views.js"></script>
+  <script type="text/javascript" src="/web/building_saas/main/js/views/select_FB_view.js"></script>
   <script type="text/javascript" src="/web/building_saas/main/js/views/calc_base_view.js"></script>
   <script type="text/javascript" src="/web/building_saas/main/js/views/project_property_labour_coe_view.js"></script>
   <script type="text/javascript" src="/web/building_saas/main/js/views/locate_view.js"></script>

+ 9 - 0
web/building_saas/main/js/views/main_tree_col.js

@@ -622,6 +622,15 @@ let MainTreeCol = {
             const color = 'red';
             return calcTools.unitFeeGTMaxPrice(node, 'common.unitFee') || calcTools.unitFeeLTMinPrice(node, 'common.unitFee') ? color : null;
         }
+    },
+    setNameCusButton:function(cell,node){
+        let isFBNode = node.sourceType == ModuleNames.bills&&node.data.type == billType.FB;
+        if(isFBNode){
+           let CELL =sheetCommonObj.getCusButtonCellType(()=>{
+            $('#selectFBDiv').modal('show');
+            })
+            cell.cellType(CELL); 
+        }
     }
 };
 

+ 89 - 0
web/building_saas/main/js/views/select_FB_view.js

@@ -0,0 +1,89 @@
+let selectFBObject = { 
+    spread:null,
+    datas:[],
+    setting:{
+        header: [
+            {headerName: "编号", headerWidth: 180, dataCode: "code", dataType: "String"},
+            {headerName: "名称", headerWidth: 210, dataCode: "name", dataType: "String"},
+            {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String", hAlign: "center"},
+        ],
+        view:{ lockColumns: ["name","code","unit"]}
+    },
+    initSpread:function(){
+        if(!this.spread){
+            this.spread = SheetDataHelper.createNewSpread($("#selectFBSheet")[0]);
+            sheetCommonObj.spreadDefaultStyle(this.spread);
+            let sheet = this.spread.getSheet(0);
+            sheetCommonObj.initSheet(sheet,this.setting,0);
+              /*   sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onSelectionChange);
+                sheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onEngineerInfoValueChange);
+                sheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onEngineerInfoRangeChange);
+                sheet.name('engineerInfo'); */
+               
+          
+
+            if(projectReadOnly){
+                sheetCommonObj.disableSpread(this.spread);
+            }
+        }else{
+            this.spread.repaint();
+        }
+        
+    },
+    getSelectedData:function(){
+        let sel = this.spread.getSheet(0).getSelections()[0];
+        if(sel && gljUtil.isDef(sel.row)){
+            return this.datas[sel.row]
+        }
+        return null;
+    },
+    showData:function(){
+        let me = selectFBObject;
+        billsGuidance.initBillsLibs(()=>{
+            if(me.datas.length==0){
+                for(let r of billsGuidance.bills.tree.roots){
+                    selectFBObject.setDatas(r);
+                }
+            }
+            sheetCommonObj.showTreeData(me.spread.getSheet(0), me.setting, me.datas);
+        });
+    },
+    setDatas:function(node){
+        if(node.children.length > 0){//过滤叶子节点
+            let nodeData = node.data;
+            let d = {
+                ID:nodeData.ID,
+                ParentID:nodeData.ParentID,
+                code:nodeData.code,
+                name:nodeData.name,
+                unit:nodeData.unit
+            }
+            this.datas.push(d);
+            for(let c of node.children){
+                this.setDatas(c)
+            }
+        }
+    }
+}
+$(function () {
+
+    $('#selectFBDiv').on('shown.bs.modal', function (e) {
+        selectFBObject.initSpread();
+        selectFBObject.showData();
+    })
+    $("#selectFBConfirm").click(async ()=>{
+        let data = selectFBObject.getSelectedData();
+        if(!data) return;
+        let selected = projectObj.project.mainTree.selected;
+        let datas = [{
+            type:'bills',
+            data:{
+                ID:selected.data.ID,
+                name:data.name,
+                code:data.code,
+                unit:data.unit
+            }
+          }]
+          await projectObj.project.syncUpdateNodesAndRefresh(datas);
+    })
+})

+ 14 - 3
web/building_saas/main/js/views/std_billsGuidance_lib.js

@@ -383,7 +383,7 @@ const billsGuidance = (function () {
     }
     //初始选择清单指引库
     //@param {Number}libID @return {void}
-    function libInitSel(libID){
+    function libInitSel(libID,rcallback){
         //获取清单
         $.bootstrapLoading.start();
         CommonAjax.post('/billsGuidance/api/getLibWithBills', {libID: libID, isGuidanceLib: false}, function(rstData){
@@ -393,6 +393,7 @@ const billsGuidance = (function () {
                 if(doAfterLoadGuidance){
                     doAfterLoadGuidance();
                 }
+                if(rcallback)rcallback();
                 $.bootstrapLoading.end();
             };
             //获取清单库中的工作内容和项目特征
@@ -403,7 +404,7 @@ const billsGuidance = (function () {
     }
     //初始化清单指引库
     //@param {Array}libDats @return {void}
-    function initLibs(libDatas){
+    function initLibs(libDatas,callback){
         libSel.empty();
         if(!libDatas){
             return;
@@ -417,7 +418,7 @@ const billsGuidance = (function () {
             libSel.append(opt);
         }
         //初始默认选择
-        libInitSel(libSel.select().val());
+        libInitSel(libSel.select().val(),callback);
     }
     //初始化视图
     //@param {void} @return {void}
@@ -452,6 +453,15 @@ const billsGuidance = (function () {
             TREE_SHEET_HELPER.refreshNodesVisible(bills.tree.roots, billsSheet, true);
         });
     }
+
+    function initBillsLibs(callback){
+        if(libSel.children().length === 0 && !$(this).hasClass('disabled')){
+            initLibs(projectObj.project.projectInfo.engineeringInfo.bill_lib,callback);
+        }else{
+            callback();
+        }
+    }
+    
     //各按钮监听事件
     //@return {void}
     function bindBtn(){
@@ -577,6 +587,7 @@ const billsGuidance = (function () {
         bindBtn,
         refreshWorkBook,
         locateAtBills,
+        initBillsLibs,
         bills
     };
 })();