Update save form
This commit is contained in:
parent
884c113a03
commit
1291d2c20c
|
|
@ -2475,6 +2475,21 @@ Ports Missing/Down: ${missing.length}\n\n`
|
||||||
</body>
|
</body>
|
||||||
</html>`
|
</html>`
|
||||||
|
|
||||||
|
// Save report to file (storage/report_sn/{SN}.html)
|
||||||
|
const reportSN = config?.inventory?.sn
|
||||||
|
if (reportSN) {
|
||||||
|
const reportDir = path.join(process.cwd(), 'storage', 'report_sn')
|
||||||
|
try {
|
||||||
|
if (!fs.existsSync(reportDir)) {
|
||||||
|
fs.mkdirSync(reportDir, { recursive: true })
|
||||||
|
}
|
||||||
|
const reportPath = path.join(reportDir, `${reportSN}.html`)
|
||||||
|
fs.writeFileSync(reportPath, body, 'utf-8')
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`Failed to save report for SN ${reportSN}:`, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.updateNote(config?.inventory?.sn, this.dataDPELP as DataDPELP)
|
this.updateNote(config?.inventory?.sn, this.dataDPELP as DataDPELP)
|
||||||
await sendMessageToMail(
|
await sendMessageToMail(
|
||||||
`[ATC] - [${config.stationName} - L${config.lineNumber}] - ${this.config.inventory?.pid} - ${this.config.inventory?.sn} - Test Summary`,
|
`[ATC] - [${config.stationName} - L${config.lineNumber}] - ${this.config.inventory?.pid} - ${this.config.inventory?.sn} - Test Summary`,
|
||||||
|
|
|
||||||
|
|
@ -85,15 +85,15 @@ const StationSetting = ({
|
||||||
form.setFieldValue("is_active", dataStation?.is_active);
|
form.setFieldValue("is_active", dataStation?.is_active);
|
||||||
form.setFieldValue(
|
form.setFieldValue(
|
||||||
"switch_control_port",
|
"switch_control_port",
|
||||||
dataStation.switch_control_port
|
dataStation.switch_control_port,
|
||||||
);
|
);
|
||||||
form.setFieldValue(
|
form.setFieldValue(
|
||||||
"switch_control_username",
|
"switch_control_username",
|
||||||
dataStation.switch_control_username
|
dataStation.switch_control_username,
|
||||||
);
|
);
|
||||||
form.setFieldValue(
|
form.setFieldValue(
|
||||||
"switch_control_password",
|
"switch_control_password",
|
||||||
dataStation.switch_control_password
|
dataStation.switch_control_password,
|
||||||
);
|
);
|
||||||
|
|
||||||
const dataLine = dataStation.lines.map((value) => ({
|
const dataLine = dataStation.lines.map((value) => ({
|
||||||
|
|
@ -116,7 +116,7 @@ const StationSetting = ({
|
||||||
const lastLine = lines[lines.length - 1];
|
const lastLine = lines[lines.length - 1];
|
||||||
if (lastLine?.lineNumber || lastLine?.port)
|
if (lastLine?.lineNumber || lastLine?.port)
|
||||||
setLines((pre) => [...pre, lineInit]);
|
setLines((pre) => [...pre, lineInit]);
|
||||||
}
|
} else setLines([lineInit]);
|
||||||
}, [lines]);
|
}, [lines]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -138,8 +138,8 @@ const StationSetting = ({
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setLines((pre) =>
|
setLines((pre) =>
|
||||||
pre.map((value, i) =>
|
pre.map((value, i) =>
|
||||||
i === index ? { ...value, lineNumber: Number(e!) } : value
|
i === index ? { ...value, lineNumber: Number(e!) } : value,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
@ -150,8 +150,8 @@ const StationSetting = ({
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setLines((pre) =>
|
setLines((pre) =>
|
||||||
pre.map((value, i) =>
|
pre.map((value, i) =>
|
||||||
i === index ? { ...value, port: Number(e!) } : value
|
i === index ? { ...value, port: Number(e!) } : value,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
@ -162,8 +162,8 @@ const StationSetting = ({
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setLines((pre) =>
|
setLines((pre) =>
|
||||||
pre.map((value, i) =>
|
pre.map((value, i) =>
|
||||||
i === index ? { ...value, lineClear: Number(e!) } : value
|
i === index ? { ...value, lineClear: Number(e!) } : value,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
@ -178,8 +178,8 @@ const StationSetting = ({
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setLines((pre) =>
|
setLines((pre) =>
|
||||||
pre.map((value, i) =>
|
pre.map((value, i) =>
|
||||||
i === index ? { ...value, apc_name: e! } : value
|
i === index ? { ...value, apc_name: e! } : value,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
@ -190,8 +190,8 @@ const StationSetting = ({
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setLines((pre) =>
|
setLines((pre) =>
|
||||||
pre.map((value, i) =>
|
pre.map((value, i) =>
|
||||||
i === index ? { ...value, outlet: Number(e!) } : value
|
i === index ? { ...value, outlet: Number(e!) } : value,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
@ -204,8 +204,8 @@ const StationSetting = ({
|
||||||
pre.map((value, i) =>
|
pre.map((value, i) =>
|
||||||
i === index
|
i === index
|
||||||
? { ...value, interface: e.target.value }
|
? { ...value, interface: e.target.value }
|
||||||
: value
|
: value,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
@ -286,16 +286,16 @@ const StationSetting = ({
|
||||||
dataStationLines?.find((value) => value?.id === el.id)
|
dataStationLines?.find((value) => value?.id === el.id)
|
||||||
? {
|
? {
|
||||||
...dataStationLines?.find(
|
...dataStationLines?.find(
|
||||||
(value: TLine) => value?.id === el.id
|
(value: TLine) => value?.id === el.id,
|
||||||
),
|
),
|
||||||
...el,
|
...el,
|
||||||
}
|
}
|
||||||
: el
|
: el,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
: el
|
: el,
|
||||||
)
|
)
|
||||||
: [...pre, station]
|
: [...pre, station],
|
||||||
);
|
);
|
||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
lineUpdate.forEach((el) => {
|
lineUpdate.forEach((el) => {
|
||||||
|
|
@ -345,7 +345,7 @@ const StationSetting = ({
|
||||||
const listStations = stations.filter((el) => el.id !== dataStation?.id);
|
const listStations = stations.filter((el) => el.id !== dataStation?.id);
|
||||||
setStations(listStations);
|
setStations(listStations);
|
||||||
setActiveTab(
|
setActiveTab(
|
||||||
listStations.length ? listStations[0]?.id.toString() : "0"
|
listStations.length ? listStations[0]?.id.toString() : "0",
|
||||||
);
|
);
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: "Success",
|
title: "Success",
|
||||||
|
|
@ -672,7 +672,7 @@ const StationSetting = ({
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
form.setFieldValue(
|
form.setFieldValue(
|
||||||
"switch_control_port",
|
"switch_control_port",
|
||||||
parseInt(e.toString())
|
parseInt(e.toString()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
@ -692,7 +692,7 @@ const StationSetting = ({
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
form.setFieldValue(
|
form.setFieldValue(
|
||||||
"switch_control_username",
|
"switch_control_username",
|
||||||
e.target.value
|
e.target.value,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
@ -704,7 +704,7 @@ const StationSetting = ({
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
form.setFieldValue(
|
form.setFieldValue(
|
||||||
"switch_control_password",
|
"switch_control_password",
|
||||||
e.target.value
|
e.target.value,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue