From 0457ff29c076e9986df9941b784be35f80e67e2a Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期一, 29 六月 2026 16:46:37 +0800
Subject: [PATCH] feat: 添加线路巡检和安全设施巡检模块
---
src/views/safeProduction/lineInspection/index.vue | 1186 +++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 865 insertions(+), 321 deletions(-)
diff --git a/src/views/safeProduction/lineInspection/index.vue b/src/views/safeProduction/lineInspection/index.vue
index 45358e9..ad3abed 100644
--- a/src/views/safeProduction/lineInspection/index.vue
+++ b/src/views/safeProduction/lineInspection/index.vue
@@ -1,374 +1,918 @@
<template>
- <div class="line-inspection">
- <!-- 鎼滅储鍖哄煙 -->
- <div class="search-area">
- <el-form :inline="true" :model="searchForm">
- <el-form-item label="浠诲姟鍚嶇О">
- <el-input v-model="searchForm.taskName" placeholder="璇疯緭鍏ヤ换鍔″悕绉�" clearable />
- </el-form-item>
- <el-form-item label="绾胯矾鍚嶇О">
- <el-input v-model="searchForm.routeName" placeholder="璇疯緭鍏ョ嚎璺悕绉�" clearable />
- </el-form-item>
- <el-form-item label="宸℃浜�">
- <el-input v-model="searchForm.inspector" placeholder="璇疯緭鍏ュ贰妫�浜�" clearable />
- </el-form-item>
- <el-form-item label="鐘舵��">
- <el-select v-model="searchForm.status" placeholder="璇烽�夋嫨鐘舵��" clearable>
- <el-option label="寰呭贰妫�" value="寰呭贰妫�" />
- <el-option label="杩涜涓�" value="杩涜涓�" />
- <el-option label="宸插畬鎴�" value="宸插畬鎴�" />
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="handleSearch">鎼滅储</el-button>
- <el-button @click="resetSearch">閲嶇疆</el-button>
- </el-form-item>
- </el-form>
+ <div class="app-container">
+ <div class="search_form mb20">
+ <div>
+ <span class="search_title">宸℃缂栧彿锛�</span>
+ <el-input v-model="searchForm.inspectionCode"
+ style="width: 200px"
+ placeholder="璇疯緭鍏ュ贰妫�缂栧彿"
+ @change="handleQuery"
+ clearable
+ :prefix-icon="Search" />
+ <span class="search_title ml10">宸℃鍚嶇О锛�</span>
+ <el-input v-model="searchForm.inspectionName"
+ style="width: 200px"
+ placeholder="璇疯緭鍏ュ贰妫�鍚嶇О"
+ @change="handleQuery"
+ clearable
+ :prefix-icon="Search" />
+ <span class="search_title ml10">绾胯矾鍚嶇О锛�</span>
+ <el-input v-model="searchForm.lineName"
+ style="width: 200px"
+ placeholder="璇疯緭鍏ョ嚎璺悕绉�"
+ @change="handleQuery"
+ clearable
+ :prefix-icon="Search" />
+ <span class="search_title ml10">鐘舵�侊細</span>
+ <el-select v-model="searchForm.status"
+ clearable
+ @change="handleQuery"
+ style="width: 150px">
+ <el-option label="寰呭贰妫�" value="寰呭贰妫�" />
+ <el-option label="宸℃涓�" value="宸℃涓�" />
+ <el-option label="宸插畬鎴�" value="宸插畬鎴�" />
+ </el-select>
+ <el-button type="primary"
+ @click="handleQuery"
+ style="margin-left: 10px">
+ 鎼滅储
+ </el-button>
+ </div>
+ <div>
+ <el-button type="primary"
+ @click="openForm('add')">鏂板宸℃浠诲姟</el-button>
+ </div>
</div>
- <!-- 鎿嶄綔鎸夐挳 -->
- <div class="actions">
- <el-button type="primary" @click="handleAdd">鏂板宸℃</el-button>
- <el-button type="success" @click="handleExport">瀵煎嚭</el-button>
+ <div class="table_list">
+ <PIMTable rowKey="id"
+ :column="tableColumn"
+ :tableData="tableData"
+ :page="page"
+ :isSelection="true"
+ @selection-change="handleSelectionChange"
+ :tableLoading="tableLoading"
+ @pagination="pagination"
+ :total="page.total"></PIMTable>
</div>
- <!-- 宸℃鍒楄〃 -->
- <el-table :data="inspectionList" style="width: 100%; margin-top: 10px;" border>
- <el-table-column prop="taskName" label="浠诲姟鍚嶇О" width="180" />
- <el-table-column prop="routeName" label="绾胯矾鍚嶇О" width="180" />
- <el-table-column prop="deviceName" label="鍏宠仈璁惧" width="150" />
- <el-table-column prop="inspector" label="宸℃浜�" width="120" />
- <el-table-column prop="inspectionTime" label="宸℃鏃堕棿" width="180" />
- <el-table-column prop="inspectionResult" label="宸℃缁撴灉" width="120">
- <template #default="{ row }">
- <el-tag :type="row.inspectionResult === '姝e父' ? 'success' : 'danger'">
- {{ row.inspectionResult || '鏈贰妫�' }}
- </el-tag>
- </template>
- </el-table-column>
- <el-table-column prop="status" label="鐘舵��" width="120">
- <template #default="{ row }">
- <el-tag :type="getStatusType(row.status)">
- {{ row.status }}
- </el-tag>
- </template>
- </el-table-column>
- <el-table-column label="鎿嶄綔" width="200" fixed="right">
- <template #default="{ row }">
- <el-button type="primary" link @click="handleEdit(row)">缂栬緫</el-button>
- <el-button type="danger" link @click="handleDelete(row)">鍒犻櫎</el-button>
- </template>
- </el-table-column>
- </el-table>
-
- <!-- 鍒嗛〉 -->
- <div class="pagination">
- <el-pagination
- v-model:current-page="pagination.currentPage"
- v-model:page-size="pagination.pageSize"
- :page-sizes="[10, 20, 50, 100]"
- :total="pagination.total"
- layout="total, sizes, prev, pager, next, jumper"
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- />
- </div>
-
- <!-- 鏂板/缂栬緫瀵硅瘽妗� -->
- <el-dialog :title="dialogTitle" v-model="showDialog" width="600px">
- <el-form :model="form" :rules="formRules" ref="formRef" label-width="100px">
- <el-form-item label="浠诲姟鍚嶇О" prop="taskName">
- <el-input v-model="form.taskName" placeholder="璇疯緭鍏ヤ换鍔″悕绉�" />
- </el-form-item>
- <el-form-item label="绾胯矾鍚嶇О" prop="routeName">
- <el-input v-model="form.routeName" placeholder="璇疯緭鍏ョ嚎璺悕绉�" />
- </el-form-item>
- <el-form-item label="鍏宠仈璁惧">
- <el-select v-model="form.deviceId" placeholder="璇烽�夋嫨璁惧" clearable>
- <el-option
- v-for="item in deviceOptions"
- :key="item.id"
- :label="item.deviceName"
- :value="item.id"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="宸℃浜�" prop="inspector">
- <el-input v-model="form.inspector" placeholder="璇疯緭鍏ュ贰妫�浜�" />
- </el-form-item>
- <el-form-item label="宸℃鏃堕棿">
- <el-date-picker
- v-model="form.inspectionTime"
- type="datetime"
- placeholder="璇烽�夋嫨宸℃鏃堕棿"
- format="YYYY-MM-DD HH:mm:ss"
- value-format="YYYY-MM-DD HH:mm:ss"
- />
- </el-form-item>
- <el-form-item label="宸℃缁撴灉">
- <el-radio-group v-model="form.inspectionResult">
- <el-radio label="姝e父">姝e父</el-radio>
- <el-radio label="寮傚父">寮傚父</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="闅愭偅鎻忚堪" v-if="form.inspectionResult === '寮傚父'">
- <el-input type="textarea" v-model="form.hazardDescription" placeholder="璇疯緭鍏ラ殣鎮f弿杩�" />
- </el-form-item>
- <el-form-item label="澶囨敞">
- <el-input type="textarea" v-model="form.remarks" placeholder="璇疯緭鍏ュ娉�" />
+ <!-- 鏂板/缂栬緫宸℃浠诲姟寮圭獥 -->
+ <el-dialog v-model="dialogVisible"
+ :title="dialogTitle"
+ width="800px"
+ :close-on-click-modal="false">
+ <el-form ref="formRef"
+ :model="form"
+ :rules="rules"
+ label-width="120px">
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="宸℃缂栧彿"
+ prop="inspectionCode">
+ <el-input v-model="form.inspectionCode"
+ placeholder="璇疯緭鍏ュ贰妫�缂栧彿" />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="宸℃鍚嶇О"
+ prop="inspectionName">
+ <el-input v-model="form.inspectionName"
+ placeholder="璇疯緭鍏ュ贰妫�鍚嶇О" />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="绾胯矾鍚嶇О"
+ prop="lineName">
+ <el-input v-model="form.lineName"
+ placeholder="璇疯緭鍏ョ嚎璺悕绉�" />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="宸℃绫诲瀷"
+ prop="inspectionType">
+ <el-select v-model="form.inspectionType"
+ placeholder="璇烽�夋嫨宸℃绫诲瀷"
+ style="width: 100%">
+ <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="planTime">
+ <el-date-picker v-model="form.planTime"
+ type="datetime"
+ placeholder="璇烽�夋嫨璁″垝宸℃鏃堕棿"
+ format="YYYY-MM-DD HH:mm:ss"
+ value-format="YYYY-MM-DD HH:mm:ss"
+ style="width: 100%" />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="宸℃浜�"
+ prop="inspectorId">
+ <el-select v-model="form.inspectorIds"
+ placeholder="璇烽�夋嫨宸℃浜猴紙鍙閫夛級"
+ filterable
+ multiple
+ collapse-tags
+ collapse-tags-tooltip
+ clearable
+ style="width: 100%">
+ <el-option v-for="item in userList"
+ :key="item.userId"
+ :label="item.nickName"
+ :value="item.userId" />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-form-item label="澶囨敞"
+ prop="remark">
+ <el-input v-model="form.remark"
+ type="textarea"
+ :rows="3"
+ placeholder="璇疯緭鍏ュ娉�" />
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
- <el-button type="primary" @click="submitForm">纭畾</el-button>
- <el-button @click="showDialog = false">鍙栨秷</el-button>
+ <el-button type="primary"
+ @click="submitForm">纭畾</el-button>
+ <el-button @click="dialogVisible = false">鍙栨秷</el-button>
</span>
</template>
+ </el-dialog>
+
+ <!-- 宸℃璁板綍寮圭獥 -->
+ <el-dialog ref="recordDialogRef"
+ v-model="recordDialogVisible"
+ title="宸℃璁板綍"
+ width="70vw"
+ :close-on-click-modal="false"
+ @open="onRecordDialogOpen">
+ <div class="mb10">
+ <el-button type="primary"
+ size="small"
+ @click="openRecordForm">鏂板璁板綍</el-button>
+ </div>
+ <div class="dialog-table-wrapper">
+ <el-table :data="recordList"
+ border
+ style="width: 100%">
+ <el-table-column prop="checkPoint" label="妫�鏌ョ偣" width="150" show-overflow-tooltip />
+ <el-table-column prop="checkContent" label="妫�鏌ュ唴瀹�" min-width="200" show-overflow-tooltip />
+ <el-table-column prop="checkResult" label="妫�鏌ョ粨鏋�" width="100">
+ <template #default="{ row }">
+ <el-tag :type="row.checkResult === '姝e父' ? 'success' : 'danger'">
+ {{ row.checkResult }}
+ </el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column prop="checkDesc" label="妫�鏌ヨ鏄�" width="200" show-overflow-tooltip />
+ <el-table-column prop="checkTime" label="妫�鏌ユ椂闂�" width="180" />
+ </el-table>
+ </div>
+
+ <!-- 鏂板璁板綍琛ㄥ崟 -->
+ <el-dialog v-model="recordFormVisible"
+ title="鏂板宸℃璁板綍"
+ width="600px"
+ append-to-body
+ :close-on-click-modal="false">
+ <el-form ref="recordFormRef"
+ :model="recordForm"
+ :rules="recordRules"
+ label-width="100px">
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="妫�鏌ョ偣"
+ prop="checkPoint">
+ <el-input v-model="recordForm.checkPoint"
+ placeholder="璇疯緭鍏ユ鏌ョ偣" />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="妫�鏌ョ粨鏋�"
+ prop="checkResult">
+ <el-radio-group v-model="recordForm.checkResult">
+ <el-radio label="姝e父">姝e父</el-radio>
+ <el-radio label="寮傚父">寮傚父</el-radio>
+ </el-radio-group>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-form-item label="妫�鏌ュ唴瀹�"
+ prop="checkContent">
+ <el-input v-model="recordForm.checkContent"
+ type="textarea"
+ :rows="3"
+ placeholder="璇疯緭鍏ユ鏌ュ唴瀹�" />
+ </el-form-item>
+ <el-form-item label="妫�鏌ヨ鏄�">
+ <el-input v-model="recordForm.checkDesc"
+ type="textarea"
+ :rows="2"
+ placeholder="璇疯緭鍏ユ鏌ヨ鏄�" />
+ </el-form-item>
+ <el-form-item label="妫�鏌ユ椂闂�">
+ <el-date-picker v-model="recordForm.checkTime"
+ type="datetime"
+ placeholder="璇烽�夋嫨妫�鏌ユ椂闂�"
+ format="YYYY-MM-DD HH:mm:ss"
+ value-format="YYYY-MM-DD HH:mm:ss"
+ style="width: 100%" />
+ </el-form-item>
+ </el-form>
+ <template #footer>
+ <span class="dialog-footer">
+ <el-button type="primary"
+ @click="submitRecordForm">纭畾</el-button>
+ <el-button @click="recordFormVisible = false">鍙栨秷</el-button>
+ </span>
+ </template>
+ </el-dialog>
+ </el-dialog>
+
+ <!-- 闅愭偅绠$悊寮圭獥 -->
+ <el-dialog ref="hazardDialogRef"
+ v-model="hazardDialogVisible"
+ title="闅愭偅绠$悊"
+ width="75vw"
+ :close-on-click-modal="false"
+ @open="onHazardDialogOpen">
+ <div class="mb10">
+ <el-button type="primary"
+ size="small"
+ @click="openHazardForm('add')">涓婃姤闅愭偅</el-button>
+ </div>
+ <div class="dialog-table-wrapper">
+ <el-table :data="hazardList"
+ border
+ style="width: 100%">
+ <el-table-column prop="hazardCode" label="闅愭偅缂栧彿" width="120" show-overflow-tooltip />
+ <el-table-column prop="hazardDesc" label="闅愭偅鎻忚堪" min-width="200" show-overflow-tooltip />
+ <el-table-column prop="hazardLevel" label="闅愭偅绛夌骇" width="100">
+ <template #default="{ row }">
+ <el-tag :type="row.hazardLevel === '閲嶅ぇ' ? 'danger' : 'warning'">
+ {{ row.hazardLevel }}
+ </el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column prop="hazardLocation" label="闅愭偅浣嶇疆" width="150" show-overflow-tooltip />
+ <el-table-column prop="status" label="鐘舵��" width="100">
+ <template #default="{ row }">
+ <el-tag :type="getHazardStatusType(row.status)">
+ {{ row.status }}
+ </el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column prop="rectifyUserName" label="鏁存敼璐d换浜�" width="120" />
+ <el-table-column label="鎿嶄綔" width="150" fixed="right">
+ <template #default="{ row }">
+ <el-button type="primary" link @click="openHazardForm('edit', row)">缂栬緫</el-button>
+ <el-button type="success" link @click="handleRectify(row)" v-if="row.status !== '宸叉暣鏀�'">鏁存敼</el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ </div>
+
+ <!-- 闅愭偅琛ㄥ崟 -->
+ <el-dialog v-model="hazardFormVisible"
+ :title="hazardDialogTitle"
+ width="600px"
+ append-to-body
+ :close-on-click-modal="false">
+ <el-form ref="hazardFormRef"
+ :model="hazardForm"
+ :rules="hazardRules"
+ label-width="100px">
+ <el-form-item label="闅愭偅鎻忚堪"
+ prop="hazardDesc">
+ <el-input v-model="hazardForm.hazardDesc"
+ type="textarea"
+ :rows="3"
+ placeholder="璇疯緭鍏ラ殣鎮f弿杩�" />
+ </el-form-item>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="闅愭偅绛夌骇"
+ prop="hazardLevel">
+ <el-select v-model="hazardForm.hazardLevel"
+ placeholder="璇烽�夋嫨闅愭偅绛夌骇"
+ style="width: 100%">
+ <el-option label="涓�鑸�" value="涓�鑸�" />
+ <el-option label="閲嶅ぇ" value="閲嶅ぇ" />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="闅愭偅浣嶇疆"
+ prop="hazardLocation">
+ <el-input v-model="hazardForm.hazardLocation"
+ placeholder="璇疯緭鍏ラ殣鎮d綅缃�" />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ </el-form>
+ <template #footer>
+ <span class="dialog-footer">
+ <el-button type="primary"
+ @click="submitHazardForm">纭畾</el-button>
+ <el-button @click="hazardFormVisible = false">鍙栨秷</el-button>
+ </span>
+ </template>
+ </el-dialog>
+
+ <!-- 鏁存敼琛ㄥ崟 -->
+ <el-dialog v-model="rectifyFormVisible"
+ title="鏁存敼"
+ width="500px"
+ append-to-body
+ :close-on-click-modal="false">
+ <el-form ref="rectifyFormRef"
+ :model="rectifyForm"
+ label-width="100px">
+ <el-form-item label="鏁存敼璇存槑"
+ prop="rectifyDesc">
+ <el-input v-model="rectifyForm.rectifyDesc"
+ type="textarea"
+ :rows="4"
+ placeholder="璇疯緭鍏ユ暣鏀硅鏄�" />
+ </el-form-item>
+ </el-form>
+ <template #footer>
+ <span class="dialog-footer">
+ <el-button type="primary"
+ @click="submitRectifyForm">纭畾</el-button>
+ <el-button @click="rectifyFormVisible = false">鍙栨秷</el-button>
+ </span>
+ </template>
+ </el-dialog>
</el-dialog>
</div>
</template>
<script setup>
-import { ref, reactive, onMounted } from 'vue'
-import { ElMessage, ElMessageBox } from 'element-plus'
+import { Search } from "@element-plus/icons-vue";
+import { nextTick, onMounted, ref, reactive, toRefs } from "vue";
+import { ElMessage, ElMessageBox } from "element-plus";
+import PIMTable from "@/components/PIMTable/PIMTable.vue";
+import { userListNoPage } from "@/api/system/user.js";
import {
getLineInspectionList,
- addOrEditLineInspection,
+ addLineInspection,
+ updateLineInspection,
deleteLineInspection,
- exportLineInspection
-} from '@/api/safeProduction/lineInspection'
-import { getDeviceLedger } from '@/api/equipmentManagement/ledger'
-
-// 鎼滅储琛ㄥ崟
-const searchForm = reactive({
- taskName: '',
- routeName: '',
- inspector: '',
- status: ''
-})
-
-// 鍒嗛〉鏁版嵁
-const pagination = reactive({
- currentPage: 1,
- pageSize: 10,
- total: 0
-})
-
-// 鍒楄〃鏁版嵁
-const inspectionList = ref([])
-
-// 璁惧閫夐」
-const deviceOptions = ref([])
-
-// 瀵硅瘽妗嗙姸鎬�
-const showDialog = ref(false)
-const dialogTitle = ref('鏂板宸℃')
-
-// 琛ㄥ崟鏁版嵁
-const form = reactive({
- id: null,
- taskName: '',
- routeName: '',
- deviceId: null,
- inspector: '',
- inspectionTime: '',
- inspectionResult: '',
- hazardDescription: '',
- remarks: ''
-})
+ completeLineInspection,
+ getInspectionRecords,
+ addInspectionRecord,
+ getHazardsByInspectionId,
+ addInspectionHazard,
+ updateInspectionHazard
+} from "@/api/safeProduction/lineInspection";
// 琛ㄥ崟楠岃瘉瑙勫垯
-const formRules = reactive({
- taskName: [{ required: true, message: '璇疯緭鍏ヤ换鍔″悕绉�', trigger: 'blur' }],
- routeName: [{ required: true, message: '璇疯緭鍏ョ嚎璺悕绉�', trigger: 'blur' }],
- inspector: [{ required: true, message: '璇疯緭鍏ュ贰妫�浜�', trigger: 'blur' }]
-})
+const rules = {
+ inspectionCode: [{ required: true, message: "璇疯緭鍏ュ贰妫�缂栧彿", trigger: "blur" }],
+ inspectionName: [{ required: true, message: "璇疯緭鍏ュ贰妫�鍚嶇О", trigger: "blur" }],
+ lineName: [{ required: true, message: "璇疯緭鍏ョ嚎璺悕绉�", trigger: "blur" }]
+};
-const formRef = ref(null)
+const recordRules = {
+ checkPoint: [{ required: true, message: "璇疯緭鍏ユ鏌ョ偣", trigger: "blur" }],
+ checkContent: [{ required: true, message: "璇疯緭鍏ユ鏌ュ唴瀹�", trigger: "blur" }],
+ checkResult: [{ required: true, message: "璇烽�夋嫨妫�鏌ョ粨鏋�", trigger: "change" }]
+};
-// 鑾峰彇鐘舵�佹爣绛剧被鍨�
-const getStatusType = (status) => {
- const map = {
- '寰呭贰妫�': 'info',
- '杩涜涓�': 'warning',
- '宸插畬鎴�': 'success'
- }
- return map[status] || 'info'
-}
+const hazardRules = {
+ hazardDesc: [{ required: true, message: "璇疯緭鍏ラ殣鎮f弿杩�", trigger: "blur" }],
+ hazardLevel: [{ required: true, message: "璇烽�夋嫨闅愭偅绛夌骇", trigger: "change" }],
+ hazardLocation: [{ required: true, message: "璇疯緭鍏ラ殣鎮d綅缃�", trigger: "blur" }]
+};
-// 鑾峰彇宸℃鍒楄〃
-const fetchList = async () => {
- try {
- const params = {
- ...searchForm,
- current: pagination.currentPage,
- size: pagination.pageSize
- }
- const res = await getLineInspectionList(params)
- if (res.code === 200) {
- inspectionList.value = res.data.records || []
- pagination.total = res.data.total || 0
- } else {
- ElMessage.error(res.message || '鑾峰彇鍒楄〃澶辫触')
- }
- } catch (error) {
- ElMessage.error('鑾峰彇鍒楄〃澶辫触')
- }
-}
-
-// 鑾峰彇璁惧鍒楄〃
-const fetchDeviceOptions = async () => {
- try {
- const res = await getDeviceLedger()
- if (res.code === 200) {
- deviceOptions.value = res.data || []
- }
- } catch (error) {
- console.error('鑾峰彇璁惧鍒楄〃澶辫触')
- }
-}
-
-// 鎼滅储
-const handleSearch = () => {
- pagination.currentPage = 1
- fetchList()
-}
-
-// 閲嶇疆鎼滅储
-const resetSearch = () => {
- Object.assign(searchForm, {
- taskName: '',
- routeName: '',
- inspector: '',
- status: ''
- })
- handleSearch()
-}
-
-// 鏂板
-const handleAdd = () => {
- dialogTitle.value = '鏂板宸℃'
- Object.assign(form, {
+// 鍝嶅簲寮忔暟鎹�
+const data = reactive({
+ searchForm: {
+ inspectionCode: "",
+ inspectionName: "",
+ lineName: "",
+ status: ""
+ },
+ tableLoading: false,
+ page: {
+ current: 1,
+ size: 20,
+ total: 0
+ },
+ tableData: [],
+ selectedIds: [],
+ form: {
id: null,
- taskName: '',
- routeName: '',
- deviceId: null,
- inspector: '',
- inspectionTime: '',
- inspectionResult: '',
- hazardDescription: '',
- remarks: ''
- })
- showDialog.value = true
-}
-
-// 缂栬緫
-const handleEdit = (row) => {
- dialogTitle.value = '缂栬緫宸℃'
- Object.assign(form, {
- id: row.id,
- taskName: row.taskName,
- routeName: row.routeName,
- deviceId: row.deviceId,
- inspector: row.inspector,
- inspectionTime: row.inspectionTime,
- inspectionResult: row.inspectionResult,
- hazardDescription: row.hazardDescription,
- remarks: row.remarks
- })
- showDialog.value = true
-}
-
-// 鍒犻櫎
-const handleDelete = async (row) => {
- try {
- await ElMessageBox.confirm('纭鍒犻櫎璇ュ贰妫�璁板綍鍚楋紵', '鎻愮ず', {
- type: 'warning'
- })
- const res = await deleteLineInspection([row.id])
- if (res.code === 200) {
- ElMessage.success('鍒犻櫎鎴愬姛')
- fetchList()
- } else {
- ElMessage.error(res.message || '鍒犻櫎澶辫触')
- }
- } catch (error) {
- // 鍙栨秷鍒犻櫎
+ inspectionCode: "",
+ inspectionName: "",
+ lineName: "",
+ inspectionType: "",
+ planTime: "",
+ inspectorId: "",
+ inspectorIds: [],
+ remark: ""
+ },
+ dialogVisible: false,
+ dialogTitle: "",
+ dialogType: "add",
+ // 宸℃璁板綍
+ currentInspectionId: null,
+ recordDialogVisible: false,
+ recordFormVisible: false,
+ recordList: [],
+ recordForm: {
+ inspectionId: null,
+ checkPoint: "",
+ checkContent: "",
+ checkResult: "姝e父",
+ checkDesc: "",
+ checkTime: ""
+ },
+ // 闅愭偅绠$悊
+ hazardDialogVisible: false,
+ hazardFormVisible: false,
+ hazardDialogTitle: "涓婃姤闅愭偅",
+ hazardList: [],
+ hazardForm: {
+ id: null,
+ inspectionId: null,
+ hazardDesc: "",
+ hazardLevel: "",
+ hazardLocation: ""
+ },
+ rectifyFormVisible: false,
+ rectifyForm: {
+ id: null,
+ rectifyDesc: ""
}
-}
+});
+
+const {
+ searchForm,
+ tableLoading,
+ page,
+ tableData,
+ selectedIds,
+ form,
+ dialogVisible,
+ dialogTitle,
+ dialogType,
+ currentInspectionId,
+ recordDialogVisible,
+ recordFormVisible,
+ recordList,
+ recordForm,
+ hazardDialogVisible,
+ hazardFormVisible,
+ hazardDialogTitle,
+ hazardList,
+ hazardForm,
+ rectifyFormVisible,
+ rectifyForm
+} = toRefs(data);
+
+// 琛ㄥ崟寮曠敤
+const formRef = ref();
+const recordFormRef = ref();
+const hazardFormRef = ref();
+const rectifyFormRef = ref();
+const userList = ref([]);
+
+// 琛ㄦ牸鍒楅厤缃�
+const tableColumn = ref([
+ {
+ label: "宸℃缂栧彿",
+ prop: "inspectionCode",
+ showOverflowTooltip: true,
+ minWidth: 150
+ },
+ {
+ label: "宸℃鍚嶇О",
+ prop: "inspectionName",
+ showOverflowTooltip: true,
+ minWidth: 180
+ },
+ {
+ label: "绾胯矾鍚嶇О",
+ prop: "lineName",
+ showOverflowTooltip: true,
+ minWidth: 150
+ },
+ {
+ label: "宸℃绫诲瀷",
+ prop: "inspectionType",
+ showOverflowTooltip: true,
+ minWidth: 100
+ },
+ {
+ label: "璁″垝宸℃鏃堕棿",
+ prop: "planTime",
+ showOverflowTooltip: true,
+ minWidth: 180
+ },
+ {
+ label: "宸℃浜�",
+ prop: "inspectorName",
+ showOverflowTooltip: true,
+ minWidth: 100
+ },
+ {
+ label: "鐘舵��",
+ prop: "status",
+ minWidth: 100,
+ dataType: "tag",
+ formatType: params => {
+ const typeMap = {
+ 寰呭贰妫�: "info",
+ 宸℃涓�: "warning",
+ 宸插畬鎴�: "success"
+ };
+ return typeMap[params] || "info";
+ }
+ },
+ {
+ dataType: "action",
+ label: "鎿嶄綔",
+ align: "center",
+ fixed: "right",
+ width: 350,
+ operation: [
+ {
+ name: "缂栬緫",
+ type: "text",
+ clickFun: row => {
+ openForm("edit", row);
+ },
+ show: row => row.status === "寰呭贰妫�"
+ },
+ {
+ name: "宸℃璁板綍",
+ type: "text",
+ clickFun: row => {
+ openRecordDialog(row);
+ }
+ },
+ {
+ name: "闅愭偅绠$悊",
+ type: "text",
+ clickFun: row => {
+ openHazardDialog(row);
+ }
+ },
+ {
+ name: "瀹屾垚宸℃",
+ type: "text",
+ style: { color: "#67C23A" },
+ clickFun: row => {
+ handleComplete(row);
+ },
+ show: row => row.status === "宸℃涓�"
+ },
+ {
+ name: "鍒犻櫎",
+ type: "text",
+ style: { color: "#F56C6C" },
+ clickFun: row => {
+ handleDelete(row);
+ },
+ show: row => row.status === "寰呭贰妫�"
+ }
+ ]
+ }
+]);
+
+// 鐢熷懡鍛ㄦ湡
+onMounted(() => {
+ getList();
+ userListNoPage().then(res => {
+ userList.value = res.data;
+ });
+});
+
+// 寮圭獥鍥哄畾楂樺害澶勭悊
+const setDialogFixedHeight = () => {
+ setTimeout(() => {
+ // 鐩存帴鍦� body 涓婃壘鎵�鏈� el-dialog锛坱eleport 娓叉煋鍒� body锛�
+ const dialogs = document.body.querySelectorAll('.el-dialog');
+ const dialog = dialogs[dialogs.length - 1]; // 鏈�鍚庝竴涓氨鏄垰鎵撳紑鐨�
+ if (!dialog) return;
+ Object.assign(dialog.style, {
+ height: '70vh',
+ maxHeight: '70vh',
+ overflow: 'hidden',
+ display: 'flex',
+ flexDirection: 'column'
+ });
+ const body = dialog.querySelector('.el-dialog__body');
+ if (body) {
+ Object.assign(body.style, { flex: '1', overflow: 'hidden' });
+ }
+ const wrapper = dialog.querySelector('.dialog-table-wrapper');
+ if (wrapper) {
+ Object.assign(wrapper.style, { flex: '1', overflowY: 'auto' });
+ }
+ }, 100);
+};
+
+const recordDialogRef = ref(null);
+const hazardDialogRef = ref(null);
+
+const onRecordDialogOpen = () => setDialogFixedHeight();
+const onHazardDialogOpen = () => setDialogFixedHeight();
+const handleQuery = () => {
+ page.value.current = 1;
+ getList();
+};
+
+const getList = () => {
+ tableLoading.value = true;
+ getLineInspectionList({ ...page.value, ...searchForm.value })
+ .then(res => {
+ tableLoading.value = false;
+ tableData.value = res.data.records;
+ page.value.total = res.data.total;
+ })
+ .catch(() => {
+ tableLoading.value = false;
+ });
+};
+
+// 鍒嗛〉澶勭悊
+const pagination = obj => {
+ page.value.current = obj.page;
+ page.value.size = obj.limit;
+ getList();
+};
+
+// 閫夋嫨鍙樺寲澶勭悊
+const handleSelectionChange = selection => {
+ selectedIds.value = selection.map(item => item.id);
+};
+
+// 鑾峰彇闅愭偅鐘舵�佺被鍨�
+const getHazardStatusType = status => {
+ const map = {
+ 寰呮暣鏀�: "danger",
+ 鏁存敼涓�: "warning",
+ 宸叉暣鏀�: "success"
+ };
+ return map[status] || "info";
+};
+
+// 鎵撳紑琛ㄥ崟
+const openForm = (type, row = null) => {
+ dialogType.value = type;
+ if (type === "add") {
+ dialogTitle.value = "鏂板宸℃浠诲姟";
+ Object.assign(form.value, {
+ id: null,
+ inspectionCode: "",
+ inspectionName: "",
+ lineName: "",
+ inspectionType: "",
+ planTime: "",
+ inspectorId: "",
+ inspectorIds: [],
+ remark: ""
+ });
+ } else if (type === "edit" && row) {
+ dialogTitle.value = "缂栬緫宸℃浠诲姟";
+ // 灏嗛�楀彿鍒嗛殧鐨処D瀛楃涓茶浆鎹负鏁扮粍
+ const inspectorIds = row.inspectorId
+ ? row.inspectorId.split(",").map(id => parseInt(id.trim())).filter(id => !isNaN(id))
+ : [];
+ Object.assign(form.value, {
+ id: row.id,
+ inspectionCode: row.inspectionCode,
+ inspectionName: row.inspectionName,
+ lineName: row.lineName,
+ inspectionType: row.inspectionType,
+ planTime: row.planTime,
+ inspectorId: row.inspectorId,
+ inspectorIds: inspectorIds,
+ remark: row.remark
+ });
+ }
+ dialogVisible.value = true;
+};
// 鎻愪氦琛ㄥ崟
const submitForm = async () => {
- if (!formRef.value) return
try {
- await formRef.value.validate()
- const res = await addOrEditLineInspection(form)
+ await formRef.value.validate();
+ // 灏嗘暟缁勮浆鎹负閫楀彿鍒嗛殧鐨勫瓧绗︿覆
+ const submitData = {
+ ...form.value,
+ inspectorId: form.value.inspectorIds ? form.value.inspectorIds.join(",") : ""
+ };
+ delete submitData.inspectorIds;
+
+ const api = dialogType.value === "add" ? addLineInspection : updateLineInspection;
+ const res = await api(submitData);
if (res.code === 200) {
- ElMessage.success('鎿嶄綔鎴愬姛')
- showDialog.value = false
- fetchList()
+ ElMessage.success(dialogType.value === "add" ? "娣诲姞鎴愬姛" : "鏇存柊鎴愬姛");
+ dialogVisible.value = false;
+ getList();
} else {
- ElMessage.error(res.message || '鎿嶄綔澶辫触')
+ ElMessage.error(res.msg || "鎿嶄綔澶辫触");
}
} catch (error) {
- ElMessage.error('璇峰~鍐欏畬鏁磋〃鍗曚俊鎭�')
+ console.error("琛ㄥ崟楠岃瘉澶辫触:", error);
}
-}
+};
-// 瀵煎嚭
-const handleExport = async () => {
+// 鍒犻櫎
+const handleDelete = row => {
+ ElMessageBox.confirm("纭鍒犻櫎璇ュ贰妫�浠诲姟鍚楋紵", "鍒犻櫎", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning"
+ })
+ .then(async () => {
+ const res = await deleteLineInspection([row.id]);
+ if (res.code === 200) {
+ ElMessage.success("鍒犻櫎鎴愬姛");
+ getList();
+ } else {
+ ElMessage.error(res.msg || "鍒犻櫎澶辫触");
+ }
+ })
+ .catch(() => {});
+};
+
+// 瀹屾垚宸℃
+const handleComplete = row => {
+ ElMessageBox.confirm("纭瀹屾垚璇ュ贰妫�浠诲姟鍚楋紵", "瀹屾垚宸℃", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning"
+ })
+ .then(async () => {
+ const res = await completeLineInspection(row.id);
+ if (res.code === 200) {
+ ElMessage.success("宸℃宸插畬鎴�");
+ getList();
+ } else {
+ ElMessage.error(res.msg || "鎿嶄綔澶辫触");
+ }
+ })
+ .catch(() => {});
+};
+
+// 鎵撳紑宸℃璁板綍寮圭獥
+const openRecordDialog = row => {
+ currentInspectionId.value = row.id;
+ fetchRecords(row.id);
+ recordDialogVisible.value = true;
+};
+
+// 鑾峰彇宸℃璁板綍
+const fetchRecords = async inspectionId => {
+ const res = await getInspectionRecords(inspectionId);
+ if (res.code === 200) {
+ recordList.value = res.data || [];
+ }
+};
+
+// 鎵撳紑璁板綍琛ㄥ崟
+const openRecordForm = () => {
+ Object.assign(recordForm.value, {
+ inspectionId: currentInspectionId.value,
+ checkPoint: "",
+ checkContent: "",
+ checkResult: "姝e父",
+ checkDesc: "",
+ checkTime: ""
+ });
+ recordFormVisible.value = true;
+};
+
+// 鎻愪氦璁板綍琛ㄥ崟
+const submitRecordForm = async () => {
try {
- const res = await exportLineInspection(searchForm)
- const blob = new Blob([res])
- const url = window.URL.createObjectURL(blob)
- const link = document.createElement('a')
- link.href = url
- link.download = '绾胯矾宸℃璁板綍.xlsx'
- link.click()
- window.URL.revokeObjectURL(url)
- ElMessage.success('瀵煎嚭鎴愬姛')
+ await recordFormRef.value.validate();
+ const res = await addInspectionRecord({ ...recordForm.value });
+ if (res.code === 200) {
+ ElMessage.success("娣诲姞鎴愬姛");
+ recordFormVisible.value = false;
+ fetchRecords(currentInspectionId.value);
+ } else {
+ ElMessage.error(res.msg || "娣诲姞澶辫触");
+ }
} catch (error) {
- ElMessage.error('瀵煎嚭澶辫触')
+ console.error("琛ㄥ崟楠岃瘉澶辫触:", error);
}
-}
+};
-// 鍒嗛〉澶у皬鏀瑰彉
-const handleSizeChange = (val) => {
- pagination.pageSize = val
- fetchList()
-}
+// 鎵撳紑闅愭偅绠$悊寮圭獥
+const openHazardDialog = row => {
+ currentInspectionId.value = row.id;
+ fetchHazards(row.id);
+ hazardDialogVisible.value = true;
+};
-// 褰撳墠椤垫敼鍙�
-const handleCurrentChange = (val) => {
- pagination.currentPage = val
- fetchList()
-}
+// 鑾峰彇闅愭偅鍒楄〃
+const fetchHazards = async inspectionId => {
+ const res = await getHazardsByInspectionId(inspectionId);
+ if (res.code === 200) {
+ hazardList.value = res.data || [];
+ }
+};
-onMounted(() => {
- fetchList()
- fetchDeviceOptions()
-})
+// 鎵撳紑闅愭偅琛ㄥ崟
+const openHazardForm = (type, row = null) => {
+ if (type === "add") {
+ hazardDialogTitle.value = "涓婃姤闅愭偅";
+ Object.assign(hazardForm.value, {
+ id: null,
+ inspectionId: currentInspectionId.value,
+ hazardDesc: "",
+ hazardLevel: "",
+ hazardLocation: ""
+ });
+ } else {
+ hazardDialogTitle.value = "缂栬緫闅愭偅";
+ Object.assign(hazardForm.value, {
+ id: row.id,
+ inspectionId: row.inspectionId,
+ hazardDesc: row.hazardDesc,
+ hazardLevel: row.hazardLevel,
+ hazardLocation: row.hazardLocation
+ });
+ }
+ hazardFormVisible.value = true;
+};
+
+// 鎻愪氦闅愭偅琛ㄥ崟
+const submitHazardForm = async () => {
+ try {
+ await hazardFormRef.value.validate();
+ const api = hazardForm.value.id ? updateInspectionHazard : addInspectionHazard;
+ const res = await api({ ...hazardForm.value });
+ if (res.code === 200) {
+ ElMessage.success("鎿嶄綔鎴愬姛");
+ hazardFormVisible.value = false;
+ fetchHazards(currentInspectionId.value);
+ } else {
+ ElMessage.error(res.msg || "鎿嶄綔澶辫触");
+ }
+ } catch (error) {
+ console.error("琛ㄥ崟楠岃瘉澶辫触:", error);
+ }
+};
+
+// 鏁存敼
+const handleRectify = row => {
+ Object.assign(rectifyForm.value, {
+ id: row.id,
+ rectifyDesc: ""
+ });
+ rectifyFormVisible.value = true;
+};
+
+// 鎻愪氦鏁存敼琛ㄥ崟
+const submitRectifyForm = async () => {
+ const res = await updateInspectionHazard({
+ id: rectifyForm.value.id,
+ status: "宸叉暣鏀�",
+ rectifyDesc: rectifyForm.value.rectifyDesc
+ });
+ if (res.code === 200) {
+ ElMessage.success("鏁存敼鎴愬姛");
+ rectifyFormVisible.value = false;
+ fetchHazards(currentInspectionId.value);
+ } else {
+ ElMessage.error(res.msg || "鏁存敼澶辫触");
+ }
+};
</script>
<style scoped>
-.line-inspection {
- padding: 20px;
+.search_title {
+ font-size: 14px;
+ color: #606266;
}
-.search-area {
- background: #f5f7fa;
- padding: 20px;
- border-radius: 4px;
- margin-bottom: 15px;
+.mb10 {
+ margin-bottom: 10px;
}
-.actions {
- margin-bottom: 15px;
+.mb20 {
+ margin-bottom: 20px;
}
-.pagination {
- margin-top: 20px;
- display: flex;
- justify-content: flex-end;
+.ml10 {
+ margin-left: 10px;
}
</style>
--
Gitblit v1.9.3