<template>
|
<div class="app-container">
|
<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="addPlan">
|
新增计划
|
</el-button>
|
<el-button
|
type="danger"
|
icon="Delete"
|
:disabled="multipleList.length <= 0"
|
>
|
批量删除
|
</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"
|
>
|
<template #maintenanceResultRef="{ row }">
|
<el-tag v-if="row.maintenanceResult === 1" type="success">
|
完好
|
</el-tag>
|
<el-tag v-if="row.maintenanceResult === 0" type="danger">
|
维修
|
</el-tag>
|
</template>
|
<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="editPlan(row.id)"
|
>
|
编辑
|
</el-button>
|
<el-button
|
type="danger"
|
text
|
icon="delete"
|
@click="delRepairByIds(row.id)"
|
>
|
删除
|
</el-button>
|
</template>
|
</PIMTable>
|
</div>
|
<PlanModal ref="planModalRef" @ok="getTableData" />
|
<MaintenanceModal ref="maintainModalRef" @ok="getTableData" />
|
</div>
|
</template>
|
|
<script setup>
|
import { usePaginationApi } from "@/hooks/usePaginationApi";
|
import { getUpkeepPage, delUpkeep } from "@/api/equipmentManagement/upkeep";
|
import { onMounted } from "vue";
|
import PlanModal from "./Modal/PlanModal.vue";
|
import MaintenanceModal from "./Modal/MaintenanceModal.vue";
|
import dayjs from "dayjs";
|
import { ElMessageBox, ElMessage } from "element-plus";
|
|
defineOptions({
|
name: "设备保养",
|
});
|
|
// 计划弹窗控制器
|
const planModalRef = ref();
|
// 保养弹窗控制器
|
const maintainModalRef = ref();
|
|
// 表格多选框选中项
|
const multipleList = ref([]);
|
|
// 多选后做什么
|
const handleSelectionChange = (selectionList) => {
|
multipleList.value = selectionList;
|
};
|
|
// 表格钩子
|
const { filters, columns, dataList, pagination, getTableData, resetFilters } =
|
usePaginationApi(getUpkeepPage, {}, [
|
{
|
label: "设备名称",
|
align: "center",
|
prop: "deviceName",
|
},
|
{
|
label: "规格型号",
|
align: "center",
|
prop: "deviceModel",
|
},
|
{
|
label: "计划保养日期",
|
align: "center",
|
prop: "maintenancePlanTime",
|
formatData: (cell) => dayjs(cell).format("YYYY-MM-DD"),
|
},
|
{
|
label: "录入人",
|
align: "center",
|
prop: "createUserName",
|
},
|
{
|
label: "录入日期",
|
align: "center",
|
prop: "createTime",
|
formatData: (cell) => dayjs(cell).format("YYYY-MM-DD HH:mm:ss"),
|
width: 200,
|
},
|
{
|
label: "实际保养人",
|
align: "center",
|
prop: "maintenanceActuallyName",
|
},
|
{
|
label: "实际保养日期",
|
align: "center",
|
prop: "maintenanceActuallyTime",
|
formatData: (cell) => dayjs(cell).format("YYYY-MM-DD HH:mm:ss"),
|
},
|
{
|
label: "保养结果",
|
align: "center",
|
prop: "maintenanceResult",
|
dataType: "slot",
|
slot: "maintenanceResultRef",
|
},
|
{
|
label: "状态",
|
align: "center",
|
prop: "status",
|
dataType: "slot",
|
slot: "statusRef",
|
},
|
{
|
fixed: "right",
|
label: "操作",
|
dataType: "slot",
|
slot: "operation",
|
align: "center",
|
width: "200px",
|
},
|
]);
|
|
// 新增保养
|
const addMaintain = () => {
|
const row = multipleList.value[0];
|
maintainModalRef.value.open(row.id, row);
|
};
|
|
// 新增计划
|
const addPlan = () => {
|
planModalRef.value.openModal();
|
};
|
|
// 编辑计划
|
const editPlan = (id) => {
|
planModalRef.value.openEdit(id);
|
};
|
|
// 单行删除
|
const delRepairByIds = async (ids) => {
|
ElMessageBox.confirm("确认删除报修数据, 此操作不可逆?", "警告", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
}).then(async () => {
|
const { code } = await delUpkeep(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>
|