zhangym преди 2 години
родител
ревизия
3fdab6cff1
променени са 1 файла, в които са добавени 42 реда и са изтрити 41 реда
  1. 42 41
      src/views/energyOperationSupport/components/securitys/pic2.vue

+ 42 - 41
src/views/energyOperationSupport/components/securitys/pic2.vue

@@ -92,8 +92,9 @@
         :loading="loading" :auto-upload="false" :on-change="handleChange" :on-remove="handleRemove">
         <el-button slot="trigger" size="small" type="primary" :loading="loading" icon="el-icon-plus">选取文件
         </el-button>
-        <el-button  size="small" type="primary"  icon="el-icon-bottom-right" @click ="beforeUpload" >上传
+        <el-button size="small" type="primary" icon="el-icon-bottom-right" @click="beforeUpload">上传
         </el-button>
+        <div slot="tip" class="el-upload__tip">上传文件总和请不要超过10mb</div>
       </el-upload>
     </el-dialog>
 
@@ -109,13 +110,9 @@
         </el-table-column>
         <el-table-column label="操作" width="200">
           <template slot-scope="scope">
-          <el-button @click = "preview(scope.row)"
-          >预 览</el-button
-        >
-        <el-button type="primary"  @click = "test3(scope.row)" 
-          >重新上传</el-button
-        >
-        </template>
+            <el-button @click="preview(scope.row)">预 览</el-button>
+            <el-button type="primary" @click="test3(scope.row)">重新上传</el-button>
+          </template>
         </el-table-column>
       </el-table>
     </el-dialog>
@@ -152,8 +149,8 @@ export default {
 
   data() {
     return {
-      rowNodeid:'',
-      rowDataid:'',
+      rowNodeid: '',
+      rowDataid: '',
       pageNum: 1,
       pageSize: 100,
       fileList: [],
@@ -341,8 +338,7 @@ export default {
               <div class="contextmenu__item" id="addLabel">新建标签</div>
               <div class="contextmenu__item" id="editLabel">重命名</div>
               <div class="contextmenu__item" id="delLabel">删除</div>
-              <div class="contextmenu__item" id="beforeUpload">上传文件</div>
-              <div class="contextmenu__item" id="del_fileName">修改上传文件</div>`;
+              <div class="contextmenu__item" id="beforeUpload">上传文件</div>`;
           return menuHtml;
         },
         handleMenuClick(target, item) {
@@ -362,11 +358,7 @@ export default {
             that.itemNode = item;
             that.dialogVisible1 = true;
             console.log('fileitemNode', that.itemNode)
-          } else if (target.id == "del_fileName") {
-            // 修改上传的文件
-            that.itemNode = item;
-            that.dialogVisible2 = true;
-          } else if (target.id == "delLabel") {
+          }else if (target.id == "delLabel") {
             // 删除
             that.itemNode = item;
             that.delDialogVisible = true;
@@ -665,36 +657,36 @@ export default {
     },
     gettableData(id) {
       let that = this;
-      let pageNum =0;
+      let pageNum = 0;
       let params = {
-        nodeId:id
+        nodeId: id
       }
-      that.pageNum= pageNum || that.pageNum;
+      that.pageNum = pageNum || that.pageNum;
       let url =
         "pass/ems/v1/tfileoperates/?pageNum=" +
         that.pageNum +
         "&pageSize=" +
         that.pageSize;
-      that.axios.get(url,{
-        params:params
+      that.axios.get(url, {
+        params: params
       }).then(res => {
         if (res.code === '0') {
           let arr = [];
-            for (let e of res.data.list) {
-              arr.push({
-                createman: e.createman,
-                createtime: e.createtime,
-                filename: e.fileName,
-                filepath: e.filePath,
-                NodeId:e.nodeId,
-                bz: e.bz,
-                type: e.fileType,
-                updateman: e.updateman,
-                updatetime: e.updatetime,
-                id: e.id,
-              });
-            }
-            that.tableData = arr;
+          for (let e of res.data.list) {
+            arr.push({
+              createman: e.createman,
+              createtime: e.createtime,
+              filename: e.fileName,
+              filepath: e.filePath,
+              NodeId: e.nodeId,
+              bz: e.bz,
+              type: e.fileType,
+              updateman: e.updateman,
+              updatetime: e.updatetime,
+              id: e.id,
+            });
+          }
+          that.tableData = arr;
           console.log(res);
         } else {
           that.$message.error(res.message);
@@ -976,7 +968,7 @@ export default {
       graph.updateChild(model, model.id);
 
     },
-    test3(row){
+    test3(row) {
       let that = this;
       that.dialogVisible2 = true;
       that.rowDataid = row.id;
@@ -1083,6 +1075,15 @@ export default {
     // 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用,function(file, fileList)
     handleChange(file, fileList) {
       this.fileList = fileList
+      let size  = 0;
+      this.fileList.forEach((item)=>{
+        size +=item.size
+      })
+       let fileSize = size/1024/1024 < 10 ?0:1
+       if(fileSize===1){
+        this.$message.error("上传文件大小请不要超过10MB!")
+       }
+      console.log(fileSize ===1)
     },
     // 删除文件之前的钩子,参数为上传的文件和文件列表,若返回 false 或者返回 Promise 且被 reject,则停止删除。function(file, fileList)
     handleRemove(file, fileList) {
@@ -1142,7 +1143,7 @@ export default {
     //上传文件
     beforeUpload() {
       let that = this;
-     // that.uploadloading = true;
+      // that.uploadloading = true;
 
       let foorData = new FormData();
       that.fileList.forEach((file => {
@@ -1183,14 +1184,14 @@ export default {
     },
     //重新上传文件
     beforeUpload2(file) {
-      console.log('beforeUpload2',file)
+      console.log('beforeUpload2', file)
       let that = this;
       that.uploadloading = true;
       let foorData = new FormData();
       foorData.append('files', file.file);
       foorData.append('id', that.rowDataid);
       //foorData.append('name', that.itemNode._cfg.model.label);
-     // that.del_fileName(that.itemNode._cfg.id);
+      // that.del_fileName(that.itemNode._cfg.id);
       that.axios.post('pass/ems/v1/tfileoperates/fileUploa2', foorData, {
         headers: {
           'Content-Type': 'multipart/form-data'