Browse Source

feat: 清单精灵后台,增加输出特征、必填列

vian 3 years ago
parent
commit
db35084598

+ 3 - 1
modules/all_models/std_billsGuidance_items.js

@@ -21,7 +21,9 @@ const stdBillsGuidanceItems = new Schema({
     comment: String, //备注
     type: Number, //0:工作内容 1:定额
     rationID: {type: Number, default: null}, //定额类型时
-    deleted: {type: Boolean, default: false}
+    deleted: {type: Boolean, default: false},
+    outputItemCharacter: {type: Boolean, default: false},
+    required: {type: Boolean, default: false},
 }, {versionKey: false});
 
 mongoose.model('std_billsGuidance_items', stdBillsGuidanceItems, 'std_billsGuidance_items');

+ 14 - 0
public/web/sheet/sheet_common.js

@@ -170,6 +170,20 @@ var sheetCommonObj = {
         sheet.resumePaint();
         //me.shieldAllCells(sheet);
     },
+    getCheckBox(threeState = false){
+        var c = new GC.Spread.Sheets.CellTypes.CheckBox();
+        c.isThreeState(threeState);
+        return c
+    },
+    // 无法勾选的复选框
+    getReadOnlyCheckBox (threeState = false) {
+        function ReadOnlyCheckBox() {}
+        ReadOnlyCheckBox.prototype = this.getCheckBox(threeState);
+        ReadOnlyCheckBox.prototype.processMouseUp = function () {
+            return;
+        };
+        return new ReadOnlyCheckBox();
+    },
     showRowData:function (sheet,setting,row,data,distTypeTree=null) {
         let ch = GC.Spread.Sheets.SheetArea.viewport;
         for (var col = 0; col < setting.header.length; col++) {

+ 88 - 10
web/maintain/billsGuidance_lib/js/billsGuidance.js

@@ -127,10 +127,49 @@ const billsGuidance = (function () {
                     hAlign: 0,
                     font: "Arial"
                 }
-            }]
+            },
+            {
+                width: 60,
+                readOnly: true,
+                head: {
+                    titleNames: ["输出特征"],
+                    spanCols: [1],
+                    spanRows: [1],
+                    vAlign: [1],
+                    hAlign: [1],
+                    font: ["Arial"]
+                },
+                data: {
+                    field: "outputItemCharacter",
+                    vAlign: 1,
+                    hAlign: 1,
+                    font: "Arial"
+                }
+            },
+            {
+                width: 50,
+                readOnly: true,
+                head: {
+                    titleNames: ["必填"],
+                    spanCols: [1],
+                    spanRows: [1],
+                    vAlign: [1],
+                    hAlign: [1],
+                    font: ["Arial"]
+                },
+                data: {
+                    field: "required",
+                    vAlign: 1,
+                    hAlign: 1,
+                    font: "Arial"
+                }
+            }
+        ]
         },
         headers: [
             {name: '项目指引', dataCode: 'name', width: 400, vAlign: 'center', hAlign: 'left', formatter: '@'},
+            {name: '输出特征', dataCode: 'outputItemCharacter', width: 60, vAlign: 'center', hAlign: 'center'},
+            {name: '必填', dataCode: 'required', width: 50, vAlign: 'center', hAlign: 'center'},
         ],
         events: {
             SelectionChanged: function (sender, info) {
@@ -139,6 +178,9 @@ const billsGuidance = (function () {
             EditEnded: function (sender, args) {
                 edit(args.sheet, [{row: args.row, col: args.col}]);
             },
+            ButtonClicked: function (sender, args) {
+                edit(args.sheet, [{row: args.row, col: args.col}]);
+            },
             RangeChanged: function (sender, args) {
                 edit(args.sheet, args.changedCells);
             }
@@ -341,6 +383,7 @@ const billsGuidance = (function () {
             getItemsByBills(libID, node.data.ID, function (rstData) {
                 initTree(node.guidance, guideSheet, guideItem.treeSetting, rstData);
                 setNodesExpandState(node.guidance.tree.items, curExpandState);
+                showCheckBox(guideSheet, node.guidance.tree.items);
                 renderSheetFunc(guideSheet, function () {
                     TREE_SHEET_HELPER.refreshNodesVisible(node.guidance.tree.roots, guideSheet, true);
                 });
@@ -352,12 +395,32 @@ const billsGuidance = (function () {
         } else{
             setNodesExpandState(node.guidance.tree.items, curExpandState);
             node.guidance.controller.showTreeData();
+            showCheckBox(guideSheet, node.guidance.tree.items);
             //设置底色
             setNodesColor(guideSheet, node.guidance.tree.items);
             //项目指引初始焦点
             guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
         }
     }
+    
+    function showCheckBox(sheet, nodes) {
+        // const checkBoxType = locked ? sheetCommonObj.getReadOnlyCheckBox() : sheetCommonObj.getCheckBox();
+        const checkBoxType = new GC.Spread.Sheets.CellTypes.CheckBox();
+        const baseType = new GC.Spread.Sheets.CellTypes.Base();
+        renderSheetFunc(sheet, function () {
+            nodes.forEach(node => {
+                const row = node.serialNo();
+                if (node.depth() % 2 === 0 && _isDef(node.data.type) && node.data.type === itemType.job) {
+                    sheet.setCellType(row, 1, checkBoxType);
+                    sheet.setCellType(row, 2, checkBoxType);
+                } else {
+                    sheet.setCellType(row, 1, baseType);
+                    sheet.setCellType(row, 2, baseType);
+                }
+            })
+        });
+    }
+
     //设置项目节点展开收起状态:展开全部、收起定额
     //@param {Array}nodes(当前清单下的所有项目指引节点) {Number}expandState(展开全部1或收起定额0).
     function setNodesExpandState(nodes, expandState) {
@@ -897,26 +960,34 @@ const billsGuidance = (function () {
         //同步节点数据
         let syncDatas = [];
         for(let cell of cells){
-            let text = sheet.getValue(cell.row, cell.col);
-            text = text ? text.toString() : '';
-            text = text.replace(deESC, '');
-            sheet.setValue(cell.row, cell.col, text);
+            const field = guideItem.headers[cell.col].dataCode;
             let node = bills.tree.selected.guidance.tree.items[cell.row];
-            if(node.data.name != text){
-                syncDatas.push({node: node, text: text});
-                updateDatas.push({updateType: updateType.update, findData: {ID: node.getID()}, updateData: {name: text}});
+            if (field === 'name') {
+                let text = sheet.getValue(cell.row, cell.col);
+                text = text ? text.toString() : '';
+                text = text.replace(deESC, '');
+                sheet.setValue(cell.row, cell.col, text);
+                if(node.data.name != text){
+                    syncDatas.push({node: node, text: text, field});
+                    updateDatas.push({updateType: updateType.update, findData: {ID: node.getID()}, updateData: {name: text}});
+                }
+            } else if (field === 'outputItemCharacter' || field === 'required') {
+                const val = !sheet.getValue(cell.row, cell.col);
+                sheet.setValue(cell.row, cell.col, val);
+                syncDatas.push({node: node, text: val, field});
+                updateDatas.push({updateType: updateType.update, findData: {ID: node.getID()}, updateData: {[field]: val}});
             }
         }
         if(updateDatas.length > 0){
             updateGuideItems(updateDatas, function () {
                 for(let syncData of syncDatas){
-                    syncData.node.data.name = syncData.text;
+                    syncData.node.data[syncData.field] = syncData.text;
                 }
             }, function () {
                 //失败恢复
                 renderSheetFunc(sheet, function () {
                     for(let syncData of syncDatas){
-                        sheet.setValue(syncData.node.serialNo(), 0, syncData.node.data.name ? syncData.node.data.name : '');
+                        sheet.setValue(syncData.node.serialNo(), 0, syncData.node.data[syncData.field] ? syncData.node.data[syncData.field] : '');
                     }
                 });
             });
@@ -966,6 +1037,7 @@ const billsGuidance = (function () {
                     //同步data
                     Object.assign(newNode.data, updateData.updateData);
                     sheet.setValue(newNode.serialNo(), 0, newNode.data.name);
+                    showCheckBox(sheet, [newNode]);
                     refreshBtn(newNode);
                 }
             }
@@ -1060,6 +1132,7 @@ const billsGuidance = (function () {
             guideItemInitSel(sheet.getActiveRowIndex());
             refreshBtn(bills.tree.selected.guidance.tree.selected);
             setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
+            showCheckBox(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
             $.bootstrapLoading.end();
             guideItem.workBook.focus(true)
         });
@@ -1095,6 +1168,7 @@ const billsGuidance = (function () {
             controller.upLevel();
             refreshBtn(bills.tree.selected.guidance.tree.selected);
             setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
+            showCheckBox(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
             $.bootstrapLoading.end();
             guideItem.workBook.focus(true)//31574
         });
@@ -1119,6 +1193,7 @@ const billsGuidance = (function () {
             controller.downLevel();
             refreshBtn(bills.tree.selected.guidance.tree.selected);
             setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
+            showCheckBox(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
             $.bootstrapLoading.end();
             guideItem.workBook.focus(true)
         });
@@ -1142,6 +1217,7 @@ const billsGuidance = (function () {
             controller.upMove();
             refreshBtn(bills.tree.selected.guidance.tree.selected);
             setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
+            showCheckBox(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
             $.bootstrapLoading.end();
             guideItem.workBook.focus(true)
         });
@@ -1165,6 +1241,7 @@ const billsGuidance = (function () {
             controller.downMove();
             refreshBtn(bills.tree.selected.guidance.tree.selected);
             setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
+            showCheckBox(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
             $.bootstrapLoading.end();
             guideItem.workBook.focus(true)
         });
@@ -1378,6 +1455,7 @@ const billsGuidance = (function () {
             cleanData(guideItem.workBook.getActiveSheet(), guideItem.headers, -1);
             itemObj.controller.showTreeData();
             setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
+            showCheckBox(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
         }, function () {
             $.bootstrapLoading.end();
         });