From 84b31aaba4d30a9a9193803b26af9c7c7776a26d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=B6=E5=90=AF=E9=BE=99?= Date: Wed, 6 Nov 2024 16:20:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BA=91=E5=B9=B3=E5=8F=B0=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=95=B0=E6=8D=AE=E4=B8=AD=E5=BF=83=E6=9D=A5=E6=90=9C?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webs/cmp-web/src/services/platform/index.js | 4 ++ .../src/views/platform/cloudVendor/list.vue | 27 +++++++++-- .../src/views/platform/vendors/config.ts | 3 +- .../src/views/platform/vendors/index.vue | 19 ++++---- webs/cmp-web/src/views/platform/vmTable.vue | 46 +++++++++++++------ webs/cmp-web/src/views/vm/index.vue | 46 ++++++++++++++++--- 6 files changed, 108 insertions(+), 37 deletions(-) diff --git a/webs/cmp-web/src/services/platform/index.js b/webs/cmp-web/src/services/platform/index.js index 34c13e3..7b9ae19 100644 --- a/webs/cmp-web/src/services/platform/index.js +++ b/webs/cmp-web/src/services/platform/index.js @@ -350,6 +350,10 @@ const vmUrl = 'cmp/v1/vms' export function getVm(params) { return request.get(vmUrl, { params }) } +// 之前的接口不能根据数据中心来查询云主机,这个接口在之前的接口上加了dcId参数,在后端其他不变还是走原来的接口 +export function getVmByDc(params) { + return request.get(`${vmUrl}/vmsOfDataCenter`, { params }) +} export function patchVms(action, params) { return request.patch(vmUrl, { diff --git a/webs/cmp-web/src/views/platform/cloudVendor/list.vue b/webs/cmp-web/src/views/platform/cloudVendor/list.vue index 6c1b26c..08bab5e 100644 --- a/webs/cmp-web/src/views/platform/cloudVendor/list.vue +++ b/webs/cmp-web/src/views/platform/cloudVendor/list.vue @@ -2,14 +2,19 @@ - + - + + + + + + 搜索 重置 @@ -52,7 +57,7 @@ diff --git a/webs/cmp-web/src/views/platform/vendors/config.ts b/webs/cmp-web/src/views/platform/vendors/config.ts index dcfe437..cce777f 100644 --- a/webs/cmp-web/src/views/platform/vendors/config.ts +++ b/webs/cmp-web/src/views/platform/vendors/config.ts @@ -209,7 +209,8 @@ export const columns = [ ] export const searchConfigs = [ { 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 = { VMWARE: ['availablitiyZone', 'region', 'isPublic', 'id', 'name', 'tenant', 'account', 'password', 'address', 'domainName', 'projectName', 'version', 'remark', 'envId', 'type', 'version', 'dcId', 'logo'], diff --git a/webs/cmp-web/src/views/platform/vendors/index.vue b/webs/cmp-web/src/views/platform/vendors/index.vue index 4432a50..e675753 100644 --- a/webs/cmp-web/src/views/platform/vendors/index.vue +++ b/webs/cmp-web/src/views/platform/vendors/index.vue @@ -181,8 +181,17 @@ export default { }, created() { this.getVType() + this.getDc() }, methods: { + getDc() { + getDc({ simple: true }).then(data => { + if (data.success) { + this.searchConfigs[2].data = data.data.rows + this.dcList = data.data.rows + } + }) + }, getVType() { getVendorType({ condition: JSON.stringify({ condition: 'listType' }) }).then(data => { if (data.success) { @@ -227,15 +236,6 @@ export default { this.getData() } }, - getDc() { - getDc({ - simple: true - }).then(data => { - if (data.success) { - this.dcList = data.data.rows - } - }) - }, getDictionaries(list, value) { getDictionaries({ value: value }).then(data => { if (data.success) { @@ -284,7 +284,6 @@ export default { this.envListData = data.data.rows } }) - this.getDc() this.getDictionaries('dictionaries', 'region') this.modifyName = '编辑平台' detailCloudVendor(data.id, this.urlObj[data.vendorCategory] || '').then(data => { diff --git a/webs/cmp-web/src/views/platform/vmTable.vue b/webs/cmp-web/src/views/platform/vmTable.vue index 89fb5f9..cd3503c 100644 --- a/webs/cmp-web/src/views/platform/vmTable.vue +++ b/webs/cmp-web/src/views/platform/vmTable.vue @@ -351,18 +351,22 @@ export default { simple: true }).then(data => { if (data.success) { - this.searchConfigs[3].data = data.data.rows.map(item => { - return { - ...item, - /* eslint-disable */ - children: item.content - ? JSON.parse(item.content).map(item1 => { - return { - name: item1, - id: `${item.name}:${item1}` - } - }) - : '' + this.searchConfigs.map(item => { + if (item.value === 'labelContent') { + item.data = data.data.rows.map(item => { + return { + ...item, + /* eslint-disable */ + children: item.content + ? JSON.parse(item.content).map(item1 => { + return { + name: item1, + id: `${item.name}:${item1}` + } + }) + : '' + } + }) } }) } @@ -374,7 +378,11 @@ export default { rows: 9999 }).then(data => { 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 }).then(data => { 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 }).then(data => { if (data.success) { - this.searchConfigs[4].data = data.data.rows + this.searchConfigs.map(item => { + if (item.value === 'businessId') { + item.data = data.data.rows + } + }) } }) }, diff --git a/webs/cmp-web/src/views/vm/index.vue b/webs/cmp-web/src/views/vm/index.vue index ab98322..2232739 100644 --- a/webs/cmp-web/src/views/vm/index.vue +++ b/webs/cmp-web/src/views/vm/index.vue @@ -17,7 +17,7 @@ import { downloadFile } from '@cmp/cmp-common/utils/' import operate from './operate/index.vue' import detail from './detail/index.vue' 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 { getProject } from 'services/system/project' import show from './show.vue' @@ -47,6 +47,7 @@ export default { { label: '项目', value: 'projectId', type: 'Select', data: [] }, { label: '业务', value: 'businessId', type: 'Select', data: [] }, { label: '平台', value: 'vendorType', type: 'Select', data: [] }, + { label: '数据中心', value: 'dcId', type: 'Select', data: [] }, { value: 'isTemplate', type: 'Const', initValue: false } ], columns: [ @@ -149,6 +150,7 @@ export default { this.getTenantList() this.getProject() this.getPlatformData() + this.getDc() }, methods: { show() { @@ -167,10 +169,25 @@ export default { getPlatformData() { getVendorType({ condition: JSON.stringify({ condition: 'listType', resourceCategory: 'COMPUTE' }) }).then(res => { if (res.success) { - this.configs[7].data = res.data.map(item => { - return { - id: item, - name: item + this.configs.map(item => { + if (item.value === 'vendorType') { + item.data = res.data.map(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() { 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) { this.list = this.setList(data.data.rows.concat(this.cacheList)) this.total = data.data.total