|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
<script>
|
|
|
|
|
import events from './events'
|
|
|
|
|
|
|
|
|
|
import { BookingOrderGet } from '@/api/modular/main/BookingLedger'
|
|
|
|
|
export default {
|
|
|
|
|
name: 'MultiTab',
|
|
|
|
|
data () {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
fullPathList: [],
|
|
|
|
|
pages: [],
|
|
|
|
@ -11,27 +11,29 @@ export default {
|
|
|
|
|
newTabIndex: 0
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created () {
|
|
|
|
|
created() {
|
|
|
|
|
// bind event
|
|
|
|
|
events.$on('open', val => {
|
|
|
|
|
events
|
|
|
|
|
.$on('open', val => {
|
|
|
|
|
if (!val) {
|
|
|
|
|
throw new Error(`multi-tab: open tab ${val} err`)
|
|
|
|
|
}
|
|
|
|
|
this.activeKey = val
|
|
|
|
|
}).$on('close', val => {
|
|
|
|
|
})
|
|
|
|
|
.$on('close', val => {
|
|
|
|
|
if (!val) {
|
|
|
|
|
this.closeThat(this.activeKey)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.closeThat(val)
|
|
|
|
|
}).$on('rename', ({ key, name }) => {
|
|
|
|
|
})
|
|
|
|
|
.$on('rename', ({ key, name }) => {
|
|
|
|
|
console.log('rename', key, name)
|
|
|
|
|
try {
|
|
|
|
|
const item = this.pages.find(item => item.path === key)
|
|
|
|
|
item.meta.customTitle = name
|
|
|
|
|
this.$forceUpdate()
|
|
|
|
|
} catch (e) {
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.pages.push(this.$route)
|
|
|
|
@ -39,10 +41,24 @@ export default {
|
|
|
|
|
this.selectedLastPath()
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
onEdit (targetKey, action) {
|
|
|
|
|
onEdit(targetKey, action) {
|
|
|
|
|
// let _that = this
|
|
|
|
|
// if (targetKey.split('?')[0] == '/BookingDetail') {
|
|
|
|
|
// this.$confirm({
|
|
|
|
|
// title: '请确认无未保存数据!',
|
|
|
|
|
// content: '当点击确定按钮时,此页面 将会关闭。',
|
|
|
|
|
// onOk() {
|
|
|
|
|
// _that[action](targetKey)
|
|
|
|
|
// },
|
|
|
|
|
// onCancel() {}
|
|
|
|
|
// })
|
|
|
|
|
// } else {
|
|
|
|
|
// this[action](targetKey)
|
|
|
|
|
// }
|
|
|
|
|
this[action](targetKey)
|
|
|
|
|
console.log('关闭?', targetKey, action)
|
|
|
|
|
},
|
|
|
|
|
remove (targetKey) {
|
|
|
|
|
remove(targetKey) {
|
|
|
|
|
this.pages = this.pages.filter(page => page.fullPath !== targetKey)
|
|
|
|
|
this.fullPathList = this.fullPathList.filter(path => path !== targetKey)
|
|
|
|
|
// 判断当前标签是否关闭,若关闭则跳转到最后一个还存在的标签页
|
|
|
|
@ -50,12 +66,12 @@ export default {
|
|
|
|
|
this.selectedLastPath()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
selectedLastPath () {
|
|
|
|
|
selectedLastPath() {
|
|
|
|
|
this.activeKey = this.fullPathList[this.fullPathList.length - 1]
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// content menu
|
|
|
|
|
closeThat (e) {
|
|
|
|
|
closeThat(e) {
|
|
|
|
|
// 判断是否为最后一个标签页,如果是最后一个,则无法被关闭
|
|
|
|
|
if (this.fullPathList.length > 1) {
|
|
|
|
|
this.remove(e)
|
|
|
|
@ -63,7 +79,7 @@ export default {
|
|
|
|
|
this.$message.info('这是最后一个标签了, 无法被关闭')
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
closeLeft (e) {
|
|
|
|
|
closeLeft(e) {
|
|
|
|
|
const currentIndex = this.fullPathList.indexOf(e)
|
|
|
|
|
if (currentIndex > 0) {
|
|
|
|
|
this.fullPathList.forEach((item, index) => {
|
|
|
|
@ -75,9 +91,9 @@ export default {
|
|
|
|
|
this.$message.info('左侧没有标签')
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
closeRight (e) {
|
|
|
|
|
closeRight(e) {
|
|
|
|
|
const currentIndex = this.fullPathList.indexOf(e)
|
|
|
|
|
if (currentIndex < (this.fullPathList.length - 1)) {
|
|
|
|
|
if (currentIndex < this.fullPathList.length - 1) {
|
|
|
|
|
this.fullPathList.forEach((item, index) => {
|
|
|
|
|
if (index > currentIndex) {
|
|
|
|
|
this.remove(item)
|
|
|
|
@ -87,7 +103,7 @@ export default {
|
|
|
|
|
this.$message.info('右侧没有标签')
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
closeAll (e) {
|
|
|
|
|
closeAll(e) {
|
|
|
|
|
const currentIndex = this.fullPathList.indexOf(e)
|
|
|
|
|
this.fullPathList.forEach((item, index) => {
|
|
|
|
|
if (index !== currentIndex) {
|
|
|
|
@ -95,12 +111,20 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
closeMenuClick (key, route) {
|
|
|
|
|
closeMenuClick(key, route) {
|
|
|
|
|
this[key](route)
|
|
|
|
|
},
|
|
|
|
|
renderTabPaneMenu (e) {
|
|
|
|
|
renderTabPaneMenu(e) {
|
|
|
|
|
return (
|
|
|
|
|
<a-menu {...{ on: { click: ({ key, item, domEvent }) => { this.closeMenuClick(key, e) } } }}>
|
|
|
|
|
<a-menu
|
|
|
|
|
{...{
|
|
|
|
|
on: {
|
|
|
|
|
click: ({ key, item, domEvent }) => {
|
|
|
|
|
this.closeMenuClick(key, e)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<a-menu-item key="closeThat">关闭当前标签</a-menu-item>
|
|
|
|
|
<a-menu-item key="closeRight">关闭右侧</a-menu-item>
|
|
|
|
|
<a-menu-item key="closeLeft">关闭左侧</a-menu-item>
|
|
|
|
@ -109,38 +133,55 @@ export default {
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
// render
|
|
|
|
|
renderTabPane (title, keyPath) {
|
|
|
|
|
renderTabPane(title, keyPath) {
|
|
|
|
|
console.log(title, keyPath)
|
|
|
|
|
let name = title
|
|
|
|
|
let data = Object.fromEntries(new URLSearchParams(keyPath.split('?')[1]))
|
|
|
|
|
const menu = this.renderTabPaneMenu(keyPath)
|
|
|
|
|
|
|
|
|
|
if (keyPath.split('?')[0] == '/BookingDetail') {
|
|
|
|
|
if (data.id) {
|
|
|
|
|
if (data.isCopy) {
|
|
|
|
|
name = '订舱复制'
|
|
|
|
|
} else {
|
|
|
|
|
name = `${data.mblno}详情`
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
name = '订舱新增'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<a-dropdown overlay={menu} trigger={['contextmenu']}>
|
|
|
|
|
<span style={{ userSelect: 'none' }}>{ title }</span>
|
|
|
|
|
<span style={{ userSelect: 'none' }}>{name}</span>
|
|
|
|
|
</a-dropdown>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
'$route': function (newVal) {
|
|
|
|
|
$route: function(newVal) {
|
|
|
|
|
this.activeKey = newVal.fullPath
|
|
|
|
|
if (this.fullPathList.indexOf(newVal.fullPath) < 0) {
|
|
|
|
|
this.fullPathList.push(newVal.fullPath)
|
|
|
|
|
this.pages.push(newVal)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
activeKey: function (newPathKey) {
|
|
|
|
|
activeKey: function(newPathKey) {
|
|
|
|
|
this.$router.push({ path: newPathKey })
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
render () {
|
|
|
|
|
const { onEdit, $data: { pages } } = this
|
|
|
|
|
render() {
|
|
|
|
|
const {
|
|
|
|
|
onEdit,
|
|
|
|
|
$data: { pages }
|
|
|
|
|
} = this
|
|
|
|
|
const panes = pages.map(page => {
|
|
|
|
|
return (
|
|
|
|
|
<a-tab-pane
|
|
|
|
|
style={{ height: 0 }}
|
|
|
|
|
tab={this.renderTabPane(page.meta.customTitle || page.meta.title, page.fullPath)}
|
|
|
|
|
key={page.fullPath} closable={pages.length > 1}
|
|
|
|
|
>
|
|
|
|
|
</a-tab-pane>)
|
|
|
|
|
key={page.fullPath}
|
|
|
|
|
closable={pages.length > 1}
|
|
|
|
|
></a-tab-pane>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
@ -151,7 +192,8 @@ export default {
|
|
|
|
|
type={'editable-card'}
|
|
|
|
|
v-model={this.activeKey}
|
|
|
|
|
tabBarStyle={{ background: '#FFF', margin: 0, paddingLeft: '16px', paddingTop: '1px' }}
|
|
|
|
|
{...{ on: { edit: onEdit } }}>
|
|
|
|
|
{...{ on: { edit: onEdit } }}
|
|
|
|
|
>
|
|
|
|
|
{panes}
|
|
|
|
|
</a-tabs>
|
|
|
|
|
</div>
|
|
|
|
|