| | |
| | | 导出 |
| | | </el-button> |
| | | <el-button |
| | | type="danger" |
| | | icon="Delete" |
| | | :disabled="multipleList.length <= 0" |
| | | @click="delRepairByIds(multipleList.map((item) => item.id))" |
| | | type="danger" |
| | | icon="Delete" |
| | | :disabled="multipleList.length <= 0 || hasFinishedStatus" |
| | | @click="delRepairByIds(multipleList.map((item) => item.id))" |
| | | > |
| | | 批量删除 |
| | | </el-button> |
| | |
| | | </template> |
| | | <template #operation="{ row }"> |
| | | <el-button |
| | | type="primary" |
| | | text |
| | | @click="addMaintain(row)" |
| | | > |
| | | 新增维修 |
| | | </el-button> |
| | | <el-button |
| | | type="primary" |
| | | text |
| | | icon="editPen" |
| | | @click="editRepair(row.id)" |
| | | type="primary" |
| | | link |
| | | :disabled="row.status === 1" |
| | | @click="editRepair(row.id)" |
| | | > |
| | | 编辑 |
| | | </el-button> |
| | | <el-button |
| | | type="danger" |
| | | text |
| | | icon="delete" |
| | | @click="delRepairByIds(row.id)" |
| | | type="info" |
| | | link |
| | | @click="viewAttachments(row)" |
| | | > |
| | | 查看附件 |
| | | </el-button> |
| | | <el-button |
| | | type="success" |
| | | link |
| | | :disabled="row.status === 1" |
| | | @click="addMaintain(row)" |
| | | > |
| | | 维修 |
| | | </el-button> |
| | | <el-button |
| | | type="danger" |
| | | link |
| | | :disabled="row.status === 1" |
| | | @click="delRepairByIds(row.id)" |
| | | > |
| | | 删除 |
| | | </el-button> |
| | |
| | | </div> |
| | | <RepairModal ref="repairModalRef" @ok="getTableData"/> |
| | | <MaintainModal ref="maintainModalRef" @ok="getTableData"/> |
| | | <FileListDialog |
| | | ref="fileListDialogRef" |
| | | v-model="fileDialogVisible" |
| | | title="查看附件" |
| | | :show-upload-button="false" |
| | | :show-delete-button="false" |
| | | name-column-label="附件名称" |
| | | /> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { onMounted, getCurrentInstance, computed } from "vue"; |
| | | import {usePaginationApi} from "@/hooks/usePaginationApi"; |
| | | import {getRepairPage, delRepair} from "@/api/equipmentManagement/repair"; |
| | | import {onMounted, getCurrentInstance} from "vue"; |
| | | import {getRepairPage, delRepair, getRepairById} from "@/api/equipmentManagement/repair"; |
| | | import RepairModal from "./Modal/RepairModal.vue"; |
| | | import {ElMessageBox, ElMessage} from "element-plus"; |
| | | import dayjs from "dayjs"; |
| | | import MaintainModal from "./Modal/MaintainModal.vue"; |
| | | import FileListDialog from "@/components/Dialog/FileListDialog.vue"; |
| | | |
| | | defineOptions({ |
| | | name: "设备报修", |
| | |
| | | // 模态框实例 |
| | | const repairModalRef = ref(); |
| | | const maintainModalRef = ref(); |
| | | const fileListDialogRef = ref(); |
| | | const fileDialogVisible = ref(false); |
| | | |
| | | const baseApi = import.meta.env.VITE_APP_BASE_API || ""; |
| | | const formatFileUrl = (url) => { |
| | | if (!url) return ""; |
| | | if (url.startsWith("http://") || url.startsWith("https://")) return url; |
| | | if (url.includes(":") || url.startsWith("/")) { |
| | | return url; |
| | | } |
| | | const path = String(url).replace(/^\/+/, ""); |
| | | return path ? baseApi + "/" + path : baseApi; |
| | | }; |
| | | |
| | | // 查看附件(与 APP 字段一致:fileList / commonFileList) |
| | | const viewAttachments = async (row) => { |
| | | try { |
| | | const { code, data } = await getRepairById(row.id); |
| | | if (code === 200 && data) { |
| | | const list = data.fileList || data.commonFileList || []; |
| | | const mapped = (Array.isArray(list) ? list : []).map((f) => ({ |
| | | id: f.id, |
| | | name: f.originalFilename || f.bucketFilename || f.name || "附件", |
| | | url: formatFileUrl(f.url || f.downloadUrl), |
| | | raw: f, |
| | | })); |
| | | fileListDialogRef.value?.open(mapped); |
| | | } else { |
| | | ElMessage.warning("获取附件失败"); |
| | | } |
| | | } catch (e) { |
| | | ElMessage.error("获取附件失败"); |
| | | } |
| | | }; |
| | | |
| | | // 表格多选框选中项 |
| | | const multipleList = ref([]); |
| | |
| | | dataType: "slot", |
| | | slot: "operation", |
| | | align: "center", |
| | | width: "300px", |
| | | width: "360px", |
| | | }, |
| | | ] |
| | | ); |
| | |
| | | multipleList.value = selectionList; |
| | | }; |
| | | |
| | | // 检查选中的记录中是否有完结状态的 |
| | | const hasFinishedStatus = computed(() => { |
| | | return multipleList.value.some(item => item.status === 1) |
| | | }) |
| | | |
| | | // 新增报修 |
| | | const addRepair = () => { |
| | | repairModalRef.value.openAdd(); |
| | |
| | | |
| | | // 单行删除 |
| | | const delRepairByIds = async (ids) => { |
| | | // 检查是否有完结状态的记录 |
| | | const idsArray = Array.isArray(ids) ? ids : [ids]; |
| | | const hasFinished = idsArray.some(id => { |
| | | const record = dataList.value.find(item => item.id === id); |
| | | return record && record.status === 1; |
| | | }); |
| | | |
| | | if (hasFinished) { |
| | | ElMessage.warning('不能删除状态为完结的记录'); |
| | | return; |
| | | } |
| | | |
| | | ElMessageBox.confirm("确认删除报修数据, 此操作不可逆?", "警告", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |