初步完成管理后台大部分页面改造

dev
truthhun 1 year ago
parent 92e89d599e
commit 83b6b608c1

@ -78,10 +78,35 @@ export default {
computed: {
...mapGetters('setting', ['settings']),
},
watch: {
'$route.query': {
immediate: true,
async handler() {
let search = { ...this.$route.query }
//
// search.page = parseInt(this.$route.query.page) || 1
// search.size = parseInt(this.$route.query.size) || 10
// enable
if (typeof this.$route.query.enable === 'object') {
this.search.enable = (this.$route.query.enable || []).map((item) =>
parseInt(item)
)
} else if (this.$route.query.enable) {
this.search.enable = [parseInt(this.$route.query.enable) || 0]
}
this.search = search
await this.initTableListFields()
this.listCategory()
},
},
},
async created() {
this.initSearchForm()
this.initTableListFields()
await this.listCategory()
// this.initTableListFields()
// await this.listCategory()
},
methods: {
async listCategory() {
@ -104,15 +129,21 @@ export default {
},
handleSizeChange(val) {
this.search.size = val
this.listCategory()
this.$router.push({
query: this.search,
})
},
handlePageChange(val) {
this.search.page = val
this.listCategory()
this.$router.push({
query: this.search,
})
},
onSearch(search) {
this.search = { ...this.search, page: 1, ...search }
this.listCategory()
this.search = { ...this.search, ...search, page: 1 }
this.$router.push({
query: this.search,
})
},
onCreate() {
this.category = {
@ -199,13 +230,16 @@ export default {
placeholder: '请选择状态',
multiple: true,
options: [
{ label: '启用', value: true },
{ label: '禁用', value: false },
{ label: '启用', value: 1 },
{ label: '禁用', value: 0 },
],
},
]
},
initTableListFields() {
if (this.tableListFields.length > 0) {
return
}
this.tableListFields = [
{ prop: 'title', label: '名称', minWidth: 120, fixed: 'left' },
{

@ -7,6 +7,7 @@
:show-create="true"
:show-delete="true"
:disabled-delete="selectedRow.length === 0"
:default-search="search"
@onSearch="onSearch"
@onCreate="onCreate"
@onDelete="batchDelete"
@ -160,12 +161,53 @@ export default {
computed: {
...mapGetters('setting', ['settings']),
},
watch: {
'$route.query': {
immediate: true,
async handler() {
this.search.page = parseInt(this.$route.query.page) || 1
this.search.size = parseInt(this.$route.query.size) || 10
this.search.wd = this.$route.query.wd || ''
if (typeof this.$route.query.category_id === 'object') {
this.search.category_id = (this.$route.query.category_id || []).map((item) =>
parseInt(item)
)
} else if (this.$route.query.category_id) {
this.search.category_id = [parseInt(this.$route.query.category_id) || 0]
}
if (typeof this.$route.query.status === 'object') {
this.search.status = (this.$route.query.status || []).map((item) =>
parseInt(item)
)
} else if (this.$route.query.status) {
this.search.status = [parseInt(this.$route.query.status) || 0]
}
if (typeof this.$route.query.is_recommend === 'object') {
this.search.is_recommend = (this.$route.query.is_recommend || []).map((item) =>
item=="true"
)
} else if (this.$route.query.is_recommend) {
this.search.is_recommend = [this.$route.query.is_recommend==="true" || false]
}
//
if (this.trees.length === 0) {
await this.listCategory()
}
await this.listDocument()
},
},
},
async created() {
this.initSearchForm()
this.initTableListFields()
//
await this.listCategory()
await this.listDocument()
// //
// await this.listCategory()
// await this.listDocument()
},
methods: {
async listCategory() {
@ -217,15 +259,21 @@ export default {
},
handleSizeChange(val) {
this.search.size = val
this.listDocument()
this.$router.push({
query: this.search,
})
},
handlePageChange(val) {
this.search.page = val
this.listDocument()
this.$router.push({
query: this.search,
})
},
onSearch(search) {
this.search = { ...this.search, page: 1, ...search }
this.listDocument()
this.search = { ...this.search, ...search, page: 1 }
this.$router.push({
query: this.search,
})
},
onCreate() {
//

@ -7,6 +7,7 @@
:show-create="false"
:show-delete="false"
:disabled-delete="selectedRow.length === 0"
:default-search="search"
@onSearch="onSearch"
>
<template slot="buttons">
@ -123,12 +124,42 @@ export default {
computed: {
...mapGetters('setting', ['settings']),
},
watch: {
'$route.query': {
immediate: true,
async handler() {
this.search.page = parseInt(this.$route.query.page) || 1
this.search.size = parseInt(this.$route.query.size) || 10
this.search.wd = this.$route.query.wd || ''
if (typeof this.$route.query.category_id === 'object') {
this.search.category_id = (this.$route.query.category_id || []).map((item) =>
parseInt(item)
)
} else if (this.$route.query.category_id) {
this.search.category_id = [parseInt(this.$route.query.category_id) || 0]
}
if (typeof this.$route.query.status === 'object') {
this.search.status = (this.$route.query.status || []).map((item) =>
parseInt(item)
)
} else if (this.$route.query.status) {
this.search.status = [parseInt(this.$route.query.status) || 0]
}
//
if (this.trees.length === 0) {
await this.listCategory()
}
await this.listDocument()
},
},
},
async created() {
this.initSearchForm()
this.initTableListFields()
//
await this.listCategory()
await this.listDocument()
},
methods: {
async listCategory() {
@ -178,15 +209,21 @@ export default {
},
handleSizeChange(val) {
this.search.size = val
this.listDocument()
this.$router.push({
query: this.search
})
},
handlePageChange(val) {
this.search.page = val
this.listDocument()
this.$router.push({
query: this.search
})
},
onSearch(search) {
this.search = { ...this.search, page: 1, ...search }
this.listDocument()
this.search = { ...this.search, ...search, page: 1 }
this.$router.push({
query: this.search
})
},
recoverRow(row) {
this.$confirm(`您确定要要恢复【${row.title}】吗?`, '温馨提示', {

Loading…
Cancel
Save