1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 23:11:24 +08:00

Added search in GroupManagement. Optimized RoleController.

This commit is contained in:
2023-06-02 21:43:31 +08:00
parent 1c55e161c5
commit 51cd40c162
8 changed files with 167 additions and 71 deletions

View File

@@ -1,19 +1,71 @@
<template>
<el-button bg style="background-color: white" :loading="tableLoading" @click="loadGroupTable">
<template #icon>
<el-icon>
<icon-pinnacle-refresh />
</el-icon>
</template>
</el-button>
<el-button type="primary" @click="handleAddBtn">
<template #icon>
<el-icon>
<icon-pinnacle-plus />
</el-icon>
</template>
<template #default> 添加 </template>
</el-button>
<el-row :gutter="5">
<el-col :span="-1">
<el-button
bg
style="background-color: white"
:loading="tableLoading"
@click="loadGroupTable"
>
<template #icon>
<el-icon>
<icon-pinnacle-refresh />
</el-icon>
</template>
</el-button>
</el-col>
<el-col :span="-1">
<el-button type="primary" @click="handleAddBtn">
<template #icon>
<el-icon>
<icon-pinnacle-plus />
</el-icon>
</template>
</el-button>
</el-col>
<el-col :span="5">
<el-form-item label="名称" class="fill-with">
<el-input
v-model="inputName"
maxlength="30"
show-word-limit
placeholder="请输入内容"
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="9">
<el-select
v-model="selectedRole"
class="fill-with"
clearable
collapse-tags
collapse-tags-tooltip
multiple
filterable
>
<el-option
v-for="item in roleOptions"
:key="item.id"
:value="item.id"
:label="item.name"
/>
</el-select>
</el-col>
<el-col :span="3">
<el-form-item label="状态" class="fill-with">
<el-select v-model="selectedEnable" class="fill-with">
<el-option label="全部" :value="-1" />
<el-option label="启用" :value="1" />
<el-option label="禁用" :value="0" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="-1">
<el-button type="primary" @click="handleQuery">查询</el-button>
<el-button @click="handleClear">清空</el-button>
</el-col>
</el-row>
<common-table
:table-date="groupTable"
:table-loading="tableLoading"
@@ -106,6 +158,13 @@ export default {
dialogVisible: false,
tableLoading: true,
dialogLoading: true,
roleOptions: [],
searchName: '',
searchRole: [],
searchEnable: -1,
inputName: '',
selectedRole: [],
selectedEnable: -1,
currentPage: 1,
pageSize: 50,
totalCount: 0,
@@ -133,7 +192,13 @@ export default {
loadGroupTable() {
this.tableLoading = true
request
.get('/group', { currentPage: this.currentPage, pageSize: this.pageSize })
.get('/group', {
currentPage: this.currentPage,
pageSize: this.pageSize,
searchName: this.searchName,
searchRole: this.searchRole + '',
searchEnable: this.searchEnable
})
.then((res) => {
const response = res.data
if (response.code === DATABASE_SELECT_OK) {
@@ -177,6 +242,7 @@ export default {
request.get('/role/list').then((res) => {
const response = res.data
if (response.code === DATABASE_SELECT_OK) {
this.roleOptions = response.data
this.roles = response.data
this.dialogLoading = false
} else {
@@ -291,10 +357,23 @@ export default {
handleCurrentChange(currentPage) {
this.currentPage = currentPage
this.loadGroupTable()
},
handleQuery() {
this.searchName = this.inputName
this.searchRole = this.selectedRole
this.searchEnable = this.selectedEnable
this.loadGroupTable()
},
handleClear() {
this.inputName = ''
this.selectedRole = []
this.selectedEnable = -1
this.handleQuery()
}
},
mounted() {
this.loadGroupTable()
this.getRoles()
}
}
</script>

View File

@@ -257,7 +257,7 @@ export default {
})
},
handleDialogOpen() {
this.getPowerTree()
this.getPowers()
if (this.isAddNew) {
this.defaultSelectedPower = []
@@ -269,7 +269,7 @@ export default {
this.dialogTitle = '编辑角色'
}
},
getPowerTree() {
getPowers() {
this.dialogLoading = true
request.get('/power').then((res) => {
const response = res.data
@@ -297,6 +297,7 @@ export default {
menu.children = menu.children[0].children
}
}
this.powerOptions = data.menuList
this.powerTree = data.menuList
this.dialogLoading = false
} else {
@@ -307,42 +308,6 @@ export default {
}
})
},
getPowerOptions() {
request.get('/power').then((res) => {
const response = res.data
if (response.code === DATABASE_SELECT_OK) {
const data = response.data
const menuList = data.menuList
const elementList = data.elementList
const operationList = data.operationList
for (const operation of operationList) {
const element = _.find(elementList, { id: operation.elementId })
if (element.children === undefined) {
element.children = []
}
element.children.push(operation)
}
for (const element of elementList) {
const menu = _.find(menuList, { id: element.menuId })
if (menu.children === undefined) {
menu.children = []
}
menu.children.push(element)
}
for (const menu of menuList) {
if (menu.children.length === 1) {
menu.children = menu.children[0].children
}
}
this.powerOptions = data.menuList
} else {
ElMessage.error({
dangerouslyUseHTMLString: true,
message: '<strong>查询出错</strong>: ' + response.msg
})
}
})
},
handleTreeSelectedPowerChange(data, checked, indeterminate) {
if (data.children === undefined) {
if (checked || indeterminate) {
@@ -479,7 +444,7 @@ export default {
},
mounted() {
this.loadRoleTable()
this.getPowerOptions()
this.getPowers()
}
}
</script>