fix: import路径修改
This commit is contained in:
@@ -177,10 +177,7 @@
|
||||
</transition>
|
||||
<!--web-->
|
||||
<el-dropdown>
|
||||
<el-dropdown-menu></el-dropdown-menu>
|
||||
<div id="header-open-cli" @click="cli">
|
||||
<!-- <div class="header-menu__item"><i class="nz-icon nz-icon-terminal"></i></div>-->
|
||||
<!-- <span v-show="$store.state.consoleCount>0" class="right-tip">{{$store.state.consoleCount<=10?$store.state.consoleCount:'10+'}}</span>-->
|
||||
</div>
|
||||
</el-dropdown>
|
||||
<!--import-->
|
||||
@@ -191,9 +188,6 @@
|
||||
<div slot="tip" class="el-upload__tip" >{{$t('overall.importTip')}}</div>
|
||||
<i class="nz-icon nz-icon-upload"></i>
|
||||
<div class="el-upload__text">{{$t('overall.dragFileTip')}},{{$t('overall.or')}} <em>{{$t('overall.clickUpload')}}</em></div>
|
||||
<!--<button type="button" class="nz-btn nz-btn-size-normal nz-btn-style-normal">
|
||||
<span class="top-tool-btn-txt" >{{$t('overall.upload')}}</span>
|
||||
</button>-->
|
||||
</el-upload>
|
||||
</div>
|
||||
<div slot="footer" class="footer">
|
||||
@@ -210,60 +204,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="importBox.type == 2">
|
||||
<div class="upload-body">
|
||||
<button @click="exportCur" class="el-button el-button--default el-button--small" :id="id+'-xlsx-export-current'">
|
||||
<span>{{$t('overall.exportCur')}}</span>
|
||||
</button>
|
||||
<button @click="exportAll" class="el-button el-button--default el-button--small" :id="id+'-xlsx-export-all'">
|
||||
<span>{{$t('overall.exportAll')}}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div slot="footer" class="footer">
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="importBox.type==3">
|
||||
<div class="upload-body result-body">
|
||||
<div>
|
||||
<span class="result-title">{{$t('overall.result.total')}}:</span>
|
||||
<span>{{importResult&&importResult.totalNum?importResult.totalNum:0}}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="result-title">{{$t('overall.result.failed')}}:</span>
|
||||
<span>{{importResult&&importResult.failNum?importResult.failNum:0}}</span>
|
||||
<span class="result-title">{{$t('overall.result.success')}}:</span>
|
||||
<span>{{importResult&&importResult.successNum?importResult.successNum:0}}</span>
|
||||
</div>
|
||||
<div>
|
||||
<div class="result-title">{{$t('overall.result.failedDetail')}}:</div>
|
||||
<div class="result-detail" v-if="importResult&&importResult.failDetail">
|
||||
<div style="height: 100%; overflow: auto;">
|
||||
<!-- <ul>
|
||||
<li v-for="(item,index) in importResult.failDetail"><span>{{item.lineNo}}</span>:<span>{{item.errorMsg}}</span> </li>
|
||||
</ul>-->
|
||||
<template v-for="(item, index) in importResult.failDetail">
|
||||
<div :key="index" class="import-result-block">
|
||||
<div class="import-result-item">
|
||||
<div class="line-num">{{$t('overall.result.line',[item.lineNo])}}</div>
|
||||
<div>{{item.errorMsg}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div slot="footer" class="footer">
|
||||
<div class="el-message-box__btns">
|
||||
<button @click="rollbackImport" class="nz-btn nz-btn-size-normal-new nz-btn-style-error-new" :id="id+'-xlsx-import-rollback'">
|
||||
<span>{{$t('overall.rollbackImport')}}</span>
|
||||
</button>
|
||||
<!--<button @click="closeDialog" class="el-button el-button--default el-button--small">-->
|
||||
<!--<span>{{$t('overall.cancel')}}</span>-->
|
||||
<!--</button>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -287,10 +227,8 @@ import axios from 'axios'
|
||||
export default {
|
||||
props: {
|
||||
show: Boolean,
|
||||
exportUrl: { type: String, required: true },
|
||||
params: { type: Object },
|
||||
exportFileName: { type: String },
|
||||
importUrl: { type: String, required: true },
|
||||
link: { type: Object },
|
||||
permissions: { type: Object },
|
||||
showCur: { type: Boolean, default: true },
|
||||
@@ -355,7 +293,8 @@ export default {
|
||||
importResult: null,
|
||||
exportShow: false,
|
||||
paramsType: '',
|
||||
// importUrl: '/monitor/module',
|
||||
assetimportUrl: '/asset/import',
|
||||
endpointimportUrl: '/monitor/endpoint/import',
|
||||
rightBox: {
|
||||
dc: {
|
||||
show: false
|
||||
@@ -524,7 +463,6 @@ export default {
|
||||
this.getDcData()
|
||||
this.getSnmpCredentialData()
|
||||
this.getFieldGroupData()
|
||||
console.log(this.$router)
|
||||
},
|
||||
methods: {
|
||||
// Datacenter
|
||||
@@ -552,7 +490,6 @@ export default {
|
||||
},
|
||||
importAsset() {
|
||||
this.showImportBox(1)
|
||||
console.log(this.importUrl)
|
||||
this.$emit("update:show", false);
|
||||
},
|
||||
webTerminal() {
|
||||
@@ -674,6 +611,10 @@ export default {
|
||||
},
|
||||
closeDialog: function () {
|
||||
this.showAgentDownload = false
|
||||
this.importBox.show = false
|
||||
this.importResult = null
|
||||
this.importFileList = []
|
||||
this.importFile = null
|
||||
},
|
||||
getAllDc () {
|
||||
this.$get('dc?pageSize=-1').then(response => {
|
||||
@@ -913,36 +854,69 @@ export default {
|
||||
showImportBox (type) {
|
||||
this.importBox.show = true
|
||||
this.importBox.type = type
|
||||
if (type == 2 && (!this.showCur)) {
|
||||
this.exportCur()
|
||||
return
|
||||
}
|
||||
if (type == 1) { // import
|
||||
this.importBox.title = this.$t('overall.importExcel')
|
||||
this.importBox.width = '600px'
|
||||
}
|
||||
},
|
||||
getTimeString () {
|
||||
const split = '-'
|
||||
const date = new Date()
|
||||
const year = date.getFullYear()
|
||||
const month = this.formatNum(date.getMonth() + 1)
|
||||
const day = this.formatNum(date.getDate())
|
||||
const hours = this.formatNum(date.getHours())
|
||||
const minutes = this.formatNum(date.getMinutes())
|
||||
const seconds = this.formatNum(date.getSeconds())
|
||||
return year + split + month + split + day + ' ' + hours + split + minutes + split + seconds
|
||||
},
|
||||
formatNum (num) {
|
||||
return num > 9 ? num : '0' + num
|
||||
},
|
||||
importChange (file, fileList) {
|
||||
// console.log(file,filelist)
|
||||
if (fileList.length > 0) {
|
||||
this.importFileList = [fileList[fileList.length - 1]]
|
||||
}
|
||||
this.importFile = this.importFileList[0]
|
||||
this.validateFile()
|
||||
},
|
||||
rollbackImport () {
|
||||
let url
|
||||
if (this.assetimportUrl.indexOf('asset') || this.assetimportUrl.indexOf('asset') > -1) {
|
||||
url = '/asset/cancelImport'
|
||||
} else if (this.assetimportUrl.indexOf('asset') || this.assetimportUrl.indexOf('asset') > -1) {
|
||||
url = '/monitor/endpoint/cancelImport'
|
||||
} else if (this.assetimportUrl.indexOf('asset') || this.assetimportUrl.indexOf('asset') > -1) {
|
||||
url = '/alert/rule/cancelImport'
|
||||
} else if (this.assetimportUrl.indexOf('asset') || this.assetimportUrl.indexOf('asset') > -1) {
|
||||
url = '/panel/cancelImport'
|
||||
} else if (this.assetimportUrl.indexOf('asset') || this.assetimportUrl.indexOf('asset') > -1) {
|
||||
url = '/expression/tmpl/cancelImport'
|
||||
}
|
||||
this.$delete(url + '?seq=' + this.importResult.seq).then(response => {
|
||||
if (response.code == 200) {
|
||||
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||
this.$emit('afterImport')
|
||||
} else {
|
||||
this.$message.error(response.msg)
|
||||
}
|
||||
this.closeDialog()
|
||||
})
|
||||
},
|
||||
downloadTemplate () {
|
||||
const language = localStorage.getItem('nz-language') || 'en' // 初始未选择默认 en 英文
|
||||
const fileName = this.exportFileName + '-' + this.$t('overall.template') + '-' + this.getTimeString() + '.xlsx'
|
||||
|
||||
let url = null
|
||||
if (this.importUrl.indexOf('asset') > -1) {
|
||||
if (this.assetimportUrl.indexOf('asset') || this.assetimportUrl.indexOf('asset') > -1) {
|
||||
url = '/asset/template'
|
||||
} else if (this.importUrl.indexOf('rule') > -1) {
|
||||
} else if (this.assetimportUrl.indexOf('asset') || this.assetimportUrl.indexOf('asset') > -1) {
|
||||
url = '/alert/rule/template'
|
||||
} else if (this.importUrl.indexOf('panel') > -1) {
|
||||
} else if (this.assetimportUrl.indexOf('asset') || this.assetimportUrl.indexOf('asset') > -1) {
|
||||
url = '/panel/template'
|
||||
} else if (this.importUrl.indexOf('endpoint') > -1) {
|
||||
} else if (this.assetimportUrl.indexOf('asset') || this.assetimportUrl.indexOf('asset') > -1) {
|
||||
url = '/monitor/endpoint/template'
|
||||
} else if (this.importUrl.indexOf('tmpl') > -1) {
|
||||
} else if (this.assetimportUrl.indexOf('asset') || this.assetimportUrl.indexOf('asset') > -1) {
|
||||
url = '/expression/tmpl/template'
|
||||
}
|
||||
|
||||
@@ -952,6 +926,40 @@ export default {
|
||||
}
|
||||
this.exportExcel(url, param, fileName)
|
||||
},
|
||||
exportExcel (url, params, fileName) {
|
||||
if (this.paramsType) {
|
||||
params.type = this.paramsType
|
||||
}
|
||||
axios.get(url, { responseType: 'blob', params: params }).then(res => {
|
||||
if (window.navigator.msSaveOrOpenBlob) {
|
||||
// 兼容ie11
|
||||
const blobObject = new Blob([res.data])
|
||||
window.navigator.msSaveOrOpenBlob(blobObject, fileName)
|
||||
} else {
|
||||
const url = URL.createObjectURL(new Blob([res.data]))
|
||||
const a = document.createElement('a')
|
||||
document.body.appendChild(a) // 此处增加了将创建的添加到body当中
|
||||
a.href = url
|
||||
a.download = fileName
|
||||
a.target = '_blank'
|
||||
a.click()
|
||||
a.remove() // 将a标签移除
|
||||
}
|
||||
}, error => {
|
||||
const $self = this
|
||||
const reader = new FileReader()
|
||||
reader.onload = function (event) {
|
||||
const responseText = reader.result
|
||||
const exception = JSON.parse(responseText)
|
||||
if (exception.message) {
|
||||
$self.$message.error(exception.message)
|
||||
} else {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
reader.readAsText(error.response.data)
|
||||
})
|
||||
},
|
||||
importExcel () {
|
||||
if (this.importFile && this.importFile.raw) {
|
||||
this.prevent_opt.import = true
|
||||
@@ -964,37 +972,35 @@ export default {
|
||||
}
|
||||
}
|
||||
form.append('language', localStorage.getItem('nz-language') ? localStorage.getItem('nz-language') : 'en')
|
||||
this.$post(this.importUrl, form, { 'Content-Type': 'multipart/form-data' }).then(response => {
|
||||
if (response.code == 200 && response.msg == 'success') {
|
||||
this.importResult = response.data
|
||||
this.$emit('afterImport')
|
||||
this.importBox.type = 3
|
||||
this.importBox.width = '600px'
|
||||
} else {
|
||||
this.$message.error(response.msg)
|
||||
}
|
||||
this.prevent_opt.import = false
|
||||
})
|
||||
if (this.assetimportUrl){
|
||||
this.$post(this.assetimportUrl, form, { 'Content-Type': 'multipart/form-data' }).then(response => {
|
||||
if (response.code == 200 && response.msg == 'success') {
|
||||
this.importResult = response.data
|
||||
this.$emit('afterImport')
|
||||
this.importBox.type = 3
|
||||
this.importBox.width = '600px'
|
||||
} else {
|
||||
this.$message.error(response.msg)
|
||||
}
|
||||
this.prevent_opt.import = false
|
||||
})
|
||||
}else if (this.endpointimportUrl){
|
||||
this.$post(this.endpointimportUrl, form, { 'Content-Type': 'multipart/form-data' }).then(response => {
|
||||
if (response.code == 200 && response.msg == 'success') {
|
||||
this.importResult = response.data
|
||||
this.$emit('afterImport')
|
||||
this.importBox.type = 3
|
||||
this.importBox.width = '600px'
|
||||
} else {
|
||||
this.$message.error(response.msg)
|
||||
}
|
||||
this.prevent_opt.import = false
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.$message.error(this.$t('tip.noImportFile'))
|
||||
}
|
||||
},
|
||||
exportCur () {
|
||||
const params = Object.assign({}, this.params)
|
||||
params.language = localStorage.getItem('nz-language') || 'en'
|
||||
this.exportExcel(this.exportUrl, params, this.exportFileName + '-' + this.getTimeString() + '.xlsx')
|
||||
this.closeDialog()
|
||||
},
|
||||
exportAll () {
|
||||
const params = JSON.parse(JSON.stringify(this.params))
|
||||
params.pageSize = -1
|
||||
if (this.importUrl.indexOf('panel') > -1) {
|
||||
delete params.panelId
|
||||
}
|
||||
params.language = localStorage.getItem('nz-language') || 'en'
|
||||
this.exportExcel(this.exportUrl, params, this.exportFileName + '-' + this.getTimeString() + '.xlsx')
|
||||
this.closeDialog()
|
||||
},
|
||||
// Box 侧滑关闭事件
|
||||
closeDcBox (refresh) {
|
||||
this.rightBox.dc.show = false
|
||||
|
||||
Reference in New Issue
Block a user