From 3ba8323cb7cc42f1441a41d998dad3e5512dbbae Mon Sep 17 00:00:00 2001
From: zlyx <1242874891@qq.com>
Date: 星期一, 30 一月 2023 20:10:16 +0800
Subject: [PATCH] update 修改 BaseEntity 创建人, 修改人字段类型, 修改相关 LambdaQueryWrapper 类型判断 ; update 修改 CreateAndUpdateMetaObjectHandler#insertFill 字段填充保存相关参数id ;

---
 ruoyi-ui/src/views/system/oss/index.vue |  216 +++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 166 insertions(+), 50 deletions(-)

diff --git a/ruoyi-ui/src/views/system/oss/index.vue b/ruoyi-ui/src/views/system/oss/index.vue
index 0ad14cb..9f8557c 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,23 +96,57 @@
           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 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="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="createTime" width="180">
+      <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"
+                       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="service"
+                       sortable="custom"/>
       <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
@@ -131,11 +175,12 @@
       @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="鏂囦欢鍚�">
-          <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,12 +192,13 @@
 </template>
 
 <script>
-import { listOss, delOss, addOss, downloadOss } from "@/api/system/oss";
+import { listOss, delOss } from "@/api/system/oss";
 
 export default {
   name: "Oss",
   data() {
     return {
+      showTable: true,
       // 鎸夐挳loading
       buttonLoading: false,
       // 閬僵灞�
@@ -169,14 +215,20 @@
       showSearch: true,
       // 鎬绘潯鏁�
       total: 0,
-      // OSS浜戝瓨鍌ㄨ〃鏍兼暟鎹�
+      // OSS瀵硅薄瀛樺偍琛ㄦ牸鏁版嵁
       ossList: [],
       // 寮瑰嚭灞傛爣棰�
       title: "",
+      // 寮瑰嚭灞傛爣棰�
+      type: 0,
       // 鏄惁鏄剧ず寮瑰嚭灞�
       open: false,
+      // 棰勮鍒楄〃鍥剧墖
+      previewListResource: true,
       // 鍒涘缓鏃堕棿鏃堕棿鑼冨洿
       daterangeCreateTime: [],
+      // 榛樿鎺掑簭
+      defaultSort: {prop: 'createTime', order: 'ascending'},
       // 鏌ヨ鍙傛暟
       queryParams: {
         pageNum: 1,
@@ -203,7 +255,7 @@
     this.getList();
   },
   methods: {
-    /** 鏌ヨOSS浜戝瓨鍌ㄥ垪琛� */
+    /** 鏌ヨOSS瀵硅薄瀛樺偍鍒楄〃 */
     getList() {
       this.loading = true;
       this.queryParams.params = {};
@@ -211,10 +263,20 @@
         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;
+        this.showTable = true;
+      });
+    },
+    checkFileSuffix(fileSuffix) {
+      let arr = ["png", "jpg", "jpeg"];
+      return arr.some(type => {
+        return fileSuffix.indexOf(type) > -1;
       });
     },
     // 鍙栨秷鎸夐挳
@@ -225,17 +287,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");
     },
@@ -246,8 +298,11 @@
     },
     /** 閲嶇疆鎸夐挳鎿嶄綔 */
     resetQuery() {
+      this.showTable = false;
       this.daterangeCreateTime = [];
       this.resetForm("queryForm");
+      this.queryParams.orderByColumn = this.defaultSort.prop;
+      this.queryParams.isAsc = this.defaultSort.order;
       this.handleQuery();
     },
     // 澶氶�夋閫変腑鏁版嵁
@@ -256,42 +311,103 @@
       this.single = selection.length!==1
       this.multiple = !selection.length
     },
-    /** 鏂板鎸夐挳鎿嶄綔 */
-    handleAdd() {
+    // 璁剧疆鍒楃殑鎺掑簭涓烘垜浠嚜瀹氫箟鐨勬帓搴�
+    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() {
+      this.$router.push({ path: '/system/oss-config/index'})
+    },
+    /** 鏂囦欢鎸夐挳鎿嶄綔 */
+    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) {
+      this.$download.oss(row.ossId)
     },
     /** 鍒犻櫎鎸夐挳鎿嶄綔 */
     handleDelete(row) {
       const ossIds = row.ossId || this.ids;
-      this.$confirm('鏄惁纭鍒犻櫎OSS浜戝瓨鍌ㄧ紪鍙蜂负"' + ossIds + '"鐨勬暟鎹」?', "璀﹀憡", {
-          confirmButtonText: "纭畾",
-          cancelButtonText: "鍙栨秷",
-          type: "warning"
-        }).then(() => {
-          this.loading = true;
-          return delOss(ossIds);
-        }).then(() => {
-          this.loading = false;
-          this.getList();
-          this.msgSuccess("鍒犻櫎鎴愬姛");
-        }).catch(() => {});
+      this.$modal.confirm('鏄惁纭鍒犻櫎OSS瀵硅薄瀛樺偍缂栧彿涓�"' + ossIds + '"鐨勬暟鎹」?').then(() => {
+        this.loading = true;
+        return delOss(ossIds);
+      }).then(() => {
+        this.loading = false;
+        this.getList();
+        this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+      }).finally(() => {
+        this.loading = false;
+      });
+    },
+    // 棰勮鍒楄〃鍥剧墖鐘舵�佷慨鏀�
+    handlePreviewListResource(previewListResource) {
+      let text = previewListResource ? "鍚敤" : "鍋滅敤";
+      this.$modal.confirm('纭瑕�"' + text + '""棰勮鍒楄〃鍥剧墖"閰嶇疆鍚�?').then(() => {
+        return this.updateConfigByKey("sys.oss.previewListResource", previewListResource);
+      }).then(() => {
+        this.getList()
+        this.$modal.msgSuccess(text + "鎴愬姛");
+      }).catch(() => {
+        this.previewListResource = previewListResource !== true;
+      })
     }
   }
 };

--
Gitblit v1.9.3