فهرست منبع

feat: 清单精灵后台,增加默认值列

vian 3 سال پیش
والد
کامیت
6d0e0d0d38
2فایلهای تغییر یافته به همراه52 افزوده شده و 15 حذف شده
  1. 1 0
      modules/all_models/std_billsGuidance_items.js
  2. 51 15
      web/maintain/billsGuidance_lib/js/billsGuidance.js

+ 1 - 0
modules/all_models/std_billsGuidance_items.js

@@ -26,6 +26,7 @@ const stdBillsGuidanceItems = new Schema({
     required: {type: Boolean, default: false},
     unit: String, // 单位,辅助运距功能
     isMaterial: {type: Boolean, default: false}, // 材料,辅助替换材料规格
+    isDefaultOption: {type: Boolean, default: false}, // 是否是默认选项
 }, {versionKey: false});
 
 mongoose.model('std_billsGuidance_items', stdBillsGuidanceItems, 'std_billsGuidance_items');

+ 51 - 15
web/maintain/billsGuidance_lib/js/billsGuidance.js

@@ -239,7 +239,25 @@ const billsGuidance = (function () {
                     hAlign: 1,
                     font: "Arial"
                 }
-            }
+            },
+            {
+                width: 40,
+                readOnly: true,
+                head: {
+                    titleNames: ["默认值"],
+                    spanCols: [1],
+                    spanRows: [1],
+                    vAlign: [1],
+                    hAlign: [1],
+                    font: ["Arial"]
+                },
+                data: {
+                    field: "isDefaultOption",
+                    vAlign: 1,
+                    hAlign: 1,
+                    font: "Arial"
+                }
+            },
         ]
         },
         headers: [
@@ -248,6 +266,7 @@ const billsGuidance = (function () {
             {name: '输出特征', dataCode: 'outputItemCharacter', width: 40, vAlign: 'center', hAlign: 'center'},
             {name: '必填', dataCode: 'required', width: 40, vAlign: 'center', hAlign: 'center'},
             {name: '材料', dataCode: 'isMaterial', width: 40, vAlign: 'center', hAlign: 'center'},
+            {name: '默认值', dataCode: 'isDefaultOption', width: 40, vAlign: 'center', hAlign: 'center'},
         ],
         events: {
             SelectionChanged: function (sender, info) {
@@ -455,6 +474,11 @@ const billsGuidance = (function () {
         return node && node.depth() % 2 === 0 && _isDef(node.data.type) && node.data.type === itemType.job
     }
 
+    // 是否是选项行
+    function isOptionNode(node) {
+        return node && node.depth() % 2 === 1 && _isDef(node.data.type) && node.data.type === itemType.job
+    }
+
     //渲染时方法,停止渲染
     //@param {Object}sheet {Function}func @return {void}
     function renderSheetFunc(sheet, func){
@@ -610,23 +634,34 @@ const billsGuidance = (function () {
         // const checkBoxType = locked ? sheetCommonObj.getReadOnlyCheckBox() : sheetCommonObj.getCheckBox();
         const checkBoxType = new GC.Spread.Sheets.CellTypes.CheckBox();
         const baseType = new GC.Spread.Sheets.CellTypes.Base();
+        const outputItemCol = guideItem.headers.findIndex(item => item.dataCode === 'outputItemCharacter');
+        const requiredCol = guideItem.headers.findIndex(item => item.dataCode === 'required');
+        const materialCol = guideItem.headers.findIndex(item => item.dataCode === 'isMaterial');
+        const defaultOption = guideItem.headers.findIndex(item => item.dataCode === 'isDefaultOption');
         renderSheetFunc(sheet, function () {
             nodes.forEach(node => {
                 const row = node.serialNo();
+                if (isOptionNode(node)) {
+                    sheet.setCellType(row, defaultOption, checkBoxType);
+                    sheet.setValue(row, defaultOption, node.data.isDefaultOption || false);
+                } else {
+                    sheet.setCellType(row, defaultOption, baseType);
+                    sheet.setValue(row, defaultOption, '');
+                }
                 if (isProcessNode(node)) {
-                    sheet.setCellType(row, 2, checkBoxType);
-                    sheet.setCellType(row, 3, checkBoxType);
-                    sheet.setCellType(row, 4, checkBoxType);
-                    sheet.setValue(row, 2, node.data.outputItemCharacter || false);
-                    sheet.setValue(row, 3, node.data.required || false);
-                    sheet.setValue(row, 4, node.data.isMaterial || false);
+                    sheet.setCellType(row, outputItemCol, checkBoxType);
+                    sheet.setCellType(row, requiredCol, checkBoxType);
+                    sheet.setCellType(row, materialCol, checkBoxType);
+                    sheet.setValue(row, outputItemCol, node.data.outputItemCharacter || false);
+                    sheet.setValue(row, requiredCol, node.data.required || false);
+                    sheet.setValue(row, materialCol, node.data.isMaterial || false);
                 } else {
-                    sheet.setCellType(row, 2, baseType);
-                    sheet.setCellType(row, 3, baseType);
-                    sheet.setCellType(row, 4, baseType);
-                    sheet.setValue(row, 2, '');
-                    sheet.setValue(row, 3, '');
-                    sheet.setValue(row, 4, '');
+                    sheet.setCellType(row, outputItemCol, baseType);
+                    sheet.setCellType(row, requiredCol, baseType);
+                    sheet.setCellType(row, materialCol, baseType);
+                    sheet.setValue(row, outputItemCol, '');
+                    sheet.setValue(row, requiredCol, '');
+                    sheet.setValue(row, materialCol, '');
                 }
             })
         });
@@ -1249,7 +1284,7 @@ const billsGuidance = (function () {
                     syncDatas.push({node: node, text: text, field, cell});
                     updateDatas.push({updateType: updateType.update, findData: {ID: node.getID()}, updateData: {[field]: text}});
                 }
-            } else if (field === 'outputItemCharacter' || field === 'required' || field === 'isMaterial') {
+            } else if (field === 'outputItemCharacter' || field === 'required' || field === 'isMaterial' || field === 'isDefaultOption') {
                 const val = !sheet.getValue(cell.row, cell.col);
                 sheet.setValue(cell.row, cell.col, val);
                 syncDatas.push({node: node, text: val, field, cell });
@@ -1309,6 +1344,7 @@ const billsGuidance = (function () {
             updateDatas.push({updateType: updateType.create, updateData: newDataIndex[i]});
         }
         updateGuideItems(updateDatas, function () {
+            const outputItemCol = guideItem.headers.findIndex(item => item.dataCode === 'outputItemCharacter');
             for(let updateData of updateDatas){
                 if(updateData.updateType === updateType.create){
                     let newNode = controller.insertByIDS(updateData.updateData.ID, updateData.updateData.ParentID, updateData.updateData.NextSiblingID);
@@ -1317,7 +1353,7 @@ const billsGuidance = (function () {
                     const row = newNode.serialNo();
                     sheet.setValue(row, 0, newNode.data.name);
                     if (newNode.data.outputItemCharacter !== undefined) {
-                        sheet.setValue(row, 2, newNode.data.outputItemCharacter);
+                        sheet.setValue(row, outputItemCol, newNode.data.outputItemCharacter);
                     }
                     setProcessNodes(sheet, [newNode]);
                     refreshBtn(newNode);