NEZ-835 fix: 新增页面添加标签页关闭提示功能

This commit is contained in:
@changcode
2021-07-15 11:56:25 +08:00
parent da04ea8875
commit 4191c8113f
30 changed files with 40 additions and 91 deletions

View File

@@ -5,9 +5,9 @@ export default {
} }
}, },
mounted () { mounted () {
if( this.isEdit ) { if (this.isEdit) {
window.onbeforeunload = () => { window.onbeforeunload = () => {
return "确认离开当前页面吗?未保存的数据将会丢失" return '确认离开当前页面吗?未保存的数据将会丢失'
} }
} }
}, },

View File

@@ -205,11 +205,13 @@
<script> <script>
import editEndpointBoxNew from './editEndpointBoxNew' import editEndpointBoxNew from './editEndpointBoxNew'
import editRigthBox from '../mixin/editRigthBox'
export default { export default {
name: 'addEndpointBox', name: 'addEndpointBox',
components: { components: {
'edit-endpoint-box-new': editEndpointBoxNew 'edit-endpoint-box-new': editEndpointBoxNew
}, },
mixins: [editRigthBox],
data () { data () {
return { return {
rules: { rules: {
@@ -434,7 +436,7 @@ export default {
disabled: false disabled: false
}] }]
}, },
showError: false, showError: false
} }
}, },
methods: { methods: {
@@ -755,6 +757,7 @@ export default {
currentModule: { currentModule: {
immediate: true, immediate: true,
handler (n, o) { handler (n, o) {
this.isEdit = true
} }
} }
} }

View File

@@ -137,12 +137,12 @@ export default {
rightBox: { model: { show: false } }, rightBox: { model: { show: false } },
roles: [], roles: [],
rules: { rules: {
name: [ name: [
{ required: true, message: '必填', trigger: 'blur' } { required: true, message: '必填', trigger: 'blur' }
], ],
brandId: [ brandId: [
{ required: true, message: this.$t('validate.required'), trigger: 'change' } { required: true, message: this.$t('validate.required'), trigger: 'change' }
] ]
} }
} }
}, },
@@ -151,9 +151,7 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler (n) { handler (n) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editAssetType = JSON.parse(JSON.stringify(n)) this.editAssetType = JSON.parse(JSON.stringify(n))
} }
} }

View File

@@ -112,9 +112,7 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler (n) { handler (n) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editModel = JSON.parse(JSON.stringify(n)) this.editModel = JSON.parse(JSON.stringify(n))
} }
} }

View File

@@ -81,9 +81,7 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler (n) { handler (n) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editRole = JSON.parse(JSON.stringify(n)) this.editRole = JSON.parse(JSON.stringify(n))
if (this.editRole.roles && this.editRole.roles.length > 0) { if (this.editRole.roles && this.editRole.roles.length > 0) {
this.editRole.roleIds = this.editRole.roles.map(t => t.id) this.editRole.roleIds = this.editRole.roles.map(t => t.id)

View File

@@ -159,9 +159,7 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler (n) { handler (n) {
if (n.id) { this.isEdit = true
this.isEdit =true
}
this.editUser = JSON.parse(JSON.stringify(n)) this.editUser = JSON.parse(JSON.stringify(n))
// if (this.editUser.roles && this.editUser.roles.length > 0) { // if (this.editUser.roles && this.editUser.roles.length > 0) {
// this.editUser.roleIds = this.editUser.roles.map(t => t.id) // this.editUser.roleIds = this.editUser.roles.map(t => t.id)

View File

@@ -190,9 +190,7 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n) { handler (n) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editPromServer = JSON.parse(JSON.stringify(n)) this.editPromServer = JSON.parse(JSON.stringify(n))
} }
}, },

View File

@@ -320,9 +320,7 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler (n, o) { handler (n, o) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editAlertRule = JSON.parse(JSON.stringify(n)) this.editAlertRule = JSON.parse(JSON.stringify(n))
if (this.editAlertRule.id) { if (this.editAlertRule.id) {
this.expressions = [this.editAlertRule.expr] this.expressions = [this.editAlertRule.expr]

View File

@@ -140,9 +140,7 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler (n, o) { handler (n, o) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
const obj = JSON.parse(JSON.stringify(n)) const obj = JSON.parse(JSON.stringify(n))
if (obj.ruleId == -1) { if (obj.ruleId == -1) {
obj.ruleId = null obj.ruleId = null

View File

@@ -469,9 +469,7 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n) { handler (n) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
if (n !== assetConstants.editTypeData.account) { if (n !== assetConstants.editTypeData.account) {
this.editData.authProtocol = 0 this.editData.authProtocol = 0
} else { } else {

View File

@@ -351,9 +351,7 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler (n) { handler (n) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editAsset = JSON.parse(JSON.stringify(n)) this.editAsset = JSON.parse(JSON.stringify(n))
this.editAsset.brandAndModel = [this.editAsset.brand.id, this.editAsset.model.id] this.editAsset.brandAndModel = [this.editAsset.brand.id, this.editAsset.model.id]
this.editAsset.stateId = n.state ? n.state.id : '' this.editAsset.stateId = n.state ? n.state.id : ''

View File

@@ -235,9 +235,7 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler (n) { handler (n) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editAssetMeta = { this.editAssetMeta = {
...n, ...n,
groupId: n.groupId ? Number(n.groupId) : '', groupId: n.groupId ? Number(n.groupId) : '',

View File

@@ -65,9 +65,7 @@ export default {
metaGroup: { metaGroup: {
immediate: true, immediate: true,
handler (n) { handler (n) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editMetaGroup = { ...n } this.editMetaGroup = { ...n }
} }
} }

View File

@@ -140,9 +140,7 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n) { handler (n) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
if (n) { if (n) {
this.editAssetState = JSON.parse(JSON.stringify(n)) this.editAssetState = JSON.parse(JSON.stringify(n))
} }

View File

@@ -158,9 +158,7 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler: function (n, o) { handler: function (n, o) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
if (n) { if (n) {
this.editCabinet = JSON.parse(JSON.stringify(n)) this.editCabinet = JSON.parse(JSON.stringify(n))
} }

View File

@@ -179,9 +179,7 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler (n) { handler (n) {
if (n.id) { this.isEdit = true
this.isEdit = false
}
this.editChartTemp = JSON.parse(JSON.stringify(n)) this.editChartTemp = JSON.parse(JSON.stringify(n))
} }
} }

View File

@@ -204,9 +204,7 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n, o) { handler (n, o) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editDc = JSON.parse(JSON.stringify(n)) this.editDc = JSON.parse(JSON.stringify(n))
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.latlngPicker.setLnglat(this.editDc.latitude, this.editDc.longitude) this.$refs.latlngPicker.setLnglat(this.editDc.latitude, this.editDc.longitude)

View File

@@ -684,9 +684,7 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n, o) { handler (n, o) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editEndpoint = JSON.parse(JSON.stringify(n)) this.editEndpoint = JSON.parse(JSON.stringify(n))
this.activeName = 'Basic' this.activeName = 'Basic'
this.changeProject() this.changeProject()

View File

@@ -88,9 +88,7 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler (n, o) { handler (n, o) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
const obj = { ...n } const obj = { ...n }
obj.expression = [obj.expression] obj.expression = [obj.expression]
this.editExprTemp = Object.assign(this.editExprTemp, obj) this.editExprTemp = Object.assign(this.editExprTemp, obj)

View File

@@ -389,9 +389,7 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n, o) { handler (n, o) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.$emit('change', n) this.$emit('change', n)
} }
}, },

View File

@@ -240,9 +240,7 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n) { handler (n) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editMenu = JSON.parse(JSON.stringify(n)) this.editMenu = JSON.parse(JSON.stringify(n))
if (this.editMenu.perms && this.editMenu.perms != '') { if (this.editMenu.perms && this.editMenu.perms != '') {
this.$set(this.editMenu, 'permissions', this.editMenu.perms.split(',').map(t => { return { value: t } })) this.$set(this.editMenu, 'permissions', this.editMenu.perms.split(',').map(t => { return { value: t } }))

View File

@@ -231,9 +231,7 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n, o) { handler (n, o) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editMib = JSON.parse(JSON.stringify(n)) this.editMib = JSON.parse(JSON.stringify(n))
if (this.editMib.models) { if (this.editMib.models) {
this.selectedModels = this.editMib.models.split(',') this.selectedModels = this.editMib.models.split(',')

View File

@@ -679,9 +679,7 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n, o) { handler (n, o) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editModule = JSON.parse(JSON.stringify(n)) this.editModule = JSON.parse(JSON.stringify(n))
this.activeName = 'Basic' this.activeName = 'Basic'

View File

@@ -124,9 +124,7 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n, o) { handler (n, o) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editPanel = JSON.parse(JSON.stringify(n)) this.editPanel = JSON.parse(JSON.stringify(n))
} }
} }

View File

@@ -121,9 +121,7 @@ export default {
project: { project: {
immediate: true, immediate: true,
handler (n, o) { handler (n, o) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editProject = JSON.parse(JSON.stringify(n)) this.editProject = JSON.parse(JSON.stringify(n))
} }
} }

View File

@@ -126,9 +126,7 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler: function (n, o) { handler: function (n, o) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
if (n) { if (n) {
this.editCabinet = JSON.parse(JSON.stringify(n)) this.editCabinet = JSON.parse(JSON.stringify(n))
} }

View File

@@ -220,9 +220,7 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n, o) { handler (n, o) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.editCredential = JSON.parse(JSON.stringify(n)) this.editCredential = JSON.parse(JSON.stringify(n))
if (this.editCredential.config && typeof this.editCredential.config === 'string') { if (this.editCredential.config && typeof this.editCredential.config === 'string') {
this.editCredential.config = JSON.parse(this.editCredential.config) this.editCredential.config = JSON.parse(this.editCredential.config)

View File

@@ -21,10 +21,8 @@
</template> </template>
<script> <script>
import editRigthBox from '../../mixin/editRigthBox'
export default { export default {
name: 'subBox', name: 'subBox',
mixins: [editRigthBox],
data () { data () {
return { return {
editTagsBox: { show: false, top: 0, left: 0 }, editTagsBox: { show: false, top: 0, left: 0 },

View File

@@ -319,9 +319,7 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n) { handler (n) {
if (n.id) { this.isEdit = true
this.isEdit = true
}
this.queryAssetList() this.queryAssetList()
} }
} }

View File

@@ -1762,10 +1762,10 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler (n) { handler (n) {
this.isEdit = true
if (n.id) { if (n.id) {
this.isEdit = true;
if (!n.param.state && n.param.state != Number) { if (!n.param.state && n.param.state != Number) {
n.param.state = "1" n.param.state = '1'
} }
if (n.param.severity && n.param.severity != Number) { if (n.param.severity && n.param.severity != Number) {
n.param.severity = 1 n.param.severity = 1