Explorar el Código

Merge branch 'master' of https://git.agilestar.cn/spfm-group/spfm-market-front

daiqisheng hace 3 años
padre
commit
1c6ac5b489
Se han modificado 3 ficheros con 84 adiciones y 0 borrados
  1. 1 0
      package.json
  2. 7 0
      public/index.html
  3. 76 0
      src/pages/main/performance/components/sheet.vue

+ 1 - 0
package.json

@@ -22,6 +22,7 @@
     "jquery-ui": "^1.12.1",
     "js-audio-recorder": "^1.0.7",
     "jsplumb": "^2.15.5",
+    "luckyexcel": "^1.0.1",
     "moment": "^2.29.1",
     "qs": "^6.9.1",
     "tinymce": "^5.7.1",

+ 7 - 0
public/index.html

@@ -8,6 +8,13 @@
   <link rel="icon" href="<%= BASE_URL %>favicon.ico">
   <title>业务服务工作台</title>
   <script src="static/js/crypoto-js.js"></script>
+  
+  <script src="/static/js/luckysheet/plugins/js/plugin.js"></script>
+  <script src="/static/js/luckysheet/luckysheet.umd.js"></script>
+  <link rel='stylesheet' href='/static/js/luckysheet/plugins/css/pluginsCss.css' />
+  <link rel='stylesheet' href='/static/js/luckysheet/plugins/plugins.css' />
+  <link rel='stylesheet' href='/static/js/luckysheet/css/luckysheet.css' />
+  <link rel='stylesheet' href='/static/js/luckysheet/assets/iconfont/iconfont.css' />
 </head>
 
 <body>

+ 76 - 0
src/pages/main/performance/components/sheet.vue

@@ -0,0 +1,76 @@
+<!--
+ * @Author       : yuanrunwei
+ * @Date         : 2021-12-04 14:23:58
+ * @LastEditors  : yuanrunwei
+ * @LastEditTime : 2021-12-04 15:38:33
+ * @FilePath     : \spfm-market-front\src\pages\main\performance\components\sheet.vue
+-->
+
+<template>
+    <div class="sheet-container">
+        <el-upload action :on-change="handleChange" :show-file-list="false">
+            <el-button size="mini" type="success">上传</el-button>
+        </el-upload>
+        <div id="luckysheet" class="sheet-container-block"></div>
+    </div>
+</template>
+
+<script>
+import XLSX from "xlsx";
+import luckyexcel from "luckyexcel";
+export default {
+    data() {
+        return {};
+    },
+    methods: {
+        handleInit() {},
+        handleCreate(file) {
+            luckyexcel.transformExcelToLucky(file, (export_json) => {
+                var options = {
+                    container: "luckysheet",
+                    data: export_json.sheets,
+                    title: export_json.info.name,
+                    userInfo: export_json.info.name.creator,
+                };
+                window.luckysheet.create(options);
+            });
+        },
+        async handleChange(response) {
+            this.handleCreate(response.raw);
+            let binary = await this.handleFile(response.raw);
+            let workbook = XLSX.read(binary, {
+                type: "binary",
+                cellDates: true,
+            });
+            let sheet = workbook.Sheets[workbook.SheetNames[0]];
+            const data = XLSX.utils.sheet_to_json(sheet);
+            this.handleCreate(data);
+        },
+        handleFile(file) {
+            return new Promise((resolve) => {
+                let reader = new FileReader();
+                reader.readAsBinaryString(file);
+                reader.onload = (event) => {
+                    resolve(event.target.result);
+                };
+            });
+        },
+    },
+    mounted() {
+        this.handleInit();
+    },
+};
+</script>
+
+<style lang="scss" scope>
+.sheet-container {
+    position: relative;
+    width: 1200px;
+    height: 500px;
+    &-block {
+        position: absolute;
+        width: calc(100% - 40px);
+        height: 100%;
+    }
+}
+</style>