Quellcode durchsuchen

feat: 清单模板编辑器增加清单预算标记 (#GLY-2655)

vian vor 1 Jahr
Ursprung
Commit
a58629bdc5

+ 1 - 0
modules/all_models/bills_template_items.js

@@ -37,6 +37,7 @@ let BillsTemplateSchema = {
     itemCharacterText: String,
     jobContentText: String,
     cantDelete: Boolean,
+    isBillBudget: Boolean, // 清单预算标记
     //费率ID
     feeRateID: Number,
     quantity: String,

+ 32 - 30
public/web/tree_sheet/tree_sheet_helper.js

@@ -5,7 +5,7 @@
 var TREE_SHEET_HELPER = {
     getObjPos: function (obj) {
         let target = obj;
-        let pos = {x: obj.offsetLeft, y: obj.offsetTop};
+        let pos = { x: obj.offsetLeft, y: obj.offsetTop };
 
         target = obj.offsetParent;
         while (target) {
@@ -24,7 +24,7 @@ var TREE_SHEET_HELPER = {
         setting.pos = this.getObjPos(obj);
     },
     createNewSpread: function (obj) {
-        var spread = new GC.Spread.Sheets.Workbook(obj, {sheetCount: 1});
+        var spread = new GC.Spread.Sheets.Workbook(obj, { sheetCount: 1 });
         spread.options.tabStripVisible = false;
         spread.options.scrollbarMaxAlign = true;
         spread.options.cutCopyIndicatorVisible = false;
@@ -138,7 +138,9 @@ var TREE_SHEET_HELPER = {
                     cell.value(getFieldText2());
                 }
                 if (colSetting.data.cellType && Object.prototype.toString.apply(colSetting.data.cellType) !== "[object String]") {
-                    cell.cellType(colSetting.data.cellType);
+                    if (colSetting.needCellType === undefined || colSetting.needCellType(node)) {
+                        cell.cellType(colSetting.data.cellType);
+                    }
                 }
                 if (colSetting.readOnly) {
                     if (Object.prototype.toString.apply(colSetting.readOnly) === "[object Function]") {
@@ -156,11 +158,11 @@ var TREE_SHEET_HELPER = {
             }
         });
     },
-    refreshChildrenVisiable:function(sheet,tree,node,row,visiable){
+    refreshChildrenVisiable: function (sheet, tree, node, row, visiable) {
         let iCount = node.posterityCount(), i, child;
         for (i = 0; i < iCount; i++) {
-            child = tree.items[row + i +1];
-            sheet.setRowVisible(row + i + 1, visiable?visiable:child.visible, GC.Spread.Sheets.SheetArea.viewport);
+            child = tree.items[row + i + 1];
+            sheet.setRowVisible(row + i + 1, visiable ? visiable : child.visible, GC.Spread.Sheets.SheetArea.viewport);
         }
         sheet.invalidateLayout();
     },
@@ -311,16 +313,16 @@ var TREE_SHEET_HELPER = {
                 hitinfo.sheet.repaint();
             }
         };
-        TreeNodeCellType.prototype.processMouseEnter = function(hitinfo){
-            if(hitinfo.sheet.name() === 'stdBillsGuidance_bills'){
-                TREE_SHEET_HELPER.delayShowTips(hitinfo,setting);
+        TreeNodeCellType.prototype.processMouseEnter = function (hitinfo) {
+            if (hitinfo.sheet.name() === 'stdBillsGuidance_bills') {
+                TREE_SHEET_HELPER.delayShowTips(hitinfo, setting);
             }
         };
         TreeNodeCellType.prototype.processMouseLeave = function (hitinfo) {
             TREE_SHEET_HELPER.hideTipsDiv();
         };
 
-        let TipCellType = function () {};
+        let TipCellType = function () { };
         TipCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
         TipCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
             return {
@@ -380,10 +382,10 @@ var TREE_SHEET_HELPER = {
             TREE_SHEET_HELPER.refreshNodesVisible(tree.roots, sheet, true);
         });
     },
-    showTipsDiv:function (text,setting,hitinfo) {
+    showTipsDiv: function (text, setting, hitinfo) {
         if (text && text !== '') {
-            if(text) text = replaceAll(/[\n]/,'<br>',text);
-            if(!this._fixedTipElement){
+            if (text) text = replaceAll(/[\n]/, '<br>', text);
+            if (!this._fixedTipElement) {
                 let div = $('#fixedTip')[0];
                 if (!div) {
                     div = document.createElement("div");
@@ -413,20 +415,20 @@ var TREE_SHEET_HELPER = {
                 this._toolTipElement = div;
                 $(this._toolTipElement).width('');
                 //实时读取位置信息
-                if(hitinfo.sheet && hitinfo.sheet.getParent().qo){
+                if (hitinfo.sheet && hitinfo.sheet.getParent().qo) {
                     setting.pos = SheetDataHelper.getObjPos(hitinfo.sheet.getParent().qo);
                 }
                 $(this._toolTipElement).html(`<span>${text}</span><div class="triangle-border tb-border_up"></div><div class="triangle-border tb-background_up"></div>`);
                 //清单指引、清单库做特殊处理
-                if($(hitinfo.sheet.name === 'stdBillsGuidance_bills')){
+                if ($(hitinfo.sheet.name === 'stdBillsGuidance_bills')) {
                     $(this._toolTipElement).html(`<span>${text}</span>`);
                     let divWidth = $(this._fixedTipElement).width(),
                         divHeight = $(this._fixedTipElement).height();
-                    if(divWidth > 600){
+                    if (divWidth > 600) {
                         divWidth = 590;
                         $(this._toolTipElement).width(divWidth);
                     }
-                    let top = setting.pos.y  + hitinfo.y - divHeight / 2 < 0 ? 0 : setting.pos.y  + hitinfo.y - divHeight / 2;
+                    let top = setting.pos.y + hitinfo.y - divHeight / 2 < 0 ? 0 : setting.pos.y + hitinfo.y - divHeight / 2;
                     $(this._toolTipElement).css("top", top).css("left", hitinfo.x + 20);
                 } else {
                     //计算显示的初始位置
@@ -435,8 +437,8 @@ var TREE_SHEET_HELPER = {
                      let left =  setting.pos.x + hitinfo.cellRect.x;
                      $(this._toolTipElement).css("top", top).css("left", left);*/
                     //显示在下方,三角形指
-                    let top = setting.pos.y  + hitinfo.cellRect.y+26;
-                    let left =  setting.pos.x + hitinfo.cellRect.x;
+                    let top = setting.pos.y + hitinfo.cellRect.y + 26;
+                    let left = setting.pos.x + hitinfo.cellRect.x;
                     $(this._toolTipElement).css("top", top).css("left", left);
 
                 }
@@ -445,7 +447,7 @@ var TREE_SHEET_HELPER = {
             }
         }
     },
-    hideTipsDiv:function () {
+    hideTipsDiv: function () {
         TREE_SHEET_HELPER.tipTimeStamp = +new Date();//这个是为了造价书清单编号树节点的那个延时显示而打的时间戳,防止已经要隐藏的提示框,延时显示
         let me = TREE_SHEET_HELPER;
         TREE_SHEET_HELPER.tipDiv = 'hide';
@@ -455,31 +457,31 @@ var TREE_SHEET_HELPER = {
         }
         TREE_SHEET_HELPER.tipDivCheck();//延时检查:当tips正在show的时候,就调用了hide方法,会导致tips一直存在,所以设置一个超时处理
     },
-    tipDivCheck(){
+    tipDivCheck() {
         setTimeout(function () {
             let tips = $('#autoTip');
-            if(TREE_SHEET_HELPER.tipDiv == 'show'){
+            if (TREE_SHEET_HELPER.tipDiv == 'show') {
                 return;
-            } else if(TREE_SHEET_HELPER.tipDiv == 'hide'&&tips){
+            } else if (TREE_SHEET_HELPER.tipDiv == 'hide' && tips) {
                 tips.hide();
                 TREE_SHEET_HELPER._toolTipElement = null;
             }
-        },600)
+        }, 600)
     },
-    delayShowTips:function(hitinfo,setting,tips){//延时显示
+    delayShowTips: function (hitinfo, setting, tips) {//延时显示
         let delayTimes = 500; //延时时间
         let now_timeStamp = +new Date();
         TREE_SHEET_HELPER.tipTimeStamp = now_timeStamp;
         setTimeout(function () {
-            if(now_timeStamp - TREE_SHEET_HELPER.tipTimeStamp == 0){//鼠标停下的时候才显示
+            if (now_timeStamp - TREE_SHEET_HELPER.tipTimeStamp == 0) {//鼠标停下的时候才显示
                 let tag = hitinfo.sheet.getTag(hitinfo.row, hitinfo.col);
-                if(tips && tips !=""){ //有tips的话优先显示tips
+                if (tips && tips != "") { //有tips的话优先显示tips
                     tag = tips;
                 }
-                if(tag&&tag!=''){
-                    TREE_SHEET_HELPER.showTipsDiv(tag,setting,hitinfo);
+                if (tag && tag != '') {
+                    TREE_SHEET_HELPER.showTipsDiv(tag, setting, hitinfo);
                 }
             }
-        },delayTimes);
+        }, delayTimes);
     }
 };

+ 41 - 5
web/maintain/bill_template_lib/js/bills_template_edit.js

@@ -132,6 +132,30 @@ let TEMPLATE_BILLS_SETTING = {
         },
     },
     {
+        width: 65,
+        readOnly: locked,
+        head: {
+            titleNames: ["清单\n预算标记"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"],
+        },
+        data: {
+            field: "isBillBudget",
+            vAlign: 0,
+            hAlign: 1,
+            font: "Arail",
+        },
+        needCellType: (node) => {
+            return [1, 8].includes(node.data.type);
+        },
+        readOnly: (node) => {
+            return ![1, 8].includes(node.data.type);
+        }
+    },
+    {
         width: 200,
         readOnly: locked,
         head: {
@@ -382,6 +406,8 @@ $(document).ready(function () {
             col.data.cellType = getFixedFlagCellType();
         } else if (col.data.field === 'cantDelete' && TEMPLATE_BILLS_SETTING.cols.indexOf(col) !== TEMPLATE_BILLS_SETTING.treeCol) {
             col.data.cellType = new GC.Spread.Sheets.CellTypes.CheckBox();
+        } else if (col.data.field === 'isBillBudget' && TEMPLATE_BILLS_SETTING.cols.indexOf(col) !== TEMPLATE_BILLS_SETTING.treeCol) {
+            col.data.cellType = new GC.Spread.Sheets.CellTypes.CheckBox();
         }
     }
 
@@ -401,21 +427,31 @@ $(document).ready(function () {
         }
         const fieldName = controller.setting.cols[info.col].data.field;
         var node = controller.tree.items[info.row];
-        if (node && fieldName === 'cantDelete') {
+        if (node && ['cantDelete', 'isBillBudget'].includes(fieldName)) {
             const isChecked = Boolean(info.sheet.getValue(info.row, info.col));
             const data = { type: "update", data: { ID: node.getID() } };
             setFee(data.data, fieldName, isChecked);
-            console.log(isChecked);
             const updateData = [data];
+            const refreshNodes = [node];
+            if (fieldName === 'isBillBudget') {
+                const subNodes = node.getPosterity();
+                refreshNodes.push(...subNodes);
+                subNodes.forEach(subNode => {
+                    updateData.push({ type: "update", data: { ID: subNode.getID(), isBillBudget: isChecked } });
+                });
+            }
             CommonAjax.post(
                 updateUrl,
                 updateData,
                 function (data) {
-                    setFee(node.data, fieldName, isChecked);
-                    controller.refreshTreeNode([node], false);
+                    //setFee(node.data, fieldName, isChecked);
+                    refreshNodes.forEach(n => {
+                        setFee(n.data, fieldName, isChecked);
+                    });
+                    controller.refreshTreeNode(refreshNodes, false);
                 },
                 function () {
-                    controller.refreshTreeNode([node], false);
+                    controller.refreshTreeNode(refreshNodes, false);
                 }
             );
         }