This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/common/mixin/editRigthBox.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-07-05 14:43:47 +08:00
export default {
data () {
return {
isEdit: false,
messageParams: {
route: '',
params: {}
}
2021-07-05 14:43:47 +08:00
}
},
mounted () {
if (this.isEdit) {
2021-07-05 14:43:47 +08:00
window.onbeforeunload = () => {
return '确认离开当前页面吗?未保存的数据将会丢失'
2021-07-05 14:43:47 +08:00
}
}
},
methods: {
messageShow (msg, route, params, showNext = false) {
this.messageParams.route = route
this.messageParams.params = params
this.$message({
duration: 2000,
dangerouslyUseHTMLString: true,
type: 'success',
message: `<div>${msg} <span id="assetAdd" class="message-next ${showNext ? '' : 'hidden'}">Next</span></div>`,
onClose: () => {
const assetAdd = document.getElementById('assetAdd')
assetAdd.removeEventListener('click', this.saveNext)
}
})
const assetAdd = document.getElementById('assetAdd')
assetAdd.addEventListener('click', this.saveNext)
},
saveNext () {
console.log(this.assetId)
this.$router.push({
path: this.messageParams.route,
query: this.messageParams.params
})
}
},
2021-07-05 14:43:47 +08:00
destroyed () {
window.onbeforeunload = null
}
}