Browse Source

部位台账,表格复制调整

MaiXinRong 2 years ago
parent
commit
8b747cdf27
3 changed files with 29 additions and 9 deletions
  1. 3 0
      app/public/js/ledger.js
  2. 22 0
      app/public/js/spreadjs_rela/spreadjs_zh.js
  3. 4 9
      app/public/js/stage_bwtz.js

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

@@ -1070,9 +1070,12 @@ $(document).ready(function() {
     ledgerSpread.bind(spreadNS.Events.SelectionChanged, treeOperationObj.selectionChanged);
     ledgerSpread.bind(spreadNS.Events.TopRowChanged, treeOperationObj.topRowChanged);
 
+    console.log(ledgerSpread.options);
     ledgerSpread.bind(spreadNS.Events.ClipboardChanging, function (e, info) {
         const copyText = SpreadJsObj.getFilterCopyText(info.sheet);
         SpreadJsObj.Clipboard.setCopyData(copyText);
+        info.copyData.text = copyText;
+        info.copyData.html = SpreadJsObj.getFilterCopyHTML(info.sheet);
     });
     if (!ledgerSpreadSetting.readOnly) {
         ledgerSpread.bind(spreadNS.Events.SelectionChanged, function (e, info) {

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

@@ -2738,10 +2738,32 @@ const SpreadJsObj = {
         const getAnalysisPasteHtml = function () {
             return SpreadJsObj.analysisPasteHtml(cHtml);
         };
+        const setSysClipboard = function(text) {
+            let textArea = document.createElement("textarea");
+            textArea.style.position = 'fixed';
+            textArea.style.top = 0;
+            textArea.style.left = 0;
+            textArea.style.width = '2em';
+            textArea.style.height = '2em';
+            textArea.style.padding = 0;
+            textArea.style.border = 'none';
+            textArea.style.outline = 'none';
+            textArea.style.boxShadow = 'none';
+            textArea.style.background = 'transparent';
+            textArea.value = text;
+            document.body.appendChild(textArea);
+            textArea.select();
+            try {
+                document.execCommand('copy');
+            } catch (err) {
+            }
+            document.body.removeChild(textArea);
+        };
         return {
             setCopyData, getPasteData, clearData,
             setSheetFilterCopyData,
             getAnalysisPasteText, getAnalysisPasteHtml,
+            setSysClipboard
         }
     })(),
 };

+ 4 - 9
app/public/js/stage_bwtz.js

@@ -90,16 +90,11 @@ $(document).ready(() => {
     xmjSpread.bind(spreadNS.Events.SelectionChanged, function (e, info) {
         unitTreeObj.loadCurUnitData();
     });
-    unitSpread.bind(spreadNS.Events.SelectionChanged, function (e, info) {
-        console.log(SpreadJsObj.getSelectObject(info.sheet));
+    xmjSpread.bind(spreadNS.Events.ClipboardChanged, function (e, info) {
+        SpreadJsObj.Clipboard.setSysClipboard(SpreadJsObj.getFilterCopyText(info.sheet));
     });
-    xmjSpread.bind(spreadNS.Events.ClipboardChanging, function (e, info) {
-        const copyText = SpreadJsObj.getFilterCopyText(info.sheet);
-        SpreadJsObj.Clipboard.setCopyData(copyText);
-    });
-    unitSpread.bind(spreadNS.Events.ClipboardChanging, function (e, info) {
-        const copyText = SpreadJsObj.getFilterCopyText(info.sheet);
-        SpreadJsObj.Clipboard.setCopyData(copyText);
+    unitSpread.bind(spreadNS.Events.ClipboardChanged, function (e, info) {
+        SpreadJsObj.Clipboard.setSysClipboard(SpreadJsObj.getFilterCopyText(info.sheet));
     });
     const loadData = function (dataType) {
         postData(window.location.pathname + '/load', {filter: dataType}, function (result) {