feat: Calculate standard and tolerance values based on lower and upper limits in equipment inspection
- Implemented logic to derive standard and tolerance values from lower and upper limits when double-clicking on inspection items. - Enhanced user interaction by automatically calculating these values, improving data accuracy and usability in the inspection form. - These changes aim to streamline the inspection process and provide clearer insights into equipment metrics across multiple company implementations.
This commit is contained in:
@@ -624,8 +624,17 @@ export default function EquipmentInfoPage() {
|
||||
<TableBody>
|
||||
{inspections.map((item) => (
|
||||
<TableRow key={item.id} className="cursor-pointer hover:bg-primary/5" onDoubleClick={() => {
|
||||
const std = item.standard_value || "";
|
||||
const tol = item.tolerance || "";
|
||||
// lower/upper → standard/tolerance 역산
|
||||
const lower = item.lower_limit !== "" && item.lower_limit != null ? Number(item.lower_limit) : null;
|
||||
const upper = item.upper_limit !== "" && item.upper_limit != null ? Number(item.upper_limit) : null;
|
||||
let std = item.standard_value || "";
|
||||
let tol = item.tolerance || "";
|
||||
if (lower !== null && upper !== null && !isNaN(lower) && !isNaN(upper)) {
|
||||
const stdCalc = (lower + upper) / 2;
|
||||
const tolCalc = (upper - lower) / 2;
|
||||
std = String(stdCalc);
|
||||
tol = String(tolCalc);
|
||||
}
|
||||
setInspectionForm({ ...item, standard_value: std, tolerance: tol });
|
||||
setInspectionEditMode(true);
|
||||
setInspectionModalOpen(true);
|
||||
|
||||
@@ -624,8 +624,17 @@ export default function EquipmentInfoPage() {
|
||||
<TableBody>
|
||||
{inspections.map((item) => (
|
||||
<TableRow key={item.id} className="cursor-pointer hover:bg-primary/5" onDoubleClick={() => {
|
||||
const std = item.standard_value || "";
|
||||
const tol = item.tolerance || "";
|
||||
// lower/upper → standard/tolerance 역산
|
||||
const lower = item.lower_limit !== "" && item.lower_limit != null ? Number(item.lower_limit) : null;
|
||||
const upper = item.upper_limit !== "" && item.upper_limit != null ? Number(item.upper_limit) : null;
|
||||
let std = item.standard_value || "";
|
||||
let tol = item.tolerance || "";
|
||||
if (lower !== null && upper !== null && !isNaN(lower) && !isNaN(upper)) {
|
||||
const stdCalc = (lower + upper) / 2;
|
||||
const tolCalc = (upper - lower) / 2;
|
||||
std = String(stdCalc);
|
||||
tol = String(tolCalc);
|
||||
}
|
||||
setInspectionForm({ ...item, standard_value: std, tolerance: tol });
|
||||
setInspectionEditMode(true);
|
||||
setInspectionModalOpen(true);
|
||||
|
||||
@@ -624,8 +624,17 @@ export default function EquipmentInfoPage() {
|
||||
<TableBody>
|
||||
{inspections.map((item) => (
|
||||
<TableRow key={item.id} className="cursor-pointer hover:bg-primary/5" onDoubleClick={() => {
|
||||
const std = item.standard_value || "";
|
||||
const tol = item.tolerance || "";
|
||||
// lower/upper → standard/tolerance 역산
|
||||
const lower = item.lower_limit !== "" && item.lower_limit != null ? Number(item.lower_limit) : null;
|
||||
const upper = item.upper_limit !== "" && item.upper_limit != null ? Number(item.upper_limit) : null;
|
||||
let std = item.standard_value || "";
|
||||
let tol = item.tolerance || "";
|
||||
if (lower !== null && upper !== null && !isNaN(lower) && !isNaN(upper)) {
|
||||
const stdCalc = (lower + upper) / 2;
|
||||
const tolCalc = (upper - lower) / 2;
|
||||
std = String(stdCalc);
|
||||
tol = String(tolCalc);
|
||||
}
|
||||
setInspectionForm({ ...item, standard_value: std, tolerance: tol });
|
||||
setInspectionEditMode(true);
|
||||
setInspectionModalOpen(true);
|
||||
|
||||
@@ -624,8 +624,17 @@ export default function EquipmentInfoPage() {
|
||||
<TableBody>
|
||||
{inspections.map((item) => (
|
||||
<TableRow key={item.id} className="cursor-pointer hover:bg-primary/5" onDoubleClick={() => {
|
||||
const std = item.standard_value || "";
|
||||
const tol = item.tolerance || "";
|
||||
// lower/upper → standard/tolerance 역산
|
||||
const lower = item.lower_limit !== "" && item.lower_limit != null ? Number(item.lower_limit) : null;
|
||||
const upper = item.upper_limit !== "" && item.upper_limit != null ? Number(item.upper_limit) : null;
|
||||
let std = item.standard_value || "";
|
||||
let tol = item.tolerance || "";
|
||||
if (lower !== null && upper !== null && !isNaN(lower) && !isNaN(upper)) {
|
||||
const stdCalc = (lower + upper) / 2;
|
||||
const tolCalc = (upper - lower) / 2;
|
||||
std = String(stdCalc);
|
||||
tol = String(tolCalc);
|
||||
}
|
||||
setInspectionForm({ ...item, standard_value: std, tolerance: tol });
|
||||
setInspectionEditMode(true);
|
||||
setInspectionModalOpen(true);
|
||||
|
||||
@@ -624,8 +624,17 @@ export default function EquipmentInfoPage() {
|
||||
<TableBody>
|
||||
{inspections.map((item) => (
|
||||
<TableRow key={item.id} className="cursor-pointer hover:bg-primary/5" onDoubleClick={() => {
|
||||
const std = item.standard_value || "";
|
||||
const tol = item.tolerance || "";
|
||||
// lower/upper → standard/tolerance 역산
|
||||
const lower = item.lower_limit !== "" && item.lower_limit != null ? Number(item.lower_limit) : null;
|
||||
const upper = item.upper_limit !== "" && item.upper_limit != null ? Number(item.upper_limit) : null;
|
||||
let std = item.standard_value || "";
|
||||
let tol = item.tolerance || "";
|
||||
if (lower !== null && upper !== null && !isNaN(lower) && !isNaN(upper)) {
|
||||
const stdCalc = (lower + upper) / 2;
|
||||
const tolCalc = (upper - lower) / 2;
|
||||
std = String(stdCalc);
|
||||
tol = String(tolCalc);
|
||||
}
|
||||
setInspectionForm({ ...item, standard_value: std, tolerance: tol });
|
||||
setInspectionEditMode(true);
|
||||
setInspectionModalOpen(true);
|
||||
|
||||
@@ -624,8 +624,17 @@ export default function EquipmentInfoPage() {
|
||||
<TableBody>
|
||||
{inspections.map((item) => (
|
||||
<TableRow key={item.id} className="cursor-pointer hover:bg-primary/5" onDoubleClick={() => {
|
||||
const std = item.standard_value || "";
|
||||
const tol = item.tolerance || "";
|
||||
// lower/upper → standard/tolerance 역산
|
||||
const lower = item.lower_limit !== "" && item.lower_limit != null ? Number(item.lower_limit) : null;
|
||||
const upper = item.upper_limit !== "" && item.upper_limit != null ? Number(item.upper_limit) : null;
|
||||
let std = item.standard_value || "";
|
||||
let tol = item.tolerance || "";
|
||||
if (lower !== null && upper !== null && !isNaN(lower) && !isNaN(upper)) {
|
||||
const stdCalc = (lower + upper) / 2;
|
||||
const tolCalc = (upper - lower) / 2;
|
||||
std = String(stdCalc);
|
||||
tol = String(tolCalc);
|
||||
}
|
||||
setInspectionForm({ ...item, standard_value: std, tolerance: tol });
|
||||
setInspectionEditMode(true);
|
||||
setInspectionModalOpen(true);
|
||||
|
||||
@@ -624,8 +624,17 @@ export default function EquipmentInfoPage() {
|
||||
<TableBody>
|
||||
{inspections.map((item) => (
|
||||
<TableRow key={item.id} className="cursor-pointer hover:bg-primary/5" onDoubleClick={() => {
|
||||
const std = item.standard_value || "";
|
||||
const tol = item.tolerance || "";
|
||||
// lower/upper → standard/tolerance 역산
|
||||
const lower = item.lower_limit !== "" && item.lower_limit != null ? Number(item.lower_limit) : null;
|
||||
const upper = item.upper_limit !== "" && item.upper_limit != null ? Number(item.upper_limit) : null;
|
||||
let std = item.standard_value || "";
|
||||
let tol = item.tolerance || "";
|
||||
if (lower !== null && upper !== null && !isNaN(lower) && !isNaN(upper)) {
|
||||
const stdCalc = (lower + upper) / 2;
|
||||
const tolCalc = (upper - lower) / 2;
|
||||
std = String(stdCalc);
|
||||
tol = String(tolCalc);
|
||||
}
|
||||
setInspectionForm({ ...item, standard_value: std, tolerance: tol });
|
||||
setInspectionEditMode(true);
|
||||
setInspectionModalOpen(true);
|
||||
|
||||
Reference in New Issue
Block a user