From c1bf5ebfe65ee67c64da6e9e4e6f7c7dbb3e992e Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期二, 17 三月 2026 14:28:26 +0800
Subject: [PATCH] fix: 新增不合格原料库存时,没有皮重、毛重、净重、过磅日期、车牌号、过磅员输入框(不会存在不合格入库,把按钮屏蔽掉)
---
src/views/equipmentManagement/repair/index.vue | 257 ++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 222 insertions(+), 35 deletions(-)
diff --git a/src/views/equipmentManagement/repair/index.vue b/src/views/equipmentManagement/repair/index.vue
index 96fb91b..a278a5c 100644
--- a/src/views/equipmentManagement/repair/index.vue
+++ b/src/views/equipmentManagement/repair/index.vue
@@ -1,24 +1,83 @@
<template>
<div class="app-container">
+ <el-form :model="filters" :inline="true">
+ <el-form-item label="璁惧鍚嶇О">
+ <el-input
+ v-model="filters.deviceName"
+ style="width: 240px"
+ placeholder="璇疯緭鍏ヨ澶囧悕绉�"
+ clearable
+ :prefix-icon="Search"
+ @change="getTableData"
+ />
+ </el-form-item>
+ <el-form-item label="瑙勬牸鍨嬪彿">
+ <el-input
+ v-model="filters.deviceModel"
+ style="width: 240px"
+ placeholder="璇烽�夋嫨瑙勬牸鍨嬪彿"
+ clearable
+ :prefix-icon="Search"
+ @change="getTableData"
+ />
+ </el-form-item>
+ <el-form-item label="鏁呴殰鐜拌薄">
+ <el-input
+ v-model="filters.remark"
+ style="width: 240px"
+ placeholder="璇疯緭鍏ユ晠闅滅幇璞�"
+ clearable
+ :prefix-icon="Search"
+ @change="getTableData"
+ />
+ </el-form-item>
+ <el-form-item label="缁翠慨浜�">
+ <el-input
+ v-model="filters.maintenanceName"
+ style="width: 240px"
+ placeholder="璇疯緭鍏ョ淮淇汉"
+ clearable
+ :prefix-icon="Search"
+ @change="getTableData"
+ />
+ </el-form-item>
+ <el-form-item label="鎶ヤ慨鏃ユ湡">
+ <el-date-picker
+ v-model="filters.repairTimeStr"
+ type="date"
+ placeholder="璇烽�夋嫨鎶ヤ慨鏃ユ湡"
+ size="default"
+ @change="(date) => handleDateChange(date,2)"
+ />
+ </el-form-item>
+ <el-form-item label="缁翠慨鏃ユ湡">
+ <el-date-picker
+ v-model="filters.maintenanceTimeStr"
+ type="date"
+ placeholder="璇烽�夋嫨缁翠慨鏃ユ湡"
+ size="default"
+ @change="(date) => handleDateChange(date,1)"
+ />
+ </el-form-item>
+ <el-form-item>
+ <el-button type="primary" @click="getTableData">鎼滅储</el-button>
+ <el-button @click="resetFilters">閲嶇疆</el-button>
+ </el-form-item>
+ </el-form>
<div class="table_list">
<div class="actions">
<el-text class="mx-1" size="large">璁惧鎶ヤ慨</el-text>
<div>
- <el-button
- type="primary"
- icon="Plus"
- :disabled="multipleList.length !== 1"
- @click="addMaintain"
- >
- 鏂板缁翠慨
- </el-button>
<el-button type="success" icon="Van" @click="addRepair">
鏂板鎶ヤ慨
+ </el-button>
+ <el-button @click="handleOut">
+ 瀵煎嚭
</el-button>
<el-button
type="danger"
icon="Delete"
- :disabled="multipleList.length <= 0"
+ :disabled="multipleList.length <= 0 || hasFinishedStatus"
@click="delRepairByIds(multipleList.map((item) => item.id))"
>
鎵归噺鍒犻櫎
@@ -26,34 +85,51 @@
</div>
</div>
<PIMTable
- rowKey="id"
- isSelection
- :column="columns"
- :tableData="dataList"
- :page="{
+ rowKey="id"
+ isSelection
+ :column="columns"
+ :tableData="dataList"
+ :page="{
current: pagination.currentPage,
size: pagination.pageSize,
total: pagination.total,
}"
- @selection-change="handleSelectionChange"
+ @selection-change="handleSelectionChange"
+ @pagination="changePage"
>
<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="error">寰呯淮淇�</el-tag>
+ <el-tag v-if="row.status === 0" type="warning">寰呯淮淇�</el-tag>
</template>
<template #operation="{ row }">
<el-button
type="primary"
- text
- icon="editPen"
+ link
+ :disabled="row.status === 1"
@click="editRepair(row.id)"
>
缂栬緫
</el-button>
<el-button
+ 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"
- text
- icon="delete"
+ link
+ :disabled="row.status === 1"
@click="delRepairByIds(row.id)"
>
鍒犻櫎
@@ -61,37 +137,94 @@
</template>
</PIMTable>
</div>
- <RepairModal ref="repairModalRef" @ok="getTableData" />
- <MaintainModal ref="maintainModalRef" @ok="getTableData" />
+ <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 { usePaginationApi } from "@/hooks/usePaginationApi";
-import { getRepairPage, delRepair } from "@/api/equipmentManagement/repair";
-import { onMounted } from "vue";
+import { onMounted, getCurrentInstance, computed } from "vue";
+import {usePaginationApi} from "@/hooks/usePaginationApi";
+import {getRepairPage, delRepair, getRepairById} from "@/api/equipmentManagement/repair";
import RepairModal from "./Modal/RepairModal.vue";
-import { ElMessageBox, ElMessage } from "element-plus";
+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 {proxy} = getCurrentInstance();
+
// 妯℃�佹瀹炰緥
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([]);
// 琛ㄦ牸閽╁瓙
-const { filters, columns, dataList, pagination, getTableData, resetFilters } =
- usePaginationApi(
+const {
+ filters,
+ columns,
+ dataList,
+ pagination,
+ getTableData,
+ resetFilters,
+ onCurrentChange,
+} = usePaginationApi(
getRepairPage,
{
- searchText: undefined,
+ deviceName: undefined,
+ deviceModel: undefined,
+ remark: undefined,
+ maintenanceName: undefined,
+ repairTimeStr: undefined,
+ maintenanceTimeStr: undefined,
},
[
{
@@ -149,19 +282,40 @@
dataType: "slot",
slot: "operation",
align: "center",
- width: "200px",
+ width: "360px",
},
]
- );
+);
+
+// type === 1 缁翠慨 2鎶ヤ慨闂�
+const handleDateChange = (value, type) => {
+ filters.maintenanceTimeStr = null
+ filters.c = null
+ if (type === 1) {
+ if (value) {
+ filters.maintenanceTimeStr = dayjs(value).format("YYYY-MM-DD");
+ }
+ } else {
+ if (value) {
+ filters.repairTimeStr = dayjs(value).format("YYYY-MM-DD");
+ }
+ }
+ getTableData();
+};
// 澶氶�夊悗鍋氫粈涔�
const handleSelectionChange = (selectionList) => {
multipleList.value = selectionList;
};
+// 妫�鏌ラ�変腑鐨勮褰曚腑鏄惁鏈夊畬缁撶姸鎬佺殑
+const hasFinishedStatus = computed(() => {
+ return multipleList.value.some(item => item.status === 1)
+})
+
// 鏂板鎶ヤ慨
const addRepair = () => {
- repairModalRef.value.openModal();
+ repairModalRef.value.openAdd();
};
// 缂栬緫鎶ヤ慨
@@ -170,24 +324,56 @@
};
// 鏂板缁翠慨
-const addMaintain = () => {
- const row = multipleList.value[0];
+const addMaintain = (row) => {
maintainModalRef.value.open(row.id, row);
+};
+
+const changePage = ({page, limit}) => {
+ pagination.currentPage = page;
+ pagination.pageSize = limit;
+ onCurrentChange(page);
};
// 鍗曡鍒犻櫎
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: "鍙栨秷",
type: "warning",
}).then(async () => {
- const { code } = await delRepair(ids);
+ const {code} = await delRepair(ids);
if (code === 200) {
ElMessage.success("鍒犻櫎鎴愬姛");
getTableData();
}
});
+};
+
+// 瀵煎嚭
+const handleOut = () => {
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ proxy.download("/device/repair/export", {}, "璁惧鎶ヤ慨.xlsx");
+ })
+ .catch(() => {
+ ElMessage.info("宸插彇娑�");
+ });
};
onMounted(() => {
@@ -199,6 +385,7 @@
.table_list {
margin-top: unset;
}
+
.actions {
display: flex;
justify-content: space-between;
--
Gitblit v1.9.3