From b88332e0a2686e68023e26438af97f79247b1ddd Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期六, 16 五月 2026 14:14:53 +0800
Subject: [PATCH] feat: 设备保养修改,新增保养人、详情
---
src/views/equipmentManagement/upkeep/index.vue | 111 ++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 72 insertions(+), 39 deletions(-)
diff --git a/src/views/equipmentManagement/upkeep/index.vue b/src/views/equipmentManagement/upkeep/index.vue
index 4cf6fc0..9820910 100644
--- a/src/views/equipmentManagement/upkeep/index.vue
+++ b/src/views/equipmentManagement/upkeep/index.vue
@@ -162,23 +162,19 @@
@selection-change="handleSelectionChange"
@pagination="changePage"
>
- <template #maintenanceResultRef="{ row }">
- <div>{{ row.maintenanceResult || '-' }}</div>
- </template>
<template #statusRef="{ row }">
<el-tag v-if="row.status === 2" type="danger">澶辫触</el-tag>
<el-tag v-if="row.status === 1" type="success">瀹岀粨</el-tag>
<el-tag v-if="row.status === 0" type="warning">寰呬繚鍏�</el-tag>
</template>
<template #operation="{ row }">
- <!-- 杩欎釜鍔熻兘璺熸柊澧炰繚鍏诲姛鑳戒竴妯′竴鏍凤紝鏈夊暐鎰忎箟锛� -->
- <!-- <el-button
- type="primary"
- text
- @click="addMaintain(row)"
+ <el-button
+ type="primary"
+ link
+ @click="openDetail(row)"
>
- 鏂板淇濆吇
- </el-button> -->
+ 璇︽儏
+ </el-button>
<el-button
type="primary"
link
@@ -218,15 +214,20 @@
<PlanModal ref="planModalRef" @ok="getTableData" />
<MaintenanceModal ref="maintainModalRef" @ok="getTableData" />
<FormDia ref="formDiaRef" @closeDia="getScheduledTableData" />
- <FileListDialog
+ <UpkeepDetailModal ref="upkeepDetailModalRef" :java-api="javaApi" />
+ <FileListDialog
ref="fileListDialogRef"
v-model="fileDialogVisible"
- :show-upload-button="true"
- :show-delete-button="true"
+ :title="currentRecordFinished ? '闄勪欢锛堝凡瀹岀粨锛屼粎鍙煡鐪嬶級' : '闄勪欢'"
+ :show-upload-button="!currentRecordFinished"
+ :show-delete-button="!currentRecordFinished"
:delete-method="handleAttachmentDelete"
:name-column-label="'闄勪欢鍚嶇О'"
- :rulesRegulationsManagementId="currentMaintenanceTaskId"
- @upload="handleAttachmentUpload" />
+ :upload-url="maintenanceFileUploadUrl"
+ :upload-data="maintenanceFileUploadData"
+ :upload-direct-save="true"
+ @upload="refreshFileList"
+ />
</div>
</template>
@@ -236,6 +237,7 @@
import { ElMessage, ElMessageBox } from 'element-plus'
import PlanModal from './Form/PlanModal.vue'
import MaintenanceModal from './Form/MaintenanceModal.vue'
+import UpkeepDetailModal from './Form/UpkeepDetailModal.vue'
import FormDia from './Form/formDia.vue'
import FileListDialog from '@/components/Dialog/FileListDialog.vue'
import {
@@ -246,7 +248,6 @@
} from '@/api/equipmentManagement/upkeep'
import {
listMaintenanceTaskFiles,
- addMaintenanceTaskFile,
delMaintenanceTaskFile,
} from '@/api/equipmentManagement/maintenanceTaskFile'
import dayjs from 'dayjs'
@@ -260,12 +261,40 @@
const planModalRef = ref()
// 淇濆吇寮圭獥鎺у埗鍣�
const maintainModalRef = ref()
+const upkeepDetailModalRef = ref()
// 瀹氭椂浠诲姟寮圭獥鎺у埗鍣�
const formDiaRef = ref()
// 闄勪欢寮圭獥
const fileListDialogRef = ref(null)
const fileDialogVisible = ref(false)
const currentMaintenanceTaskId = ref(null)
+/** 褰撳墠闄勪欢鎵�灞炶褰曟槸鍚﹀凡瀹岀粨锛坰tatus=1锛� */
+const currentRecordFinished = ref(false)
+
+const javaApi = import.meta.env.VITE_APP_BASE_API
+const maintenanceFileUploadUrl = `${javaApi}/maintenanceTaskFile/upload`
+const maintenanceFileUploadData = computed(() => ({
+ deviceMaintenanceId: currentMaintenanceTaskId.value,
+}))
+
+const normalizeMaintenanceFileUrl = (rawUrl = "") => {
+ let fileUrl = rawUrl || ""
+ if (!fileUrl) return ""
+ if (fileUrl.startsWith("http://") || fileUrl.startsWith("https://")) return fileUrl
+ if (fileUrl.indexOf("\\") > -1) {
+ const lowerPath = fileUrl.toLowerCase()
+ const uploadPathIndex = lowerPath.indexOf("uploadpath")
+ if (uploadPathIndex > -1) {
+ fileUrl = fileUrl.substring(uploadPathIndex).replace(/\\/g, "/")
+ } else {
+ fileUrl = fileUrl.replace(/\\/g, "/")
+ }
+ }
+ fileUrl = fileUrl.replace(/^\/?uploadPath/i, "/profile")
+ if (!fileUrl.startsWith("/")) fileUrl = "/" + fileUrl
+ if (!fileUrl.startsWith(javaApi)) fileUrl = javaApi + fileUrl
+ return fileUrl
+}
// 浠诲姟璁板綍tab锛堝師璁惧淇濆吇椤甸潰锛夌浉鍏冲彉閲�
const filters = reactive({
@@ -338,6 +367,13 @@
}
},
{ prop: "registrant", label: "鐧昏浜�", minWidth: 100 },
+ { prop: "maintenancePerson", label: "淇濆吇浜�", minWidth: 100 },
+ {
+ prop: "maintenanceItems",
+ label: "淇濆吇椤圭洰",
+ minWidth: 180,
+ showOverflowTooltip: true,
+ },
{ prop: "registrationDate", label: "鐧昏鏃ユ湡", minWidth: 100 },
{
fixed: "right",
@@ -365,6 +401,12 @@
label: "淇濆吇椤圭洰",
align: "center",
prop: "maintenanceLocation",
+ showOverflowTooltip: true,
+ },
+ {
+ label: "淇濆吇浜�",
+ align: "center",
+ prop: "maintenancePerson",
},
{
label: "璁″垝淇濆吇鏃ユ湡",
@@ -400,8 +442,8 @@
label: "淇濆吇缁撴灉",
align: "center",
prop: "maintenanceResult",
- dataType: "slot",
- slot: "maintenanceResultRef",
+ minWidth: 200,
+ showOverflowTooltip: true,
},
{
label: "鐘舵��",
@@ -416,7 +458,7 @@
dataType: "slot",
slot: "operation",
align: "center",
- width: "350px",
+ width: "400px",
},
])
@@ -610,14 +652,13 @@
current: 1,
size: 100,
deviceMaintenanceId,
- rulesRegulationsManagementId:deviceMaintenanceId
}
const res = await listMaintenanceTaskFiles(params)
const records = res?.data?.records || []
const mapped = records.map(item => ({
id: item.id,
name: item.fileName || item.name,
- url: item.fileUrl || item.url,
+ url: normalizeMaintenanceFileUrl(item.fileUrl || item.url),
raw: item,
}))
fileListDialogRef.value?.setList(mapped)
@@ -626,9 +667,14 @@
}
}
+const openDetail = (row) => {
+ upkeepDetailModalRef.value?.open(row)
+}
+
// 鎵撳紑闄勪欢寮圭獥
const openFileDialog = async (row) => {
currentMaintenanceTaskId.value = row.id
+ currentRecordFinished.value = row.status === 1
fileDialogVisible.value = true
await fetchMaintenanceTaskFiles(row.id)
}
@@ -639,25 +685,12 @@
await fetchMaintenanceTaskFiles(currentMaintenanceTaskId.value)
}
-// 涓婁紶闄勪欢
-const handleAttachmentUpload = async (filePayload) => {
- if (!currentMaintenanceTaskId.value) return
- try {
- const payload = {
- name: filePayload?.fileName || filePayload?.name,
- url: filePayload?.fileUrl || filePayload?.url,
- deviceMaintenanceId: currentMaintenanceTaskId.value,
- }
- await addMaintenanceTaskFile(payload)
- ElMessage.success('鏂囦欢涓婁紶鎴愬姛')
- await refreshFileList()
- } catch (error) {
- ElMessage.error('鏂囦欢涓婁紶澶辫触')
- }
-}
-
-// 鍒犻櫎闄勪欢
+// 鍒犻櫎闄勪欢锛堝凡瀹岀粨涓嶅彲鍒狅級
const handleAttachmentDelete = async (row) => {
+ if (currentRecordFinished.value) {
+ ElMessage.warning('璇ヤ繚鍏诲凡瀹岀粨锛屼笉鍙垹闄ら檮浠�')
+ return false
+ }
if (!row?.id) return false
try {
await ElMessageBox.confirm('纭鍒犻櫎璇ラ檮浠讹紵', '鎻愮ず', { type: 'warning' })
--
Gitblit v1.9.3