gaoshp
2024-06-13 fd7586c8d91473d2850af1e48b12f1a289e6b8d1
src/views/console/resource/attach.vue
@@ -8,12 +8,15 @@
-->
<template>
   <div class="dict-main">
      <el-form :inline="true" :model="searchData" abel-width="120px">
         <el-form-item label="字典编号">
            <el-input v-model="searchData.code" placeholder="字典编号" clearable />
      <el-form :inline="true" :model="searchData" label-width="80px">
         <el-form-item label="附件域名">
            <el-input v-model="searchData.domainName" placeholder="附件域名" clearable />
         </el-form-item>
         <el-form-item label="字典名称">
            <el-input v-model="searchData.dictValue" placeholder="字典名称" clearable></el-input>
         <el-form-item label="附件名称">
            <el-input v-model="searchData.name" placeholder="附件名称" clearable></el-input>
         </el-form-item>
         <el-form-item label="附件原名">
            <el-input v-model="searchData.originalName" placeholder="附件原名" clearable></el-input>
         </el-form-item>
         <el-form-item>
            <el-button type="primary" @click="searchclick">搜索</el-button>
@@ -22,32 +25,28 @@
      </el-form>
      <div>
         <div class="dict-Btn">
            <div class="dict-btn-bottom">
               <el-button type="primary" @click="addData">+ 新增</el-button>
               <el-button type="danger" plain @click="delData">删除</el-button>
            <div class="dict-btn-bottom">
               <el-button @click="showUpload" icon="el-icon-upload">上传</el-button>
               <el-button @click="delFile" type="danger" icon="el-icon-delete">删除</el-button>
            </div>
         </div>
         <div class="dict-table">
            <el-table ref="multipleTableRef" :data="tableData" border style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange">
               <el-table-column type="selection" width="55" />
               <el-table-column prop="code" label="字典编号">
               <el-table-column prop="link" label="附件地址"></el-table-column>
               <el-table-column prop="domainName" label="附件域名"></el-table-column>
               <el-table-column prop="name" label="附件名称"></el-table-column>
               <el-table-column prop="originalName" label="附件原名"></el-table-column>
               <el-table-column prop="extension" label="附件拓展名"></el-table-column>
               <el-table-column prop="attachSize" label="附件大小">
                  <template #default="scope">
                     <el-check-tag type="info" checked @change="table_allocation(scope.row, scope.$index)">{{scope.row.code}}</el-check-tag>
                  </template>
               </el-table-column>
               <el-table-column prop="dictValue" label="字典名称"></el-table-column>
               <el-table-column prop="sort" label="字典排序"></el-table-column>
               <el-table-column prop="isSealed" label="封存">
                  <template #default="scope">
                     <div>{{scope.row.isSealed == 0?"否":"是"}}</div>
                     <span class="attachSize">{{scope.row.attachSize}} B</span>
                  </template>
               </el-table-column>
               <el-table-column fixed="right" label="操作">
                  <template #default="scope">
                     <el-button text type="primary" size="small" @click="table_show(scope.row, scope.$index)">查看</el-button>
                     <el-button type="text" size="small" @click="table_edit(scope.row, scope.$index)">编辑</el-button>
                     <el-button text type="primary" size="small" @click="table_del(scope.row, scope.$index)">删除</el-button>
                     <el-button text type="primary" size="small" @click="table_allocation(scope.row, scope.$index)">字典配置</el-button>
                     <el-button text type="primary" size="small" @click="exportFile(scope.row, scope.$index)">下载</el-button>
                  </template>
               </el-table-column>
            </el-table>
@@ -63,20 +62,34 @@
            </el-pagination>
         </div>
      </div>
      <el-dialog title="附件管理" v-model="fileDialogVisible" :width="600">
         <span>附件上传</span>
         <el-upload
           class="upload-demo"
           drag
           :headers="authorization"
           :on-success="handleAvatarSuccess"
           action="/api/blade-resource/oss/endpoint/put-file-attach">
           <i class="el-icon-upload"></i>
           <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
         </el-upload>
      </el-dialog>
   </div>
</template>
<script>
   export default {
      name: "attach",
      data(){
         return {
            authorization: {Authorization: "Basic c2FiZXI6c2FiZXJfc2VjcmV0"},
            fileDialogVisible: false,
            getModalData: [],
            selection: [],
            total: 0,
            searchData: {
               code: "",
               dictValue: "",
               domainName: "",
               name: "",
               originalName: "",
               current: "1",
               size: "15"
            },
@@ -84,13 +97,6 @@
               save: false,
               allocation: false
            },
            leftActive: true,
            input: '',
            options: [{
               value: '选项1',
               label: '黄金糕'
            }],
            input3: '',
            tableData: []
         }
      },
@@ -104,16 +110,24 @@
         
      },
      methods: {
         exportFile(row,index){
            window.open(row.link);
         },
         handleAvatarSuccess(res, file) {
            this.fileDialogVisible = false;
            this.searchClearBtn();
          },
         showUpload() {
            this.fileDialogVisible = true;
         },
         codeClick() {
            
         },
         addDictSuccess(addDictForm) {
            this.searchClearBtn();
         },
         searchClearBtn() {
            this.searchData = {
               code: "",
               dictValue: "",
               domainName: "",
               name: "",
               originalName: "",
               current: "1",
               size: "15"
            }
@@ -125,18 +139,18 @@
            this.searchBtn();
         },
         searchBtn() {
            this.$HTTP.get("/api/blade-system/dict/parent-list",this.searchData).then(res=> {
            var obj = {};
            for(var key in this.searchData) {
               if(this.searchData[key]) {
                  obj[key] = this.searchData[key];
               }
            }
            this.$HTTP.get("/api/blade-resource/attach/list",obj).then(res=> {
               if(res.code == 200) {
                  this.tableData = res.data.records;
                  this.total = res.data.total;
                  console.log(this.tableData,this.tota)
               }
            })
         },
         //字典配置
         table_allocation(row) {
            this.dialog.allocation = true;
            this.$nextTick(() => {
               this.$refs.allocationDialog.open('edit').setData(row);
            })
         },
         //删除
@@ -145,7 +159,7 @@
            this.$confirm(`确定将选择数据删除?`, '', {
               type: 'warning'
            }).then(() => {
               this.$HTTP.post("/api/blade-system/dict/remove?ids="+row.id).then(res=> {
               this.$HTTP.post("/api/blade-resource/attach/remove?ids="+row.id).then(res=> {
                  if(res.code == 200) {
                     that.$message.success("操作成功");
                     that.searchBtn();
@@ -153,24 +167,6 @@
               })
            }).catch(() => {
            })
         },
         //添加
         addData(){
            this.dialog.save = true
            this.$nextTick(() => {
               this.$refs.saveDialog.open()
            })
         },
         table_edit(row){
            this.dialog.save = true
            this.$HTTP.get("/api/blade-system/dict/detail?id="+row.id).then(res=> {
               if(res.code == 200) {
                  this.dialog.save = true;
                  this.$nextTick(() => {
                     this.$refs.saveDialog.open('edit').setData(res.data);
                  })
               }
            })
         },
         //查看
@@ -183,7 +179,7 @@
         handleSelectionChange(selection) {
            this.selection = selection;
         },
         delData() {
         delFile() {
            if(this.selection.length == 0) {
               this.$message({
                   message: '请选择至少一条数据',
@@ -197,7 +193,7 @@
            })
            selStr = selStr.replace(/,$/, '');
            var that = this;
            this.$HTTP.post("/api/blade-system/dict/remove?ids="+selStr).then(res=> {
            this.$HTTP.post("/api/blade-resource/attach/remove?ids="+selStr).then(res=> {
               if(res.code == 200) {
                  that.$message.success("操作成功");
                  that.searchclick();
@@ -206,13 +202,6 @@
         },
         changeDepartment() {
            this.departmentVisible = true;
         },
         changeTab(name) {
            if(name == 1) {
               this.leftActive = true;
            }else {
               this.leftActive = false;
            }
         },
         handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
@@ -243,10 +232,6 @@
      padding-left: 8px;
      padding-right: 8px;
   }
   .searchStatus {
      margin-right: 6px;
      width: 200px;
   }
   .dict-btn-bottom {
      padding-left: 8px;
      padding-right: 8px;
@@ -261,4 +246,11 @@
   .multipleTableRef {
      margin-bottom: 8px;
   }
   .attachSize {
      color:#409eff;
      padding: 0 10px;
       font-size: 12px;
      background-color: #ebf4f4;
      border: 1px solid #d8e8e8;
   }
</style>