Merge pull request 'dev' (#598) from dev into dev-deploy

Reviewed-on: #598
This commit is contained in:
ysCha 2026-01-23 17:44:33 +09:00
commit 51036421fc

View File

@ -9,7 +9,7 @@ import BasicSetting from '@/components/floor-plan/modal/basic/BasicSetting'
import { useMasterController } from '@/hooks/common/useMasterController'
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
import { GlobalDataContext } from '@/app/GlobalDataProvider'
import { POLYGON_TYPE, MENU } from '@/common/common'
import { MENU, POLYGON_TYPE } from '@/common/common'
import { useSwal } from '@/hooks/useSwal'
import { canvasState, canvasZoomState, currentMenuState } from '@/store/canvasAtom'
@ -151,24 +151,31 @@ export default function CircuitTrestleSetting({ id }) {
// :
const getSortFn = () => {
switch (direction) {
case 'south': return (a, b) => b.y - a.y // (y )
case 'north': return (a, b) => a.y - b.y // (y )
case 'east': return (a, b) => b.x - a.x // (x )
case 'west': return (a, b) => a.x - b.x // (x )
default: return () => 0
case 'south':
return (a, b) => b.y - a.y // (y )
case 'north':
return (a, b) => a.y - b.y // (y )
case 'east':
return (a, b) => b.x - a.x // (x )
case 'west':
return (a, b) => a.x - b.x // (x )
default:
return () => 0
}
}
// ( )
const findTargetModules = (current, margin) => {
return centerPoints.filter(cp => {
const sameAxis = isVertical
? Math.abs(cp.x - current.x) < margin
: Math.abs(cp.y - current.y) < margin
const targetDirection = direction === 'south' ? cp.y < current.y
: direction === 'north' ? cp.y > current.y
: direction === 'east' ? cp.x < current.x
: cp.x > current.x
return centerPoints.filter((cp) => {
const sameAxis = isVertical ? Math.abs(cp.x - current.x) < margin : Math.abs(cp.y - current.y) < margin
const targetDirection =
direction === 'south'
? cp.y < current.y
: direction === 'north'
? cp.y > current.y
: direction === 'east'
? cp.x < current.x
: cp.x > current.x
return sameAxis && targetDirection
})
}
@ -178,11 +185,16 @@ export default function CircuitTrestleSetting({ id }) {
if (filtered.length === 0) return null
return filtered.reduce((closest, cp) => {
switch (direction) {
case 'south': return cp.y > closest.y ? cp : closest
case 'north': return cp.y < closest.y ? cp : closest
case 'east': return cp.x > closest.x ? cp : closest
case 'west': return cp.x < closest.x ? cp : closest
default: return closest
case 'south':
return cp.y > closest.y ? cp : closest
case 'north':
return cp.y < closest.y ? cp : closest
case 'east':
return cp.x > closest.x ? cp : closest
case 'west':
return cp.x < closest.x ? cp : closest
default:
return closest
}
})
}
@ -191,12 +203,12 @@ export default function CircuitTrestleSetting({ id }) {
const getGap = (current, target) => {
if (isVertical) {
return direction === 'south'
? (current.y - current.height / 2) - (target.y + target.height / 2)
: (target.y - target.height / 2) - (current.y + current.height / 2)
? current.y - current.height / 2 - (target.y + target.height / 2)
: target.y - target.height / 2 - (current.y + current.height / 2)
} else {
return direction === 'east'
? (current.x - current.width / 2) - (target.x + target.width / 2)
: (target.x - target.width / 2) - (current.x + current.width / 2)
? current.x - current.width / 2 - (target.x + target.width / 2)
: target.x - target.width / 2 - (current.x + current.width / 2)
}
}
@ -228,10 +240,14 @@ export default function CircuitTrestleSetting({ id }) {
const offsetAxis = isVertical
? Math.abs(cp.x - (current.x + offsetValue)) <= primaryInterval
: Math.abs(cp.y - (current.y + offsetValue)) <= primaryInterval
const targetDirection = direction === 'south' ? cp.y < current.y
: direction === 'north' ? cp.y > current.y
: direction === 'east' ? cp.x < current.x
: cp.x > current.x
const targetDirection =
direction === 'south'
? cp.y < current.y
: direction === 'north'
? cp.y > current.y
: direction === 'east'
? cp.x < current.x
: cp.x > current.x
return offsetAxis && targetDirection
})
@ -428,12 +444,13 @@ export default function CircuitTrestleSetting({ id }) {
let pcsObj = {}
models.forEach((model) => {
pcsObj[model.itemId] = model
pcsObj[`${model.pcsSerCd}_${model.itemId}`] = model
})
res.data?.pcsItemList.forEach((item) => {
if (pcsObj[item.itemId]) {
const key = `${item.pcsSerCd}_${item.itemId}`
if (pcsObj[key]) {
pcsItemList.push({
...pcsObj[item.itemId],
...pcsObj[key],
isUsed: false,
id: uuidv4(),
})
@ -560,12 +577,13 @@ export default function CircuitTrestleSetting({ id }) {
let pcsItemList = []
let pcsObj = {}
models.forEach((model) => {
pcsObj[model.itemId] = model
pcsObj[`${model.pcsSerCd}_${model.itemId}`] = model
})
res.data?.pcsItemList.forEach((item) => {
if (pcsObj[item.itemId]) {
const key = `${item.pcsSerCd}_${item.itemId}`
if (pcsObj[key]) {
pcsItemList.push({
...pcsObj[item.itemId],
...pcsObj[key],
isUsed: false,
id: uuidv4(),
})