Prechádzať zdrojové kódy

1 台账分解,控制剪切
2 台账分解,工具栏,复制,剪切按钮,添加内容至剪切板

MaiXinRong 5 rokov pred
rodič
commit
e5d995b7bd
3 zmenil súbory, kde vykonal 39 pridanie a 8 odobranie
  1. 31 0
      app/public/js/global.js
  2. 7 4
      app/public/js/ledger.js
  3. 1 4
      app/public/js/stage.js

+ 31 - 0
app/public/js/global.js

@@ -373,3 +373,34 @@ function removeLocalCache(key) {
     }
     return storage.removeItem(key);
 }
+
+//params: 需要复制的对象(元素)
+function copyToClipboard( text ) {
+    var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
+    var aux =  document.createElement('textarea');// 创建元素用于复制
+    // Prevent zooming on iOS
+    aux.style.fontSize = '12pt';
+    // Reset box model
+    aux.style.border = '0';
+    aux.style.padding = '0';
+    aux.style.margin = '0';
+    // Move element out of screen horizontally
+    aux.style.position = 'absolute';
+    aux.style[isRTL ? 'right' : 'left'] = '-9999px';
+    // Move element to the same position vertically
+    var yPosition = window.pageYOffset || document.documentElement.scrollTop;
+    aux.style.top = yPosition + 'px';
+
+    aux.setAttribute('readonly', '');
+    // 设置元素内容
+    aux.value = text;
+    // 将元素插入页面进行调用
+    document.body.appendChild(aux);
+    // 复制内容
+    aux.select();
+    aux.setSelectionRange(0, text.length);
+    // 将内容复制到剪贴板
+    document.execCommand("copy", true);
+    // 删除创建元素
+    document.body.removeChild(aux);
+}

+ 7 - 4
app/public/js/ledger.js

@@ -574,6 +574,10 @@ $(document).ready(function() {
         },
         cut: function (sheet, sel, callback) {
             if (!sheet || !sel) return;
+            if (sel.colCount >= sheet.zh_setting.cols.length) {
+                toast('请勿选中整行剪切', 'warnning');
+                return;
+            }
 
             const sortData = SpreadJsObj.getSortData(sheet), datas = [];
             for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
@@ -605,7 +609,7 @@ $(document).ready(function() {
 
             if (datas.length > 0) {
                 postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
-                    const refreshNode = tree.loadPostData(result);
+                    const refreshNode = sheet.zh_tree.loadPostData(result);
                     callback();
                     treeOperationObj.refreshTree(sheet, refreshNode);
                 });
@@ -623,10 +627,9 @@ $(document).ready(function() {
         ledgerSpread.bind(GC.Spread.Sheets.Events.ClipboardPasted, treeOperationObj.clipboardPasted);
         SpreadJsObj.addDeleteBind(ledgerSpread, treeOperationObj.deletePress);
         ledgerSpread.bind(GC.Spread.Sheets.Events.ClipboardChanging, function (e, info) {
+            //info.cancel = true;
             const copyText = SpreadJsObj.getFilterCopyText(info.sheet);
-        });
-        ledgerSpread.bind(GC.Spread.Sheets.Events.ClipboardChanged, function (e, info) {
-            console.log(info.copyData.text);
+            copyToClipboard(copyText);
         });
         ledgerSpread.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (e, info) {
         });

+ 1 - 4
app/public/js/stage.js

@@ -698,10 +698,7 @@ $(document).ready(() => {
             }
         },
         measureAllPosInNode(node, ratio = 1) {
-            const posterity = stageTree.getPosterity(node);
-            console.log(node);
-            console.log(posterity.length);
-            console.log(posterity);
+            const posterity = stageTree.getPosterity(node)
             const data = {updateType: 'update', updateData: []};
             for (const p of posterity) {
                 if (p.children && p.children.length > 0) continue;