diff --git a/src/api/link.js b/src/api/link.js index 73774984..3c077ce1 100644 --- a/src/api/link.js +++ b/src/api/link.js @@ -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}`, diff --git a/src/views/page/internal/LinkList.vue b/src/views/page/internal/LinkList.vue index 56bd1bb9..ee4729f4 100644 --- a/src/views/page/internal/LinkList.vue +++ b/src/views/page/internal/LinkList.vue @@ -2,29 +2,33 @@
- + - + - + - + - + - 保存 + 保存 + + 更新 + 返回添加 + @@ -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('删除成功!')