diff --git a/src/api/common.js b/src/api/common.js new file mode 100644 index 00000000..267c3de7 --- /dev/null +++ b/src/api/common.js @@ -0,0 +1,26 @@ +import request from '@/utils/request' + +/* 下拉等公共接口 */ + +// 获取设备类型 +export const getDeviceTypeAPI = () => { + return request({ + url: '/smart-site/devType/querySelected', + method: 'post', + }) +} +// 获取监测区域 +export const getMonitoringAreaAPI = (data) => { + return request({ + url: '/smart-site/constInfo/querySelected', + method: 'post', + data, + }) +} +// 获取所属边代 +export const getBelongToBdAPI = () => { + return request({ + url: '/smart-site/collect/dev/queryBdSelected', + method: 'post', + }) +} diff --git a/src/api/high-formwork/index.js b/src/api/high-formwork/index.js index bdf21b66..238ab0a9 100644 --- a/src/api/high-formwork/index.js +++ b/src/api/high-formwork/index.js @@ -20,3 +20,18 @@ export const editHighFormworkDataAPI = (data) => { export const deleteHighFormworkDataAPI = (data) => { return request.post('/smart-site/devModel/deleteData', data) } + +// 弹框内设备绑定数据接口 +export const getHighFormworkListInDeviceAPI = (data) => { + return request.get('/smart-site/devModel/getDevList', { + params: data, + }) +} +// 弹框内设备绑定接口 +export const bindHighFormworkListInDeviceAPI = (data) => { + return request.post('/smart-site/devModel/bindDevice', data) +} +// 弹框内设备解绑接口 +export const unBindHighFormworkListInDeviceAPI = (data) => { + return request.post('/smart-site/devModel/unBindDev', data) +} diff --git a/src/api/perception-devices/equipment-manage.js b/src/api/perception-devices/equipment-manage.js index d5829e76..adfaf229 100644 --- a/src/api/perception-devices/equipment-manage.js +++ b/src/api/perception-devices/equipment-manage.js @@ -1,18 +1,21 @@ import request from '@/utils/request' +import requestNew from '@/utils/request-new' /* 感知设备 ---- 设备管理接口 */ // 列表接口 export const getEquipmentManageListAPI = (data) => { - return request.get('/smart-site/collect/dev/getPageList', data) + return request.get('/smart-site/collect/dev/getPageList', { + params: data, + }) } // 新增接口 export const addEquipmentManageDataAPI = (data) => { - return request.post('/smart-site/collect/dev/insertData', data) + return requestNew.post('/smart-site/collect/dev/insertData', data) } // 修改接口 export const editEquipmentManageDataAPI = (data) => { - return request.post('/xxx', data) + return requestNew.post('/smart-site/collect/dev/updateData', data) } // 详情接口 export const getEquipmentManageDetailsAPI = (data) => { @@ -20,21 +23,23 @@ export const getEquipmentManageDetailsAPI = (data) => { } // 删除接口 export const deleteEquipmentManageDataAPI = (data) => { - return request.post('/xxx', data) + return request.post('/smart-site/collect/dev/delData', data) } // 详情内列表接口 export const getEquipmentManageListInDetailsAPI = (data) => { - return request.post('/xxx', data) + return request.get('/smart-site/collect/dev/getAttrPageList', { + params: data, + }) } // 详情内新增接口 export const addEquipmentManageDataInDetailsAPI = (data) => { - return request.post('/xxx', data) + return request.post('/smart-site/collect/dev/addAttrData', data) } // 详情内修改接口 export const editEquipmentManageDataInDetailsAPI = (data) => { - return request.post('/xxx', data) + return request.post('/smart-site/collect/dev/updateAttrData', data) } // 详情内删除接口 export const deleteEquipmentManageDataInDetailsAPI = (data) => { - return request.post('/xxx', data) + return request.post('/smart-site/collect/dev/delDataAttr', data) } diff --git a/src/components/DialogModel/index.vue b/src/components/DialogModel/index.vue index e2c6c280..c6685143 100644 --- a/src/components/DialogModel/index.vue +++ b/src/components/DialogModel/index.vue @@ -64,12 +64,10 @@ export default { left: 50% !important; transform: translate(-50%, -50%) !important; max-height: 100vh !important; + min-height: 100vh; .el-dialog__body { flex: 1; overflow-y: scroll !important; - .el-table__header-wrapper .el-checkbox { - display: none !important; - } } .dialog-content { padding: 20px; diff --git a/src/components/TableModel/index.vue b/src/components/TableModel/index.vue index b6977fe1..48ceb866 100644 --- a/src/components/TableModel/index.vue +++ b/src/components/TableModel/index.vue @@ -114,7 +114,13 @@ @selection-change="handleSelectionChange" > > - + - + 新增 @@ -21,20 +27,18 @@ - - - - - - - - - + + + + + + + 取消 - 确认绑定 + 确认绑定 @@ -47,7 +51,18 @@ import DialogModel from '@/components/DialogModel' import { formLabel, columnsList, dialogConfig } from './config' import { getProjectListAPI } from '@/api/project-manage/index.js' +import { + getHighFormworkListInDeviceAPI, + bindHighFormworkListInDeviceAPI, + unBindHighFormworkListInDeviceAPI, +} from '@/api/high-formwork/index.js' export default { + props: { + detailsId: { + type: [Number, String], + default: () => '', + }, + }, components: { TableModel, DialogModel, @@ -57,7 +72,7 @@ export default { formLabel, columnsList, dialogConfig, - getProjectListAPI, + getHighFormworkListInDeviceAPI, dialogType: 1, // 新增或修改接口 addOrEditForm: { @@ -81,6 +96,11 @@ export default { }, ], }, + sendParams: { + id: '', + }, + deviceList: [], + selectionList: [], } }, methods: { @@ -89,6 +109,10 @@ export default { 1: '新增', 2: '修改', } + + if (type === 1) { + this.getHighFormworkListInDeviceData() + } this.dialogType = type this.dialogConfig.outerTitle = titleType[type] this.dialogConfig.outerVisible = true @@ -97,13 +121,26 @@ export default { this.$modal .confirm(`是否确认解绑设备`) .then(async () => { - this.$refs.tableRef.getTableList() + const res = await unBindHighFormworkListInDeviceAPI({ + id: this.detailsId, + devId: data.id, + }) + + if (res.code === 200) { + this.$modal.msgSuccess('解绑成功') + this.$refs.tableRef.getTableList() + } }) .catch(() => {}) }, + + // 获取绑定的数据源 + async getHighFormworkListInDeviceData() { + const res = await getHighFormworkListInDeviceAPI() + this.deviceList = res.rows + }, /** 关闭外侧弹框 */ closeDialogOuter() { - this.$refs.addOrEditFormRef.resetFields() this.dialogConfig.outerVisible = false }, @@ -116,11 +153,51 @@ export default { }) }, + // 确认绑定 + async onHandleBind() { + if (this.selectionList.length < 1) { + this.$modal.msgError('请勾选需要绑定的数据') + } else { + const bingParams = { + id: this.detailsId, + devId: this.selectionList.join(',').slice(0, -1), + } + + const res = await bindHighFormworkListInDeviceAPI(bingParams) + + if (res.code === 200) { + this.$modal.msgSuccess('绑定成功') + this.dialogConfig.outerVisible = false + this.$refs.tableRef.getTableList() + } + + console.log('res', res) + } + }, + // 取消按钮 onCancel() { this.$refs.addOrEditFormRef.resetFields() this.dialogConfig.outerVisible = false }, + + // 列表勾选事件 + handleSelectionChange(val) { + console.log(val) + if (val.length > 0) { + this.selectionList = val.map((e) => e.id) + } + }, + }, + + watch: { + detailsId: { + handler(newValue) { + this.sendParams.id = newValue + }, + deep: true, + immediate: true, + }, }, } diff --git a/src/views/high-formwork/index.vue b/src/views/high-formwork/index.vue index ee8e17a3..dbf4ff77 100644 --- a/src/views/high-formwork/index.vue +++ b/src/views/high-formwork/index.vue @@ -48,7 +48,7 @@ v-if="dialogType === 1 || dialogType === 2" /> - + @@ -76,6 +76,7 @@ export default { dialogType: 1, getHighFormworkListAPI, editFormModel: null, + detailsId: '', } }, methods: { @@ -91,6 +92,7 @@ export default { } if (type === 3) { + this.detailsId = data.id this.dialogConfig.outerWidth = '90%' } else { this.dialogConfig.outerWidth = '50%' diff --git a/src/views/perception-devices/equipment-manage/components/add-edit-form.vue b/src/views/perception-devices/equipment-manage/components/add-edit-form.vue index 05737e2f..ffa03b90 100644 --- a/src/views/perception-devices/equipment-manage/components/add-edit-form.vue +++ b/src/views/perception-devices/equipment-manage/components/add-edit-form.vue @@ -1,15 +1,21 @@ - + - - + + @@ -17,31 +23,82 @@ - - + + - - + + + + + - - + + - + - - + + - - - - + + + + + + + 1、上传图片文件格式支持PNG、JPG、JPEG; + 2、图片大小不超过10MB; + + + + + + - - + + + + + + + + + + @@ -49,55 +106,65 @@ 保存 + + + + - + diff --git a/src/views/perception-devices/equipment-manage/components/config.js b/src/views/perception-devices/equipment-manage/components/config.js index 2d4f5db7..47127842 100644 --- a/src/views/perception-devices/equipment-manage/components/config.js +++ b/src/views/perception-devices/equipment-manage/components/config.js @@ -1,14 +1,11 @@ -export const formLabel = [{ f_label: '搜索关键词', f_model: 'proName', f_type: 'ipt', isShow: false }] +export const formLabel = [{ f_label: '搜索关键词', f_model: 'keyWord', f_type: 'ipt', isShow: false }] export const columnsList = [ - { t_props: 'projectName', t_label: '监测名称' }, - { t_props: 'address', t_label: '监测值' }, - { t_props: 'planStartTime', t_label: '单位' }, - { t_props: 'planEndTime', t_label: '监测时间' }, - { t_props: 'ownerUnit', t_label: '变化值' }, - { t_props: 'projectStatus', t_label: '最大阈值' }, - { t_props: 'auditStatus', t_label: '最小阈值' }, - { t_props: 'auditStatus', t_label: '采集值类型' }, - { t_props: 'auditStatus', t_label: '设备级联编码' }, + { t_props: 'attrName', t_label: '监测名称' }, + { t_props: 'attrVal', t_label: '监测值' }, + { t_props: 'unit', t_label: '单位' }, + { t_props: 'dataType', t_label: '采集值类型' }, + { t_props: 'attrCode', t_label: '编码' }, + { t_props: 'updateTime', t_label: '监测时间', t_width: 180 }, ] export const dialogConfig = { diff --git a/src/views/perception-devices/equipment-manage/components/project-details.vue b/src/views/perception-devices/equipment-manage/components/project-details.vue index 39c48429..029976ee 100644 --- a/src/views/perception-devices/equipment-manage/components/project-details.vue +++ b/src/views/perception-devices/equipment-manage/components/project-details.vue @@ -1,7 +1,14 @@ - + 新增 @@ -25,44 +32,52 @@ - - + + - - - - + + + + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + + @@ -80,8 +95,19 @@ import TableModel from '@/components/TableModel' import DialogModel from '@/components/DialogModel' import { formLabel, columnsList, dialogConfig } from './config' -import { getProjectListAPI } from '@/api/project-manage/index.js' +import { + getEquipmentManageListInDetailsAPI, + addEquipmentManageDataInDetailsAPI, + editEquipmentManageDataInDetailsAPI, + deleteEquipmentManageDataInDetailsAPI, +} from '@/api/perception-devices/equipment-manage.js' export default { + props: { + detailsId: { + type: [Number, String], + default: () => '', + }, + }, components: { TableModel, DialogModel, @@ -91,29 +117,44 @@ export default { formLabel, columnsList, dialogConfig, - getProjectListAPI, + getEquipmentManageListInDetailsAPI, dialogType: 1, // 新增或修改接口 addOrEditForm: { - jc_name: '', // 监测名称 - createTime: '', // 创建时间 - cj_data: '', //采集值 - cj_type: '', // 采集值类型 - cj_unit: '', // 采集值单位 - is_warning: '', // 是否告警 - change_data: '', // 变化值 - max_data: '', // 最大阈值 - min_data: '', // 最小阈值 - code: '', // 设备级联编码 + devId: '', // 外层列表id + attrName: '', // 监测名称 + updateTime: '', // 创建时间 + attrVal: '', //采集值 + dataType: '', // 采集值类型 + unit: '', // 采集值单位 + isWarn: '', // 是否告警 + changeVal: '', // 变化值 + maxVal: '', // 最大阈值 + minVal: '', // 最小阈值 + attrCode: '', // 设备级联编码 + remark: '', // 备注 + attrId: '', }, addOrEditFormRules: { - jc_name: [ + attrName: [ { required: true, message: '请输入监测名称', trigger: 'blur', }, ], + attrCode: [ + { + required: true, + message: '请输入编码', + trigger: 'blur', + }, + ], + }, + + // 列表查询参数 + sendParams: { + devId: '', }, } }, @@ -123,15 +164,69 @@ export default { 1: '新增', 2: '修改', } + + if (type === 2) { + const { + devId, // 外层列表id + attrName, // 监测名称 + updateTime, // 创建时间 + attrVal, //采集值 + dataType, // 采集值类型 + unit, // 采集值单位 + isWarn, // 是否告警 + changeVal, // 变化值 + maxVal, // 最大阈值 + minVal, // 最小阈值 + attrCode, // 设备级联编码 + remark, // 备注 + attrId, // 列表id + } = data + + Object.assign(this.addOrEditForm, { + devId, // 外层列表id + attrName, // 监测名称 + updateTime, // 创建时间 + attrVal, //采集值 + dataType, // 采集值类型 + unit, // 采集值单位 + isWarn, // 是否告警 + changeVal, // 变化值 + maxVal, // 最大阈值 + minVal, // 最小阈值 + attrCode, // 设备级联编码 + remark, // 备注 + attrId, // 列表id + }) + } else { + this.addOrEditForm = { + devId: '', // 外层列表id + attrName: '', // 监测名称 + updateTime: '', // 创建时间 + attrVal: '', //采集值 + dataType: '', // 采集值类型 + unit: '', // 采集值单位 + isWarn: '', // 是否告警 + changeVal: '', // 变化值 + maxVal: '', // 最大阈值 + minVal: '', // 最小阈值 + attrCode: '', // 设备级联编码 + remark: '', // 备注 + attrId: '', + } + } this.dialogType = type - this.dialogConfig.outerTitle = titleType[type] this.dialogConfig.outerVisible = true + this.dialogConfig.outerTitle = titleType[type] }, handleDeleteData(data) { this.$modal .confirm(`是否确认删除该条数据`) .then(async () => { - this.$refs.tableRef.getTableList() + const res = await deleteEquipmentManageDataInDetailsAPI({ attrId: data.attrId }) + if (res.code === 200) { + this.$modal.msgSuccess('删除成功') + this.$refs.tableRef.getTableList() + } }) .catch(() => {}) }, @@ -145,6 +240,61 @@ export default { onSubmitForm() { this.$refs.addOrEditFormRef.validate(async (valid) => { if (valid) { + // this.dialogConfig.outerVisible = false + + const { + devId, // 外层列表id + attrName, // 监测名称 + updateTime, // 创建时间 + attrVal, //采集值 + dataType, // 采集值类型 + unit, // 采集值单位 + isWarn, // 是否告警 + changeVal, // 变化值 + maxVal, // 最大阈值 + minVal, // 最小阈值 + attrCode, // 设备级联编码 + remark, // 备注 + attrId, + } = this.addOrEditForm + const params = { + devId, // 外层列表id + attrName, // 监测名称 + updateTime, // 创建时间 + attrVal, //采集值 + dataType, // 采集值类型 + unit, // 采集值单位 + isWarn, // 是否告警 + changeVal, // 变化值 + maxVal, // 最大阈值 + minVal, // 最小阈值 + attrCode, // 设备级联编码 + remark, // 备注 + } + + // 当修改表单时需要传递列表id + if (this.dialogType === 2) { + params.attrId = attrId + } + + params.devId = this.detailsId + console.log( + `%c🔍 感知设备详情属性${this.dialogType === 1 ? '新增' : '修改'}入参 %c`, + 'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;', + '', + params, + ) + + const API = + this.dialogType === 1 ? addEquipmentManageDataInDetailsAPI : editEquipmentManageDataInDetailsAPI + + const res = await API(params) + + if (res.code === 200) { + this.$modal.msgSuccess(this.dialogType === 1 ? '新增成功' : '修改成功') + this.$refs.tableRef.getTableList() + } + this.$refs.addOrEditFormRef.resetFields() this.dialogConfig.outerVisible = false } }) @@ -156,6 +306,16 @@ export default { this.dialogConfig.outerVisible = false }, }, + + watch: { + detailsId: { + handler(newValue) { + this.sendParams.devId = newValue + }, + deep: true, + immediate: true, + }, + }, } diff --git a/src/views/perception-devices/equipment-manage/config.js b/src/views/perception-devices/equipment-manage/config.js index eabb89ed..c107ad80 100644 --- a/src/views/perception-devices/equipment-manage/config.js +++ b/src/views/perception-devices/equipment-manage/config.js @@ -7,13 +7,11 @@ export const columnsList = [ // { t_props: 'projectName', t_label: '所属工程' }, { t_props: 'devType', t_label: '设备类型' }, { t_props: 'devCode', t_label: '设备编码' }, - { t_props: 'typeName', t_label: '设备名称' }, - { t_props: 'typeCode', t_label: '设备级联编码' }, - { t_props: 'isOnline', t_label: '设备状态', t_slot: 'status' }, - { t_props: 'auditStatus', t_label: '设备信号' }, - { t_props: 'bdName', t_label: '所属边带' }, - { t_props: 'auditStatus', t_label: '监测区域' }, - { t_props: 'auditStatus', t_label: '备注' }, + { t_props: 'devName', t_label: '设备名称' }, + { t_props: 'isActive', t_label: '是否启用', t_slot: 'isActive' }, + { t_props: 'isOnline', t_label: '在线状态', t_slot: 'isOnline' }, + { t_props: 'constName', t_label: '监测区域' }, + { t_props: 'remark', t_label: '备注' }, ] export const dialogConfig = { diff --git a/src/views/perception-devices/equipment-manage/index.vue b/src/views/perception-devices/equipment-manage/index.vue index c62ef0f5..a35cf4f6 100644 --- a/src/views/perception-devices/equipment-manage/index.vue +++ b/src/views/perception-devices/equipment-manage/index.vue @@ -25,8 +25,13 @@ - - 状态 + + 启用 + 禁用 + + + 在线 + 离线 @@ -34,9 +39,14 @@ - + - + @@ -48,9 +58,7 @@ import DialogModel from '@/components/DialogModel' import AddEditForm from './components/add-edit-form' import ProjectDetails from './components/project-details' import { formLabel, columnsList, dialogConfig } from './config' -import { getProjectListAPI } from '@/api/project-manage/index.js' - -import { getEquipmentManageListAPI } from '@/api/perception-devices/equipment-manage.js' +import { getEquipmentManageListAPI, deleteEquipmentManageDataAPI } from '@/api/perception-devices/equipment-manage.js' export default { components: { TableModel, @@ -66,6 +74,10 @@ export default { // getProjectListAPI, getEquipmentManageListAPI, dialogType: 1, + + // 修改时数据源 + editFormModel: null, + detailsId: '', } }, methods: { @@ -79,26 +91,70 @@ export default { 2: '设备修改', 3: '设备详情列表', } - this.dialogType = type - this.dialogConfig.outerTitle = titleType[type] - this.dialogConfig.outerVisible = true if (type === 3) { this.dialogConfig.outerWidth = '90%' + this.detailsId = data.id } else { this.dialogConfig.outerWidth = '50%' } + + if (type === 2) { + const { + typeId, // 设备类型 + devName, //设备名称 + devCode, // 设备编码 + isActive, // 是否启用 + isOnline, // 设备状态 + devLocation, // 位置 + constId, // 监测区域 + bdId, // 所属边带 + backImage, // 背景 + remark, // 描述 + configData, // 配置 + id, + } = data + + this.editFormModel = { + typeId, // 设备类型 + devName, //设备名称 + devCode, // 设备编码 + isActive, // 是否启用 + isOnline, // 设备状态 + devLocation, // 位置 + constId, // 监测区域 + bdId, // 所属边带 + backImage, // 背景 + remark, // 描述 + configData, // 配置 + id, + } + } else { + this.editFormModel = null + } + + this.dialogType = type + this.dialogConfig.outerTitle = titleType[type] + this.dialogConfig.outerVisible = true }, handleDeleteData(data) { this.$modal .confirm(`是否确认删除该条数据`) .then(async () => { - this.$refs.tableRef.getTableList() + const res = await deleteEquipmentManageDataAPI({ id: data.id }) + if (res.code === 200) { + this.$modal.msgSuccess('删除成功') + this.$refs.tableRef.getTableList() + } }) .catch(() => {}) }, /** 关闭外侧弹框 */ - closeDialogOuter() { + closeDialogOuter(isChange) { + // isChange 判断是否触发修改或者新增逻辑 + if (isChange) { + this.$refs.tableRef.getTableList() + } this.dialogConfig.outerVisible = false }, },