feat:设备运维-点检记录页面
parent
fddd0fad61
commit
456678b5d2
@ -1,2 +1,2 @@
|
|||||||
VITE_APP_BASE_URL=http://192.168.5.106:48081
|
VITE_APP_BASE_URL=http://192.168.43.233:48081
|
||||||
# VITE_APP_BASE_URL=http://47.106.185.127:8089
|
# 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
|
||||||
|
})
|
||||||
|
}
|
||||||
@ -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>
|
||||||
Loading…
Reference in New Issue