Commit cc0c3990 authored by yf's avatar yf

部门和菜单的条件查询 杨帆

parent 3e00909b
...@@ -148,7 +148,7 @@ export function handleTree(data, id, parentId, children, rootId) { ...@@ -148,7 +148,7 @@ export function handleTree(data, id, parentId, children, rootId) {
id = id || 'id' id = id || 'id'
parentId = parentId || 'parentId' parentId = parentId || 'parentId'
children = children || 'children' children = children || 'children'
rootId = rootId || 0 rootId = rootId || Math.min.apply(Math, data.map(item => { return item[parentId] })) || 0
// 对源数据深度克隆 // 对源数据深度克隆
const cloneData = JSON.parse(JSON.stringify(data)) const cloneData = JSON.parse(JSON.stringify(data))
// 循环所有项 // 循环所有项
...@@ -157,7 +157,7 @@ export function handleTree(data, id, parentId, children, rootId) { ...@@ -157,7 +157,7 @@ export function handleTree(data, id, parentId, children, rootId) {
// 返回每一项的子级数组 // 返回每一项的子级数组
return father[id] === child[parentId] return father[id] === child[parentId]
}) })
branchArr.length > 0 ? (father.children = branchArr) : '' branchArr.length > 0 ? father.children = branchArr : ''
// 返回第一层 // 返回第一层
return father[parentId] === rootId return father[parentId] === rootId
}) })
......
...@@ -90,12 +90,19 @@ ...@@ -90,12 +90,19 @@
<!-- </template>--> <!-- </template>-->
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
v-hasPermi="['system:dept:edit']" v-hasPermi="['system:dept:update']"
size="mini" size="mini"
type="text" type="text"
style="color: #49cec9" style="color: #49cec9"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
>修改</el-button> >修改</el-button>
<!-- <el-switch-->
<!-- v-model="scope.row.flag"-->
<!-- v-hasPermi="['system:dept:toggle']"-->
<!-- active-value="0"-->
<!-- inactive-value="1"-->
<!-- @change="handleStatusChange(scope.row)"-->
<!-- />-->
<el-button <el-button
v-hasPermi="['system:dept:add']" v-hasPermi="['system:dept:add']"
size="mini" size="mini"
...@@ -104,7 +111,7 @@ ...@@ -104,7 +111,7 @@
>新增</el-button> >新增</el-button>
<el-button <el-button
v-if="scope.row.parentId !== 0" v-if="scope.row.parentId !== 0"
v-hasPermi="['system:dept:remove']" v-hasPermi="['system:dept:delete']"
size="mini" size="mini"
type="text" type="text"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
...@@ -246,6 +253,23 @@ export default { ...@@ -246,6 +253,23 @@ export default {
this.Loading = false this.Loading = false
}) })
}, },
// handleStatusChange(row) {
// const text = row.flag === '1' ? '启用' : '停用'
// this.$confirm(`“${row.deptName}”部门即将被${text},是否继续?`, '提示', {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning'
// }).then(function() {
// return updateDept(row)
// }).then(() => {
// this.$message({
// message: text + '成功',
// type: 'success'
// })
// }).catch(function() {
// row.flag = row.flag === '0' ? '1' : '0'
// })
// },
/** 转换部门数据结构 */ /** 转换部门数据结构 */
normalizer(node) { normalizer(node) {
if (node.children && !node.children.length) { if (node.children && !node.children.length) {
......
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" size="small" @click="handleQuery">查询</el-button> <el-button v-hasPermi="['system:menu:query']" type="primary" size="small" @click="handleQuery">查询</el-button>
</el-form-item> </el-form-item>
<div style="float: right"> <div style="float: right">
<el-form-item> <el-form-item>
<el-button type="primary" size="small" @click="handleAdd">新增</el-button> <el-button v-hasPermi="['system:menu:add']" type="primary" size="small" @click="handleAdd">新增</el-button>
<!-- <el-button size="small" @click="resetQuery">重置</el-button>--> <!-- <el-button size="small" @click="resetQuery">重置</el-button>-->
</el-form-item> </el-form-item>
</div> </div>
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
</template>--> </template>-->
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
v-hasPermi="['system:menu:edit']" v-hasPermi="['system:menu:update']"
size="mini" size="mini"
type="text" type="text"
style="color: #49cec9" style="color: #49cec9"
...@@ -93,8 +93,8 @@ ...@@ -93,8 +93,8 @@
<el-switch <el-switch
v-model="scope.row.flag" v-model="scope.row.flag"
v-hasPermi="['system:menu:toggle']" v-hasPermi="['system:menu:toggle']"
active-value="0" active-value="1"
inactive-value="1" inactive-value="0"
@change="handleStatusChange(scope.row)" @change="handleStatusChange(scope.row)"
/> />
<el-dropdown class="table-drop"> <el-dropdown class="table-drop">
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item> <el-dropdown-item>
<el-button <el-button
v-hasPermi="['system:menu:remove']" v-hasPermi="['system:menu:delete']"
size="mini" size="mini"
type="text" type="text"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
...@@ -216,8 +216,8 @@ ...@@ -216,8 +216,8 @@
<el-col :span="12"> <el-col :span="12">
<el-form-item v-if="form.menuType !== 'f'" label="菜单状态"> <el-form-item v-if="form.menuType !== 'f'" label="菜单状态">
<el-radio-group v-model="form.flag"> <el-radio-group v-model="form.flag">
<el-radio label="0">启用</el-radio> <el-radio label="1">启用</el-radio>
<el-radio label="1">停用</el-radio> <el-radio label="0">停用</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col> </el-col>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</template> </template>
<script> <script>
import { listMenu, getMenu, delMenu, addMenu, updateMenu, findAllMenu } from '@/api/system/menu' import { addMenu, delMenu, getMenu, listMenu, updateMenu } from '@/api/system/menu'
import Treeselect from '@riophae/vue-treeselect' import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css' import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import IconSelect from '@/components/IconSelect' import IconSelect from '@/components/IconSelect'
...@@ -364,7 +364,7 @@ export default { ...@@ -364,7 +364,7 @@ export default {
getList() { getList() {
this.loading = true this.loading = true
if (this.queryParams.menuName) { if (this.queryParams.menuName) {
findAllMenu(this.queryParams.menuName).then(response => { listMenu(this.queryParams.menuName).then(response => {
this.menuList = this.handleTree(response.data.filter(menu => { return menu.businessId }), 'businessId') this.menuList = this.handleTree(response.data.filter(menu => { return menu.businessId }), 'businessId')
this.loading = false this.loading = false
}).catch(e => { }).catch(e => {
...@@ -439,8 +439,8 @@ export default { ...@@ -439,8 +439,8 @@ export default {
/** 查询按钮操作 */ /** 查询按钮操作 */
handleQuery() { handleQuery() {
this.loading = true this.loading = true
findAllMenu(this.queryParams.menuName).then(response => { listMenu(this.queryParams).then(response => {
this.menuList = this.handleTree(response.data.filter(menu => { return menu.businessId }), 'businessId') this.menuList = this.handleTree(response.data, 'businessId')
this.loading = false this.loading = false
}).catch(e => { }).catch(e => {
this.loading = false this.loading = false
...@@ -473,7 +473,7 @@ export default { ...@@ -473,7 +473,7 @@ export default {
}) })
}, },
handleStatusChange(row) { handleStatusChange(row) {
const text = row.flag === '0' ? '启用' : '停用' const text = row.flag === '0' ? '停用' : '启用'
this.$confirm(`“${row.menuName}”菜单即将被${text},是否继续?`, '提示', { this.$confirm(`“${row.menuName}”菜单即将被${text},是否继续?`, '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment