feat: add article and production modules
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
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_name?: string
|
||||
step_name?: string
|
||||
operator?: string
|
||||
user_code?: 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 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 submitRepairRecord(data: Record<string, any>) {
|
||||
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 || ''
|
||||
}
|
||||
Reference in New Issue
Block a user