From 45a141415af34ff2af4c5ef0e6efd6cbcf2986db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A2=A8=E5=A4=A7=E5=8F=94?= <494979559@qq.com>
Date: Tue, 7 May 2024 18:02:37 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E8=B0=83=E6=95=B4=E3=80=81de?=
=?UTF-8?q?bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/ss/store.js | 8 +
src/api/system/device.js | 8 +
src/components/Business/Group/groupSelect.vue | 110 -----------
.../groupDialog.vue => Store/StoreDialog.vue} | 119 ++++++-----
src/components/Business/Store/StoreInput.vue | 185 ++++++++++++++++++
src/components/SnInput/index.vue | 94 +++++++++
.../device/components/readingRecord.vue | 3 -
.../device/components/rechargeRecord.vue | 12 +-
.../system/device/components/resetRecord.vue | 9 +-
src/views/system/device/detail.vue | 49 +++--
src/views/system/device/index.vue | 168 ++++++----------
.../system/smUser/components/userDevice.vue | 2 +-
src/views/system/smUser/detail.vue | 13 +-
src/views/system/smUser/index.vue | 2 +-
14 files changed, 466 insertions(+), 316 deletions(-)
delete mode 100644 src/components/Business/Group/groupSelect.vue
rename src/components/Business/{Group/groupDialog.vue => Store/StoreDialog.vue} (66%)
create mode 100644 src/components/Business/Store/StoreInput.vue
create mode 100644 src/components/SnInput/index.vue
diff --git a/src/api/ss/store.js b/src/api/ss/store.js
index cfd414f..43a2d36 100644
--- a/src/api/ss/store.js
+++ b/src/api/ss/store.js
@@ -9,6 +9,14 @@ export function listStore(query) {
})
}
+// ids查询商户列表列表
+export function listStoreByIds(ids) {
+ return request({
+ url: `/ss/store/listByIds/${ids}`,
+ method: 'get',
+ })
+}
+
// 查询商户列表详细
export function getStore(storeId) {
return request({
diff --git a/src/api/system/device.js b/src/api/system/device.js
index c9f1451..3420ea6 100644
--- a/src/api/system/device.js
+++ b/src/api/system/device.js
@@ -43,6 +43,14 @@ export function updateDevice(data) {
})
}
+// 修改设备SN
+export function updateDeviceSn(deviceId, sn) {
+ return request({
+ url: `/system/device/${deviceId}/bindSn/${sn}`,
+ method: 'put'
+ })
+}
+
// 删除设备
export function delDevice(deviceId) {
return request({
diff --git a/src/components/Business/Group/groupSelect.vue b/src/components/Business/Group/groupSelect.vue
deleted file mode 100644
index 54322f8..0000000
--- a/src/components/Business/Group/groupSelect.vue
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/src/components/Business/Group/groupDialog.vue b/src/components/Business/Store/StoreDialog.vue
similarity index 66%
rename from src/components/Business/Group/groupDialog.vue
rename to src/components/Business/Store/StoreDialog.vue
index e5e414b..7a431af 100644
--- a/src/components/Business/Group/groupDialog.vue
+++ b/src/components/Business/Store/StoreDialog.vue
@@ -1,10 +1,12 @@
-
+
+
+
-
-
-
+
+
+
搜索
@@ -23,9 +25,18 @@
>
-
-
-
+
+
+
+
+
+
+
+
+
+ {{d.row.province}}{{d.row.city}}{{d.row.county}}{{d.row.address}}
+
+
import {clone} from "@/utils";
-import {listGroup} from "@/api/system/group";
+import { listStore } from '@/api/ss/store'
export default {
- name: "groupDialog",
- data() {
- return {
- loadTable: false,
- tableData: [],
- searchForm: {
- pageNum: 1,
- pageSize: 10,
- ...this.search
- },
- total: 0,
- row: null,
- selected: [],
- }
- },
+ name: "StoreDialog",
props: {
- initSelect: {
- type: Array,
+ // 标题
+ title: {
+ type: String,
+ default: '选择店铺'
+ },
+ value: {
+ type: [String, Number, Array],
default: null,
},
multiple: {
@@ -72,23 +74,50 @@ export default {
type: Boolean,
default: false
},
- title: {
- type: String,
- default: '选择分组'
- },
- search: {
+ query: {
type: Object,
default: () => ({})
},
+ initSelect: {
+ type: Array,
+ default: null,
+ },
+ prop: {
+ type: String,
+ default: 'id'
+ }
+ },
+ data() {
+ return {
+ loadTable: false,
+ tableData: [],
+ searchForm: {},
+ total: 0,
+ row: null,
+ selected: [],
+ }
},
methods: {
+ // 获取数据列表
+ searchList() {
+ this.loadTable = true;
+ listStore(this.searchForm).then(response => {
+ this.tableData = response.rows;
+ this.total = response.total;
+ // 刷新表格状态
+ this.$nextTick(()=>{
+ this.refreshTableSelection();
+ })
+ }).finally(() =>{
+ this.loadTable = false;
+ })
+ },
// 打开时
open() {
this.searchForm = {
- code: null,
pageNum: 1,
pageSize: 10,
- ...this.search,
+ ...this.query,
}
if (this.initSelect) {
@@ -103,7 +132,7 @@ export default {
refreshTableSelection() {
if(this.multiple){
this.tableData.forEach(item => {
- if (this.selected.map(j => j.id).includes(item.id)) {
+ if (this.selected.map(j => j[this.prop]).includes(item[this.prop])) {
this.$refs.multipleTable.toggleRowSelection(item, true);
} else {
this.$refs.multipleTable.toggleRowSelection(item, false);
@@ -115,10 +144,10 @@ export default {
selectionAll(val){
let flag = val.length > 0;
this.tableData.forEach(item => {
- if (flag && !this.selected.map(i => i.id).includes(item.id)){
+ if (flag && !this.selected.map(i => i[this.prop]).includes(item[this.prop])){
this.selected.push(item);
- } else if (!flag && this.selected.map(i => i.id).includes(item.id)){
- this.selected = this.selected.filter(i => i.id !== item.id);
+ } else if (!flag && this.selected.map(i => i[this.prop]).includes(item[this.prop])){
+ this.selected = this.selected.filter(i => i[this.prop] !== item[this.prop]);
}
})
},
@@ -133,9 +162,9 @@ export default {
// 更换某一行的选中状态
changeSelection(row){
if(this.multiple){
- if (this.selected.map(i => i.id).includes(row.id)){
+ if (this.selected.map(i => i[this.prop]).includes(row[this.prop])){
this.$refs.multipleTable.toggleRowSelection(row, false);
- this.selected = this.selected.filter(i => i.id !== row.id);
+ this.selected = this.selected.filter(i => i[this.prop] !== row[this.prop]);
}else {
this.$refs.multipleTable.toggleRowSelection(row, true);
this.selected.push(row);
@@ -149,20 +178,6 @@ export default {
this.searchForm.pageNum = 1;
this.searchList();
},
- // 获取数据列表
- searchList() {
- this.loadTable = true;
- listGroup(this.searchForm).then(response => {
- this.tableData = response.rows;
- this.total = response.total;
- // 刷新表格状态
- this.$nextTick(() => {
- this.refreshTableSelection();
- })
- }).finally(() => {
- this.loadTable = false;
- })
- },
// 关闭弹窗
close() {
this.$emit('update:show', false);
diff --git a/src/components/Business/Store/StoreInput.vue b/src/components/Business/Store/StoreInput.vue
new file mode 100644
index 0000000..f3a3df3
--- /dev/null
+++ b/src/components/Business/Store/StoreInput.vue
@@ -0,0 +1,185 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/SnInput/index.vue b/src/components/SnInput/index.vue
new file mode 100644
index 0000000..3cd91cc
--- /dev/null
+++ b/src/components/SnInput/index.vue
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+
+
+ 确认
+ 取消
+
+
+
+
+
+
+
diff --git a/src/views/system/device/components/readingRecord.vue b/src/views/system/device/components/readingRecord.vue
index 67295db..a93c389 100644
--- a/src/views/system/device/components/readingRecord.vue
+++ b/src/views/system/device/components/readingRecord.vue
@@ -6,9 +6,6 @@
{{d.row.totalElectriQuantity | money}} 度
-
- {{d.row.surplusElectriQuantity | money}} 度
-
-
- {{d.row.deviceAmount | money}} 元
+
+
+ {{d.row.money | money}} 元
-
- {{d.row.unitPrice | money}} 元/度
-
-
+
- {{d.row.deviceAmount / d.row.unitPrice | money}} 度
+ {{d.row.suitTime | money}} 分钟
diff --git a/src/views/system/device/components/resetRecord.vue b/src/views/system/device/components/resetRecord.vue
index 171d8e4..cb8acf0 100644
--- a/src/views/system/device/components/resetRecord.vue
+++ b/src/views/system/device/components/resetRecord.vue
@@ -3,12 +3,9 @@
-
-
- {{d.row.surplusElectriQuantity | money}} 度
-
-
- {{d.row.totalElectriQuantity | money}} 度
+
+
+ {{d.row.surplusTime | money}} 分钟
diff --git a/src/views/system/device/detail.vue b/src/views/system/device/detail.vue
index 668f9b9..f733f52 100644
--- a/src/views/system/device/detail.vue
+++ b/src/views/system/device/detail.vue
@@ -18,34 +18,23 @@
{{deviceData.mac | defaultValue}}
+ {{deviceData.deviceNo | defaultValue}}
{{deviceData.model | defaultValue}}
- {{deviceData.userName | defaultValue}}
- {{deviceData.groupName | defaultValue}}
- {{deviceData.remark | defaultValue}}
- {{deviceData.price | defaultValue}}元/度
+ {{deviceData.userName | defaultValue}}
+ {{deviceData.storeName | defaultValue}}
--
{{deviceData.wifi | defaultValue}}
- {{deviceData.surplusElectriQuantity | defaultValue}}度
-
-
+ {{surplusTime | defaultValue}} 分钟
{{deviceData.realTimePower | defaultValue}} KWH
-
-
- {{deviceData.expireDate | defaultValue}}
-
-
- {{deviceData.expireDay | defaultValue}}日
-
-
-
+ {{deviceData.remark | defaultValue}}
@@ -67,9 +56,6 @@
-
-
-
@@ -97,6 +83,8 @@ export default {
return {
loading: false,
deviceData: {},
+ timer: null,
+ surplusTime: 0, // 剩余时长
}
},
computed: {
@@ -109,7 +97,23 @@ export default {
created() {
this.getDevice();
},
+ beforeDestroy() {
+ clearInterval(this.timer);
+ },
methods: {
+ // 计算剩余时长
+ computeSurplusTime() {
+ console.log('compute', this.deviceData.expireTime , this.surplusTime );
+ if (this.deviceData.expireTime == null) {
+ return 0;
+ }
+ let expireTime = new Date(this.deviceData.expireTime).getTime();
+ let now = new Date().getTime();
+ if (expireTime < now) {
+ return 0;
+ }
+ return Math.floor((expireTime - now) / 60000);
+ },
// 刷新设备信息
refreshIot() {
refreshIot(this.deviceData.deviceId).then(data => {
@@ -125,6 +129,13 @@ export default {
this.loading = true;
getDevice(this.$route.query.deviceId).then(response => {
this.deviceData = response.data;
+ this.surplusTime = this.computeSurplusTime();
+ if (this.timer == null) {
+ this.timer = setInterval(() => {
+ console.log('timer')
+ this.surplusTime = this.computeSurplusTime();
+ }, 60000)
+ }
}).finally(() => {
this.loading = false;
})
diff --git a/src/views/system/device/index.vue b/src/views/system/device/index.vue
index ba3e311..037c75c 100644
--- a/src/views/system/device/index.vue
+++ b/src/views/system/device/index.vue
@@ -53,18 +53,10 @@
/>
-
+
-
-
-
@@ -123,7 +115,7 @@
-
+
@@ -143,10 +135,15 @@
+
+
+
+ 点击绑定
+ {{d.row.deviceNo}}
+
+
-
-
@@ -157,10 +154,8 @@
-
-
-
-
+
+
+
+
-
-
+
+
@@ -206,13 +203,13 @@
-
-
+
+
+
+
+
+
+
@@ -220,65 +217,9 @@
-
-
-
- 元/度
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -292,21 +233,22 @@