feat:设备运维-点检任务模块

master
黄伟杰 2 weeks ago
parent e3a3d9330e
commit 38e6800e78

@ -0,0 +1,17 @@
import request from '@/utils/request'
export function getTaskManagementPage(params = {}) {
return request({
url: '/admin-api/mes/task-management/page',
method: 'get',
params
})
}
export function createTaskManagementTicket(id) {
return request({
url: '/admin-api/mes/task-management/createTicket',
method: 'post',
params: { id }
})
}

@ -451,6 +451,29 @@ export default {
planSelectTitle: 'Select Inspection Plans',
userSelectTitle: 'Select Operable Users'
},
equipmentInspectionTasks: {
moduleName: 'Equipment Inspection Tasks',
subTitle: 'Work order management for equipment inspection tasks',
detailTitle: 'Equipment Inspection Task Detail',
basicInfo: 'Basic Info',
name: 'Task Name',
taskType: 'Task Type',
taskTypeInspect: 'Inspection',
taskTypeMaintain: 'Maintenance',
deviceList: 'Device List',
projectFormName: 'Project Form',
dateRange: 'Valid Date Range',
cronExpression: 'Cron Expression',
operableUsers: 'Operable Users',
enabled: 'Enabled',
creatorName: 'Creator',
createTime: 'Created At',
updateTime: 'Updated At',
searchPlaceholder: 'Enter task name',
empty: 'No equipment inspection tasks',
createTicketSuccess: 'Work order created successfully',
createTicketFail: 'Work order creation failed'
},
moldWorkOrder: {
moduleName: 'Inspection Records',
subTitle: 'Mold management inspection records',

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

@ -451,6 +451,29 @@ export default {
planSelectTitle: '选择点检模板',
userSelectTitle: '选择可操作用户'
},
equipmentInspectionTasks: {
moduleName: '设备点检任务',
subTitle: '设备点检任务工单管理',
detailTitle: '设备点检任务详情',
basicInfo: '基础信息',
name: '任务名称',
taskType: '任务类型',
taskTypeInspect: '点检',
taskTypeMaintain: '保养',
deviceList: '设备列表',
projectFormName: '项目方案',
dateRange: '有效日期',
cronExpression: 'Cron表达式',
operableUsers: '可操作用户',
enabled: '是否启用',
creatorName: '创建人',
createTime: '创建时间',
updateTime: '更新时间',
searchPlaceholder: '请输入任务名称',
empty: '暂无设备点检任务数据',
createTicketSuccess: '工单创建成功',
createTicketFail: '工单创建失败'
},
moldWorkOrder: {
moduleName: '点检记录',
subTitle: '模具管理点检记录查询',

@ -645,6 +645,20 @@
"navigationStyle": "custom"
}
},
{
"path": "equipmentInspectionTasks/index",
"style": {
"navigationBarTitleText": "设备点检任务",
"navigationStyle": "custom"
}
},
{
"path": "equipmentInspectionTasks/detail",
"style": {
"navigationBarTitleText": "设备点检任务详情",
"navigationStyle": "custom"
}
},
{
"path": "planList/index",
"style": {

@ -0,0 +1,189 @@
<template>
<view class="page-container">
<view class="fixed-header">
<NavBar :title="t('equipmentInspectionTasks.detailTitle')" />
</view>
<scroll-view scroll-y class="detail-scroll">
<view class="content-section">
<view class="info-card">
<view class="card-title">{{ t('equipmentInspectionTasks.basicInfo') }}</view>
<view class="info-row">
<text class="info-label">{{ t('equipmentInspectionTasks.name') }}</text>
<text class="info-value">{{ textValue(detailData.name) }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('equipmentInspectionTasks.taskType') }}</text>
<text class="info-value">{{ taskTypeText }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('equipmentInspectionTasks.deviceList') }}</text>
<text class="info-value">{{ deviceListText }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('equipmentInspectionTasks.projectFormName') }}</text>
<text class="info-value">{{ textValue(detailData.projectFormName) }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('equipmentInspectionTasks.dateRange') }}</text>
<text class="info-value">{{ formatDate(detailData.startDate) }} ~ {{ formatDate(detailData.endDate) }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('equipmentInspectionTasks.cronExpression') }}</text>
<text class="info-value">{{ textValue(detailData.cronExpression) }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('equipmentInspectionTasks.operableUsers') }}</text>
<text class="info-value">{{ textValue(detailData.operableUsers) }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('equipmentInspectionTasks.enabled') }}</text>
<text :class="['info-value', isEnabled(detailData.enabled) ? 'text-success' : 'text-danger']">{{ enabledText(detailData.enabled) }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('equipmentInspectionTasks.creatorName') }}</text>
<text class="info-value">{{ textValue(detailData.creatorName) }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('equipmentInspectionTasks.createTime') }}</text>
<text class="info-value">{{ formatDateTime(detailData.createTime) }}</text>
</view>
<view class="info-row no-border">
<text class="info-label">{{ t('equipmentInspectionTasks.updateTime') }}</text>
<text class="info-value">{{ formatDateTime(detailData.updateTime) }}</text>
</view>
</view>
</view>
</scroll-view>
<view class="action-bar">
<view :class="['action-btn', ticketLoading ? 'action-btn-disabled' : '']" @click="handleCreateTicket">
{{ t('equipmentInspectionTasks.createTicket') }}
</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 { createTaskManagementTicket } from '@/api/mes/taskManagement'
const { t } = useI18n()
const detailData = reactive({})
const ticketLoading = ref(false)
const taskTypeText = computed(() => {
const normalized = Number(detailData.taskType)
if (normalized === 1) return t('equipmentInspectionTasks.taskTypeInspect')
if (normalized === 2) return t('equipmentInspectionTasks.taskTypeMaintain')
return textValue(detailData.taskType)
})
const deviceListText = computed(() => {
const value = detailData.deviceListText || detailData.deviceList
if (Array.isArray(value)) return value.join('') || '-'
return textValue(value)
})
onLoad(() => {
try {
const cached = uni.getStorageSync('equipmentInspectionTasksDetail')
if (cached) {
Object.assign(detailData, JSON.parse(cached))
uni.removeStorageSync('equipmentInspectionTasksDetail')
}
} catch (error) {}
})
async function handleCreateTicket() {
if (!detailData.id || ticketLoading.value) return
ticketLoading.value = true
try {
await createTaskManagementTicket(detailData.id)
uni.showToast({ title: t('equipmentInspectionTasks.createTicketSuccess'), icon: 'success' })
} catch (error) {
uni.showToast({ title: t('equipmentInspectionTasks.createTicketFail'), icon: 'none' })
} finally {
ticketLoading.value = false
}
}
function isEnabled(value) {
return value === true || value === 1 || value === '1' || value === 'true'
}
function enabledText(value) {
return isEnabled(value) ? t('functionCommon.yes') : t('functionCommon.no')
}
function textValue(value) {
if (value === 0) return '0'
if (value === null || value === undefined) return '-'
const text = String(value).trim()
return text || '-'
}
function formatDate(value) {
if (!value) return '-'
if (Array.isArray(value) && value.length >= 3) {
const [year, month, day] = value
const pad = (num) => String(num).padStart(2, '0')
return `${year}-${pad(month)}-${pad(day)}`
}
return String(value).trim().substring(0, 10) || '-'
}
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-color: #f0f2f5; }
.fixed-header { position: sticky; top: 0; z-index: 20; }
.detail-scroll { height: calc(100vh - 200rpx); }
.content-section { padding: 0 24rpx 24rpx; }
.info-card { margin-top: 20rpx; background: #fff; 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-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 18rpx 0; border-bottom: 1rpx solid #edf0f3; }
.no-border { border-bottom: none; }
.info-label { width: 220rpx; font-size: 27rpx; color: #8a9099; }
.info-value { flex: 1; text-align: right; font-size: 28rpx; color: #303133; line-height: 1.45; }
.text-success { color: #18bc37; }
.text-danger { color: #e34d59; }
.action-bar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 20rpx 24rpx calc(20rpx + env(safe-area-inset-bottom));
background: #f0f2f5;
}
.action-btn {
height: 88rpx;
border-radius: 16rpx;
background: #1f4b79;
color: #ffffff;
font-size: 30rpx;
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
}
.action-btn-disabled {
background: #94a3b8;
}
</style>

@ -0,0 +1,324 @@
<template>
<view class="page-container">
<NavBar :title="t('equipmentInspectionTasks.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('equipmentInspectionTasks.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>
<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.name) }}</text>
<text :class="['task-type-tag', Number(item.taskType) === 1 ? 'tag-inspect' : 'tag-maintain']">{{ taskTypeText(item.taskType) }}</text>
</view>
</view>
<view class="card-body">
<view class="row">
<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)">
<uni-icons type="paperplane" size="18" color="#ffffff"></uni-icons>
</view>
</view>
</view>
<view v-if="loading && pageNo === 1" class="hint">{{ t('functionCommon.loading') }}</view>
<view v-else-if="!list.length" class="hint">{{ t('equipmentInspectionTasks.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 { getTaskManagementPage, createTaskManagementTicket } from '@/api/mes/taskManagement'
import { getDeviceLedgerList } from '@/api/mes/deviceLedger'
const { t } = useI18n()
const searchKeyword = ref('')
const selectedTaskType = 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 ticketLoadingId = ref(null)
const deviceOptions = ref([])
const taskTypeOptions = computed(() => [
{ label: t('functionCommon.all'), value: '' },
{ label: t('equipmentInspectionTasks.taskTypeInspect'), value: '1' },
{ label: t('equipmentInspectionTasks.taskTypeMaintain'), value: '2' }
])
const taskTypeLabels = computed(() => taskTypeOptions.value.map((item) => item.label))
const taskTypeIndex = computed(() => {
const index = taskTypeOptions.value.findIndex((item) => item.value === selectedTaskType.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')
})
onLoad(async () => {
await Promise.all([ensureDeviceOptionsLoaded(), fetchList(true)])
})
onReachBottom(() => {
loadMore()
})
async function ensureDeviceOptionsLoaded() {
try {
const res = await getDeviceLedgerList()
const root = res && res.data !== undefined ? res.data : res
const data = Array.isArray(root) ? root : (Array.isArray(root?.data) ? root.data : root?.list || [])
deviceOptions.value = (Array.isArray(data) ? data : [])
.filter((item) => item && item.id !== undefined && item.id !== null)
.map((item) => ({
id: item.id,
label: `${item.deviceCode || ''} ${item.deviceName || ''}`.trim(),
deviceName: item.deviceName || '',
raw: item
}))
} catch (error) {
deviceOptions.value = []
}
}
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,
name: searchKeyword.value.trim() || undefined,
taskType: selectedTaskType.value || undefined
}
const res = await getTaskManagementPage(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 = ''
await nextTick()
await fetchList(true)
}
function onTaskTypeChange(event) {
const index = Number(event?.detail?.value || 0)
selectedTaskType.value = taskTypeOptions.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('equipmentInspectionTasksDetail', JSON.stringify(item))
uni.navigateTo({
url: `/pages_function/pages/equipmentInspectionTasks/detail?id=${encodeURIComponent(String(item.id))}`
})
}
async function handleCreateTicket(item) {
if (!item?.id || ticketLoadingId.value) return
ticketLoadingId.value = item.id
try {
await createTaskManagementTicket(item.id)
uni.showToast({ title: t('equipmentInspectionTasks.createTicketSuccess'), icon: 'success' })
} catch (error) {
uni.showToast({ title: t('equipmentInspectionTasks.createTicketFail'), icon: 'none' })
} finally {
ticketLoadingId.value = null
}
}
function onScroll(event) {
showGoTop.value = (event?.detail?.scrollTop || 0) > 600
}
function goTop() {
scrollTop.value = 0
}
function parseIdsValue(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 getDeviceNames(value) {
const ids = parseIdsValue(value)
if (!ids.length) return '-'
const names = ids
.map((id) => {
const matched = deviceOptions.value.find((item) => String(item.id) === id)
return matched?.deviceName || matched?.label || id
})
.filter(Boolean)
return names.length ? names.join('') : '-'
}
function taskTypeText(value) {
const normalized = Number(value)
if (normalized === 1) return t('equipmentInspectionTasks.taskTypeInspect')
if (normalized === 2) return t('equipmentInspectionTasks.taskTypeMaintain')
return textValue(value)
}
function isEnabled(value) {
return value === true || value === 1 || value === '1' || value === 'true'
}
function enabledText(value) {
return isEnabled(value) ? t('functionCommon.yes') : t('functionCommon.no')
}
function textValue(value) {
if (value === 0) return '0'
if (value === null || value === undefined) return '-'
const text = String(value).trim()
return text || '-'
}
function formatDate(value) {
if (!value) return '-'
if (Array.isArray(value) && value.length >= 3) {
const [year, month, day] = value
const pad = (num) => String(num).padStart(2, '0')
return `${year}-${pad(month)}-${pad(day)}`
}
return String(value).trim().substring(0, 10) || '-'
}
</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; }
.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 - 272rpx); }
.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; }
.card-actions { display: flex; justify-content: flex-end; margin-top: 18rpx; }
.action-btn { width: 72rpx; height: 72rpx; border-radius: 18rpx; display: flex; align-items: center; justify-content: center; }
.ticket-btn { background: linear-gradient(135deg, #1f4b79, #2f6ea8); }
.action-btn-disabled { background: #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>

@ -43,6 +43,9 @@ const MENU_ROUTE_MAP = {
'设备维修': '/pages_function/pages/equipmentMaintenance/index',
equipmentmaintenance: '/pages_function/pages/equipmentMaintenance/index',
dvrepair: '/pages_function/pages/equipmentMaintenance/index',
'设备点检任务': '/pages_function/pages/equipmentInspectionTasks/index',
equipmentinspectiontasks: '/pages_function/pages/equipmentInspectionTasks/index',
taskmanagement: '/pages_function/pages/equipmentInspectionTasks/index',
'设备关键件': '/pages_function/pages/criticalComponent/index',
criticalcomponent: '/pages_function/pages/criticalComponent/index',
equipmentkeypart: '/pages_function/pages/equipmentKeypart/index',

Loading…
Cancel
Save