fix description field

This commit is contained in:
2025-10-24 14:53:02 +07:00
parent 50d040953f
commit 7eabb2c7c8
2 changed files with 33 additions and 17 deletions

View File

@@ -34,9 +34,9 @@ const DetailTag = (props) => {
lim_high: '', lim_high: '',
lim_high_crash: '', lim_high_crash: '',
device_id: null, device_id: null,
description: '', tag_description: '',
sub_section_id: null, plant_sub_section_id: null,
}; };
const [formData, setformData] = useState(defaultData); const [formData, setformData] = useState(defaultData);
@@ -148,8 +148,15 @@ const DetailTag = (props) => {
payload.unit = formData.unit.trim(); payload.unit = formData.unit.trim();
} }
// Add device_id - backend requires this field even if null // Add tag_description only if it has a value
payload.device_id = formData.device_id ? parseInt(formData.device_id) : null; if (formData.tag_description && formData.tag_description.trim() !== '') {
payload.tag_description = formData.tag_description.trim();
}
// Add device_id only if it has a value
if (formData.device_id) {
payload.device_id = parseInt(formData.device_id);
}
// Add limit fields only if they have values // Add limit fields only if they have values
if (formData.lim_low_crash !== '' && formData.lim_low_crash !== null) { if (formData.lim_low_crash !== '' && formData.lim_low_crash !== null) {
@@ -165,8 +172,10 @@ const DetailTag = (props) => {
payload.lim_high_crash = parseFloat(formData.lim_high_crash); payload.lim_high_crash = parseFloat(formData.lim_high_crash);
} }
// Add sub_section_id - backend requires this field even if null // Add plant_sub_section_id only if it has a value
payload.sub_section_id = formData.sub_section_id ? parseInt(formData.sub_section_id) : null; if (formData.plant_sub_section_id) {
payload.plant_sub_section_id = parseInt(formData.plant_sub_section_id);
}
try { try {
const response = const response =
@@ -510,9 +519,9 @@ const DetailTag = (props) => {
<Select <Select
style={{ width: '100%' }} style={{ width: '100%' }}
placeholder="Select Plant Sub Section" placeholder="Select Plant Sub Section"
value={formData.sub_section_id || undefined} value={formData.plant_sub_section_id || undefined}
onChange={(value) => onChange={(value) =>
handleSelectChange('sub_section_id', value) handleSelectChange('plant_sub_section_id', value)
} }
disabled={props.readOnly} disabled={props.readOnly}
loading={loadingPlantSubSections} loading={loadingPlantSubSections}
@@ -527,10 +536,10 @@ const DetailTag = (props) => {
> >
{plantSubSectionList.map((section) => ( {plantSubSectionList.map((section) => (
<Select.Option <Select.Option
key={section.sub_section_id} key={section.plant_sub_section_id}
value={section.sub_section_id} value={section.plant_sub_section_id}
> >
{section.sub_section_name || ''} {section.plant_sub_section_name || ''}
</Select.Option> </Select.Option>
))} ))}
</Select> </Select>
@@ -688,8 +697,8 @@ const DetailTag = (props) => {
<div style={{ marginBottom: 12 }}> <div style={{ marginBottom: 12 }}>
<Text strong>Description</Text> <Text strong>Description</Text>
<Input.TextArea <Input.TextArea
name="description" name="tag_description"
value={formData.description} value={formData.tag_description}
onChange={handleInputChange} onChange={handleInputChange}
placeholder="Enter Description (Optional)" placeholder="Enter Description (Optional)"
readOnly={props.readOnly} readOnly={props.readOnly}

View File

@@ -43,7 +43,7 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [
title: 'Data Type', title: 'Data Type',
dataIndex: 'data_type', dataIndex: 'data_type',
key: 'data_type', key: 'data_type',
width: '10%', width: '8%',
render: (text) => text || '-', render: (text) => text || '-',
}, },
{ {
@@ -55,9 +55,9 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [
}, },
{ {
title: 'Sub Section', title: 'Sub Section',
dataIndex: 'sub_section_name', dataIndex: 'plant_sub_section_name',
key: 'sub_section_name', key: 'plant_sub_section_name',
width: '12%', width: '10%',
render: (text) => text || '-', render: (text) => text || '-',
}, },
{ {
@@ -67,6 +67,13 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [
width: '12%', width: '12%',
render: (text) => text || '-', render: (text) => text || '-',
}, },
{
title: 'Description',
dataIndex: 'tag_description',
key: 'tag_description',
width: '12%',
render: (text) => text || '-',
},
{ {
title: 'Status', title: 'Status',
dataIndex: 'is_active', dataIndex: 'is_active',