Resolve conflict

pull/9/head
johnniang 6 years ago
commit be299bbe7d

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

@ -72,7 +72,6 @@
<a-upload-dragger <a-upload-dragger
name="file" name="file"
:multiple="true" :multiple="true"
accept="image/*"
:customRequest="handleUpload" :customRequest="handleUpload"
@change="handleChange" @change="handleChange"
> >

@ -7,51 +7,29 @@
:md="10" :md="10"
:sm="24" :sm="24"
:xs="24" :xs="24"
:style="{ 'padding-bottom': '12px' }" :style="{ 'padding-bottom': '12px' }">
>
<a-card :title="title"> <a-card :title="title">
<a-form layout="horizontal"> <a-form layout="horizontal">
<a-form-item label="网站名称:"> <a-form-item label="网站名称:">
<a-input v-model="link.name" /> <a-input v-model="link.name"/>
</a-form-item> </a-form-item>
<a-form-item <a-form-item label="网站地址:" help="* 需要加上 http://">
label="网站地址:" <a-input v-model="link.url"/>
help="* 需要加上 http://"
>
<a-input v-model="link.url" />
</a-form-item> </a-form-item>
<a-form-item label="Logo"> <a-form-item label="Logo">
<a-input v-model="link.logo" /> <a-input v-model="link.logo"/>
</a-form-item> </a-form-item>
<a-form-item <a-form-item label="分组:" help="* 非必填">
label="分组:" <a-input v-model="link.team"/>
help="* 非必填"
>
<a-input v-model="link.team" />
</a-form-item> </a-form-item>
<a-form-item label="描述:"> <a-form-item label="描述:">
<a-input <a-input type="textarea" :autosize="{ minRows: 5 }" v-model="link.description"/>
type="textarea"
:autosize="{ minRows: 5 }"
v-model="link.description"
/>
</a-form-item> </a-form-item>
<a-form-item> <a-form-item>
<a-button <a-button type="primary" @click="handleSaveClick" v-if="formType==='create'"></a-button>
type="primary"
@click="createLink"
v-if="formType==='create'"
>保存</a-button>
<a-button-group v-else> <a-button-group v-else>
<a-button <a-button type="primary" @click="handleSaveClick"></a-button>
type="primary" <a-button type="dashed" @click="addLink" v-if="formType==='update'"></a-button>
@click="updateLink"
>更新</a-button>
<a-button
type="dashed"
@click="addLink"
v-if="formType==='update'"
>返回添加</a-button>
</a-button-group> </a-button-group>
</a-form-item> </a-form-item>
</a-form> </a-form>
@ -63,8 +41,7 @@
:md="14" :md="14"
:sm="24" :sm="24"
:xs="24" :xs="24"
:style="{ 'padding-bottom': '12px' }" :style="{ 'padding-bottom': '12px' }">
>
<a-card title="所有友情链接"> <a-card title="所有友情链接">
<a-table <a-table
:columns="columns" :columns="columns"
@ -72,30 +49,13 @@
:loading="loading" :loading="loading"
:rowKey="link => link.id" :rowKey="link => link.id"
> >
<template <template slot="url" slot-scope="text">
slot="url" <a target="_blank" :href="text">{{ text }}</a>
slot-scope="text"
>
<a
target="_blank"
:href="text"
>{{ text }}</a>
</template> </template>
<ellipsis <ellipsis :length="15" tooltip slot="name" slot-scope="text">{{ text }}</ellipsis>
:length="15" <span slot="action" slot-scope="text, record">
tooltip <a href="javascript:;" @click="editLink(record.id)"></a>
slot="name" <a-divider type="vertical"/>
slot-scope="text"
>{{ text }}</ellipsis>
<span
slot="action"
slot-scope="text, record"
>
<a
href="javascript:;"
@click="editLink(record.id)"
>编辑</a>
<a-divider type="vertical" />
<a-popconfirm <a-popconfirm
:title="'你确定要删除【' + record.name + '】链接?'" :title="'你确定要删除【' + record.name + '】链接?'"
@confirm="deleteLink(record.id)" @confirm="deleteLink(record.id)"
@ -161,11 +121,8 @@ export default {
this.loading = false this.loading = false
}) })
}, },
createLink() { handleSaveClick() {
linkApi.create(this.link).then(response => { this.createOrUpdateLink()
this.loadLinks()
this.link = {}
})
}, },
updateLink() { updateLink() {
this.$message.success('编辑') this.$message.success('编辑')
@ -175,14 +132,30 @@ export default {
this.formType = 'create' this.formType = 'create'
}, },
editLink(id) { editLink(id) {
this.title = '编辑友情链接' linkApi.get(id).then(response => {
this.formType = 'update' this.link = response.data.data
this.title = '编辑友情链接'
this.formType = 'update'
})
}, },
deleteLink(id) { deleteLink(id) {
linkApi.delete(id).then(response => { linkApi.delete(id).then(response => {
this.$message.success('删除成功!') this.$message.success('删除成功!')
this.loadLinks() this.loadLinks()
}) })
},
createOrUpdateLink() {
if (this.link.id) {
linkApi.update(this.link.id, this.link).then(response => {
this.$message.success('更新成功!')
})
} else {
linkApi.create(this.link).then(response => {
this.$message.success('保存成功!')
})
}
this.loadLinks()
this.link = {}
} }
} }
} }

Loading…
Cancel
Save