diff --git a/src/router/modules/remaining.ts b/src/router/modules/remaining.ts index 986b6360..fdb8c006 100644 --- a/src/router/modules/remaining.ts +++ b/src/router/modules/remaining.ts @@ -579,6 +579,25 @@ const remainingRouter: AppRouteRecordRaw[] = [ } ] }, + { + path: '/erp', + component: Layout, + name: 'ErpCenter', + meta: { hidden: true }, + children: [ + { + path: 'mold/detail/:id', + name: 'ErpMoldDetail', + meta: { + title: '模具详情', + noCache: true, + hidden: true, + activeMenu: '/erp/mold' + }, + component: () => import('@/views/erp/mold/detail/index.vue') + } + ] + }, { path: '/:pathMatch(.*)*', diff --git a/src/views/erp/mold/components/MoldList.vue b/src/views/erp/mold/components/MoldList.vue index 95d02c4a..37512b08 100644 --- a/src/views/erp/mold/components/MoldList.vue +++ b/src/views/erp/mold/components/MoldList.vue @@ -58,218 +58,6 @@ link type="primary" @click="openForm('update', scope.row.id)" - -
- - {{ detailData?.code ?? '' }} - {{ detailData?.name ?? '' }} - - - - {{ detailData?.brandName ?? '' }} - {{ detailData?.moldType ?? '' }} - - - - {{ detailData?.moldSize ?? '' }} - {{ detailData?.useTime ?? '' }} - {{ detailData?.machineName ?? detailData?.machineId ?? '' - }} - {{ formatDetailDate(detailData?.inTime) }} - - - - {{ detailData?.remark ?? '' }} - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- @@ -354,291 +142,10 @@ const recordFormRef = ref() const openRecordForm = (type: string, id?: number, brandId?: number) => { recordFormRef.value.open(type, id, brandId) } +const { push } = useRouter() -const detailVisible = ref(false) -const detailLoading = ref(false) -const detailData = ref<(MoldVO & Record) | null>(null) -const detailActiveTab = ref('check') - -const formatDetailDate = (value: any) => { - if (!value) return '' - return formatDate(new Date(value), 'YYYY-MM-DD') -} - -const formatHistoryTime = (value: any) => { - const raw = value ?? '-' - if (Array.isArray(raw) && raw.length >= 3) { - const [y, m, d, hh, mm, ss] = raw - const pad = (n: any) => String(n).padStart(2, '0') - if (hh !== undefined) return `${y}-${pad(m)}-${pad(d)} ${pad(hh)}:${pad(mm)}:${pad(ss)}` - return `${y}-${pad(m)}-${pad(d)}` - } - return String(raw) -} - -const getResultLabel = (value: any) => { - const v = value === '' || value === null || value === undefined ? undefined : String(value) - if (v === '0') return '待检测' - if (v === '1') return 'OK' - if (v === '2') return 'NG' - return '-' -} - -const getResultTagType = (value: any) => { - const v = value === '' || value === null || value === undefined ? undefined : String(value) - if (v === '1') return 'success' - if (v === '2') return 'danger' - if (v === '0') return 'info' - return 'info' -} - -const inspectionHistory = computed(() => { - const data: any = detailData.value - return data?.inspectionList ?? [] -}) - -const maintainHistory = computed(() => { - const data: any = detailData.value - const list = data?.maintainList ?? [] - return Array.isArray(list) ? list : [] -}) - -type HistoryStepItem = { - key: string - name: string - result: any - method?: any - criteria?: any - images?: string[] - remark?: any - inspectionTime?: any - createTime?: any -} - -type HistoryStepGroup = { key: string; time: string; operator: string; items: HistoryStepItem[] } - -const parseImages = (value: any): string[] => { - if (!value) return [] - if (Array.isArray(value)) return value.map(String).filter(Boolean) - const cleaned = String(value).replace(/[`'\"]/g, '').trim() - return cleaned - .split(',') - .map((v) => v.trim()) - .filter(Boolean) -} - -const buildStepGroups = ( - rows: any[], - options: { timeField: string; nameFieldCandidates: string[]; resultFieldCandidates: string[] } -) => { - const groups = new Map() - - for (const row of rows ?? []) { - const time = formatHistoryTime(row?.[options.timeField] ?? row?.createTime) - const operator = String(row?.creatorName ?? row?.creator ?? '-') - const groupKey = `${row?.managementId ?? ''}__${time}__${operator}` - - const name = - options.nameFieldCandidates - .map((k) => row?.[k]) - .find((v) => v !== undefined && v !== null && String(v).trim() !== '') ?? '-' - - const result = - options.resultFieldCandidates.map((k) => row?.[k]).find((v) => v !== undefined && v !== null) ?? undefined - - const item: HistoryStepItem = { - key: String(row?.id ?? `${groupKey}__${String(name)}`), - name: String(name), - result, - method: row?.inspectionMethod, - criteria: row?.judgmentCriteria, - images: parseImages(row?.images), - remark: row?.remark, - inspectionTime: row?.inspectionTime, - createTime: row?.createTime - } - - if (!groups.has(groupKey)) { - groups.set(groupKey, { key: groupKey, time, operator, items: [item] }) - } else { - groups.get(groupKey)!.items.push(item) - } - } - - return Array.from(groups.values()).sort((a, b) => String(b.time).localeCompare(String(a.time))) -} - -const inspectionStepGroups = computed(() => { - return buildStepGroups(inspectionHistory.value, { - timeField: 'inspectionTime', - nameFieldCandidates: ['inspectionItemName', 'name'], - resultFieldCandidates: ['inspectionResult'] - }) -}) - -const maintainStepGroups = computed(() => { - return buildStepGroups(maintainHistory.value, { - timeField: 'inspectionTime', - nameFieldCandidates: ['maintainItemName', 'inspectionItemName', 'name'], - resultFieldCandidates: ['maintainResult', 'inspectionResult'] - }) -}) - -type RepairHistoryRow = { - repairId?: any - subjectCode?: any - subjectName?: any - subjectContent?: any - subjectStandard?: any - malfunction?: any - repairDes?: any - remark?: any - createTime?: any -} - -const repairHistoryView = computed(() => { - const data: any = detailData.value - const raw = data?.repairList - if (!raw) return [] - if (Array.isArray(raw)) { - return raw as RepairHistoryRow[] - } - if (typeof raw === 'object') { - const result: RepairHistoryRow[] = [] - Object.values(raw as Record).forEach((rows: any) => { - if (Array.isArray(rows)) { - result.push(...(rows as RepairHistoryRow[])) - } - }) - return result - } - return [] -}) - -const openDetail = async (id: number) => { - detailVisible.value = true - detailActiveTab.value = 'check' - detailLoading.value = true - try { - detailData.value = await MoldBrandApi.getMold(id) - } finally { - detailLoading.value = false - } +const openDetail = (id: number) => { + push({ name: 'ErpMoldDetail', params: { id } }) } - - diff --git a/src/views/erp/mold/detail/index.vue b/src/views/erp/mold/detail/index.vue new file mode 100644 index 00000000..735acd23 --- /dev/null +++ b/src/views/erp/mold/detail/index.vue @@ -0,0 +1,486 @@ + + + +