Files
eladmin-web/src/views/tools/picture/index.vue

103 lines
3.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="app-container">
<eHeader :query="query"/>
<!--表格渲染-->
<el-table v-loading="loading" :data="data" size="small" border style="width: 100%;">
<el-table-column prop="filename" label="文件名"/>
<el-table-column prop="username" label="上传者"/>
<el-table-column :show-overflow-tooltip="true" prop="url" label="链接地址">
<template slot-scope="scope">
<a :href="scope.row.url" style="color: #42b983" target="_blank">{{ scope.row.url }}</a>
</template>
</el-table-column>
<el-table-column prop="size" label="文件大小"/>
<el-table-column prop="height" label="高度"/>
<el-table-column prop="width" label="宽度"/>
<el-table-column width="180px" prop="createTime" label="创建日期">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="100px" align="center">
<template slot-scope="scope">
<el-popover
v-if="checkPermission(['ADMIN','PICTURE_ALL','PICTURE_DELETE'])"
v-model="scope.row.delPopover"
placement="top"
width="180">
<p>确定删除本条数据吗</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="scope.row.delPopover = false">取消</el-button>
<el-button :loading="delLoading" type="primary" size="mini" @click="subDelete(scope.$index, scope.row)">确定</el-button>
</div>
<el-button slot="reference" type="danger" size="mini" @click="scope.row.delPopover = true">删除</el-button>
</el-popover>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<el-pagination
:total="total"
style="margin-top: 8px;"
layout="total, prev, pager, next, sizes"
@size-change="sizeChange"
@current-change="pageChange"/>
</div>
</template>
<script>
import checkPermission from '@/utils/permission' // 权限判断函数
import initData from '../../../mixins/initData'
import { del } from '@/api/picture'
import { parseTime } from '@/utils/index'
import eHeader from './module/header'
export default {
components: { eHeader },
mixins: [initData],
data() {
return {
delLoading: false, sup_this: this
}
},
created() {
this.$nextTick(() => {
this.init()
})
},
methods: {
parseTime,
checkPermission,
beforeInit() {
this.url = 'api/pictures'
const sort = 'id,desc'
const query = this.query
const value = query.value
this.params = { page: this.page, size: this.size, sort: sort }
if (value) { this.params['filename'] = value }
return true
},
subDelete(index, row) {
this.delLoading = true
del(row.id).then(res => {
this.delLoading = false
row.delPopover = false
this.init()
this.$notify({
title: '删除成功',
type: 'success',
duration: 2500
})
}).catch(err => {
this.delLoading = false
row.delPopover = false
console.log(err.response.data.message)
})
}
}
}
</script>
<style scoped>
</style>