181 lines
5.9 KiB
TypeScript
181 lines
5.9 KiB
TypeScript
import request from '~/utils/request'
|
|
|
|
export interface ProduceExceptionSetting {
|
|
id: string | number
|
|
parent_id?: string | number | null
|
|
setting_type: 'type' | 'reason' | 'issue' | string
|
|
code?: string
|
|
name: string
|
|
sort?: number
|
|
frequency?: number
|
|
remark?: string
|
|
}
|
|
|
|
export interface ProduceExceptionRecord {
|
|
id: string | number
|
|
order_no?: string
|
|
user_code?: string
|
|
reporter?: string
|
|
type_id?: string | number
|
|
type_name?: string
|
|
reason_id?: string | number
|
|
reason_name?: string
|
|
issue_id?: string | number | null
|
|
issue_name?: string
|
|
images?: string[]
|
|
remark?: string
|
|
status?: number
|
|
status_name?: string
|
|
reported_date?: string
|
|
handled_date?: string
|
|
handler?: string
|
|
}
|
|
|
|
export interface ProduceRepairTask {
|
|
id: string | number
|
|
device_no: string
|
|
type_name?: string
|
|
reason_name?: string
|
|
issue_name?: string
|
|
reporter?: string
|
|
user_code?: string
|
|
reported_date?: string
|
|
status?: number
|
|
status_name?: string
|
|
}
|
|
|
|
export interface ProduceRepairPart {
|
|
product_code: string
|
|
product_name?: string
|
|
category_id?: string | number
|
|
category_name?: string
|
|
source?: 'new' | 'after_sales' | 'refurbished' | string
|
|
quantity?: number
|
|
fault_description_ids?: Array<string | number>
|
|
}
|
|
|
|
export interface ProduceScanRecord {
|
|
id: string | number
|
|
process_id?: string | number | null
|
|
step_id?: string | number | null
|
|
process_name?: string
|
|
step_name?: string
|
|
operator?: string
|
|
user_code?: string
|
|
}
|
|
|
|
export type ProduceOperationFaultStep = string | number
|
|
|
|
export type ProduceResponsibleOperator = string | number
|
|
|
|
export interface ProduceRepairRecordPayload {
|
|
exception_id: string | number
|
|
user_code: string
|
|
repair_result: string
|
|
images?: string[]
|
|
category_ids?: Array<string | number>
|
|
parts?: ProduceRepairPart[]
|
|
operation_fault_steps?: ProduceOperationFaultStep[]
|
|
responsible_operators?: ProduceResponsibleOperator[]
|
|
remark?: string
|
|
}
|
|
|
|
export function getExceptionSettings() {
|
|
return request.get<ProduceExceptionSetting[]>('/produce/exception/settings', {}, { showErrorMessage: false })
|
|
}
|
|
|
|
export function getExceptionStatistics(params: Record<string, any> = {}) {
|
|
return request.get<{ pending: number; review: number; done: number }>('/produce/exception/statistics', params, { showErrorMessage: false })
|
|
}
|
|
|
|
export function getRecentExceptions(params: Record<string, any> = {}) {
|
|
return request.get<ProduceExceptionRecord[]>('/produce/exception/recent', params, { showErrorMessage: false })
|
|
}
|
|
|
|
export function checkExceptionOrder(orderNo: string) {
|
|
return request.get<Record<string, any>>('/produce/exception/order-check', { order_no: orderNo.trim() }, { showErrorMessage: false })
|
|
}
|
|
|
|
export function checkMemberUser(userCode: string) {
|
|
return request.get<{ id: number; username: string; nickname: string }>('/produce/member-user/check', { user_code: userCode.trim() }, { showErrorMessage: false })
|
|
}
|
|
|
|
export function submitExceptionRecord(data: Record<string, any>) {
|
|
return request.post<{ code: number; msg: string; data?: { id: string | number } }>('/produce/exception/record', data, {
|
|
showErrorMessage: false,
|
|
returnFullResponse: true,
|
|
})
|
|
}
|
|
|
|
export function getRepairTasks(params: Record<string, any> = {}) {
|
|
return request.get<ProduceRepairTask[]>('/produce/repair-record/tasks', params, { showErrorMessage: false })
|
|
}
|
|
|
|
export function getRepairStatistics(params: Record<string, any> = {}) {
|
|
return request.get<{ pending: number; processing: number; completed_today: number }>('/produce/repair-record/statistics', params, { showErrorMessage: false })
|
|
}
|
|
|
|
export function getRepairTask(deviceNo: string) {
|
|
return request.get<ProduceRepairTask>('/produce/exception/repair-task', { device_no: deviceNo.trim() }, { showErrorMessage: false })
|
|
}
|
|
|
|
export function getScanRecords(params: Record<string, any> = {}) {
|
|
return request.get<{ items: ProduceScanRecord[]; total: number }>('/produce/scan-data', {
|
|
limit: 50,
|
|
page: 1,
|
|
...params,
|
|
}, { showErrorMessage: false })
|
|
}
|
|
|
|
export function getMaterialCategories() {
|
|
return request.get<Array<{ id: string | number; category_name: string }>>('/produce/scanapp/material-category', {}, { showErrorMessage: false })
|
|
}
|
|
|
|
export function getFaultDescriptionOptions(categoryIds: Array<string | number>) {
|
|
return request.get<Array<{ id: string | number; category_id: string | number; description: string }>>(
|
|
'/produce/hardware-fault-description/options',
|
|
{ category_ids: categoryIds.join(',') },
|
|
{ showErrorMessage: false },
|
|
)
|
|
}
|
|
|
|
export function lookupMaterial(productCode: string) {
|
|
return request.get<{
|
|
id: string | number
|
|
category_id: string | number
|
|
category_name: string
|
|
product_code: string
|
|
product_name: string
|
|
}>('/produce/material/lookup', { product_code: productCode.trim() }, { showErrorMessage: false })
|
|
}
|
|
|
|
export function searchMaterials(productCode = '', productName = '', categoryId: string | number = '', page = 1, limit = 10) {
|
|
return request.get<{
|
|
items: Array<{
|
|
id: string | number
|
|
category_id: string | number
|
|
category_name: string
|
|
product_code: string
|
|
product_name: string
|
|
}>
|
|
total: number
|
|
page: number
|
|
limit: number
|
|
}>('/produce/material/options', { product_code: productCode.trim(), product_name: productName.trim(), category_id: categoryId, page, limit }, { showErrorMessage: false })
|
|
}
|
|
|
|
export function submitRepairRecord(data: ProduceRepairRecordPayload) {
|
|
return request.post<{ code: number; msg: string; data?: { id: string | number; repair_no: string } }>('/produce/repair-record/record', data, {
|
|
showErrorMessage: false,
|
|
returnFullResponse: true,
|
|
})
|
|
}
|
|
|
|
export async function uploadProduceImage(file: File, subDir: 'exception' | 'repair') {
|
|
const formData = new FormData()
|
|
formData.append('file', file)
|
|
formData.append('sub_dir', subDir)
|
|
const result = await request.upload<Record<string, any>>('/file/image', formData)
|
|
return result?.url || result?.full_url || result?.path || ''
|
|
}
|