【modify】使用ESLint格式化代码
This commit is contained in:
@@ -76,105 +76,105 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {JeroListMixin} from '@/mixins/JeroListMixin'
|
||||
import Vue from 'vue'
|
||||
import { ACCESS_TOKEN } from "@/store/mutation-types"
|
||||
const Base64 = require('js-base64').Base64
|
||||
export default {
|
||||
name: "OSSFileList",
|
||||
mixins: [JeroListMixin],
|
||||
data() {
|
||||
return {
|
||||
description: '文件列表',
|
||||
// 表头
|
||||
columns: [
|
||||
{
|
||||
title: '#',
|
||||
dataIndex: '',
|
||||
key: 'rowIndex',
|
||||
width: 60,
|
||||
align: "center",
|
||||
customRender: function (t, r, index) {
|
||||
return parseInt(index) + 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '文件名称',
|
||||
align: "center",
|
||||
dataIndex: 'fileName'
|
||||
},
|
||||
{
|
||||
title: '文件地址',
|
||||
align: "center",
|
||||
dataIndex: 'url'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
align: "center",
|
||||
scopedSlots: {customRender: 'action'},
|
||||
import { JeroListMixin } from '@/mixins/JeroListMixin'
|
||||
import Vue from 'vue'
|
||||
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||
const Base64 = require('js-base64').Base64
|
||||
export default {
|
||||
name: 'OSSFileList',
|
||||
mixins: [JeroListMixin],
|
||||
data () {
|
||||
return {
|
||||
description: '文件列表',
|
||||
// 表头
|
||||
columns: [
|
||||
{
|
||||
title: '#',
|
||||
dataIndex: '',
|
||||
key: 'rowIndex',
|
||||
width: 60,
|
||||
align: 'center',
|
||||
customRender: function (t, r, index) {
|
||||
return parseInt(index) + 1
|
||||
}
|
||||
],
|
||||
url: {
|
||||
upload: "/sys/common/upload",
|
||||
list: "/sys/oss/file/page",
|
||||
delete: "/sys/oss/file/delete",
|
||||
},
|
||||
{
|
||||
title: '文件名称',
|
||||
align: 'center',
|
||||
dataIndex: 'fileName'
|
||||
},
|
||||
{
|
||||
title: '文件地址',
|
||||
align: 'center',
|
||||
dataIndex: 'url'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
align: 'center',
|
||||
scopedSlots: { customRender: 'action' }
|
||||
}
|
||||
],
|
||||
url: {
|
||||
upload: '/sys/common/upload',
|
||||
list: '/sys/oss/file/page',
|
||||
delete: '/sys/oss/file/delete'
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
uploadAction () {
|
||||
return window._CONFIG.domianURL + this.url.upload
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
beforeUpload (file) {
|
||||
var fileType = file.type
|
||||
if (fileType === 'image') {
|
||||
if (fileType.indexOf('image') < 0) {
|
||||
this.$message.warning('请上传图片')
|
||||
return false
|
||||
}
|
||||
} else if (fileType === 'file') {
|
||||
if (fileType.indexOf('image') >= 0) {
|
||||
this.$message.warning('请上传文件')
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
},
|
||||
computed: {
|
||||
uploadAction() {
|
||||
return window._CONFIG['domianURL'] + this.url.upload;
|
||||
handleChange (info) {
|
||||
console.log('ok')
|
||||
if (info.file.status === 'done') {
|
||||
if (info.file.response.success) {
|
||||
this.loadData()
|
||||
this.$message.success(`${info.file.name} 上传成功!`)
|
||||
} else {
|
||||
this.$message.error(`${info.file.response.message}`)
|
||||
}
|
||||
} else if (info.file.status === 'error') {
|
||||
this.$message.error(`${info.file.response.message}`)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
beforeUpload(file) {
|
||||
var fileType = file.type;
|
||||
if (fileType === 'image') {
|
||||
if (fileType.indexOf('image') < 0) {
|
||||
this.$message.warning('请上传图片');
|
||||
return false;
|
||||
}
|
||||
} else if (fileType === 'file') {
|
||||
if (fileType.indexOf('image') >= 0) {
|
||||
this.$message.warning('请上传文件');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true
|
||||
},
|
||||
handleChange(info) {
|
||||
console.log("ok")
|
||||
if (info.file.status === 'done') {
|
||||
if (info.file.response.success) {
|
||||
this.loadData()
|
||||
this.$message.success(`${info.file.name} 上传成功!`);
|
||||
} else {
|
||||
this.$message.error(`${info.file.response.message}`);
|
||||
}
|
||||
} else if (info.file.status === 'error') {
|
||||
this.$message.error(`${info.file.response.message}`);
|
||||
}
|
||||
},
|
||||
ossDelete(id) {
|
||||
var that = this;
|
||||
that.$confirm({
|
||||
title: "确认删除",
|
||||
content: "是否删除选中文件?",
|
||||
onOk: function () {
|
||||
that.handleDelete(id)
|
||||
}
|
||||
});
|
||||
},
|
||||
handlePreview(record) {
|
||||
if (record && record.url) {
|
||||
var fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${record.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${record.fileName}`
|
||||
let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
|
||||
window.open(url)
|
||||
ossDelete (id) {
|
||||
var that = this
|
||||
that.$confirm({
|
||||
title: '确认删除',
|
||||
content: '是否删除选中文件?',
|
||||
onOk: function () {
|
||||
that.handleDelete(id)
|
||||
}
|
||||
})
|
||||
},
|
||||
handlePreview (record) {
|
||||
if (record && record.url) {
|
||||
var fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/download/${record.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${record.fileName}`
|
||||
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
|
||||
window.open(url)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user