yangbifan 2 years ago
parent
commit
073f7e6336
1 changed files with 48 additions and 36 deletions
  1. 48 36
      public/static/views/onlineShareExcel.html

+ 48 - 36
public/static/views/onlineShareExcel.html

@@ -73,24 +73,29 @@
         </div>
         <div style="float: right;padding-right: 10px" id="shareBtn">
             <button id="share" class="btn btn-primary"
-                style="padding:3px 6px;font-size: 18px;margin-right: 10px;width: 100px">分享
+                style="padding:3px 6px;font-size: 12px;margin-right: 10px;width: 70px">分享
             </button>
-            <button id="saves" lass="btn btn-primary"
-                style=" padding:3px 6px; font-size: 12px; margin-right: 10px;">保存</button>
+            <!-- <button id="saves" lass="btn btn-primary"
+                style=" padding:3px 6px; font-size: 12px; margin-right: 10px;">保存</button> -->
         </div>
         <div style="float: right;padding-right: 10px" id="newShareBtn">
             <button id="newShare" class="btn btn-primary"
-                style="padding:3px 6px;font-size: 18px;margin-right: 10px;width: 100px">分享
+                style="padding:3px 6px;font-size: 12px;margin-right: 10px;width: 70px">分享
             </button>
-            <input id="importspro" type="file" class="btn btn-primary" style="padding:3px 6px;font-size: 12px;margin-right: 10px;"></input>
+        </div>
+        <div style="float: right;padding-right: 10px">
+            <input id="importspro" type="file" class="btn btn-primary"
+                style="padding:3px 6px;font-size: 12px;margin-right: 10px;"></input>
             <button id="savesid" class="btn btn-primary"
-            style="padding:3px 6px;font-size: 18px;margin-right: 10px;width: 100px">保存</button>
+                style="padding:3px 6px;font-size: 12px;margin-right: 10px;width: 70px">保存</button>
             <button id="closeExcel" class="btn btn-primary"
-            style="padding:3px 6px;font-size: 18px;margin-right: 10px;width: 100px">返回</button><button id="fullScreen"
-                class="btn btn-primary" style="padding:3px 6px;font-size: 18px;margin-right: 10px;width: 100px">全屏显示</button><button
+                style="padding:3px 6px;font-size: 12px;margin-right: 10px;width: 70px">返回</button><button
+                id="fullScreen" class="btn btn-primary"
+                style="padding:3px 6px;font-size: 12px;margin-right: 10px;width: 70px">全屏显示</button><button
                 id="exitFullScreen" class="btn btn-primary"
-                style="padding:3px 6px;font-size: 18px;margin-right: 10px;width: 100px;display:none">退出全屏</button>
-                <button id="exports"class="btn btn-primary"  style="padding:3px 6px;font-size: 18px;margin-right: 10px;width: 100px">导出</button>
+                style="padding:3px 6px;font-size: 12px;margin-right: 10px;width: 70px;display:none">退出全屏</button>
+            <button id="exports" class="btn btn-primary"
+                style="padding:3px 6px;font-size: 12px;margin-right: 10px;width: 70px">导出</button>
         </div>
     </div>
     <div style="height:90%;width: 100%;">
@@ -171,11 +176,13 @@
                         $("#editStatus").val(excelInfo.editStatus);
                         console.log(type);
                         if (type == '2') {
-                            if (isAdmin) {
+                            if (!isAdmin) {
+                                $("#importspro").css("display", "none");
                                 // toolBar += '<input id="importspro" type="file" class="btn btn-primary" style="padding:3px 6px;font-size: 12px;margin-right: 10px;"></input>';
                             }
                         }
-                        if (isAdmin) {
+                        if (!isAdmin) {
+                            $("#exports").css("display", "none");
                             // toolBar += '<button id="exports" class="btn btn-primary btn-danger" style="padding:3px 6px;font-size: 12px;margin-right: 10px;">导出</button>';
                         }
                         //  toolBar += '<button id="savesid" class="btn btn-primary btn-danger" style=" padding:3px 6px; font-size: 12px; margin-right: 10px;">保存</button>';
@@ -343,11 +350,11 @@
                 }
                 if (emptyExcel == true) {
                     $("#shareBtn").show();
-                    // $("#saves").hide();
+                    $("#savesid").hide();
                     $("#newShareBtn").hide();
                 } else {
                     $("#shareBtn").hide();
-                    // $("#saves").show();
+                    $("#savesid").show();
                     if (isAdmin) {
                         $("#newShareBtn").show();
                     }
@@ -574,9 +581,7 @@
                         });
                         return;
                     }
-                    util.ajaxJson("正在加载中", ctx + '/market/cOnlineExcel/checkExcelEmpty', {
-                        data: excelData,
-                    }, function (data) {
+                    util.ajaxJson("正在加载中", ctx + '/market/cOnlineExcel/checkExcelEmpty', { data: excelData, }, function (data) {
                         if (data.result == 1) {
                             window.top.$vm.$message({
                                 message: data.desc,
@@ -618,6 +623,7 @@
                     var excelId = $(window.parent.document).find("#excelId").attr("value");
                     console.log(evt);
                     var files = evt.target.files;
+                    console.log(files);
                     if (files == null || files.length == 0) {
                         window.top.$vm.$message({
                             message: '没有文件导入',
@@ -635,27 +641,33 @@
                         })
                         return;
                     }
+
+
                     // 解析文件
-                    LuckyExcel.transformExcelToLucky(
-                        files[0],
-                        function (exportJson, luckysheetfile) {
-                            console.log(exportJson);
-                            if (exportJson.sheets == null || exportJson.sheets.length == 0) {
-                                window.top.$vm.$message({
-                                    message: '无法读取excel文件的内容,当前不支持xls文件',
-                                    type: 'info'
-                                })
-                                return;
-                            }
-                            // 销毁原来的excel
-                            window.luckysheet.destroy();
-                            // 重新加载
-                            var a = exportJson.sheets[0];
-                            a.name = '';
-                            initExcel([a], name.replace('.xlsx', ''),excelId);
-                            // 绑定按钮事件
-                            initHandel()
+                    LuckyExcel.transformExcelToLucky(files[0], function (exportJson, luckysheetfile) {
+                        console.log(exportJson);
+                        if (exportJson.sheets == null || exportJson.sheets.length == 0) {
+                            window.top.$vm.$message({
+                                message: '无法读取excel文件的内容,当前不支持xls文件',
+                                type: 'info'
+                            })
+                            return;
                         }
+                        let res = JSON.stringify(exportJson)
+                        console.log(res);
+                        util.ajaxJson("正在导入中", "http://43.138.50.94:7777/sheet/excel/importFile", { exceldata: res, id: excelId }, function (res) {
+
+                            console.log(res);
+                        });
+                        // 销毁原来的excel
+                        window.luckysheet.destroy();
+                        // // 重新加载
+                        var a = exportJson.sheets[0];
+                        a.name = '';
+                        initExcel([a], name.replace('.xlsx', ''), excelId);
+                        // // 绑定按钮事件
+                        initHandel()
+                    }
                     );
                 });
             }