fix: 修改 endpoint 导出时 未带checkBox的参数

This commit is contained in:
zhangyu
2021-06-17 15:01:13 +08:00
parent 57c77a8679
commit ed853172f9
2 changed files with 34 additions and 22 deletions

View File

@@ -106,6 +106,7 @@ export default {
}, },
exportUrl: { type: String, default: '' }, exportUrl: { type: String, default: '' },
params: { type: Object }, params: { type: Object },
params2: { type: Object },
exportFileName: { type: String }, exportFileName: { type: String },
importUrl: { type: String, default: '' }, // 为空时不显示导入按钮 importUrl: { type: String, default: '' }, // 为空时不显示导入按钮
link: { type: Object }, // 为空时不显示导出按钮 link: { type: Object }, // 为空时不显示导出按钮
@@ -241,6 +242,19 @@ export default {
}, },
exportCur () { exportCur () {
const params = JSON.parse(JSON.stringify(this.params)) const params = JSON.parse(JSON.stringify(this.params))
if (this.params2){
Object.keys(this.params2).forEach(key=>{
if ( params[key] ) {
if ( params[key].prototype.toString.call(val) === '[object Object]' ){
Object.assign(params[key],this.params2[key])
} else if (params[key].prototype.toString.call(val) === '[object Array]'){
params[key].concat(this.params2[key])
}
} else {
params[key] = this.params2[key]
}
})
}
if (this.exportUrl.indexOf('panel') > -1) { if (this.exportUrl.indexOf('panel') > -1) {
params.pageSize = -1 params.pageSize = -1
delete params.start_time delete params.start_time
@@ -254,6 +268,19 @@ export default {
}, },
exportAll () { exportAll () {
const params = JSON.parse(JSON.stringify(this.params)) const params = JSON.parse(JSON.stringify(this.params))
if (this.params2){
Object.keys(this.params2).forEach(key=>{
if ( params[key] ) {
if ( params[key].prototype.toString.call(val) === '[object Object]' ){
Object.assign(params[key],this.params2[key])
} else if (params[key].prototype.toString.call(val) === '[object Array]'){
params[key].concat(this.params2[key])
}
} else {
params[key] = this.params2[key]
}
})
}
params.pageSize = -1 params.pageSize = -1
if (this.exportUrl.indexOf('panel') > -1) { if (this.exportUrl.indexOf('panel') > -1) {
delete params.start_time delete params.start_time

View File

@@ -21,6 +21,7 @@
ref="export" ref="export"
id="endpoint-template-list" id="endpoint-template-list"
:params="searchLabel" :params="searchLabel"
:params2="searchCheckBox"
:permissions="{import: 'monitor_endpoint_add', export: 'monitor_module_view'}" :permissions="{import: 'monitor_endpoint_add', export: 'monitor_module_view'}"
class="top-tool-export margin-l-10 margin-r-10" class="top-tool-export margin-l-10 margin-r-10"
export-file-name="expression-template" export-file-name="expression-template"
@@ -201,7 +202,8 @@ export default {
projectIds: [], projectIds: [],
moduleIds: [], moduleIds: [],
states: [] states: []
} },
searchCheckBox: {}
} }
}, },
methods: { methods: {
@@ -256,16 +258,7 @@ export default {
...this.searchLabel, ...this.searchLabel,
...this.searchCheckBox ...this.searchCheckBox
} }
if (this.searchLabel.projectIds) { localStorage.removeItem('endpointProjectId')
localStorage.setItem('endpointProjectId', this.searchLabel.projectIds)
if (params.projectIds) {
params.projectIds += ',' + this.searchLabel.projectIds
} else {
params.projectIds = this.searchLabel.projectIds
}
} else {
localStorage.removeItem('endpointProjectId')
}
this.tools.loading = true this.tools.loading = true
this.$get(this.url, params).then(response => { this.$get(this.url, params).then(response => {
this.tools.loading = false this.tools.loading = false
@@ -334,22 +327,14 @@ export default {
}, },
created () { created () {
if (localStorage.getItem('endpointProjectId')) { if (localStorage.getItem('endpointProjectId')) {
this.searchLabel.projectIds = localStorage.getItem('endpointProjectId') this.selectValue.projectIds = [Number(localStorage.getItem('endpointProjectId'))]
} }
}, },
mounted () { mounted () {
if (localStorage.getItem('endpointProjectId')) { if (localStorage.getItem('endpointProjectId')) {
this.$refs.dataList.$refs.searchInput.select_list.push({ this.selectValue.projectIds = [Number(localStorage.getItem('endpointProjectId'))]
id: 11, // this.$refs.clickSearch.selectValueOut.projectIds = [localStorage.getItem('endpointProjectId')]
name: 'project id',
type: 'input',
label: 'projectIds',
disabled: false,
val: localStorage.getItem('endpointProjectId')
})
this.$refs.dataList.$refs.searchInput.sreach_num = 1
} }
this.getTitleSearch() this.getTitleSearch()
}, },
watch: { watch: {