feat:设备运维-点检记录页面

master
黄伟杰 2 weeks ago
parent fddd0fad61
commit 456678b5d2

@ -1,2 +1,2 @@
VITE_APP_BASE_URL=http://192.168.5.106:48081
# VITE_APP_BASE_URL=http://47.106.185.127:8089
VITE_APP_BASE_URL=http://192.168.43.233:48081
# VITE_APP_BASE_URL=http://47.106.185.127:8089

@ -0,0 +1,43 @@
import upload from '@/utils/upload'
import request from '@/utils/request'
export function getEquipmentInspectionRecordPage(params = {}) {
return request({
url: '/admin-api/mes/ticket-management/page',
method: 'get',
params
})
}
export function batchUpdateEquipmentInspectionRecordStatus(data) {
return request({
url: '/admin-api/mes/ticket-management/batchUpdateStatus',
method: 'put',
data
})
}
export function getEquipmentInspectionRecordResultsPage(params = {}) {
return request({
url: '/admin-api/mes/ticket-results/list',
method: 'get',
params
})
}
export function batchUpdateEquipmentInspectionRecordResults(data) {
return request({
url: '/admin-api/mes/ticket-results/batchUpdate',
method: 'put',
data
})
}
export function uploadEquipmentInspectionRecordImage(filePath, name = 'file') {
return upload({
url: '/admin-api/infra/file/upload',
name,
filePath,
showLoading: false
})
}

@ -474,6 +474,47 @@ export default {
createTicketSuccess: 'Work order created successfully',
createTicketFail: 'Work order creation failed'
},
equipmentInspectionRecord: {
moduleName: 'Equipment Inspection Records',
subTitle: 'Equipment inspection record list',
detailTitle: 'Equipment Inspection Record Detail',
taskType: 'Task Type',
taskTypeInspect: 'Inspection',
taskTypeMaintain: 'Maintenance',
taskTypeInspectShort: 'I',
taskTypeMaintainShort: 'M',
planNo: 'Task No.',
deviceName: 'Device Name',
configName: 'Inspection Template',
jobStatus: 'Job Status',
jobStatusPending: 'Pending',
jobStatusProcessing: 'Processing',
jobStatusCompleted: 'Completed',
jobStatusTimeout: 'Timeout',
jobStatusCancelled: 'Cancelled',
jobResult: 'Result',
jobResultOk: 'Pass',
jobResultNg: 'Fail',
taskTime: 'Job Time',
searchPlaceholder: 'Enter task no.',
empty: 'No equipment inspection records',
progressTitle: 'Progress',
inspectionMethod: 'Inspection Method',
judgmentCriteria: 'Criteria',
valueType: 'Value Type',
resultText: 'Result',
requiredText: 'Required',
inspectionResultPending: 'Pending',
inspectionResultPass: 'Pass',
inspectionResultFail: 'Fail',
textInput: 'Input Value',
inputPlaceholder: 'Please enter',
remark: 'Remark',
images: 'Images',
maxUploadCount: 'You can upload up to 9 images',
selectAllDecisionError: 'Please choose a result for all pending items',
noResultData: 'No inspection items'
},
moldWorkOrder: {
moduleName: 'Inspection Records',
subTitle: 'Mold management inspection records',

@ -115,6 +115,8 @@ const literalMap = {
'点检任务详情': 'moldTaskConfig.detailTitle',
'设备点检任务': 'equipmentInspectionTasks.moduleName',
'设备点检任务详情': 'equipmentInspectionTasks.detailTitle',
'设备点检记录': 'equipmentInspectionRecord.moduleName',
'设备点检记录详情': 'equipmentInspectionRecord.detailTitle',
'点检记录': 'moldWorkOrder.moduleName',
'点检记录详情': 'moldWorkOrder.detailTitle'
}

@ -474,6 +474,47 @@ export default {
createTicketSuccess: '工单创建成功',
createTicketFail: '工单创建失败'
},
equipmentInspectionRecord: {
moduleName: '设备点检记录',
subTitle: '设备点检记录查询',
detailTitle: '设备点检记录详情',
taskType: '任务类型',
taskTypeInspect: '点检',
taskTypeMaintain: '保养',
taskTypeInspectShort: '检',
taskTypeMaintainShort: '养',
planNo: '任务编号',
deviceName: '设备名称',
configName: '点检模板',
jobStatus: '作业状态',
jobStatusPending: '待处理',
jobStatusProcessing: '处理中',
jobStatusCompleted: '已完成',
jobStatusTimeout: '已超时',
jobStatusCancelled: '已取消',
jobResult: '结果',
jobResultOk: '通过',
jobResultNg: '不通过',
taskTime: '作业时间',
searchPlaceholder: '请输入任务编号',
empty: '暂无设备点检记录数据',
progressTitle: '执行进度',
inspectionMethod: '检验方式',
judgmentCriteria: '标准要求',
valueType: '值类型',
resultText: '结果',
requiredText: '必检',
inspectionResultPending: '待检',
inspectionResultPass: '通过',
inspectionResultFail: '不通过',
textInput: '输入值',
inputPlaceholder: '请输入',
remark: '备注',
images: '图片',
maxUploadCount: '最多上传 9 张图片',
selectAllDecisionError: '请为所有待检项选择结果',
noResultData: '暂无点检项数据'
},
moldWorkOrder: {
moduleName: '点检记录',
subTitle: '模具管理点检记录查询',

@ -659,6 +659,20 @@
"navigationStyle": "custom"
}
},
{
"path": "equipmentInspectionRecord/index",
"style": {
"navigationBarTitleText": "设备点检记录",
"navigationStyle": "custom"
}
},
{
"path": "equipmentInspectionRecord/detail",
"style": {
"navigationBarTitleText": "设备点检记录详情",
"navigationStyle": "custom"
}
},
{
"path": "planList/index",
"style": {

@ -0,0 +1,399 @@
<template>
<view class="page-container">
<view class="fixed-header">
<NavBar :title="t('equipmentInspectionRecord.detailTitle')" />
</view>
<scroll-view scroll-y class="detail-scroll">
<view class="content-section">
<view class="hero-card">
<view class="hero-left">
<view class="hero-icon">{{ taskTypeShortText }}</view>
</view>
<view class="hero-body">
<text class="hero-title">{{ textValue(detailData.deviceName) }}</text>
<view class="hero-meta-row">
<text class="hero-meta-label">{{ t('equipmentInspectionRecord.taskType') }}</text>
<text class="hero-meta-value">{{ planTypeText }}</text>
<text class="hero-meta-label hero-meta-gap">{{ t('equipmentInspectionRecord.configName') }}</text>
<text class="hero-meta-value">{{ textValue(detailData.configName) }}</text>
</view>
<view class="hero-meta-row">
<text class="hero-meta-label">{{ t('equipmentInspectionRecord.planNo') }}</text>
<text class="hero-meta-value">{{ textValue(detailData.planNo) }}</text>
</view>
</view>
</view>
<view class="progress-sticky-wrap">
<view class="progress-card">
<view class="progress-header">
<text class="progress-title">{{ t('equipmentInspectionRecord.progressTitle') }}</text>
<text class="progress-count">{{ completedCount }}/{{ totalCount }}</text>
</view>
<view class="progress-track">
<view class="progress-bar" :style="{ width: `${progressPercent}%` }"></view>
</view>
</view>
</view>
<view v-if="resultLoading" class="hint">{{ t('functionCommon.loading') }}</view>
<view v-else-if="!resultList.length" class="hint">{{ t('equipmentInspectionRecord.noResultData') }}</view>
<view v-else class="result-list">
<view v-for="(item, index) in resultList" :key="item.id || index" class="result-card">
<view class="result-header">
<view class="result-index">{{ index + 1 }}</view>
<text class="result-title">{{ textValue(item.inspectionItemName) }}</text>
<view v-if="isRequiredItem(item)" class="required-tag">{{ t('equipmentInspectionRecord.requiredText') }}</view>
</view>
<view class="result-fields">
<view class="field-row">
<text class="field-label">{{ t('equipmentInspectionRecord.inspectionMethod') }}</text>
<text class="field-value">{{ inspectionMethodText(item.inspectionMethod) }}</text>
</view>
<view class="field-row">
<text class="field-label">{{ t('equipmentInspectionRecord.judgmentCriteria') }}</text>
<text class="field-value">{{ textValue(item.judgmentCriteria) }}</text>
</view>
<view class="field-row">
<text class="field-label">{{ t('equipmentInspectionRecord.valueType') }}</text>
<text class="field-value">{{ valueTypeText(item.valueType) }}</text>
</view>
<view v-if="shouldShowInput(item)" class="field-block">
<text class="field-label block-label">{{ t('equipmentInspectionRecord.textInput') }}</text>
<textarea
v-if="isEditableItem(item)"
v-model="item.textInput"
class="form-textarea"
:placeholder="t('equipmentInspectionRecord.inputPlaceholder')"
maxlength="500"
/>
<view v-else class="readonly-box">{{ textInputDisplay(item) }}</view>
</view>
<view class="field-block">
<text class="field-label block-label">{{ t('equipmentInspectionRecord.images') }}</text>
<view class="image-list">
<view v-for="(img, imgIndex) in parseImages(item.images)" :key="imgIndex" class="image-item">
<image
:src="img"
class="result-image"
mode="aspectFill"
@click="previewImage(img, parseImages(item.images))"
/>
<view v-if="isEditableItem(item)" class="image-remove" @click="removeImage(item, imgIndex)">×</view>
</view>
<view v-if="isEditableItem(item) && parseImages(item.images).length < 9" class="image-upload" @click="chooseImages(item)">
<text class="image-upload-icon">+</text>
</view>
</view>
</view>
<view v-if="item.remark" class="field-row field-row-top">
<text class="field-label">{{ t('equipmentInspectionRecord.remark') }}</text>
<text class="field-value multiline">{{ textValue(item.remark) }}</text>
</view>
<view class="field-block">
<text class="field-label block-label">{{ t('equipmentInspectionRecord.resultText') }}</text>
<view class="result-option-group">
<view
:class="['result-option', resultOptionClass(item, '1')]"
@click="setDecision(item, '1')"
>
{{ t('equipmentInspectionRecord.inspectionResultPass') }}
</view>
<view
:class="['result-option', resultOptionClass(item, '2')]"
@click="setDecision(item, '2')"
>
{{ t('equipmentInspectionRecord.inspectionResultFail') }}
</view>
<view v-if="isEditableItem(item) && String(item?.inspectionResult || '') === '0'" class="pending-tag">{{ t('equipmentInspectionRecord.inspectionResultPending') }}</view>
</view>
</view>
</view>
</view>
</view>
</view>
</scroll-view>
<view class="action-bar">
<view class="action-btn back-btn" @click="goBack">{{ t('dashboard.back') }}</view>
<view :class="['action-btn', 'save-btn', (saveLoading || isExecuted) ? 'action-btn-disabled' : '']" @click="handleSave">{{ t('functionCommon.save') }}</view>
</view>
</view>
</template>
<script setup>
import { computed, reactive, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { batchUpdateEquipmentInspectionRecordResults, getEquipmentInspectionRecordResultsPage, uploadEquipmentInspectionRecordImage } from '@/api/mes/equipmentInspectionRecord'
import { DICT_TYPE, getDictLabel, initAllDict } from '@/utils/dict'
const { t } = useI18n()
const detailData = reactive({})
const resultList = ref([])
const resultLoading = ref(false)
const managementId = ref('')
const saveLoading = ref(false)
const isExecuted = computed(() => String(detailData.jobStatus || '') === '2')
const planTypeText = computed(() => {
const value = String(detailData.planType || '')
if (value === '1') return t('equipmentInspectionRecord.taskTypeInspect')
if (value === '2') return t('equipmentInspectionRecord.taskTypeMaintain')
return textValue(detailData.planType)
})
const taskTypeShortText = computed(() => {
const value = String(detailData.planType || '')
if (value === '2') return t('equipmentInspectionRecord.taskTypeMaintainShort')
return t('equipmentInspectionRecord.taskTypeInspectShort')
})
const totalCount = computed(() => resultList.value.length)
const completedCount = computed(() => resultList.value.filter((item) => isItemCompleted(item)).length)
const progressPercent = computed(() => {
if (!totalCount.value) return 0
return Math.min(100, Math.round((completedCount.value / totalCount.value) * 100))
})
onLoad(async (query) => {
managementId.value = String(query?.id || '')
if (!managementId.value) {
uni.showToast({ title: t('functionCommon.noIdView'), icon: 'none' })
return
}
await initAllDict()
try {
const cached = uni.getStorageSync('equipmentInspectionRecordDetail')
if (cached) {
Object.assign(detailData, JSON.parse(cached))
uni.removeStorageSync('equipmentInspectionRecordDetail')
}
} catch (error) {}
await fetchResults()
})
async function fetchResults() {
resultLoading.value = true
try {
const res = await getEquipmentInspectionRecordResultsPage({ managementId: managementId.value })
const root = res && res.data !== undefined ? res.data : res
const items = root?.list || root?.rows || root?.records || root?.data?.list || root?.data?.rows || root?.data?.records || root?.data || root || []
resultList.value = (Array.isArray(items) ? items : []).map((item) => ({
...item,
__editable: !isExecuted.value && String(item?.inspectionResult ?? '0') === '0'
}))
} catch (error) {
uni.showToast({ title: t('functionCommon.loadFailed'), icon: 'none' })
} finally {
resultLoading.value = false
}
}
function isRequiredItem(item) {
const value = item?.required ?? item?.isRequired ?? item?.needCheck ?? item?.mustCheck
return value === true || value === 1 || value === '1'
}
function isPendingItem(item) {
return String(item?.inspectionResult ?? '') === '0'
}
function isEditableItem(item) {
return !isExecuted.value && item?.__editable === true
}
function shouldShowInput(item) {
const valueType = String(item?.valueType ?? '')
return valueType === '0' || valueType === '2' || !!String(item?.textInput || '').trim()
}
function textInputDisplay(item) {
const text = String(item?.textInput || '').trim()
return text || t('equipmentInspectionRecord.inspectionResultPending')
}
function isItemCompleted(item) {
const result = String(item?.inspectionResult ?? '').trim()
return !!result && result !== '0'
}
function textValue(value) {
if (value === 0) return '0'
if (value === null || value === undefined) return '-'
const text = String(value).trim()
return text || '-'
}
function inspectionMethodText(value) {
return getDictLabel(DICT_TYPE.INSPECTION_METHOD, value, textValue(value))
}
function valueTypeText(value) {
return getDictLabel(DICT_TYPE.VALUE_TYPES, value, textValue(value))
}
function parseImages(value) {
if (!value) return []
if (Array.isArray(value)) return value.map((item) => String(item).trim()).filter(Boolean)
return String(value).split(',').map((item) => item.trim()).filter(Boolean)
}
function joinImages(value) {
return parseImages(value).join(',')
}
function resultOptionClass(item, value) {
const current = String(item?.inspectionResult || '')
if (current !== String(value)) return ''
return String(value) === '1' ? 'result-option-active' : 'result-option-danger'
}
function setDecision(item, value) {
if (!isEditableItem(item)) return
item.inspectionResult = String(value)
}
async function chooseImages(item) {
try {
const currentCount = parseImages(item.images).length
const remain = Math.max(0, 9 - currentCount)
if (!remain) {
uni.showToast({ title: t('equipmentInspectionRecord.maxUploadCount'), icon: 'none' })
return
}
const res = await uni.chooseImage({ count: remain, sizeType: ['compressed'] })
const files = Array.isArray(res?.tempFilePaths) ? res.tempFilePaths : []
if (!files.length) return
uni.showLoading({ title: t('functionCommon.uploading'), mask: true })
const uploaded = []
for (const filePath of files) {
const uploadRes = await uploadEquipmentInspectionRecordImage(filePath)
const url = String(uploadRes?.data?.fileUrl || uploadRes?.data?.url || uploadRes?.data || uploadRes?.url || '').trim()
if (url) uploaded.push(url)
}
item.images = joinImages([...parseImages(item.images), ...uploaded])
} catch (error) {
const message = String(error?.errMsg || '')
if (!message.includes('cancel')) {
uni.showToast({ title: t('functionCommon.uploadImageFailed'), icon: 'none' })
}
} finally {
uni.hideLoading()
}
}
function removeImage(item, index) {
if (!isEditableItem(item)) return
const next = parseImages(item.images)
next.splice(index, 1)
item.images = next.join(',')
}
function previewImage(current, urls) {
uni.previewImage({ current, urls })
}
function goBack() {
uni.navigateBack()
}
async function handleSave() {
if (saveLoading.value || isExecuted.value) return
const pendingItems = resultList.value.filter((item) => isEditableItem(item))
if (!pendingItems.length) {
uni.navigateBack()
return
}
const hasUnselected = pendingItems.some((item) => String(item?.inspectionResult || '') === '0')
if (hasUnselected) {
uni.showToast({ title: t('equipmentInspectionRecord.selectAllDecisionError'), icon: 'none' })
return
}
const payload = pendingItems.map((item) => ({
...item,
managementId: item.managementId || managementId.value,
inspectionResult: item.inspectionResult,
images: joinImages(item.images),
textInput: String(item.textInput || '').trim() || undefined
}))
saveLoading.value = true
try {
await batchUpdateEquipmentInspectionRecordResults(payload)
detailData.jobStatus = '2'
uni.showToast({ title: t('functionCommon.saveSuccess'), icon: 'success' })
await fetchResults()
} catch (error) {
uni.showToast({ title: t('functionCommon.saveFailed'), icon: 'none' })
} finally {
saveLoading.value = false
}
}
</script>
<style lang="scss" scoped>
.page-container { min-height: 100vh; background-color: #f5f7fb; }
.fixed-header { position: sticky; top: 0; z-index: 20; }
.detail-scroll { height: calc(100vh - 212rpx); }
.content-section { padding: 20rpx 24rpx 28rpx; }
.hero-card { display: flex; gap: 20rpx; background: #ffffff; border-radius: 24rpx; padding: 24rpx; box-shadow: 0 6rpx 18rpx rgba(15, 23, 42, 0.05); }
.hero-left { width: 120rpx; height: 120rpx; border-radius: 20rpx; background: linear-gradient(135deg, #e8f2ff, #d7e8ff); display: flex; align-items: center; justify-content: center; }
.hero-icon { font-size: 52rpx; font-weight: 700; color: #1f7cff; }
.hero-body { flex: 1; min-width: 0; }
.hero-title { display: block; font-size: 42rpx; line-height: 1.2; font-weight: 700; color: #1f2937; }
.hero-meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8rpx; margin-top: 16rpx; }
.hero-meta-label { font-size: 25rpx; color: #9ca3af; }
.hero-meta-gap { margin-left: 24rpx; }
.hero-meta-value { font-size: 25rpx; color: #6b7280; }
.progress-sticky-wrap { position: sticky; top: 0; z-index: 15; padding-top: 20rpx; padding-bottom: 8rpx; background: #f5f7fb; }
.progress-card { background: #ffffff; border-radius: 24rpx; padding: 24rpx; box-shadow: 0 6rpx 18rpx rgba(15, 23, 42, 0.05); }
.progress-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16rpx; }
.progress-title { font-size: 30rpx; font-weight: 600; color: #374151; }
.progress-count { font-size: 40rpx; font-weight: 700; color: #1f7cff; }
.progress-track { height: 16rpx; border-radius: 999rpx; background: #edf2f7; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999rpx; background: linear-gradient(90deg, #1f7cff, #4da3ff); }
.result-list { margin-top: 20rpx; display: flex; flex-direction: column; gap: 20rpx; }
.result-card { background: #ffffff; border-radius: 24rpx; padding: 24rpx; box-shadow: 0 6rpx 18rpx rgba(15, 23, 42, 0.05); }
.result-header { display: flex; align-items: center; gap: 16rpx; }
.result-index { width: 44rpx; height: 44rpx; border-radius: 50%; background: #1f7cff; color: #ffffff; font-size: 24rpx; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.result-title { flex: 1; min-width: 0; font-size: 40rpx; font-weight: 700; color: #1f2937; }
.required-tag { padding: 8rpx 16rpx; border-radius: 10rpx; background: #e8fff2; color: #22c55e; font-size: 24rpx; }
.result-fields { margin-top: 16rpx; display: flex; flex-direction: column; gap: 18rpx; }
.field-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 20rpx; }
.field-row-top { align-items: flex-start; }
.field-label { width: 170rpx; font-size: 27rpx; color: #9ca3af; flex-shrink: 0; }
.field-value { flex: 1; text-align: right; font-size: 28rpx; color: #374151; line-height: 1.5; }
.field-value.multiline { text-align: left; }
.field-block { display: flex; flex-direction: column; gap: 14rpx; }
.block-label { width: auto; }
.result-option-group { display: flex; align-items: center; gap: 16rpx; flex-wrap: wrap; }
.result-option { min-width: 160rpx; height: 72rpx; padding: 0 24rpx; border-radius: 14rpx; border: 1rpx solid #d1d5db; color: #6b7280; font-size: 30rpx; display: flex; align-items: center; justify-content: center; background: #ffffff; }
.result-option-active { border-color: #60a5fa; background: #eff6ff; color: #1f7cff; }
.result-option-danger { border-color: #fca5a5; background: #fef2f2; color: #ef4444; }
.pending-tag { padding: 8rpx 14rpx; border-radius: 10rpx; background: #f3f4f6; color: #9ca3af; font-size: 24rpx; }
.readonly-box { min-height: 84rpx; padding: 18rpx 20rpx; border-radius: 14rpx; background: #f8fafc; font-size: 28rpx; color: #374151; line-height: 1.5; }
.form-textarea { width: 100%; min-height: 76rpx; max-height: 108rpx; background: #f8fafc; border-radius: 12rpx; padding: 10rpx 16rpx; font-size: 26rpx; color: #374151; box-sizing: border-box; }
.image-list { display: flex; flex-wrap: wrap; gap: 12rpx; }
.image-item { position: relative; }
.result-image { width: 140rpx; height: 140rpx; border-radius: 16rpx; background: #f3f4f6; }
.image-remove { position: absolute; top: -12rpx; right: -12rpx; width: 36rpx; height: 36rpx; border-radius: 18rpx; background: rgba(15, 23, 42, 0.72); color: #ffffff; display: flex; align-items: center; justify-content: center; font-size: 24rpx; }
.image-upload { width: 140rpx; height: 140rpx; border-radius: 16rpx; border: 2rpx dashed #cbd5e1; background: #f8fafc; display: flex; align-items: center; justify-content: center; }
.image-upload-icon { font-size: 60rpx; color: #94a3b8; line-height: 1; }
.hint { padding: 48rpx 0; text-align: center; color: #9ca3af; font-size: 26rpx; }
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 20rpx; padding: 20rpx 24rpx calc(20rpx + env(safe-area-inset-bottom)); background: #f5f7fb; }
.action-btn { flex: 1; height: 88rpx; border-radius: 18rpx; display: flex; align-items: center; justify-content: center; font-size: 30rpx; font-weight: 600; }
.back-btn { background: #ffffff; color: #1f7cff; border: 1rpx solid #bfdbfe; }
.save-btn { background: linear-gradient(135deg, #1f7cff, #3b82f6); color: #ffffff; }
.action-btn-disabled { background: #94a3b8; }
</style>

@ -0,0 +1,321 @@
<template>
<view class="page-container">
<NavBar :title="t('equipmentInspectionRecord.moduleName')" />
<view class="search-card">
<view class="search-row">
<view class="search-input-wrap">
<text class="iconfont icon-search search-icon"></text>
<input
v-model="searchKeyword"
class="search-input"
:placeholder="t('equipmentInspectionRecord.searchPlaceholder')"
confirm-type="search"
@confirm="handleSearch"
/>
</view>
<view class="search-btn" @click="handleSearch">{{ t('functionCommon.search') }}</view>
</view>
<view class="filter-row">
<picker mode="selector" :range="taskTypeLabels" :value="taskTypeIndex" @change="onTaskTypeChange">
<view class="picker-chip">{{ currentTaskTypeLabel }}</view>
</picker>
<picker mode="selector" :range="jobStatusLabels" :value="jobStatusIndex" @change="onJobStatusChange">
<view class="picker-chip">{{ currentJobStatusLabel }}</view>
</picker>
<view class="reset-btn" @click="resetFilters">{{ t('functionCommon.reset') }}</view>
</view>
</view>
<scroll-view scroll-y class="list-scroll" :scroll-top="scrollTop" @scroll="onScroll" @scrolltolower="loadMore" :lower-threshold="80">
<view class="list-wrap">
<view v-for="item in list" :key="item.id" class="task-card" @click="openDetail(item)">
<view class="card-header">
<view class="header-main">
<text class="task-name">{{ textValue(item.planNo) }}</text>
<text :class="['task-type-tag', String(item.planType) === '1' ? 'tag-inspect' : 'tag-maintain']">{{ taskTypeText(item.planType) }}</text>
</view>
</view>
<view class="card-body">
<view class="row">
<text class="label">{{ t('equipmentInspectionRecord.deviceName') }}</text>
<text class="value">{{ textValue(item.deviceName) }}</text>
</view>
<view class="row">
<text class="label">{{ t('equipmentInspectionRecord.configName') }}</text>
<text class="value">{{ textValue(item.configName) }}</text>
</view>
<view class="row">
<text class="label">{{ t('equipmentInspectionRecord.jobStatus') }}</text>
<text :class="['value', jobStatusClass(item.jobStatus)]">{{ jobStatusText(item.jobStatus) }}</text>
</view>
<view class="row">
<text class="label">{{ t('equipmentInspectionRecord.taskTime') }}</text>
<text class="value">{{ formatDateTime(item.taskTime) }}</text>
</view>
<view class="row">
<text class="label">{{ t('equipmentInspectionRecord.jobResult') }}</text>
<text :class="['value', jobResultClass(item.jobResult)]">{{ jobResultText(item.jobResult) }}</text>
</view>
</view>
</view>
<view v-if="loading && pageNo === 1" class="hint">{{ t('functionCommon.loading') }}</view>
<view v-else-if="!list.length" class="hint">{{ t('equipmentInspectionRecord.empty') }}</view>
<view v-else-if="loadingMore" class="hint">{{ t('functionCommon.loadingMore') }}</view>
<view v-else-if="finished" class="hint">{{ t('functionCommon.noMoreData') }}</view>
</view>
</scroll-view>
<view v-if="showGoTop" class="go-top-btn" @click="goTop">
<uni-icons type="arrow-up" size="20" color="#1a3a5c"></uni-icons>
</view>
</view>
</template>
<script setup>
import { computed, nextTick, ref } from 'vue'
import { onLoad, onReachBottom } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { getEquipmentInspectionRecordPage } from '@/api/mes/equipmentInspectionRecord'
import { DICT_TYPE, getDictLabel, initAllDict } from '@/utils/dict'
const { t } = useI18n()
const searchKeyword = ref('')
const selectedTaskType = ref('')
const selectedJobStatus = ref('')
const list = ref([])
const loading = ref(false)
const loadingMore = ref(false)
const finished = ref(false)
const pageNo = ref(1)
const pageSize = ref(10)
const scrollTop = ref(0)
const showGoTop = ref(false)
const taskTypeOptions = computed(() => [
{ label: t('functionCommon.all'), value: '' },
{ label: t('equipmentInspectionRecord.taskTypeInspect'), value: '1' },
{ label: t('equipmentInspectionRecord.taskTypeMaintain'), value: '2' }
])
const jobStatusOptions = computed(() => [
{ label: t('functionCommon.all'), value: '' },
{ label: t('equipmentInspectionRecord.jobStatusPending'), value: '0' },
{ label: t('equipmentInspectionRecord.jobStatusProcessing'), value: '1' },
{ label: t('equipmentInspectionRecord.jobStatusCompleted'), value: '2' },
{ label: t('equipmentInspectionRecord.jobStatusTimeout'), value: '3' },
{ label: t('equipmentInspectionRecord.jobStatusCancelled'), value: '4' }
])
const taskTypeLabels = computed(() => taskTypeOptions.value.map((item) => item.label))
const jobStatusLabels = computed(() => jobStatusOptions.value.map((item) => item.label))
const taskTypeIndex = computed(() => {
const index = taskTypeOptions.value.findIndex((item) => item.value === selectedTaskType.value)
return index >= 0 ? index : 0
})
const jobStatusIndex = computed(() => {
const index = jobStatusOptions.value.findIndex((item) => item.value === selectedJobStatus.value)
return index >= 0 ? index : 0
})
const currentTaskTypeLabel = computed(() => {
const current = taskTypeOptions.value.find((item) => item.value === selectedTaskType.value)
return current ? current.label : t('functionCommon.all')
})
const currentJobStatusLabel = computed(() => {
const current = jobStatusOptions.value.find((item) => item.value === selectedJobStatus.value)
return current ? current.label : t('functionCommon.all')
})
onLoad(async () => {
await initAllDict()
await fetchList(true)
})
onReachBottom(() => {
loadMore()
})
async function fetchList(reset) {
if (reset) {
pageNo.value = 1
finished.value = false
}
if (pageNo.value === 1) {
loading.value = true
} else {
loadingMore.value = true
}
try {
const params = {
pageNo: pageNo.value,
pageSize: pageSize.value,
planNo: searchKeyword.value.trim() || undefined,
planType: selectedTaskType.value || undefined,
jobStatus: selectedJobStatus.value || undefined
}
const res = await getEquipmentInspectionRecordPage(params)
const page = normalizePageData(res)
list.value = reset ? page.list : [...list.value, ...page.list]
finished.value = list.value.length >= page.total || page.list.length < pageSize.value
} catch (error) {
if (!reset) pageNo.value = Math.max(1, pageNo.value - 1)
uni.showToast({ title: t('functionCommon.loadFailed'), icon: 'none' })
} finally {
loading.value = false
loadingMore.value = false
}
}
function normalizePageData(res) {
const root = res && res.data !== undefined ? res.data : res
const candidateList = root?.list || root?.rows || root?.records || root?.data?.list || root?.data?.rows || root?.data?.records || []
const candidateTotal = root?.total ?? root?.data?.total ?? (Array.isArray(candidateList) ? candidateList.length : 0)
return {
list: Array.isArray(candidateList) ? candidateList : [],
total: Number(candidateTotal || 0)
}
}
function handleSearch() {
uni.hideKeyboard()
fetchList(true)
}
async function resetFilters() {
searchKeyword.value = ''
selectedTaskType.value = ''
selectedJobStatus.value = ''
await nextTick()
await fetchList(true)
}
function onTaskTypeChange(event) {
const index = Number(event?.detail?.value || 0)
selectedTaskType.value = taskTypeOptions.value[index]?.value ?? ''
fetchList(true)
}
function onJobStatusChange(event) {
const index = Number(event?.detail?.value || 0)
selectedJobStatus.value = jobStatusOptions.value[index]?.value ?? ''
fetchList(true)
}
async function loadMore() {
if (loading.value || loadingMore.value || finished.value) return
pageNo.value += 1
await fetchList(false)
}
function openDetail(item) {
if (!item?.id) {
uni.showToast({ title: t('functionCommon.noIdView'), icon: 'none' })
return
}
uni.setStorageSync('equipmentInspectionRecordDetail', JSON.stringify(item))
uni.navigateTo({
url: `/pages_function/pages/equipmentInspectionRecord/detail?id=${encodeURIComponent(String(item.id))}`
})
}
function onScroll(event) {
showGoTop.value = (event?.detail?.scrollTop || 0) > 600
}
function goTop() {
scrollTop.value = 0
}
function taskTypeText(value) {
const normalized = String(value)
if (normalized === '1') return t('equipmentInspectionRecord.taskTypeInspect')
if (normalized === '2') return t('equipmentInspectionRecord.taskTypeMaintain')
return textValue(value)
}
function jobStatusText(value) {
return getDictLabel(DICT_TYPE.JOB_STATUS, value, textValue(value))
}
function jobStatusClass(value) {
const normalized = String(value)
if (normalized === '1') return 'text-primary'
if (normalized === '2') return 'text-success'
if (normalized === '3') return 'text-danger'
if (normalized === '4') return 'text-muted'
return 'text-warning'
}
function jobResultText(value) {
const normalized = String(value).trim().toUpperCase()
if (normalized === '1' || normalized === 'OK') return t('equipmentInspectionRecord.jobResultOk')
if (normalized === '2' || normalized === 'NG') return t('equipmentInspectionRecord.jobResultNg')
if (!normalized || normalized === '0') return '-'
return textValue(value)
}
function jobResultClass(value) {
const normalized = String(value).trim().toUpperCase()
if (normalized === '1' || normalized === 'OK') return 'text-success'
if (normalized === '2' || normalized === 'NG') return 'text-danger'
return ''
}
function textValue(value) {
if (value === 0) return '0'
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 [year, month, day, hour = 0, minute = 0, second = 0] = value
const pad = (num) => String(num).padStart(2, '0')
return `${year}-${pad(month)}-${pad(day)} ${pad(hour)}:${pad(minute)}:${pad(second)}`
}
const date = new Date(Number(value))
if (Number.isNaN(date.getTime())) return textValue(value)
const pad = (num) => String(num).padStart(2, '0')
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`
}
</script>
<style lang="scss" scoped>
.page-container { min-height: 100vh; background: #f4f5f7; }
.search-card { margin: 20rpx 24rpx 0; padding: 24rpx; background: #fff; border-radius: 20rpx; }
.search-row { display: flex; gap: 16rpx; align-items: center; }
.search-input-wrap { flex: 1; display: flex; align-items: center; gap: 12rpx; padding: 0 20rpx; min-height: 84rpx; background: #f8fafc; border-radius: 16rpx; }
.search-icon { color: #94a3b8; font-size: 30rpx; }
.search-input { flex: 1; font-size: 28rpx; color: #111827; }
.search-btn, .reset-btn { min-width: 120rpx; height: 84rpx; border-radius: 16rpx; display: flex; align-items: center; justify-content: center; font-size: 28rpx; font-weight: 600; }
.search-btn { background: #1f4b79; color: #fff; }
.filter-row { display: flex; gap: 16rpx; margin-top: 16rpx; flex-wrap: wrap; }
.picker-chip { min-width: 220rpx; padding: 0 20rpx; height: 72rpx; background: #eef4fb; border-radius: 14rpx; color: #1f4b79; font-size: 26rpx; display: flex; align-items: center; }
.reset-btn { background: #eef2f7; color: #475569; height: 72rpx; }
.list-scroll { height: calc(100vh - 304rpx); }
.list-wrap { padding: 0 24rpx 32rpx; }
.task-card { position: relative; margin-top: 20rpx; padding: 28rpx; background: #fff; border-radius: 22rpx; box-shadow: 0 8rpx 28rpx rgba(15, 23, 42, 0.06); }
.card-header { margin-bottom: 18rpx; }
.header-main { display: flex; align-items: center; justify-content: space-between; gap: 16rpx; }
.task-name { flex: 1; font-size: 32rpx; font-weight: 700; color: #0f172a; }
.task-type-tag { padding: 8rpx 18rpx; border-radius: 999rpx; font-size: 22rpx; }
.tag-inspect { color: #1d4ed8; background: #dbeafe; }
.tag-maintain { color: #15803d; background: #dcfce7; }
.card-body .row { display: flex; justify-content: space-between; align-items: flex-start; gap: 20rpx; padding: 10rpx 0; }
.label { width: 180rpx; font-size: 25rpx; color: #94a3b8; }
.value { flex: 1; text-align: right; font-size: 27rpx; color: #334155; line-height: 1.5; }
.text-success { color: #16a34a; }
.text-danger { color: #dc2626; }
.text-warning { color: #f59e0b; }
.text-primary { color: #2563eb; }
.text-muted { color: #94a3b8; }
.hint { padding: 36rpx 0; text-align: center; color: #94a3b8; font-size: 26rpx; }
.go-top-btn { position: fixed; right: 28rpx; bottom: calc(40rpx + env(safe-area-inset-bottom)); width: 88rpx; height: 88rpx; border-radius: 44rpx; background: rgba(255,255,255,0.96); box-shadow: 0 8rpx 24rpx rgba(15, 23, 42, 0.12); display: flex; align-items: center; justify-content: center; }
</style>

@ -38,22 +38,10 @@
<text class="label">{{ t('equipmentInspectionTasks.deviceList') }}</text>
<text class="value">{{ getDeviceNames(item.deviceList) }}</text>
</view>
<view class="row">
<text class="label">{{ t('equipmentInspectionTasks.projectFormName') }}</text>
<text class="value">{{ textValue(item.projectFormName) }}</text>
</view>
<view class="row">
<text class="label">{{ t('equipmentInspectionTasks.dateRange') }}</text>
<text class="value">{{ formatDate(item.startDate) }} ~ {{ formatDate(item.endDate) }}</text>
</view>
<view class="row">
<text class="label">{{ t('equipmentInspectionTasks.enabled') }}</text>
<text :class="['value', isEnabled(item.enabled) ? 'text-success' : 'text-danger']">{{ enabledText(item.enabled) }}</text>
</view>
<view class="row">
<text class="label">{{ t('equipmentInspectionTasks.creatorName') }}</text>
<text class="value">{{ textValue(item.creatorName) }}</text>
</view>
</view>
<view class="card-actions">
<view :class="['action-btn', ticketLoadingId === item.id ? 'action-btn-disabled' : 'ticket-btn']" @click.stop="handleCreateTicket(item)">

@ -46,6 +46,9 @@ const MENU_ROUTE_MAP = {
'设备点检任务': '/pages_function/pages/equipmentInspectionTasks/index',
equipmentinspectiontasks: '/pages_function/pages/equipmentInspectionTasks/index',
taskmanagement: '/pages_function/pages/equipmentInspectionTasks/index',
'设备点检记录': '/pages_function/pages/equipmentInspectionRecord/index',
equipmentinspectionrecord: '/pages_function/pages/equipmentInspectionRecord/index',
equipmentinspectionrecords: '/pages_function/pages/equipmentInspectionRecord/index',
'设备关键件': '/pages_function/pages/criticalComponent/index',
criticalcomponent: '/pages_function/pages/criticalComponent/index',
equipmentkeypart: '/pages_function/pages/equipmentKeypart/index',

Loading…
Cancel
Save