feat:无法切换图片的bug修复,材料一栏重叠bug修复
This commit is contained in:
parent
1d205a22c5
commit
d28341cd24
2
app.js
2
app.js
@ -221,7 +221,7 @@ function App() {
|
||||
if (currentDrawingId !== targetDrawingId) {
|
||||
setCurrentDrawingId(targetDrawingId);
|
||||
}
|
||||
}, [selectedItemId, currentDrawingId]);
|
||||
}, [selectedItemId]);
|
||||
|
||||
const handleItemRename = (oldId, newId) => {
|
||||
if (oldId === '__ROOT__') {
|
||||
|
||||
@ -6,30 +6,6 @@ function DataEditor({ item, items, setItems }) {
|
||||
);
|
||||
}
|
||||
|
||||
const isRoot = item.id === '__ROOT__';
|
||||
|
||||
if (isRoot) {
|
||||
return React.createElement('div', { className: 'workspace-panel p-4 h-full' },
|
||||
React.createElement('h2', { className: 'text-lg font-semibold mb-4' }, '编辑总装图'),
|
||||
React.createElement('div', { className: 'space-y-4' },
|
||||
React.createElement('div', {},
|
||||
React.createElement('label', { className: 'block text-sm font-medium text-gray-700 mb-1' }, '总装图名称'),
|
||||
React.createElement('input', {
|
||||
type: 'text',
|
||||
name: 'name',
|
||||
value: item.name,
|
||||
onChange: (e) => setItems(prev => ({
|
||||
...prev,
|
||||
['__ROOT__']: { ...prev['__ROOT__'], name: e.target.value }
|
||||
})),
|
||||
className: 'form-input'
|
||||
})
|
||||
),
|
||||
React.createElement('p', { className: 'text-xs text-gray-500 mt-1' }, '这是项目的根节点,只可修改名称。')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const handleInputChange = (e) => {
|
||||
const { name, value } = e.target;
|
||||
const isNumber = ['quantity', 'weight'].includes(name);
|
||||
@ -49,6 +25,68 @@ function DataEditor({ item, items, setItems }) {
|
||||
}));
|
||||
};
|
||||
|
||||
const isRoot = item.id === '__ROOT__';
|
||||
|
||||
if (isRoot) {
|
||||
return React.createElement('div', { className: 'workspace-panel p-4 h-full' },
|
||||
React.createElement('h2', { className: 'text-lg font-semibold mb-1' }, '编辑总装图'),
|
||||
React.createElement('div', { className: 'space-y-4' },
|
||||
React.createElement('div', {},
|
||||
React.createElement('label', { className: 'block text-sm font-medium text-gray-700 mb-1' }, '总装图名称'),
|
||||
React.createElement('input', {
|
||||
type: 'text', name: 'name', value: item.name || '', onChange: handleInputChange, className: 'form-input'
|
||||
})
|
||||
),
|
||||
React.createElement('div', { className: 'grid grid-cols-2 gap-3' },
|
||||
React.createElement('div', {},
|
||||
React.createElement('label', { className: 'block text-sm font-medium text-gray-700 mb-1' }, '中文名称'),
|
||||
React.createElement('input', {
|
||||
type: 'text', name: 'chinese_name', value: item.chinese_name || '', onChange: handleInputChange, className: 'form-input', placeholder: '中文名称'
|
||||
})
|
||||
),
|
||||
React.createElement('div', {},
|
||||
React.createElement('label', { className: 'block text-sm font-medium text-gray-700 mb-1' }, '英文名称'),
|
||||
React.createElement('input', {
|
||||
type: 'text', name: 'english_name', value: item.english_name || '', onChange: handleInputChange, className: 'form-input', placeholder: 'English Name'
|
||||
})
|
||||
)
|
||||
),
|
||||
React.createElement('div', {},
|
||||
React.createElement('label', { className: 'block text-sm font-medium text-gray-700 mb-1' }, '规格描述'),
|
||||
React.createElement('input', {
|
||||
type: 'text', name: 'specification', value: item.specification || '', onChange: handleInputChange, className: 'form-input', placeholder: '规格与技术要求'
|
||||
})
|
||||
),
|
||||
React.createElement('div', { className: 'grid grid-cols-2 gap-3' },
|
||||
React.createElement('div', {},
|
||||
React.createElement('label', { className: 'block text-sm font-medium text-gray-700 mb-1' }, '材料'),
|
||||
React.createElement('input', {
|
||||
type: 'text', name: 'material', value: item.material || '', onChange: handleInputChange, className: 'form-input', placeholder: '如: Q235'
|
||||
})
|
||||
),
|
||||
React.createElement('div', {},
|
||||
React.createElement('label', { className: 'block text-sm font-medium text-gray-700 mb-1' }, '比例'),
|
||||
React.createElement('input', {
|
||||
type: 'text', name: 'scale', value: item.scale || '1:1', onChange: handleInputChange, className: 'form-input'
|
||||
})
|
||||
)
|
||||
),
|
||||
React.createElement('div', {},
|
||||
React.createElement('label', { className: 'block text-sm font-medium text-gray-700 mb-1' }, '质量 (kg)'),
|
||||
React.createElement('input', {
|
||||
type: 'number', name: 'weight', value: item.weight || 0, onChange: handleInputChange, className: 'form-input bg-gray-100', readOnly: true, title: '由子项自动汇总'
|
||||
})
|
||||
),
|
||||
React.createElement('div', {},
|
||||
React.createElement('label', { className: 'block text-sm font-medium text-gray-700 mb-1' }, '备注'),
|
||||
React.createElement('textarea', {
|
||||
name: 'remark', value: item.remark || '', onChange: handleInputChange, className: 'form-input resize-none', rows: 2, placeholder: '其他说明信息'
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const hasChildren = Array.isArray(item.children) && item.children.length > 0;
|
||||
const isLeafPart = !isRoot && !hasChildren;
|
||||
const isAssemblyPart = !isRoot && hasChildren;
|
||||
|
||||
@ -94,22 +94,35 @@ function GraphicalTable({ template, items, allItems, drawings }) {
|
||||
'装配图号': item.assyDwgNo || (allItems[item.parentId] ? (drawings[allItems[item.parentId]?.drawingId]?.drawingNumber || '') : '')
|
||||
};
|
||||
const dataItem = cell[normName];
|
||||
return colDef.text_definitions.map(textDef => {
|
||||
let content = '';
|
||||
if (normName === '名称' && typeof dataItem === 'object' && dataItem !== null) {
|
||||
content = dataItem[textDef.data_key] || '';
|
||||
} else {
|
||||
content = dataItem;
|
||||
}
|
||||
if (content === null || content === undefined) return null;
|
||||
return React.createElement(SvgText, {
|
||||
key: `${item.id}-${normName}-${textDef.data_key || 'main'}`,
|
||||
content,
|
||||
x: colDef.relative_x_start + textDef.relative_pos[0],
|
||||
y: textDef.relative_pos[1],
|
||||
height: textDef.height,
|
||||
alignment: textDef.alignment,
|
||||
const isObject = typeof dataItem === 'object' && dataItem !== null;
|
||||
|
||||
// 名称列:按定义分别渲染中文/英文/规格
|
||||
if (normName === '名称' && isObject) {
|
||||
return colDef.text_definitions.map(textDef => {
|
||||
const content = dataItem[textDef.data_key] || '';
|
||||
if (content === null || content === undefined || content === '') return null;
|
||||
return React.createElement(SvgText, {
|
||||
key: `${item.id}-${normName}-${textDef.data_key || 'main'}`,
|
||||
content,
|
||||
x: colDef.relative_x_start + textDef.relative_pos[0],
|
||||
y: textDef.relative_pos[1],
|
||||
height: textDef.height,
|
||||
alignment: textDef.alignment,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 非对象数据:仅渲染一个主文本,避免重复(例如材料为字符串)
|
||||
const primaryDef = colDef.text_definitions.find(td => td.data_key === 'main') || colDef.text_definitions[0];
|
||||
const content = dataItem;
|
||||
if (content === null || content === undefined) return null;
|
||||
return React.createElement(SvgText, {
|
||||
key: `${item.id}-${normName}-main` ,
|
||||
content,
|
||||
x: colDef.relative_x_start + primaryDef.relative_pos[0],
|
||||
y: primaryDef.relative_pos[1],
|
||||
height: primaryDef.height,
|
||||
alignment: primaryDef.alignment,
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user