yangbifan 2 년 전
부모
커밋
2dd7ae8716
3개의 변경된 파일172개의 추가작업 그리고 66개의 파일을 삭제
  1. 2 13
      public/static/views/onlineShareExcel.html
  2. 47 0
      src/assets/js/util.js
  3. 123 53
      src/pages/main/onlineExcel/index.vue

+ 2 - 13
public/static/views/onlineShareExcel.html

@@ -84,8 +84,8 @@
             </button>
         </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>
+            <!-- <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: 12px;margin-right: 10px;width: 70px">保存</button>
             <button id="closeExcel" class="btn btn-primary"
@@ -697,17 +697,6 @@
                             }
 
                         });
-                        // // 销毁原来的excel
-                        // window.luckysheet.destroy();
-                        // // // 重新加载
-                        // var a = exportJson.sheets[0];
-                        // a.name = '';
-                        // if (res.code === '1') {
-
-                        // }
-                        // initExcel([a], name.replace('.xlsx', ''), excelId);
-                        // // // 绑定按钮事件
-                        // initHandel()
                     }
                     );
                 });

+ 47 - 0
src/assets/js/util.js

@@ -35,6 +35,53 @@ util.hasPermission = function(permission) {
 
   return found;
 };
+util.ajaxJson = function (msg, url, param, callBack, beforeSend, async) {
+
+
+
+  $.ajax({
+    type: "POST",
+    url: url,
+    global: true,
+    data: JSON.stringify(param),
+    contentType: "application/json;charset=UTF-8",
+    beforeSend: function (req) {
+
+      req.setRequestHeader("agileauthtoken", window.sessionStorage.agileauthtoken);
+
+      if ($.isFunction(beforeSend)) {
+
+        beforeSend.call(this, req);
+      }
+
+
+    },
+    xhrFields: {
+      withCredentials: false //跨域session保持
+    },
+    async: async == undefined ? true : async,
+    dataType: "json",
+    success: function (page) {
+
+      // util.disLoad();
+
+      if ($.isFunction(callBack)) {
+
+        callBack.call(this, page);
+      }
+
+    },
+    error: function (xhr, textStatus, errorThrow) {
+
+      // util.disLoad();
+
+      // util.closeAll();
+
+      // util.error("系统异常!");
+    }
+  });
+
+},
 //获取前端地址参数对象
 util.getRequestSearchObject = function() {
   var url = window.location.search; //获取url中"?"符后的字串

+ 123 - 53
src/pages/main/onlineExcel/index.vue

@@ -2,7 +2,7 @@
     <fullscreen :fullscreen.sync="fullscreen" class="container">
         <div class="container">
             <div class="main-box container-box">
-                <input type="hidden" id="excelId"/>
+                <input type="hidden" id="excelId" />
                 <div class="inner-left" style="overflow: hidden">
                     <!--                <div class="button-list">-->
                     <!--                    <el-button type="primary" @click="showExcel = true" plain>excel</el-button>-->
@@ -10,27 +10,26 @@
                     <!--                </div>-->
                     <div style="margin: 10px 0">
                         <el-input placeholder="请输入内容" v-model="filterText" class="input-with-select" clearable
-                                  @change="() => {if (!filterText) {searchMenu();}}">
+                            @change="() => { if (!filterText) { searchMenu(); } }">
                             <el-button slot="append" @click="searchMenu" icon="el-icon-search"></el-button>
                         </el-input>
                     </div>
                     <div v-loading="loading" style="height: calc(100% - 100px);overflow-y: scroll;overflow-x: scroll">
                         <el-tree ref="tree" class="tree-line" :expand-on-click-node="false" :auto-expand-parent="true"
-                                 :default-expand-all="true" :default-checked-keys="checkedMenu" :data="menuList"
-                                 @check="checkChange"
-                                 @node-click="nodeClick" :filter-node-method="filterNode" node-key="functionCode"
-                                 style="width: 300px">
-                        <span class="custom-tree-node" slot-scope="{ node }">
-                            <span>
-                                <span v-if="node.data.type == 4"
-                                      style="color: #009cff" class="iconfont icon-wenjianjia"></span>
-                                <span v-else style="color: #fdb441" class="iconfont icon-wenjian"></span>
-                                <span
-                                    :style="node.data.hasOwnProperty('parent')? 'font-size:14px;padding-left:5px':'font-size:12px;padding-left:5px'">{{
-                                        node.data.functionName
-                                    }}</span>
+                            :default-expand-all="true" :default-checked-keys="checkedMenu" :data="menuList"
+                            @check="checkChange" @node-click="nodeClick" :filter-node-method="filterNode"
+                            node-key="functionCode" style="width: 300px">
+                            <span class="custom-tree-node" slot-scope="{ node }">
+                                <span>
+                                    <span v-if="node.data.type == 4" style="color: #009cff"
+                                        class="iconfont icon-wenjianjia"></span>
+                                    <span v-else style="color: #fdb441" class="iconfont icon-wenjian"></span>
+                                    <span
+                                        :style="node.data.hasOwnProperty('parent') ? 'font-size:14px;padding-left:5px' : 'font-size:12px;padding-left:5px'">{{
+                                            node.data.functionName
+                                        }}</span>
+                                </span>
                             </span>
-                        </span>
                         </el-tree>
                     </div>
                     <div class="tree-action"></div>
@@ -40,19 +39,21 @@
                         <toolList @iconCli='iconCli' :tooltit='tooltit' style="margin: 10px"></toolList>
                         <div style="margin-top: 20px;float: left;" class="bigbtns">
                             <el-button style="margin-left: 20px;" class="btn-check" size="medium" type="primary"
-                                       @click="addNewStatus = true">新建
+                                @click="addNewStatus = true">新建
                             </el-button>
+                            <input style="margin-left:30px" id="upload-file" name="file" type="file" @change="handleUpload">
                         </div>
+                        
                         <div style="margin-top: 20px;float: right;margin-right: 20px" class="bigbtns"
-                             v-if="selectionSize != 0">
+                            v-if="selectionSize != 0">
                             <el-button style="margin-left: 5px;" class="btn-check" size="small" type="primary"
-                                       @click="delExcel()">删除
+                                @click="delExcel()">删除
                             </el-button>
                             <el-button style="margin-left: 5px;" class="btn-check" size="small" type="primary"
-                                       @click="cancelSelection()">取消
+                                @click="cancelSelection()">取消
                             </el-button>
                             <el-button style="margin-left: 5px;" class="btn-check" size="small" type="primary"
-                                       @click="moveStatus = true">移动到
+                                @click="moveStatus = true">移动到
                             </el-button>
                         </div>
                     </div>
@@ -61,8 +62,8 @@
                             <span v-if="selectionSize != 0">已选{{ selectionSize }}项</span>
                         </div>
                         <el-table height="calc(100% - 60px)" class="com-table" ref="multipleTable" :data="tableData"
-                                  tooltip-effect="dark" size="small" border style="width: 100%" v-loading="loading"
-                                  @selection-change="handleSelectionChange">
+                            tooltip-effect="dark" size="small" border style="width: 100%" v-loading="loading"
+                            @selection-change="handleSelectionChange">
                             <el-table-column type="selection" width="45"></el-table-column>
                             <el-table-column prop="fileName" label="名称">
                             </el-table-column>
@@ -81,38 +82,40 @@
                             <el-table-column label="操作" width="180px" align="center" fixed="right">
                                 <template slot-scope="scope">
                                     <el-button size="mini" type="primary" @click="moveToEdit(scope.row)"
-                                               :disabled="scope.row.shareEditStatus==1">编辑
+                                        :disabled="scope.row.shareEditStatus == 1">编辑
                                     </el-button>
                                 </template>
                             </el-table-column>
                         </el-table>
                         <el-pagination class="pageBox" @current-change="currchange" layout="prev, pager, next"
-                                       background
-                                       :total="total">
+                            background :total="total">
                         </el-pagination>
                     </div>
 
                     <div class="container" id="container" v-else>
                         <fullscreen :fullscreen.sync="excelFullScreen" class="container">
                             <iframe id="excelIframe" height="100%" width="100%"
-                                    src="/static/views/onlineShareExcel.html"
-                                    frameborder="0"></iframe>
+                                src="/static/views/onlineShareExcel.html" frameborder="0"></iframe>
                         </fullscreen>
                     </div>
                 </div>
             </div>
-            <el-dialog :title="'新建'" :visible.sync="addNewStatus" width="300px" :destroy-on-close="true"
-                       :modal-append-to-body="false" :close-on-click-modal="false">
+            <el-dialog :title="'新建'" :visible.sync="addNewStatus" width="450px" :destroy-on-close="true"
+                :modal-append-to-body="false" :close-on-click-modal="false">
                 <div>
                     <!--                <el-button type="primary" @click="addExcel()" plain class="iconfont icon-wenjian">在线文档</el-button>-->
                     <!--                <el-button type="primary" @click="addFolderStatus = true" plain class="iconfont icon-wenjianjia">文件夹</el-button>-->
-                    <div style="padding-bottom: 30px">
+                    <div style="padding-bottom: 30px;display:flex">
                         <div style="width: 85px;display: inline-block;cursor: pointer" @click="addExcel()">
                             <span class="iconfont icon-wenjian" style="font-size: 80px;color: dodgerblue"></span>
                             <p style="margin-left: 20px;margin-top: 10px">在线文档</p>
                         </div>
+                        <div style="width: 85px;display: inline-block;margin-left: 70px;cursor: pointer">
+                            <span class="iconfont icon-excel" style="font-size: 80px;color: dodgerblue"></span>
+                            <input id="upload-file" name="file" type="file" @change="handleUpload">123
+                        </div>
                         <div style="width: 85px;display: inline-block;margin-left: 70px;cursor: pointer"
-                             @click="addFolderStatus = true">
+                            @click="addFolderStatus = true">
                             <span class="iconfont icon-wenjianjia" style="font-size: 80px;color: dodgerblue"></span>
                             <p style="margin-left: 20px;margin-top: 10px">文件夹</p>
                         </div>
@@ -120,14 +123,14 @@
                 </div>
             </el-dialog>
             <el-dialog :title="'新增文件夹'" :visible.sync="addFolderStatus" width="50%" :destroy-on-close="true"
-                       :modal-append-to-body="false" :close-on-click-modal="false">
+                :modal-append-to-body="false" :close-on-click-modal="false">
                 <div v-loading="loading">
                     <el-form :model="infolist" ref="infolist">
                         <div class="online">
                             <el-form-item prop="name">
                                 <span>文件夹名称</span>
                                 <el-input v-model="infolist.name" placeholder="文件夹名称"
-                                          :disabled="disableStatus"></el-input>
+                                    :disabled="disableStatus"></el-input>
                             </el-form-item>
                         </div>
                     </el-form>
@@ -138,7 +141,7 @@
                 </div>
             </el-dialog>
             <el-dialog :title="'分享选项'" :visible.sync="shareStatus" width="550px" :destroy-on-close="true"
-                       :modal-append-to-body="false" :close-on-click-modal="false">
+                :modal-append-to-body="false" :close-on-click-modal="false">
                 <div style="margin-left: 30px;padding-bottom: 20px" v-loading='shareLoading'>
                     <el-button type="primary" @click="processExcelShare(1)" plain>仅我可编辑</el-button>
                     <el-button type="primary" @click="openOADialog(2)" plain>部门内所有人可编辑</el-button>
@@ -146,16 +149,16 @@
                 </div>
             </el-dialog>
             <el-dialog title="选择填报人" :visible.sync="checkexa" width="50%" :destroy-on-close="true"
-                       :modal-append-to-body="false" :close-on-click-modal="false" v-loading="shareLoading">
+                :modal-append-to-body="false" :close-on-click-modal="false" v-loading="shareLoading">
                 <div>
                     <el-form :model="exaList" ref="addInfoList">
                         <el-form-item prop="processUserId" class="info-line online">
                             <span style="width: 80px;margin-right: 20px">审批人员</span>
                             <deptTreeUserNew class="tree" @treeCheck="treeCheckonly" :defaultList="defaultList"
-                                             :type="depttype" :closeList="closeList"></deptTreeUserNew>
+                                :type="depttype" :closeList="closeList"></deptTreeUserNew>
                             <div class="tree treeUser">
-                                <p v-for="(item,index) in treeList" :key="index">{{ item.receiveName }}
-                                    <i @click="deletes(item,index)" class="el-icon-error"></i>
+                                <p v-for="(item, index) in treeList" :key="index">{{ item.receiveName }}
+                                    <i @click="deletes(item, index)" class="el-icon-error"></i>
                                 </p>
                             </div>
                         </el-form-item>
@@ -168,19 +171,19 @@
                 </div>
             </el-dialog>
             <el-dialog title="移动到" :visible.sync="moveStatus" width="500px" :destroy-on-close="true"
-                       :modal-append-to-body="false" :close-on-click-modal="false">
+                :modal-append-to-body="false" :close-on-click-modal="false">
                 <div>
                     <el-tree ref="tree" class="tree-line" :expand-on-click-node="false" :auto-expand-parent="true"
-                             :default-expand-all="true" :default-checked-keys="checkedMenu" :data="moveMenuList"
-                             @check="checkChange"
-                             @node-click="folderNodeClick" node-key="functionCode" @expand-on-click-node="false">
+                        :default-expand-all="true" :default-checked-keys="checkedMenu" :data="moveMenuList"
+                        @check="checkChange" @node-click="folderNodeClick" node-key="functionCode"
+                        @expand-on-click-node="false">
                         <span class="custom-tree-node" slot-scope="{ node }">
                             <span>
-                                <span v-if="node.data.type == 4"
-                                      style="color: #009cff" class="iconfont icon-wenjianjia"></span>
+                                <span v-if="node.data.type == 4" style="color: #009cff"
+                                    class="iconfont icon-wenjianjia"></span>
                                 <span v-else style="color: #fdb441" class="iconfont icon-wenjian"></span>
                                 <span
-                                    :style="node.data.hasOwnProperty('parent')? 'font-size:14px;padding-left:5px':'font-size:12px;padding-left:5px'">{{
+                                    :style="node.data.hasOwnProperty('parent') ? 'font-size:14px;padding-left:5px' : 'font-size:12px;padding-left:5px'">{{
                                         node.data.functionName
                                     }}</span>
                             </span>
@@ -195,20 +198,22 @@
                 </div>
             </el-dialog>
             <myMessage :messTit='messTit' @closeMessage="processDel" :centerDialogVisible="delVisible"
-                       v-if="delVisible"></myMessage>
+                v-if="delVisible"></myMessage>
             <myMessageRadio :messTit='oaTitle' @closeMessage="processOa" :centerDialogVisible="oaVisible"
-                            v-if="oaVisible" yesBtnName="是" noBtnName="否" ok-btn-name="提交"></myMessageRadio>
+                v-if="oaVisible" yesBtnName="是" noBtnName="否" ok-btn-name="提交"></myMessageRadio>
         </div>
     </fullscreen>
 </template>
 
 <script>
+import LuckyExcel from "luckyexcel";
 import pForm from "../../../components/p-form";
 import toolList from "../../../components/toolList";
 import myMessage from "../../../components/myMessage.vue";
 import myMessageNew from "../../../components/myMessageNew.vue";
 import myMessageRadio from "../../../components/myMessageRadio.vue";
 import deptTreeUserNew from "../../../components/deptTreeUserNew.vue"
+import {ajaxJson} from '../../../../public/static/js/util'
 
 export default {
     components: {
@@ -274,6 +279,71 @@ export default {
         }
     },
     methods: {
+        //外部导入
+        addExport(e) {
+            this.$http({
+                url: '/market/cOnlineExcel/addExcel',
+                method: "post",
+                headers: {
+                    "Content-Type": "application/json",
+                },
+                data: {
+                    folderId: '',
+                },
+            }).then((res) => {
+                console.log(res);
+                res.data.desc
+                this.startUpload(e, res.data.desc)
+            });
+        },
+        startUpload(e, res) {
+            let _this = this;
+            let files = e.target.files;
+            if (files == null || files.length == 0) {
+                window.top.$vm.$message({
+                    message: '没有文件导入',
+                    type: 'info'
+                })
+                return;
+            }
+            let name = files[0].name;
+            let suffixArr = name.split("."),
+                suffix = suffixArr[suffixArr.length - 1];
+            if (suffix != "xlsx") {
+                window.top.$vm.$message({
+                    message: '目前只支持xlsx文件的导入',
+                    type: 'info'
+                })
+                return;
+            }
+            // 解析文件
+            LuckyExcel.transformExcelToLucky(files[0], function (exportJson, luckysheetfile) {
+                if (exportJson.sheets == null || exportJson.sheets.length == 0) {
+                    window.top.$vm.$message({
+                        message: '无法读取excel文件的内容,当前不支持xls文件',
+                        type: 'info'
+                    })
+                    return;
+                }
+                let exceljson = JSON.stringify(exportJson)
+                _this.$util.ajaxJson("正在导入中", "http://192.168.2.124:7777/sheet/excel/importFile", { exceldata: exceljson, id: res }, function (res) {
+                    // console.log('[ res ] >', res)
+                    _this.addNewStatus = false;
+                    document.getElementById('excelId').setAttribute("value", res.id);
+                    _this.showExcel = true;
+  
+
+                });
+            }
+            );
+            console.log(e); //文件
+            console.log(res);//excel id
+
+        },
+        handleUpload(e) {
+            this.addExport(e)
+
+        },
         processWoNo() {
             console.log(this.woNo);
             var _this = this;
@@ -466,7 +536,7 @@ export default {
         },
         //打开excel
         moveToEdit(row) {
-            
+
             //放入id,切换到excel模式
             document.getElementById('excelId').setAttribute("value", row.id);
             this.showExcel = true;
@@ -814,7 +884,7 @@ export default {
         overflow: hidden;
         display: flex;
 
-        > div {
+        >div {
             background-color: white;
         }
 
@@ -836,7 +906,7 @@ export default {
     }
 }
 
-.el-button + .el-button {
+.el-button+.el-button {
     margin-left: 20px;
 }
 
@@ -907,11 +977,11 @@ export default {
     }
 
     // 去掉最顶层的虚线,放最下面样式才不会被上面的覆盖了
-    & > .el-tree-node::after {
+    &>.el-tree-node::after {
         border-top: none;
     }
 
-    & > .el-tree-node::before {
+    &>.el-tree-node::before {
         border-left: none;
     }