From cd86cdae33c3247ce3bd7c57871d4b22ca47df97 Mon Sep 17 00:00:00 2001 From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com> Date: Wed, 21 Jan 2026 11:05:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E7=A8=8B=E5=AE=89=E5=85=A8=E5=88=86?= =?UTF-8?q?=E6=9E=90=E6=A8=A1=E5=9D=97=E5=88=9D=E6=AD=A5=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/dataManage/projectSafety.js | 59 +- src/views/dataManage/projectQuality/index.vue | 42 +- .../components/addAndEditForm.vue | 305 +++++++ .../components/addAndEditFormOne.vue | 249 ----- .../components/addAndEditFormTwo.vue | 239 ----- src/views/dataManage/projectSafety/index.vue | 863 ++++++++---------- 6 files changed, 712 insertions(+), 1045 deletions(-) create mode 100644 src/views/dataManage/projectSafety/components/addAndEditForm.vue delete mode 100644 src/views/dataManage/projectSafety/components/addAndEditFormOne.vue delete mode 100644 src/views/dataManage/projectSafety/components/addAndEditFormTwo.vue diff --git a/src/api/dataManage/projectSafety.js b/src/api/dataManage/projectSafety.js index 92c6ad5..ea87887 100644 --- a/src/api/dataManage/projectSafety.js +++ b/src/api/dataManage/projectSafety.js @@ -1,7 +1,8 @@ import request from '@/utils/request' import requestFormData from '@/utils/request_formdata' -// 获取工程安全分析一本账列表 + +// 获取工程安全分析列表 export function getProjectSafetyAnalysisListAPI(data) { return request({ url: '/background/sj/safety/list', @@ -10,7 +11,7 @@ export function getProjectSafetyAnalysisListAPI(data) { }) } -// 新增工程安全分析一本账列表 +// 新增工程安全分析 export function addProjectSafetyAnalysisAPI(data) { return request({ url: '/background/sj/safety/addData', @@ -19,74 +20,46 @@ export function addProjectSafetyAnalysisAPI(data) { }) } -// 编辑工工程安全分析一本账列表 +// 编辑工程安全分析 export function editProjectSafetyAnalysisAPI(data) { return request({ - url: '/background/sj/safety/updateData', + url: '/background/sj/safety/editData', method: 'post', data, }) } -// 删除工工程安全分析一本账列表 +// 删除工程安全分析 export function deleteProjectSafetyAnalysisAPI(data) { return request({ - url: '/background/sj/safety/delete', + url: '/background/sj/safety/deleteData', method: 'post', data, }) } -// 获取视频风险分析列表 -export function getVideoSafetyAnalysisListAPI(data) { +// 获取工程安全分析阈值列表 +export function getProjectSafetyThresholdListAPI(data) { return request({ - url: '/background/sj/safety/getVideoList', + url: '/background/sj/safety/threshold/list', method: 'get', params: data, }) } -// 新增视频风险分析列表 -export function addVideoSafetyAnalysisAPI(data) { - return requestFormData({ - url: '/background/sj/safety/addVideoFile', - method: 'post', - data, - }) -} - -// 编辑工视频风险分析列表 -export function editVideoSafetyAnalysisAPI(data) { - return requestFormData({ - url: '/background/sj/safety/updateVideoFile', - method: 'post', - data, - }) -} - -// 删除工视频风险分析列表 -export function deleteVideoSafetyAnalysisAPI(data) { +// 新增工程安全分析阈值 +export function addProjectSafetyThresholdAPI(data) { return request({ - url: '/background/sj/safety/deleteVideo', + url: '/background/sj/safety/threshold/add', method: 'post', data, }) } -// 下载模板 -export function downloadProjectTemplateAPI(data = {}) { +// 编辑工程安全分析阈值 +export function editProjectSafetyThresholdAPI(data) { return request({ - url: '/background/sj/safety/downloadFile', - method: 'get', - responseType: 'blob', - params: data, - }) -} - -// 导入工程安全分析一本账列表 -export function importProjectSafetyAnalysisAPI(data) { - return requestFormData({ - url: '/background/sj/safety/importFileData', + url: '/background/sj/safety/threshold/edit', method: 'post', data, }) diff --git a/src/views/dataManage/projectQuality/index.vue b/src/views/dataManage/projectQuality/index.vue index ecb7348..e008360 100644 --- a/src/views/dataManage/projectQuality/index.vue +++ b/src/views/dataManage/projectQuality/index.vue @@ -1,31 +1,42 @@ + + + + diff --git a/src/views/dataManage/projectSafety/components/addAndEditFormOne.vue b/src/views/dataManage/projectSafety/components/addAndEditFormOne.vue deleted file mode 100644 index 8bca56a..0000000 --- a/src/views/dataManage/projectSafety/components/addAndEditFormOne.vue +++ /dev/null @@ -1,249 +0,0 @@ - - - - - diff --git a/src/views/dataManage/projectSafety/components/addAndEditFormTwo.vue b/src/views/dataManage/projectSafety/components/addAndEditFormTwo.vue deleted file mode 100644 index ed425bc..0000000 --- a/src/views/dataManage/projectSafety/components/addAndEditFormTwo.vue +++ /dev/null @@ -1,239 +0,0 @@ - - - - - diff --git a/src/views/dataManage/projectSafety/index.vue b/src/views/dataManage/projectSafety/index.vue index 8f02263..84501cf 100644 --- a/src/views/dataManage/projectSafety/index.vue +++ b/src/views/dataManage/projectSafety/index.vue @@ -1,259 +1,115 @@ @@ -301,186 +223,163 @@ import { getProjectSafetyAnalysisListAPI, deleteProjectSafetyAnalysisAPI, - getVideoSafetyAnalysisListAPI, - deleteVideoSafetyAnalysisAPI, - downloadProjectTemplateAPI, - importProjectSafetyAnalysisAPI, -} from '@/api/dataAnalysis/projectSafety' + getProjectSafetyThresholdListAPI, + addProjectSafetyThresholdAPI, + editProjectSafetyThresholdAPI, +} from '@/api/dataManage/projectSafety' -import { downloadFile } from '@/utils/download' - -import AddAndEditFormOne from './components/addAndEditFormOne.vue' -import AddAndEditFormTwo from './components/addAndEditFormTwo.vue' -import UploadFileFormData from '@/components/UploadFileFormData' +import AddAndEditForm from './components/addAndEditForm.vue' export default { name: 'ProjectQuality', components: { - AddAndEditFormOne, - AddAndEditFormTwo, - UploadFileFormData, + AddAndEditForm, }, data() { return { - total_1: 0, - total_2: 0, + total: 0, detailsOneId: '', - detailsTwoId: '', editRow_1: {}, // 编辑风险一本账行 - editRow_2: {}, // 编辑视频风险分析行 - safetyType: '风险一本账', projectList: [], // 风险一本账列表 - projectList_1: [], // 视频风险分析列表 - importFileList: [], // 导入文件列表 addAndEditDialogVisible: false, importDialogVisible: false, loading: false, addAndEditDialogTitle: '', tableColumns: [ - { - label: '风险编号', - prop: 'riskCode', - }, - { - label: '作业部位', - prop: 'riskSite', - }, - { - label: '风险等级', - prop: 'riskLevel', - }, - { - label: '预控措施', - prop: 'controller', - }, - { - label: '风险控制关键因素', - prop: 'riskController', - }, - { - label: '开始日期', - prop: 'startTime', - }, - { - label: '是否销号', - prop: 'isXh', - }, + { label: '工程名称', prop: 'projectName' }, + { label: '作业计划编号', prop: 'jobPlanCode' }, + { label: '作业地点', prop: 'jobSite' }, + { label: '监测点编号', prop: 'monitorPointCode' }, + { label: '监测点名称', prop: 'monitorPointName' }, + { label: '温度', prop: 'temperature' }, + { label: '湿度', prop: 'humidity' }, + { label: '风速', prop: 'windSpeed' }, + { label: '空气质量', prop: 'airQuality' }, + { label: '是否存在隐患', prop: 'hiddenDanger' }, + { label: '分析与改进', prop: 'analyzeImprove' }, ], - tableColumns_1: [ - { - label: '球机名称', - prop: 'ballName', - }, - { - label: '创建时间', - prop: 'createTime', - }, - { - label: '图片', - prop: 'bast64', - }, - { - label: '名称', - prop: 'name', - }, - ], - queryParams_1: { + + queryParams: { pageNum: 1, pageSize: 10, - riskCode: '', - riskSite: '', - riskLevel: '', + jobSite: '', + monitorPointCode: '', }, - queryParams_2: { - pageNum: 1, - pageSize: 10, - ballName: '', - name: '', + + // 阈值配置 + thresholdDialogVisible: false, + thresholdSubmitLoading: false, + thresholdId: '', + thresholdForm: { + temperatureMin: '', + temperatureMax: '', + humidityMin: '', + humidityMax: '', + windSpeedMin: '', + windSpeedMax: '', + airQualityMin: '', + airQualityMax: '', + }, + thresholdRules: { + temperatureRange: [ + { + validator: this.validateRange( + 'temperatureMin', + 'temperatureMax', + '温度阈值', + ), + trigger: 'blur', + }, + ], + humidityRange: [ + { + validator: this.validateRange( + 'humidityMin', + 'humidityMax', + '湿度阈值', + ), + trigger: 'blur', + }, + ], + windSpeedRange: [ + { + validator: this.validateRange( + 'windSpeedMin', + 'windSpeedMax', + '风速阈值', + ), + trigger: 'blur', + }, + ], + airQualityRange: [ + { + validator: this.validateRange( + 'airQualityMin', + 'airQualityMax', + '空气质量阈值', + ), + trigger: 'blur', + }, + ], }, } }, created() { this.getProjectSafetyAnalysisList() - this.getVideoSafetyAnalysisList() }, methods: { + validateRange(minKey, maxKey, label) { + return (rule, value, callback) => { + const min = this.thresholdForm[minKey] + const max = this.thresholdForm[maxKey] + if (min === '' || max === '') { + callback(new Error(`${label}的最小值和最大值不能为空`)) + return + } + const minNum = Number(min) + const maxNum = Number(max) + if (Number.isNaN(minNum) || Number.isNaN(maxNum)) { + callback(new Error(`${label}仅支持数字`)) + return + } + if (minNum > maxNum) { + callback(new Error(`${label}的最小值不能大于最大值`)) + return + } + callback() + } + }, + onHandleQuery() { this.getProjectSafetyAnalysisList() }, - onHandleQuery_2() { - this.getVideoSafetyAnalysisList() - }, - onHandleReset_2() { - this.queryParams_2 = { - pageNum: 1, - pageSize: 10, - ballName: '', - name: '', - } - this.getVideoSafetyAnalysisList() - }, - onHandleAddProject() { + onHandleAddProjectSafety() { this.addAndEditDialogVisible = true this.addAndEditDialogTitle = '新增' + this.detailsOneId = '' + this.editRow_1 = {} }, onHandleReset() { - this.queryParams_1 = { + this.queryParams = { pageNum: 1, pageSize: 10, - riskCode: '', - riskSite: '', - riskLevel: '', + jobSite: '', + monitorPointCode: '', } - this.getProjectSafetyAnalysisList() + // this.getProjectSafetyAnalysisList() }, // 获取风险一本账列表 async getProjectSafetyAnalysisList() { - const res = await getProjectSafetyAnalysisListAPI( - this.queryParams_1, - ) + const res = await getProjectSafetyAnalysisListAPI(this.queryParams) this.projectList = res.rows - this.total_1 = res.total + this.total = res.total }, - // 获取视频风险分析列表 - async getVideoSafetyAnalysisList() { - const res = await getVideoSafetyAnalysisListAPI(this.queryParams_2) - this.projectList_1 = res.rows - this.total_2 = res.total - }, - - // 新增工程质量 - addProjectQuality() {}, - - // 编辑视频风险分析行 - onHandleEditProject(row) { - this.editRow_2 = row - this.detailsTwoId = row.id - this.addAndEditDialogVisible = true - this.addAndEditDialogTitle = '编辑' - }, - - // 删除视频风险分析行 - onHandleDeleteProject(row) { - this.$confirm('确定删除该视频风险分析行吗?', '提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - }).then(async () => { - const res = await deleteVideoSafetyAnalysisAPI({ id: row.id }) - if (res.code === 200) { - this.$message.success('删除成功') - this.getVideoSafetyAnalysisList() - } else { - this.$message.error('删除失败') - } - }) - }, - - // 编辑风险一本账行 + // 编辑风险 onHandleEditProject_1(row) { this.editRow_1 = row this.detailsOneId = row.id @@ -488,9 +387,9 @@ export default { this.addAndEditDialogTitle = '编辑' }, - // 删除风险一本账行 + // 删除风险 onHandleDeleteProject_1(row) { - this.$confirm('确定删除该风险一本账行吗?', '提示', { + this.$confirm('确定删除该项目安全吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', }).then(async () => { @@ -504,115 +403,71 @@ export default { }) }, - indexToRiskLevel(index) { - switch (index) { - case '1': - return '一级风险' - case '2': - return '二级风险' - case '3': - return '三级风险' - case '4': - return '四级风险' - case '5': - return '五级风险' - default: - return '' - } - }, - // 提交工程质量 async onHandleSubmit() { - if (this.safetyType === '风险一本账') { - const res = await this.$refs.addAndEditFormOneRef.submitForm() - if (res) { - this.$message.success( - this.addAndEditDialogTitle === '新增' - ? '新增成功' - : '编辑成功', - ) - this.getProjectSafetyAnalysisList() - this.addAndEditDialogVisible = false - } else { - this.$message.error('提交失败') - } - } else { - const res = await this.$refs.addAndEditFormTwoRef.submitForm() - if (res) { - this.$message.success( - this.addAndEditDialogTitle === '新增' - ? '新增成功' - : '编辑成功', - ) - this.getVideoSafetyAnalysisList() - this.addAndEditDialogVisible = false - } else { - this.$message.error('提交失败') - } - } - }, - - // 导入 - onHandleImport() { - this.importDialogVisible = true - this.importFileList = [] - }, - - // 下载模板 - onHandleDownloadTemplate() { - downloadProjectTemplateAPI().then((res) => { - downloadFile({ - fileName: '模板.xlsx', - fileData: res, - fileType: 'application/vnd.ms-excel;charset=utf-8', - }) - }) - }, - - // 取消上传 - onHandleCancelImport() { - this.importFileList = [] - this.dialogConfig.outerVisible = false - }, - - // 确定上传 - async onHandleConfirmImport() { - if (this.importFileList.length > 0) { - const formData = new FormData() - // 增加全局loading - this.loading = true - formData.append('file', this.importFileList[0].raw) - const res = await importProjectSafetyAnalysisAPI(formData) - - this.loading = false - - if (res.code === 200) { - this.$message.success('导入成功') - this.importFileList = [] - this.importDialogVisible = false - this.getProjectSafetyAnalysisList() - } else { - this.$message.error(res.msg) - } - } else { - this.$confirm( - '当前未选择文件,确定后将关闭上传页面?', - '温馨提示', - { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning', - }, + const res = await this.$refs.AddAndEditFormRef.submitForm() + if (res) { + this.$message.success( + this.addAndEditDialogTitle === '新增' + ? '新增成功' + : '编辑成功', ) - .then(async () => { - this.importFileList = [] - this.importDialogVisible = false - }) - .catch(() => { - // console.log('取消') - }) + this.getProjectSafetyAnalysisList() + this.addAndEditDialogVisible = false + } else { + this.$message.error('提交失败') } }, + + // 阈值配置:打开弹窗并加载数据 + async onHandleThresholdConfig() { + this.thresholdDialogVisible = true + await this.loadThreshold() + }, + + async loadThreshold() { + const res = await getProjectSafetyThresholdListAPI({ + pageNum: 1, + pageSize: 1, + }) + const record = + res?.data?.[0] || + res?.rows?.[0] || + (Array.isArray(res) ? res[0] : null) + if (record) { + this.thresholdId = record.id || '' + this.thresholdForm.temperatureMin = record.temperatureMin || '' + this.thresholdForm.temperatureMax = record.temperatureMax || '' + this.thresholdForm.humidityMin = record.humidityMin || '' + this.thresholdForm.humidityMax = record.humidityMax || '' + this.thresholdForm.windSpeedMin = record.windSpeedMin || '' + this.thresholdForm.windSpeedMax = record.windSpeedMax || '' + this.thresholdForm.airQualityMin = record.airQualityMin || '' + this.thresholdForm.airQualityMax = record.airQualityMax || '' + } + }, + + async onHandleThresholdSubmit() { + this.$refs.thresholdFormRef.validate(async (valid) => { + if (!valid) return + this.thresholdSubmitLoading = true + const payload = { ...this.thresholdForm } + if (this.thresholdId) { + payload.id = this.thresholdId + } + const API = this.thresholdId + ? editProjectSafetyThresholdAPI + : addProjectSafetyThresholdAPI + const res = await API(payload) + this.thresholdSubmitLoading = false + if (res.code === 200) { + this.$message.success('阈值配置保存成功') + this.thresholdDialogVisible = false + } else { + this.$message.error(res.msg || '保存失败') + } + }) + }, }, } @@ -641,4 +496,16 @@ export default { text-align: right; margin-top: 20px; } + +.range-box { + display: flex; + align-items: center; + gap: 8px; +} + +.range-split { + width: 12px; + text-align: center; + color: #666; +}