Skip to content

Commit 063914f

Browse files
committed
feat(ui): rack - supported configuration device list display direction
1 parent f332bdb commit 063914f

File tree

3 files changed

+44
-13
lines changed

3 files changed

+44
-13
lines changed

cmdb-ui/src/modules/cmdb/views/dcim/components/rackDetail/rackView/index.vue

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
viewType="front"
66
:countList="countList"
77
:unitList="unitList"
8-
:rackId="rackData._id"
8+
:rackData="rackData"
99
@migrateDevice="migrateDevice"
1010
@openDeviceForm="openDeviceForm"
1111
@draggable="handleDraggable"
@@ -19,7 +19,7 @@
1919
viewType="rear"
2020
:countList="countList"
2121
:unitList="unitList"
22-
:rackId="rackData._id"
22+
:rackData="rackData"
2323
@migrateDevice="migrateDevice"
2424
@openDeviceForm="openDeviceForm"
2525
@draggable="handleDraggable"
@@ -52,7 +52,7 @@
5252
import _ from 'lodash'
5353
import { v4 as uuidv4 } from 'uuid'
5454
import { putDevice } from '@/modules/cmdb/api/dcim.js'
55-
import { DEVICE_CITYPE_NAME } from '../../../constants.js'
55+
import { DEVICE_CITYPE_NAME, U_NUMBERING_DIRECTION } from '../../../constants.js'
5656
5757
import RackUnitView from './rackUnitView.vue'
5858
import DeviceForm from './deviceForm/index.vue'
@@ -194,8 +194,20 @@ export default {
194194
}
195195
}
196196
197-
this.unitList = _.reverse(unitList)
198-
this.countList = Array.from({ length: this.rackData.u_count }, (_, i) => this.rackData.u_count - i)
197+
/**
198+
* 根据U位编号方向,调整U位列表和U位数量列表
199+
* bottom_to_top: 底部到顶部
200+
* top_to_bottom: 顶部到底部
201+
* 如果为空,则默认为 bottom_to_top
202+
*/
203+
const u_numbering_direction = this?.rackData?.u_numbering_direction || U_NUMBERING_DIRECTION.BOTTOM_TO_TOP
204+
if (u_numbering_direction === U_NUMBERING_DIRECTION.TOP_TO_BOTTOM) {
205+
this.unitList = unitList
206+
this.countList = Array.from({ length: this.rackData.u_count }, (_, i) => i + 1)
207+
} else {
208+
this.unitList = _.reverse(unitList)
209+
this.countList = Array.from({ length: this.rackData.u_count }, (_, i) => this.rackData.u_count - i)
210+
}
199211
},
200212
201213
getDeviceViewImage(name) {

cmdb-ui/src/modules/cmdb/views/dcim/components/rackDetail/rackView/rackUnitView.vue

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
<script>
161161
import _ from 'lodash'
162162
import { deleteDevice } from '@/modules/cmdb/api/dcim.js'
163+
import { U_NUMBERING_DIRECTION } from '../../../constants.js'
163164
164165
import RackHeader from './rackHeader/index.vue'
165166
import draggable from 'vuedraggable'
@@ -187,9 +188,9 @@ export default {
187188
type: Array,
188189
default: () => []
189190
},
190-
rackId: {
191-
type: Number,
192-
default: 0
191+
rackData: {
192+
type: Object,
193+
default: () => {}
193194
}
194195
},
195196
data() {
@@ -213,8 +214,14 @@ export default {
213214
const sliceUnitList = this.unitList.slice(0, index)
214215
const unitCount = sliceUnitList.reduce((acc, cur) => acc + cur.unitCount, 0)
215216
217+
const u_numbering_direction = this?.rackData?.u_numbering_direction
218+
let unitStart = this.countList.length - unitCount
219+
if (u_numbering_direction === U_NUMBERING_DIRECTION.TOP_TO_BOTTOM) {
220+
unitStart = unitCount + 1
221+
}
222+
216223
this.$emit('openDeviceForm', {
217-
unitStart: this.countList.length - unitCount
224+
unitStart
218225
})
219226
},
220227
@@ -283,10 +290,11 @@ export default {
283290
title: this.$t('warning'),
284291
content,
285292
onOk: () => {
286-
deleteDevice(
287-
this.rackId,
288-
data.id
289-
).then(() => {
293+
if (!this.rackData._id) {
294+
return
295+
}
296+
297+
deleteDevice(this.rackData._id, data.id).then(() => {
290298
this.$message.success(this.$t('deleteSuccess'))
291299
this.$emit('refreshRackAllData')
292300
})
@@ -383,6 +391,7 @@ export default {
383391
background: linear-gradient(90deg, rgba(0, 0, 0, 0.80) 0%, rgba(102, 102, 102, 0.80) 100%);
384392
align-items: center;
385393
justify-content: center;
394+
z-index: 1;
386395
387396
&-btn {
388397
font-size: 14px;

cmdb-ui/src/modules/cmdb/views/dcim/constants.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ export const DEVICE_CITYPE_NAME = {
2222
RAID: 'raid'
2323
}
2424

25+
/**
26+
* U位编号方向
27+
* bottom_to_top: 底部到顶部
28+
* top_to_bottom: 顶部到底部
29+
*/
30+
export const U_NUMBERING_DIRECTION = {
31+
BOTTOM_TO_TOP: 'bottom_to_top',
32+
TOP_TO_BOTTOM: 'top_to_bottom'
33+
}
34+
2535
const createTypeNameMap = (typeObj, typeNameObj) => {
2636
const map = {}
2737

0 commit comments

Comments
 (0)