From 376cab4afba8fd1b8be67cae067ed917462c2e16 Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期四, 18 十二月 2025 09:05:12 +0800
Subject: [PATCH] 添加设备报修和保养附件管理功能,维修保养过程描述

---
 src/views/equipmentManagement/upkeep/index.vue           |   25 ++
 src/api/equipmentManagement/repair.js                    |   24 ++
 src/views/equipmentManagement/repair/filesDia.vue        |  199 ++++++++++++++++++++++
 src/views/equipmentManagement/upkeep/filesDia.vue        |  199 ++++++++++++++++++++++
 src/views/equipmentManagement/repair/index.vue           |   29 ++
 src/views/equipmentManagement/repair/Form/RepairForm.vue |   12 +
 src/api/equipmentManagement/upkeep.js                    |   24 ++
 7 files changed, 502 insertions(+), 10 deletions(-)

diff --git a/src/api/equipmentManagement/repair.js b/src/api/equipmentManagement/repair.js
index 0233ae6..320db96 100644
--- a/src/api/equipmentManagement/repair.js
+++ b/src/api/equipmentManagement/repair.js
@@ -70,3 +70,27 @@
     data,
   });
 };
+// 鏌ヨ闄勪欢鍒楄〃
+export function fileListPage(query) {
+    return request({
+        url: "/device/deviceRepairFile/listPage",
+        method: "get",
+        params: query,
+    });
+}
+// 淇濆瓨闄勪欢鍒楄〃
+export function fileAdd(query) {
+    return request({
+        url: "/device/deviceRepairFile/add",
+        method: "post",
+        data: query,
+    });
+}
+// 鍒犻櫎闄勪欢鍒楄〃
+export function fileDel(query) {
+    return request({
+        url: "/device/deviceRepairFile/del",
+        method: "delete",
+        data: query,
+    });
+}
\ No newline at end of file
diff --git a/src/api/equipmentManagement/upkeep.js b/src/api/equipmentManagement/upkeep.js
index c091670..d4c2d54 100644
--- a/src/api/equipmentManagement/upkeep.js
+++ b/src/api/equipmentManagement/upkeep.js
@@ -70,3 +70,27 @@
     method: "delete",
   });
 };
+// 鏌ヨ闄勪欢鍒楄〃
+export function fileListPage(query) {
+    return request({
+        url: "/device/deviceMaintenanceFile/listPage",
+        method: "get",
+        params: query,
+    });
+}
+// 淇濆瓨闄勪欢鍒楄〃
+export function fileAdd(query) {
+    return request({
+        url: "/device/deviceMaintenanceFile/add",
+        method: "post",
+        data: query,
+    });
+}
+// 鍒犻櫎闄勪欢鍒楄〃
+export function fileDel(query) {
+    return request({
+        url: "/device/deviceMaintenanceFile/del",
+        method: "delete",
+        data: query,
+    });
+}
\ No newline at end of file
diff --git a/src/views/equipmentManagement/repair/Form/RepairForm.vue b/src/views/equipmentManagement/repair/Form/RepairForm.vue
index 1fadde4..b6790f1 100644
--- a/src/views/equipmentManagement/repair/Form/RepairForm.vue
+++ b/src/views/equipmentManagement/repair/Form/RepairForm.vue
@@ -50,6 +50,16 @@
           />
         </el-form-item>
       </el-col>
+      <el-col :span="24">
+        <el-form-item label="杩囩▼鎻忚堪">
+          <el-input
+              v-model="form.maintenanceProcessDesc"
+              :rows="2"
+              type="textarea"
+              placeholder="璇疯緭鍏ヨ繃绋嬫弿杩�"
+          />
+        </el-form-item>
+      </el-col>
     </el-row>
   </el-form>
 </template>
@@ -78,6 +88,7 @@
   repairTime: undefined, // 鎶ヤ慨鏃ユ湡
   repairName: userStore.nickName, // 鎶ヤ慨浜�
   remark: undefined, // 鏁呴殰鐜拌薄
+  maintenanceProcessDesc: undefined, // 杩囩▼鎻忚堪
 });
 
 const setDeviceModel = (id) => {
@@ -96,6 +107,7 @@
   form.repairTime = data.repairTime;
   form.repairName = data.repairName;
   form.remark = data.remark;
+  form.maintenanceProcessDesc = data.maintenanceProcessDesc;
 };
 
 // onMounted(() => {
diff --git a/src/views/equipmentManagement/repair/filesDia.vue b/src/views/equipmentManagement/repair/filesDia.vue
new file mode 100644
index 0000000..b328593
--- /dev/null
+++ b/src/views/equipmentManagement/repair/filesDia.vue
@@ -0,0 +1,199 @@
+<template>
+  <div>
+    <el-dialog
+        v-model="dialogFormVisible"
+        title="涓婁紶闄勪欢"
+        width="50%"
+        @close="closeDia"
+    >
+      <div style="margin-bottom: 10px;text-align: right">
+        <el-upload
+            v-model:file-list="fileList"
+            class="upload-demo"
+            :action="uploadUrl"
+            :on-success="handleUploadSuccess"
+            :on-error="handleUploadError"
+            name="file"
+            :show-file-list="false"
+            :headers="headers"
+            style="display: inline;margin-right: 10px"
+        >
+          <el-button type="primary">涓婁紶闄勪欢</el-button>
+        </el-upload>
+        <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
+      </div>
+      <PIMTable
+          rowKey="id"
+          :column="tableColumn"
+          :tableData="tableData"
+          :tableLoading="tableLoading"
+          :isSelection="true"
+          @selection-change="handleSelectionChange"
+          @pagination="paginationSearch"
+          :page="page"
+          height="500"
+      >
+      </PIMTable>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="closeDia">鍙栨秷</el-button>
+        </div>
+      </template>
+    </el-dialog>
+    <filePreview ref="filePreviewRef" />
+  </div>
+</template>
+
+<script setup>
+import {ref} from "vue";
+import {ElMessageBox} from "element-plus";
+import {getToken} from "@/utils/auth.js";
+import filePreview from '@/components/filePreview/index.vue'
+import {
+  fileAdd,
+  fileDel,
+  fileListPage
+} from "@/api/equipmentManagement/repair";
+import PIMTable from "@/components/PIMTable/PIMTable.vue";
+import Pagination from "@/components/PIMTable/Pagination.vue";
+const { proxy } = getCurrentInstance()
+const emit = defineEmits(['close'])
+
+const dialogFormVisible = ref(false);
+const currentId = ref('')
+const selectedRows = ref([]);
+const filePreviewRef = ref()
+const tableColumn = ref([
+  {
+    label: "鏂囦欢鍚嶇О",
+    prop: "name",
+  },
+  {
+    dataType: "action",
+    label: "鎿嶄綔",
+    align: "center",
+    operation: [
+      {
+        name: "涓嬭浇",
+        type: "text",
+        clickFun: (row) => {
+          downLoadFile(row);
+        },
+      },
+      {
+        name: "棰勮",
+        type: "text",
+        clickFun: (row) => {
+          lookFile(row);
+        },
+      }
+    ],
+  },
+]);
+const page = reactive({
+	current: 1,
+	size: 100,
+  total: 0
+});
+
+const total = ref(0);
+const tableData = ref([]);
+const fileList = ref([]);
+const tableLoading = ref(false);
+const accountType = ref('')
+const headers = ref({
+  Authorization: "Bearer " + getToken(),
+});
+const uploadUrl = ref(import.meta.env.VITE_APP_BASE_API + "/file/upload"); // 涓婁紶鐨勫浘鐗囨湇鍔″櫒鍦板潃
+
+// 鎵撳紑寮规
+const openDialog = (row,type) => {
+  accountType.value = type;
+  dialogFormVisible.value = true;
+  currentId.value = row.id;
+  getList()
+}
+const paginationSearch = (obj) => {
+	page.current = obj.page;
+	page.size = obj.limit;
+	getList();
+};
+const getList = () => {
+  fileListPage({deviceRepairId: currentId.value, ...page}).then(res => {
+    tableData.value = res.data.records;
+		total.value = res.data.total;
+    page.total = total.value;
+  })
+}
+// 琛ㄦ牸閫夋嫨鏁版嵁
+const handleSelectionChange = (selection) => {
+  selectedRows.value = selection;
+};
+
+// 鍏抽棴寮规
+const closeDia = () => {
+  dialogFormVisible.value = false;
+  emit('close')
+};
+// 涓婁紶鎴愬姛澶勭悊
+function handleUploadSuccess(res, file) {
+  // 濡傛灉涓婁紶鎴愬姛
+  if (res.code == 200) {
+    const fileRow = {}
+    fileRow.name = res.data.originalName
+    fileRow.url = res.data.tempPath
+    uploadFile(fileRow)
+  } else {
+    proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
+  }
+}
+function uploadFile(file) {
+  file.deviceRepairId = currentId.value;
+  fileAdd(file).then(res => {
+    proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛");
+    getList()
+  })
+}
+// 涓婁紶澶辫触澶勭悊
+function handleUploadError() {
+  proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
+}
+// 涓嬭浇闄勪欢
+const downLoadFile = (row) => {
+  proxy.$download.name(row.url);
+}
+// 鍒犻櫎
+const handleDelete = () => {
+  let ids = [];
+  if (selectedRows.value.length > 0) {
+    ids = selectedRows.value.map((item) => item.id);
+  } else {
+    proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+    return;
+  }
+  ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "瀵煎嚭", {
+    confirmButtonText: "纭",
+    cancelButtonText: "鍙栨秷",
+    type: "warning",
+  }).then(() => {
+    fileDel(ids).then((res) => {
+      proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+      getList();
+    });
+  }).catch(() => {
+    proxy.$modal.msg("宸插彇娑�");
+  });
+};
+// 棰勮闄勪欢
+const lookFile = (row) => {
+  filePreviewRef.value.open(row.url)
+}
+
+defineExpose({
+  openDialog,
+});
+</script>
+
+<style scoped>
+
+</style>
\ No newline at end of file
diff --git a/src/views/equipmentManagement/repair/index.vue b/src/views/equipmentManagement/repair/index.vue
index 1a2ff1e..bff058a 100644
--- a/src/views/equipmentManagement/repair/index.vue
+++ b/src/views/equipmentManagement/repair/index.vue
@@ -7,7 +7,6 @@
             style="width: 240px"
             placeholder="璇疯緭鍏ヨ澶囧悕绉�"
             clearable
-            :prefix-icon="Search"
             @change="getTableData"
         />
       </el-form-item>
@@ -17,7 +16,6 @@
             style="width: 240px"
             placeholder="璇烽�夋嫨瑙勬牸鍨嬪彿"
             clearable
-            :prefix-icon="Search"
             @change="getTableData"
         />
       </el-form-item>
@@ -27,7 +25,6 @@
             style="width: 240px"
             placeholder="璇疯緭鍏ユ晠闅滅幇璞�"
             clearable
-            :prefix-icon="Search"
             @change="getTableData"
         />
       </el-form-item>
@@ -37,7 +34,6 @@
             style="width: 240px"
             placeholder="璇疯緭鍏ョ淮淇汉"
             clearable
-            :prefix-icon="Search"
             @change="getTableData"
         />
       </el-form-item>
@@ -119,6 +115,14 @@
             缂栬緫
           </el-button>
           <el-button
+              type="primary"
+              text
+              icon="folder"
+              @click="openFilesForm(row)"
+          >
+            闄勪欢
+          </el-button>
+          <el-button
             type="danger"
             text
             icon="delete"
@@ -131,6 +135,7 @@
     </div>
     <RepairModal ref="repairModalRef" @ok="getTableData" />
     <MaintainModal ref="maintainModalRef" @ok="getTableData" />
+    <files-dia ref="filesDia"></files-dia>
   </div>
 </template>
 
@@ -142,7 +147,7 @@
 import { ElMessageBox, ElMessage } from "element-plus";
 import dayjs from "dayjs";
 import MaintainModal from "./Modal/MaintainModal.vue";
-
+import FilesDia from "./filesDia.vue";
 defineOptions({
   name: "璁惧鎶ヤ慨",
 });
@@ -152,7 +157,7 @@
 // 妯℃�佹瀹炰緥
 const repairModalRef = ref();
 const maintainModalRef = ref();
-
+const filesDia = ref()
 // 琛ㄦ牸澶氶�夋閫変腑椤�
 const multipleList = ref([]);
 
@@ -201,6 +206,11 @@
       label: "鏁呴殰鐜拌薄",
       align: "center",
       prop: "remark",
+    },
+    {
+      label: "淇濆吇杩涘害鎻忚堪",
+      align: "center",
+      prop: "maintenanceProcessDesc",
     },
     {
       label: "缁翠慨浜�",
@@ -266,7 +276,12 @@
 const editRepair = (id) => {
   repairModalRef.value.openEdit(id);
 };
-
+// 鎵撳紑闄勪欢寮规
+const openFilesForm = (row) => {
+  nextTick(() => {
+    filesDia.value?.openDialog( row,'璁惧鎶ヤ慨')
+  })
+};
 // 鏂板缁翠慨
 const addMaintain = () => {
   const row = multipleList.value[0];
diff --git a/src/views/equipmentManagement/upkeep/filesDia.vue b/src/views/equipmentManagement/upkeep/filesDia.vue
new file mode 100644
index 0000000..730c5b0
--- /dev/null
+++ b/src/views/equipmentManagement/upkeep/filesDia.vue
@@ -0,0 +1,199 @@
+<template>
+  <div>
+    <el-dialog
+        v-model="dialogFormVisible"
+        title="涓婁紶闄勪欢"
+        width="50%"
+        @close="closeDia"
+    >
+      <div style="margin-bottom: 10px;text-align: right">
+        <el-upload
+            v-model:file-list="fileList"
+            class="upload-demo"
+            :action="uploadUrl"
+            :on-success="handleUploadSuccess"
+            :on-error="handleUploadError"
+            name="file"
+            :show-file-list="false"
+            :headers="headers"
+            style="display: inline;margin-right: 10px"
+        >
+          <el-button type="primary">涓婁紶闄勪欢</el-button>
+        </el-upload>
+        <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
+      </div>
+      <PIMTable
+          rowKey="id"
+          :column="tableColumn"
+          :tableData="tableData"
+          :tableLoading="tableLoading"
+          :isSelection="true"
+          @selection-change="handleSelectionChange"
+          @pagination="paginationSearch"
+          :page="page"
+          height="500"
+      >
+      </PIMTable>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="closeDia">鍙栨秷</el-button>
+        </div>
+      </template>
+    </el-dialog>
+    <filePreview ref="filePreviewRef" />
+  </div>
+</template>
+
+<script setup>
+import {ref} from "vue";
+import {ElMessageBox} from "element-plus";
+import {getToken} from "@/utils/auth.js";
+import filePreview from '@/components/filePreview/index.vue'
+import {
+  fileAdd,
+  fileDel,
+  fileListPage
+} from "@/api/equipmentManagement/upkeep.js";
+import PIMTable from "@/components/PIMTable/PIMTable.vue";
+import Pagination from "@/components/PIMTable/Pagination.vue";
+const { proxy } = getCurrentInstance()
+const emit = defineEmits(['close'])
+
+const dialogFormVisible = ref(false);
+const currentId = ref('')
+const selectedRows = ref([]);
+const filePreviewRef = ref()
+const tableColumn = ref([
+  {
+    label: "鏂囦欢鍚嶇О",
+    prop: "name",
+  },
+  {
+    dataType: "action",
+    label: "鎿嶄綔",
+    align: "center",
+    operation: [
+      {
+        name: "涓嬭浇",
+        type: "text",
+        clickFun: (row) => {
+          downLoadFile(row);
+        },
+      },
+      {
+        name: "棰勮",
+        type: "text",
+        clickFun: (row) => {
+          lookFile(row);
+        },
+      }
+    ],
+  },
+]);
+const page = reactive({
+	current: 1,
+	size: 100,
+  total: 0
+});
+
+const total = ref(0);
+const tableData = ref([]);
+const fileList = ref([]);
+const tableLoading = ref(false);
+const accountType = ref('')
+const headers = ref({
+  Authorization: "Bearer " + getToken(),
+});
+const uploadUrl = ref(import.meta.env.VITE_APP_BASE_API + "/file/upload"); // 涓婁紶鐨勫浘鐗囨湇鍔″櫒鍦板潃
+
+// 鎵撳紑寮规
+const openDialog = (row,type) => {
+  accountType.value = type;
+  dialogFormVisible.value = true;
+  currentId.value = row.id;
+  getList()
+}
+const paginationSearch = (obj) => {
+	page.current = obj.page;
+	page.size = obj.limit;
+	getList();
+};
+const getList = () => {
+  fileListPage({deviceRepairId: currentId.value, ...page}).then(res => {
+    tableData.value = res.data.records;
+		total.value = res.data.total;
+    page.total = total.value;
+  })
+}
+// 琛ㄦ牸閫夋嫨鏁版嵁
+const handleSelectionChange = (selection) => {
+  selectedRows.value = selection;
+};
+
+// 鍏抽棴寮规
+const closeDia = () => {
+  dialogFormVisible.value = false;
+  emit('close')
+};
+// 涓婁紶鎴愬姛澶勭悊
+function handleUploadSuccess(res, file) {
+  // 濡傛灉涓婁紶鎴愬姛
+  if (res.code == 200) {
+    const fileRow = {}
+    fileRow.name = res.data.originalName
+    fileRow.url = res.data.tempPath
+    uploadFile(fileRow)
+  } else {
+    proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
+  }
+}
+function uploadFile(file) {
+  file.deviceRepairId = currentId.value;
+  fileAdd(file).then(res => {
+    proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛");
+    getList()
+  })
+}
+// 涓婁紶澶辫触澶勭悊
+function handleUploadError() {
+  proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
+}
+// 涓嬭浇闄勪欢
+const downLoadFile = (row) => {
+  proxy.$download.name(row.url);
+}
+// 鍒犻櫎
+const handleDelete = () => {
+  let ids = [];
+  if (selectedRows.value.length > 0) {
+    ids = selectedRows.value.map((item) => item.id);
+  } else {
+    proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+    return;
+  }
+  ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "瀵煎嚭", {
+    confirmButtonText: "纭",
+    cancelButtonText: "鍙栨秷",
+    type: "warning",
+  }).then(() => {
+    fileDel(ids).then((res) => {
+      proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+      getList();
+    });
+  }).catch(() => {
+    proxy.$modal.msg("宸插彇娑�");
+  });
+};
+// 棰勮闄勪欢
+const lookFile = (row) => {
+  filePreviewRef.value.open(row.url)
+}
+
+defineExpose({
+  openDialog,
+});
+</script>
+
+<style scoped>
+
+</style>
\ No newline at end of file
diff --git a/src/views/equipmentManagement/upkeep/index.vue b/src/views/equipmentManagement/upkeep/index.vue
index a85a351..63ca907 100644
--- a/src/views/equipmentManagement/upkeep/index.vue
+++ b/src/views/equipmentManagement/upkeep/index.vue
@@ -114,11 +114,20 @@
           >
             鍒犻櫎
           </el-button>
+          <el-button
+              type="primary"
+              text
+              icon="folder"
+              @click="openFilesForm(row)"
+          >
+            闄勪欢
+          </el-button>
         </template>
       </PIMTable>
     </div>
     <PlanModal ref="planModalRef" @ok="getTableData" />
     <MaintenanceModal ref="maintainModalRef" @ok="getTableData" />
+    <files-dia ref="filesDia"></files-dia>
   </div>
 </template>
 
@@ -130,7 +139,7 @@
 import MaintenanceModal from "./Modal/MaintenanceModal.vue";
 import dayjs from "dayjs";
 import { ElMessageBox, ElMessage } from "element-plus";
-
+import FilesDia from "./filesDia.vue";
 defineOptions({
   name: "璁惧淇濆吇",
 });
@@ -141,7 +150,7 @@
 const planModalRef = ref();
 // 淇濆吇寮圭獥鎺у埗鍣�
 const maintainModalRef = ref();
-
+const filesDia = ref()
 // 琛ㄦ牸澶氶�夋閫変腑椤�
 const multipleList = ref([]);
 
@@ -193,6 +202,11 @@
   //   formatData: (cell) => dayjs(cell).format("YYYY-MM-DD HH:mm:ss"),
   //   width: 200,
   // },
+  {
+    label: "淇濆吇杩涘害鎻忚堪",
+    align: "center",
+    prop: "maintenanceProcessDesc",
+  },
   {
     label: "瀹為檯淇濆吇浜�",
     align: "center",
@@ -265,7 +279,12 @@
 	pagination.pageSize = limit;
 	onCurrentChange(page);
 };
-
+// 鎵撳紑闄勪欢寮规
+const openFilesForm = (row) => {
+  nextTick(() => {
+    filesDia.value?.openDialog( row,'璁惧淇濆吇')
+  })
+};
 // 鍗曡鍒犻櫎
 const delRepairByIds = async (ids) => {
   ElMessageBox.confirm("纭鍒犻櫎鎶ヤ慨鏁版嵁, 姝ゆ搷浣滀笉鍙��?", "璀﹀憡", {

--
Gitblit v1.9.3