Browse Source

文件中心相关功能开发

bobo04052021@163.com 4 months ago
parent
commit
e1de3d9f06
3 changed files with 111 additions and 26 deletions
  1. 7 0
      common/router/modules/routes.js
  2. 74 0
      pages/filecenter/fileModel.vue
  3. 30 26
      pages/filecenter/filecenter.vue

+ 7 - 0
common/router/modules/routes.js

@@ -128,5 +128,12 @@ const routes = [
       title: "风门",
     },
   },
+  {
+    path: "/pages/filecenter/fileModel",
+    name: "fileModel",
+    meta: {
+      title: "文件详情",
+    },
+  },
 ];
 export default routes;

+ 74 - 0
pages/filecenter/fileModel.vue

@@ -0,0 +1,74 @@
+<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>

+ 30 - 26
pages/filecenter/filecenter.vue

@@ -3,7 +3,7 @@
     <u-navbar title="文件中心" :safeAreaInsetTop="true" leftIcon=""> </u-navbar>
     <view class="main">
       <u-subsection
-        :list="list"
+        :list="sectionList"
         mode="subsection"
         :current="curNow"
         @change="sectionChange"
@@ -14,7 +14,7 @@
           v-for="(item, index) in fileData"
           :key="index"
         >
-          <view class="content flcard" @click="openFile(item.id)" v-if="item.bpmStatus == 1">
+          <div class="content flcard" @tap="openFile(item)">
             <view
               class="demo-layout bg-purple-light"
               style="margin-bottom: 20rpx"
@@ -53,7 +53,7 @@
                 >上传时间</view
               >
             </view>
-          </view>
+          </div>
         </u-list-item>
       </u-list>
     </view>
@@ -62,28 +62,46 @@
 
 <script>
 import api from "@/api/api";
+import { computed } from "uview-ui/libs/mixin/mixin";
 export default {
   components: {},
   name: "filecenter",
   watch: {},
   data() {
     return {
-      list: [{ name: "全部" }, { name: "待审批" }, { name: "已审批" }],
+      sectionList: [
+        { name: "全部", code: 0 },
+        { name: "待审批", code: 1 },
+        { name: "已审批", code: 2 },
+      ],
       curNow: 0,
       fileData: [],
-	  bpmStatus:1,//1处理中  2 已完成  3 已驳回
+      bpmStatus: 1, //1处理中  2 已完成  3 已驳回
     };
   },
   mounted() {
     this.getFileInfo();
   },
+  computed: {},
   methods: {
-    sectionChange(index) {
-      this.curNow = index;
+    sectionChange(newVal) {
+      this.curNow = newVal;
+      if (this.curNow === 0) {
+        // 如果选择了“全部”,返回所有文件
+        this.bpmStatus = "";
+        this.getFileInfo(this.bpmStatus);
+      } else if (this.curNow === 1) {
+        // 否则,根据curNow的值过滤文件
+        this.bpmStatus = 1;
+        this.getFileInfo(this.bpmStatus);
+      } else if (this.curNow === 2) {
+        this.bpmStatus = 2;
+        this.getFileInfo(this.bpmStatus);
+      }
     },
-    getFileInfo() {
+    getFileInfo(code) {
       var params = {
-        bpmStatus: "",
+        bpmStatus: code,
         column: "createTime",
         fileSuffix: "",
         likeFileName: "",
@@ -109,23 +127,9 @@ export default {
           });
       });
     },
-    openFile(ID) {
-      var params = {
-        id: ID,
-      };
-      new Promise((resolve, reject) => {
-        api
-          .getFilePreview(params)
-          .then((response) => {
-            if (response.data.code == 200) {
-            } else {
-              reject(response);
-            }
-          })
-          .catch((error) => {
-            console.log("catch===>response", response);
-            reject(error);
-          });
+    openFile(params) {
+      uni.navigateTo({
+        url: `/pages/filecenter/fileModel?id=${params.id}&type=${params.fileSuffix}`,
       });
     },
   },