疯狂的狮子li
2021-12-24 5ca038d888922e93bf45c7bd37f3c6dce849dcff
ruoyi-ui/src/views/system/oss/index.vue
@@ -96,25 +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">
          <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">
@@ -152,7 +170,7 @@
      @pagination="getList"
    />
    <!-- 添加或修改OSS云存储对话框 -->
    <!-- 添加或修改OSS对象存储对话框 -->
    <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="文件名">
@@ -169,8 +187,7 @@
</template>
<script>
import { listOss, delOss } from "@/api/system/oss";
import { downLoadOss } from "@/utils/zipdownload";
import { listOss, delOss, changePreviewListResource } from "@/api/system/oss";
export default {
  name: "Oss",
@@ -192,7 +209,7 @@
      showSearch: true,
      // 总条数
      total: 0,
      // OSS云存储表格数据
      // OSS对象存储表格数据
      ossList: [],
      // 弹出层标题
      title: "",
@@ -230,7 +247,7 @@
    this.getList();
  },
  methods: {
    /** 查询OSS云存储列表 */
    /** 查询OSS对象存储列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
@@ -245,6 +262,12 @@
        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 +299,10 @@
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 任务日志列表查询 */
    handleOssConfig() {
      this.$router.push({ path: '/system/oss-config/index'})
    },
    /** 文件按钮操作 */
    handleFile() {
      this.reset();
@@ -297,23 +324,33 @@
    },
    /** 下载按钮操作 */
    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.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 changePreviewListResource(previewListResource);
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess(text + "成功");
      }).catch(() => {
        this.previewListResource = previewListResource !== true;
      })
    }
  }
};