From 2c2dad24d59b37df254d1c003d6c3e1119b51d6c Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期三, 11 八月 2021 14:28:05 +0800
Subject: [PATCH] update 更新 阿里云 maven源 新地址

---
 ruoyi-ui/src/views/system/oss/index.vue |   90 +++++++++++++++++++++++++++++---------------
 1 files changed, 59 insertions(+), 31 deletions(-)

diff --git a/ruoyi-ui/src/views/system/oss/index.vue b/ruoyi-ui/src/views/system/oss/index.vue
index 0ad14cb..a183938 100644
--- a/ruoyi-ui/src/views/system/oss/index.vue
+++ b/ruoyi-ui/src/views/system/oss/index.vue
@@ -71,9 +71,19 @@
           plain
           icon="el-icon-plus"
           size="mini"
-          @click="handleAdd"
+          @click="handleFile"
           v-hasPermi="['system:oss:upload']"
-        >涓婁紶</el-button>
+        >涓婁紶鏂囦欢</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          plain
+          icon="el-icon-plus"
+          size="mini"
+          @click="handleImage"
+          v-hasPermi="['system:oss:upload']"
+        >涓婁紶鍥剧墖</el-button>
       </el-col>
       <el-col :span="1.5">
         <el-button
@@ -86,6 +96,7 @@
           v-hasPermi="['system:oss:remove']"
         >鍒犻櫎</el-button>
       </el-col>
+
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
@@ -94,8 +105,18 @@
       <el-table-column label="浜戝瓨鍌ㄤ富閿�" align="center" prop="ossId" v-if="false"/>
       <el-table-column label="鏂囦欢鍚�" align="center" prop="fileName" />
       <el-table-column label="鍘熷悕" align="center" prop="originalName" />
-      <el-table-column label="鏂囦欢鍚庣紑鍚�" align="center" prop="fileSuffix" />
-      <el-table-column label="URL鍦板潃" align="center" prop="url" />
+      <el-table-column label="鏂囦欢鍚庣紑" align="center" prop="fileSuffix" />
+      <el-table-column label="鏂囦欢灞曠ず" align="center" prop="url">
+        <template slot-scope="scope">
+          <el-image
+            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="!checkFileSuffix(scope.row.fileSuffix) || !previewListResource"/>
+        </template>
+      </el-table-column>
       <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="180">
         <template slot-scope="scope">
           <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
@@ -135,7 +156,8 @@
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
         <el-form-item label="鏂囦欢鍚�">
-          <imageUpload v-model="form.file"/>
+          <fileUpload v-model="form.file" v-if="type === 0"/>
+          <imageUpload v-model="form.file" v-if="type === 1"/>
         </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
@@ -147,7 +169,8 @@
 </template>
 
 <script>
-import { listOss, delOss, addOss, downloadOss } from "@/api/system/oss";
+import { listOss, delOss } from "@/api/system/oss";
+import { downLoadOss } from "@/utils/download";
 
 export default {
   name: "Oss",
@@ -173,8 +196,12 @@
       ossList: [],
       // 寮瑰嚭灞傛爣棰�
       title: "",
+      // 寮瑰嚭灞傛爣棰�
+      type: 0,
       // 鏄惁鏄剧ず寮瑰嚭灞�
       open: false,
+      // 棰勮鍒楄〃鍥剧墖
+      previewListResource: true,
       // 鍒涘缓鏃堕棿鏃堕棿鑼冨洿
       daterangeCreateTime: [],
       // 鏌ヨ鍙傛暟
@@ -211,10 +238,19 @@
         this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0];
         this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
       }
+      this.getConfigKey("sys.oss.previewListResource").then(response => {
+        this.previewListResource = response.msg === undefined ? true : response.msg === 'true';
+      });
       listOss(this.queryParams).then(response => {
         this.ossList = response.rows;
         this.total = response.total;
         this.loading = false;
+      });
+    },
+    checkFileSuffix(fileSuffix) {
+      let arr = ["png", "jpg", "jpeg"];
+      return arr.some(type => {
+        return fileSuffix.indexOf(type) > -1;
       });
     },
     // 鍙栨秷鎸夐挳
@@ -225,17 +261,7 @@
     // 琛ㄥ崟閲嶇疆
     reset() {
       this.form = {
-        ossId: undefined,
         file: undefined,
-        fileName: undefined,
-        originalName: undefined,
-        fileSuffix: undefined,
-        url: undefined,
-        createTime: undefined,
-        createBy: undefined,
-        updateTime: undefined,
-        updateBy: undefined,
-        service: undefined
       };
       this.resetForm("form");
     },
@@ -256,26 +282,28 @@
       this.single = selection.length!==1
       this.multiple = !selection.length
     },
-    /** 鏂板鎸夐挳鎿嶄綔 */
-    handleAdd() {
+    /** 鏂囦欢鎸夐挳鎿嶄綔 */
+    handleFile() {
       this.reset();
       this.open = true;
-      this.title = "涓婁紶OSS浜戝瓨鍌�";
+      this.title = "涓婁紶鏂囦欢";
+      this.type = 0;
+    },
+    /** 鍥剧墖鎸夐挳鎿嶄綔 */
+    handleImage() {
+      this.reset();
+      this.open = true;
+      this.title = "涓婁紶鍥剧墖";
+      this.type = 1;
     },
     /** 鎻愪氦鎸夐挳 */
     submitForm() {
-      this.$refs["form"].validate(valid => {
-        if (valid) {
-          this.buttonLoading = true;
-          addOss(this.form).then(response => {
-            this.msgSuccess("涓婁紶鎴愬姛");
-            this.open = false;
-            this.getList();
-          }).finally(() => {
-            this.buttonLoading = false;
-          });
-        }
-      });
+      this.open = false;
+      this.getList();
+    },
+    /** 涓嬭浇鎸夐挳鎿嶄綔 */
+    handleDownload(row) {
+      downLoadOss(row.ossId)
     },
     /** 鍒犻櫎鎸夐挳鎿嶄綔 */
     handleDelete(row) {

--
Gitblit v1.9.3