From 03fedb6bd519c3badb0af92fb85d5f6f34bc0f60 Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Tue, 26 Oct 2021 16:55:10 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E7=BC=96=E8=BE=91=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/components/device-edit.vue | 12 +-- src/store/device.js | 27 ++++- src/views/device-edit.vue | 179 +++++++++++++++++++++++++++++++++ src/views/device-list.vue | 10 +- 5 files changed, 214 insertions(+), 16 deletions(-) create mode 100644 src/views/device-edit.vue diff --git a/package.json b/package.json index 321193c..56ad52e 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "cz": "git add . && git cz", "format": "prettier --write ./src", "lint": "eslint ./src --ext .vue,.js,.ts", - "lint-fix": "eslint --fix ./src --ext .vue,.js,.ts", + "fix": "eslint --fix ./src --ext .vue,.js,.ts", "prepare": "husky install" }, "dependencies": { diff --git a/src/components/device-edit.vue b/src/components/device-edit.vue index e469345..cf2ad62 100644 --- a/src/components/device-edit.vue +++ b/src/components/device-edit.vue @@ -1,19 +1,13 @@ diff --git a/src/store/device.js b/src/store/device.js index bdd5466..1966708 100644 --- a/src/store/device.js +++ b/src/store/device.js @@ -4,11 +4,21 @@ const user = { namespaced: true, state: { - devices: [], - devicesAll: null, + devices: [], // 站点列表 设备列表简版 + devicesAll: null, // 设备列表完整版 + currentDeviceId: '', // 当前正在编辑的设备deviceId }, - getters: {}, + getters: { + // 当前正在编辑的设备的完整信息 + current({ devicesAll, currentDeviceId }) { + try { + return devicesAll.data.find(device => device.deviceId === currentDeviceId); + } catch (error) { + return null; + } + }, + }, mutations: { /** @@ -23,11 +33,20 @@ const user = { /** * 设置devicesAll的数据 * @param {*} state - * @param {*} devices + * @param {array} devices */ setDevicesAll(state, devices) { state.devicesAll = devices; }, + + /** + * 设置正则编辑的设备deviceId + * @param {*} state + * @param {string} deviceId + */ + setCurrentDeviceId(state, deviceId) { + state.currentDeviceId = deviceId; + }, }, actions: { diff --git a/src/views/device-edit.vue b/src/views/device-edit.vue new file mode 100644 index 0000000..0ae2293 --- /dev/null +++ b/src/views/device-edit.vue @@ -0,0 +1,179 @@ + + + diff --git a/src/views/device-list.vue b/src/views/device-list.vue index 97bef5d..e5d6d51 100644 --- a/src/views/device-list.vue +++ b/src/views/device-list.vue @@ -26,14 +26,14 @@ -