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