menuId改为menu_id

This commit is contained in:
2023-05-05 16:35:38 +08:00
parent afd8dc8026
commit 047199776d
3 changed files with 61 additions and 62 deletions

View File

@@ -13,9 +13,9 @@
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
<rrOperation/>
<rrOperation />
</div>
<crudOperation :permission="permission"/>
<crudOperation :permission="permission" />
</div>
<!-- 表单渲染 -->
<el-dialog
@@ -28,10 +28,10 @@
>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="mini" label-width="80px">
<el-form-item label="角色名称" prop="name">
<el-input v-model="form.name" style="width: 380px;"/>
<el-input v-model="form.name" style="width: 380px;" />
</el-form-item>
<el-form-item label="备注" prop="description">
<el-input v-model="form.remark" style="width: 380px;" rows="2" type="textarea"/>
<el-input v-model="form.remark" style="width: 380px;" rows="2" type="textarea" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@@ -55,9 +55,9 @@
@selection-change="crud.selectionChangeHandler"
@current-change="handleCurrentChange"
>
<el-table-column type="selection" width="55"/>
<el-table-column prop="name" label="名称" min-width="100" show-overflow-tooltip/>
<el-table-column show-overflow-tooltip prop="remark" label="描述"/>
<el-table-column type="selection" width="55" />
<el-table-column prop="name" label="名称" min-width="100" show-overflow-tooltip />
<el-table-column show-overflow-tooltip prop="remark" label="描述" />
<el-table-column show-overflow-tooltip width="135px" prop="createTime" label="创建日期">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
@@ -79,7 +79,7 @@
</el-table-column>
</el-table>
<!--分页组件-->
<pagination/>
<pagination />
</el-card>
</el-col>
<!-- 菜单授权 -->
@@ -106,13 +106,13 @@
ref="menu"
lazy
:data="menus"
:default-checked-keys="menuIds"
:default-checked-keys="menu_ids"
:load="getMenuDatas"
:props="defaultProps"
check-strictly
accordion
show-checkbox
node-key="menuId"
node-key="menu_id"
@check="menuChange"
/>
</el-card>
@@ -123,7 +123,7 @@
<script>
import crudRoles from './role'
import crudMenu from '@/views/system/menu'
import crudMenu from '@/views/system/menu/menu'
import { getChild, getMenusTree } from '@/views/system/menu/menu'
import CRUD, { crud, form, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
@@ -136,14 +136,14 @@ export default {
name: 'Role',
components: { pagination, crudOperation, rrOperation, udOperation, crudMenu },
cruds() {
return CRUD({ idField: 'roleId', title: '角色', url: 'api/sysRole', crudMethod: { ...crudRoles } })
return CRUD({ idField: 'roleId', title: '角色', url: 'api/sysRole', crudMethod: { ...crudRoles }})
},
mixins: [presenter(), header(), form(defaultForm), crud()],
data() {
return {
defaultProps: { children: 'children', label: 'title', isLeaf: 'leaf' },
currentId: 0, menuLoading: false, showButton: false,
menus: [], menuIds: [], // 多选时使用
menus: [], menu_ids: [], // 多选时使用
permission: {
add: ['admin', 'roles:add'],
edit: ['admin', 'roles:edit'],
@@ -164,7 +164,7 @@ export default {
methods: {
getMenuDatas(node, resolve) {
setTimeout(() => {
getMenusTree(node.data.menuId ? node.data.menuId : 0).then(res => {
getMenusTree(node.data.menu_id ? node.data.menu_id : 0).then(res => {
resolve(res)
})
}, 100)
@@ -182,9 +182,9 @@ export default {
_this.menus = res
// 初始化默认选中的key
_this.menuIds = []
_this.menu_ids = []
_this.menus.forEach(function(data) {
_this.menuIds.push(data)
_this.menu_ids.push(data)
})
})
}
@@ -205,33 +205,33 @@ export default {
// 保存当前的角色id
this.currentId = val.roleId
// 初始化默认选中的key
this.menuIds = []
this.menu_ids = []
val.menus.forEach(function(data) {
_this.menuIds.push(data)
_this.menu_ids.push(data)
})
this.showButton = true
}
},
menuChange(menu) {
// 获取该节点的所有子节点id 包含自身
getChild(menu.menuId).then(childIds => {
// 判断是否在 menuIds 中,如果存在则删除,否则添加
if (this.menuIds.indexOf(menu.menuId) !== -1) {
getChild(menu.menu_id).then(childIds => {
// 判断是否在 menu_ids 中,如果存在则删除,否则添加
if (this.menu_ids.indexOf(menu.menu_id) !== -1) {
for (let i = 0; i < childIds.length; i++) {
const index = this.menuIds.indexOf(childIds[i])
const index = this.menu_ids.indexOf(childIds[i])
if (index !== -1) {
this.menuIds.splice(index, 1)
this.menu_ids.splice(index, 1)
}
}
} else {
for (let i = 0; i < childIds.length; i++) {
const index = this.menuIds.indexOf(childIds[i])
const index = this.menu_ids.indexOf(childIds[i])
if (index === -1) {
this.menuIds.push(childIds[i])
this.menu_ids.push(childIds[i])
}
}
}
this.$refs.menu.setCheckedKeys(this.menuIds)
this.$refs.menu.setCheckedKeys(this.menu_ids)
})
},
// 保存菜单
@@ -239,8 +239,8 @@ export default {
this.menuLoading = true
const role = { roleId: this.currentId, menus: [] }
// 得到已选中的 key 值
this.menuIds.forEach(function(menuId) {
const menu = { menuId: menuId }
this.menu_ids.forEach(function(menu_id) {
const menu = { menu_id: menu_id }
role.menus.push(menu)
})
crudRoles.editMenu(role).then(() => {
@@ -258,7 +258,7 @@ export default {
// 无刷新更新 表格数据
crudRoles.get(this.currentId).then(res => {
for (let i = 0; i < this.crud.data.length; i++) {
if (res.menuId === this.crud.data[i].menuId) {
if (res.menu_id === this.crud.data[i].menu_id) {
this.crud.data[i] = res
break
}