|
|
@ -1,6 +1,6 @@
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
import events from './events'
|
|
|
|
import events from './events'
|
|
|
|
|
|
|
|
import { BookingOrderGet } from '@/api/modular/main/BookingLedger'
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
name: 'MultiTab',
|
|
|
|
name: 'MultiTab',
|
|
|
|
data() {
|
|
|
|
data() {
|
|
|
@ -13,25 +13,27 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
created() {
|
|
|
|
// bind event
|
|
|
|
// bind event
|
|
|
|
events.$on('open', val => {
|
|
|
|
events
|
|
|
|
|
|
|
|
.$on('open', val => {
|
|
|
|
if (!val) {
|
|
|
|
if (!val) {
|
|
|
|
throw new Error(`multi-tab: open tab ${val} err`)
|
|
|
|
throw new Error(`multi-tab: open tab ${val} err`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.activeKey = val
|
|
|
|
this.activeKey = val
|
|
|
|
}).$on('close', val => {
|
|
|
|
})
|
|
|
|
|
|
|
|
.$on('close', val => {
|
|
|
|
if (!val) {
|
|
|
|
if (!val) {
|
|
|
|
this.closeThat(this.activeKey)
|
|
|
|
this.closeThat(this.activeKey)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.closeThat(val)
|
|
|
|
this.closeThat(val)
|
|
|
|
}).$on('rename', ({ key, name }) => {
|
|
|
|
})
|
|
|
|
|
|
|
|
.$on('rename', ({ key, name }) => {
|
|
|
|
console.log('rename', key, name)
|
|
|
|
console.log('rename', key, name)
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const item = this.pages.find(item => item.path === key)
|
|
|
|
const item = this.pages.find(item => item.path === key)
|
|
|
|
item.meta.customTitle = name
|
|
|
|
item.meta.customTitle = name
|
|
|
|
this.$forceUpdate()
|
|
|
|
this.$forceUpdate()
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
this.pages.push(this.$route)
|
|
|
|
this.pages.push(this.$route)
|
|
|
@ -40,7 +42,21 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
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)
|
|
|
|
this[action](targetKey)
|
|
|
|
|
|
|
|
console.log('关闭?', targetKey, action)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
remove(targetKey) {
|
|
|
|
remove(targetKey) {
|
|
|
|
this.pages = this.pages.filter(page => page.fullPath !== targetKey)
|
|
|
|
this.pages = this.pages.filter(page => page.fullPath !== targetKey)
|
|
|
@ -77,7 +93,7 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
closeRight(e) {
|
|
|
|
closeRight(e) {
|
|
|
|
const currentIndex = this.fullPathList.indexOf(e)
|
|
|
|
const currentIndex = this.fullPathList.indexOf(e)
|
|
|
|
if (currentIndex < (this.fullPathList.length - 1)) {
|
|
|
|
if (currentIndex < this.fullPathList.length - 1) {
|
|
|
|
this.fullPathList.forEach((item, index) => {
|
|
|
|
this.fullPathList.forEach((item, index) => {
|
|
|
|
if (index > currentIndex) {
|
|
|
|
if (index > currentIndex) {
|
|
|
|
this.remove(item)
|
|
|
|
this.remove(item)
|
|
|
@ -100,7 +116,15 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
renderTabPaneMenu(e) {
|
|
|
|
renderTabPaneMenu(e) {
|
|
|
|
return (
|
|
|
|
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="closeThat">关闭当前标签</a-menu-item>
|
|
|
|
<a-menu-item key="closeRight">关闭右侧</a-menu-item>
|
|
|
|
<a-menu-item key="closeRight">关闭右侧</a-menu-item>
|
|
|
|
<a-menu-item key="closeLeft">关闭左侧</a-menu-item>
|
|
|
|
<a-menu-item key="closeLeft">关闭左侧</a-menu-item>
|
|
|
@ -110,17 +134,30 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// render
|
|
|
|
// 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)
|
|
|
|
const menu = this.renderTabPaneMenu(keyPath)
|
|
|
|
|
|
|
|
if (keyPath.split('?')[0] == '/BookingDetail') {
|
|
|
|
|
|
|
|
if (data.id) {
|
|
|
|
|
|
|
|
if (data.isCopy) {
|
|
|
|
|
|
|
|
name = '订舱复制'
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
name = `${data.mblno}详情`
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
name = '订舱新增'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<a-dropdown overlay={menu} trigger={['contextmenu']}>
|
|
|
|
<a-dropdown overlay={menu} trigger={['contextmenu']}>
|
|
|
|
<span style={{ userSelect: 'none' }}>{ title }</span>
|
|
|
|
<span style={{ userSelect: 'none' }}>{name}</span>
|
|
|
|
</a-dropdown>
|
|
|
|
</a-dropdown>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
watch: {
|
|
|
|
'$route': function (newVal) {
|
|
|
|
$route: function(newVal) {
|
|
|
|
this.activeKey = newVal.fullPath
|
|
|
|
this.activeKey = newVal.fullPath
|
|
|
|
if (this.fullPathList.indexOf(newVal.fullPath) < 0) {
|
|
|
|
if (this.fullPathList.indexOf(newVal.fullPath) < 0) {
|
|
|
|
this.fullPathList.push(newVal.fullPath)
|
|
|
|
this.fullPathList.push(newVal.fullPath)
|
|
|
@ -132,15 +169,19 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
render() {
|
|
|
|
render() {
|
|
|
|
const { onEdit, $data: { pages } } = this
|
|
|
|
const {
|
|
|
|
|
|
|
|
onEdit,
|
|
|
|
|
|
|
|
$data: { pages }
|
|
|
|
|
|
|
|
} = this
|
|
|
|
const panes = pages.map(page => {
|
|
|
|
const panes = pages.map(page => {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<a-tab-pane
|
|
|
|
<a-tab-pane
|
|
|
|
style={{ height: 0 }}
|
|
|
|
style={{ height: 0 }}
|
|
|
|
tab={this.renderTabPane(page.meta.customTitle || page.meta.title, page.fullPath)}
|
|
|
|
tab={this.renderTabPane(page.meta.customTitle || page.meta.title, page.fullPath)}
|
|
|
|
key={page.fullPath} closable={pages.length > 1}
|
|
|
|
key={page.fullPath}
|
|
|
|
>
|
|
|
|
closable={pages.length > 1}
|
|
|
|
</a-tab-pane>)
|
|
|
|
></a-tab-pane>
|
|
|
|
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
@ -151,7 +192,8 @@ export default {
|
|
|
|
type={'editable-card'}
|
|
|
|
type={'editable-card'}
|
|
|
|
v-model={this.activeKey}
|
|
|
|
v-model={this.activeKey}
|
|
|
|
tabBarStyle={{ background: '#FFF', margin: 0, paddingLeft: '16px', paddingTop: '1px' }}
|
|
|
|
tabBarStyle={{ background: '#FFF', margin: 0, paddingLeft: '16px', paddingTop: '1px' }}
|
|
|
|
{...{ on: { edit: onEdit } }}>
|
|
|
|
{...{ on: { edit: onEdit } }}
|
|
|
|
|
|
|
|
>
|
|
|
|
{panes}
|
|
|
|
{panes}
|
|
|
|
</a-tabs>
|
|
|
|
</a-tabs>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|