feat: add material type management feature
- Add MaterialTypeManagementDialog component for managing material type keywords - Add MaterialsTypeToBeDeletedDAO for database operations - Add material-type-handler IPC handlers - Update CleanerPage with type management button - Add database fix scripts for AUTO_INCREMENT - Update documentation for settings partial save and validation flow Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
This commit is contained in:
51
src/preload/index.d.ts
vendored
51
src/preload/index.d.ts
vendored
@@ -8,7 +8,12 @@ import type {
|
||||
UserSelectionResponse,
|
||||
CurrentUserResponse
|
||||
} from '../main/ipc/auth-handler'
|
||||
import type { ValidationRequest, ValidationResponse } from '../main/types/validation.types'
|
||||
import type {
|
||||
ValidationRequest,
|
||||
ValidationResponse,
|
||||
MaterialTypeRecord,
|
||||
MaterialTypeBatchRequest
|
||||
} from '../main/types/validation.types'
|
||||
import type {
|
||||
SettingsData,
|
||||
UserType,
|
||||
@@ -178,6 +183,49 @@ export interface SettingsAPI {
|
||||
testDbConnection: () => Promise<ConnectionTestResult>
|
||||
}
|
||||
|
||||
/**
|
||||
* Material Type API
|
||||
*/
|
||||
export interface MaterialTypeAPI {
|
||||
/**
|
||||
* Get all material type records
|
||||
*/
|
||||
getAll: () => Promise<{ success: boolean; data?: MaterialTypeRecord[]; error?: string }>
|
||||
/**
|
||||
* Get material types by manager
|
||||
* @param managerName - Manager name
|
||||
*/
|
||||
getByManager: (
|
||||
managerName: string
|
||||
) => Promise<{ success: boolean; data?: MaterialTypeRecord[]; error?: string }>
|
||||
/**
|
||||
* Get list of managers
|
||||
*/
|
||||
getManagers: () => Promise<{ success: boolean; data?: string[]; error?: string }>
|
||||
/**
|
||||
* Upsert (insert or update) a material type record
|
||||
*/
|
||||
upsert: (
|
||||
materialName: string,
|
||||
managerName: string
|
||||
) => Promise<{ success: boolean; error?: string }>
|
||||
/**
|
||||
* Delete a material type record
|
||||
*/
|
||||
delete: (
|
||||
materialName: string,
|
||||
managerName: string
|
||||
) => Promise<{ success: boolean; error?: string }>
|
||||
/**
|
||||
* Batch operation for material types
|
||||
*/
|
||||
upsertBatch: (request: MaterialTypeBatchRequest) => Promise<{
|
||||
success: boolean
|
||||
stats?: { total: number; success: number; failed: number }
|
||||
error?: string
|
||||
}>
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
electron: {
|
||||
@@ -205,6 +253,7 @@ declare global {
|
||||
validation: ValidationAPI
|
||||
materials: MaterialsAPI
|
||||
settings: SettingsAPI
|
||||
materialType: MaterialTypeAPI
|
||||
}
|
||||
api: unknown
|
||||
}
|
||||
|
||||
@@ -6,7 +6,11 @@ import type { CleanerInput } from '../main/types/cleaner.types'
|
||||
import type { ResolverInput } from '../main/ipc/resolver-handler'
|
||||
import type { LoginRequest } from '../main/ipc/auth-handler'
|
||||
import type { UserInfo } from '../main/types/user.types'
|
||||
import type { ValidationRequest } from '../main/types/validation.types'
|
||||
import type {
|
||||
ValidationRequest,
|
||||
MaterialTypeRecord,
|
||||
MaterialTypeBatchRequest
|
||||
} from '../main/types/validation.types'
|
||||
import type { SettingsData } from '../main/types/settings.types'
|
||||
|
||||
// Custom APIs for renderer
|
||||
@@ -94,6 +98,20 @@ const api = {
|
||||
resetDefaults: () => ipcRenderer.invoke('settings:resetDefaults'),
|
||||
testErpConnection: () => ipcRenderer.invoke('settings:testErpConnection'),
|
||||
testDbConnection: () => ipcRenderer.invoke('settings:testDbConnection')
|
||||
},
|
||||
|
||||
// Material Type service
|
||||
materialType: {
|
||||
getAll: () => ipcRenderer.invoke('materialType:getAll'),
|
||||
getByManager: (managerName: string) =>
|
||||
ipcRenderer.invoke('materialType:getByManager', managerName),
|
||||
getManagers: () => ipcRenderer.invoke('materialType:getManagers'),
|
||||
upsert: (materialName: string, managerName: string) =>
|
||||
ipcRenderer.invoke('materialType:upsert', { materialName, managerName }),
|
||||
delete: (materialName: string, managerName: string) =>
|
||||
ipcRenderer.invoke('materialType:delete', { materialName, managerName }),
|
||||
upsertBatch: (request: MaterialTypeBatchRequest) =>
|
||||
ipcRenderer.invoke('materialType:upsertBatch', request)
|
||||
}
|
||||
} as const
|
||||
|
||||
|
||||
Reference in New Issue
Block a user