Skip to content

Commit e3515eb

Browse files
committed
fix(ui): rack - fixed drag-and-drop device list data error
1 parent 063914f commit e3515eb

File tree

1 file changed

+8
-2
lines changed
  • cmdb-ui/src/modules/cmdb/views/dcim/components/rackDetail/rackView

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,16 @@ export default {
248248
const sliceUnitList = this.unitList.slice(0, e.newIndex)
249249
const unitCount = sliceUnitList.reduce((acc, cur) => acc + cur.unitCount, 0)
250250
251+
const u_numbering_direction = this?.rackData?.u_numbering_direction
251252
/**
252-
* 拖拽后的起始U位 = 总U数 - 该设备以上的U数 - 该设备U数 + 1
253+
* 根据 u_numbering_direction (U位编号方向),计算拖拽后的起始U位
254+
* 从下往上: 拖拽后的起始U位 = 总U数 - 该设备以上的设备U数合计 - 该设备U数 + 1
255+
* 从上往下: 拖拽后的起始U位 = 该设备以上的设备U数合计 + 1
253256
*/
254-
const startUnit = this.countList.length - unitCount - this.draggableDevice.unitCount + 1
257+
let startUnit = this.countList.length - unitCount - this.draggableDevice.unitCount + 1
258+
if (u_numbering_direction === U_NUMBERING_DIRECTION.TOP_TO_BOTTOM) {
259+
startUnit = unitCount + 1
260+
}
255261
256262
if (this?.draggableDevice?.id) {
257263
this.$emit('draggable', {

0 commit comments

Comments
 (0)