diff --git a/src/views/interface/MenuList.vue b/src/views/interface/MenuList.vue
index 456ff60d..c2d2c93b 100644
--- a/src/views/interface/MenuList.vue
+++ b/src/views/interface/MenuList.vue
@@ -13,86 +13,105 @@
:title="title"
:bodyStyle="{ padding: '16px' }"
>
-
-
+
-
-
-
+
+
+
+
+
-
-
-
-
-
-
+
+
-
-
+
-
-
-
+
+
-
-
+
当前窗口
新窗口
-
-
+
+
保存
更新
返回添加
更多选项
-
+
-
-
+
+
编辑
@@ -146,7 +165,6 @@
删除
-
@@ -171,9 +189,9 @@
@@ -183,7 +201,7 @@
>
编辑
{
- this.menus = response.data.data
- this.loading = false
- })
+ handleListMenus() {
+ this.table.loading = true
+ menuApi
+ .listTree()
+ .then(response => {
+ this.table.data = response.data.data
+ })
+ .finally(() => {
+ setTimeout(() => {
+ this.table.loading = false
+ }, 200)
+ })
},
- loadTeams() {
+ handleListTeams() {
menuApi.listTeams().then(response => {
- this.teams = response.data.data
+ this.teams.data = response.data.data
})
},
- handleSaveClick() {
- this.createOrUpdateMenu()
- },
- handleAddMenu() {
- this.formType = 'create'
- this.menuToCreate = {}
- },
- handleEditMenu(menu) {
- this.menuToCreate = menu
- this.formType = 'update'
- },
handleDeleteMenu(id) {
- menuApi.delete(id).then(response => {
- this.$message.success('删除成功!')
- this.loadMenus()
- this.loadTeams()
+ menuApi
+ .delete(id)
+ .then(response => {
+ this.$message.success('删除成功!')
+ })
+ .finally(() => {
+ this.handleListMenus()
+ this.handleListTeams()
+ })
+ },
+ handleCreateOrUpdateMenu() {
+ const _this = this
+ _this.$refs.menuForm.validate(valid => {
+ if (valid) {
+ _this.form.saving = true
+ if (_this.isUpdateMode) {
+ menuApi
+ .update(_this.form.model.id, _this.form.model)
+ .then(response => {
+ _this.$message.success('更新成功!')
+ _this.form.model = { target: '_self' }
+ })
+ .finally(() => {
+ setTimeout(() => {
+ _this.form.saving = false
+ }, 200)
+ _this.handleListMenus()
+ _this.handleListTeams()
+ })
+ } else {
+ menuApi
+ .create(_this.form.model)
+ .then(response => {
+ _this.$message.success('保存成功!')
+ _this.form.model = { target: '_self' }
+ })
+ .finally(() => {
+ setTimeout(() => {
+ _this.form.saving = false
+ }, 200)
+ _this.handleListMenus()
+ _this.handleListTeams()
+ })
+ }
+ }
})
- },
- createOrUpdateMenu() {
- if (!this.menuToCreate.name) {
- this.$notification['error']({
- message: '提示',
- description: '菜单名称不能为空!'
- })
- return
- }
- if (!this.menuToCreate.url) {
- this.$notification['error']({
- message: '提示',
- description: '菜单地址不能为空!'
- })
- return
- }
- if (this.menuToCreate.id) {
- menuApi.update(this.menuToCreate.id, this.menuToCreate).then(response => {
- this.$message.success('更新成功!')
- this.loadMenus()
- this.loadTeams()
- })
- } else {
- menuApi.create(this.menuToCreate).then(response => {
- this.$message.success('保存成功!')
- this.loadMenus()
- this.loadTeams()
- })
- }
- this.handleAddMenu()
- },
- toggleExpand() {
- this.fieldExpand = !this.fieldExpand
}
}
}
diff --git a/src/views/interface/ThemeEdit.vue b/src/views/interface/ThemeEdit.vue
index efb836fd..d84be11a 100644
--- a/src/views/interface/ThemeEdit.vue
+++ b/src/views/interface/ThemeEdit.vue
@@ -22,6 +22,7 @@
type="primary"
@click="handlerSaveContent"
:disabled="buttonDisabled"
+ :loading="saving"
>保存
@@ -88,7 +89,8 @@ export default {
file: {},
content: '',
themes: [],
- selectedTheme: {}
+ selectedTheme: {},
+ saving: false
}
},
created() {
@@ -150,9 +152,17 @@ export default {
})
},
handlerSaveContent() {
- themeApi.saveContent(this.selectedTheme.id, this.file.path, this.content).then(response => {
- this.$message.success('保存成功!')
- })
+ this.saving = true
+ themeApi
+ .saveContent(this.selectedTheme.id, this.file.path, this.content)
+ .then(response => {
+ this.$message.success('保存成功!')
+ })
+ .finally(() => {
+ setTimeout(() => {
+ this.saving = false
+ }, 200)
+ })
}
}
}
diff --git a/src/views/post/CategoryList.vue b/src/views/post/CategoryList.vue
index 4e3b588c..19c15dff 100644
--- a/src/views/post/CategoryList.vue
+++ b/src/views/post/CategoryList.vue
@@ -15,8 +15,8 @@
>
-
+
-
+
-
+
@@ -59,29 +59,31 @@
保存
更新
返回添加
@@ -106,8 +108,8 @@
itemLayout="vertical"
size="large"
:pagination="false"
- :dataSource="categories"
- :loading="loading"
+ :dataSource="table.data"
+ :loading="table.loading"
>
编辑
@@ -176,10 +178,10 @@
编辑
@@ -213,7 +215,7 @@
@@ -239,7 +241,7 @@
@@ -279,100 +281,114 @@ const columns = [
scopedSlots: { customRender: 'action' }
}
]
+
export default {
components: { CategorySelectTree },
mixins: [mixin, mixinDevice],
data() {
return {
- categories: [],
- categoryToCreate: {},
- thumbnailDrawerVisible: false,
- loading: false,
- columns,
- categoryRules: {
- name: [
- { required: true, message: '* 分类名称不能为空', trigger: ['change', 'blur'] },
- { max: 255, message: '* 分类名称的字符长度不能超过 255', trigger: ['change', 'blur'] }
- ],
- slug: [{ max: 255, message: '* 分类别名的字符长度不能超过 255', trigger: ['change', 'blur'] }],
- thumbnail: [{ max: 1023, message: '* 封面图链接的字符长度不能超过 1023', trigger: ['change', 'blur'] }],
- description: [{ max: 100, message: '* 分类描述的字符长度不能超过 100', trigger: ['change', 'blur'] }]
+ table: {
+ columns,
+ data: [],
+ loading: false
+ },
+ form: {
+ model: {},
+ saving: false,
+ rules: {
+ name: [
+ { required: true, message: '* 分类名称不能为空', trigger: ['change', 'blur'] },
+ { max: 255, message: '* 分类名称的字符长度不能超过 255', trigger: ['change', 'blur'] }
+ ],
+ slug: [{ max: 255, message: '* 分类别名的字符长度不能超过 255', trigger: ['change', 'blur'] }],
+ thumbnail: [{ max: 1023, message: '* 封面图链接的字符长度不能超过 1023', trigger: ['change', 'blur'] }],
+ description: [{ max: 100, message: '* 分类描述的字符长度不能超过 100', trigger: ['change', 'blur'] }]
+ }
+ },
+ thumbnailDrawer: {
+ visible: false
}
}
},
computed: {
title() {
- if (this.categoryToCreate.id) {
+ if (this.isUpdateMode) {
return '修改分类'
}
return '添加分类'
},
- isUpdateForm() {
- return this.categoryToCreate.id
+ isUpdateMode() {
+ return !!this.form.model.id
}
},
created() {
- this.loadCategories()
+ this.handleListCategories()
},
methods: {
- loadCategories() {
- this.loading = true
+ handleListCategories() {
+ this.table.loading = true
categoryApi
.listAll(true)
.then(response => {
- this.categories = response.data.data
+ this.table.data = response.data.data
})
.finally(() => {
setTimeout(() => {
- this.loading = false
+ this.table.loading = false
}, 200)
})
},
- handleSaveClick() {
- this.createOrUpdateCategory()
- },
- handleEditCategory(category) {
- this.categoryToCreate = category
- },
handleDeleteCategory(id) {
categoryApi
.delete(id)
.then(response => {
this.$message.success('删除成功!')
- this.categoryToCreate = {}
+ this.form.model = {}
})
.finally(() => {
- this.loadCategories()
+ this.handleListCategories()
})
},
- createOrUpdateCategory() {
- this.$refs.categoryForm.validate(valid => {
+
+ /**
+ * Create or update a category.
+ */
+ handleCreateOrUpdateCategory() {
+ const _this = this
+ _this.$refs.categoryForm.validate(valid => {
if (valid) {
- if (this.categoryToCreate.id) {
+ _this.form.saving = true
+ if (_this.isUpdateMode) {
categoryApi
- .update(this.categoryToCreate.id, this.categoryToCreate)
+ .update(_this.form.model.id, _this.form.model)
.then(response => {
- this.$message.success('更新成功!')
- this.categoryToCreate = {}
+ _this.$message.success('更新成功!')
+ _this.form.model = {}
})
.finally(() => {
- this.loadCategories()
+ setTimeout(() => {
+ _this.form.saving = false
+ }, 200)
+ _this.handleListCategories()
})
} else {
categoryApi
- .create(this.categoryToCreate)
+ .create(this.form.model)
.then(response => {
- this.$message.success('保存成功!')
- this.categoryToCreate = {}
+ _this.$message.success('保存成功!')
+ _this.form.model = {}
})
.finally(() => {
- this.loadCategories()
+ setTimeout(() => {
+ _this.form.saving = false
+ }, 200)
+ _this.handleListCategories()
})
}
}
})
},
- handleCategoryToMenu(category) {
+ handleCreateMenuByCategory(category) {
const menu = {
name: category.name,
url: `${category.fullPath}`
@@ -382,8 +398,8 @@ export default {
})
},
handleSelectThumbnail(data) {
- this.$set(this.categoryToCreate, 'thumbnail', encodeURI(data.path))
- this.thumbnailDrawerVisible = false
+ this.$set(this.form.model, 'thumbnail', encodeURI(data.path))
+ this.thumbnailDrawer.visible = false
},
handleQueryCategoryPosts(category) {
this.$router.push({ name: 'PostList', query: { categoryId: category.id } })
diff --git a/src/views/post/TagList.vue b/src/views/post/TagList.vue
index 8be93047..75d6682c 100644
--- a/src/views/post/TagList.vue
+++ b/src/views/post/TagList.vue
@@ -15,8 +15,8 @@
>
-
+
-
+
-
+
@@ -51,25 +51,27 @@
保存
更新
返回添加
-
-
-
- {{ tag.postCount }} 篇文章
-
- {{ tag.name }}
-
+
+
+
+
+ {{ tag.postCount }} 篇文章
+
+ {{ tag.name }}
+
+
@@ -126,81 +130,104 @@ import tagApi from '@/api/tag'
export default {
data() {
return {
- tags: [],
- tagToCreate: {},
- thumbnailDrawerVisible: false,
- tagRules: {
- name: [
- { required: true, message: '* 标签名称不能为空', trigger: ['change', 'blur'] },
- { max: 255, message: '* 标签名称的字符长度不能超过 255', trigger: ['change', 'blur'] }
- ],
- slug: [{ max: 255, message: '* 标签别名的字符长度不能超过 255', trigger: ['change', 'blur'] }],
- thumbnail: [{ max: 1023, message: '* 封面图链接的字符长度不能超过 1023', trigger: ['change', 'blur'] }]
+ list: {
+ data: [],
+ loading: false
+ },
+ form: {
+ model: {},
+ saving: false,
+ rules: {
+ name: [
+ { required: true, message: '* 标签名称不能为空', trigger: ['change', 'blur'] },
+ { max: 255, message: '* 标签名称的字符长度不能超过 255', trigger: ['change', 'blur'] }
+ ],
+ slug: [{ max: 255, message: '* 标签别名的字符长度不能超过 255', trigger: ['change', 'blur'] }],
+ thumbnail: [{ max: 1023, message: '* 封面图链接的字符长度不能超过 1023', trigger: ['change', 'blur'] }]
+ }
+ },
+ thumbnailDrawer: {
+ visible: false
}
}
},
computed: {
title() {
- if (this.tagToCreate.id) {
+ if (this.isUpdateMode) {
return '修改标签'
}
return '添加标签'
},
- isUpdateForm() {
- return this.tagToCreate.id
+ isUpdateMode() {
+ return !!this.form.model.id
}
},
created() {
- this.loadTags()
+ this.handleListTags()
},
methods: {
- loadTags() {
- tagApi.listAll(true).then(response => {
- this.tags = response.data.data
- })
- },
- handleSaveClick() {
- this.createOrUpdateTag()
- },
- handleEditTag(tag) {
- this.tagToCreate = tag
+ handleListTags() {
+ this.list.loading = true
+ tagApi
+ .listAll(true)
+ .then(response => {
+ this.list.data = response.data.data
+ })
+ .finally(() => {
+ setTimeout(() => {
+ this.list.loading = false
+ }, 200)
+ })
},
handleDeleteTag(tagId) {
tagApi
.delete(tagId)
.then(response => {
this.$message.success('删除成功!')
- this.tagToCreate = {}
+ this.form.model = {}
})
.finally(() => {
- this.loadTags()
+ this.handleListTags()
})
},
- createOrUpdateTag() {
- this.$refs.tagForm.validate(valid => {
+ handleCreateOrUpdateTag() {
+ const _this = this
+ _this.$refs.tagForm.validate(valid => {
if (valid) {
- if (this.tagToCreate.id) {
- tagApi.update(this.tagToCreate.id, this.tagToCreate).then(response => {
- this.$message.success('更新成功!')
- this.tagToCreate = {}
- })
- } else {
+ this.form.saving = true
+ if (_this.isUpdateMode) {
tagApi
- .create(this.tagToCreate)
+ .update(_this.form.model.id, _this.form.model)
.then(response => {
- this.$message.success('保存成功!')
- this.tagToCreate = {}
+ _this.$message.success('更新成功!')
+ _this.form.model = {}
})
.finally(() => {
- this.loadTags()
+ setTimeout(() => {
+ _this.form.saving = false
+ }, 200)
+ _this.handleListTags()
+ })
+ } else {
+ tagApi
+ .create(_this.form.model)
+ .then(response => {
+ _this.$message.success('保存成功!')
+ _this.form.model = {}
+ })
+ .finally(() => {
+ setTimeout(() => {
+ _this.form.saving = false
+ }, 200)
+ _this.handleListTags()
})
}
}
})
},
handleSelectThumbnail(data) {
- this.$set(this.tagToCreate, 'thumbnail', encodeURI(data.path))
- this.thumbnailDrawerVisible = false
+ this.$set(this.form.model, 'thumbnail', encodeURI(data.path))
+ this.thumbnailDrawer.visible = false
}
}
}
diff --git a/src/views/sheet/independent/JournalList.vue b/src/views/sheet/independent/JournalList.vue
index be044a10..32ec1978 100644
--- a/src/views/sheet/independent/JournalList.vue
+++ b/src/views/sheet/independent/JournalList.vue
@@ -65,7 +65,7 @@
-
+
保存
-
+
@@ -250,7 +253,6 @@ import AttachmentDrawer from '../../attachment/components/AttachmentDrawer'
import { mixin, mixinDevice } from '@/utils/mixin.js'
import { mapGetters, mapActions } from 'vuex'
import journalApi from '@/api/journal'
-import journalCommentApi from '@/api/journalComment'
import optionApi from '@/api/option'
export default {
mixins: [mixin, mixinDevice],
@@ -299,11 +301,17 @@ export default {
this.queryParam.page = this.pagination.page - 1
this.queryParam.size = this.pagination.size
this.queryParam.sort = this.pagination.sort
- journalApi.query(this.queryParam).then(response => {
- this.journals = response.data.data.content
- this.pagination.total = response.data.data.total
- this.listLoading = false
- })
+ journalApi
+ .query(this.queryParam)
+ .then(response => {
+ this.journals = response.data.data.content
+ this.pagination.total = response.data.data.total
+ })
+ .finally(() => {
+ setTimeout(() => {
+ this.listLoading = false
+ }, 200)
+ })
},
loadFormOptions() {
optionApi.listAll().then(response => {
@@ -334,12 +342,6 @@ export default {
this.journal = journal
this.journalCommentVisible = true
},
- handleCommentDelete(comment) {
- journalCommentApi.delete(comment.id).then(response => {
- this.$message.success('删除成功!')
- this.handleCommentShow(this.journal)
- })
- },
createOrUpdateJournal() {
this.journal.type = this.isPublic ? 'PUBLIC' : 'INTIMATE'
diff --git a/src/views/sheet/independent/LinkList.vue b/src/views/sheet/independent/LinkList.vue
index dd40c7d3..e60a20a5 100644
--- a/src/views/sheet/independent/LinkList.vue
+++ b/src/views/sheet/independent/LinkList.vue
@@ -13,15 +13,24 @@
:title="title"
:bodyStyle="{ padding: '16px' }"
>
-
-
-
-
-
+
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
-
-
+
+
-
-
+
+
保存
更新
返回添加
-
-
+
+
编辑
@@ -153,9 +177,9 @@
@@ -179,8 +203,8 @@
slot-scope="text, record"
>
编辑
保存
-
-
+
+
@@ -263,114 +290,141 @@ export default {
mixins: [mixin, mixinDevice],
data() {
return {
- formType: 'create',
- optionFormVisible: false,
- data: [],
- loading: false,
- columns,
- links: [],
- link: {},
- teams: [],
- options: []
+ table: {
+ columns,
+ data: [],
+ loading: false
+ },
+ form: {
+ model: {},
+ saving: false,
+ rules: {
+ name: [
+ { required: true, message: '* 友情链接名称不能为空', trigger: ['change', 'blur'] },
+ { max: 255, message: '* 友情链接名称的字符长度不能超过 255', trigger: ['change', 'blur'] }
+ ],
+ url: [
+ { required: true, message: '* 友情链接地址不能为空', trigger: ['change', 'blur'] },
+ { max: 1023, message: '* 友情链接地址的字符长度不能超过 1023', trigger: ['change', 'blur'] },
+ { type: 'url', message: '* 友情链接地址格式有误', trigger: ['change', 'blur'] }
+ ],
+ logo: [{ max: 1023, message: '* 友情链接 Logo 的字符长度不能超过 1023', trigger: ['change', 'blur'] }],
+ description: [{ max: 255, message: '* 友情链接描述的字符长度不能超过 255', trigger: ['change', 'blur'] }],
+ team: [{ max: 255, message: '* 友情链接分组的字符长度 255', trigger: ['change', 'blur'] }]
+ }
+ },
+ optionsModal: {
+ visible: false,
+ data: []
+ },
+ teams: []
}
},
computed: {
title() {
- if (this.link.id) {
+ if (this.isUpdateMode) {
return '修改友情链接'
}
return '添加友情链接'
+ },
+ isUpdateMode() {
+ return !!this.form.model.id
}
},
created() {
- this.loadLinks()
- this.loadTeams()
- this.loadFormOptions()
+ this.handleListLinks()
+ this.handleListLinkTeams()
+ this.handleListOptions()
},
methods: {
...mapActions(['loadOptions']),
- loadLinks() {
- this.loading = true
- linkApi.listAll().then(response => {
- this.links = response.data.data
- this.loading = false
- })
+ handleListLinks() {
+ this.table.loading = true
+ linkApi
+ .listAll()
+ .then(response => {
+ this.table.data = response.data.data
+ })
+ .finally(() => {
+ setTimeout(() => {
+ this.table.loading = false
+ }, 200)
+ })
},
- loadTeams() {
+ handleListLinkTeams() {
linkApi.listTeams().then(response => {
this.teams = response.data.data
})
},
- loadFormOptions() {
+ handleListOptions() {
optionApi.listAll().then(response => {
- this.options = response.data.data
- })
- },
- handleSaveClick() {
- this.createOrUpdateLink()
- },
- handleAddLink() {
- this.formType = 'create'
- this.link = {}
- },
- handleEditLink(id) {
- linkApi.get(id).then(response => {
- this.link = response.data.data
- this.formType = 'update'
+ this.optionsModal.data = response.data.data
})
},
handleDeleteLink(id) {
- linkApi.delete(id).then(response => {
- this.$message.success('删除成功!')
- this.loadLinks()
- this.loadTeams()
- })
+ linkApi
+ .delete(id)
+ .then(response => {
+ this.$message.success('删除成功!')
+ })
+ .finally(() => {
+ this.handleListLinks()
+ this.handleListLinkTeams()
+ })
},
handleParseUrl() {
- linkApi.getByParse(this.link.url).then(response => {
- this.link = response.data.data
+ linkApi.getByParse(this.form.model.url).then(response => {
+ this.form.model = response.data.data
})
},
- createOrUpdateLink() {
- if (!this.link.name) {
- this.$notification['error']({
- message: '提示',
- description: '网站名称不能为空!'
- })
- return
- }
- if (!this.link.url) {
- this.$notification['error']({
- message: '提示',
- description: '网站地址不能为空!'
- })
- return
- }
- if (this.link.id) {
- linkApi.update(this.link.id, this.link).then(response => {
- this.$message.success('更新成功!')
- this.loadLinks()
- this.loadTeams()
- })
- } else {
- linkApi.create(this.link).then(response => {
- this.$message.success('保存成功!')
- this.loadLinks()
- this.loadTeams()
- })
- }
- this.handleAddLink()
+ handleCreateOrUpdateLink() {
+ const _this = this
+ _this.$refs.linkForm.validate(valid => {
+ if (valid) {
+ _this.form.saving = true
+ if (_this.isUpdateMode) {
+ linkApi
+ .update(_this.form.model.id, _this.form.model)
+ .then(response => {
+ _this.$message.success('更新成功!')
+ _this.form.model = {}
+ })
+ .finally(() => {
+ setTimeout(() => {
+ _this.form.saving = false
+ }, 200)
+ _this.handleListLinks()
+ _this.handleListLinkTeams()
+ })
+ } else {
+ linkApi
+ .create(_this.form.model)
+ .then(response => {
+ _this.$message.success('保存成功!')
+ _this.form.model = {}
+ })
+ .finally(() => {
+ setTimeout(() => {
+ _this.form.saving = false
+ }, 200)
+ _this.handleListLinks()
+ _this.handleListLinkTeams()
+ })
+ }
+ }
+ })
},
handleSaveOptions() {
- optionApi.save(this.options).then(response => {
- this.loadFormOptions()
- this.loadOptions()
- this.$message.success('保存成功!')
- this.optionFormVisible = false
- })
- },
- onOptionFormClose() {
- this.optionFormVisible = false
+ optionApi
+ .save(this.optionsModal.data)
+ .then(response => {
+ this.$message.success('保存成功!')
+ this.optionsModal.visible = false
+ })
+ .finally(() => {
+ this.handleListOptions()
+ this.loadOptions()
+ })
}
}
}