Merge branch 'qcast-pub' into dev
This commit is contained in:
commit
98b8bb674f
@ -408,7 +408,7 @@ export default function CanvasMenu(props) {
|
||||
const checkMenuState = (menu) => {
|
||||
return (
|
||||
(['2', '3'].includes(canvasSetting?.roofSizeSet) && menu.type === 'outline') ||
|
||||
(selectedMenu === 'module' && ['drawing', 'placement'].includes(menu.type)) ||
|
||||
(selectedMenu === 'module' && ['placement', 'outline', 'surface'].includes(menu.type)) ||
|
||||
(isExistModule() && ['placement', 'outline'].some((num) => num === menu.type)) ||
|
||||
(['estimate', 'simulation'].includes(selectedMenu) && ['placement', 'outline', 'surface'].includes(menu.type))
|
||||
)
|
||||
|
||||
@ -521,6 +521,15 @@ export default function CircuitTrestleSetting({ id }) {
|
||||
const handlePassivityAllocationCkeck = () => {
|
||||
let pcsCount = {}
|
||||
let result = {}
|
||||
const notAllocationModules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE && !obj.circuit)
|
||||
if (notAllocationModules.length > 0) {
|
||||
swalFire({
|
||||
text: getMessage('not.allocation.exist.module'),
|
||||
type: 'alert',
|
||||
icon: 'warning',
|
||||
})
|
||||
return
|
||||
}
|
||||
canvas
|
||||
.getObjects()
|
||||
.filter((obj) => obj.name === POLYGON_TYPE.MODULE)
|
||||
|
||||
@ -31,6 +31,7 @@ export default function DimensionLineSetting(props) {
|
||||
useEffect(() => {
|
||||
if (canvas) {
|
||||
const dimensionObject = canvas.getActiveObject()
|
||||
console.log(dimensionObject)
|
||||
const id = dimensionObject.groupId
|
||||
const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0]
|
||||
if (!textObj) return
|
||||
@ -38,6 +39,7 @@ export default function DimensionLineSetting(props) {
|
||||
setBasicLength(+dimensionObject.length)
|
||||
setSelectedSlope1(dimensionObject.angle1)
|
||||
setSelectedSlope2(dimensionObject.angle2)
|
||||
setSlopeAble(dimensionObject.slopeAble)
|
||||
}
|
||||
|
||||
if (basicSetting.roofAngleSet === 'slope') {
|
||||
@ -65,13 +67,13 @@ export default function DimensionLineSetting(props) {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!slopeAble) {
|
||||
const dimensionObject = canvas.getActiveObject()
|
||||
dimensionObject.set({
|
||||
angle1: null,
|
||||
angle2: null,
|
||||
})
|
||||
}
|
||||
// if (!slopeAble) {
|
||||
// const dimensionObject = canvas.getActiveObject()
|
||||
// dimensionObject.set({
|
||||
// angle1: null,
|
||||
// angle2: null,
|
||||
// })
|
||||
// }
|
||||
}, [slopeAble])
|
||||
|
||||
const handleChangeLength = () => {
|
||||
@ -79,19 +81,24 @@ export default function DimensionLineSetting(props) {
|
||||
const dimensionObject = canvas.getActiveObject()
|
||||
const id = dimensionObject.groupId
|
||||
const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0]
|
||||
let resultText = +changeLength > 0 ? +changeLength : '0'
|
||||
console.log(changeLength)
|
||||
let resultText = +changeLength > 0 ? +changeLength : dimensionObject.length
|
||||
|
||||
if (slopeAble) {
|
||||
resultText = !selectedSlope2
|
||||
? calculateLength(basicLength, selectedSlope1.value).toFixed(0)
|
||||
: calculateLength(basicLength, selectedSlope1.value, selectedSlope2.value).toFixed(0)
|
||||
? calculateLength(resultText, selectedSlope1.value).toFixed(0)
|
||||
: calculateLength(resultText, selectedSlope1.value, selectedSlope2.value).toFixed(0)
|
||||
}
|
||||
|
||||
textObj.set({
|
||||
text: String(resultText),
|
||||
})
|
||||
|
||||
dimensionObject.set({ length: +resultText })
|
||||
dimensionObject.set({
|
||||
length: +changeLength > 0 ? +changeLength : dimensionObject.length,
|
||||
slopeAble: slopeAble,
|
||||
angle1: selectedSlope1,
|
||||
angle2: selectedSlope2,
|
||||
})
|
||||
setBasicLength(resultText)
|
||||
setChangeLength('')
|
||||
canvas.renderAll()
|
||||
@ -153,7 +160,7 @@ export default function DimensionLineSetting(props) {
|
||||
</div>
|
||||
</div>
|
||||
<div className="d-check-box pop">
|
||||
<input type="checkbox" id="ch99" onChange={() => setSlopeAble(!slopeAble)} />
|
||||
<input type="checkbox" id="ch99" checked={slopeAble} onChange={() => setSlopeAble(!slopeAble)} />
|
||||
<label htmlFor="ch99">{getMessage('modal.display.edit.input.slope')}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -428,7 +428,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{currentRoof && (
|
||||
{/* {currentRoof && (
|
||||
<div className="placement-roof-btn-wrap">
|
||||
<div className="icon-btn-wrap mt10">
|
||||
<button
|
||||
@ -450,7 +450,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
)} */}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@ -282,6 +282,10 @@ export function useCommonUtils() {
|
||||
originY: 'center',
|
||||
lineDirection: lineDirection,
|
||||
groupId: uuid,
|
||||
length: distance * 10,
|
||||
slopeAble: false,
|
||||
angle1: null,
|
||||
angle2: null,
|
||||
})
|
||||
|
||||
canvas.add(group)
|
||||
|
||||
@ -536,14 +536,7 @@ export function useModule() {
|
||||
|
||||
const moduleRowRemove = (type) => {
|
||||
const activeModule = canvas.getObjects().filter((obj) => canvas.getActiveObjects()[0].id === obj.id)[0]
|
||||
if (activeModule.circuit) {
|
||||
swalFire({
|
||||
title: getMessage('can.not.remove.module'),
|
||||
icon: 'error',
|
||||
type: 'alert',
|
||||
})
|
||||
return
|
||||
}
|
||||
c
|
||||
const rowModules = getRowModules(activeModule)
|
||||
const otherModules = getOtherModules(rowModules)
|
||||
const objects = getObjects()
|
||||
@ -671,6 +664,9 @@ export function useModule() {
|
||||
const moduleSetupSurface = canvas
|
||||
.getObjects()
|
||||
.filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && obj.id === activeModule.surfaceId)[0]
|
||||
if (moduleSetupSurface.modules.filter((module) => module.circuit).length > 0) {
|
||||
return
|
||||
}
|
||||
let width = -1
|
||||
let isWarning = false
|
||||
if (targetModules.length === 0) {
|
||||
@ -776,6 +772,9 @@ export function useModule() {
|
||||
const moduleSetupSurface = canvas
|
||||
.getObjects()
|
||||
.filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && obj.id === activeModule.surfaceId)[0]
|
||||
if (moduleSetupSurface.modules.filter((module) => module.circuit).length > 0) {
|
||||
return
|
||||
}
|
||||
let height = -1
|
||||
let isWarning = false
|
||||
canvas.discardActiveObject()
|
||||
@ -855,6 +854,14 @@ export function useModule() {
|
||||
}
|
||||
|
||||
const alignModule = (type, surfaceArray) => {
|
||||
if (activeModule.circuit) {
|
||||
swalFire({
|
||||
title: getMessage('can.not.remove.module'),
|
||||
icon: 'error',
|
||||
type: 'alert',
|
||||
})
|
||||
return
|
||||
}
|
||||
surfaceArray.forEach((surface) => {
|
||||
const modules = surface.modules
|
||||
|
||||
@ -939,6 +946,7 @@ export function useModule() {
|
||||
.getObjects()
|
||||
.filter((module) => module.name === POLYGON_TYPE.MODULE && module.surfaceId === surface.id)
|
||||
.forEach((module) => {
|
||||
canvas.remove(module.circuit)
|
||||
canvas.remove(module)
|
||||
})
|
||||
})
|
||||
|
||||
@ -706,12 +706,68 @@ export function useContextMenu() {
|
||||
{
|
||||
id: 'moduleVerticalCenterAlign',
|
||||
name: getMessage('contextmenu.module.vertical.align'),
|
||||
fn: () => alignModule(MODULE_ALIGN_TYPE.VERTICAL, currentObject.arrayData ?? [currentObject]),
|
||||
fn: () => {
|
||||
if (currentObject.arrayData) {
|
||||
let existCircuit = false
|
||||
currentObject.arrayData.forEach((surface) => {
|
||||
surface.modules.forEach((module) => {
|
||||
if (module.circuit) existCircuit = true
|
||||
})
|
||||
})
|
||||
if (existCircuit) {
|
||||
swalFire({
|
||||
title: getMessage('can.not.move.module'),
|
||||
icon: 'error',
|
||||
type: 'alert',
|
||||
})
|
||||
return
|
||||
}
|
||||
} else {
|
||||
const allocatedModules = currentObject.modules.filter((module) => module.circuit !== null)
|
||||
if (allocatedModules.length > 0) {
|
||||
swalFire({
|
||||
title: getMessage('can.not.move.module'),
|
||||
icon: 'error',
|
||||
type: 'alert',
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
alignModule(MODULE_ALIGN_TYPE.VERTICAL, currentObject.arrayData ?? [currentObject])
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'moduleHorizonCenterAlign',
|
||||
name: getMessage('contextmenu.module.horizon.align'),
|
||||
fn: () => alignModule(MODULE_ALIGN_TYPE.HORIZONTAL, currentObject.arrayData ?? [currentObject]),
|
||||
fn: () => {
|
||||
if (currentObject.arrayData) {
|
||||
let existCircuit = false
|
||||
currentObject.arrayData.forEach((surface) => {
|
||||
surface.modules.forEach((module) => {
|
||||
if (module.circuit) existCircuit = true
|
||||
})
|
||||
})
|
||||
if (existCircuit) {
|
||||
swalFire({
|
||||
title: getMessage('can.not.move.module'),
|
||||
icon: 'error',
|
||||
type: 'alert',
|
||||
})
|
||||
return
|
||||
}
|
||||
} else {
|
||||
const allocatedModules = currentObject.modules.filter((module) => module.circuit !== null)
|
||||
if (allocatedModules.length > 0) {
|
||||
swalFire({
|
||||
title: getMessage('can.not.move.module'),
|
||||
icon: 'error',
|
||||
type: 'alert',
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
alignModule(MODULE_ALIGN_TYPE.HORIZONTAL, currentObject.arrayData ?? [currentObject])
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'moduleRemove',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user