Selaa lähdekoodia

清单树结构增加工程专业

zhongzewei 7 vuotta sitten
vanhempi
commit
26bb349256

+ 1 - 0
modules/bills_lib/models/bills_lib_schemas.js

@@ -44,6 +44,7 @@ let billsSchema = mongoose.Schema({
     name: String,
     unit: String,
     ruleText: String,
+    engineering: Number,   //工程专业,对应计算程序工程ID
     Expression: String,
     jobs: [],
     items: [],

+ 7 - 1
web/maintain/bills_lib/html/qingdan.html

@@ -351,6 +351,7 @@
         billsTree.loadDatas(datas);
         let controller = TREE_SHEET_CONTROLLER.createNew(billsTree.tree, billsSpread.getActiveSheet(), setting);
         controller.showTreeData();
+        sheetBillsDatas = tools.getsheetDatas(controller.sheet, 'bills', controller);
         setSheet.formatter(billsSpread.getActiveSheet());
         //setTagId
         setTagID(controller, setting);
@@ -581,6 +582,9 @@
             if(recharge){
                 $('#exampleTextarea').val(recharge);
             }
+            else{
+                $('#exampleTextarea').val('');
+            }
         }
     }
 
@@ -628,6 +632,7 @@
             let maxRow = orgRow + rowCount - 1, maxCol = orgCol + colCount -1;
             let markRow = orgRow, colLen = sheet.getColumnCount(GC.Spread.Sheets.SheetArea.viewport);
             let validDatas = tools.getValidDatas(sheet, setting, args);
+            sheet.suspendPaint();
             for(let i =orgRow, j=0; i<= maxRow; i++, j++){
                 let id = sheet.getTag(i, 0);
                 if(id && j< validDatas.length){
@@ -653,11 +658,13 @@
                     sheet.setValue(i, 1, sheetBillsDatas.datasIdx['rowIdx'+ i].name);
                     sheet.setValue(i, 2, sheetBillsDatas.datasIdx['rowIdx'+ i].unit);
                     sheet.setValue(i, 3, sheetBillsDatas.datasIdx['rowIdx'+ i].ruleText);
+                    sheet.setValue(i, 4, sheetBillsDatas.datasIdx['rowIdx'+ i].engineering);
                 }
                 else {
                     sheet.clear(i, 0, 1, sheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport,GC.Spread.Sheets.StorageType.data);
                 }
             }
+            sheet.resumePaint();
             billsAjax.pasteBills(userAccount, billsLibId, validDatas);
             setSheet.setMaxRowCount(sheet, sheetBillsDatas);
         });
@@ -765,7 +772,6 @@
                     });
                     if(flag){
                         serialNoUn ++;
-                        console.log(serialNoUn);
                         uncrossedDatas.push({data: uniqPasteArr[j], serialNo: serialNoUn});
                     }
                     else {

+ 19 - 2
web/maintain/bills_lib/scripts/bills_lib_setting.js

@@ -35,7 +35,7 @@ var billsLibSetting = {
                 hAlign: 0,
                 font: 'Arial'
             },
-            width: 300
+            width: 240
         },
         {
             head: {
@@ -52,7 +52,7 @@ var billsLibSetting = {
                 hAlign: 0,
                 font: 'Arial'
             },
-            width: 160
+            width: 140
         },
         {
             head: {
@@ -70,6 +70,23 @@ var billsLibSetting = {
                 font: 'Arial'
             },
             width: 420
+        },
+        {
+            head: {
+                titleNames: ['工程专业'],
+                spanCols: [1],
+                spanRows: [2],
+                vAlign: [1, 1],
+                hAlign: [1, 1],
+                font: ' Arial'
+            },
+            data: {
+                field: 'engineering',
+                vAlign: 1,
+                hAlign: 1,
+                font: 'Arial'
+            },
+            width: 80
         }
     ],
     headRows: 1,

+ 28 - 38
web/maintain/bills_lib/scripts/db_controller.js

@@ -2,6 +2,7 @@
  * Created by vian on 2017/4/12.
  */
 var dbController = {
+    currentEditData: null,
     insert: function(controller, btn){
         tools.btnClose(btn);
         btn.attr('doing', 'true');
@@ -274,19 +275,24 @@ var dbController = {
     },
 
     editData: function(controller){
+        controller.sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
+            dbController.currentEditData = args.sheet.getValue(args.row, args.col);
+        });
         controller.sheet.bind(GC.Spread.Sheets.Events.EditEnded, function(sender, args){
             var node = controller.tree.selected, updateId, field;
             if(node){
                 updateId = node.getID();
-                billsLibSetting.cols.forEach(function(col, idx){
-                    if(args.col === idx){
-                        field = col.data.field;
-                        node.data[field] = args.editingText;
-                        sheetBillsDatas.datasIdx['rowIdx'+ args.row][field] = args.editingText;
+                field = billsLibSetting.cols[args.col].data.field;
+                if(field === 'engineering'){
+                    if(isNaN(args.editingText) || args.editingText % 1 !== 0){
+                        args.sheet.setValue(args.row, args.col, dbController.currentEditData ? dbController.currentEditData : '');
+                        alert('工程专业只能输入整数!');
+                        return;
                     }
-                });
+                }
+                node.data[field] = args.editingText;
+                sheetBillsDatas.datasIdx['rowIdx'+ args.row][field] = args.editingText;
                 billsAjax.updateBills(userAccount, billsLibId, updateId, field, args.editingText);
-                //sheetBillsDatas = tools.getsheetDatas(controller.sheet, 'bills', controller);
             }
             else {
                 args.sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).value('');
@@ -569,7 +575,6 @@ var tools = {
 
     getValidDatas: function(sheet, setting, args){
         let validDatas = [];
-        const colLen = 4;
         let orgRow = args.cellRange.row, orgCol = args.cellRange.col, rowCount = args.cellRange.rowCount, colCount = args.cellRange.colCount;
         let maxRow = orgRow + rowCount - 1, maxCol = orgCol + colCount -1;
         for(let i =orgRow; i<=maxRow; i++){
@@ -577,45 +582,30 @@ var tools = {
             for(let j= orgCol; j<=maxCol; j++){
                 let value = sheet.getValue(i, j);
                 if(value){
-                    setting.cols.forEach(function(col, colIdx){
+                  /*  setting.cols.forEach(function(col, colIdx){
                         if(colIdx === j){
                             validData[col.data.field] = value;
                         }
-                    });
+                    });*/
+                    if(setting.cols[j].data.field === 'engineering'){
+                        if(!isNaN(value) && value % 1 === 0){
+                            validData[setting.cols[j].data.field] = value;
+                        }
+                    }
+                    else {
+                        validData[setting.cols[j].data.field] = value;
+                    }
                 }
             }
             if(!tools.isEmptyObj(validData)){
                 validDatas.push(validData);
             }
         }
-
-
-
-        //---------------------------------------
-        /*for(let i=orgRow; i<= maxRow; i++){
-            if(tools.getValidRow(sheet, i)){
-                console.log(`validRow: ${i}`);
-                let validData = {code: '', name: '', unit: '', ruleText: ''};
-                for(var j=orgCol; j<=maxCol; j++){
-                    let field;
-                    setting.cols.forEach(function(col, colIdx){
-                        if(colIdx === j){
-                            field = col.data.field;
-                            if(sheet.getValue(i, j)){
-                                validData[field] = sheet.getValue(i, j);
-                            }
-                        }
-                    });
-                    //validData[field] = sheet.getValue(i, j);
-                }
-                validDatas.push(validData);
-            }
-        }*/
         return validDatas;
     },
 
     getValidRow: function(sheet, rowIdx){
-        const colCount = 4;
+        const colCount = 5;
         let isValid = false;
         for(let i=0; i< colCount; i++){
             if(sheet.getValue(rowIdx, i, GC.Spread.Sheets.SheetArea.viewport)){
@@ -1659,7 +1649,7 @@ var jobsController = {
                     field = col.data.field;
                 }
             });
-            if (controller.tree.selected && newData !== me.currentEditData) {
+            if (controller.tree.selected && newData != me.currentEditData) {
                 var isExist = tools.isExist(totalJobs.jobsArr, field, newData);
                 var isRepeat = tools.isRepeat(controller.tree.selected.jobs, field ,newData, 'reference', 'job');
                 //create
@@ -1874,7 +1864,7 @@ var itemsController = {
                     field = col.data.field;
                 }
             });
-            if (controller.tree.selected && newData !== me.currentEditData) {
+            if (controller.tree.selected && newData != me.currentEditData) {
                 var isExist = tools.isExist(totalItems.itemsArr, field, newData);
                 var isRepeat = tools.isRepeat(controller.tree.selected.items, field ,newData, 'reference', 'item');
                 //create
@@ -2194,7 +2184,7 @@ var totalJobsController = {
                     field = col.data.field;
                 }
             });
-            if(newData !== me.currentEditData){
+            if(newData != me.currentEditData){
                 isRepeat = tools.isRepeat(totalJobs.jobsArr, field, newData, 'reference', null);
                 if(!tagId && !isRepeat && newData){//create
                     totalJobsController.createJob(sheet, totalJobs, field, newData, args);
@@ -2282,7 +2272,7 @@ var totalItemsController = {
                     field = col.data.field;
                 }
             });
-            if(newData !== me.currentEditData){
+            if(newData != me.currentEditData){
                 isRepeat = tools.isRepeat(totalItems.itemsArr, field, newData, 'reference', null);
                 if(!tagId && !isRepeat && newData){//create
                     totalItemsController.createItem(sheet, totalItems, field, newData, args);

+ 6 - 10
web/maintain/ration_repository/js/ration.js

@@ -355,11 +355,11 @@ let rationOprObj = {
         let cacheSection = me.getCache();
         let updateArr = [], addArr = [];
         let items = sheetCommonObj.analyzePasteData(me.setting, info);
-        //let failPasteArr = [];
-        for (let i = 0, rowIdx =info.cellRange.row; i < items.length; i++, rowIdx++) {
+        for (let i = 0; i < items.length; i++) {
+            let rowIdx = info.cellRange.row + i;
             if (cacheSection) {
                 if(!me.isValidUnit(items[i], rationUnits)){//无效单位
-                    items[i].unit = typeof cacheSection[rowIdx].unit !== 'undefined' && !cacheSection[rowIdx] ? cacheSection[rowIdx].unit : '';
+                    items[i].unit = rowIdx < cacheSection.length  && typeof cacheSection[rowIdx].unit !== 'undefined' ? cacheSection[rowIdx].unit : '';
                 }
                 if(!cacheSection[rowIdx] && info.cellRange.col === 0 ){
                     if(me.rationsCodes.indexOf(items[i].code) === -1){
@@ -375,7 +375,6 @@ let rationOprObj = {
                         me.rationsCodes.push(items[i].code);
                     }
                     else{
-                        //failPasteArr.push(items[i].code);
                         me.workBook.getSheet(0).setValue(rowIdx, 0, '');
                     }
                 }
@@ -422,19 +421,16 @@ let rationOprObj = {
                             me.setInitPrc(items[i]);
                             addArr.push(items[i]);
                         }
-                        /*else{
-                            failPasteArr.push(items[i]);
-                        }*/
                 }
             }
         };
-       /* if(failPasteArr.length > 0 && !(updateArr.length > 0 || addArr.length > 0)){
-            me.showRationItems(me.currentSectionId);
-        }*/
          if (updateArr.length > 0 || addArr.length > 0) {
              me.mixUpdate = 1;
             me.mixUpdateRequest(updateArr, addArr, []);
         }
+        else{
+             me.getRationItems(me.currentSectionId);
+         }
     },
     setInitPrc: function (obj) {
         obj.labourPrice = 0;