fix: 弹性IP列表执行绑定云主机操作,云主机存在2个网卡,在下拉列表中无法单独选择云主机的某一个网卡,前端自动选中了该云主机的2个网卡数据

develop
时启龙 2024-08-28 22:59:20 +08:00
parent 336543beeb
commit 59b0c799d1
1 changed files with 11 additions and 6 deletions

View File

@ -3,9 +3,9 @@
<el-dialog title="绑定云主机" :visible.sync="addData.dialog" width="40%"> <el-dialog title="绑定云主机" :visible.sync="addData.dialog" width="40%">
<el-row> <el-row>
<cb-form label-width="90px" :model="addData.data" ref="data"> <cb-form label-width="90px" :model="addData.data" ref="data">
<cb-form-item label="云主机:" prop="instanceId" :rules="[required]" required-message=""> <cb-form-item label="云主机:" prop="networkcardUuid" :rules="[required]" required-message="">
<el-select v-model="addData.data.instanceId" filterable> <el-select v-model="addData.data.networkcardUuid" filterable>
<el-option v-for="(item, index) in vmList" :label="item.serverName + '(' + item.ipAddress + ')'" :value="item.instanceId" :key="index"></el-option> <el-option v-for="(item, index) in vmList" :label="item.serverName + '(' + item.ipAddress + ')'" :value="item.networkcardUuid" :key="index"></el-option>
</el-select> </el-select>
</cb-form-item> </cb-form-item>
</cb-form> </cb-form>
@ -47,22 +47,27 @@ export default {
ok() { ok() {
this.$refs.data.validate(valid => { this.$refs.data.validate(valid => {
if (valid) { if (valid) {
let instanceId = ''
let networkCardId = '' let networkCardId = ''
let fixedIpAddress = '', let fixedIpAddress = '',
serverId serverId
let cell = null let cell = null
this.vmList.forEach(item => { this.vmList.forEach(item => {
if (item.instanceId == this.addData.data.instanceId) { if (item.networkcardUuid == this.addData.data.networkcardUuid) {
cell = item cell = item
networkCardId = item.id networkCardId = item.id
instanceId = item.instanceId
fixedIpAddress = item.ipAddress fixedIpAddress = item.ipAddress
} }
}) })
floatIpPorts({ floatIpPorts({
networkCardId, networkCardId,
fixedIpAddress, fixedIpAddress,
portUuid: cell.networkcardUuid, instanceId,
...this.addData.data portUuid: this.addData.data.networkcardUuid,
id: this.addData.data.id,
regionId: this.addData.data.regionId,
vendorId: this.addData.data.vendorId
}).then(data => { }).then(data => {
if (data.success) { if (data.success) {
this.$message({ this.$message({