feat: implement material validation UI in CleanerPage
New Features: - Material validation from database (full table or filtered by ProductionID) - Checkbox selection for materials to delete with auto-select for marked items - Manager-based filtering (Admin only) - Two-phase deletion: confirm (mark in DB) + execute (delete from ERP) - Export results to CSV - Hide/show checked items feature (User mode) - Share Production IDs between ExtractorPage and CleanerPage - Persist page state using sessionStorage Bug Fixes: - Fix MySQL query rowCount for INSERT/UPDATE/DELETE operations - Add AUTO_INCREMENT to MaterialsToBeDeleted.ID (preserved 43 records) - Add UNIQUE constraint on MaterialsToBeDeleted.MaterialCode Files Added: - src/main/ipc/validation-handler.ts - src/main/types/validation.types.ts - src/main/services/database/materials-to-be-deleted-dao.ts - src/main/services/database/discrete-material-plan-dao.ts Files Modified: - src/renderer/src/pages/CleanerPage.tsx (complete rewrite) - src/renderer/src/pages/ExtractorPage.tsx - src/renderer/src/App.tsx (add navigation tabs) - src/main/services/database/mysql.ts - src/preload/index.ts + index.d.ts
This commit is contained in:
@@ -78,17 +78,27 @@ export class MySqlService {
|
||||
}
|
||||
|
||||
try {
|
||||
const [rows, fields] = await this.connection.execute(sql, params)
|
||||
const [result, fields] = await this.connection.execute(sql, params)
|
||||
|
||||
// Convert rows to plain objects and extract column names
|
||||
const columns = fields.map((field) => field.name)
|
||||
const rowCount = Array.isArray(rows) ? rows.length : 0
|
||||
// Convert to plain objects and extract column names
|
||||
const columns = Array.isArray(fields) ? fields.map((field) => field.name) : []
|
||||
|
||||
// Type assertion for rows - mysql2 returns different types based on query
|
||||
const typedRows = Array.isArray(rows) ? (rows as Record<string, unknown>[]) : []
|
||||
// Handle different result types
|
||||
let rows: Record<string, unknown>[] = []
|
||||
let rowCount = 0
|
||||
|
||||
if (Array.isArray(result)) {
|
||||
// SELECT query - result is an array of rows
|
||||
rows = result as Record<string, unknown>[]
|
||||
rowCount = rows.length
|
||||
} else if (typeof result === 'object' && result !== null) {
|
||||
// INSERT/UPDATE/DELETE query - result is OkPacket
|
||||
const okPacket = result as any
|
||||
rowCount = okPacket.affectedRows || okPacket.changedRows || 0
|
||||
}
|
||||
|
||||
return {
|
||||
rows: typedRows,
|
||||
rows,
|
||||
columns,
|
||||
rowCount
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user