yusm 3 недель назад
Родитель
Сommit
65901b007b

+ 49 - 1
fhKeeper/formulahousekeeper/timesheet/src/components/taskComponent.vue

@@ -1801,13 +1801,28 @@
                     ></p>
                     <p v-if="item2.attachment != null">
                       {{ $t("fu-jian") }}:
-                      <a
+                      <!-- <a
                         v-for="file in JSON.parse(item2.attachment)"
                         style="margin-right: 5px"
                         :href="'/upload/' + file.serverName"
                         :download="file.originName"
                         >{{ file.originName }}</a
+                      > -->
+                      <el-link
+                        v-for="item in JSON.parse(item2.attachment)"
+                        @click.prevent="viewOnline2(item)"
                       >
+                        <span style="margin-left: 8px; color: #262626">{{
+                          item.originName
+                        }}</span>
+                        <el-button
+                          icon="el-icon-download"
+                          circle
+                          size="mini"
+                          style="margin-left: 100px"
+                          @click.stop.native="downloadByA(item)"
+                        ></el-button>
+                      </el-link>
                     </p>
                   </div>
                   <p></p>
@@ -3274,6 +3289,32 @@ export default {
       this.times = `${Y}-${M}-${D}`;
       console.log(this.times, "时间");
     },
+    // 在线预览
+    viewOnline2(row) {
+      sessionStorage.setItem("fileName", row.serverName);
+      sessionStorage.setItem("fileUrl", "/upload/" + row.serverName);
+      let routeUrl;
+      if (row.serverName.endsWith(".doc") || row.serverName.endsWith(".docx")) {
+        routeUrl = this.$router.resolve({
+          path: "/viewWord",
+          params: {},
+        });
+      } else if (
+        row.serverName.endsWith(".xls") ||
+        row.serverName.endsWith(".xlsx")
+      ) {
+        routeUrl = this.$router.resolve({
+          path: "/viewExcel",
+          params: {},
+        });
+      }
+      if (routeUrl != null) {
+        console.log(routeUrl.href);
+        window.open(routeUrl.href, "_blank");
+      } else {
+        window.open(row.url, "_blank");
+      }
+    },
     // 提交按钮
     submitInsert() {
       if (this.textContent !== true)
@@ -4152,6 +4193,13 @@ export default {
         },
       );
     },
+    downloadByA(row) {
+      const a = document.createElement("a"); // 创建a标签
+      a.setAttribute("download", row.serverName); // download属性
+      a.setAttribute("href", "/upload/" + row.serverName); // href链接
+      a.click(); // 自执行点击事件
+      a.remove();
+    },
     uploadFileClickTwo(item, row) {
       let files = new FormData();
       files.append("projectId", this.curProjectId);

Разница между файлами не показана из-за своего большого размера
+ 1180 - 819
fhKeeper/formulahousekeeper/timesheet/src/views/project/fileCenter.vue