From 56bd210f524342075b443a5b59b5bc6c215473f5 Mon Sep 17 00:00:00 2001 From: lSun <15893999301@qq.com> Date: Tue, 27 Jan 2026 18:50:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=85=E5=A4=87=E5=AE=9A=E4=BD=8D=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/iotDevice/index.js | 18 +- src/views/iotDevice/index.vue | 488 ++++++++++++++++-- src/views/material/ma/supplier/index.vue | 22 +- src/views/search/category/index.vue | 4 +- .../toolsManage/codeToolsLedger/index.vue | 36 +- src/views/toolsManage/toolsLedger/index.vue | 44 +- vue.config.js | 4 +- 7 files changed, 537 insertions(+), 79 deletions(-) diff --git a/src/api/iotDevice/index.js b/src/api/iotDevice/index.js index 81952e6c..f5f92586 100644 --- a/src/api/iotDevice/index.js +++ b/src/api/iotDevice/index.js @@ -44,7 +44,7 @@ export function unbindDeviceApi(data) { export function deleteDeviceApi(id) { return request({ url: `/material-mall/iotMachine/deleteById/${id}`, - method: 'delete', + method: 'POST', }) } @@ -149,3 +149,19 @@ export function getRecordListAll(params = {}) { params, }) } + +export function getCategoryList(query) { + return request({ + url: '/material-mall/iotMachine/getCategoryList', + method: 'get', + params: query + }) +} + +export function getEquipment(query) { + return request({ + url: '/material-mall/iotMachine/getEquipment', + method: 'get', + params: query + }) +} diff --git a/src/views/iotDevice/index.vue b/src/views/iotDevice/index.vue index 477fc0c0..d455bb23 100644 --- a/src/views/iotDevice/index.vue +++ b/src/views/iotDevice/index.vue @@ -4,35 +4,92 @@
- + - - 重置 - + + + + + + + + + +
+ + + + + + + +
+ +
+
+ + +
- + 新增 + +
@@ -48,12 +105,40 @@ height="100%" > - + + + + + + + + - + @@ -213,20 +298,20 @@ :model="addOrEditForm" :rules="addOrEditFormRules" > - + - + - + - - - + + + - + 取消 - {{ isAdd ? '新增' : '保存' }} + {{ isAdd ? '确定' : '保存' }}
- - + <!– 新增:隐藏存储iotId,无样式修改 –> - + <!– 仅修改prop为typeName,label/样式完全保留 –> - + <!– 仅修改prop为typeCode,label/样式完全保留 –> + --> + + +
+ +
+ + + + + + + + + + + + + + + 查询 + 重置 + + +
+ + + + + + + + + + + + + + +
+ +
@@ -397,6 +594,8 @@ import { addOrUpdate, getIotList, unbindIot, + getCategoryList, + getEquipment } from '@/api/iotDevice' import { dialogConfig } from './config' import DialogModel from '@/components/DialogModel' // 弹框组件 @@ -404,6 +603,7 @@ import TableModel from '@/components/TableModel' import { bindIot } from '../../api/iotDevice' // 表格组件 import MapDialog from './MapDIalog' +import { getOwnEquipmentList } from '@/api/system/equipmentNew' export default { name: 'IOTManagement', @@ -460,7 +660,8 @@ export default { bindForm: { iotId:'', // 核心:存储绑定的设备ID typeName:'', - maCode: '' + maCode: '', + maId:'' }, // 绑定表单校验规则 bindFormRules: { @@ -493,6 +694,58 @@ export default { deviceName: '', deviceType: '', iotCode: '', + // 搜索区域展开状态 + searchExpanded: false, + showSearch: true, + // 表头字段 + columns:[ + { key: 1, label: `定位设备名称`, prop: 'iotName', visible: true, }, + { key: 2, label: `定位设备编码`, prop: 'iotCode', visible: true, }, + { key: 3, label: `装备类目`, prop: 'type',width: 300, visible: true, }, + { key: 4, label: `装备名称`, prop: 'typeName',width: 300, visible: true, }, + { key: 5, label: `装备编码`, prop: 'maCode', visible: true, }, + { key: 6, label: `使用项目`, prop: 'propertyUnit', visible: true, }, + { key: 7, label: `装备状态`, prop: 'maStatus', visible: true, }, + { key: 8, label: `设备状态`, prop: 'iotStatus', visible: true, }, + { key: 9, label: `绑定状态`, prop: 'bindStatus', visible: true, }, + { key: 10, label: `设备地图`, prop: 'address', visible: true, }, + { key: 11, label: `设备负责人`, prop: 'iotManager', visible: true, }, + { key: 12, label: `绑定时间`, prop: 'bindTime', visible: true, }, + { key: 13, label: `解绑时间`, prop: 'unBindTime', visible: true, }, + ], + + + // 新增:筛选表单数据 + searchForm: { + equipmentName: '', + equipmentType: '', + specModel: '', + type: '', + }, + + categoryList: [], + + // 所有表格状态:新增自有/共享/外租表格数据 + tableData: { + // 新增 + own: { list: [], loading: false, total: 0, pageNum: 1, pageSize: 10 }, + }, + tableColumns: { + // 新增:实例详情表格列(用于弹窗内的表格) + instanceDetail: [ + { label: '分类', prop: 'type', minWidth: 300 }, + { label: '设备编码', prop: 'deviceCode', minWidth: 120 }, + { label: '装备名称', prop: 'name', minWidth: 150 }, + { label: '原始编码', prop: 'originalEncoding', minWidth: 120 }, + { label: '装备状态', prop: 'maStatus', minWidth: 120, + dictMap: { 1: '在库', 2: '自用', 3: '共享', 5: '维修' } + }, + + ], + }, + ownOpen: false, // 自有装备弹窗 + selectedOwnRows: [], + selectedRowId: '', } }, created() { @@ -500,6 +753,25 @@ export default { //this.getDeviceTypeList() }, methods: { + + async getCategoryList() { + const res = await getCategoryList() + if (res.code === 200) { + this.categoryList = res.data.map(item => ({ + ...item, + uniqueKey: `${item.typeId}-${item.type}` + })) + } + }, + +/* async getEquipment(){ + const res = await getEquipment() + if (res.code === 200) { + this.tableData.own.list = res.rows + this.tableData.own.total = res.total + } + }, */ + isOverflow(text, line = 2, width = 180) { // 创建一个隐藏的测量节点 const div = document.createElement('div') @@ -569,6 +841,8 @@ export default { /** 添加/编辑设备 */ addDevice(row) { + + this.getCategoryList() // 1. 先清空旧表单(放在最前) this.$refs.addOrEditFormRef?.resetFields() @@ -584,7 +858,7 @@ export default { } } else { this.isAdd = true - this.dialogTitle = '新增设备' // 用新的标题变量 + this.dialogTitle = '新增定位设备' // 用新的标题变量 // 新增:重置表单默认值 this.addOrEditForm = { iotId: '', @@ -605,11 +879,15 @@ export default { /** 绑定设备 */ handleBind(row){ + this.selectedRowId =''; + this.getCategoryList(); + this.loadOwnEquipmentData() this.$refs.bindFormRef?.resetFields() this.bindForm = { iotId: row.iotId, typeName: '', maCode: '', + maId: '', } this.bindDialogTitle = '设备绑定' // 用新的标题变量 this.bindDialogVisible = true; @@ -686,7 +964,8 @@ export default { this.bindForm = { iotId:'', typeName:'', - maCode: '' + maCode: '', + maId: '', } }, @@ -715,7 +994,7 @@ export default { }).then(async () => { try { if (type === 1) { - const res = await deleteDeviceApi(row.id) + const res = await deleteDeviceApi(row.iotId) if (res.code === 200) { this.$message.success(`${title}成功!`) this.getDeviceList() @@ -778,10 +1057,99 @@ export default { async handleMap(row) { this.deviceName = row.specificationType - this.deviceType = row.maStatusName + this.deviceType = row.maStatusName this.iotCode = row.iotCode this.mapDialogVisible = true }, + + /** + * 切换搜索区域展开/收起状态 + */ + toggleSearch() { + this.searchExpanded = !this.searchExpanded + this.searchExpanded ? (this.tableHeight = 320) : (this.tableHeight = 500) + }, + + handleCategoryChange(selectedTypeId) { + if (!selectedTypeId) { + this.formData.classificationForm.selectedCategory = null + this.formData.classificationForm.category = '' + return + } + const selectedItem = this.categoryList.find( + item => item.typeId === selectedTypeId + ) + if (selectedItem) { + this.formData.classificationForm.matchingName = selectedItem.typeId + this.formData.classificationForm.category = selectedItem.type + this.formData.classificationForm.name = selectedItem.equipmentName + } + }, + + handleOwnSearch() { + this.tableData.own.pageNum = 1 + this.loadOwnEquipmentData() + }, + resetOwnSearch() { + this.searchForm.own = { + name: '', + type: '', + specificationModel: '' + } + this.tableData.own.pageNum = 1 + this.loadOwnEquipmentData() + }, + handleOwnSizeChange(val) { + this.tableData.own.pageSize = val + this.loadOwnEquipmentData() + }, + handleOwnCurrentChange(val) { + this.tableData.own.pageNum = val + this.loadOwnEquipmentData() + }, + + // 点击行选中单选框 + handleRowClick(row) { + this.selectedRowId = row.id; // 替换为你行数据的唯一标识(如row.key) + + this.bindForm = { + iotId: this.bindForm.iotId, + typeName: row.name, + maCode: row.deviceCode, + maId: this.selectedRowId, + } + }, + async handleOwnConfirm() { + const res = await bindIot(this.bindForm) + if (res.code === 200) { + this.$message.success(`绑定成功!`) + this.bindDialogVisible = false + this.getDeviceList() + } + }, + + async loadOwnEquipmentData() { + const tabConfig = this.tableData.own + tabConfig.loading = true + try { + const queryParams = { + ...this.searchForm.own, + pageNum: tabConfig.pageNum, + pageSize: tabConfig.pageSize + } + const res = await getEquipment(queryParams) + tabConfig.list = res.rows || [] + tabConfig.total = res.total || 0 + } catch (err) { + console.error('加载自有装备数据失败:', err) + this.$message.error('加载自有装备数据失败,请稍后重试') + tabConfig.list = [] + tabConfig.total = 0 + } finally { + tabConfig.loading = false + } + } + } } @@ -803,7 +1171,7 @@ export default { background: #fff; padding: 16px; border-radius: 4px; - margin-bottom: 16px; + margin-bottom: 2px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); flex-shrink: 0; /* 不压缩 */ } @@ -913,4 +1281,62 @@ export default { .project-table .el-table__row:hover { background-color: #f5f7fa; } + +.status-operation-bar { + background-color: #fff; + border-radius: 4px; + box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05); + padding: 15px 20px; + margin-bottom: 20px; + display: flex; + justify-content: space-between; + align-items: center; +} + +/* 搜索区域收起/展开按钮 */ +.search-toggle-btn { + color: #2CBAB2; + padding: 5px 10px; + font-size: 16px; + font-weight: 300; +} + +/* 固定操作栏样式 */ +.sticky-bar { + position: sticky; + top: 0; + z-index: 10; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); +} + +.operation-buttons { + width: 100%; +} + +.el-button--text { + color: #2CBAB2; +} + +.el-button--primary { + background-color: #2CBAB2; + border-color: #2CBAB2; +} + +/* 隐藏el-radio的文本部分 */ +.radio-no-text .el-radio__label { + display: none !important; +} +/* 可选:微调单选按钮位置,居中显示 */ +.radio-no-text .el-radio__input { + margin: 0 auto; + display: block; +} + +.el-radio__input.is-checked+.el-radio__label{ + display: none; +} + +::v-deep .el-radio__label{ + display: none; +} diff --git a/src/views/material/ma/supplier/index.vue b/src/views/material/ma/supplier/index.vue index 50e8fab9..d74dcaac 100644 --- a/src/views/material/ma/supplier/index.vue +++ b/src/views/material/ma/supplier/index.vue @@ -97,7 +97,7 @@ - +