Browse Source

Refactor code.

pull/9/head
ruibaby 6 years ago
parent
commit
3a0258ff1f
  1. 11
      src/views/interface/MenuList.vue
  2. 11
      src/views/post/CategoryList.vue
  3. 11
      src/views/sheet/internal/LinkList.vue

11
src/views/interface/MenuList.vue

@ -159,7 +159,6 @@ export default {
components: { MenuSelectTree }, components: { MenuSelectTree },
data() { data() {
return { return {
title: '添加菜单',
formType: 'create', formType: 'create',
loading: false, loading: false,
columns, columns,
@ -168,6 +167,14 @@ export default {
fieldExpand: false fieldExpand: false
} }
}, },
computed: {
title() {
if (this.menuToCreate.id) {
return '修改菜单'
}
return '添加菜单'
}
},
created() { created() {
this.loadMenus() this.loadMenus()
}, },
@ -183,14 +190,12 @@ export default {
this.createOrUpdateMenu() this.createOrUpdateMenu()
}, },
handleAddMenu() { handleAddMenu() {
this.title = '添加菜单'
this.formType = 'create' this.formType = 'create'
this.menuToCreate = {} this.menuToCreate = {}
}, },
handleEditMenu(id) { handleEditMenu(id) {
menuApi.get(id).then(response => { menuApi.get(id).then(response => {
this.menuToCreate = response.data.data this.menuToCreate = response.data.data
this.title = '编辑菜单'
this.formType = 'update' this.formType = 'update'
}) })
}, },

11
src/views/post/CategoryList.vue

@ -146,7 +146,6 @@ export default {
components: { CategorySelectTree, CategoryTree }, components: { CategorySelectTree, CategoryTree },
data() { data() {
return { return {
title: '添加分类',
formType: 'create', formType: 'create',
categories: [], categories: [],
categoryToCreate: {}, categoryToCreate: {},
@ -154,6 +153,14 @@ export default {
columns columns
} }
}, },
computed: {
title() {
if (this.categoryToCreate.id) {
return '修改分类'
}
return '添加分类'
}
},
created() { created() {
this.loadCategories() this.loadCategories()
}, },
@ -169,14 +176,12 @@ export default {
this.createOrUpdateCategory() this.createOrUpdateCategory()
}, },
handleAddCategory() { handleAddCategory() {
this.title = '添加分类'
this.formType = 'create' this.formType = 'create'
this.categoryToCreate = {} this.categoryToCreate = {}
}, },
handleEditCategory(id) { handleEditCategory(id) {
categoryApi.get(id).then(response => { categoryApi.get(id).then(response => {
this.categoryToCreate = response.data.data this.categoryToCreate = response.data.data
this.title = '编辑分类'
this.formType = 'update' this.formType = 'update'
}) })
}, },

11
src/views/sheet/internal/LinkList.vue

@ -138,7 +138,6 @@ const columns = [
export default { export default {
data() { data() {
return { return {
title: '添加友情链接',
formType: 'create', formType: 'create',
data: [], data: [],
loading: false, loading: false,
@ -147,6 +146,14 @@ export default {
link: {} link: {}
} }
}, },
computed: {
title() {
if (this.link.id) {
return '修改友情链接'
}
return '添加友情链接'
}
},
created() { created() {
this.loadLinks() this.loadLinks()
}, },
@ -162,14 +169,12 @@ export default {
this.createOrUpdateLink() this.createOrUpdateLink()
}, },
handleAddLink() { handleAddLink() {
this.title = '添加友情链接'
this.formType = 'create' this.formType = 'create'
this.link = {} this.link = {}
}, },
handleEditLink(id) { handleEditLink(id) {
linkApi.get(id).then(response => { linkApi.get(id).then(response => {
this.link = response.data.data this.link = response.data.data
this.title = '编辑友情链接'
this.formType = 'update' this.formType = 'update'
}) })
}, },

Loading…
Cancel
Save