浏览代码

文件中心模块功能

bobo04052021@163.com 3 月之前
父节点
当前提交
e32d691214
共有 3 个文件被更改,包括 367 次插入99 次删除
  1. 44 22
      api/api.js
  2. 0 74
      pages/filecenter/fileModel.vue
  3. 323 3
      pages/filecenter/filecenter.vue

+ 44 - 22
api/api.js

@@ -1,6 +1,6 @@
 import { http } from "@/common/service/service.js";
 import configService from "@/common/service/config.service.js";
-import  buildURL from "@/common/luch-request/helpers/buildURL.js"
+import buildURL from "@/common/luch-request/helpers/buildURL.js";
 const apiService = {
   /**
    * 登录
@@ -40,7 +40,7 @@ const apiService = {
   getShowColumList(params) {
     // const urlParams = new URLSearchParams(params);
     // const url = "/safety/ventanalyShowColum/list?" + urlParams.toString();
-	const url = buildURL("/safety/ventanalyShowColum/list", params)
+    const url = buildURL("/safety/ventanalyShowColum/list", params);
     return http.get(url);
   },
   //设备控制
@@ -54,7 +54,7 @@ const apiService = {
   getCameraById(params) {
     // const urlParams = new URLSearchParams(params);
     // const url = "/safety/ventanalyCamera/list?" + urlParams.toString();
-	const url = buildURL("/safety/ventanalyCamera/list", params)
+    const url = buildURL("/safety/ventanalyCamera/list", params);
     return http.get(url);
   },
   //如果上面这个接口返回code码  则使用这个接口获取url
@@ -62,7 +62,7 @@ const apiService = {
     // const urlParams = new URLSearchParams(params);
     // const url =
     //   "/ventanaly-device/camera/queryByCameraCode?" + urlParams.toString();
-	const url = buildURL("/ventanaly-device/camera/queryByCameraCode", params)
+    const url = buildURL("/ventanaly-device/camera/queryByCameraCode", params);
     return http.get(url);
   },
   //获取设备历史数据
@@ -71,7 +71,10 @@ const apiService = {
     // const url =
     //   "/ventanaly-device/safety/ventanalyMonitorData/listdays?" +
     //   urlParams.toString();
-	const url = buildURL("/ventanaly-device/safety/ventanalyMonitorData/listdays", params)
+    const url = buildURL(
+      "/ventanaly-device/safety/ventanalyMonitorData/listdays",
+      params
+    );
     return http.get(url);
   },
   //获取操作历史
@@ -80,27 +83,46 @@ const apiService = {
     // const url =
     //   "/ventanaly-device/safety/ventanalyDevicesetLog/list?" +
     //   urlParams.toString();
-	const url = buildURL("/ventanaly-device/safety/ventanalyDevicesetLog/list", params)
+    const url = buildURL(
+      "/ventanaly-device/safety/ventanalyDevicesetLog/list",
+      params
+    );
     return http.get(url);
   },
-  //获取文件数据  
-  getFileInfo(params){
-	  return http.post(
-	    "/ventanaly-sharefile/fileServer/list",
-	    params
-	  );
+  //获取文件数据
+  getFileInfo(params) {
+    return http.post("/ventanaly-sharefile/fileServer/list", params);
   },
   //获取预警信息
-  getWarnInfo(params){
-	  return http.get(
-	    "/safety/ventanalyAlarmLog/total",
-	    params
-	  );
-  },
-  getFilePreview(params){
-	  return http.post(
-	  "/ventanaly-sharefile/fileServer/preview",
-	  params)
+  getWarnInfo(params) {
+    return http.get("/safety/ventanalyAlarmLog/total", params);
+  },
+  getFilePreview(params) {
+    return http.post("/ventanaly-sharefile/fileServer/preview", params);
+  },
+  // 下载文件
+  downloadFile(params) {
+    return http.post("/ventanaly-sharefile/fileServer/download", params);
+  },
+  // 删除文件
+  delateFile(params) {
+    const url = buildURL("/ventanaly-sharefile/fileServer/delete", params);
+    return http.delete(url);
+  },
+  //提交文件
+  commitFile(params) {
+    const url = buildURL("/safety/actBusiness/commit", params);
+    return http.post(url);
+  },
+  // 撤回文件
+  cancelFile(params) {
+    const url = buildURL("/safety/actBusiness/cancelNew", params);
+    return http.post(url);
+  },
+  // 审批流程
+  getListFile(params) {
+    const url = buildURL("/activiti/activiti_process/listData", params);
+    return http.get(url);
   },
   /**
    * 获取文件访问路径

+ 0 - 74
pages/filecenter/fileModel.vue

@@ -1,74 +0,0 @@
-<template>
-  <view class="container">
-    <div id="fileEdit"></div>
-  </view>
-</template>
-
-<script>
-import configService from "../../common/service/config.service";
-
-export default {
-  data() {
-    return {
-      editID: "", //文件ID
-      fileType: "", //文件类型
-    };
-  },
-  onLoad(data) {
-    this.editID = data.id;
-    this.fileType = data.fileSuffix.slice(1);
-    this.initDocEditor();
-  },
-  methods: {
-    initDocEditor() {
-      new DocsAPI.DocEditor(
-        "fileEdit", // 元素id
-        {
-          type: "desktop",
-          width: "100%",
-          height: "100%",
-          document: {
-            title: "文档管理",
-            url:
-              configService.apiUrl +
-              ":9999/ventanaly-sharefile/fileServer/onlyOffice/read?id=" +
-              this.editID, //id表示文件id,后端接口用这个id来加载文件
-            // url: `${window.location.origin}:9999/ventanaly-sharefile/fileServer/onlyOffice/read?id=${this.editID}`, //id表示文件id,后端接口用这个id来加载文件
-            fileType:
-              this.fileType == "doc"
-                ? "docx"
-                : this.fileType == "xls"
-                ? "xlsx"
-                : this.fileType == "ppt"
-                ? "pptx"
-                : this.fileType, //当文件类型为doc、xls、ppt时,对应用docx、xlsx、pptx否则会保存异常。
-            key: "",
-            lang: "zh-CN",
-            permissions: {
-              download: true, //是否可下载
-              edit: true,
-              fillForms: true,
-              print: true, //是否可打印
-            },
-          },
-        }
-      );
-    },
-  },
-};
-</script>
-<style scoped>
-::v-deep .suffix {
-  height: 32px;
-  line-height: 32px;
-  margin-left: 5px;
-  color: #fff;
-}
-.main {
-  /* margin-top: 100rpx; */
-  margin-top: 80px;
-  display: flex;
-  flex-direction: column;
-  margin-top: 80px; /* 内容区域顶部留出导航栏的高度 */
-}
-</style>

+ 323 - 3
pages/filecenter/filecenter.vue

@@ -14,7 +14,7 @@
           v-for="(item, index) in fileData"
           :key="index"
         >
-          <div class="content flcard" @tap="openFile(item)">
+          <div class="content flcard" @tab="openFile(item)">
             <view
               class="demo-layout bg-purple-light"
               style="margin-bottom: 20rpx"
@@ -54,14 +54,110 @@
               >
             </view>
           </div>
+          <div class="btnClass">
+            <u-button
+              class="btn"
+              type="primary"
+              shape="circle"
+              text="审批详情"
+              @click="detailmodal(item)"
+            ></u-button>
+            <u-button
+              class="btn"
+              type="primary"
+              shape="circle"
+              text="提交"
+              @click="commitmodal(item)"
+            ></u-button>
+            <u-button
+              class="btn"
+              type="primary"
+              shape="circle"
+              text="撤回"
+              @click="retractmodal(item)"
+            ></u-button>
+            <u-button
+              class="btn"
+              type="primary"
+              shape="circle"
+              text="下载"
+              @click="download(item)"
+            ></u-button>
+            <u-button
+              class="btn"
+              type="primary"
+              shape="circle"
+              text="删除"
+              @click="showmodal(item)"
+            ></u-button>
+          </div>
         </u-list-item>
       </u-list>
+      <!-- 审批详情 -->
+      <u-popup
+        :show="detailShow"
+        :closeable="true"
+        :round="10"
+        mode="bottom"
+        @close="detailClose"
+      >
+        <view>
+          <u--textarea
+            v-model="value1"
+            placeholder="请输入撤回原因"
+          ></u--textarea>
+        </view>
+      </u-popup>
+      <!-- 删除 -->
+      <u-modal
+        :show="show"
+        :showCancelButton="true"
+        :showConfirmButton="true"
+        :content="content"
+        @confirm="confirm"
+        @cancel="cancel"
+      ></u-modal>
+      <!-- 提交 -->
+      <u-picker
+        :show="commitShow"
+        :columns="columns"
+        title="选择审批"
+        @confirm="confirmCommit"
+        @cancel="cancelCommit"
+      ></u-picker>
+      <!-- 撤回 -->
+      <u-popup
+        :show="showretract"
+        closeable="true"
+        :round="10"
+        mode="bottom"
+        @close="close"
+      >
+        <view>
+          <u--textarea
+            v-model="value1"
+            placeholder="请输入撤回原因"
+          ></u--textarea>
+        </view>
+        <view class="button-container">
+          <u-button @click="cancelRetract" shape="circle">取消</u-button>
+          <u-button @click="confirmRetract" shape="circle" type="primary"
+            >确认</u-button
+          >
+        </view>
+      </u-popup>
+      <u-notify
+        message="只有审批中的数据才能撤回!"
+        :show="notifyShow"
+        :duration="1000"
+      ></u-notify>
     </view>
   </view>
 </template>
 
 <script>
 import api from "@/api/api";
+import configService from "../../common/service/config.service";
 import { computed } from "uview-ui/libs/mixin/mixin";
 export default {
   components: {},
@@ -77,6 +173,18 @@ export default {
       curNow: 0,
       fileData: [],
       bpmStatus: 1, //1处理中  2 已完成  3 已驳回
+      show: false, //删除modal
+      content: "确定要删除吗?",
+      selectItem: "", //选择文件
+      showretract: false, //撤回popup
+      value1: "", //撤回原因
+      cancelItem: "", //撤回文件
+      detailShow: false, //详情
+      notifyShow: false, //撤回文件提示消息显示
+      commitShow: false, //提交
+      columns: [],
+      commitItem: "", //提交文件
+      selectFile: [],
     };
   },
   mounted() {
@@ -127,16 +235,214 @@ export default {
           });
       });
     },
+    //查看文件内容
     openFile(params) {
-      uni.navigateTo({
-        url: `/pages/filecenter/fileModel?id=${params.id}&type=${params.fileSuffix}`,
+      uni.downloadFile({
+        url:
+          configService.apiUrl +
+          "/ventanaly-sharefile/fileServer/onlyOffice/read?id=" +
+          params.id,
+        success: function (res) {
+          var filePath = res.tempFilePath;
+          uni.openDocument({
+            filePath: filePath,
+            showMenu: true,
+            success: function (res) {
+              console.log("打开文档成功");
+            },
+          });
+        },
+      });
+    },
+    // //下载文件到手机
+    download(params) {
+      var fileiId = params.id;
+      var params = {
+        id: fileiId,
+        responseType: "blob", // 期望的响应类型是Blob
+      };
+      new Promise((resolve, reject) => {
+        api
+          .downloadFile(params)
+          .then((response) => {
+            if (response.data.code == 200) {
+              const blob = response.data;
+              const fileName = params.fileName; // 替换为你的文件名和扩展名
+              // 使用uni.saveFile保存文件
+              uni.saveFile({
+                tempFilePath: response.tempFilePath,
+                content: blob,
+                success: (saveRes) => {
+                  console.log("saved file path:", saveRes.savedFilePath);
+                  // 可以使用 uni.openDocument 打开文件(如果支持)
+                  // 或者引导用户去文件管理器中查找
+                },
+                fail: (err) => {
+                  console.error("save file fail:", err);
+                },
+              });
+            } else {
+              // console.log("请求下载文件失败:", err);
+            }
+          })
+          .catch((error) => {
+            reject(error);
+          });
+      });
+    },
+    // //删除文件
+    showmodal(data) {
+      this.selectItem = data;
+      this.show = true;
+    },
+    confirm() {
+      this.delatefile(this.selectItem);
+    },
+    cancel() {
+      this.show = false;
+    },
+    delatefile(params) {
+      var fileiId = params.id;
+      new Promise((resolve, reject) => {
+        api
+          .delateFile({ id: fileiId })
+          .then((response) => {
+            if (response.data.code == 200) {
+              this.show = false;
+              this.getFileInfo();
+            } else {
+              // console.log("请求下载文件失败:", err);
+            }
+          })
+          .catch((error) => {
+            reject(error);
+          });
       });
     },
+    //撤回文件
+    retractmodal(data) {
+      this.showretract = true;
+      this.cancelItem = data;
+    },
+    close() {
+      this.showretract = false;
+    },
+    cancelRetract() {
+      this.showretract = false;
+    },
+    confirmRetract(e) {
+      console.log(e);
+      var fileiId = this.cancelItem.id;
+      var params = {
+        tableId: fileiId,
+        reason: this.value1,
+        tableName: this.cancelItem.tableName,
+      };
+      if (this.cancelItem.bpmStatus == 1) {
+        new Promise((resolve, reject) => {
+          api
+            .cancelFile(params)
+            .then((response) => {
+              if (response.data.code == 200) {
+                this.showretract = false;
+                this.getFileInfo();
+              } else {
+                // console.log("请求下载文件失败:", err);
+              }
+            })
+            .catch((error) => {
+              reject(error);
+            });
+        });
+      } else {
+        this.notifyShow = true;
+      }
+    },
+    // 详情
+    detailmodal() {
+      this.detailShow = true;
+    },
+    detailClose() {
+      this.detailShow = false;
+    },
+    // 提交
+    commitmodal(data) {
+      this.commitShow = true;
+      this.commitItem = data;
+      this.getListFile();
+    },
+    getListFile() {
+      this.columns = [];
+      var params = {
+        zx: true,
+        column: "createTime",
+        order: "desc",
+        status: 1,
+        _t: Date.now(),
+      };
+      new Promise((resolve, reject) => {
+        api
+          .getListFile(params)
+          .then((response) => {
+            if (response.data.code == 200) {
+              this.selectFile = response.data.result;
+              this.selectFile.forEach((item) => {
+                this.columns.push(item.id);
+                console.log(this.columns);
+              });
+            } else {
+              // console.log("请求下载文件失败:", err);
+            }
+          })
+          .catch((error) => {
+            reject(error);
+          });
+      });
+    },
+    confirmCommit() {
+      var fileiId = this.commitItem.id;
+      var params = {
+        tableId: fileiId,
+        procDefId: this.columns,
+      };
+      new Promise((resolve, reject) => {
+        api
+          .commitFile(params)
+          .then((response) => {
+            if (response.data.code == 200) {
+              this.commitShow = false;
+              this.getFileInfo();
+            } else {
+              // console.log("请求下载文件失败:", err);
+            }
+          })
+          .catch((error) => {
+            reject(error);
+          });
+      });
+    },
+    cancelCommit() {
+      this.commitShow = false;
+    },
   },
 };
 </script>
 
 <style scoped>
+.button-container {
+  display: flex;
+  justify-content: space-between;
+  margin-top: 10px; /* 根据需要调整 */
+}
+button {
+  /* 样式可以根据需要自定义 */
+  padding: 10px 20px;
+  background-color: #007aff;
+  color: white;
+  border: none;
+  border-radius: 5px;
+  cursor: pointer;
+}
 .main {
   /* margin-top: 100rpx; */
   margin-top: 80px;
@@ -149,6 +455,20 @@ export default {
   padding: 20rpx;
   background-color: #ffffff;
   margin-bottom: 5rpx;
+  display: flex;
+}
+.btnClass {
+  display: flex;
+  justify-content: space-around;
+  margin-top: 20rpx;
+}
+.btn {
+  border-radius: 10rpx;
+  margin-right: 10rpx; /* 示例:添加一些右外边距,但确保它不会导致换行 */
+}
+/* 最后一个按钮不需要右外边距 */
+.btn:last-child {
+  margin-right: 0;
 }
 .text-style {
   color: #3787fe;