feat:模具详情-维修记录接口更换、添加跳转详情

master
黄伟杰 6 days ago
parent 16d67cc1dd
commit 85af0173aa

@ -9,6 +9,14 @@ export function getMoldRepairPage(params = {}) {
})
}
export function getMoldRepairList(params = {}) {
return request({
url: '/admin-api/mes/mold-repair/list',
method: 'get',
params
})
}
export function getMoldRepair(id) {
return request({
url: '/admin-api/mes/mold-repair/get',
@ -64,4 +72,4 @@ export function uploadRepairImage(filePath, name = 'file') {
filePath,
showLoading: false
})
}
}

@ -1302,6 +1302,8 @@ export default {
mold: 'Mold',
moldCode: 'Mold Code',
moldName: 'Mold Name',
specModel: 'Spec Model',
brand: 'Brand',
faultLevel: 'Fault Level',
isShutdown: 'Is Shutdown',
status: 'Status',
@ -1328,6 +1330,8 @@ export default {
statusPending: 'Pending',
statusPassed: 'Passed',
statusRejected: 'Rejected',
orderStatusPending: 'Pending',
orderStatusDone: 'Completed',
placeholderRepairCode: 'Enter repair code',
placeholderRepairName: 'Enter repair name',
placeholderRequireDate: 'Select require date',

@ -1305,6 +1305,8 @@ export default {
mold: '模具',
moldCode: '模具编码',
moldName: '模具名称',
specModel: '规格型号',
brand: '品牌',
faultLevel: '故障等级',
isShutdown: '是否停机',
status: '单据状态',
@ -1331,6 +1333,8 @@ export default {
statusPending: '待维修',
statusPassed: '通过',
statusRejected: '不通过',
orderStatusPending: '待处理',
orderStatusDone: '已完成',
placeholderRepairCode: '请输入维修单编号',
placeholderRepairName: '请输入维修单名称',
placeholderRequireDate: '请选择报修日期',

@ -125,7 +125,7 @@
<view v-else-if="currentTab === 2">
<view v-if="repairLoading" class="hint">{{ t('functionCommon.loading') }}</view>
<view v-else-if="!repairRecords.length" class="hint">{{ t('moldLedger.noRepair') }}</view>
<view v-for="row in repairRecords" :key="row.key" class="record-card">
<view v-for="row in repairRecords" :key="row.key" class="record-card" @click="openRepairDetail(row)">
<view class="record-head">
<text class="record-title">{{ detailValue(row.repairCode || row.subjectName || row.repairName) }}</text>
<text class="result-badge" :class="`result-${row.resultType}`">{{ row.resultLabel }}</text>
@ -138,7 +138,7 @@
detailValue(row.finishDateLabel) }}</text></view>
<view class="record-row"><text class="record-label">{{ t('moldLedger.remark') }}</text><text class="record-value">{{
detailValue(row.remark) }}</text></view>
<view v-if="row.images.length" class="history-images">
<view v-if="row.images.length" class="history-images" @click.stop>
<image v-for="img in row.images" :key="img" class="history-image" :src="img" mode="aspectFill"
@click="previewImages(row.images, img)" />
</view>
@ -206,10 +206,10 @@ import {
getMoldBrandDetail,
getMoldInspectionByMoldId,
getMoldMaintenanceByMoldId,
getMoldPage,
getMoldRepairListByMoldId
getMoldPage
} from '@/api/mes/mold'
import { getMoldOperatePage } from '@/api/mes/moldoperate'
import { getMoldRepairList } from '@/api/mes/moldrepair'
import { DICT_TYPE, getDictLabel, initAllDict } from '@/utils/dict'
const { t } = useI18n()
@ -245,7 +245,7 @@ const childMoldCount = computed(() => childMolds.value.length || detailData.valu
const statusLabel = computed(() => getDictLabel(DICT_TYPE.ERP_MOLD_STATUS, detailData.value?.status, detailValue(detailData.value?.status)))
const statusTagType = computed(() => {
const label = String(statusLabel.value || '')
if (label.includes('正常') || label.includes('使用')) return 'success'
if (label.includes('正常') || label.includes('使用') || label.includes('在机') || label.includes('在库')) return 'success'
if (label.includes('维修') || label.includes('警')) return 'warning'
if (label.includes('报废') || label.includes('停')) return 'error'
return 'primary'
@ -278,14 +278,14 @@ const maintainGroups = computed(() =>
const repairRecords = computed(() => {
const rows = Array.isArray(repairList.value) ? repairList.value : []
return rows.map((row, index) => {
const resultMeta = formatRepairResult(row?.repairResult !== undefined ? row.repairResult : row?.result)
const resultMeta = formatRepairResult(row?.repairResult ?? row?.repairStatus ?? row?.result)
return {
...row,
key: String(row?.id ?? row?.repairCode ?? index),
finishDateLabel: formatDateTime(row?.finishDate || row?.createTime),
resultLabel: resultMeta.label,
resultType: resultMeta.type,
images: parseImages(row?.malfunctionUrl || row?.malfunctionImages || row?.images)
images: parseImages(row?.malfunctionUrl || row?.malfunctionImages || row?.images || row?.faultImages)
}
})
})
@ -384,7 +384,7 @@ async function fetchRepairRecords() {
if (!brandId.value) return
repairLoading.value = true
try {
const res = await getMoldRepairListByMoldId(brandId.value)
const res = await getMoldRepairList({ moldId: brandId.value })
repairList.value = normalizeListData(res)
} catch (e) {
repairList.value = []
@ -467,7 +467,7 @@ function moldTypeText(type) {
function statusTextClass(status) {
const label = moldStatusText(status)
if (label.includes('正常') || label.includes('使用')) return 'text-success'
if (label.includes('正常') || label.includes('使用') || label.includes('在机') || label.includes('在库')) return 'text-success'
if (label.includes('维修') || label.includes('警')) return 'text-warning'
if (label.includes('报废') || label.includes('停')) return 'text-danger'
return 'text-default'
@ -583,6 +583,17 @@ function previewImages(list, current) {
if (!list || !list.length) return
uni.previewImage({ urls: list, current })
}
function openRepairDetail(row) {
const id = row?.id
if (id === undefined || id === null || id === '') {
uni.showToast({ title: t('moldRepair.noId'), icon: 'none' })
return
}
uni.navigateTo({
url: `/pages_function/pages/moldRepair/form?mode=detail&id=${encodeURIComponent(String(id))}`
})
}
</script>
<style lang="scss" scoped>

@ -105,6 +105,16 @@
<text class="form-label">{{ t('moldRepair.moldCode') }}</text>
<input v-model="formData.moldCode" class="form-input" type="text" :placeholder="t('moldRepair.placeholderMoldCodeAuto')" disabled />
</view>
<view class="form-item">
<text class="form-label">{{ t('moldRepair.specModel') }}</text>
<input v-model="formData.specModel" class="form-input" type="text" :placeholder="t('moldRepair.placeholderMoldCodeAuto')" disabled />
</view>
<view class="form-item">
<text class="form-label">{{ t('moldRepair.brand') }}</text>
<input v-model="formData.brand" class="form-input" type="text" :placeholder="t('moldRepair.placeholderMoldCodeAuto')" disabled />
</view>
</view>
<view class="section-card">
@ -252,6 +262,8 @@ const formData = reactive({
moldId: undefined,
moldCode: '',
moldName: '',
specModel: '',
brand: '',
requireDate: today,
finishDate: today,
confirmDate: today,
@ -289,10 +301,9 @@ const repairCodeDisabled = computed(() => Boolean(formData.isCode) || mode.value
const showRepairSection = computed(() => mode.value === 'repair' || mode.value === 'detail' || String(formData.repairStatus || '0') !== '0' || String(formData.status || '0') === '1')
const submitButtonText = computed(() => t('functionCommon.save'))
const statusLabel = computed(() => {
const normalized = String(formData.repairStatus || '0')
if (normalized === '1') return t('moldRepair.statusPassed')
if (normalized === '2') return t('moldRepair.statusRejected')
return t('moldRepair.statusPending')
const normalized = String(formData.status || '0')
if (normalized === '1') return t('moldRepair.orderStatusDone')
return t('moldRepair.orderStatusPending')
})
const moldLabels = computed(() => moldOptions.value.map((item) => item.label))
const faultLevelOptions = computed(() => {
@ -377,6 +388,8 @@ async function fetchDetail(id) {
formData.moldId = detail?.moldId ?? detail?.machineryId
formData.moldCode = inputValue(detail?.moldCode ?? detail?.machineryCode)
formData.moldName = inputValue(detail?.moldName ?? detail?.machineryName)
formData.specModel = inputValue(detail?.machinerySpec ?? detail?.moldSpec)
formData.brand = inputValue(detail?.machineryBrand ?? detail?.moldBrand)
formData.requireDate = defaultDateValue(detail?.requireDate)
formData.finishDate = defaultDateValue(detail?.finishDate)
formData.confirmDate = defaultDateValue(detail?.confirmDate)
@ -502,7 +515,7 @@ function onRepairStatusChange(event) {
function resolveUserLabel(value, placeholder) {
if (value === undefined || value === null || value === '') return placeholder
const current = users.value.find((item) => String(item.id) === String(value) || item.nickname === String(value))
return current?.nickname || current?.name || placeholder
return current?.nickname || current?.name || String(value)
}
function normalizeUserId(value) {

Loading…
Cancel
Save