From 2af534eea471f4adb104906c7a814bcc66d4d68d Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期一, 13 九月 2021 13:03:58 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev --- ruoyi-ui/src/views/system/oss/index.vue | 91 ++++++++++++++++++++++++++++++++++----------- 1 files changed, 69 insertions(+), 22 deletions(-) diff --git a/ruoyi-ui/src/views/system/oss/index.vue b/ruoyi-ui/src/views/system/oss/index.vue index 8312454..b4c5a46 100644 --- a/ruoyi-ui/src/views/system/oss/index.vue +++ b/ruoyi-ui/src/views/system/oss/index.vue @@ -96,23 +96,43 @@ 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> <el-table v-loading="loading" :data="ossList" @selection-change="handleSelectionChange"> <el-table-column type="selection" width="55" align="center" /> - <el-table-column label="浜戝瓨鍌ㄤ富閿�" align="center" prop="ossId" v-if="false"/> + <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="鏂囦欢灞曠ず" align="center" prop="url" > - <template slot-scope="scope" v-if="previewListResource"> + <el-table-column label="鏂囦欢灞曠ず" align="center" prop="url"> + <template slot-scope="scope"> <el-image - v-if="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="!checkFileSuffix(scope.row.fileSuffix) || !previewListResource"/> </template> </el-table-column> <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="180"> @@ -150,7 +170,7 @@ @pagination="getList" /> - <!-- 娣诲姞鎴栦慨鏀筄SS浜戝瓨鍌ㄥ璇濇 --> + <!-- 娣诲姞鎴栦慨鏀筄SS瀵硅薄瀛樺偍瀵硅瘽妗� --> <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="鏂囦欢鍚�"> @@ -167,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", @@ -192,7 +210,7 @@ showSearch: true, // 鎬绘潯鏁� total: 0, - // OSS浜戝瓨鍌ㄨ〃鏍兼暟鎹� + // OSS瀵硅薄瀛樺偍琛ㄦ牸鏁版嵁 ossList: [], // 寮瑰嚭灞傛爣棰� title: "", @@ -230,7 +248,7 @@ this.getList(); }, methods: { - /** 鏌ヨOSS浜戝瓨鍌ㄥ垪琛� */ + /** 鏌ヨOSS瀵硅薄瀛樺偍鍒楄〃 */ getList() { this.loading = true; this.queryParams.params = {}; @@ -239,12 +257,18 @@ this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1]; } this.getConfigKey("sys.oss.previewListResource").then(response => { - this.previewListResource = response.msg; + 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; }); }, // 鍙栨秷鎸夐挳 @@ -276,6 +300,10 @@ this.single = selection.length!==1 this.multiple = !selection.length }, + /** 浠诲姟鏃ュ織鍒楄〃鏌ヨ */ + handleOssConfig() { + this.$router.push({ path: '/system/oss-config/index'}) + }, /** 鏂囦欢鎸夐挳鎿嶄綔 */ handleFile() { this.reset(); @@ -302,18 +330,37 @@ /** 鍒犻櫎鎸夐挳鎿嶄綔 */ handleDelete(row) { const ossIds = row.ossId || this.ids; - this.$confirm('鏄惁纭鍒犻櫎OSS浜戝瓨鍌ㄧ紪鍙蜂负"' + ossIds + '"鐨勬暟鎹」?', "璀﹀憡", { + this.$confirm('鏄惁纭鍒犻櫎OSS瀵硅薄瀛樺偍缂栧彿涓�"' + ossIds + '"鐨勬暟鎹」?', "璀﹀憡", { 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