[Update] 添加默认更新配置

This commit is contained in:
ibuler
2020-04-03 15:50:05 +08:00
parent 8a40a5c0ff
commit 5d9d87512a
5 changed files with 20 additions and 8 deletions

View File

@@ -5,13 +5,16 @@
<script>
import ActionsGroup from '@/components/ActionsGroup/index'
import BaseFormatter from './base'
const defaultPerformDelete = function({row, col}) {
const id = row.id
const url = `/api/v1/users/groups/${id}/`
return this.$axios.delete(url)
}
const defaultUpdateCallback = ({row, col, cellValue, reload}) => {
const defaultUpdateCallback = function({row, col}) {
const id = row.id
const routeName = col.actions.updateRoute || '404'
this.$router.push({name: routeName, params: {id: id}})
}
const defaultDeleteCallback = function({row, col, cellValue, reload}) {

View File

@@ -37,6 +37,7 @@ const cn = {
'More actions': '更多操作',
'Delete selected': '删除所选',
'Update selected': '更新所选',
'Delete success': '删除成功',
'Search': '搜索',
'Source': '来源',
'Status': '状态',

View File

@@ -87,10 +87,10 @@ export const constantRoutes = [
},
{
path: 'groups/:id/update',
component: () => import('@/views/users/UserGroupEdit.vue'), // Parent router-view
name: 'UserGroupEdit',
component: () => import('@/views/users/UserGroupUpdate.vue'), // Parent router-view
name: 'UserGroupUpdate',
hidden: true,
meta: { title: 'UserGroupEdit' }
meta: { title: 'UserGroupUpdate' }
},
{
path: 'groups/:id',

View File

@@ -11,7 +11,6 @@ export default {
GenericListPage
},
data() {
const data = []
return {
tableConfig: {
url: '/api/v1/users/groups/',
@@ -21,7 +20,7 @@ export default {
label: this.$tc('Name'),
formatter: DetailFormatter,
sortable: true,
route: 'UserDetail'
route: 'UserGroupDetail'
},
{
prop: 'users_amount',
@@ -38,7 +37,16 @@ export default {
label: this.$tc('Actions'),
align: 'center',
formatter: ActionsFormatter,
width: '200px'
width: '200px',
actions: {
updateRoute: 'UserGroupUpdate',
extraActions: [
{
name: 'run',
title: this.$tc('Run')
}
]
}
}
],
// 写路由名字table组件会自动传作为参数