| | |
| | | |
| | | <el-dialog v-model="rectDialogVisible" :title="rectDialogTitle" width="900px" :close-on-click-modal="false"> |
| | | <el-form ref="rectFormRef" :model="rectForm" label-position="top" :rules="rectRules"> |
| | | <el-divider content-position="left">隐患任务</el-divider> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"><el-form-item label="关联设备" prop="equipmentId"><el-select v-model="rectForm.equipmentId" filterable clearable style="width: 100%" placeholder="请选择设备"><el-option v-for="item in activeLedgerOptions" :key="item.id" :label="item.equipmentName" :value="item.id" /></el-select></el-form-item></el-col> |
| | | <el-col :span="12"><el-form-item label="风险等级" prop="riskLevel"><el-select v-model="rectForm.riskLevel" clearable style="width: 100%" placeholder="请选择风险等级"><el-option label="低" value="低" /><el-option label="中" value="中" /><el-option label="高" value="高" /></el-select></el-form-item></el-col> |
| | | <el-col :span="12"><el-form-item label="关联设备" prop="equipmentId"><el-select v-model="rectForm.equipmentId" filterable clearable style="width: 100%" placeholder="请选择设备" :disabled="!canEditRectTask"><el-option v-for="item in activeLedgerOptions" :key="item.id" :label="item.equipmentName" :value="item.id" /></el-select></el-form-item></el-col> |
| | | <el-col :span="12"><el-form-item label="风险等级" prop="riskLevel"><el-select v-model="rectForm.riskLevel" clearable style="width: 100%" placeholder="请选择风险等级" :disabled="!canEditRectTask"><el-option label="低" value="低" /><el-option label="中" value="中" /><el-option label="高" value="高" /></el-select></el-form-item></el-col> |
| | | </el-row> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"><el-form-item label="发现日期" prop="discoveredDate"><el-date-picker v-model="rectForm.discoveredDate" value-format="YYYY-MM-DD" type="date" style="width: 100%" /></el-form-item></el-col> |
| | | <el-col :span="12"><el-form-item label="整改期限" prop="rectificationDeadline"><el-date-picker v-model="rectForm.rectificationDeadline" value-format="YYYY-MM-DD" type="date" style="width: 100%" /></el-form-item></el-col> |
| | | <el-col :span="12"><el-form-item label="发现日期" prop="discoveredDate"><el-date-picker v-model="rectForm.discoveredDate" value-format="YYYY-MM-DD" type="date" style="width: 100%" :disabled="!canEditRectTask" /></el-form-item></el-col> |
| | | <el-col :span="12"><el-form-item label="整改期限" prop="rectificationDeadline"><el-date-picker v-model="rectForm.rectificationDeadline" value-format="YYYY-MM-DD" type="date" style="width: 100%" :disabled="!canEditRectTask" /></el-form-item></el-col> |
| | | </el-row> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="整改责任人" prop="responsibleUserId"> |
| | | <el-select v-model="rectForm.responsibleUserId" filterable clearable style="width: 100%" placeholder="请选择整改责任人" @change="handleResponsibleUserChange"> |
| | | <el-select v-model="rectForm.responsibleUserId" filterable clearable style="width: 100%" placeholder="请选择整改责任人" :disabled="!canEditRectTask" @change="handleResponsibleUserChange"> |
| | | <el-option v-for="item in activeUserOptions" :key="item.userId" :label="item.nickName || item.userName" :value="item.userId" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"><el-form-item label="整改状态" prop="rectificationStatus"><el-select v-model="rectForm.rectificationStatus" clearable style="width: 100%" placeholder="请选择整改状态"><el-option label="待整改" :value="1" /><el-option label="整改中" :value="2" /><el-option label="待复核" :value="3" /><el-option label="已闭环" :value="4" /></el-select></el-form-item></el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="整改状态"> |
| | | <el-tag :type="getRectStatusType(rectForm.rectificationStatus)">{{ formatRectStatus(rectForm.rectificationStatus) }}</el-tag> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-form-item label="隐患描述" prop="hazardDescription"><el-input v-model="rectForm.hazardDescription" type="textarea" :rows="3" /></el-form-item> |
| | | <el-form-item label="整改措施" prop="rectificationMeasures"><el-input v-model="rectForm.rectificationMeasures" type="textarea" :rows="3" /></el-form-item> |
| | | <el-form-item label="整改结果" prop="rectificationResult"><el-input v-model="rectForm.rectificationResult" type="textarea" :rows="3" /></el-form-item> |
| | | <el-form-item label="整改附件"> |
| | | <FileUpload v-model:file-list="rectForm.storageBlobDTOs" :limit="6" /> |
| | | </el-form-item> |
| | | <el-form-item label="备注" prop="remarks"><el-input v-model="rectForm.remarks" type="textarea" :rows="2" /></el-form-item> |
| | | <el-form-item label="隐患描述" prop="hazardDescription"><el-input v-model="rectForm.hazardDescription" type="textarea" :rows="3" :disabled="!canEditRectTask" /></el-form-item> |
| | | <el-form-item label="备注" prop="remarks"><el-input v-model="rectForm.remarks" type="textarea" :rows="2" :disabled="!canEditRectTask" /></el-form-item> |
| | | <template v-if="showRectProcess"> |
| | | <el-divider content-position="left">整改处理</el-divider> |
| | | <el-row v-if="rectForm.closedDate" :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="闭环日期"> |
| | | <el-date-picker v-model="rectForm.closedDate" value-format="YYYY-MM-DD" type="date" style="width: 100%" disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-form-item label="整改措施" prop="rectificationMeasures"><el-input v-model="rectForm.rectificationMeasures" type="textarea" :rows="3" placeholder="请输入整改措施" :disabled="!canEditRectProcess" /></el-form-item> |
| | | <el-form-item label="整改结果" prop="rectificationResult"><el-input v-model="rectForm.rectificationResult" type="textarea" :rows="3" placeholder="请输入整改结果" :disabled="!canEditRectProcess" /></el-form-item> |
| | | <el-form-item label="整改附件"> |
| | | <FileUpload v-model:file-list="rectForm.storageBlobDTOs" :limit="6" :disabled="!canEditRectProcess" /> |
| | | </el-form-item> |
| | | </template> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button type="primary" @click="submitRectForm">确定</el-button> |
| | | <el-button @click="rectDialogVisible = false">取消</el-button> |
| | | <el-button v-if="!isRectView" type="primary" @click="submitRectForm">确定</el-button> |
| | | <el-button @click="rectDialogVisible = false">{{ isRectView ? "关闭" : "取消" }}</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | |
| | | specialEquipmentRectificationListPage, |
| | | specialEquipmentRectificationAdd, |
| | | specialEquipmentRectificationUpdate, |
| | | specialEquipmentRectificationClose, |
| | | specialEquipmentRectificationDel, |
| | | } from "@/api/safeProduction/specialEquipmentManagement.js"; |
| | | import { userListNoPageByTenantId } from "@/api/system/user.js"; |
| | | import useUserStore from "@/store/modules/user.js"; |
| | | import FileUpload from "@/components/AttachmentUpload/file/index.vue"; |
| | | |
| | | const activeTab = ref("ledger"); |
| | | const userOptions = ref([]); |
| | | const userStore = useUserStore(); |
| | | const currentUserId = computed(() => Number(userStore.id) || null); |
| | | |
| | | const ledgerSearch = reactive({ equipmentName: "" }); |
| | | const recordSearch = reactive({ recordType: "" }); |
| | |
| | | }; |
| | | const rectDialogVisible = ref(false); |
| | | const rectDialogTitle = ref(""); |
| | | const rectDialogMode = ref("create"); |
| | | const rectFormRef = ref(); |
| | | const rectForm = reactive({ |
| | | equipmentId: "", |
| | |
| | | rectificationStatus: 1, |
| | | rectificationMeasures: "", |
| | | rectificationResult: "", |
| | | closedDate: "", |
| | | storageBlobDTOs: [], |
| | | remarks: "", |
| | | }); |
| | | const rectRules = { |
| | | equipmentId: [{ required: true, message: "请选择关联设备", trigger: "change" }], |
| | | riskLevel: [{ required: true, message: "请选择风险等级", trigger: "change" }], |
| | | hazardDescription: [{ required: true, message: "请输入隐患描述", trigger: "blur" }], |
| | | responsibleUserId: [{ required: true, message: "请选择整改责任人", trigger: "change" }], |
| | | discoveredDate: [{ required: true, message: "请选择发现日期", trigger: "change" }], |
| | | rectificationDeadline: [{ required: true, message: "请选择整改期限", trigger: "change" }], |
| | | }; |
| | | const ledgerOptions = ref([]); |
| | | const activeLedgerOptions = computed(() => ledgerOptions.value); |
| | | const activeUserOptions = computed(() => userOptions.value || []); |
| | | const isRectView = computed(() => rectDialogMode.value === "view"); |
| | | const canEditRectTask = computed(() => ["create", "edit"].includes(rectDialogMode.value)); |
| | | const canEditRectProcess = computed(() => rectDialogMode.value === "rectify"); |
| | | const showRectProcess = computed(() => { |
| | | const status = Number(rectForm.rectificationStatus); |
| | | return ( |
| | | canEditRectProcess.value || |
| | | isRectView.value || |
| | | status >= 3 || |
| | | !!rectForm.rectificationMeasures || |
| | | !!rectForm.rectificationResult || |
| | | getAttachments(rectForm).length > 0 |
| | | ); |
| | | }); |
| | | const getAttachments = row => row?.storageBlobDTOs || row?.storageBlobVOs || []; |
| | | const rectStatusMap = { 1: "待整改", 2: "整改中", 3: "待复核", 4: "已闭环" }; |
| | | |
| | | const getDueDays = (dateValue) => { |
| | | if (!dateValue) return null; |
| | |
| | | return map[status] || "info"; |
| | | }; |
| | | |
| | | const formatRectStatus = status => rectStatusMap[status] || "未设置"; |
| | | |
| | | const findLedgerById = equipmentId => { |
| | | return ledgerOptions.value.find(item => Number(item.id) === Number(equipmentId)); |
| | | }; |
| | | |
| | | const fillEquipmentName = row => { |
| | | const equipment = findLedgerById(row?.equipmentId); |
| | | return { |
| | | ...row, |
| | | equipmentName: row?.equipmentName || equipment?.equipmentName || "-", |
| | | }; |
| | | }; |
| | | |
| | | const isPendingRect = row => [1, 2].includes(Number(row?.rectificationStatus)); |
| | | const isReviewRect = row => Number(row?.rectificationStatus) === 3; |
| | | const canAdjustRectTask = row => Number(row?.rectificationStatus) === 1; |
| | | const isNotResponsibleUser = row => |
| | | !!row?.responsibleUserId && Number(row.responsibleUserId) !== Number(currentUserId.value); |
| | | |
| | | const ledgerColumns = [ |
| | | { label: "设备编号", prop: "equipmentNo" }, |
| | | { label: "设备名称", prop: "equipmentName" }, |
| | | { label: "设备类别", prop: "equipmentType" }, |
| | | { label: "安装位置", prop: "installLocation" }, |
| | | { label: "负责人", prop: "managerName" }, |
| | | { label: "设备编号", prop: "equipmentNo", align: "center"}, |
| | | { label: "设备名称", prop: "equipmentName", align: "center"}, |
| | | { label: "设备类别", prop: "equipmentType", align: "center" }, |
| | | { label: "安装位置", prop: "installLocation", align: "center" }, |
| | | { label: "负责人", prop: "managerName", align: "center" }, |
| | | { |
| | | label: "操作", |
| | | dataType: "action", |
| | | width: "180", |
| | | width: "150", |
| | | align: "center", |
| | | operation: [ |
| | | { name: "编辑", clickFun: (row) => openLedgerForm(row) }, |
| | | { name: "删除", clickFun: (row) => deleteLedger(row.id) }, |
| | |
| | | ]; |
| | | |
| | | const recordColumns = [ |
| | | { label: "记录编号", prop: "recordNo" }, |
| | | { label: "记录类型", prop: "recordType", formatData: { 1: "检验", 2: "维保" } }, |
| | | { label: "记录日期", prop: "recordDate" }, |
| | | { label: "执行人", prop: "executorName" }, |
| | | { label: "执行结果", prop: "executeResult" }, |
| | | { label: "下次到期日期", prop: "nextDueDate" }, |
| | | { label: "到期提醒", prop: "nextDueDate", dataType: "tag", formatData: formatDueStatus, formatType: getDueStatusType }, |
| | | { label: "记录编号", prop: "recordNo", align: "center" }, |
| | | { label: "记录类型", prop: "recordType", formatData: { 1: "检验", 2: "维保" }, align: "center" }, |
| | | { label: "记录日期", prop: "recordDate", align: "center" }, |
| | | { label: "执行人", prop: "executorName", align: "center" }, |
| | | { label: "执行结果", prop: "executeResult", align: "center" }, |
| | | { label: "下次到期日期", prop: "nextDueDate", align: "center" }, |
| | | { label: "到期提醒", prop: "nextDueDate", dataType: "tag", formatData: formatDueStatus, formatType: getDueStatusType, align: "center" }, |
| | | { |
| | | label: "操作", |
| | | dataType: "action", |
| | | width: "180", |
| | | width: "150", |
| | | align: "center", |
| | | operation: [ |
| | | { name: "编辑", clickFun: (row) => openRecordForm(row) }, |
| | | { name: "删除", clickFun: (row) => deleteRecord(row.id) }, |
| | |
| | | ]; |
| | | |
| | | const rectColumns = [ |
| | | { label: "隐患描述", prop: "hazardDescription" }, |
| | | { label: "风险等级", prop: "riskLevel" }, |
| | | { label: "发现日期", prop: "discoveredDate" }, |
| | | { label: "责任人", prop: "responsibleUserName" }, |
| | | { label: "整改期限", prop: "rectificationDeadline" }, |
| | | { label: "整改状态", prop: "rectificationStatus", dataType: "tag", formatData: { 1: "待整改", 2: "整改中", 3: "待复核", 4: "已闭环" }, formatType: getRectStatusType }, |
| | | { label: "关联设备", prop: "equipmentName", align: "center" }, |
| | | { label: "隐患描述", prop: "hazardDescription", align: "center" }, |
| | | { label: "风险等级", prop: "riskLevel", align: "center" }, |
| | | { label: "发现日期", prop: "discoveredDate", align: "center" }, |
| | | { label: "责任人", prop: "responsibleUserName", align: "center" }, |
| | | { label: "整改期限", prop: "rectificationDeadline", align: "center" }, |
| | | { label: "整改状态", prop: "rectificationStatus", dataType: "tag", formatData: { 1: "待整改", 2: "整改中", 3: "待复核", 4: "已闭环" }, formatType: getRectStatusType, align: "center" }, |
| | | { |
| | | label: "操作", |
| | | dataType: "action", |
| | | width: "220", |
| | | width: "260", |
| | | align: "center", |
| | | operation: [ |
| | | { name: "编辑", clickFun: (row) => openRectForm(row) }, |
| | | { name: "删除", clickFun: (row) => deleteRect(row.id) }, |
| | | { name: "详情", clickFun: (row) => openRectDetail(row) }, |
| | | { |
| | | name: "整改", |
| | | clickFun: (row) => openRectifyForm(row), |
| | | show: isPendingRect, |
| | | disabled: isNotResponsibleUser, |
| | | }, |
| | | { name: "闭环", clickFun: (row) => closeRect(row), show: isReviewRect }, |
| | | { name: "编辑", clickFun: (row) => openRectForm(row), show: canAdjustRectTask }, |
| | | { name: "删除", clickFun: (row) => deleteRect(row.id), show: canAdjustRectTask }, |
| | | ], |
| | | }, |
| | | ]; |
| | |
| | | const loadLedgerOptions = async () => { |
| | | const res = await specialEquipmentLedgerList({}); |
| | | ledgerOptions.value = res.data || []; |
| | | rectTableData.value = rectTableData.value.map(fillEquipmentName); |
| | | }; |
| | | |
| | | const recordQuery = async () => { |
| | |
| | | const rectQuery = async () => { |
| | | rectLoading.value = true; |
| | | const res = await specialEquipmentRectificationListPage({ ...rectSearch, ...rectPage }); |
| | | rectTableData.value = res.data?.records || res.data?.rows || []; |
| | | const rows = res.data?.records || res.data?.rows || []; |
| | | rectTableData.value = rows.map(fillEquipmentName); |
| | | rectPage.total = res.data?.total || 0; |
| | | rectLoading.value = false; |
| | | }; |
| | |
| | | recordQuery(); |
| | | }; |
| | | |
| | | const openRectForm = (row = {}) => { |
| | | const openRectForm = (row = {}, mode = row.id ? "edit" : "create") => { |
| | | rectDialogMode.value = mode; |
| | | Object.assign(rectForm, { |
| | | id: "", |
| | | equipmentId: "", |
| | |
| | | rectificationStatus: 1, |
| | | rectificationMeasures: "", |
| | | rectificationResult: "", |
| | | closedDate: "", |
| | | storageBlobDTOs: [], |
| | | remarks: "", |
| | | }); |
| | |
| | | const matched = userOptions.value.find((item) => (item.nickName || item.userName) === rectForm.responsibleUserName); |
| | | rectForm.responsibleUserId = matched?.userId || ""; |
| | | } |
| | | rectDialogTitle.value = row.id ? "编辑整改" : "新增整改"; |
| | | if (mode === "view") { |
| | | rectDialogTitle.value = "整改详情"; |
| | | } else if (mode === "rectify") { |
| | | rectDialogTitle.value = "整改处理"; |
| | | } else { |
| | | rectDialogTitle.value = row.id ? "编辑整改" : "新增整改"; |
| | | } |
| | | rectDialogVisible.value = true; |
| | | }; |
| | | |
| | | const openRectDetail = (row) => { |
| | | openRectForm(row, "view"); |
| | | }; |
| | | |
| | | const openRectifyForm = (row) => { |
| | | if (isNotResponsibleUser(row)) { |
| | | return ElMessage.warning("只有整改责任人可以处理该整改任务"); |
| | | } |
| | | openRectForm(row, "rectify"); |
| | | }; |
| | | |
| | | const buildRectTaskPayload = () => ({ |
| | | id: rectForm.id, |
| | | equipmentId: rectForm.equipmentId, |
| | | hazardDescription: rectForm.hazardDescription, |
| | | riskLevel: rectForm.riskLevel, |
| | | discoveredDate: rectForm.discoveredDate, |
| | | responsibleUserId: rectForm.responsibleUserId, |
| | | responsibleUserName: rectForm.responsibleUserName, |
| | | rectificationDeadline: rectForm.rectificationDeadline, |
| | | rectificationStatus: 1, |
| | | rectificationMeasures: "", |
| | | rectificationResult: "", |
| | | closedDate: "", |
| | | storageBlobDTOs: [], |
| | | remarks: rectForm.remarks, |
| | | }); |
| | | |
| | | const buildRectProcessPayload = () => ({ |
| | | id: rectForm.id, |
| | | equipmentId: rectForm.equipmentId, |
| | | hazardDescription: rectForm.hazardDescription, |
| | | riskLevel: rectForm.riskLevel, |
| | | discoveredDate: rectForm.discoveredDate, |
| | | responsibleUserId: rectForm.responsibleUserId, |
| | | responsibleUserName: rectForm.responsibleUserName, |
| | | rectificationDeadline: rectForm.rectificationDeadline, |
| | | rectificationStatus: 3, |
| | | rectificationMeasures: rectForm.rectificationMeasures, |
| | | rectificationResult: rectForm.rectificationResult, |
| | | storageBlobDTOs: rectForm.storageBlobDTOs, |
| | | remarks: rectForm.remarks, |
| | | }); |
| | | |
| | | const submitRectForm = async () => { |
| | | await rectFormRef.value.validate(); |
| | | const api = rectForm.id ? specialEquipmentRectificationUpdate : specialEquipmentRectificationAdd; |
| | | await api(rectForm); |
| | | ElMessage.success("保存成功"); |
| | | if (isRectView.value) return; |
| | | if (canEditRectProcess.value) { |
| | | if (!String(rectForm.rectificationMeasures || "").trim()) { |
| | | return ElMessage.warning("请输入整改措施"); |
| | | } |
| | | if (!String(rectForm.rectificationResult || "").trim()) { |
| | | return ElMessage.warning("请输入整改结果"); |
| | | } |
| | | await specialEquipmentRectificationUpdate(buildRectProcessPayload()); |
| | | ElMessage.success("整改已提交,等待闭环"); |
| | | } else { |
| | | await rectFormRef.value.validate(); |
| | | const api = rectForm.id ? specialEquipmentRectificationUpdate : specialEquipmentRectificationAdd; |
| | | await api(buildRectTaskPayload()); |
| | | ElMessage.success(rectForm.id ? "整改任务已更新" : "整改任务已派发"); |
| | | } |
| | | rectDialogVisible.value = false; |
| | | rectQuery(); |
| | | }; |
| | | |
| | | const closeRect = async (row) => { |
| | | await ElMessageBox.confirm("确认该整改已复核完成并闭环吗?", "闭环确认", { type: "warning" }); |
| | | await specialEquipmentRectificationClose({ id: row.id }); |
| | | ElMessage.success("已闭环"); |
| | | rectQuery(); |
| | | }; |
| | | |
| | | const deleteRect = async (id) => { |
| | | const ids = id ? [id] : rectSelection.value.map((i) => i.id); |
| | | if (!ids.length) return ElMessage.warning("请选择要删除的数据"); |
| | | const selectedRows = id ? rectTableData.value.filter((item) => item.id === id) : rectSelection.value; |
| | | if (selectedRows.some((item) => !canAdjustRectTask(item))) { |
| | | return ElMessage.warning("只能删除待整改的整改任务"); |
| | | } |
| | | await ElMessageBox.confirm("确认删除所选整改数据吗?", "提示", { type: "warning" }); |
| | | await specialEquipmentRectificationDel(ids); |
| | | ElMessage.success("删除成功"); |