From 2aabdb83ad578b0c9213a18d1fb1257349e2bc3f Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期五, 17 二月 2023 10:47:32 +0800
Subject: [PATCH] fix 修复 管理员登出动态租户未清理导致二次无法登录

---
 ruoyi-ui/src/views/system/oss/index.vue |  100 ++++++++++++++++++++++++++++++++++----------------
 1 files changed, 68 insertions(+), 32 deletions(-)

diff --git a/ruoyi-ui/src/views/system/oss/index.vue b/ruoyi-ui/src/views/system/oss/index.vue
index b4c5a46..ae6e4d8 100644
--- a/ruoyi-ui/src/views/system/oss/index.vue
+++ b/ruoyi-ui/src/views/system/oss/index.vue
@@ -40,15 +40,6 @@
           end-placeholder="缁撴潫鏃ユ湡"
         ></el-date-picker>
       </el-form-item>
-      <el-form-item label="涓婁紶浜�" prop="createBy">
-        <el-input
-          v-model="queryParams.createBy"
-          placeholder="璇疯緭鍏ヤ笂浼犱汉"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
       <el-form-item label="鏈嶅姟鍟�" prop="service">
         <el-input
           v-model="queryParams.service"
@@ -118,7 +109,10 @@
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
-    <el-table v-loading="loading" :data="ossList" @selection-change="handleSelectionChange">
+    <el-table v-loading="loading" :data="ossList" @selection-change="handleSelectionChange"
+              :header-cell-class-name="handleHeaderClass"
+              @header-click="handleHeaderCLick"
+              v-if="showTable">
       <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="fileName" />
@@ -135,13 +129,15 @@
                 v-if="!checkFileSuffix(scope.row.fileSuffix) || !previewListResource"/>
         </template>
       </el-table-column>
-      <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="180">
+      <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="180"
+                       sortable="custom">
         <template slot-scope="scope">
           <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="涓婁紶浜�" align="center" prop="createBy" />
-      <el-table-column label="鏈嶅姟鍟�" align="center" prop="service" />
+      <el-table-column label="涓婁紶浜�" align="center" prop="createByName" />
+      <el-table-column label="鏈嶅姟鍟�" align="center" prop="service"
+                       sortable="custom"/>
       <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
@@ -187,13 +183,13 @@
 </template>
 
 <script>
-import { listOss, delOss, changePreviewListResource } from "@/api/system/oss";
-import { downLoadOss } from "@/utils/download";
+import { listOss, delOss } from "@/api/system/oss";
 
 export default {
   name: "Oss",
   data() {
     return {
+      showTable: true,
       // 鎸夐挳loading
       buttonLoading: false,
       // 閬僵灞�
@@ -222,6 +218,8 @@
       previewListResource: true,
       // 鍒涘缓鏃堕棿鏃堕棿鑼冨洿
       daterangeCreateTime: [],
+      // 榛樿鎺掑簭
+      defaultSort: {prop: 'createTime', order: 'ascending'},
       // 鏌ヨ鍙傛暟
       queryParams: {
         pageNum: 1,
@@ -229,9 +227,7 @@
         fileName: undefined,
         originalName: undefined,
         fileSuffix: undefined,
-        url: undefined,
         createTime: undefined,
-        createBy: undefined,
         service: undefined
       },
       // 琛ㄥ崟鍙傛暟
@@ -263,6 +259,7 @@
         this.ossList = response.rows;
         this.total = response.total;
         this.loading = false;
+        this.showTable = true;
       });
     },
     checkFileSuffix(fileSuffix) {
@@ -290,8 +287,11 @@
     },
     /** 閲嶇疆鎸夐挳鎿嶄綔 */
     resetQuery() {
+      this.showTable = false;
       this.daterangeCreateTime = [];
       this.resetForm("queryForm");
+      this.queryParams.orderByColumn = this.defaultSort.prop;
+      this.queryParams.isAsc = this.defaultSort.order;
       this.handleQuery();
     },
     // 澶氶�夋閫変腑鏁版嵁
@@ -299,6 +299,51 @@
       this.ids = selection.map(item => item.ossId)
       this.single = selection.length!==1
       this.multiple = !selection.length
+    },
+    // 璁剧疆鍒楃殑鎺掑簭涓烘垜浠嚜瀹氫箟鐨勬帓搴�
+    handleHeaderClass({column}) {
+      column.order = column.multiOrder
+    },
+    // 鐐瑰嚮琛ㄥご杩涜鎺掑簭
+    handleHeaderCLick(column) {
+      if (column.sortable !== 'custom') {
+        return
+      }
+      switch (column.multiOrder) {
+        case 'descending':
+          column.multiOrder = 'ascending';
+          break;
+        case 'ascending':
+          column.multiOrder = '';
+          break;
+        default:
+          column.multiOrder = 'descending';
+          break;
+      }
+      this.handleOrderChange(column.property, column.multiOrder)
+    },
+    handleOrderChange(prop, order) {
+      let orderByArr = this.queryParams.orderByColumn ? this.queryParams.orderByColumn.split(",") : [];
+      let isAscArr = this.queryParams.isAsc ? this.queryParams.isAsc.split(",") : [];
+      let propIndex = orderByArr.indexOf(prop)
+      if (propIndex !== -1) {
+        if (order) {
+          //鎺掑簭閲屽凡瀛樺湪 鍙慨鏀规帓搴�
+          isAscArr[propIndex] = order;
+        } else {
+          //濡傛灉order涓簄ull 鍒欏垹闄ゆ帓搴忓瓧娈靛拰灞炴��
+          isAscArr.splice(propIndex, 1);//鍒犻櫎鎺掑簭
+          orderByArr.splice(propIndex, 1);//鍒犻櫎灞炴��
+        }
+      } else {
+        //鎺掑簭閲屼笉瀛樺湪鍒欐柊澧炴帓搴�
+        orderByArr.push(prop);
+        isAscArr.push(order);
+      }
+      //鍚堝苟鎺掑簭
+      this.queryParams.orderByColumn = orderByArr.join(",");
+      this.queryParams.isAsc = isAscArr.join(",");
+      this.getList();
     },
     /** 浠诲姟鏃ュ織鍒楄〃鏌ヨ */
     handleOssConfig() {
@@ -325,22 +370,18 @@
     },
     /** 涓嬭浇鎸夐挳鎿嶄綔 */
     handleDownload(row) {
-      downLoadOss(row.ossId)
+      this.$download.oss(row.ossId)
     },
     /** 鍒犻櫎鎸夐挳鎿嶄綔 */
     handleDelete(row) {
       const ossIds = row.ossId || this.ids;
-      this.$confirm('鏄惁纭鍒犻櫎OSS瀵硅薄瀛樺偍缂栧彿涓�"' + ossIds + '"鐨勬暟鎹」?', "璀﹀憡", {
-          confirmButtonText: "纭畾",
-          cancelButtonText: "鍙栨秷",
-          type: "warning"
-      }).then(() => {
+      this.$modal.confirm('鏄惁纭鍒犻櫎OSS瀵硅薄瀛樺偍缂栧彿涓�"' + ossIds + '"鐨勬暟鎹」?').then(() => {
         this.loading = true;
         return delOss(ossIds);
       }).then(() => {
         this.loading = false;
         this.getList();
-        this.msgSuccess("鍒犻櫎鎴愬姛");
+        this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
       }).finally(() => {
         this.loading = false;
       });
@@ -348,16 +389,11 @@
     // 棰勮鍒楄〃鍥剧墖鐘舵�佷慨鏀�
     handlePreviewListResource(previewListResource) {
       let text = previewListResource ? "鍚敤" : "鍋滅敤";
-      this.$confirm(
-        '纭瑕�"' + text + '""棰勮鍒楄〃鍥剧墖"閰嶇疆鍚�?', "璀﹀憡", {
-          confirmButtonText: "纭畾",
-          cancelButtonText: "鍙栨秷",
-          type: "warning",
-      }).then(() => {
-        return changePreviewListResource(previewListResource);
+      this.$modal.confirm('纭瑕�"' + text + '""棰勮鍒楄〃鍥剧墖"閰嶇疆鍚�?').then(() => {
+        return this.updateConfigByKey("sys.oss.previewListResource", previewListResource);
       }).then(() => {
         this.getList()
-        this.msgSuccess(text + "鎴愬姛");
+        this.$modal.msgSuccess(text + "鎴愬姛");
       }).catch(() => {
         this.previewListResource = previewListResource !== true;
       })

--
Gitblit v1.9.3