fix: 云平台增加数据中心来搜索

develop
时启龙 2024-11-06 16:20:10 +08:00
parent 1ff06b2958
commit 84b31aaba4
6 changed files with 108 additions and 37 deletions

View File

@ -350,6 +350,10 @@ const vmUrl = 'cmp/v1/vms'
export function getVm(params) { export function getVm(params) {
return request.get(vmUrl, { params }) return request.get(vmUrl, { params })
} }
// 之前的接口不能根据数据中心来查询云主机,这个接口在之前的接口上加了dcId参数,在后端其他不变还是走原来的接口
export function getVmByDc(params) {
return request.get(`${vmUrl}/vmsOfDataCenter`, { params })
}
export function patchVms(action, params) { export function patchVms(action, params) {
return request.patch(vmUrl, { return request.patch(vmUrl, {

View File

@ -2,14 +2,19 @@
<el-card> <el-card>
<el-row :gutter="10"> <el-row :gutter="10">
<el-row :gutter="10" class="m-b"> <el-row :gutter="10" class="m-b">
<el-col :span="6"> <el-col :span="5">
<el-input v-model="searchObj.name" placeholder="名称"></el-input> <el-input v-model="searchObj.name" placeholder="名称"></el-input>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="5">
<el-select v-model="searchObj.resourceCategory" @change="handleSearch" placeholder="请选择平台类型" clearable> <el-select v-model="searchObj.resourceCategory" @change="handleSearch" placeholder="请选择平台类型" clearable>
<el-option v-for="item in resourceCategoryList" :key="item.id" :value="item.id" :label="item.name"></el-option> <el-option v-for="item in resourceCategoryList" :key="item.id" :value="item.id" :label="item.name"></el-option>
</el-select> </el-select>
</el-col> </el-col>
<el-col :span="5">
<el-select v-model="searchObj.dcId" @change="handleSearch" placeholder="请选择数据中心" clearable>
<el-option v-for="item in dcList" :key="item.id" :value="item.id" :label="item.name"></el-option>
</el-select>
</el-col>
<el-col :span="6"> <el-col :span="6">
<el-button type="ghost" icon="el-icon-search" @click="handleSearch"></el-button> <el-button type="ghost" icon="el-icon-search" @click="handleSearch"></el-button>
<el-button type="ghost" icon="el-icon-refresh" @click="handleReset"></el-button> <el-button type="ghost" icon="el-icon-refresh" @click="handleReset"></el-button>
@ -52,7 +57,7 @@
<script> <script>
import webSocket from '@cmp/cmp-common/mixins/getGlobalSocket' import webSocket from '@cmp/cmp-common/mixins/getGlobalSocket'
import { content, platformStatusBgFilter, platformStatusFilter } from './config' import { content, platformStatusBgFilter, platformStatusFilter } from './config'
import { getCloudVendor, getVendorType, syncCloudVendor } from 'services/platform/index' import { getCloudVendor, getVendorType, syncCloudVendor, getDc } from 'services/platform/index'
import { handleSearchParam } from '@cmp/cmp-element' import { handleSearchParam } from '@cmp/cmp-element'
export default { export default {
@ -86,9 +91,11 @@ export default {
BACK_RESOURCE: '/cmp/v1/vendors' BACK_RESOURCE: '/cmp/v1/vendors'
}, },
resourceCategoryList: [], resourceCategoryList: [],
dcList: [],
searchObj: { searchObj: {
name: '', name: '',
resourceCategory: '' resourceCategory: '',
dcId: ''
} }
} }
}, },
@ -116,6 +123,7 @@ export default {
handleReset() { handleReset() {
this.searchObj.name = '' this.searchObj.name = ''
this.searchObj.resourceCategory = '' this.searchObj.resourceCategory = ''
this.searchObj.dcId = ''
this.getData() this.getData()
}, },
// //
@ -146,7 +154,8 @@ export default {
params: handleSearchParam({ params: handleSearchParam({
vendorCategory: this.$route.name, vendorCategory: this.$route.name,
'name:LK': this.searchObj.name, 'name:LK': this.searchObj.name,
type: this.searchObj.resourceCategory type: this.searchObj.resourceCategory,
dcId: this.searchObj.dcId
}) })
}, },
this.urlObj[this.$route.name] || '' this.urlObj[this.$route.name] || ''
@ -180,11 +189,19 @@ export default {
}) })
} }
}) })
},
getDc() {
getDc({ simple: true }).then(data => {
if (data.success) {
this.dcList = data.data.rows
}
})
} }
}, },
created() { created() {
this.getData() this.getData()
this.getVendorTypes() this.getVendorTypes()
this.getDc()
} }
} }
</script> </script>

View File

@ -209,7 +209,8 @@ export const columns = [
] ]
export const searchConfigs = [ export const searchConfigs = [
{ type: 'Input', label: '名称', value: 'name' }, { type: 'Input', label: '名称', value: 'name' },
{ type: 'Select', label: '请选择云类型', value: 'type', data: [] } { type: 'Select', label: '请选择云类型', value: 'type', data: [] },
{ type: 'Select', label: '请选择数据中心', value: 'dcId', data: [] }
] ]
export const test = { export const test = {
VMWARE: ['availablitiyZone', 'region', 'isPublic', 'id', 'name', 'tenant', 'account', 'password', 'address', 'domainName', 'projectName', 'version', 'remark', 'envId', 'type', 'version', 'dcId', 'logo'], VMWARE: ['availablitiyZone', 'region', 'isPublic', 'id', 'name', 'tenant', 'account', 'password', 'address', 'domainName', 'projectName', 'version', 'remark', 'envId', 'type', 'version', 'dcId', 'logo'],

View File

@ -181,8 +181,17 @@ export default {
}, },
created() { created() {
this.getVType() this.getVType()
this.getDc()
}, },
methods: { methods: {
getDc() {
getDc({ simple: true }).then(data => {
if (data.success) {
this.searchConfigs[2].data = data.data.rows
this.dcList = data.data.rows
}
})
},
getVType() { getVType() {
getVendorType({ condition: JSON.stringify({ condition: 'listType' }) }).then(data => { getVendorType({ condition: JSON.stringify({ condition: 'listType' }) }).then(data => {
if (data.success) { if (data.success) {
@ -227,15 +236,6 @@ export default {
this.getData() this.getData()
} }
}, },
getDc() {
getDc({
simple: true
}).then(data => {
if (data.success) {
this.dcList = data.data.rows
}
})
},
getDictionaries(list, value) { getDictionaries(list, value) {
getDictionaries({ value: value }).then(data => { getDictionaries({ value: value }).then(data => {
if (data.success) { if (data.success) {
@ -284,7 +284,6 @@ export default {
this.envListData = data.data.rows this.envListData = data.data.rows
} }
}) })
this.getDc()
this.getDictionaries('dictionaries', 'region') this.getDictionaries('dictionaries', 'region')
this.modifyName = '编辑平台' this.modifyName = '编辑平台'
detailCloudVendor(data.id, this.urlObj[data.vendorCategory] || '').then(data => { detailCloudVendor(data.id, this.urlObj[data.vendorCategory] || '').then(data => {

View File

@ -351,18 +351,22 @@ export default {
simple: true simple: true
}).then(data => { }).then(data => {
if (data.success) { if (data.success) {
this.searchConfigs[3].data = data.data.rows.map(item => { this.searchConfigs.map(item => {
return { if (item.value === 'labelContent') {
...item, item.data = data.data.rows.map(item => {
/* eslint-disable */ return {
children: item.content ...item,
? JSON.parse(item.content).map(item1 => { /* eslint-disable */
return { children: item.content
name: item1, ? JSON.parse(item.content).map(item1 => {
id: `${item.name}:${item1}` return {
} name: item1,
}) id: `${item.name}:${item1}`
: '' }
})
: ''
}
})
} }
}) })
} }
@ -374,7 +378,11 @@ export default {
rows: 9999 rows: 9999
}).then(data => { }).then(data => {
if (data.success) { if (data.success) {
this.searchConfigs[4].data = data.data.rows this.searchConfigs.map(item => {
if (item.value === 'tenantId') {
item.data = data.data.rows
}
})
} }
}) })
}, },
@ -384,7 +392,11 @@ export default {
rows: 9999 rows: 9999
}).then(data => { }).then(data => {
if (data.success) { if (data.success) {
this.searchConfigs[5].data = data.data.rows this.searchConfigs.map(item => {
if (item.value === 'projectId') {
item.data = data.data.rows
}
})
} }
}) })
}, },
@ -394,7 +406,11 @@ export default {
rows: 9999 rows: 9999
}).then(data => { }).then(data => {
if (data.success) { if (data.success) {
this.searchConfigs[4].data = data.data.rows this.searchConfigs.map(item => {
if (item.value === 'businessId') {
item.data = data.data.rows
}
})
} }
}) })
}, },

View File

@ -17,7 +17,7 @@ import { downloadFile } from '@cmp/cmp-common/utils/'
import operate from './operate/index.vue' import operate from './operate/index.vue'
import detail from './detail/index.vue' import detail from './detail/index.vue'
import webSocket from '@cmp/cmp-common/mixins/getGlobalSocket' import webSocket from '@cmp/cmp-common/mixins/getGlobalSocket'
import { getVm, detailTypeVm, patchVms, getVendorType } from 'services/platform/index' import { getVmByDc, detailTypeVm, patchVms, getVendorType, getDc } from 'services/platform/index'
import { getTenantTree } from 'services/system/tenant' import { getTenantTree } from 'services/system/tenant'
import { getProject } from 'services/system/project' import { getProject } from 'services/system/project'
import show from './show.vue' import show from './show.vue'
@ -47,6 +47,7 @@ export default {
{ label: '项目', value: 'projectId', type: 'Select', data: [] }, { label: '项目', value: 'projectId', type: 'Select', data: [] },
{ label: '业务', value: 'businessId', type: 'Select', data: [] }, { label: '业务', value: 'businessId', type: 'Select', data: [] },
{ label: '平台', value: 'vendorType', type: 'Select', data: [] }, { label: '平台', value: 'vendorType', type: 'Select', data: [] },
{ label: '数据中心', value: 'dcId', type: 'Select', data: [] },
{ value: 'isTemplate', type: 'Const', initValue: false } { value: 'isTemplate', type: 'Const', initValue: false }
], ],
columns: [ columns: [
@ -149,6 +150,7 @@ export default {
this.getTenantList() this.getTenantList()
this.getProject() this.getProject()
this.getPlatformData() this.getPlatformData()
this.getDc()
}, },
methods: { methods: {
show() { show() {
@ -167,10 +169,25 @@ export default {
getPlatformData() { getPlatformData() {
getVendorType({ condition: JSON.stringify({ condition: 'listType', resourceCategory: 'COMPUTE' }) }).then(res => { getVendorType({ condition: JSON.stringify({ condition: 'listType', resourceCategory: 'COMPUTE' }) }).then(res => {
if (res.success) { if (res.success) {
this.configs[7].data = res.data.map(item => { this.configs.map(item => {
return { if (item.value === 'vendorType') {
id: item, item.data = res.data.map(item => {
name: item return {
id: item,
name: item
}
})
}
})
}
})
},
getDc() {
getDc({ simple: true }).then(data => {
if (data.success) {
this.configs.map(item => {
if (item.value === 'dcId') {
item.data = data.data.rows
} }
}) })
} }
@ -413,7 +430,24 @@ export default {
}, },
getList() { getList() {
this.loading = true this.loading = true
getVm(this.params).then(data => { const cloneParams = JSON.parse(this.params.params)
console.log(cloneParams)
//
const convertedParams = []
cloneParams.forEach(item => {
const paramKeys = Object.keys(item.param)
paramKeys.forEach(key => {
convertedParams.push({
param: { [key]: item.param[key] },
sign: item.sign
})
})
})
const params = {
...this.params,
params: JSON.stringify(convertedParams)
}
getVmByDc(params).then(data => {
if (data.success) { if (data.success) {
this.list = this.setList(data.data.rows.concat(this.cacheList)) this.list = this.setList(data.data.rows.concat(this.cacheList))
this.total = data.data.total this.total = data.data.total