Link form type switch.

pull/9/head
ruibaby 2019-04-11 23:08:12 +08:00
parent 4b1160b801
commit d9518b908a
2 changed files with 33 additions and 11 deletions

View File

@ -19,6 +19,14 @@ linkApi.create = (link) => {
})
}
linkApi.update = (linkId, link) => {
return service({
url: `${baseUrl}/${linkId}`,
data: link,
method: 'put'
})
}
linkApi.delete = linkId => {
return service({
url: `${baseUrl}/${linkId}`,

View File

@ -2,29 +2,33 @@
<div class="page-header-index-wide">
<a-row :gutter="12">
<a-col :xl="10" :lg="10" :md="10" :sm="24" :xs="24" :style="{ 'padding-bottom': '12px' }">
<a-card title="添加友情链接">
<a-card :title="title">
<a-form layout="horizontal">
<a-form-item label="网站名称:">
<a-input v-model="linkToCreate.name"/>
<a-input v-model="link.name"/>
</a-form-item>
<a-form-item label="网站地址:" help="* 需要加上 http://">
<a-input v-model="linkToCreate.url"/>
<a-input v-model="link.url"/>
</a-form-item>
<a-form-item label="Logo">
<a-input v-model="linkToCreate.logo"/>
<a-input v-model="link.logo"/>
</a-form-item>
<a-form-item label="分组:" help="* 非必填">
<a-input v-model="linkToCreate.team"/>
<a-input v-model="link.team"/>
</a-form-item>
<a-form-item label="描述:">
<a-input
type="textarea"
:autosize="{ minRows: 5 }"
v-model="linkToCreate.description"
v-model="link.description"
/>
</a-form-item>
<a-form-item>
<a-button type="primary" @click="createLink"></a-button>
<a-button type="primary" @click="createLink" v-if="formType==='create'"></a-button>
<a-button-group v-else>
<a-button type="primary" @click="updateLink"></a-button>
<a-button type="dashed" @click="addLink" v-if="formType==='update'"></a-button>
</a-button-group>
</a-form-item>
</a-form>
</a-card>
@ -89,11 +93,13 @@ export default {
},
data() {
return {
title: '添加友情链接',
formType: 'create',
data: [],
loading: true,
columns,
links: [],
linkToCreate: {}
link: {}
}
},
created() {
@ -107,14 +113,22 @@ export default {
})
},
createLink() {
linkApi.create(this.linkToCreate).then(response => {
linkApi.create(this.link).then(response => {
this.loadLinks()
this.linkToCreate = {}
this.link = {}
})
},
editLink(id) {
updateLink() {
this.$message.success('编辑' + id)
},
addLink() {
this.title = '添加友情链接'
this.formType = 'create'
},
editLink(id) {
this.title = '编辑友情链接'
this.formType = 'update'
},
deleteLink(id) {
linkApi.delete(id).then(response => {
this.$message.success('删除成功!')