完成管理后台页面调整

dev
truthhun 1 year ago
parent 83b6b608c1
commit a6a41b4077

@ -43,6 +43,10 @@ export default {
type: Object, type: Object,
default: () => {}, default: () => {},
}, },
placeholder: {
type: String,
default: '请输入评论内容',
},
}, },
data() { data() {
return { return {

@ -119,10 +119,12 @@ export default {
'$route.query': { '$route.query': {
immediate: true, immediate: true,
handler() { handler() {
this.search.page = parseInt(this.$route.query.page) || 1 this.search = {
this.search.size = parseInt(this.$route.query.size) || 10 ...this.search,
this.search.wd = this.$route.query.wd || '' ...this.$route.query,
page: parseInt(this.$route.query.page) || 1,
size: parseInt(this.$route.query.size) || 10,
}
this.listArticle() this.listArticle()
}, },
}, },
@ -159,7 +161,7 @@ export default {
// this.listArticle() // this.listArticle()
}, },
onSearch(search) { onSearch(search) {
this.search = { ...this.search, page: 1, ...search } this.search = { ...this.search, ...search, page: 1 }
this.$router.push({ this.$router.push({
query: this.search, query: this.search,
}) })

@ -43,7 +43,7 @@
</div> </div>
</el-card> </el-card>
<el-dialog title="编辑附件" width="640px" :visible.sync="formVisible"> <el-dialog title="编辑附件" width="520px" :visible.sync="formVisible">
<FormAttachment :init-attachment="attachment" @success="formSuccess" /> <FormAttachment :init-attachment="attachment" @success="formSuccess" />
</el-dialog> </el-dialog>
</div> </div>
@ -59,6 +59,7 @@ import TableList from '~/components/TableList.vue'
import FormSearch from '~/components/FormSearch.vue' import FormSearch from '~/components/FormSearch.vue'
import FormAttachment from '~/components/FormAttachment.vue' import FormAttachment from '~/components/FormAttachment.vue'
import { attachmentTypeOptions } from '~/utils/enum' import { attachmentTypeOptions } from '~/utils/enum'
import { parseQueryIntArray } from '~/utils/utils'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
components: { TableList, FormSearch, FormAttachment }, components: { TableList, FormSearch, FormAttachment },
@ -93,28 +94,13 @@ export default {
'$route.query': { '$route.query': {
immediate: true, immediate: true,
handler() { handler() {
this.search.page = parseInt(this.$route.query.page) || 1 this.search = {
this.search.size = parseInt(this.$route.query.size) || 10 ...this.search,
this.search.wd = this.$route.query.wd || '' ...this.$route.query,
page: parseInt(this.$route.query.page) || 1,
// enable size: parseInt(this.$route.query.size) || 10,
if (typeof this.$route.query.enable === 'object') { ...parseQueryIntArray(this.$route.query, ['enable', 'type']),
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]
}
// type
if (typeof this.$route.query.type === 'object') {
this.search.type = (this.$route.query.type || []).map((item) =>
parseInt(item)
)
} else if (this.$route.query.type) {
this.search.type = [parseInt(this.$route.query.type) || 0]
} }
this.listAttachment() this.listAttachment()
}, },
}, },
@ -151,7 +137,7 @@ export default {
// this.listAttachment() // this.listAttachment()
}, },
onSearch(search) { onSearch(search) {
this.search = { ...this.search, page: 1, ...search } this.search = { ...this.search, ...search, page: 1 }
this.$router.push({ this.$router.push({
query: this.search, query: this.search,
}) })

@ -46,7 +46,7 @@
</el-card> </el-card>
<el-dialog <el-dialog
width="640px" width="520px"
:title="banner.id > 0 ? '编辑横幅' : '新增横幅'" :title="banner.id > 0 ? '编辑横幅' : '新增横幅'"
:visible.sync="formVisible" :visible.sync="formVisible"
> >
@ -65,6 +65,7 @@ import TableList from '~/components/TableList.vue'
import FormSearch from '~/components/FormSearch.vue' import FormSearch from '~/components/FormSearch.vue'
import FormBanner from '~/components/FormBanner.vue' import FormBanner from '~/components/FormBanner.vue'
import { bannerTypeOptions } from '~/utils/enum' import { bannerTypeOptions } from '~/utils/enum'
import { parseQueryIntArray } from '~/utils/utils'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
components: { TableList, FormSearch, FormBanner }, components: { TableList, FormSearch, FormBanner },
@ -99,28 +100,13 @@ export default {
'$route.query': { '$route.query': {
immediate: true, immediate: true,
handler() { handler() {
this.search.page = parseInt(this.$route.query.page) || 1 this.search = {
this.search.size = parseInt(this.$route.query.size) || 10 ...this.search,
this.search.wd = this.$route.query.wd || '' ...this.$route.query,
page: parseInt(this.$route.query.page) || 1,
// enable size: parseInt(this.$route.query.size) || 10,
if (typeof this.$route.query.enable === 'object') { ...parseQueryIntArray(this.$route.query, ['enable', 'type']),
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]
}
// type
if (typeof this.$route.query.type === 'object') {
this.search.type = (this.$route.query.type || []).map((item) =>
parseInt(item)
)
} else if (this.$route.query.type) {
this.search.type = [parseInt(this.$route.query.type) || 0]
} }
this.listBanner() this.listBanner()
}, },
}, },
@ -128,7 +114,6 @@ export default {
async created() { async created() {
this.initSearchForm() this.initSearchForm()
this.initTableListFields() this.initTableListFields()
// await this.listBanner()
}, },
methods: { methods: {
async listBanner() { async listBanner() {
@ -147,21 +132,18 @@ export default {
this.$router.push({ this.$router.push({
query: this.search, query: this.search,
}) })
// this.listBanner()
}, },
handlePageChange(val) { handlePageChange(val) {
this.search.page = val this.search.page = val
this.$router.push({ this.$router.push({
query: this.search, query: this.search,
}) })
// this.listBanner()
}, },
onSearch(search) { onSearch(search) {
this.search = { ...this.search, page: 1, ...search } this.search = { ...this.search, ...search, page: 1 }
this.$router.push({ this.$router.push({
query: this.search, query: this.search,
}) })
// this.listBanner()
}, },
onCreate() { onCreate() {
this.banner = {} this.banner = {}

@ -64,7 +64,7 @@
v-if="comment.id > 0" v-if="comment.id > 0"
title="评论编审" title="评论编审"
:visible.sync="formCommentVisible" :visible.sync="formCommentVisible"
width="640px" width="520px"
> >
<FormCommentCheck <FormCommentCheck
ref="formComment" ref="formComment"
@ -84,6 +84,7 @@ import {
} from '~/api/comment' } from '~/api/comment'
import TableList from '~/components/TableList.vue' import TableList from '~/components/TableList.vue'
import FormSearch from '~/components/FormSearch.vue' import FormSearch from '~/components/FormSearch.vue'
import { parseQueryIntArray } from '~/utils/utils'
export default { export default {
components: { TableList, FormSearch }, components: { TableList, FormSearch },
layout: 'admin', layout: 'admin',
@ -120,15 +121,12 @@ export default {
'$route.query': { '$route.query': {
immediate: true, immediate: true,
handler() { handler() {
this.search.page = parseInt(this.$route.query.page) || 1 this.search = {
this.search.size = parseInt(this.$route.query.size) || 10 ...this.search,
this.search.wd = this.$route.query.wd || '' ...this.$route.query,
if (typeof this.$route.query.status === 'object') { page: parseInt(this.$route.query.page) || 1,
this.search.status = (this.$route.query.status || []).map((item) => size: parseInt(this.$route.query.size) || 10,
parseInt(item) ...parseQueryIntArray(this.$route.query, ['status']),
)
} else if (this.$route.query.status) {
this.search.status = [parseInt(this.$route.query.status) || 0]
} }
this.listComment() this.listComment()
}, },
@ -137,7 +135,6 @@ export default {
async created() { async created() {
this.initSearchForm() this.initSearchForm()
this.initTableListFields() this.initTableListFields()
// await this.listComment()
}, },
methods: { methods: {
async listComment() { async listComment() {
@ -159,21 +156,18 @@ export default {
this.$router.push({ this.$router.push({
query: this.search, query: this.search,
}) })
// this.listComment()
}, },
handlePageChange(val) { handlePageChange(val) {
this.search.page = val this.search.page = val
this.$router.push({ this.$router.push({
query: this.search, query: this.search,
}) })
// this.listComment()
}, },
onSearch(search) { onSearch(search) {
this.search = { ...this.search, page: 1, ...search } this.search = { ...this.search, ...search, page: 1 }
this.$router.push({ this.$router.push({
query: this.search, query: this.search,
}) })
// this.listComment()
}, },
onCreate() { onCreate() {
this.comment = { id: 0 } this.comment = { id: 0 }

@ -85,9 +85,6 @@ export default {
immediate: true, immediate: true,
}, },
}, },
// created() {
// this.loadConfig()
// },
methods: { methods: {
handleClick(tab) { handleClick(tab) {
this.activeName = tab.name this.activeName = tab.name
@ -96,7 +93,6 @@ export default {
tab: tab.name, tab: tab.name,
}, },
}) })
// this.loadConfig()
}, },
async loadConfig() { async loadConfig() {
const res = await listConfig({ category: [this.activeName] }) const res = await listConfig({ category: [this.activeName] })

@ -126,12 +126,12 @@
empty-text="您暂无权限查看环境依赖情况" empty-text="您暂无权限查看环境依赖情况"
> >
<el-table-column prop="name" label="名称" width="100"> </el-table-column <el-table-column prop="name" label="名称" width="100"> </el-table-column
><el-table-column prop="is_required" label="是否必" width="100"> ><el-table-column prop="is_required" label="是否必" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag v-if="scope.row.is_required" effect="danger" size="small" <el-tag v-if="scope.row.is_required" effect="danger" size="small"
>安装</el-tag >安装</el-tag
> >
<el-tag effect="info" size="small" v-else></el-tag> <el-tag effect="info" size="small" v-else></el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="is_installed" label="安装" width="100"> <el-table-column prop="is_installed" label="安装" width="100">

@ -31,7 +31,7 @@
<el-dialog <el-dialog
:title="category.id ? '编辑分类' : '新增分类'" :title="category.id ? '编辑分类' : '新增分类'"
:visible.sync="formVisible" :visible.sync="formVisible"
:width="'640px'" :width="'520px'"
> >
<FormCategory <FormCategory
ref="categoryForm" ref="categoryForm"
@ -48,7 +48,7 @@ import { listCategory, deleteCategory, getCategory } from '~/api/category'
import TableList from '~/components/TableList.vue' import TableList from '~/components/TableList.vue'
import FormSearch from '~/components/FormSearch.vue' import FormSearch from '~/components/FormSearch.vue'
import FormCategory from '~/components/FormCategory.vue' import FormCategory from '~/components/FormCategory.vue'
import { categoryToTrees } from '~/utils/utils' import { categoryToTrees, parseQueryIntArray } from '~/utils/utils'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
components: { TableList, FormSearch, FormCategory }, components: { TableList, FormSearch, FormCategory },
@ -82,22 +82,11 @@ export default {
'$route.query': { '$route.query': {
immediate: true, immediate: true,
async handler() { async handler() {
let search = { ...this.$route.query } this.search = {
...this.search,
// ...this.$route.query,
// search.page = parseInt(this.$route.query.page) || 1 ...parseQueryIntArray(this.$route.query, ['enable']),
// 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() await this.initTableListFields()
this.listCategory() this.listCategory()
}, },
@ -105,8 +94,6 @@ export default {
}, },
async created() { async created() {
this.initSearchForm() this.initSearchForm()
// this.initTableListFields()
// await this.listCategory()
}, },
methods: { methods: {
async listCategory() { async listCategory() {

@ -97,7 +97,7 @@
</el-pagination> </el-pagination>
</div> </div>
</el-card> </el-card>
<el-dialog title="编辑文档" width="640px" :visible.sync="formVisible"> <el-dialog title="编辑文档" width="520px" :visible.sync="formVisible">
<FormUpdateDocument <FormUpdateDocument
:category-trees="trees" :category-trees="trees"
:init-document="document" :init-document="document"
@ -108,7 +108,7 @@
<el-dialog <el-dialog
title="推荐设置" title="推荐设置"
:visible.sync="formDocumentRecommendVisible" :visible.sync="formDocumentRecommendVisible"
width="640px" width="520px"
> >
<FormDocumentRecommend :init-document="document" @success="formSuccess" /> <FormDocumentRecommend :init-document="document" @success="formSuccess" />
</el-dialog> </el-dialog>
@ -125,7 +125,11 @@ import {
} from '~/api/document' } from '~/api/document'
import TableList from '~/components/TableList.vue' import TableList from '~/components/TableList.vue'
import FormSearch from '~/components/FormSearch.vue' import FormSearch from '~/components/FormSearch.vue'
import { categoryToTrees } from '~/utils/utils' import {
categoryToTrees,
parseQueryIntArray,
parseQueryBoolArray,
} from '~/utils/utils'
import { documentStatusOptions, boolOptions } from '~/utils/enum' import { documentStatusOptions, boolOptions } from '~/utils/enum'
import FormUpdateDocument from '~/components/FormUpdateDocument.vue' import FormUpdateDocument from '~/components/FormUpdateDocument.vue'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
@ -165,39 +169,21 @@ export default {
'$route.query': { '$route.query': {
immediate: true, immediate: true,
async handler() { async handler() {
this.search.page = parseInt(this.$route.query.page) || 1 let search = { ...this.search, ...this.$route.query }
this.search.size = parseInt(this.$route.query.size) || 10 search.page = parseInt(this.$route.query.page) || 1
this.search.wd = this.$route.query.wd || '' search.size = parseInt(this.$route.query.size) || 10
search.wd = this.$route.query.wd || ''
if (typeof this.$route.query.category_id === 'object') { this.search = {
this.search.category_id = (this.$route.query.category_id || []).map((item) => ...search,
parseInt(item) ...parseQueryIntArray(this.$route.query, ['category_id', 'status']),
) ...parseQueryBoolArray(this.$route.query, ['is_recommend']),
} 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) { if (this.trees.length === 0) {
await this.listCategory() await this.listCategory()
} }
await this.listDocument() await this.listDocument()
}, },
}, },
@ -205,9 +191,6 @@ export default {
async created() { async created() {
this.initSearchForm() this.initSearchForm()
this.initTableListFields() this.initTableListFields()
// //
// await this.listCategory()
// await this.listDocument()
}, },
methods: { methods: {
async listCategory() { async listCategory() {

@ -91,7 +91,7 @@ import {
} from '~/api/document' } from '~/api/document'
import TableList from '~/components/TableList.vue' import TableList from '~/components/TableList.vue'
import FormSearch from '~/components/FormSearch.vue' import FormSearch from '~/components/FormSearch.vue'
import { categoryToTrees } from '~/utils/utils' import { categoryToTrees, parseQueryIntArray } from '~/utils/utils'
import { documentStatusOptions } from '~/utils/enum' import { documentStatusOptions } from '~/utils/enum'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
@ -128,27 +128,14 @@ export default {
'$route.query': { '$route.query': {
immediate: true, immediate: true,
async handler() { async handler() {
this.search.page = parseInt(this.$route.query.page) || 1 this.search = {
this.search.size = parseInt(this.$route.query.size) || 10 ...this.search,
this.search.wd = this.$route.query.wd || '' ...this.$route.query,
page: parseInt(this.$route.query.page) || 1,
if (typeof this.$route.query.category_id === 'object') { size: parseInt(this.$route.query.size) || 10,
this.search.category_id = (this.$route.query.category_id || []).map((item) => ...parseQueryIntArray(this.$route.query, ['category_id', 'status']),
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) { if (this.trees.length === 0) {
await this.listCategory() await this.listCategory()
@ -210,19 +197,19 @@ export default {
handleSizeChange(val) { handleSizeChange(val) {
this.search.size = val this.search.size = val
this.$router.push({ this.$router.push({
query: this.search query: this.search,
}) })
}, },
handlePageChange(val) { handlePageChange(val) {
this.search.page = val this.search.page = val
this.$router.push({ this.$router.push({
query: this.search query: this.search,
}) })
}, },
onSearch(search) { onSearch(search) {
this.search = { ...this.search, ...search, page: 1 } this.search = { ...this.search, ...search, page: 1 }
this.$router.push({ this.$router.push({
query: this.search query: this.search,
}) })
}, },
recoverRow(row) { recoverRow(row) {

@ -47,7 +47,7 @@
<el-dialog <el-dialog
:title="friendlink.id ? '编辑友链' : '新增友链'" :title="friendlink.id ? '编辑友链' : '新增友链'"
:visible.sync="formFriendlinkVisible" :visible.sync="formFriendlinkVisible"
width="640px" width="520px"
> >
<FormFriendlink <FormFriendlink
ref="friendlinkForm" ref="friendlinkForm"
@ -64,6 +64,7 @@ import {
deleteFriendlink, deleteFriendlink,
getFriendlink, getFriendlink,
} from '~/api/friendlink' } from '~/api/friendlink'
import { parseQueryIntArray } from '~/utils/utils'
import TableList from '~/components/TableList.vue' import TableList from '~/components/TableList.vue'
import FormSearch from '~/components/FormSearch.vue' import FormSearch from '~/components/FormSearch.vue'
import FormFriendlink from '~/components/FormFriendlink.vue' import FormFriendlink from '~/components/FormFriendlink.vue'
@ -101,15 +102,12 @@ export default {
'$route.query': { '$route.query': {
immediate: true, immediate: true,
handler() { handler() {
this.search.page = parseInt(this.$route.query.page) || 1 this.search = {
this.search.size = parseInt(this.$route.query.size) || 10 ...this.search,
this.search.wd = this.$route.query.wd || '' ...this.$route.query,
if (typeof this.$route.query.enable === 'object') { page: parseInt(this.$route.query.page) || 1,
this.search.enable = (this.$route.query.enable || []).map((item) => size: parseInt(this.$route.query.size) || 10,
parseInt(item) ...parseQueryIntArray(this.$route.query, ['enable']),
)
} else if (this.$route.query.enable) {
this.search.enable = [parseInt(this.$route.query.enable) || 0]
} }
this.listFriendlink() this.listFriendlink()
}, },
@ -135,23 +133,20 @@ export default {
handleSizeChange(val) { handleSizeChange(val) {
this.search.size = val this.search.size = val
this.$router.push({ this.$router.push({
query: this.search query: this.search,
}) })
// this.listFriendlink()
}, },
handlePageChange(val) { handlePageChange(val) {
this.search.page = val this.search.page = val
this.$router.push({ this.$router.push({
query: this.search query: this.search,
}) })
// this.listFriendlink()
}, },
onSearch(search) { onSearch(search) {
this.search = { ...this.search, page: 1, ...search } this.search = { ...this.search, ...search, page: 1 }
this.$router.push({ this.$router.push({
query: this.search query: this.search,
}) })
// this.listFriendlink()
}, },
onCreate() { onCreate() {
this.friendlink = { id: 0 } this.friendlink = { id: 0 }

@ -47,7 +47,7 @@
<el-dialog <el-dialog
:title="report.id ? '编辑举报' : '新增举报'" :title="report.id ? '编辑举报' : '新增举报'"
:visible.sync="formReportVisible" :visible.sync="formReportVisible"
width="640px" width="520px"
> >
<FormReport <FormReport
ref="reportForm" ref="reportForm"
@ -62,6 +62,7 @@
<script> <script>
import { listReport, deleteReport } from '~/api/report' import { listReport, deleteReport } from '~/api/report'
import { reportOptions } from '~/utils/enum' import { reportOptions } from '~/utils/enum'
import { parseQueryIntArray } from '~/utils/utils'
import TableList from '~/components/TableList.vue' import TableList from '~/components/TableList.vue'
import FormSearch from '~/components/FormSearch.vue' import FormSearch from '~/components/FormSearch.vue'
import FormReport from '~/components/FormReport.vue' import FormReport from '~/components/FormReport.vue'
@ -99,22 +100,16 @@ export default {
async created() { async created() {
this.initSearchForm() this.initSearchForm()
this.initTableListFields() this.initTableListFields()
// await this.listReport()
}, },
watch: { watch: {
'$route.query': { '$route.query': {
handler() { handler() {
this.search.page = parseInt(this.$route.query.page) || 1 this.search = {
this.search.size = parseInt(this.$route.query.size) || 10 ...this.search,
this.search.wd = this.$route.query.wd || '' ...this.$route.query,
page: parseInt(this.$route.query.page) || 1,
// this.$route.query.status size: parseInt(this.$route.query.size) || 10,
if (typeof this.$route.query.status === 'object') { ...parseQueryIntArray(this.$route.query, ['status']),
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]
} }
this.listReport() this.listReport()
}, },
@ -138,18 +133,15 @@ export default {
this.$router.push({ this.$router.push({
query: this.search, query: this.search,
}) })
// this.listReport()
}, },
handlePageChange(val) { handlePageChange(val) {
this.search.page = val this.search.page = val
this.$router.push({ this.$router.push({
query: this.search, query: this.search,
}) })
// this.listReport()
}, },
onSearch(search) { onSearch(search) {
this.search = { ...this.search, page: 1, ...search } this.search = { ...this.search, ...search, page: 1 }
// this.listReport()
this.$router.push({ this.$router.push({
query: this.search, query: this.search,
}) })

@ -58,7 +58,7 @@
<el-dialog <el-dialog
:title="group.id ? '编辑分组' : '新增分组'" :title="group.id ? '编辑分组' : '新增分组'"
:visible.sync="formGroupVisible" :visible.sync="formGroupVisible"
width="640px" width="520px"
> >
<FormGroup :init-group="group" @success="success" /> <FormGroup :init-group="group" @success="success" />
</el-dialog> </el-dialog>
@ -95,8 +95,6 @@ export default {
search: { search: {
wd: '', wd: '',
page: 1, page: 1,
// status: [],
// group_id: [],
size: 10, size: 10,
}, },
groups: [], groups: [],
@ -119,10 +117,12 @@ export default {
'$route.query': { '$route.query': {
immediate: true, immediate: true,
handler() { handler() {
let search = { ...this.$route.query } this.search = {
search.page = parseInt(this.$route.query.page) || 1 ...this.search,
search.size = parseInt(this.$route.query.size) || 10 ...this.$route.query,
this.search = search page: parseInt(this.$route.query.page) || 1,
size: parseInt(this.$route.query.size) || 10,
}
this.listGroup() this.listGroup()
}, },
}, },

@ -59,7 +59,7 @@
<el-dialog <el-dialog
:title="user.id ? '设置用户' : '新增用户'" :title="user.id ? '设置用户' : '新增用户'"
:visible.sync="formUserVisible" :visible.sync="formUserVisible"
width="640px" width="520px"
> >
<FormUser <FormUser
ref="formUser" ref="formUser"
@ -71,7 +71,7 @@
<el-dialog <el-dialog
title="编辑用户" title="编辑用户"
:visible.sync="formUserProfileVisible" :visible.sync="formUserProfileVisible"
width="640px" width="520px"
> >
<FormUserProfile <FormUserProfile
ref="formUserProfile" ref="formUserProfile"
@ -86,6 +86,7 @@
import { deleteUser, getUser, listUser } from '~/api/user' import { deleteUser, getUser, listUser } from '~/api/user'
import { listGroup } from '~/api/group' import { listGroup } from '~/api/group'
import { userStatusOptions } from '~/utils/enum' import { userStatusOptions } from '~/utils/enum'
import { parseQueryIntArray } from '~/utils/utils'
import TableList from '~/components/TableList.vue' import TableList from '~/components/TableList.vue'
import FormSearch from '~/components/FormSearch.vue' import FormSearch from '~/components/FormSearch.vue'
import FormUser from '~/components/FormUser.vue' import FormUser from '~/components/FormUser.vue'
@ -127,29 +128,14 @@ export default {
'$route.query': { '$route.query': {
immediate: true, immediate: true,
async handler() { async handler() {
let search = { ...this.$route.query } this.search = {
search.page = parseInt(this.$route.query.page) || 1 ...this.search,
search.size = parseInt(this.$route.query.size) || 10 ...this.$route.query,
page: parseInt(this.$route.query.page) || 1,
// group_id size: parseInt(this.$route.query.size) || 10,
if (typeof this.$route.query.group_id === 'object') { ...parseQueryIntArray(this.$route.query, ['group_id', 'status']),
search.group_id = (this.$route.query.group_id || []).map((item) =>
parseInt(item)
)
} else if (this.$route.query.group_id) {
search.group_id = [parseInt(this.$route.query.group_id) || 0]
}
// status
if (typeof this.$route.query.status === 'object') {
search.status = (this.$route.query.status || []).map((item) =>
parseInt(item)
)
} else if (this.$route.query.status) {
search.status = [parseInt(this.$route.query.status) || 0]
} }
this.search = search
// //
await this.initTableListFields() await this.initTableListFields()
this.listUser() this.listUser()
@ -195,7 +181,7 @@ export default {
}) })
}, },
onSearch(search) { onSearch(search) {
this.search = { ...this.search, page: 1, ...search } this.search = { ...this.search, ...search, page: 1 }
this.$router.push({ this.$router.push({
query: this.search, query: this.search,
}) })

@ -41,7 +41,7 @@
</div> </div>
</el-card> </el-card>
<el-dialog title="编辑附件" width="640px" :visible.sync="formVisible"> <el-dialog title="编辑附件" width="520px" :visible.sync="formVisible">
<FormPermission :init-permission="permission" @success="formSuccess" /> <FormPermission :init-permission="permission" @success="formSuccess" />
</el-dialog> </el-dialog>
</div> </div>
@ -87,10 +87,12 @@ export default {
'$route.query': { '$route.query': {
immediate: true, immediate: true,
handler() { handler() {
let search = { ...this.$route.query } this.search = {
search.page = parseInt(this.$route.query.page) || 1 ...this.search,
search.size = parseInt(this.$route.query.size) || 10 ...this.$route.query,
this.search = search page: parseInt(this.$route.query.page) || 1,
size: parseInt(this.$route.query.size) || 10,
}
this.listPermission() this.listPermission()
}, },
}, },
@ -124,7 +126,7 @@ export default {
}) })
}, },
onSearch(search) { onSearch(search) {
this.search = { ...this.search, page: 1, ...search } this.search = { ...this.search, ...search, page: 1 }
this.$router.push({ this.$router.push({
query: this.search, query: this.search,
}) })

@ -177,3 +177,28 @@ const extMapIcon = {
export function getIcon(ext) { export function getIcon(ext) {
return extMapIcon[ext] || 'other' return extMapIcon[ext] || 'other'
} }
// 解析 $route.query 中的数组
export function parseQueryIntArray(query, keys) {
const result = {}
keys.forEach((key) => {
if (typeof query[key] === 'object') {
result[key] = (query[key] || []).map((item) => parseInt(item))
} else if (query[key]) {
result[key] = [parseInt(query[key]) || 0]
}
})
return result
}
export function parseQueryBoolArray(query, keys) {
const result = {}
keys.forEach((key) => {
if (typeof query[key] === 'object') {
result[key] = (query[key] || []).map((item) => item === 'true')
} else if (query[key]) {
result[key] = [query[key] === 'true']
}
})
return result
}

Loading…
Cancel
Save