refactor: 前端驼峰转下划线

This commit is contained in:
2024-01-27 15:41:13 +08:00
parent 1c6f2bd7be
commit 29ca5f703c
18 changed files with 496 additions and 400 deletions

View File

@@ -58,9 +58,9 @@
<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="创建日期">
<el-table-column show-overflow-tooltip width="135px" prop="create_time" label="创建日期">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
<span>{{ parseTime(scope.row.create_time) }}</span>
</template>
</el-table-column>
<el-table-column
@@ -112,7 +112,7 @@
check-strictly
accordion
show-checkbox
node-key="menuId"
node-key="menu_id"
@check="menuChange"
/>
</el-card>
@@ -123,20 +123,20 @@
<script>
import crudRoles from './role'
import crudMenu from '@/views/system/menu'
import { getChild, getMenusTree } from '@/views/system/menu/menu'
import crudMenu from '../menu/menu'
import { getChild, getMenusTree } from '../menu/menu'
import CRUD, { crud, form, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
const defaultForm = { roleId: null, name: null, remark: null }
const defaultForm = { role_id: null, name: null, remark: null }
export default {
name: 'Role',
components: { pagination, crudOperation, rrOperation, udOperation, crudMenu },
cruds() {
return CRUD({ idField: 'roleId', title: '角色', url: 'api/sysRole', crudMethod: { ...crudRoles } })
return CRUD({ idField: 'role_id', title: '角色', url: 'api/sysRole', crudMethod: { ...crudRoles } })
},
mixins: [presenter(), header(), form(defaultForm), crud()],
data() {
@@ -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)
@@ -203,7 +203,7 @@ export default {
// 清空菜单的选中
this.$refs.menu.setCheckedKeys([])
// 保存当前的角色id
this.currentId = val.roleId
this.currentId = val.role_id
// 初始化默认选中的key
this.menuIds = []
val.menus.forEach(function(data) {
@@ -214,9 +214,9 @@ export default {
},
menuChange(menu) {
// 获取该节点的所有子节点id 包含自身
getChild(menu.menuId).then(childIds => {
getChild(menu.menu_id).then(childIds => {
// 判断是否在 menuIds 中,如果存在则删除,否则添加
if (this.menuIds.indexOf(menu.menuId) !== -1) {
if (this.menuIds.indexOf(menu.menu_id) !== -1) {
for (let i = 0; i < childIds.length; i++) {
const index = this.menuIds.indexOf(childIds[i])
if (index !== -1) {
@@ -237,7 +237,7 @@ export default {
// 保存菜单
saveMenu() {
this.menuLoading = true
const role = { roleId: this.currentId, menus: [] }
const role = { role_id: this.currentId, menus: [] }
// 得到已选中的 key 值
this.menuIds.forEach(function(menuId) {
const menu = { menuId: menuId }
@@ -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
}