feat:模具管理-添加模具类型/模具台账模块
parent
1514cdf7b4
commit
0ea15894bd
@ -0,0 +1,697 @@
|
||||
<template>
|
||||
<view class="page-container">
|
||||
<view class="fixed-header">
|
||||
<AppTitleHeader title="模具台账详情" />
|
||||
</view>
|
||||
|
||||
<view class="content-section">
|
||||
<view class="info-card">
|
||||
<view class="card-title">基本信息</view>
|
||||
<view class="info-list">
|
||||
<view class="info-row">
|
||||
<text class="info-label">模具名称</text>
|
||||
<text class="info-value">{{ getDetailField('name') }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">模具编号</text>
|
||||
<text class="info-value">{{ getDetailField('code') }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">模具状态</text>
|
||||
<u-tag :text="statusLabel" :type="statusTagType" size="mini" />
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">模具型号</text>
|
||||
<text class="info-value">{{ getDetailField('brandName') }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">模具规格</text>
|
||||
<text class="info-value">{{ getDetailField('moldType') }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">工序</text>
|
||||
<text class="info-value">{{ getDetailField('orgType') }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">模穴数</text>
|
||||
<text class="info-value">{{ getDetailField('moldSize') }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">使用次数/次</text>
|
||||
<text class="info-value">{{ getDetailField('useTime') }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">使用设备</text>
|
||||
<text class="info-value">{{ machineLabel }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">入库日期</text>
|
||||
<text class="info-value">{{ inTimeLabel }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">是否启用</text>
|
||||
<text class="info-value">{{ enableLabel }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">备注</text>
|
||||
<text class="info-value">{{ getDetailField('remark') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="info-card">
|
||||
<view class="card-title">履历</view>
|
||||
<view class="tabs-box">
|
||||
<u-tabs activeColor="#1a3a5c" :list="tabList" :current="currentTab" :is-scroll="false" @change="handleTabChange" />
|
||||
</view>
|
||||
<view>
|
||||
<view v-if="currentTab === 0">
|
||||
<view v-if="!inspectionGroups.length" class="empty">暂无点检数据</view>
|
||||
<view v-for="group in inspectionGroups" :key="group.key" class="history-group">
|
||||
<view class="history-group-head">
|
||||
<text class="history-group-time">[{{ group.time }}]</text>
|
||||
<text class="history-group-operator">操作人: {{ group.operator }}</text>
|
||||
</view>
|
||||
<view v-for="item in group.items" :key="item.key" class="history-item">
|
||||
<view class="history-item-head">
|
||||
<text class="result-badge" :class="'result-' + item.resultType">{{ item.resultLabel }}</text>
|
||||
<text class="history-item-name">{{ item.name }}</text>
|
||||
</view>
|
||||
<view class="history-item-body">
|
||||
<view class="history-row">
|
||||
<text class="history-label">点检方式</text>
|
||||
<text class="history-value">{{ detailValue(item.method) }}</text>
|
||||
</view>
|
||||
<view class="history-row">
|
||||
<text class="history-label">判定标准</text>
|
||||
<text class="history-value">{{ detailValue(item.criteria) }}</text>
|
||||
</view>
|
||||
<view class="history-row">
|
||||
<text class="history-label">点检时间</text>
|
||||
<text class="history-value">{{ detailValue(item.taskTimeLabel) }}</text>
|
||||
</view>
|
||||
<view class="history-row">
|
||||
<text class="history-label">创建时间</text>
|
||||
<text class="history-value">{{ detailValue(item.createTimeLabel) }}</text>
|
||||
</view>
|
||||
<view class="history-row">
|
||||
<text class="history-label">备注</text>
|
||||
<text class="history-value">{{ detailValue(item.remark) }}</text>
|
||||
</view>
|
||||
<view v-if="item.images && item.images.length" class="history-images">
|
||||
<image v-for="img in item.images" :key="img" class="history-image" :src="img" mode="aspectFill" @click="previewImages(item.images, img)" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-else-if="currentTab === 1">
|
||||
<view v-if="!maintainGroups.length" class="empty">暂无保养数据</view>
|
||||
<view v-for="group in maintainGroups" :key="group.key" class="history-group">
|
||||
<view class="history-group-head">
|
||||
<text class="history-group-time">[{{ group.time }}]</text>
|
||||
<text class="history-group-operator">操作人: {{ group.operator }}</text>
|
||||
</view>
|
||||
<view v-for="item in group.items" :key="item.key" class="history-item">
|
||||
<view class="history-item-head">
|
||||
<text class="result-badge" :class="'result-' + item.resultType">{{ item.resultLabel }}</text>
|
||||
<text class="history-item-name">{{ item.name }}</text>
|
||||
</view>
|
||||
<view class="history-item-body">
|
||||
<view class="history-row">
|
||||
<text class="history-label">保养方式</text>
|
||||
<text class="history-value">{{ detailValue(item.method) }}</text>
|
||||
</view>
|
||||
<view class="history-row">
|
||||
<text class="history-label">判定标准</text>
|
||||
<text class="history-value">{{ detailValue(item.criteria) }}</text>
|
||||
</view>
|
||||
<view class="history-row">
|
||||
<text class="history-label">保养时间</text>
|
||||
<text class="history-value">{{ detailValue(item.taskTimeLabel) }}</text>
|
||||
</view>
|
||||
<view class="history-row">
|
||||
<text class="history-label">创建时间</text>
|
||||
<text class="history-value">{{ detailValue(item.createTimeLabel) }}</text>
|
||||
</view>
|
||||
<view class="history-row">
|
||||
<text class="history-label">备注</text>
|
||||
<text class="history-value">{{ detailValue(item.remark) }}</text>
|
||||
</view>
|
||||
<view v-if="item.images && item.images.length" class="history-images">
|
||||
<image v-for="img in item.images" :key="img" class="history-image" :src="img" mode="aspectFill" @click="previewImages(item.images, img)" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-else>
|
||||
<view v-if="!repairGroups.length" class="empty">暂无维修数据</view>
|
||||
<view v-for="group in repairGroups" :key="group.key" class="repair-group">
|
||||
<view class="repair-group-head">
|
||||
<text class="repair-group-name">{{ group.name }}</text>
|
||||
<text class="repair-group-meta">共{{ group.items.length }}条</text>
|
||||
</view>
|
||||
<view v-for="row in group.items" :key="row.key" class="repair-item">
|
||||
<view class="repair-item-head">
|
||||
<text class="repair-tag">{{ detailValue(row.subjectCode) }}</text>
|
||||
<text class="repair-title">{{ detailValue(row.subjectName) }}</text>
|
||||
</view>
|
||||
<view class="repair-item-body">
|
||||
<view class="history-row">
|
||||
<text class="history-label">项目内容</text>
|
||||
<text class="history-value">{{ detailValue(row.subjectContent) }}</text>
|
||||
</view>
|
||||
<view class="history-row">
|
||||
<text class="history-label">维修结果</text>
|
||||
<text class="history-value">
|
||||
<text class="result-badge" :class="'result-' + row.resultType">{{ row.resultLabel }}</text>
|
||||
</text>
|
||||
</view>
|
||||
<view class="history-row">
|
||||
<text class="history-label">备注</text>
|
||||
<text class="history-value">{{ detailValue(row.remark) }}</text>
|
||||
</view>
|
||||
<view class="history-row">
|
||||
<text class="history-label">完成日期</text>
|
||||
<text class="history-value">{{ detailValue(row.finishDateLabel) }}</text>
|
||||
</view>
|
||||
<view v-if="row.images && row.images.length" class="history-images">
|
||||
<image v-for="img in row.images" :key="img" class="history-image" :src="img" mode="aspectFill" @click="previewImages(row.images, img)" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import AppTitleHeader from '@/components/common/AppTitleHeader.vue'
|
||||
import { getMoldDetail, getMoldInspectionByMoldId, getMoldMaintenanceByMoldId, getMoldRepairListByMoldId } from '@/api/mes/mold'
|
||||
import { getDictLabel, initAllDict } from '@/utils/dict'
|
||||
|
||||
const loading = ref(false)
|
||||
const moldId = ref(undefined)
|
||||
const detailData = ref(null)
|
||||
const inspectionList = ref([])
|
||||
const maintainList = ref([])
|
||||
const repairList = ref([])
|
||||
|
||||
const tabList = ref([{ name: '点检履历' }, { name: '保养履历' }, { name: '维修履历' }])
|
||||
const currentTab = ref(0)
|
||||
|
||||
function getDetailField(field) {
|
||||
const d = detailData.value
|
||||
return detailValue(d ? d[field] : undefined)
|
||||
}
|
||||
|
||||
const statusMeta = computed(() => {
|
||||
const d = detailData.value
|
||||
const raw = d ? d.status : undefined
|
||||
const label = getDictLabel('erp_mold_status', raw, detailValue(raw))
|
||||
return formatStatus(label)
|
||||
})
|
||||
const statusLabel = computed(() => statusMeta.value.label)
|
||||
const statusType = computed(() => statusMeta.value.type)
|
||||
const statusTagType = computed(() => {
|
||||
if (statusType.value === 'error') return 'error'
|
||||
if (statusType.value === 'warning') return 'warning'
|
||||
return 'success'
|
||||
})
|
||||
const machineLabel = computed(() => {
|
||||
const d = detailData.value
|
||||
const v = d ? d.machineName || d.machineId : undefined
|
||||
return detailValue(v)
|
||||
})
|
||||
const inTimeLabel = computed(() => {
|
||||
const d = detailData.value
|
||||
return formatDateOnly(d ? d.inTime : undefined)
|
||||
})
|
||||
const enableLabel = computed(() => {
|
||||
const d = detailData.value
|
||||
return formatEnable(d ? d.isEnable : undefined)
|
||||
})
|
||||
|
||||
const inspectionGroups = computed(() =>
|
||||
buildStepGroups(inspectionList.value, {
|
||||
timeFieldCandidates: ['taskTime', 'inspectionTime', 'createTime'],
|
||||
nameFieldCandidates: ['inspectionItemName', 'name', 'itemName'],
|
||||
resultFieldCandidates: ['inspectionResult', 'result'],
|
||||
methodFieldCandidates: ['inspectionMethod', 'method'],
|
||||
criteriaFieldCandidates: ['judgmentCriteria', 'criteria'],
|
||||
imagesFieldCandidates: ['images'],
|
||||
remarkFieldCandidates: ['remark']
|
||||
})
|
||||
)
|
||||
|
||||
const maintainGroups = computed(() =>
|
||||
buildStepGroups(maintainList.value, {
|
||||
timeFieldCandidates: ['taskTime', 'inspectionTime', 'createTime'],
|
||||
nameFieldCandidates: ['maintainItemName', 'inspectionItemName', 'name', 'itemName'],
|
||||
resultFieldCandidates: ['maintainResult', 'inspectionResult', 'result'],
|
||||
methodFieldCandidates: ['inspectionMethod', 'method'],
|
||||
criteriaFieldCandidates: ['judgmentCriteria', 'criteria'],
|
||||
imagesFieldCandidates: ['images'],
|
||||
remarkFieldCandidates: ['remark']
|
||||
})
|
||||
)
|
||||
|
||||
const repairGroups = computed(() => {
|
||||
const groupsMap = new Map()
|
||||
const rows = Array.isArray(repairList.value) ? repairList.value : []
|
||||
for (const row of rows) {
|
||||
const groupKey = String((row && (row.repairCode || row.repairId || row.subjectName || row.id)) ? (row.repairCode || row.repairId || row.subjectName || row.id) : '-')
|
||||
if (!groupsMap.has(groupKey)) {
|
||||
groupsMap.set(groupKey, {
|
||||
key: groupKey,
|
||||
name: String((row && (row.repairName || row.repairCode)) ? (row.repairName || row.repairCode) : groupKey),
|
||||
items: []
|
||||
})
|
||||
}
|
||||
const resultMeta = formatResult(row ? (row.repairResult !== undefined ? row.repairResult : row.result) : undefined)
|
||||
groupsMap.get(groupKey).items.push({
|
||||
key: String(row && row.id !== undefined && row.id !== null ? row.id : `${groupKey}_${Math.random()}`),
|
||||
subjectCode: row ? row.subjectCode : undefined,
|
||||
subjectName: row ? row.subjectName : undefined,
|
||||
subjectContent: row ? row.subjectContent : undefined,
|
||||
remark: row ? row.remark : undefined,
|
||||
finishDateLabel: formatDateOnly(row ? row.finishDate : undefined),
|
||||
resultLabel: resultMeta.label,
|
||||
resultType: resultMeta.type,
|
||||
images: parseImages(row ? (row.malfunctionUrl || row.malfunctionImages) : undefined)
|
||||
})
|
||||
}
|
||||
return Array.from(groupsMap.values())
|
||||
})
|
||||
|
||||
function handleTabChange(e) {
|
||||
const idx = e && typeof e === 'object' ? e.index : e
|
||||
currentTab.value = Number(idx === 0 ? 0 : idx || 0)
|
||||
}
|
||||
|
||||
onLoad(async (query) => {
|
||||
const rawId = query && (query.id !== undefined ? query.id : query.code)
|
||||
const decoded = rawId ? decodeURIComponent(String(rawId)) : ''
|
||||
moldId.value = decoded ? decoded : undefined
|
||||
await initAllDict()
|
||||
await fetchAll()
|
||||
})
|
||||
|
||||
async function fetchAll() {
|
||||
if (!moldId.value) {
|
||||
uni.showToast({ title: '缺少模具ID', icon: 'none' })
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const [detailRes, inspectionRes, maintainRes, repairRes] = await Promise.all([
|
||||
getMoldDetail(moldId.value),
|
||||
getMoldInspectionByMoldId(moldId.value),
|
||||
getMoldMaintenanceByMoldId(moldId.value),
|
||||
getMoldRepairListByMoldId(moldId.value)
|
||||
])
|
||||
detailData.value = detailRes.data
|
||||
inspectionList.value = normalizeList(inspectionRes)
|
||||
maintainList.value = normalizeList(maintainRes)
|
||||
repairList.value = normalizeList(repairRes)
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeList(res) {
|
||||
const data = res && res.data !== undefined ? res.data : res
|
||||
if (Array.isArray(data)) return data
|
||||
if (data && Array.isArray(data.data)) return data.data
|
||||
if (data && data.data && Array.isArray(data.data.list)) return data.data.list
|
||||
if (data && data.data && Array.isArray(data.data.rows)) return data.data.rows
|
||||
if (data && data.data && Array.isArray(data.data.records)) return data.data.records
|
||||
if (data && Array.isArray(data.list)) return data.list
|
||||
if (data && Array.isArray(data.rows)) return data.rows
|
||||
if (data && Array.isArray(data.records)) return data.records
|
||||
return []
|
||||
}
|
||||
|
||||
function detailValue(v) {
|
||||
if (v === 0) return '0'
|
||||
if (v === false) return '否'
|
||||
if (v === true) return '是'
|
||||
if (v === null || v === undefined) return '-'
|
||||
const s = String(v).trim()
|
||||
return s ? s : '-'
|
||||
}
|
||||
|
||||
function formatEnable(v) {
|
||||
if (v === true || v === 'true' || v === 1 || v === '1') return '是'
|
||||
if (v === false || v === 'false' || v === 0 || v === '0') return '否'
|
||||
return detailValue(v)
|
||||
}
|
||||
|
||||
function formatStatus(v) {
|
||||
const raw = v === null || v === undefined ? '' : String(v).trim()
|
||||
const upper = raw.toUpperCase()
|
||||
if (!raw) return { label: '-', type: 'normal' }
|
||||
if (raw === '1' || upper === 'OK' || raw.includes('正常')) return { label: raw, type: 'normal' }
|
||||
if (raw === '2' || upper === 'NG' || raw.includes('停') || raw.includes('禁') || raw.includes('坏') || raw.includes('修')) return { label: raw, type: 'error' }
|
||||
return { label: raw, type: 'warning' }
|
||||
}
|
||||
|
||||
function formatResult(v) {
|
||||
const raw = v === null || v === undefined ? '' : String(v).trim()
|
||||
const upper = raw.toUpperCase()
|
||||
if (!raw) return { label: '-', type: 'info' }
|
||||
if (raw === '0') return { label: '待检测', type: 'info' }
|
||||
if (raw === '1' || upper === 'OK') return { label: '通过', type: 'success' }
|
||||
if (raw === '2' || upper === 'NG') return { label: '不通过', type: 'danger' }
|
||||
return { label: raw, type: 'info' }
|
||||
}
|
||||
|
||||
function formatHistoryTime(value) {
|
||||
if (!value) return ''
|
||||
if (Array.isArray(value) && value.length >= 3) {
|
||||
const [y, m, d, hh, mm, ss] = value
|
||||
const pad = (n) => 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)}`
|
||||
}
|
||||
const s = String(value).trim()
|
||||
if (!s) return ''
|
||||
const num = Number(s)
|
||||
if (Number.isFinite(num)) {
|
||||
const ms = s.length === 10 ? num * 1000 : num
|
||||
const d = new Date(ms)
|
||||
if (!Number.isNaN(d.getTime())) return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}:${String(d.getSeconds()).padStart(2, '0')}`
|
||||
}
|
||||
const d = new Date(s)
|
||||
if (!Number.isNaN(d.getTime())) return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}:${String(d.getSeconds()).padStart(2, '0')}`
|
||||
return s
|
||||
}
|
||||
|
||||
function formatDateOnly(value) {
|
||||
const t = formatHistoryTime(value)
|
||||
if (!t) return '-'
|
||||
return String(t).split(' ')[0]
|
||||
}
|
||||
|
||||
function parseImages(value) {
|
||||
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)
|
||||
}
|
||||
|
||||
function pickFirst(obj, keys) {
|
||||
for (const k of keys) {
|
||||
if (obj && obj[k] !== undefined && obj[k] !== null && String(obj[k]).trim() !== '') return obj[k]
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
function buildStepGroups(rows, options) {
|
||||
const groupsMap = new Map()
|
||||
const list = Array.isArray(rows) ? rows : []
|
||||
for (const row of list) {
|
||||
const time = formatHistoryTime(pickFirst(row, options.timeFieldCandidates) || (row ? row.createTime : undefined))
|
||||
const operator = detailValue(row ? (row.operator || row.creatorName || row.creator) : undefined)
|
||||
const managementId = row && row.managementId !== undefined && row.managementId !== null ? row.managementId : ''
|
||||
const groupKey = `${managementId}__${time}__${operator}`
|
||||
const name = pickFirst(row, options.nameFieldCandidates) || '-'
|
||||
const resultMeta = formatResult(pickFirst(row, options.resultFieldCandidates))
|
||||
const item = {
|
||||
key: String(row && row.id !== undefined && row.id !== null ? row.id : `${groupKey}_${String(name)}`),
|
||||
name: detailValue(name),
|
||||
resultLabel: resultMeta.label,
|
||||
resultType: resultMeta.type,
|
||||
method: pickFirst(row, options.methodFieldCandidates),
|
||||
criteria: pickFirst(row, options.criteriaFieldCandidates),
|
||||
remark: pickFirst(row, options.remarkFieldCandidates),
|
||||
images: parseImages(pickFirst(row, options.imagesFieldCandidates)),
|
||||
taskTimeLabel: formatHistoryTime(row ? (row.taskTime || row.inspectionTime) : undefined),
|
||||
createTimeLabel: formatHistoryTime(row ? row.createTime : undefined)
|
||||
}
|
||||
|
||||
if (!groupsMap.has(groupKey)) {
|
||||
groupsMap.set(groupKey, { key: groupKey, time: time || '-', operator, items: [item] })
|
||||
} else {
|
||||
groupsMap.get(groupKey).items.push(item)
|
||||
}
|
||||
}
|
||||
return Array.from(groupsMap.values())
|
||||
}
|
||||
|
||||
function previewImages(list, current) {
|
||||
if (!list || !list.length) return
|
||||
uni.previewImage({ urls: list, current })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-container {
|
||||
min-height: 100vh;
|
||||
background-color: #f0f2f5;
|
||||
}
|
||||
|
||||
.fixed-header {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.content-section {
|
||||
padding: 168rpx 30rpx 30rpx;
|
||||
}
|
||||
|
||||
.info-card {
|
||||
background: #ffffff;
|
||||
border-radius: 20rpx;
|
||||
padding: 30rpx;
|
||||
margin-top: 24rpx;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #1a3a5c;
|
||||
margin-bottom: 24rpx;
|
||||
padding-bottom: 20rpx;
|
||||
border-bottom: 2rpx solid #f0f2f5;
|
||||
}
|
||||
|
||||
.info-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1rpx solid #f5f7fa;
|
||||
}
|
||||
|
||||
.info-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
font-size: 28rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.tabs-box {
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.empty {
|
||||
padding: 32rpx 0;
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.history-group {
|
||||
background: #f8fafc;
|
||||
border-radius: 16rpx;
|
||||
padding: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.history-group-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.history-group-time {
|
||||
font-size: 24rpx;
|
||||
color: #1a3a5c;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.history-group-operator {
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.history-item {
|
||||
background: #ffffff;
|
||||
border-radius: 14rpx;
|
||||
padding: 18rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.history-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.history-item-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 14rpx;
|
||||
}
|
||||
|
||||
.history-item-name {
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.result-badge {
|
||||
padding: 6rpx 14rpx;
|
||||
border-radius: 999rpx;
|
||||
font-size: 22rpx;
|
||||
margin-right: 14rpx;
|
||||
}
|
||||
|
||||
.result-success {
|
||||
background: rgba(24, 188, 55, 0.12);
|
||||
color: #18bc37;
|
||||
}
|
||||
|
||||
.result-danger {
|
||||
background: rgba(255, 77, 79, 0.12);
|
||||
color: #ff4d4f;
|
||||
}
|
||||
|
||||
.result-info {
|
||||
background: rgba(153, 153, 153, 0.12);
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.history-item-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.history-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
padding: 10rpx 0;
|
||||
}
|
||||
|
||||
.history-label {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
width: 160rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.history-value {
|
||||
font-size: 24rpx;
|
||||
color: #333333;
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.history-images {
|
||||
margin-top: 12rpx;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.history-image {
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #f0f2f5;
|
||||
}
|
||||
|
||||
.repair-group {
|
||||
background: #f8fafc;
|
||||
border-radius: 16rpx;
|
||||
padding: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.repair-group-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.repair-group-name {
|
||||
font-size: 28rpx;
|
||||
color: #1a3a5c;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.repair-group-meta {
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.repair-item {
|
||||
background: #ffffff;
|
||||
border-radius: 14rpx;
|
||||
padding: 18rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.repair-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.repair-item-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 14rpx;
|
||||
}
|
||||
|
||||
.repair-tag {
|
||||
padding: 6rpx 14rpx;
|
||||
border-radius: 999rpx;
|
||||
font-size: 22rpx;
|
||||
background: rgba(74, 144, 194, 0.12);
|
||||
color: #2d5a87;
|
||||
margin-right: 14rpx;
|
||||
}
|
||||
|
||||
.repair-title {
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,211 @@
|
||||
<template>
|
||||
<view class="page-container">
|
||||
<AppTitleHeader title="模具类型详情" />
|
||||
|
||||
<view class="content-section">
|
||||
<view class="info-card">
|
||||
<view class="card-title">基础信息</view>
|
||||
<view class="info-list">
|
||||
<view class="info-row">
|
||||
<text class="info-label">型号编码</text>
|
||||
<text class="info-value">{{ fieldValue('code') }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">型号名称</text>
|
||||
<text class="info-value">{{ fieldValue('name') }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">规格</text>
|
||||
<text class="info-value">{{ fieldValue('moldType') }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">工序</text>
|
||||
<text class="info-value">{{ orgTypeText }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">预期寿命(小时)</text>
|
||||
<text class="info-value">{{ fieldValue('useTime') }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">模穴数</text>
|
||||
<text class="info-value">{{ fieldValue('moldSize') }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">维保模式</text>
|
||||
<text class="info-value">{{ fieldValue('maintainType') }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">维保周期</text>
|
||||
<text class="info-value">{{ fieldValue('maintainTime') }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">产品ID</text>
|
||||
<text class="info-value">{{ fieldValue('productId') }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">是否启用</text>
|
||||
<text class="info-value">{{ enableText }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">创建时间</text>
|
||||
<text class="info-value">{{ formatDateTime(detailData?.createTime) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">更新时间</text>
|
||||
<text class="info-value">{{ formatDateTime(detailData?.updateTime) }}</text>
|
||||
</view>
|
||||
<view class="info-row remark-row">
|
||||
<text class="info-label">备注</text>
|
||||
<text class="info-value remark-value">{{ fieldValue('remark') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import AppTitleHeader from '@/components/common/AppTitleHeader.vue'
|
||||
import { getMoldBrandDetail } from '@/api/mes/mold'
|
||||
import { getDictLabel, initAllDict } from '@/utils/dict'
|
||||
|
||||
const detailId = ref(undefined)
|
||||
const detailData = ref(null)
|
||||
|
||||
const orgTypeText = computed(() =>
|
||||
getDictLabel('mes_org_type', detailData.value?.orgType, textValue(detailData.value?.orgType))
|
||||
)
|
||||
|
||||
const enableText = computed(() => {
|
||||
const value = detailData.value?.isEnable
|
||||
if (value === true || value === 1 || value === '1' || value === 'true') return '是'
|
||||
if (value === false || value === 0 || value === '0' || value === 'false') return '否'
|
||||
return textValue(value)
|
||||
})
|
||||
|
||||
onLoad(async (query) => {
|
||||
const id = query?.id ? decodeURIComponent(String(query.id)) : ''
|
||||
detailId.value = id || undefined
|
||||
await initAllDict()
|
||||
await fetchDetail()
|
||||
})
|
||||
|
||||
async function fetchDetail() {
|
||||
if (!detailId.value) {
|
||||
uni.showToast({ title: '缺少模具类型ID', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res = await getMoldBrandDetail(detailId.value)
|
||||
detailData.value = normalizeDetail(res)
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '详情加载失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeDetail(res) {
|
||||
const root = res && res.data !== undefined ? res.data : res
|
||||
if (root?.data && typeof root.data === 'object') return root.data
|
||||
if (root && typeof root === 'object') return root
|
||||
return {}
|
||||
}
|
||||
|
||||
function fieldValue(field) {
|
||||
return textValue(detailData.value ? detailData.value[field] : undefined)
|
||||
}
|
||||
|
||||
function textValue(value) {
|
||||
if (value === 0) return '0'
|
||||
if (value === false) return '否'
|
||||
if (value === true) return '是'
|
||||
if (value === null || value === undefined) return '-'
|
||||
const text = String(value).trim()
|
||||
return text || '-'
|
||||
}
|
||||
|
||||
function formatDateTime(value) {
|
||||
if (!value) return '-'
|
||||
if (Array.isArray(value) && value.length >= 3) {
|
||||
const [y, m, d, hh = 0, mm = 0, ss = 0] = value
|
||||
const pad = (n) => String(n).padStart(2, '0')
|
||||
return `${y}-${pad(m)}-${pad(d)} ${pad(hh)}:${pad(mm)}:${pad(ss)}`
|
||||
}
|
||||
const text = String(value).trim()
|
||||
if (!text) return '-'
|
||||
const numeric = Number(text)
|
||||
if (Number.isFinite(numeric)) {
|
||||
const timestamp = text.length === 10 ? numeric * 1000 : numeric
|
||||
const date = new Date(timestamp)
|
||||
if (!Number.isNaN(date.getTime())) {
|
||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}:${String(date.getSeconds()).padStart(2, '0')}`
|
||||
}
|
||||
}
|
||||
const date = new Date(text)
|
||||
if (!Number.isNaN(date.getTime())) {
|
||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}:${String(date.getSeconds()).padStart(2, '0')}`
|
||||
}
|
||||
return text
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-container {
|
||||
min-height: 100vh;
|
||||
background-color: #f0f2f5;
|
||||
}
|
||||
|
||||
.content-section {
|
||||
padding: 0 24rpx 24rpx;
|
||||
}
|
||||
|
||||
.info-card {
|
||||
margin-top: 20rpx;
|
||||
background: #ffffff;
|
||||
border-radius: 20rpx;
|
||||
padding: 28rpx;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 32rpx;
|
||||
color: #1a3a5c;
|
||||
font-weight: 700;
|
||||
margin-bottom: 18rpx;
|
||||
}
|
||||
|
||||
.info-list {
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
padding: 18rpx 0;
|
||||
border-bottom: 1rpx solid #edf0f3;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
font-size: 27rpx;
|
||||
color: #8a9099;
|
||||
width: 220rpx;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
font-size: 28rpx;
|
||||
color: #30363d;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.remark-row {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.remark-value {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue