From 0375fd319c9f3b08d255c814cb0f8521d8ec641b Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期三, 18 八月 2021 11:11:24 +0800
Subject: [PATCH] !78 同步dev分支 Merge pull request !78 from 疯狂的狮子Li/dev

---
 ruoyi-ui/src/views/system/oss/index.vue |   75 ++++++++++++++++++++++++++++++-------
 1 files changed, 60 insertions(+), 15 deletions(-)

diff --git a/ruoyi-ui/src/views/system/oss/index.vue b/ruoyi-ui/src/views/system/oss/index.vue
index 1171cc9..2bbbba0 100644
--- a/ruoyi-ui/src/views/system/oss/index.vue
+++ b/ruoyi-ui/src/views/system/oss/index.vue
@@ -96,7 +96,25 @@
           v-hasPermi="['system:oss:remove']"
         >鍒犻櫎</el-button>
       </el-col>
-
+      <el-col :span="1.5">
+        <el-button
+          :type="previewListResource ? 'danger' : 'warning'"
+          plain
+          size="mini"
+          @click="handlePreviewListResource(!previewListResource)"
+          v-hasPermi="['system:oss:edit']"
+        >棰勮寮�鍏� : {{previewListResource ? "绂佺敤" : "鍚敤"}}</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="info"
+          plain
+          icon="el-icon-s-operation"
+          size="mini"
+          @click="handleOssConfig"
+          v-hasPermi="['system:oss:list']"
+        >閰嶇疆绠$悊</el-button>
+      </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
@@ -109,12 +127,12 @@
       <el-table-column label="鏂囦欢灞曠ず" align="center" prop="url">
         <template slot-scope="scope">
           <el-image
-            v-if="previewListResource && scope.row.fileSuffix.indexOf('png','jpg','jpeg') > 0"
+            v-if="previewListResource && checkFileSuffix(scope.row.fileSuffix)"
             style="width: 100px; height: 100px;"
             :src="scope.row.url"
             :preview-src-list="[scope.row.url]"/>
           <span v-text="scope.row.url"
-                v-if="scope.row.fileSuffix.indexOf('png','jpg','jpeg') < 0 || !previewListResource"/>
+                v-if="!checkFileSuffix(scope.row.fileSuffix) || !previewListResource"/>
         </template>
       </el-table-column>
       <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="180">
@@ -169,10 +187,8 @@
 </template>
 
 <script>
-import { listOss, delOss } from "@/api/system/oss";
-import { downLoadOss } from "@/utils/ossdownload";
-import { updateConfig } from "@/api/system/config";
-
+import { listOss, delOss, changePreviewListResource } from "@/api/system/oss";
+import { downLoadOss } from "@/utils/download";
 
 export default {
   name: "Oss",
@@ -249,6 +265,12 @@
         this.loading = false;
       });
     },
+    checkFileSuffix(fileSuffix) {
+      let arr = ["png", "jpg", "jpeg"];
+      return arr.some(type => {
+        return fileSuffix.indexOf(type) > -1;
+      });
+    },
     // 鍙栨秷鎸夐挳
     cancel() {
       this.open = false;
@@ -277,6 +299,10 @@
       this.ids = selection.map(item => item.ossId)
       this.single = selection.length!==1
       this.multiple = !selection.length
+    },
+    /** 浠诲姟鏃ュ織鍒楄〃鏌ヨ */
+    handleOssConfig() {
+      this.$router.push({ path: '/system/oss-config/index'})
     },
     /** 鏂囦欢鎸夐挳鎿嶄綔 */
     handleFile() {
@@ -308,14 +334,33 @@
           confirmButtonText: "纭畾",
           cancelButtonText: "鍙栨秷",
           type: "warning"
-        }).then(() => {
-          this.loading = true;
-          return delOss(ossIds);
-        }).then(() => {
-          this.loading = false;
-          this.getList();
-          this.msgSuccess("鍒犻櫎鎴愬姛");
-        }).catch(() => {});
+      }).then(() => {
+        this.loading = true;
+        return delOss(ossIds);
+      }).then(() => {
+        this.loading = false;
+        this.getList();
+        this.msgSuccess("鍒犻櫎鎴愬姛");
+      }).finally(() => {
+        this.loading = false;
+      });
+    },
+    // 棰勮鍒楄〃鍥剧墖鐘舵�佷慨鏀�
+    handlePreviewListResource(previewListResource) {
+      let text = previewListResource ? "鍚敤" : "鍋滅敤";
+      this.$confirm(
+        '纭瑕�"' + text + '""棰勮鍒楄〃鍥剧墖"閰嶇疆鍚�?', "璀﹀憡", {
+          confirmButtonText: "纭畾",
+          cancelButtonText: "鍙栨秷",
+          type: "warning",
+      }).then(() => {
+        return changePreviewListResource(previewListResource);
+      }).then(() => {
+        this.getList()
+        this.msgSuccess(text + "鎴愬姛");
+      }).catch(() => {
+        this.previewListResource = previewListResource !== true;
+      })
     }
   }
 };

--
Gitblit v1.9.3