Merge branch 'dev-2.0' of https://git.mesalab.cn/nezha/nezha-fronted into dev-2.0

# Conflicts:
#	nezha-fronted/src/components/page/dashboard/chartBox.vue
This commit is contained in:
zhangyu
2021-07-05 15:13:51 +08:00
30 changed files with 160 additions and 8 deletions

View File

@@ -210,9 +210,6 @@ export default {
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)
this.$set(this.searchLabel, 'pageSize', this.pageObj.pageSize)
this.tools.loading = true
if (this.obj) {
this.$set(this.searchLabel, 'modelIds', this.obj.id)
}
this.$get(this.url, { ...this.searchLabel, ...this.searchCheckBox }).then(response => {
this.tools.loading = false
if (response.code === 200) {

View File

@@ -0,0 +1,17 @@
export default {
data () {
return {
isEdit: false
}
},
mounted () {
if( this.isEdit ) {
window.onbeforeunload = () => {
return window.confirm("确认操作吗?")
}
}
},
destroyed () {
window.onbeforeunload = null
}
}

View File

@@ -100,6 +100,8 @@
<script>
import { asset as assetConstants} from '@/components/common/js/constants'
import selectWalk from '../../popBox/selectWalk'
import editRigthBox from '../../mixin/editRigthBox'
export default {
name: 'assetTypeBox',
components: {
@@ -117,6 +119,7 @@ export default {
}
}
},
mixins: [editRigthBox],
data () {
return {
assetConstants,
@@ -148,6 +151,9 @@ export default {
deep: true,
immediate: true,
handler (n) {
if (n.id) {
this.isEdit = true
}
this.editAssetType = JSON.parse(JSON.stringify(n))
}
}

View File

@@ -60,6 +60,8 @@
<script>
// import { host, port } from '@/components/common/js/validate'
import selectWalk from '../../popBox/selectWalk'
import editRigthBox from '../../mixin/editRigthBox'
export default {
name: 'modelBox',
components: {
@@ -77,6 +79,7 @@ export default {
}
}
},
mixins: [editRigthBox],
data () {
return {
language: localStorage.getItem('nz-language'),
@@ -109,6 +112,9 @@ export default {
deep: true,
immediate: true,
handler (n) {
if (n.id) {
this.isEdit = true
}
this.editModel = JSON.parse(JSON.stringify(n))
}
}

View File

@@ -48,6 +48,7 @@
</template>
<script>
import editRigthBox from '../../mixin/editRigthBox'
export default {
name: 'roleBox',
components: {
@@ -58,6 +59,7 @@ export default {
},
detail: Boolean
},
mixins: [editRigthBox],
data () {
return {
editRole: {},
@@ -79,6 +81,9 @@ export default {
deep: true,
immediate: true,
handler (n) {
if (n.id) {
this.isEdit = true
}
this.editRole = JSON.parse(JSON.stringify(n))
if (this.editRole.roles && this.editRole.roles.length > 0) {
this.editRole.roleIds = this.editRole.roles.map(t => t.id)

View File

@@ -82,6 +82,7 @@
<script>
// import { host, port } from '@/components/common/js/validate'
import editRigthBox from '../../mixin/editRigthBox'
export default {
name: 'userBox',
@@ -92,6 +93,7 @@ export default {
type: Object
}
},
mixins: [editRigthBox],
computed: {
isCurrentUser () {
return function (username) {
@@ -157,6 +159,9 @@ export default {
deep: true,
immediate: true,
handler (n) {
if (n.id) {
this.isEdit =true
}
this.editUser = JSON.parse(JSON.stringify(n))
// if (this.editUser.roles && this.editUser.roles.length > 0) {
// this.editUser.roleIds = this.editUser.roles.map(t => t.id)

View File

@@ -74,11 +74,13 @@
<script>
import { host, port } from '../../common/js/validate'
import { agent2 } from '@/components/common/js/constants'
import editRigthBox from '../mixin/editRigthBox'
export default {
name: 'agentBox',
props: {
agent: Object
},
mixins: [editRigthBox],
data () {
return {
agent2: agent2,
@@ -188,6 +190,9 @@ export default {
immediate: true,
deep: true,
handler (n) {
if (n.id) {
this.isEdit = true
}
this.editPromServer = JSON.parse(JSON.stringify(n))
}
},

View File

@@ -124,6 +124,7 @@
import chartDataFormat from '../../charts/chartDataFormat'
import promqlInput from '../../page/dashboard/explore/promqlInput'
import { nzNumber } from '../js/validate'
import editRigthBox from '../mixin/editRigthBox'
export default {
name: 'alertRuleBox',
props: {
@@ -132,6 +133,7 @@ export default {
components: {
'promql-input': promqlInput
},
mixins: [editRigthBox],
data () {
return {
promqlCount: 1,
@@ -318,6 +320,9 @@ export default {
deep: true,
immediate: true,
handler (n, o) {
if (n.id) {
this.isEdit = true
}
this.editAlertRule = JSON.parse(JSON.stringify(n))
if (this.editAlertRule.id) {
this.expressions = [this.editAlertRule.expr]

View File

@@ -125,12 +125,13 @@
import bus from '@/libs/bus'
import { sameLabels } from '@/components/common/js/constants'
// import selectAlertSilence from '../alert/selectAlertSilence'
import editRigthBox from '../mixin/editRigthBox'
export default {
name: 'alertSilenceBox',
components: {
// selectAlertSilence
},
mixins: [editRigthBox],
props: {
alertSilence: Object
},
@@ -139,6 +140,9 @@ export default {
deep: true,
immediate: true,
handler (n, o) {
if (n.id) {
this.isEdit = true
}
const obj = JSON.parse(JSON.stringify(n))
if (obj.ruleId == -1) {
obj.ruleId = null

View File

@@ -221,6 +221,7 @@
<script>
import nzTransfer from '@/components/common/nzTransfer'
import { asset as assetConstants } from '@/components/common/js/constants'
import editRigthBox from '../../mixin/editRigthBox'
export default {
name: 'assetBatchEditBox',
components: {
@@ -237,6 +238,7 @@ export default {
type: Array
}
},
mixins: [editRigthBox],
data () {
const vm = this
return {
@@ -467,6 +469,9 @@ export default {
immediate: true,
deep: true,
handler (n) {
if (n.id) {
this.isEdit = true
}
if (n !== assetConstants.editTypeData.account) {
this.editData.authProtocol = 0
} else {

View File

@@ -242,6 +242,8 @@ import { host, port } from '@/components/common/js/validate'
import { asset as assetConstants } from '@/components/common/js/constants'
import selectAssetType from '@/components/common/popBox/selectAssetType'
import locationCascader from '@/components/common/rightBox/locationCascader'
import editRigthBox from '../../mixin/editRigthBox'
export default {
name: 'assetBox',
components: {
@@ -253,6 +255,7 @@ export default {
type: Object
}
},
mixins: [editRigthBox],
data () {
const vm = this
return {
@@ -347,6 +350,9 @@ export default {
deep: true,
immediate: true,
handler (n) {
if (n.id) {
this.isEdit = true
}
this.editAsset = JSON.parse(JSON.stringify(n))
this.editAsset.brandAndModel = [this.editAsset.brand.id, this.editAsset.model.id]
this.editAsset.stateId = n.state ? n.state.id : ''

View File

@@ -142,12 +142,14 @@
<script>
import assetTagEx from '../../page/asset/components/assetTagEx'
import editRigthBox from '../mixin/editRigthBox'
export default {
name: 'assetLabelBox',
props: {
obj: { type: Object }
},
components: { assetTagEx },
mixins: [editRigthBox],
data () {
return {
ready: false,
@@ -233,6 +235,9 @@ export default {
deep: true,
immediate: true,
handler (n) {
if (n.id) {
this.isEdit = true
}
this.editAssetMeta = {
...n,
groupId: n.groupId ? Number(n.groupId) : '',

View File

@@ -41,12 +41,14 @@
</template>
<script>
import editRigthBox from '../mixin/editRigthBox'
export default {
name: 'assetMetaGroup',
props: {
metaGroup: {}
},
components: {},
mixins: [editRigthBox],
data () {
return {
editMetaGroup: {
@@ -63,6 +65,9 @@ export default {
metaGroup: {
immediate: true,
handler (n) {
if (n.id) {
this.isEdit = true
}
this.editMetaGroup = { ...n }
}
}

View File

@@ -62,12 +62,14 @@
</div>
</template>
<script>
import editRigthBox from '../mixin/editRigthBox'
export default {
name: 'asset-state-right-box',
props: {
assetState: Object,
assetStateData: Array // 所有数据,用于选择下拉框显示内容
},
mixins: [editRigthBox],
data () {
return {
rules: { // 表单校验规则
@@ -138,6 +140,9 @@ export default {
immediate: true,
deep: true,
handler (n) {
if (n.id) {
this.isEdit = true
}
if (n) {
this.editAssetState = JSON.parse(JSON.stringify(n))
}

View File

@@ -52,6 +52,7 @@
</template>
<script>
import editRigthBox from '../mixin/editRigthBox'
export default {
name: 'cabinetBox',
props: {
@@ -62,6 +63,7 @@ export default {
default: true
}
},
mixins: [editRigthBox],
data () {
return {
editCabinet: {},
@@ -156,6 +158,9 @@ export default {
deep: true,
immediate: true,
handler: function (n, o) {
if (n.id) {
this.isEdit = true
}
if (n) {
this.editCabinet = JSON.parse(JSON.stringify(n))
}

View File

@@ -74,6 +74,8 @@
<script>
import nzTransfer from '@/components/common/nzTransfer'
import { fromRoute } from '@/components/common/js/constants'
import editRigthBox from '../mixin/editRigthBox'
export default {
name: 'chartTempBox',
components: {
@@ -85,6 +87,7 @@ export default {
},
from: String
},
mixins: [editRigthBox],
data () {
return {
fromRoute,
@@ -176,6 +179,9 @@ export default {
deep: true,
immediate: true,
handler (n) {
if (n.id) {
this.isEdit = false
}
this.editChartTemp = JSON.parse(JSON.stringify(n))
}
}

View File

@@ -64,6 +64,8 @@
<script>
import latlngPicker from '../latlngPicker'
import editRigthBox from '../mixin/editRigthBox'
const regNum = /^[0-9]+.?[0-9]*/
export default {
@@ -75,6 +77,7 @@ export default {
},
userData: Array
},
mixins: [editRigthBox],
data () {
return {
editDc: {},
@@ -201,6 +204,9 @@ export default {
immediate: true,
deep: true,
handler (n, o) {
if (n.id) {
this.isEdit = true
}
this.editDc = JSON.parse(JSON.stringify(n))
this.$nextTick(() => {
this.$refs.latlngPicker.setLnglat(this.editDc.latitude, this.editDc.longitude)

View File

@@ -264,6 +264,7 @@
<script>
import { noSpecialChar, port, nzNumber } from '../js/validate'
import selectWalk from '../popBox/selectWalk'
import editRigthBox from '../mixin/editRigthBox'
import VueTagsInput from '@johmun/vue-tags-input'
export default {
@@ -288,6 +289,7 @@ export default {
'select-walk': selectWalk,
VueTagsInput
},
mixins: [editRigthBox],
data () {
return {
walkData: [],
@@ -678,6 +680,9 @@ export default {
immediate: true,
deep: true,
handler (n, o) {
if (n.id) {
this.isEdit = true
}
this.editEndpoint = JSON.parse(JSON.stringify(n))
this.activeName = 'Basic'
this.changeProject()

View File

@@ -72,6 +72,8 @@
<script>
import promqlInput from '../../page/dashboard/explore/promqlInput'
import editRigthBox from '../mixin/editRigthBox'
export default {
name: 'exprTempBox',
components: {
@@ -80,11 +82,15 @@ export default {
props: {
exprTemp: Object
},
mixins: [editRigthBox],
watch: {
exprTemp: {
deep: true,
immediate: true,
handler (n, o) {
if (n.id) {
this.isEdit = true
}
const obj = { ...n }
obj.expression = [obj.expression]
this.editExprTemp = Object.assign(this.editExprTemp, obj)

View File

@@ -47,6 +47,7 @@
</template>
<script>
import editRigthBox from '../mixin/editRigthBox'
export default {
name: 'locationCascader',
components: {
@@ -62,6 +63,7 @@ export default {
disabled: { type: Boolean },
dcOption: { type: Array }
},
mixins: [editRigthBox],
data () {
return {
initData: null,
@@ -387,6 +389,9 @@ export default {
immediate: true,
deep: true,
handler (n, o) {
if (n.id) {
this.isEdit = true
}
this.$emit('change', n)
}
},

View File

@@ -83,6 +83,8 @@
<script>
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import editRigthBox from '../mixin/editRigthBox'
export default {
name: 'menuBox',
components: {
@@ -106,6 +108,7 @@ export default {
return enabled.length === 0
}
},
mixins: [editRigthBox],
data () {
return {
rules: { // 表单校验规则
@@ -237,6 +240,9 @@ export default {
immediate: true,
deep: true,
handler (n) {
if (n.id) {
this.isEdit = true
}
this.editMenu = JSON.parse(JSON.stringify(n))
if (this.editMenu.perms && this.editMenu.perms != '') {
this.$set(this.editMenu, 'permissions', this.editMenu.perms.split(',').map(t => { return { value: t } }))

View File

@@ -55,11 +55,14 @@
</template>
<script>
import editRigthBox from '../mixin/editRigthBox'
export default {
name: 'modelBox',
props: {
mib: Object
},
mixins: [editRigthBox],
data () {
const $temp = this
return {
@@ -228,6 +231,9 @@ export default {
immediate: true,
deep: true,
handler (n, o) {
if (n.id) {
this.isEdit = true
}
this.editMib = JSON.parse(JSON.stringify(n))
if (this.editMib.models) {
this.selectedModels = this.editMib.models.split(',')

View File

@@ -259,6 +259,7 @@
<script>
import { noSpecialChar, port, nzNumber } from '../js/validate'
import selectWalk from '../popBox/selectWalk'
import editRigthBox from '../mixin/editRigthBox'
import VueTagsInput from '@johmun/vue-tags-input'
export default {
@@ -271,6 +272,7 @@ export default {
'select-walk': selectWalk,
VueTagsInput
},
mixins: [editRigthBox],
data () {
return {
walkData: [],
@@ -674,6 +676,9 @@ export default {
immediate: true,
deep: true,
handler (n, o) {
if (n.id) {
this.isEdit = true
}
this.editModule = JSON.parse(JSON.stringify(n))
this.activeName = 'Basic'

View File

@@ -31,6 +31,7 @@
</template>
<script>
import editRigthBox from '../mixin/editRigthBox'
export default {
name: 'panelBox',
props: {
@@ -38,6 +39,7 @@ export default {
type: Object
}
},
mixins: [editRigthBox],
data () {
return {
url: 'visual/panel',
@@ -122,6 +124,9 @@ export default {
immediate: true,
deep: true,
handler (n, o) {
if (n.id) {
this.isEdit = true
}
this.editPanel = JSON.parse(JSON.stringify(n))
}
}

View File

@@ -34,12 +34,14 @@
</div>
</template>
<script>
import editRigthBox from '../mixin/editRigthBox'
import { noSpecialChar } from '../../common/js/validate'
export default {
name: 'projectBox',
props: {
project: Object
},
mixins: [editRigthBox],
data () {
return {
editProject: {},
@@ -119,6 +121,9 @@ export default {
project: {
immediate: true,
handler (n, o) {
if (n.id) {
this.isEdit = true
}
this.editProject = JSON.parse(JSON.stringify(n))
}
}

View File

@@ -36,12 +36,14 @@
</template>
<script>
import editRigthBox from '../../mixin/editRigthBox'
export default {
name: 'cabinetBox',
props: {
obj: { type: Object },
currentDc: { type: Object }
},
mixins: [editRigthBox],
data () {
return {
editCabinet: {},
@@ -124,6 +126,9 @@ export default {
deep: true,
immediate: true,
handler: function (n, o) {
if (n.id) {
this.isEdit = true
}
if (n) {
this.editCabinet = JSON.parse(JSON.stringify(n))
}

View File

@@ -84,7 +84,7 @@
</template>
<script>
import editRigthBox from '../mixin/editRigthBox'
import { port } from '../js/validate'
export default {
@@ -93,6 +93,7 @@ export default {
props: {
credential: Object
},
mixins: [editRigthBox],
data () {
return {
editCredential: {},
@@ -219,6 +220,9 @@ export default {
immediate: true,
deep: true,
handler (n, o) {
if (n.id) {
this.isEdit = true
}
this.editCredential = JSON.parse(JSON.stringify(n))
if (this.editCredential.config && typeof this.editCredential.config === 'string') {
this.editCredential.config = JSON.parse(this.editCredential.config)

View File

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

View File

@@ -28,6 +28,7 @@
<script>
import trafficSettingTab from './trafficSettingTab'
import editRigthBox from '../../mixin/editRigthBox'
import { getUUID } from '../../js/common'
export default {
@@ -41,6 +42,7 @@ export default {
required: true
}
},
mixins: [editRigthBox],
mounted () {
this.queryTrafficSettings()
},
@@ -316,7 +318,10 @@ export default {
dc: {
immediate: true,
deep: true,
handler () {
handler (n) {
if (n.id) {
this.isEdit = true
}
this.queryAssetList()
}
}

View File

@@ -499,7 +499,7 @@ import nezhaColor from '../../common/nezhaColor'
import i18n from '../../common/i18n'
import { fromRoute } from '@/components/common/js/constants'
import diagram from '@/components/common/ChartDiagram/diagram'
import rightBoxMain from '@/components/common/mixin/rightBox'
import editRigthBox from '../../common/mixin/editRigthBox'
const rz = {
methods: {
rz (e) {
@@ -520,7 +520,7 @@ export default {
default: false
}
},
mixins: [rz, rightBoxMain],
mixins: [rz,editRigthBox],
data () {
return {
fromRoute,