From 480a92f43a3723100627753aa89162a4b3dd8ac3 Mon Sep 17 00:00:00 2001 From: jjLv <1981429112@qq.com> Date: Thu, 19 Sep 2024 10:03:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/base/device.js | 30 ++-- src/api/base/edgeDevice.js | 12 ++ .../base/device/components/form-device.vue | 156 ++++++++---------- src/views/base/device/config.js | 25 ++- src/views/base/device/index.vue | 52 +++++- src/views/base/edgeDeviceManage/config.js | 18 ++ src/views/base/edgeDeviceManage/index.vue | 47 ++++++ 7 files changed, 234 insertions(+), 106 deletions(-) create mode 100644 src/api/base/edgeDevice.js create mode 100644 src/views/base/edgeDeviceManage/config.js create mode 100644 src/views/base/edgeDeviceManage/index.vue diff --git a/src/api/base/device.js b/src/api/base/device.js index d56c79d..02fe38b 100644 --- a/src/api/base/device.js +++ b/src/api/base/device.js @@ -10,35 +10,35 @@ export const queryDeviceListApi = (data) => { }) } -/** 项目部名称查询 */ -export const queryProjDeptNameApi = (data) => { - return request.get('/base/tbProDepart/getList', { +/** 设备类型查询 */ +export const queryDeviceTypeApi = (data) => { + return request.get('/base/tbDevice/getDeviceTypeList', { params: data }) } -/** 项目部类型查询 */ -export const queryProjDeptTypeApi = (data) => { - return request.get('/base/tbProDepart/getDataList', { +/** 所属边带查询 */ +export const queryBdIdApi = (data) => { + return request.get('/base/tbDevice/getBdIdList', { params: data }) } -/** 各省份查询 */ -export const queryProvincesApi = (data) => { - return request.get('/base/tbProDepart/getAreaList', { +/** 预警配置查询 */ +export const queryConfigApi = (data) => { + return request.get('/base/tbDevice/getConfigList', { params: data }) } -/** 新增项目部 */ -export const addProjDeptApi = (data) => { - return request.post('/base/tbProDepart', data) +/** 新增设备 */ +export const addDeviceApi = (data) => { + return request.post('/base/tbDevice', data) } -/** 修改项目部 */ -export const editProjDeptApi = (data) => { - return request.put('/base/tbProDepart', data) +/** 修改设备 */ +export const editDeviceApi = (data) => { + return request.put('/base/tbDevice', data) } /** 删除设备 */ diff --git a/src/api/base/edgeDevice.js b/src/api/base/edgeDevice.js new file mode 100644 index 0000000..eed9dc3 --- /dev/null +++ b/src/api/base/edgeDevice.js @@ -0,0 +1,12 @@ +/** + * 边代设备管理页面 API + */ +import request from '@/utils/request' +/** 边代设备列表查询 */ +export const queryEdgeDeviceListApiTwo = (data) => { + return request.get('/base/tbBdRecord/listTwo', { + params: data + }) +} + + diff --git a/src/views/base/device/components/form-device.vue b/src/views/base/device/components/form-device.vue index 0909b8a..da42621 100644 --- a/src/views/base/device/components/form-device.vue +++ b/src/views/base/device/components/form-device.vue @@ -4,66 +4,67 @@ - + - + + + + + + + + - + + - - - - - - - - - + 确认 import { - queryProvincesApi, - queryProjDeptTypeApi, - queryProjDeptNameApi, - addProjDeptApi, - editProjDeptApi -} from '@/api/base/projDept' + queryDeviceTypeApi, + queryBdIdApi, + queryConfigApi, + addDeviceApi, + editDeviceApi +} from '@/api/base/device' export default { name: 'FormDevice', props: { @@ -102,7 +103,7 @@ export default { mounted() { console.log(this.editParams) if (this.editParams) { - Object.assign(this.projectParams, this.editParams) + Object.assign(this.deviceParams, this.editParams) this.subSort = 2 } else { this.subSort = 1 @@ -111,20 +112,21 @@ export default { data() { return { subSort: '', // 提交类型:新增 1 / 修改 2 - projectParams: { + deviceParams: { + // devId: undefined, // 设备id devType: undefined, //设备类型 devName: undefined, //设备名称 devCode: undefined, // 设备编码 - bdId: undefined, // 所属边代 + bdId: undefined, // 所属边带 configId: undefined, //预警配置 }, // 校验规则 - projectParamsRules: { + deviceParamsRules: { devType: [ { required: true, message: '请选择设备类型', - trigger: 'blur', + trigger: 'change', }, ], devName: [ @@ -144,15 +146,15 @@ export default { bdId: [ { required: true, - message: '请选择所属边代', - trigger: 'blur', + message: '请选择所属边带', + trigger: 'change', }, ], configId: [ { required: true, message: '请选择预警配置', - trigger: 'blur', + trigger: 'change', }, ], }, @@ -163,35 +165,28 @@ export default { methods: { /** 获取各类下拉框 */ async getRanges() { - // 获取省份下拉选 - let provinceRes = await queryProvincesApi() - this.provinceRange = provinceRes.data.map(item => { + // 获取设备类型下拉选 + let deviceTypeRes = await queryDeviceTypeApi() + this.deviceTypeRange = deviceTypeRes.data.map(item => { return { - label: item.areaName, - value: item.areaId + label: item.devName, + value: item.devId } }) - // 获取项目部类型下拉选 - let typeRes = await queryProjDeptTypeApi({ - dictType: 'depar_type' - }) - this.typeRange = typeRes.data.map(item => { + // 获取所属边带下拉选 + let bdIdRes = await queryBdIdApi() + this.bdIdRange = bdIdRes.data.map(item => { return { - label: item.dictLabel, - value: item.dictCode + label: item.bdName, + value: item.bdId } }) - // 获取项目部名称下拉选 - let projRes = await queryProjDeptNameApi() - this.projRange = projRes.data.map(item => { + // 获取预警配置下拉选 + let configRes = await queryConfigApi() + this.configRange = configRes.data.map(item => { return { - label: item.departName, - value: item.departName, - departType: item.departType, - areaName: item.areaName, - headUser: item.headUser, - headUserPhone: item.headUserPhone, - remarks: item.remarks, + label: item.configName, + value: item.configId, } }) }, @@ -205,36 +200,29 @@ export default { }) return leaf }, - /** 项目部名称改变 */ - departNameChange(e) { - this.projRange.forEach(item => { - if(e === item.label) { - this.projectParams.departType = item.departType - this.projectParams.areaId = item.areaId - this.projectParams.headUser = item.headUser - this.projectParams.headUserPhone = item.headUserPhone - this.projectParams.remarks = item.remarks - } - }) - }, + // /** 项目部名称改变 */ + // departNameChange(e) { + // this.projRange.forEach(item => { + // if(e === item.label) { + // this.deviceParams.departType = item.departType + // this.deviceParams.areaId = item.areaId + // this.deviceParams.headUser = item.headUser + // this.deviceParams.headUserPhone = item.headUserPhone + // this.deviceParams.remarks = item.remarks + // } + // }) + // }, /** 级联选择器改变 */ handleCas(e) { - this.projectParams.impUnit = e[e.length - 1] + this.deviceParams.impUnit = e[e.length - 1] }, /** 确认按钮 */ onSubmit() { - this.$refs.projectParamsRef.validate(valid => { + this.$refs.deviceParamsRef.validate(valid => { if (valid) { - if(this.projectParams.headUserPhone !== undefined && this.projectParams.headUserPhone !== "" && this.projectParams.headUserPhone !== null) { - if(!this.phoneReg.test(this.projectParams.headUserPhone)) { - this.$modal.msgError('请填写正确的联系方式') - return false - } - } - console.log('校验通过', this.projectParams, this.subSort) // 1. 表单校验通过后调后台 Api if(this.subSort === 1) { - addProjDeptApi(this.projectParams).then(res => { + addDeviceApi(this.deviceParams).then(res => { this.$modal.msgSuccess('操作成功') // 2. 成功之后通知父组件关闭弹框 this.$emit('closeDialog', true) @@ -242,7 +230,7 @@ export default { console.log(err) }) } else if(this.subSort === 2) { - editProjDeptApi(this.projectParams).then(res => { + editDeviceApi(this.deviceParams).then(res => { this.$modal.msgSuccess('操作成功') // 2. 成功之后通知父组件关闭弹框 this.$emit('closeDialog', true) diff --git a/src/views/base/device/config.js b/src/views/base/device/config.js index 3917ed4..7a89ea5 100644 --- a/src/views/base/device/config.js +++ b/src/views/base/device/config.js @@ -1,8 +1,25 @@ +import { + queryDeviceTypeApi + } from '@/api/base/device' + + export const queryDeviceTypes = () => { + queryDeviceTypeApi().then(res => { + formLabel[0].f_selList = res.data.map(item => { + return { + label: item.deviceName, + value: item.deviceId + } + }) + }).catch(err => {}) + } export const formLabel = [ - { f_label: '设备类型', f_model: 'devType', f_type: 'ipt', }, + { f_label: '设备类型', f_model: 'devType', f_type: 'sel',f_selList: [] }, { f_label: '设备名称', f_model: 'devName', f_type: 'ipt' }, { f_label: '设备编码', f_model: 'devCode', f_type: 'ipt' }, - { f_label: '设备状态', f_model: 'devStatus', f_type: 'ipt' }, + { f_label: '设备状态', f_model: 'devStatus', f_type: 'sel',f_selList: [ + { label: '在用', value: '0' }, + { label: '未用', value: '1' }, + ] }, ] export const columnsList = [ @@ -10,8 +27,8 @@ export const columnsList = [ { t_props: 'devCode', t_label: '设备编码' }, { t_props: 'devName', t_label: '设备名称' }, { t_props: 'bdId', t_label: '所属边代设备', }, - { t_props: 'configId', t_label: '预警配置', }, - { t_props: 'devStatus', t_label: '设备状态', }, + { t_props: 'configId', t_label: '预警配置',t_slot: 'configId' }, + { t_props: 'devStatus', t_label: '设备状态', t_slot: 'devStatus'}, ] export const dialogConfig = { diff --git a/src/views/base/device/index.vue b/src/views/base/device/index.vue index 9003799..79f73dd 100644 --- a/src/views/base/device/index.vue +++ b/src/views/base/device/index.vue @@ -42,6 +42,27 @@ + + + + @@ -61,7 +82,7 @@