<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>
|
<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
|
type="danger"
|
icon="Delete"
|
:disabled="multipleList.length <= 0"
|
@click="delRepairByIds(multipleList.map((item) => item.id))"
|
>
|
批量删除
|
</el-button>
|
</div>
|
</div>
|
<PIMTable
|
rowKey="id"
|
isSelection
|
:column="columns"
|
:tableData="dataList"
|
:page="{
|
current: pagination.currentPage,
|
size: pagination.pageSize,
|
total: pagination.total,
|
}"
|
@selection-change="handleSelectionChange"
|
@pagination="changePage"
|
>
|
<template #statusRef="{ row }">
|
<el-tag v-if="row.status === 1" type="success">完结</el-tag>
|
<el-tag v-if="row.status === 0" type="danger">待维修</el-tag>
|
</template>
|
<template #operation="{ row }">
|
<el-button
|
type="primary"
|
text
|
icon="editPen"
|
@click="editRepair(row.id)"
|
>
|
编辑
|
</el-button>
|
<el-button
|
type="danger"
|
text
|
icon="delete"
|
@click="delRepairByIds(row.id)"
|
>
|
删除
|
</el-button>
|
</template>
|
</PIMTable>
|
</div>
|
<RepairModal ref="repairModalRef" @ok="getTableData" />
|
<MaintainModal ref="maintainModalRef" @ok="getTableData" />
|
</div>
|
</template>
|
|
<script setup>
|
import { usePaginationApi } from "@/hooks/usePaginationApi";
|
import { getRepairPage, delRepair } from "@/api/equipmentManagement/repair";
|
import { onMounted } from "vue";
|
import RepairModal from "./Modal/RepairModal.vue";
|
import { ElMessageBox, ElMessage } from "element-plus";
|
import dayjs from "dayjs";
|
import MaintainModal from "./Modal/MaintainModal.vue";
|
|
defineOptions({
|
name: "设备报修",
|
});
|
|
// 模态框实例
|
const repairModalRef = ref();
|
const maintainModalRef = ref();
|
|
// 表格多选框选中项
|
const multipleList = ref([]);
|
|
// 表格钩子
|
const {
|
filters,
|
columns,
|
dataList,
|
pagination,
|
getTableData,
|
resetFilters,
|
onCurrentChange,
|
} = usePaginationApi(
|
getRepairPage,
|
{
|
searchText: undefined,
|
},
|
[
|
{
|
label: "设备名称",
|
align: "center",
|
prop: "deviceName",
|
},
|
{
|
label: "规格型号",
|
align: "center",
|
prop: "deviceModel",
|
},
|
{
|
label: "报修日期",
|
align: "center",
|
prop: "repairTime",
|
formatData: (cell) => dayjs(cell).format("YYYY-MM-DD"),
|
},
|
{
|
label: "报修人",
|
align: "center",
|
prop: "repairName",
|
},
|
{
|
label: "故障现象",
|
align: "center",
|
prop: "remark",
|
},
|
{
|
label: "维修人",
|
align: "center",
|
prop: "maintenanceName",
|
},
|
{
|
label: "维修结果",
|
align: "center",
|
prop: "maintenanceResult",
|
},
|
{
|
label: "维修日期",
|
align: "center",
|
prop: "maintenanceTime",
|
formatData: (cell) => (cell ? dayjs(cell).format("YYYY-MM-DD") : ""),
|
},
|
{
|
label: "状态",
|
align: "center",
|
prop: "status",
|
dataType: "slot",
|
slot: "statusRef",
|
},
|
{
|
fixed: "right",
|
label: "操作",
|
dataType: "slot",
|
slot: "operation",
|
align: "center",
|
width: "200px",
|
},
|
]
|
);
|
|
// 多选后做什么
|
const handleSelectionChange = (selectionList) => {
|
multipleList.value = selectionList;
|
};
|
|
// 新增报修
|
const addRepair = () => {
|
repairModalRef.value.openAdd();
|
};
|
|
// 编辑报修
|
const editRepair = (id) => {
|
repairModalRef.value.openEdit(id);
|
};
|
|
// 新增维修
|
const addMaintain = () => {
|
const row = multipleList.value[0];
|
maintainModalRef.value.open(row.id, row);
|
};
|
|
const changePage = ({ page }) => {
|
pagination.currentPage = page;
|
onCurrentChange(page);
|
};
|
|
// 单行删除
|
const delRepairByIds = async (ids) => {
|
ElMessageBox.confirm("确认删除报修数据, 此操作不可逆?", "警告", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
}).then(async () => {
|
const { code } = await delRepair(ids);
|
if (code === 200) {
|
ElMessage.success("删除成功");
|
getTableData();
|
}
|
});
|
};
|
|
onMounted(() => {
|
getTableData();
|
});
|
</script>
|
|
<style lang="scss" scoped>
|
.table_list {
|
margin-top: unset;
|
}
|
.actions {
|
display: flex;
|
justify-content: space-between;
|
margin-bottom: 10px;
|
}
|
</style>
|