zhangym пре 2 година
родитељ
комит
505761f7fd
1 измењених фајлова са 140 додато и 57 уклоњено
  1. 140 57
      src/views/energyOperationSupport/components/securitys/pic2.vue

+ 140 - 57
src/views/energyOperationSupport/components/securitys/pic2.vue

@@ -88,12 +88,37 @@
       </el-upload>
     </el-dialog>
     <el-dialog title="文件上传" :visible.sync="dialogVisible1" destroy-on-close width="15%" top="6vh" height="90%">
-      <el-upload class="upload-demo" ref="upload1" action="" :http-request="beforeUpload" :loading="loading"
-        :auto-upload="true">
+      <el-upload class="upload-demo" ref="upload1" :file-list="fileList" action=""
+        :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>
       </el-upload>
     </el-dialog>
+
+    <el-dialog title="文件信息预览" :visible.sync="dialogVisible3" destroy-on-close width="85%" top="6vh" height="90%">
+      <el-table :data="tableData" border style="width: 100%">
+        <el-table-column prop="createtime" label="上传时间" width="180">
+        </el-table-column>
+        <el-table-column prop="createman" label="上传人" width="80">
+        </el-table-column>
+        <el-table-column prop="filepath" label="文件地址" width="350">
+        </el-table-column>
+        <el-table-column prop="filename" label="文件名">
+        </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-table-column>
+      </el-table>
+    </el-dialog>
   </div>
 </template>
 <script>
@@ -127,6 +152,13 @@ export default {
 
   data() {
     return {
+      rowNodeid:'',
+      rowDataid:'',
+      pageNum: 1,
+      pageSize: 100,
+      fileList: [],
+      tableData: [],
+      dialogVisible3: false,
       graph: null,
       thereDataId: '',
       crumbNavs: [],
@@ -263,18 +295,18 @@ export default {
   },
   methods: {
     changeNode(node) {
-      if(node){
+      if (node) {
         console.log('casdasd', node)
-      if (node.tlevel === 1) {
-        this.crumbNavs = null;
-      }
-      graph.changeData(node);
-      //graph.changeData(JSON.parse(JSON.stringify(node)));
-      graph.fitView([140, 40, 20, 40]);
-      }else{
+        if (node.tlevel === 1) {
+          this.crumbNavs = null;
+        }
+        graph.changeData(node);
+        //graph.changeData(JSON.parse(JSON.stringify(node)));
+        graph.fitView([140, 40, 20, 40]);
+      } else {
         console.log("没有数据")
       }
-    
+
     },
     treeData3() {
       //获取tree数据
@@ -328,8 +360,8 @@ export default {
           } else if (target.id == "beforeUpload") {
             // 上传文件
             that.itemNode = item;
-            console.log('fileitemNode', that.itemNode)
             that.dialogVisible1 = true;
+            console.log('fileitemNode', that.itemNode)
           } else if (target.id == "del_fileName") {
             // 修改上传的文件
             that.itemNode = item;
@@ -574,12 +606,15 @@ export default {
         const { item } = event;
         const nodeItem = event.item // 获取被点击的节点元素对象
         const nodeModel = item.getModel();
-        if (nodeModel.tlevel >= 3 && nodeModel.file_url !== null) {
+        that.tableData = [];
+        if (nodeModel.itemtype === 200) {
+          that.dialogVisible3 = true;
           let arg = {
             fileUrl: nodeModel.file_url,
             fileName: nodeModel.file_name
           }
-          that.preview(arg);
+          //that.preview(arg);
+          that.gettableData(nodeModel.id);
         }
         that.findNodesByModels([nodeModel]);
         that.crumbNavs = [];
@@ -628,6 +663,45 @@ export default {
         // edges.forEach((edge) => graph.setItemState(edge, "running", false));
       });
     },
+    gettableData(id) {
+      let that = this;
+      let pageNum =0;
+      let params = {
+        nodeId:id
+      }
+      that.pageNum= pageNum || that.pageNum;
+      let url =
+        "pass/ems/v1/tfileoperates/?pageNum=" +
+        that.pageNum +
+        "&pageSize=" +
+        that.pageSize;
+      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;
+          console.log(res);
+        } else {
+          that.$message.error(res.message);
+        }
+      })
+
+    },
     getParentNodes(data, node) {
       let no1 = 0;
       //如果点击的是第二层,只显示导航到第一层
@@ -682,16 +756,16 @@ export default {
     },
     //changeDat
     changeDat(node) {
-      if(node){
+      if (node) {
         if (node.tlevel > 1) {
-        //graph.changeData(JSON.parse(JSON.stringify(node))),
-        graph.changeData(node)
-        graph.fitView([230, 240, 390, 390]);
-      }else{
-        console.log("没有数据")
-      }
+          //graph.changeData(JSON.parse(JSON.stringify(node))),
+          graph.changeData(node)
+          graph.fitView([230, 240, 390, 390]);
+        } else {
+          console.log("没有数据")
+        }
       }
-   
+
     },
 
     // 获取节点结构数据
@@ -902,6 +976,12 @@ export default {
       graph.updateChild(model, model.id);
 
     },
+    test3(row){
+      let that = this;
+      that.dialogVisible2 = true;
+      that.rowDataid = row.id;
+      that.rowNodeid = row.NodeId;
+    },
 
     renameSubmit() {
       const model = this.itemNode.getModel();
@@ -1000,6 +1080,14 @@ export default {
         // window.open(fileURL);
       }
     },
+    // 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用,function(file, fileList)
+    handleChange(file, fileList) {
+      this.fileList = fileList
+    },
+    // 删除文件之前的钩子,参数为上传的文件和文件列表,若返回 false 或者返回 Promise 且被 reject,则停止删除。function(file, fileList)
+    handleRemove(file, fileList) {
+      this.fileList = fileList
+    },
     // 新增节点结构数据
     addGxNameData(arr1) {
       let that = this
@@ -1052,14 +1140,18 @@ export default {
       });
     },
     //上传文件
-    beforeUpload(file) {
+    beforeUpload() {
       let that = this;
-      that.uploadloading = true;
+     // that.uploadloading = true;
+
       let foorData = new FormData();
-      foorData.append('file', file.file);
+      that.fileList.forEach((file => {
+        foorData.append('files', file.raw);
+      }))
+      //foorData.append('files', file.file);
       foorData.append('id', that.itemNode._cfg.id);
-      foorData.append('name', that.itemNode._cfg.model.label);
-      that.axios.post('pass/ems/v1/uploadfiles/file2', foorData, {
+      //foorData.append('name', that.itemNode._cfg.model.label);
+      that.axios.post('pass/ems/v1/tfileoperates/fileUpload', foorData, {
         headers: {
           'Content-Type': 'multipart/form-data'
         }
@@ -1086,18 +1178,20 @@ export default {
         }
         that.tableLoading = false;
         that.uploadloading = false;
+        that.fileList = [];
       })
     },
     //重新上传文件
     beforeUpload2(file) {
+      console.log('beforeUpload2',file)
       let that = this;
-      that.loading = true;
+      that.uploadloading = true;
       let foorData = new FormData();
-      foorData.append('file', file.file);
-      foorData.append('id', that.itemNode._cfg.id);
-      foorData.append('name', that.itemNode._cfg.model.label);
-      //that.del_fileName(that.itemNode._cfg.id);
-      that.axios.post('pass/ems/v1/uploadfiles/file2', foorData, {
+      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.axios.post('pass/ems/v1/tfileoperates/fileUploa2', foorData, {
         headers: {
           'Content-Type': 'multipart/form-data'
         }
@@ -1108,10 +1202,11 @@ export default {
             type: 'success'
           });
           that.loading = false;
+          that.dialogVisible2 = false;
           that.$refs.upload2.clearFiles();
-          that.getGxNameData();
+          console.log(that.rowNodeid);
+          that.gettableData(that.rowNodeid);
           graph.changeData();
-          location.reload();
         }
         else {
           that.$message.error(res.message);
@@ -1125,9 +1220,9 @@ export default {
     // 删除上传的文件
     del_fileName(file) {
       let that = this;
-      let id = that.itemNode._cfg.id
+      let id = that.rowDataid;
       if (id) {
-        that.axios.delete('pass/ems/v1/uploadfiles/' + id)
+        that.axios.delete('pass/ems/v1/tfileoperates/' + id)
           .then(function (res) {
             if (res.code === '0') {
               that.$message({
@@ -1170,15 +1265,16 @@ export default {
       let that = this;
       that.loading = true;
       that.chart.fileData = data;
+      console.log(data)
       let SubmitData = {
-        fileName: data.fileName,
-        fileUrl: data.fileUrl
+        fileName: data.filename,
+        fileUrl: data.filepath
       };
       let urla = 'pass/ems/v1/uploadfiles/getfile/';
       let type = 'text/html';
       let responseType = 'application/json';
-      if (data.fileName !== null) {
-        let fileExtension = data.fileName.substring(data.fileName.lastIndexOf('.') + 1);
+      if (data.filename !== null) {
+        let fileExtension = data.filename.substring(data.filename.lastIndexOf('.') + 1);
         if (fileExtension === 'pdf') {
           urla = 'pass/ems/v1/uploadfiles/downloadFile/';
           type = 'application/pdf';
@@ -1242,29 +1338,16 @@ export default {
     downloadFile(data) {
       let that = this;
       let SubmitData = {
-        fileName: data.fileName,
-        fileUrl: data.fileUrl
+        fileName: data.filename,
+        fileUrl: data.filepath
       };
-      // 不带token访问方式,留底后端修改shiroconfig.java,application.properties
-      //     let url = '/icore.icp.web/pass/ems/v1/uploadfiles/downloadFile/?fileName=' + that.tableFormDataObj[key].fileName + '&fileUrl=' + that.tableFormDataObj[key].fileUrl;
-      // const xhr = new XMLHttpRequest();
-      // xhr.open('GET', url, true);
-      // xhr.responseType = 'blob';
-      // xhr.onload = () => {
-      //     if (xhr.status === 200) {
-      //         var fileName = that.tableFormDataObj[key].fileName;
-      //         // 获取文件blob数据并保存
-      //         that.saveAs(xhr.response, fileName);
-      //     }
-      // };
-      // xhr.send();
       that.loading = true;
       let urla = 'pass/ems/v1/uploadfiles/downloadFile/';
       that.axios.get(urla, {
         params: SubmitData,
         responseType: 'blob'
       }).then(function (res) {
-        that.saveAs(res, data.fileName);
+        that.saveAs(res, data.filename);
         that.$message({
           message: '下载成功',
           type: 'success'