hujunwei@agilestar.cn 2 lat temu
rodzic
commit
a27f2cf099

+ 16 - 5
src/components/uploadOnlineOffice.vue

@@ -1,9 +1,9 @@
 <template>
     <div v-loading="loading">
-        <el-upload class="upload-demo" :drag="fileInfo.type !== 'btn'" multiple :limit="fileInfo.limit" ref="upload"
-            action="string" :on-remove="handleRemove" :on-exceed="handleExceed" :file-list="attList" :auto-upload="true"
-            :show-file-list="fileInfo.type !== 'btn'" :before-upload="deforeUp" :http-request="signUpload"
-            :on-preview="defUp" :disabled="disabled">
+        <el-upload class="upload-demo" accept=".xls,.xlsx,.ppt,.pptx,.doc,.docx" :drag="fileInfo.type !== 'btn'" multiple
+            :limit="fileInfo.limit" ref="upload" action="string" :on-remove="handleRemove" :on-exceed="handleExceed"
+            :file-list="attList" :auto-upload="true" :show-file-list="fileInfo.type !== 'btn'" :before-upload="deforeUp"
+            :http-request="signUpload" :on-preview="defUp" :disabled="disabled">
             <div v-if="fileInfo.type !== 'btn'">
                 <span class="iconfont icon-excel" style="font-size: 80px;color: dodgerblue;margin-top: 10px;"></span>
                 <div class="el-upload__text" style="margin-top: 10px;">{{ fileInfo.typename
@@ -102,7 +102,18 @@ export default {
             let query = new FormData();
             query.append("file", file);
             console.log(query);
-            // let docType = file.name.split('.')[1]
+            let docType = file.name.split('.')[1]
+            const extension1 = docType === "xlsx";
+            const extension2 = docType === "xls";
+            const extension3 = docType === "docx";
+            const extension4 = docType === "doc";
+            const extension5 = docType === "ppt";
+            const extension6 = docType === "pptx";
+            console.log(extension6);
+            if (!extension1 && !extension2 && !extension3 && !extension4 && !extension5 && !extension6) {
+                this.$message.error("上传文件格式有误!");
+                return false;
+            }
             // if (docType == 'xlsx' || docType == 'xls') {
             //     docType = 'cell'
             // }

+ 22 - 103
src/pages/main/onlineOfficeExcel/index.vue

@@ -121,17 +121,11 @@
                             </el-table-column>
                             <el-table-column label="操作" width="200px" align="center" fixed="right">
                                 <template slot-scope="scope">
-                                    <!-- <el-button size="mini" type="primary" @click="moveToEdit(scope.row)"
-                                        :disabled="scope.row.shareEditStatus == 1">编辑
-                                    </el-button> -->
                                     <el-button type="primary" icon="el-icon-edit" @click="moveToEdit(scope.row)"
                                         size="small" style="height: 50%;">编辑</el-button>
                                     <el-button type="primary" icon="el-icon-share" plain
                                         v-if="scope.row.addUserId == shareadmin" @click="shareBtn(scope.row)" size="small"
                                         style="height: 50%;">分享</el-button>
-                                    <!-- <el-button size="mini" type="primary" v-if="scope.row.addUserId == shareadmin"
-                                        @click="shareBtn(scope.row)">分享
-                                    </el-button> -->
                                 </template>
                             </el-table-column>
                         </el-table>
@@ -478,94 +472,6 @@ export default {
             this.page = e;
             this.currentPage(this.dataList)
         },
-        //外部导入
-        // async addExport(e) {
-        //     await this.$http({
-        //         url: '/market/cOnlineSyncExcel/addExcel',
-        //         method: "post",
-        //         headers: {
-        //             "Content-Type": "application/json",
-        //         },
-        //         data: {
-        //             folderId: '',
-        //         },
-        //     }).then((res) => {
-        //         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("正在导入中", getConfig().EXCEL_URL + "/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;
-
-
-                });
-            }
-            );
-
-        },
-        // async handleUpload(file) {
-        //     console.log(file);
-        //     const isLt2M = file.size / 1024 / 1024 < 100;
-        //     if (!isLt2M) {
-        //         this.$message.error("上传文件大小不能超过 20MB!");
-        //         return false;
-        //     }
-        //     this.loading = true;
-        //     let query = new FormData();
-        //     query.append("file", file);
-        //     console.log(query);
-        //     this.$http({
-        //         url: this.fileInfo.url,
-        //         method: "post",
-        //         headers: {
-        //             "Content-Type": "application/json",
-        //         },
-        //         data: query,
-        //     }).then((res) => {
-
-        //     }).catch((res) => {
-        //         this.$message({
-        //             message: file.name + "上传失败",
-        //             type: "error",
-        //         });
-
-        //     });
-        //     // await this.addExport(e)
-
-
-        // },
         processWoNo() {
             console.log(this.woNo);
             var _this = this;
@@ -587,17 +493,30 @@ export default {
                         });
                     }
                 } else {
-                    _this.$message({
-                        message: '请填写完毕后点击“保存”按钮',
-                        type: 'success'
-                    });
-                    var id = res.data.desc;
-                    //放入id,切换到excel模式
-                    document.getElementById('excelId').setAttribute("value", id);
-                    _this.showExcel = true;
-                    console.log(_this.showExcel);
+                    // moveToEdit(e)
+                    // _this.$message({
+                    //     message: '请填写完毕后点击“保存”按钮',
+                    //     type: 'success'
+                    // });
+                    // var id = res.data.desc;
+                    // //放入id,切换到excel模式
+                    // document.getElementById('excelId').setAttribute("value", id);
+                    // _this.showExcel = true;
+                    // console.log(_this.showExcel);
                 }
             });
+            this.$http({
+                url: '/market/cOnlineSyncExcel/getExcleInfoByOaId',
+                method: "post",
+                headers: {
+                    "Content-Type": "application/json",
+                },
+                data: {
+                    id: _this.woNo,
+                },
+            }).then((res) => {
+                this.moveToEdit(res.data.body)
+            });
         },
         moveExcel() {
             var _this = this;