diff --git a/src/components/Drawer/index.vue b/src/components/Drawer/index.vue
index a33cfc748..6a6a9ef0a 100644
--- a/src/components/Drawer/index.vue
+++ b/src/components/Drawer/index.vue
@@ -81,6 +81,7 @@ export default {
return this.visible
},
set(val) {
+ this.$log.debug('>>> Drawer iVisible set: ', val)
this.$emit('update:visible', val)
}
}
diff --git a/src/components/Table/DrawerListTable/index.vue b/src/components/Table/DrawerListTable/index.vue
index e7a2a55dc..ca566e5d1 100644
--- a/src/components/Table/DrawerListTable/index.vue
+++ b/src/components/Table/DrawerListTable/index.vue
@@ -75,14 +75,12 @@ export default {
title: '',
action: '',
drawerVisible: false,
- drawerComponent: ''
+ drawerComponent: '',
+ drawerTitle: ''
}
},
computed: {
...mapGetters(['inDrawer']),
- drawerTitle() {
- return this.getDefaultTitle()
- },
iHeaderActions() {
const actions = this.headerActions
if (!actions.onCreate) {
@@ -95,8 +93,7 @@ export default {
const actionMap = {
'columnsMeta.actions.formatterArgs.onUpdate': this.onUpdate,
'columnsMeta.actions.formatterArgs.onClone': this.onClone,
- 'columnsMeta.name.formatterArgs.drawer': true,
- 'columnsMeta.name.formatterArgs.drawerComponent': this.detailDrawer
+ 'columnsMeta.name.formatterArgs.onClick': this.onDetail
}
for (const [key, value] of Object.entries(actionMap)) {
if (_.get(config, key)) {
@@ -108,9 +105,9 @@ export default {
for (const value of Object.values(columnsMeta)) {
if (
value.formatter && value.formatter.name === 'AmountFormatter' &&
- value.formatterArgs && !value.formatterArgs.drawer
+ value.formatterArgs && value.formatterArgs.drawer !== false
) {
- value.formatterArgs.drawer = this.detailDrawer
+ value.formatterArgs.onClick = this.onDetail
}
}
return config
@@ -122,11 +119,11 @@ export default {
return
}
if (!val) {
- this.drawerVisible = false
- this.reloadTable()
+ // this.drawerVisible = false
}
},
drawerVisible: {
+ immediate: true,
handler(val, oldVal) {
this.$log.debug('>>> drawerVisible changed: ', oldVal, '->', val)
if (!val && oldVal) {
@@ -165,9 +162,18 @@ export default {
}
this.drawerComponent = ''
- console.log('>>> afterCloseDrawer 2', this.$route)
},
- getDefaultTitle() {
+ getDetailDrawerTitle({ col, row, cellValue, route }) {
+ let title = cellValue || row.name
+ const resource = route?.meta?.title || route?.name
+
+ if (resource) {
+ title = `${resource}: ${title}`
+ }
+
+ return title
+ },
+ getDefaultTitle({ row, col, cellValue, detailRoute }) {
let title = this.title
let dispatchAction = ''
if (!title && this.resource) {
@@ -186,8 +192,13 @@ export default {
dispatchAction = this.$t('Create')
} else if (action === 'update') {
dispatchAction = this.$t('Update')
+ } else if (action === 'detail') {
+ dispatchAction = this.$t('Detail')
}
title = dispatchAction + this.$t('WordSep') + toLowerCaseExcludeAbbr(title)
+ if (this.action === 'detail') {
+ title = this.getDetailDrawerTitle({ row, col, cellValue, route: detailRoute })
+ }
return title
},
getDefaultDrawer(action) {
@@ -214,7 +225,27 @@ export default {
return component
}
},
- async showDrawer(action) {
+ resolveRoute(route) {
+ const routes = this.$router.resolve(route)
+ if (!routes) {
+ return
+ }
+ const matched = routes.resolved.matched.filter(item => item.name === route.name && item.components)
+ if (matched.length === 0) {
+ return
+ }
+ if (matched[0] && matched[0].components?.default) {
+ return matched[0]
+ }
+ },
+ getDetailComponent(r) {
+ const route = this.resolveRoute(r)
+ if (route) {
+ return route.components.default
+ }
+ },
+ async showDrawer(action, { row, col, cellValue, detailRoute }) {
+ this.drawerTitle = this.getDefaultTitle({ row, col, cellValue, detailRoute })
try {
// 1. 先重置状态
this.drawerVisible = false
@@ -229,7 +260,7 @@ export default {
} else if (action === 'update') {
this.drawerComponent = this.updateDrawer || this.createDrawer
} else if (action === 'detail') {
- this.drawerComponent = this.detailDrawer
+ this.drawerComponent = this.detailDrawer || this.getDetailComponent(detailRoute)
} else if (action === 'clone') {
this.drawerComponent = this.createDrawer || this.getDefaultDrawer('create')
} else {
@@ -278,6 +309,13 @@ export default {
}
this.$refs.ListTable.reloadTable()
},
+ async onDetail({ row, col, cellValue, detailRoute }) {
+ this.$route.params.id = row.id
+ await this.$store.dispatch('common/setDrawerActionMeta', {
+ action: 'detail', row: row, col: col, id: row.id
+ })
+ await this.showDrawer('detail', { row, col, cellValue, detailRoute })
+ },
async onCreate(meta) {
if (!meta) {
meta = {}
@@ -291,7 +329,7 @@ export default {
await this.$store.dispatch('common/setDrawerActionMeta', {
action: 'clone', row: row, col: col, id: row.id
})
- await this.showDrawer('clone')
+ await this.showDrawer('clone', { row, col })
},
async onUpdate({ row, col }) {
this.$route.params.id = row.id
@@ -299,7 +337,7 @@ export default {
await this.$store.dispatch('common/setDrawerActionMeta', {
action: 'update', row: row, col: col, id: row.id
})
- await this.showDrawer('update')
+ await this.showDrawer('update', { row, col })
}
}
}
diff --git a/src/components/Table/TableFormatters/AmountFormatter.vue b/src/components/Table/TableFormatters/AmountFormatter.vue
index 40fab74de..a5a3d2093 100644
--- a/src/components/Table/TableFormatters/AmountFormatter.vue
+++ b/src/components/Table/TableFormatters/AmountFormatter.vue
@@ -43,7 +43,8 @@ export default {
async: false,
ajax: {},
title: '',
- preventClick: false
+ preventClick: false,
+ onClick: null
}
}
}
@@ -53,6 +54,7 @@ export default {
return {
formatterArgs: formatterArgs,
listData: formatterArgs.async ? [] : (this.cellValue || []),
+ onClick: formatterArgs.onClick,
amount: '',
asyncGetDone: false
}
diff --git a/src/components/Table/TableFormatters/DetailFormatter.vue b/src/components/Table/TableFormatters/DetailFormatter.vue
index a563625e5..60e823fbe 100644
--- a/src/components/Table/TableFormatters/DetailFormatter.vue
+++ b/src/components/Table/TableFormatters/DetailFormatter.vue
@@ -12,24 +12,14 @@
{{ iTitle }}
-
+
+
diff --git a/src/views/acls/UserLoginACL/UserLoginACLTable.vue b/src/views/acls/UserLoginACL/UserLoginACLTable.vue
index ad03cc780..234d11869 100644
--- a/src/views/acls/UserLoginACL/UserLoginACLTable.vue
+++ b/src/views/acls/UserLoginACL/UserLoginACLTable.vue
@@ -10,7 +10,7 @@
diff --git a/src/views/users/User/UserDetail/UserLoginACL.vue b/src/views/users/User/UserDetail/UserLoginACL.vue
index 5e3232d66..d034266e1 100644
--- a/src/views/users/User/UserDetail/UserLoginACL.vue
+++ b/src/views/users/User/UserDetail/UserLoginACL.vue
@@ -1,6 +1,6 @@
-
+
diff --git a/src/views/users/User/UserDetail/index.vue b/src/views/users/User/UserDetail/index.vue
index e06fa9206..0cfb43f3b 100644
--- a/src/views/users/User/UserDetail/index.vue
+++ b/src/views/users/User/UserDetail/index.vue
@@ -5,9 +5,7 @@
v-bind="config"
v-on="$listeners"
>
-
-
-
+
@@ -85,6 +83,12 @@ export default {
'currentUserIsSuperAdmin'
])
},
+ mounted() {
+ this.$log.debug('>>> UserDetail mounted: visible ', this)
+ },
+ destroyed() {
+ this.$log.debug('>>> UserDetail destroyed: visible ', this)
+ },
methods: {
handleTabClick(tab) {
this.$log.debug('Current nav is: ', this.config.activeMenu)