[add
This commit is contained in:
parent
528d657968
commit
ae7bab6747
@ -11,6 +11,10 @@ export default {
|
||||
list(params) {
|
||||
return fetch('/library/list', params,'post','json')
|
||||
},
|
||||
|
||||
setImg(params) {
|
||||
return fetch('/library/uploadImg',params,'post','json')
|
||||
},
|
||||
/**
|
||||
* 热门
|
||||
* @param params
|
||||
|
||||
@ -4,12 +4,13 @@
|
||||
:action="action"
|
||||
:show-file-list="false"
|
||||
:auto-upload="true"
|
||||
:headers="headers"
|
||||
multiple
|
||||
@progress="progress"
|
||||
@success="upload"
|
||||
>
|
||||
<template #upload-button>
|
||||
<a-button size="small" type="outline">
|
||||
<a-button size="small" type="text">
|
||||
<template #icon>
|
||||
<icon-loading v-if="loading" />
|
||||
<icon-upload v-else />
|
||||
@ -26,12 +27,18 @@ export default {
|
||||
props: {
|
||||
action: {
|
||||
type: String,
|
||||
default: '/api/file/upload'
|
||||
}
|
||||
},
|
||||
default: '/api/oss/upload'
|
||||
},
|
||||
headers: {
|
||||
type:Object,
|
||||
default(){
|
||||
return { Authorization: 'Bearer ' + localStorage.getItem('token') }
|
||||
}
|
||||
}},
|
||||
data() {
|
||||
return {
|
||||
loading: false
|
||||
loading: false,
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -44,7 +51,7 @@ export default {
|
||||
const code = res.response.code
|
||||
this.loading = false
|
||||
if (code === 200) {
|
||||
this.$emit('ok', res.response.data)
|
||||
this.$emit('ok', res.response.data.file)
|
||||
} else {
|
||||
this.$notification.error('上传错误')
|
||||
}
|
||||
|
||||
@ -6,10 +6,17 @@
|
||||
<edit @ok="fetchList"/>
|
||||
</div>
|
||||
<a-table class="mt-20" :columns="columns" :data="list" >
|
||||
<template #name="{record}">
|
||||
<div class="flex flex-center flex-justify-start">
|
||||
<a-image width="60" height="60" :src="record.oss.url" :alt="record.id"/>
|
||||
<div class="ml-10">{{record.name}}</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #menu="{record}">
|
||||
<div class="flex flex-center">
|
||||
<edit type="edit" :info="record" @ok="fetchList"/>
|
||||
<a-button type="text" @click="changeHot(record)">{{record.isHot === 0 ?'设置热门':'取消热门'}}</a-button>
|
||||
<upload @ok="upload(record,$event)"/>
|
||||
</div>
|
||||
</template>
|
||||
</a-table>
|
||||
@ -19,11 +26,13 @@
|
||||
|
||||
<script>
|
||||
import navbar from '@/components/navbar/index.vue'
|
||||
import upload from "../../../components/upload/index.vue";
|
||||
import edit from './components/edit.vue'
|
||||
export default {
|
||||
components: {
|
||||
navbar,
|
||||
edit
|
||||
edit,
|
||||
upload
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -35,7 +44,7 @@ export default {
|
||||
columns :[
|
||||
{
|
||||
title:'名称',
|
||||
dataIndex: 'name',
|
||||
slotName: 'name',
|
||||
},
|
||||
{
|
||||
title:'别名',
|
||||
@ -79,6 +88,15 @@ export default {
|
||||
this.$message.error(res.msg);
|
||||
}
|
||||
})
|
||||
},
|
||||
upload(item,file){
|
||||
const data = {libraryId:item.id,ossId:file.id}
|
||||
this.$api.flower.setImg(data).then(res => {
|
||||
if(res.code === 200){
|
||||
console.log(res)
|
||||
this.fetchList()
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user