<!--
|
* @Author: lzhe lzhe@example.com
|
* @Date: 2024-03-26 10:28:33
|
* @LastEditors: lzhe lzhe@example.com
|
* @LastEditTime: 2024-09-29 17:49:26
|
* @FilePath: /smart-web/src/views/master/person/main/index.vue
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
-->
|
<template>
|
<div class="dict-main">
|
<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.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>
|
<el-button @click="searchClearBtn">清空</el-button>
|
</el-form-item>
|
</el-form>
|
<div>
|
<div class="dict-Btn">
|
<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="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">
|
<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_del(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>
|
<el-pagination
|
style="margin-top: 12px;"
|
@size-change="handleSizeChange"
|
@current-change="handleCurrentChange"
|
:current-page="currentPage4"
|
:page-sizes="[15, 50, 100]"
|
:page-size="15"
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="total">
|
</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"
|
:before-upload="beforeAvatarUpload"
|
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: {
|
domainName: "",
|
name: "",
|
originalName: "",
|
current: "1",
|
size: "15"
|
},
|
dialog: {
|
save: false,
|
allocation: false
|
},
|
tableData: []
|
}
|
},
|
created(){
|
|
},
|
mounted(){
|
this.searchBtn();
|
},
|
components: {
|
|
},
|
methods: {
|
beforeAvatarUpload() {
|
var TOKEN = this.$TOOL.cookie.get("TOKEN")
|
this.authorization = {Authorization: 'Basic c2FiZXI6c2FiZXJfc2VjcmV0','Blade-Auth': TOKEN}
|
return true;
|
},
|
exportFile(row,index){
|
window.open(row.link);
|
},
|
handleAvatarSuccess(res, file) {
|
this.fileDialogVisible = false;
|
this.searchClearBtn();
|
},
|
showUpload() {
|
this.fileDialogVisible = true;
|
},
|
codeClick() {
|
|
},
|
searchClearBtn() {
|
this.searchData = {
|
domainName: "",
|
name: "",
|
originalName: "",
|
current: "1",
|
size: "15"
|
}
|
this.searchBtn();
|
},
|
searchclick() {
|
this.searchData.current = "1";
|
this.searchData.size = "15";
|
this.searchBtn();
|
},
|
searchBtn() {
|
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_del(row) {
|
var that = this;
|
this.$confirm(`确定将选择数据删除?`, '', {
|
type: 'warning'
|
}).then(() => {
|
this.$HTTP.post("/api/blade-resource/attach/remove?ids="+row.id).then(res=> {
|
if(res.code == 200) {
|
that.$message.success("操作成功");
|
that.searchBtn();
|
}
|
})
|
}).catch(() => {
|
|
})
|
},
|
//查看
|
table_show(row){
|
this.dialog.save = true
|
this.$nextTick(() => {
|
this.$refs.saveDialog.open('show').setData(row)
|
})
|
},
|
handleSelectionChange(selection) {
|
this.selection = selection;
|
},
|
delFile() {
|
if(this.selection.length == 0) {
|
this.$message({
|
message: '请选择至少一条数据',
|
type: 'warning'
|
});
|
return;
|
}
|
var selStr = "";
|
this.selection.map(item=> {
|
selStr += item.id + ","
|
})
|
selStr = selStr.replace(/,$/, '');
|
var that = this;
|
this.$HTTP.post("/api/blade-resource/attach/remove?ids="+selStr).then(res=> {
|
if(res.code == 200) {
|
that.$message.success("操作成功");
|
that.searchclick();
|
}
|
})
|
},
|
changeDepartment() {
|
this.departmentVisible = true;
|
},
|
handleSizeChange(val) {
|
console.log(`每页 ${val} 条`);
|
this.searchData.current = "1";
|
this.searchData.size = val;
|
this.searchBtn();
|
},
|
handleCurrentChange(val) {
|
console.log(`当前页: ${val}`);
|
this.searchData.current = val;
|
this.searchBtn();
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.dict-main {
|
background-color: #fff;
|
margin: 8px;
|
padding: 8px;
|
}
|
.dict-Btn {
|
display: flex;
|
justify-content: space-between;
|
border-bottom: 1px solid #dcdfe6;
|
margin-bottom: 8px;
|
padding-left: 8px;
|
padding-right: 8px;
|
}
|
.dict-btn-bottom {
|
padding-left: 8px;
|
padding-right: 8px;
|
margin-bottom: 8px;
|
}
|
.dict-table {
|
padding-left: 8px;
|
padding-right: 8px;
|
margin-bottom: 8px;
|
|
}
|
.multipleTableRef {
|
margin-bottom: 8px;
|
}
|
.attachSize {
|
color:#409eff;
|
padding: 0 10px;
|
font-size: 12px;
|
background-color: #ebf4f4;
|
border: 1px solid #d8e8e8;
|
}
|
</style>
|