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

Reviewed-on: #319
This commit is contained in:
ysCha 2025-09-02 17:29:44 +09:00
commit 7193d26bf5
3 changed files with 14 additions and 5 deletions

View File

@ -2,6 +2,7 @@ import { fabric } from 'fabric'
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import { getDirectionByPoint } from '@/util/canvas-util' import { getDirectionByPoint } from '@/util/canvas-util'
import { calcLinePlaneSize } from '@/util/qpolygon-utils' import { calcLinePlaneSize } from '@/util/qpolygon-utils'
import { logger } from '@/util/logger'
export const QLine = fabric.util.createClass(fabric.Line, { export const QLine = fabric.util.createClass(fabric.Line, {
type: 'QLine', type: 'QLine',
@ -69,7 +70,14 @@ export const QLine = fabric.util.createClass(fabric.Line, {
}, },
setLength() { setLength() {
this.length = calcLinePlaneSize(this) / 10 // Ensure all required properties are valid numbers
const { x1, y1, x2, y2 } = this;
if (isNaN(x1) || isNaN(y1) || isNaN(x2) || isNaN(y2)) {
logger.error('Invalid coordinates in QLine:', { x1, y1, x2, y2 });
this.length = 0;
return;
}
this.length = calcLinePlaneSize({ x1, y1, x2, y2 }) / 10;
}, },
addLengthText() { addLengthText() {

View File

@ -169,6 +169,7 @@ const Placement = forwardRef((props, refs) => {
<div className="roof-module-table"> <div className="roof-module-table">
<table> <table>
<thead> <thead>
<tr>
{moduleData.header.map((data) => ( {moduleData.header.map((data) => (
<th key={data.prop} style={{ width: data.width ? data.width : '' }}> <th key={data.prop} style={{ width: data.width ? data.width : '' }}>
{data.type === 'check' ? ( {data.type === 'check' ? (
@ -181,6 +182,7 @@ const Placement = forwardRef((props, refs) => {
)} )}
</th> </th>
))} ))}
</tr>
</thead> </thead>
<tbody> <tbody>
{selectedModules?.itemList && {selectedModules?.itemList &&
@ -216,7 +218,7 @@ const Placement = forwardRef((props, refs) => {
className="input-origin block" className="input-origin block"
name="row" name="row"
value={props.layoutSetup[index]?.row ?? 1} value={props.layoutSetup[index]?.row ?? 1}
defaultValue={0} //defaultValue={0}
onChange={(e) => handleLayoutSetup(e, item.itemId, index)} onChange={(e) => handleLayoutSetup(e, item.itemId, index)}
/> />
</div> </div>
@ -228,7 +230,7 @@ const Placement = forwardRef((props, refs) => {
className="input-origin block" className="input-origin block"
name="col" name="col"
value={props.layoutSetup[index]?.col ?? 1} value={props.layoutSetup[index]?.col ?? 1}
defaultValue={0} //defaultValue={0}
onChange={(e) => handleLayoutSetup(e, item.itemId, index)} onChange={(e) => handleLayoutSetup(e, item.itemId, index)}
/> />
</div> </div>

View File

@ -86,7 +86,7 @@ export default function RoofAllocationSetting(props) {
return ( return (
<div className="grid-option-box" key={index}> <div className="grid-option-box" key={index}>
<div className="d-check-radio pop no-text"> <div className="d-check-radio pop no-text">
<input type="radio" name="radio01" checked={roof.selected && 'checked'} readOnly={true} /> <input type="radio" name="radio01" checked={roof.selected} readOnly />
<label <label
htmlFor="ra01" htmlFor="ra01"
onClick={(e) => { onClick={(e) => {
@ -213,7 +213,6 @@ export default function RoofAllocationSetting(props) {
handleChangePitch(e, index) handleChangePitch(e, index)
}} }}
value={currentAngleType === 'slope' ? roof.pitch : roof.angle} value={currentAngleType === 'slope' ? roof.pitch : roof.angle}
defaultValue={currentAngleType === 'slope' ? roof.pitch : roof.angle}
/> />
</div> </div>
<span className="absol">{pitchText}</span> <span className="absol">{pitchText}</span>