| | |
| | | style="width: 240px" |
| | | placeholder="请输入设备名称" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @change="getTableData" |
| | | /> |
| | | </el-form-item> |
| | |
| | | <el-input |
| | | v-model="filters.deviceModel" |
| | | style="width: 240px" |
| | | placeholder="请选择规格型号" |
| | | placeholder="请输入规格型号" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @change="getTableData" |
| | | /> |
| | | </el-form-item> |
| | |
| | | style="width: 240px" |
| | | placeholder="请输入故障现象" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @change="getTableData" |
| | | /> |
| | | </el-form-item> |
| | |
| | | style="width: 240px" |
| | | placeholder="请输入维修人" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @change="getTableData" |
| | | /> |
| | | </el-form-item> |
| | |
| | | <div class="actions"> |
| | | <el-text class="mx-1" size="large">设备报修</el-text> |
| | | <div> |
| | | <el-button |
| | | type="primary" |
| | | icon="Plus" |
| | | :disabled="multipleList.length !== 1 || multipleList[0]?.status !== 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)" |
| | | :disabled="multipleList.length <= 0 || hasFinishedStatus" |
| | | @click="delRepairByIds(multipleList.map((item) => item.id))" |
| | | > |
| | | 批量删除 |
| | | </el-button> |
| | |
| | | @pagination="changePage" |
| | | > |
| | | <template #statusRef="{ row }"> |
| | | <el-tag v-if="row.status === 5" type="danger">维修失败</el-tag> |
| | | <el-tag v-if="row.status === 4" type="danger">维修成功</el-tag> |
| | | <el-tag v-if="row.status === 3" type="danger">维修中</el-tag> |
| | | <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="warning">审核中</el-tag> |
| | | <el-tag v-if="row.status === 0" type="warning">待维修</el-tag> |
| | | <el-tag v-else-if="row.status === 1" type="success">完结</el-tag> |
| | | <el-tag v-else-if="row.status === 2" type="info">待审核</el-tag> |
| | | <el-tag v-else-if="row.status === 3" type="danger">审核不通过</el-tag> |
| | | </template> |
| | | <template #operation="{ row }"> |
| | | <el-button |
| | | type="primary" |
| | | text |
| | | icon="editPen" |
| | | link |
| | | :disabled="row.status === 1" |
| | | @click="editRepair(row.id)" |
| | | :disabled="row.status !== 0" |
| | | > |
| | | 编辑 |
| | | </el-button> |
| | | <el-button |
| | | type="danger" |
| | | text |
| | | icon="delete" |
| | | @click="delRepairByIds(row)" |
| | | type="warning" |
| | | link |
| | | :disabled="row.status !== 2" |
| | | @click="openApprove(row.id)" |
| | | > |
| | | 审批 |
| | | </el-button> |
| | | <el-button |
| | | type="success" |
| | | link |
| | | :disabled="row.status !== 0" |
| | | @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" /> |
| | | <ApproveModal ref="approveModalRef" @ok="getTableData"/> |
| | | </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 RepairModal from "./Modal/RepairModal.vue"; |
| | | import { ElMessageBox, ElMessage } from "element-plus"; |
| | | import dayjs from "dayjs"; |
| | | import MaintainModal from "./Modal/MaintainModal.vue"; |
| | | import ApproveModal from "./Modal/ApproveModal.vue"; |
| | | |
| | | defineOptions({ |
| | | name: "设备报修", |
| | |
| | | // 模态框实例 |
| | | const repairModalRef = ref(); |
| | | const maintainModalRef = ref(); |
| | | const approveModalRef = ref(); |
| | | |
| | | // 表格多选框选中项 |
| | | const multipleList = ref([]); |
| | |
| | | prop: "maintenanceTime", |
| | | formatData: (cell) => (cell ? dayjs(cell).format("YYYY-MM-DD") : ""), |
| | | }, |
| | | { prop: "auditName", label: "审核人", width: 120 }, |
| | | { prop: "supervisoryName", label: "监督人", width: 120 }, |
| | | { |
| | | label: "状态", |
| | | align: "center", |
| | |
| | | dataType: "slot", |
| | | slot: "operation", |
| | | align: "center", |
| | | width: "200px", |
| | | width: "300px", |
| | | }, |
| | | ] |
| | | ); |
| | |
| | | multipleList.value = selectionList; |
| | | }; |
| | | |
| | | // 检查选中的记录中是否有完结状态的 |
| | | const hasFinishedStatus = computed(() => { |
| | | return multipleList.value.some(item => item.status === 1) |
| | | }) |
| | | |
| | | // 新增报修 |
| | | const addRepair = () => { |
| | | repairModalRef.value.openAdd(); |
| | |
| | | }; |
| | | |
| | | // 新增维修 |
| | | const addMaintain = () => { |
| | | |
| | | const row = multipleList.value[0]; |
| | | const addMaintain = (row) => { |
| | | maintainModalRef.value.open(row.id, row); |
| | | }; |
| | | |
| | | // 审批 |
| | | const openApprove = (id) => { |
| | | approveModalRef.value.open(id); |
| | | }; |
| | | |
| | | const changePage = ({ page, limit }) => { |
| | |
| | | |
| | | // 单行删除 |
| | | const delRepairByIds = async (ids) => { |
| | | let isDel = false |
| | | if(Array.isArray(ids)){ |
| | | ids.forEach((item)=>{ |
| | | if(item.status !== 0){ |
| | | isDel = true |
| | | } |
| | | }) |
| | | }else{ |
| | | if(ids.status !== 0){ |
| | | isDel = true |
| | | } |
| | | } |
| | | // 检查是否有完结状态的记录 |
| | | 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(isDel){ |
| | | ElMessage.warning("只能删除审核中的报修数据"); |
| | | return |
| | | if (hasFinished) { |
| | | ElMessage.warning('不能删除状态为完结的记录'); |
| | | return; |
| | | } |
| | | |
| | | ElMessageBox.confirm("确认删除报修数据, 此操作不可逆?", "警告", { |
| | |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }).then(async () => { |
| | | let idsList = "" |
| | | if(Array.isArray(ids)){ |
| | | idsList = multipleList.value.map((item) => item.id); |
| | | console.log(idsList) |
| | | }else{ |
| | | idsList = ids.id |
| | | } |
| | | const { code } = await delRepair(idsList); |
| | | const {code} = await delRepair(ids); |
| | | if (code === 200) { |
| | | ElMessage.success("删除成功"); |
| | | await getTableData(); |
| | | getTableData(); |
| | | } |
| | | }); |
| | | }; |
| | |
| | | .table_list { |
| | | margin-top: unset; |
| | | } |
| | | |
| | | .actions { |
| | | display: flex; |
| | | justify-content: space-between; |