mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-16 23:31:29 +00:00
[Update] 修改generic list page
This commit is contained in:
@@ -486,12 +486,8 @@ export default {
|
|||||||
*/
|
*/
|
||||||
onEdit: {
|
onEdit: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default(data) {
|
default(row) {
|
||||||
return this.$axios.put(
|
console.log('On delete row')
|
||||||
`${this.url}/${this.row[this.id]}`,
|
|
||||||
data,
|
|
||||||
this.axiosConfig
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -1094,7 +1090,7 @@ export default {
|
|||||||
},
|
},
|
||||||
onDefaultEdit(row) {
|
onDefaultEdit(row) {
|
||||||
this.row = row
|
this.row = row
|
||||||
this.$refs.dialog.show(dialogModes.edit, row)
|
this.onEdit(row)
|
||||||
},
|
},
|
||||||
async onConfirm(isNew, formValue, done) {
|
async onConfirm(isNew, formValue, done) {
|
||||||
const data = {
|
const data = {
|
||||||
|
@@ -17,6 +17,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
const userTableActions = this.config.tableActions || {}
|
||||||
return {
|
return {
|
||||||
defaultConfig: {
|
defaultConfig: {
|
||||||
axiosConfig: {
|
axiosConfig: {
|
||||||
@@ -30,8 +31,8 @@ export default {
|
|||||||
totalPath: 'count',
|
totalPath: 'count',
|
||||||
saveQuery: false, // 关闭路径保存查询参数
|
saveQuery: false, // 关闭路径保存查询参数
|
||||||
persistSelection: true, // 切换页面 已勾选项不会丢失
|
persistSelection: true, // 切换页面 已勾选项不会丢失
|
||||||
hasEdit: true, // 有编辑按钮
|
hasEdit: userTableActions.hasEdit !== false, // 有编辑按钮
|
||||||
hasDelete: true,
|
hasDelete: userTableActions.hasDelete !== false,
|
||||||
hasNew: false,
|
hasNew: false,
|
||||||
// editText: this.$t('action.update'), // 编辑按钮文案
|
// editText: this.$t('action.update'), // 编辑按钮文案
|
||||||
operationAttrs: {
|
operationAttrs: {
|
||||||
@@ -43,6 +44,18 @@ export default {
|
|||||||
border: true, // 表格边框
|
border: true, // 表格边框
|
||||||
fit: true // 宽度自适应
|
fit: true // 宽度自适应
|
||||||
},
|
},
|
||||||
|
extraButtons: userTableActions.extraButtons,
|
||||||
|
onEdit: (row) => {
|
||||||
|
const defaultOnEdit = (row) => {
|
||||||
|
const routeName = userTableActions.editRoute
|
||||||
|
this.$router.push({ name: routeName, params: { id: row.id }})
|
||||||
|
}
|
||||||
|
let onEdit = userTableActions.onEdit
|
||||||
|
if (!onEdit) {
|
||||||
|
onEdit = defaultOnEdit
|
||||||
|
}
|
||||||
|
return onEdit(row)
|
||||||
|
},
|
||||||
pageCount: 5,
|
pageCount: 5,
|
||||||
paginationLayout: 'total, sizes, prev, pager, next',
|
paginationLayout: 'total, sizes, prev, pager, next',
|
||||||
transformQuery: query => {
|
transformQuery: query => {
|
||||||
|
@@ -31,7 +31,7 @@ export default {
|
|||||||
hasUpdate: defaultTrue,
|
hasUpdate: defaultTrue,
|
||||||
hasLeftActions: defaultTrue,
|
hasLeftActions: defaultTrue,
|
||||||
hasSearch: defaultTrue,
|
hasSearch: defaultTrue,
|
||||||
hasRightActions: defaultTrue,
|
hasRightActions: defaultTrue
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<TableAction v-bind="actionConfig" @clickAction="handleActionClick"></TableAction>
|
<TableAction v-bind="headerActions" @clickAction="handleActionClick"></TableAction>
|
||||||
<el-card class="table-content">
|
<el-card class="table-content">
|
||||||
<DataTable :config="tableConfig" @selection-change="handleSelectionChange"></DataTable>
|
<DataTable :config="tableConfig" @selection-change="handleSelectionChange"></DataTable>
|
||||||
</el-card>
|
</el-card>
|
||||||
@@ -24,14 +24,14 @@ export default {
|
|||||||
default: () => {}
|
default: () => {}
|
||||||
},
|
},
|
||||||
// 是否显示table左侧的action
|
// 是否显示table左侧的action
|
||||||
actionConfig: {
|
headerActions: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({ })
|
default: () => ({ })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
selectRows: []
|
selectRows: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -43,7 +43,27 @@ export default {
|
|||||||
(val.length > 0) ? (this.selectDisable = false) : (this.selectDisable = true)
|
(val.length > 0) ? (this.selectDisable = false) : (this.selectDisable = true)
|
||||||
},
|
},
|
||||||
handleActionClick(item) {
|
handleActionClick(item) {
|
||||||
console.log('Handle ', item, this.selectRows)
|
const handler = this.getActionHandler(item)
|
||||||
|
handler(this.selectRows)
|
||||||
|
},
|
||||||
|
handleActionCreate() {
|
||||||
|
const routeName = this.headerActions.createRoute || ''
|
||||||
|
this.$router.push({ name: routeName })
|
||||||
|
console.log('handle create')
|
||||||
|
},
|
||||||
|
getActionHandler(item) {
|
||||||
|
let handler = this.headerActions.item
|
||||||
|
const defaultHandlerName = 'handle' + item[0].toUpperCase() + item.slice(1, item.length)
|
||||||
|
if (!handler) {
|
||||||
|
handler = this[defaultHandlerName]
|
||||||
|
}
|
||||||
|
if (!handler) {
|
||||||
|
handler = () => {
|
||||||
|
console.log('No handler found for ', item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(handler)
|
||||||
|
return handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
src/layout/components/GenericListPage/index.vue
Normal file
13
src/layout/components/GenericListPage/index.vue
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<template>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'index'
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
@@ -69,15 +69,15 @@ export const constantRoutes = [
|
|||||||
path: 'users/create',
|
path: 'users/create',
|
||||||
component: () => import('@/views/users/UserCreate.vue'), // Parent router-view
|
component: () => import('@/views/users/UserCreate.vue'), // Parent router-view
|
||||||
name: 'UserCreate',
|
name: 'UserCreate',
|
||||||
|
hidden: true,
|
||||||
meta: { title: 'UserCreate' },
|
meta: { title: 'UserCreate' },
|
||||||
hidden: true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'users/:id',
|
path: 'users/:id',
|
||||||
component: () => import('@/views/users/UserDetail.vue'), // Parent router-view
|
component: () => import('@/views/users/UserDetail.vue'), // Parent router-view
|
||||||
name: 'UserDetail',
|
name: 'UserDetail',
|
||||||
|
hidden: true,
|
||||||
meta: { title: 'UserDetail', activeMenu: '/users/users' },
|
meta: { title: 'UserDetail', activeMenu: '/users/users' },
|
||||||
hidden: true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'groups',
|
path: 'groups',
|
||||||
@@ -89,16 +89,23 @@ export const constantRoutes = [
|
|||||||
path: 'groups/:id/update',
|
path: 'groups/:id/update',
|
||||||
component: () => import('@/views/users/UserGroupEdit.vue'), // Parent router-view
|
component: () => import('@/views/users/UserGroupEdit.vue'), // Parent router-view
|
||||||
name: 'UserGroupEdit',
|
name: 'UserGroupEdit',
|
||||||
|
hidden: true,
|
||||||
meta: { title: 'UserGroupEdit' },
|
meta: { title: 'UserGroupEdit' },
|
||||||
hidden: true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'groups/:id',
|
path: 'groups/:id',
|
||||||
component: () => import('@/views/users/UserGroupDetail/index.vue'), // Parent router-view
|
component: () => import('@/views/users/UserGroupDetail/index.vue'), // Parent router-view
|
||||||
name: 'UserGroupDetail',
|
name: 'UserGroupDetail',
|
||||||
|
hidden: true,
|
||||||
meta: { title: 'UserGroupDetail', activeMenu: '/users/groups' },
|
meta: { title: 'UserGroupDetail', activeMenu: '/users/groups' },
|
||||||
hidden: true
|
},
|
||||||
}
|
{
|
||||||
|
path: 'groups/create',
|
||||||
|
component: () => import('@/views/users/UserCreate.vue'), // Parent router-view
|
||||||
|
name: 'UserGroupCreate',
|
||||||
|
hidden: true,
|
||||||
|
meta: { title: 'UserGroupCreate' }
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<Page>
|
<Page>
|
||||||
<el-alert type="success"> 这里是一个成功的文案 </el-alert>
|
<el-alert type="success"> 这里是一个成功的文案 </el-alert>
|
||||||
<ListTable :table-config="tableConfig" :action-config="actionConfig" />
|
<ListTable :table-config="tableConfig" :header-actions="headerActions" />
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -41,12 +41,13 @@ export default {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
// 写路由名字,table组件会自动传作为参数
|
// 写路由名字,table组件会自动传作为参数
|
||||||
action: {
|
tableActions: {
|
||||||
hasEdit: 'UserGroupEdit',
|
hasEdit: true,
|
||||||
newClick: 'UserGroupEdit'
|
editRoute: '404'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actionConfig: {
|
headerActions: {
|
||||||
|
createRoute: 'UserGroupCreate'
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user