From 8d7216a6c883be4710e388f5ec6622b9f46fb371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8F=AC=E9=9B=AA?= <1637048769@qq.com> Date: Mon, 23 Nov 2020 13:27:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/hardware/deviceNode.js | 47 ++++++ src/api/hardware/node.js | 2 +- src/api/hardware/productNode.js | 47 ++++++ src/views/hardware/deviceList/index.vue | 186 ++++++++++++++++++++++- src/views/hardware/productList/index.vue | 15 +- 5 files changed, 282 insertions(+), 15 deletions(-) create mode 100644 src/api/hardware/deviceNode.js create mode 100644 src/api/hardware/productNode.js diff --git a/src/api/hardware/deviceNode.js b/src/api/hardware/deviceNode.js new file mode 100644 index 0000000..7a9a7c2 --- /dev/null +++ b/src/api/hardware/deviceNode.js @@ -0,0 +1,47 @@ +import request from '@/utils/request' + +// 获取设备节点列表 +export function deviceNodeList (params) { + return request({ + url: '/system/device/node/list', + method: 'get', + params + }) +} + +// 新增节点 +export function deviceNodeSave (data) { + return request({ + url: '/system/device/node/save', + method: 'post', + data + }) +} + +/** + * 查询设备节点详细 + * @param {*} nodeId + */ +export function deviceNodeInfo (nodeId) { + return request({ + url: '/system/device/node/' + nodeId, + method: 'get' + }) +} + +// 删除节点 +export function deviceNodeDel (ids) { + return request({ + url: '/system/device/node/' + ids, + method: 'delete' + }) +} + +// 获取节点下拉 +export function deviceNodeSelect (params) { + return request({ + url: '/system/device/node/select', + method: 'get', + params + }) +} diff --git a/src/api/hardware/node.js b/src/api/hardware/node.js index ccf659e..3692d1e 100644 --- a/src/api/hardware/node.js +++ b/src/api/hardware/node.js @@ -3,7 +3,7 @@ import request from '@/utils/request' // 获取节点列表 export function nodeList (params) { return request({ - url: '/system/node/list', + url: '/system/product/node/list', method: 'get', params }) diff --git a/src/api/hardware/productNode.js b/src/api/hardware/productNode.js new file mode 100644 index 0000000..f416a75 --- /dev/null +++ b/src/api/hardware/productNode.js @@ -0,0 +1,47 @@ +import request from '@/utils/request' + +// 获取产品节点列表 +export function productNodeList (params) { + return request({ + url: '/system/product/node/list', + method: 'get', + params + }) +} + +/** + * 查询产品节点详细 + * @param { Object } params + */ + +export function productNodeInfo (nodeId) { + return request({ + url: '/system/product/node/' + nodeId, + method: 'get' + }) +} + +export function productNodeSelect (params) { + return request({ + url: '/system/product/node/select', + method: 'get', + params + }) +} + +// 新增节点 +export function productNodeAdd (data) { + return request({ + url: '/system/product/node/save', + method: 'post', + data + }) +} + +// 删除节点 +export function productNodeDel (ids) { + return request({ + url: '/system/product/node/' + ids, + method: 'delete' + }) +} diff --git a/src/views/hardware/deviceList/index.vue b/src/views/hardware/deviceList/index.vue index 0b267ae..4969d33 100644 --- a/src/views/hardware/deviceList/index.vue +++ b/src/views/hardware/deviceList/index.vue @@ -57,8 +57,12 @@ @@ -128,6 +132,46 @@ 取 消 + + + + + 批量删除 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -140,10 +184,14 @@ import { update, del, } from "@/api/hardware/device"; +// import { nodeList, addNode, nodeInfo, delNode, nodeSelect } from "@/api/system/device/node"; import { select as productSelect } from "@/api/hardware/product"; import { select as projectSelect } from "@/api/hardware/project"; import { userSelect } from "@/api/system/user"; import { list as provinceList, getProvinceByParent } from "@/api/hardware/province"; +import { productNodeList, productNodeSelect } from "@/api/hardware/productNode"; +import { deviceNodeList, deviceNodeSave, deviceNodeInfo, deviceNodeDel, deviceNodeSelect } from "@/api/hardware/deviceNode"; + export default { name: "DeviceList", components: { @@ -159,6 +207,7 @@ export default { // }, data () { return { + snapDeviceInfo: {}, // 产品下拉列表 productSelectList: [], userSelectList: [], @@ -166,12 +215,15 @@ export default { provinceSelectList: [], citySelectList: [], districtSelectList: [], + productNodeSelectList: [], // 选中数组 ids: [], + nodeIds: [], // 非单个禁用 single: true, // 非多个禁用 multiple: true, + nodeMultiple: true, // 显示搜索条件 showSearch: true, // 总条数 @@ -180,10 +232,14 @@ export default { title: "", // 是否显示弹出层 open: false, + nodeDialog: false, + nodeOpen:false, // 表单参数 form: {}, + nodeForm: {}, // 表格数据 tableData: null, + nodeData: null, // 查询参数 queryParams: { pageNum: 1, @@ -218,6 +274,17 @@ export default { { required: true, message: "区不能为空", trigger: "blur" }, ], }, + nodeRules: { + nodeId: [ + { required: true, message: "节点SN不能为空", trigger: "blur" }, + ], + deviceId: [ + { required: true, message: "设备ID不能为空", trigger: "blur" }, + ], + nodeDataId: [ + { required: true, message: "节点真正ID不能为空", trigger: "blur" }, + ], + } }; }, created () { @@ -262,14 +329,14 @@ export default { } }) }, - getProvinceByParent(id) { + getProvinceByParent (id) { return new Promise((resolve, reject) => { getProvinceByParent(id).then(({ code, msg, data }) => { if (code == 200) { resolve(data); } else { this.$message.error(msg); - reject({msg, code}) + reject({ msg, code }) } }).catch(error => { reject(error) @@ -304,10 +371,18 @@ export default { }); }, + // 获取节点数据列表 + getListnode ({ deviceId }) { + deviceNodeList({ deviceId }).then((response) => { + this.nodeData = response.rows; + }); + }, + // 取消按钮 cancel () { this.open = false; - // this.reset(); + this.nodeOpen = false; + this.reset(); }, // 表单重置 @@ -318,7 +393,13 @@ export default { deviceName: "", status: "0", }; + this.nodeForm = { + nodeId: "", + deviceId: "", + nodeDataId: "", + }; this.resetForm("form"); + this.resetForm("nodeForm"); }, // 多选框选中数据 @@ -328,6 +409,12 @@ export default { this.multiple = !selection.length; }, + // nodeHandleSelectionChange(){}, + nodeHandleSelectionChange (selection) { + this.nodeIds = selection.map((item) => item.id); + this.nodeMultiple = !selection.length; + }, + /** 新增按钮操作 */ handleAdd () { this.reset(); @@ -335,10 +422,32 @@ export default { this.title = "添加设备"; }, + // 新增节点 + handleAddnode (row) { + productNodeSelect({productId: row.productId}).then(({ code, msg, select }) => { + if (code == 200) { + this.productNodeSelectList = select; + } else { + this.$message.error(msg); + } + }) + this.reset(); + this.nodeOpen = true; + this.title = "添加设备节点"; + this.nodeForm.deviceId = row.deviceId; + }, + + // 查看节点 + handleview (row) { + this.nodeDialog = true; + this.snapDeviceInfo = row; + this.getListnode(row) + }, + /** 修改按钮操作 */ handleUpdate (row) { this.reset(); - info(row.id).then( ({ code, info, msg }) => { + info(row.id).then(({ code, info, msg }) => { if (200 == code) { this.provinceCodeChange(info.proCode); this.cityCodeChange(info.cityCode); @@ -350,6 +459,21 @@ export default { } }) }, + + /** 修改节点 */ + handleUpdatenode(row){ + this.reset(); + productNodeSelect({productId: this.snapDeviceInfo.productId}).then(({ code, msg, select }) => { + if (code == 200) { + this.productNodeSelectList = select; + } else { + this.$message.error(msg); + } + }) + this.nodeOpen = true; + this.title = "修改设备节点"; + this.nodeForm = row; + }, /** 提交按钮 */ submitForm: function () { this.$refs["form"].validate((valid) => { @@ -381,6 +505,19 @@ export default { }); }, + // 节点提交 + saveNode: function () { + deviceNodeSave(this.nodeForm).then((res) => { + if (200 == res.code) { + this.msgSuccess(this.title + "成功"); + this.nodeOpen = false; + this.getList(); + } else { + this.msgSuccess(res.msg); + } + }); + }, + /** 删除按钮操作 */ handleDelete (row) { const ids = row.id || this.ids; @@ -400,6 +537,47 @@ export default { }).catch(res => { }) }, + handleDeletenode (row) { + const ids = row.id || this.ids; + this.$confirm("是否确认删除?", "警告", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }) + .then(() => { + return deviceNodeDel(ids); + }) + .then((res) => { + if (200 == res.code) { + this.getListnode(row); + this.msgSuccess("删除成功"); + } else { + this.msgError(res.msg); + } + }) + .catch((res) => { }); + }, + // 批量删除节点 + batchHandleDeletenode () { + this.$confirm("是否确认删除?", "警告", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }) + .then(() => { + return deviceNodeDel(this.nodeIds); + }) + .then((res) => { + if (200 == res.code) { + this.getListnode(...this.nodeData); + this.msgSuccess("删除成功"); + } else { + this.msgError(res.msg); + } + }) + .catch((res) => { }); + }, + // 页码尺寸改变 handleSizeChange (val) { this.queryForm.pagesize = val; diff --git a/src/views/hardware/productList/index.vue b/src/views/hardware/productList/index.vue index ee4cdad..bb0ad00 100644 --- a/src/views/hardware/productList/index.vue +++ b/src/views/hardware/productList/index.vue @@ -94,9 +94,6 @@ - - - @@ -119,9 +116,7 @@ - -