Browse Source

台账分解、台账修订、计量台账,计量单元,复制粘贴超过已有列数时,删除多余粘贴列数据

maixinrong 5 years ago
parent
commit
51afe88c64

+ 6 - 0
app/public/js/ledger.js

@@ -1334,6 +1334,7 @@ $(document).ready(function() {
          * 加载计量单元 根据当前台账选择节点
          * 加载计量单元 根据当前台账选择节点
          */
          */
         loadCurPosData: function () {
         loadCurPosData: function () {
+            //spreadJsObj.reinitSheet(posSpread.getActiveSheet());
             const node = treeOperationObj.getSelectNode(ledgerSpread.getActiveSheet());
             const node = treeOperationObj.getSelectNode(ledgerSpread.getActiveSheet());
             if (node) {
             if (node) {
                 const posData = pos.ledgerPos[itemsPre + node.id] || [];
                 const posData = pos.ledgerPos[itemsPre + node.id] || [];
@@ -1518,6 +1519,9 @@ $(document).ready(function() {
          * @param info
          * @param info
          */
          */
         clipboardPasted: function (e, info) {
         clipboardPasted: function (e, info) {
+            if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
+                info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
+            }
             const node = treeOperationObj.getSelectNode(ledgerSpread.getActiveSheet());
             const node = treeOperationObj.getSelectNode(ledgerSpread.getActiveSheet());
             if (node.code && (node.code !== '')) {
             if (node.code && (node.code !== '')) {
                 toastr.error('项目节不可含有清单明细');
                 toastr.error('项目节不可含有清单明细');
@@ -1548,6 +1552,8 @@ $(document).ready(function() {
                     for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
                     for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
                         const curCol = info.cellRange.col + iCol;
                         const curCol = info.cellRange.col + iCol;
                         const colSetting = info.sheet.zh_setting.cols[curCol];
                         const colSetting = info.sheet.zh_setting.cols[curCol];
+                        if (!colSetting) continue;
+                        
                         posData[colSetting.field] = trimInvalidChar(info.sheet.getText(curRow, curCol));
                         posData[colSetting.field] = trimInvalidChar(info.sheet.getText(curRow, curCol));
 
 
                         if (colSetting.type === 'Number') {
                         if (colSetting.type === 'Number') {

+ 6 - 0
app/public/js/revise.js

@@ -1199,6 +1199,10 @@ $(document).ready(() => {
          * @param info
          * @param info
          */
          */
         clipboardPasted: function (e, info) {
         clipboardPasted: function (e, info) {
+            if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
+                info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
+            }
+
             const node = SpreadJsObj.getSelectObject(billsSheet);
             const node = SpreadJsObj.getSelectObject(billsSheet);
             if (node.code && (node.code !== '')) {
             if (node.code && (node.code !== '')) {
                 toastr.error('项目节不可含有节点明细');
                 toastr.error('项目节不可含有节点明细');
@@ -1233,6 +1237,8 @@ $(document).ready(() => {
                 for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
                 for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
                     const curCol = info.cellRange.col + iCol;
                     const curCol = info.cellRange.col + iCol;
                     const colSetting = info.sheet.zh_setting.cols[curCol];
                     const colSetting = info.sheet.zh_setting.cols[curCol];
+                    if (!colSetting) continue;
+                    
                     posData[colSetting.field] = trimInvalidChar(info.sheet.getText(curRow, curCol));
                     posData[colSetting.field] = trimInvalidChar(info.sheet.getText(curRow, curCol));
                     if (colSetting.type === 'Number') {
                     if (colSetting.type === 'Number') {
                         const num = _.toNumber(posData[colSetting.field]);
                         const num = _.toNumber(posData[colSetting.field]);

+ 10 - 0
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -322,6 +322,16 @@ const SpreadJsObj = {
             sheet.defaults.rowHeight = sheet.zh_setting.defaultRowHeight;
             sheet.defaults.rowHeight = sheet.zh_setting.defaultRowHeight;
         }
         }
     },
     },
+    reinitSheetHeader: function (sheet) {
+        this.beginMassOperation(sheet);
+        if (sheet.zh_setting.headColWidth) {
+            for (const [i, w] of sheet.zh_setting.headColWidth.entries()) {
+                sheet.setColumnWidth(i, w, spreadNS.SheetArea.rowHeader);
+            }
+        }
+        this._initSheetHeader(sheet);
+        this.endMassOperation(sheet);
+    },
     /**
     /**
      * 初始化sheet, 设置sheet.zh_setting, 并初始化表头
      * 初始化sheet, 设置sheet.zh_setting, 并初始化表头
      * @param {GC.Spread.Sheets.Worksheet} sheet
      * @param {GC.Spread.Sheets.Worksheet} sheet

+ 6 - 0
app/public/js/stage.js

@@ -1142,6 +1142,10 @@ $(document).ready(() => {
         },
         },
         clipboardPasted: function (e, info) {
         clipboardPasted: function (e, info) {
             if (info.sheet.zh_setting) {
             if (info.sheet.zh_setting) {
+                if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
+                    info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
+                }
+
                 const data = { updateType: '', updateData: [], };
                 const data = { updateType: '', updateData: [], };
                 const sortData = info.sheet.zh_data;
                 const sortData = info.sheet.zh_data;
                 const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
                 const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
@@ -1164,6 +1168,8 @@ $(document).ready(() => {
                         for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
                         for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
                             const curCol = info.cellRange.col + iCol;
                             const curCol = info.cellRange.col + iCol;
                             const colSetting = info.sheet.zh_setting.cols[curCol];
                             const colSetting = info.sheet.zh_setting.cols[curCol];
+                            if (!colSetting) continue;
+
                             newData[colSetting.field] = trimInvalidChar(info.sheet.getText(curRow, curCol));
                             newData[colSetting.field] = trimInvalidChar(info.sheet.getText(curRow, curCol));
                             if (colSetting.type === 'Number') {
                             if (colSetting.type === 'Number') {
                                 const num = _.toNumber(newData[colSetting.field]);
                                 const num = _.toNumber(newData[colSetting.field]);