From 17256e8807cdee21b72cdaafc8048fb5969a2264 Mon Sep 17 00:00:00 2001
From: tx <2622874537@qq.com>
Date: Tue, 7 Jan 2025 11:41:36 +0800
Subject: [PATCH 1/5] =?UTF-8?q?=E8=AE=BE=E6=96=BD=20=E7=BB=91=E5=AE=9A?=
=?UTF-8?q?=E5=95=86=E6=88=B7=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/system/device.js | 8 +
src/views/system/device/device_detail.vue | 459 +++++++++++++++-------
2 files changed, 322 insertions(+), 145 deletions(-)
diff --git a/src/api/system/device.js b/src/api/system/device.js
index 2dc7388..3df6f16 100644
--- a/src/api/system/device.js
+++ b/src/api/system/device.js
@@ -140,3 +140,11 @@ export function getDeviceBySn(sn){
})
}
+// 绑定设备设施
+export function bindDeviceFacility(data){
+ return request({
+ url: '/system/device/bindDeviceFacility/'+data.equipmentId+'/'+data.deviceId,
+ method: 'post',
+ // data: data
+ })
+}
\ No newline at end of file
diff --git a/src/views/system/device/device_detail.vue b/src/views/system/device/device_detail.vue
index f08ec73..2d364ad 100644
--- a/src/views/system/device/device_detail.vue
+++ b/src/views/system/device/device_detail.vue
@@ -8,27 +8,14 @@
@@ -86,10 +74,7 @@
型号功能:
-
@@ -106,8 +91,9 @@
@@ -139,10 +125,7 @@
绑定设施:
-
@@ -163,7 +146,7 @@
备注:
-
+
{{ deviceData.remark || '--' }}
@@ -320,6 +303,68 @@
命令日志内容
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ formatFeeRules(scope.row.feeRuleVOS) }}
+
+
+
+
+
+
+
+
+
+
+ 绑定
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ scope.row.status === '0' ? '正常' : '停用' }}
+
+
+
+
+
+ 绑定
+
+
+
+
+
@@ -331,34 +376,75 @@ import {
handleUnlocking,
reboot,
refreshDevice,
- delDevice
+ delDevice,
+ bindDeviceFacility,
+ bindDeviceUser
} from '@/api/system/device'
+import { listUser } from "@/api/user/user"
import { listData } from '@/api/system/dict/data'
+import { listEquipment } from "@/api/system/equipment"
import QrCode from '@/components/QrCode/index.vue'
import QRCode from 'qrcode'
export default {
- name: 'DeviceDetail',
- components: { QrCode },
+ name: "DeviceDetail",
+ components: {
+ QrCode
+ },
+ dicts: ['ss_equipment_type', 'ss_equipment_status', 'ss_user_type'],
data() {
return {
- deviceData: {},
- isEditing: false, // 是否处于编辑状态
+ // 设备数据
+ deviceData: {
+ modelTags: [] // 初始化为空数组
+ },
+ loading: false,
+ isEditing: false,
+
+ // 编辑表单数据
editForm: {
- deviceId: '',
- deviceName: '',
+ deviceId: undefined,
mac: '',
mac2: '',
sn: '',
model: '',
productId: '',
- modelTags: [],
+ deviceName: '',
+ roomName: '',
storeName: '',
- serviceRate: '',
userName: '',
remark: '',
- roomName: ''
+ modelTags: [],
+ serviceRate: undefined
},
+
+ // 设施相关数据
+ bindFacilityDialogVisible: false,
+ facilityTableLoading: false,
+ facilityList: [],
+ facilityTotal: 0,
+ facilityQueryParams: {
+ pageNum: 1,
+ pageSize: 10
+ },
+ facilityOptions: [],
+ modelTagOptions: [],
+
+ // 用户相关数据
+ bindUserDialogVisible: false,
+ userTableLoading: false,
+ userList: [],
+ userTotal: 0,
+ userQueryParams: {
+ pageNum: 1,
+ pageSize: 10,
+ userName: undefined,
+ phonenumber: undefined,
+ status: undefined,
+ userType: '01'
+ },
+
+ // 标签页相关
activeTab: 'packages',
searchForm: {
userName: '',
@@ -366,161 +452,241 @@ export default {
packageName: '',
chargeMode: '',
chargeType: ''
- },
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- dictType: 'sm_model_tag',
- dictLabel: undefined,
- status: undefined
- },
- facilityOptions: [],
- modelTagOptions: [],
- loading: true
+ }
}
},
computed: {
- modelTags() {
- return this.deviceData.modelTags ? this.deviceData.modelTags.map(tag => {
- const modelTag = this.modelTagOptions.find(option => option.dictValue === tag);
- return modelTag ? modelTag.dictLabel : tag;
- }) : [];
+ qrCodeText() {
+ return this.deviceData.sn || ''
},
- serviceModeText() {
- switch (this.deviceData.serviceMode) {
- case "1": return "直营模式";
- case "2": return "代理模式";
- default: return "--";
- }
+ modelTags() {
+ // 确保返回数组类型
+ if (!this.deviceData.modelTags) return []
+ return Array.isArray(this.deviceData.modelTags)
+ ? this.deviceData.modelTags
+ : this.deviceData.modelTags.split(',').filter(Boolean)
},
facilityTag() {
- const facility = this.facilityOptions.find(option => option.dictValue === this.deviceData.serviceRate);
- return facility ? facility.dictLabel : '--';
- },
- qrCodeText() {
- return this.deviceData.qrText || '无二维码信息';
+ return this.deviceData.facilityName || '--'
}
},
created() {
- const deviceId = this.$route.params.deviceId;
+ const deviceId = this.$route.params.deviceId
if (deviceId) {
- this.fetchDeviceData(deviceId);
+ this.fetchDeviceData(deviceId)
}
- this.fetchFacilityOptions();
- this.fetchModelTagOptions();
+ this.fetchFacilityOptions()
+ this.fetchModelTagOptions()
},
methods: {
- // 切换编辑状态
- toggleEdit() {
- this.isEditing = true;
- // 复制当前数据到编辑表单
- this.editForm = {
- deviceId: this.deviceData.deviceId,
- deviceName: this.deviceData.deviceName,
- mac: this.deviceData.mac,
- mac2: this.deviceData.mac2,
- sn: this.deviceData.sn,
- model: this.deviceData.model,
- productId: this.deviceData.productId,
- modelTags: this.deviceData.modelTags || [],
- storeName: this.deviceData.storeName,
- serviceRate: this.deviceData.serviceRate,
- userName: this.deviceData.userName,
- remark: this.deviceData.remark,
- roomName: this.deviceData.monthFee
- };
- },
-
- // 保存编辑
- handleSave() {
- updateDevice(this.editForm).then(() => {
- this.$message.success("设备信息已更新");
- this.isEditing = false;
- // 重新获取设备数据
- this.fetchDeviceData(this.editForm.deviceId);
- }).catch(() => {
- this.$message.error("更新设备信息失败");
- });
- },
-
- // 取消编辑
- handleCancel() {
- this.isEditing = false;
- this.editForm = {};
- },
-
fetchDeviceData(deviceId) {
+ this.loading = true
getDevice(deviceId).then(response => {
- this.deviceData = response.data;
- this.loading = false;
+ if (response.data) {
+ // 确保modelTags是数组
+ this.deviceData = {
+ ...response.data,
+ modelTags: Array.isArray(response.data.modelTags)
+ ? response.data.modelTags
+ : (response.data.modelTags ? response.data.modelTags.split(',') : [])
+ }
+ }
+ this.loading = false
}).catch(error => {
- this.$message.error("获取设备详情失败");
- this.loading = false;
- });
+ this.$message.error("获取设备详情失败")
+ this.loading = false
+ })
+ },
+ formatFeeRules(feeRuleVOS) {
+ if (!feeRuleVOS || !feeRuleVOS.length) {
+ return '-';
+ }
+ return feeRuleVOS.map(rule => rule.explain).join(',');
},
-
fetchFacilityOptions() {
- listData({ pageNum: 1, pageSize: 10, dictType: 'ss_equipment_type' }).then(response => {
- this.facilityOptions = response.rows;
- }).catch(error => {
- this.$message.error("获取绑定设施数据失败");
- });
+ listData({ dictType: 'ss_equipment_type' }).then(response => {
+ this.facilityOptions = response.rows || []
+ }).catch(() => {
+ this.$message.error("获取绑定设施数据失败")
+ })
},
fetchModelTagOptions() {
- listData(this.queryParams).then(response => {
- this.modelTagOptions = response.rows;
- }).catch(error => {
- this.$message.error("获取modelTags数据失败");
- });
+ listData({ dictType: 'ss_model_tags' }).then(response => {
+ this.modelTagOptions = response.rows || []
+ }).catch(() => {
+ this.$message.error("获取型号功能数据失败")
+ })
+ },
+ getFacilityList() {
+ this.facilityTableLoading = true;
+ // 修改查询参数
+ const queryParams = {
+ pageNum: this.facilityQueryParams.pageNum,
+ pageSize: this.facilityQueryParams.pageSize,
+ name: undefined,
+ type: undefined,
+ status: undefined
+ };
+
+ listEquipment(queryParams).then(response => {
+ this.facilityList = response.rows;
+ this.facilityTotal = response.total;
+ this.facilityTableLoading = false;
+ }).catch(() => {
+ this.$message.error("获取设施列表失败");
+ this.facilityTableLoading = false;
+ });
+},
+ toggleEdit() {
+ this.isEditing = true
+ this.editForm = {
+ ...this.deviceData,
+ modelTags: Array.isArray(this.deviceData.modelTags)
+ ? [...this.deviceData.modelTags]
+ : []
+ }
+ },
+
+ handleSave() {
+ updateDevice(this.editForm).then(() => {
+ this.$message.success("保存成功")
+ this.isEditing = false
+ this.fetchDeviceData(this.deviceData.deviceId)
+ }).catch(() => {
+ this.$message.error("保存失败")
+ })
+ },
+
+ handleCancel() {
+ this.isEditing = false
+ this.editForm = {}
},
downloadQRCode() {
- const qrText = this.qrCodeText;
+ const qrText = this.qrCodeText
+ if (!qrText) {
+ this.$message.warning("没有可用的设备SN码")
+ return
+ }
QRCode.toDataURL(qrText, { width: 150, height: 150 }, (err, url) => {
if (err) {
- this.$message.error("生成二维码失败");
- return;
+ this.$message.error("生成二维码失败")
+ return
}
- const link = document.createElement('a');
- link.href = url;
- link.download = `${this.deviceData.sn || 'unknown'}.png`;
- link.click();
- });
+ const link = document.createElement('a')
+ link.href = url
+ link.download = `${this.deviceData.sn || 'device'}.png`
+ link.click()
+ })
},
handleUnlocking(row) {
handleUnlocking(row.deviceId).then(() => {
- this.$message.success("设备已解锁");
- });
+ this.$message.success("设备已解锁")
+ })
},
handleLock(row) {
handleLock(row.deviceId).then(() => {
- this.$message.success("设备已锁定");
- });
+ this.$message.success("设备已锁定")
+ })
},
reboot(row) {
reboot(row.deviceId).then(() => {
- this.$message.success("设备已重启");
- });
+ this.$message.success("设备已重启")
+ })
},
refresh(row) {
refreshDevice(row.deviceId).then(() => {
- this.$message.success("设备已更新");
- });
+ this.$message.success("设备已更新")
+ })
},
handleDelete(row) {
- delDevice(row.deviceId).then(() => {
- this.$message.success("设备已删除");
- });
+ this.$modal.confirm('是否确认删除该设备?').then(() => {
+ return delDevice(row.deviceId)
+ }).then(() => {
+ this.$message.success("设备已删除")
+ this.$router.push('/system/device')
+ }).catch(() => {})
+ },
+
+ openBindFacilityDialog() {
+ this.bindFacilityDialogVisible = true
+ this.getFacilityList()
+ },
+
+ getFacilityList() {
+ this.facilityTableLoading = true
+ listEquipment(this.facilityQueryParams).then(response => {
+ this.facilityList = response.rows || []
+ this.facilityTotal = response.total || 0
+ this.facilityTableLoading = false
+ })
+ },
+
+ handleBindFacility(row) {
+ this.$modal.confirm('确认要将该设备绑定到设施"' + row.name + '"吗?').then(() => {
+ return bindDeviceFacility({
+ deviceId: this.deviceData.deviceId,
+ equipmentId: row.equipmentId
+ })
+ }).then(() => {
+ this.$modal.msgSuccess("绑定成功")
+ this.bindFacilityDialogVisible = false
+ this.fetchDeviceData(this.deviceData.deviceId)
+ }).catch(() => {})
+ },
+
+ handleOnline(row) {
+ const status = row.status === '8' ? '0' : '8'
+ const statusText = status === '8' ? '禁用' : '启用'
+
+ this.$modal.confirm('确认要' + statusText + '该设备吗?').then(() => {
+ return updateDevice({
+ deviceId: row.deviceId,
+ status: status
+ })
+ }).then(() => {
+ this.$modal.msgSuccess(statusText + "成功")
+ this.fetchDeviceData(row.deviceId)
+ }).catch(() => {})
+ },
+
+ openBindUserDialog() {
+ this.bindUserDialogVisible = true
+ this.getUserList()
+ },
+
+ getUserList() {
+ this.userTableLoading = true
+ listUser(this.userQueryParams).then(response => {
+ this.userList = response.rows || []
+ this.userTotal = response.total || 0
+ this.userTableLoading = false
+ })
+ },
+
+ handleBindUser(row) {
+ this.$modal.confirm('确认要将该设备绑定到商户"' + row.userName + '"吗?').then(() => {
+ return bindDeviceUser({
+ deviceId: this.deviceData.deviceId,
+ userId: row.userId
+ })
+ }).then(() => {
+ this.$modal.msgSuccess("绑定成功")
+ this.bindUserDialogVisible = false
+ this.fetchDeviceData(this.deviceData.deviceId)
+ }).catch(() => {})
}
}
}
+
+
+
\ No newline at end of file
diff --git a/src/views/user/user/index.vue b/src/views/user/user/index.vue
index eb1293e..00f7af1 100644
--- a/src/views/user/user/index.vue
+++ b/src/views/user/user/index.vue
@@ -351,6 +351,7 @@ export default {
name: "User",
components: {UserConfigDialog },
dicts: ['sys_normal_disable', 'sys_user_sex','et_user_is_authentication','ss_user_type'],
+ props: ['storeId'],
data() {
return {
showConfigDialog: false,
@@ -481,6 +482,7 @@ export default {
},
/** 查询用户列表 */
getList() {
+ this.queryParams.storeId = this.storeId;
this.loading = true;
listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.userList = response.rows;
From a6799f09f8197d8e1507e793ce0ad3d47b11190d Mon Sep 17 00:00:00 2001
From: tx <2622874537@qq.com>
Date: Tue, 7 Jan 2025 18:00:36 +0800
Subject: [PATCH 5/5] =?UTF-8?q?=E6=88=BF=E9=97=B4=E8=AF=A6=E6=83=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/router/index.js | 17 ++++++++++++++++-
src/views/system/room/index.vue | 3 +++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/router/index.js b/src/router/index.js
index 4b54d13..3d541e1 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -162,6 +162,20 @@ export const dynamicRoutes = [
}
]
},
+ {
+ path: '/system/roomDetail',
+ component: Layout,
+ hidden: true,
+ permissions: ['system:room:list'],
+ children: [
+ {
+ path: 'detail/:roomId(\\d+)',
+ component: () => import('@/views/system/room/room_detail'),
+ name: 'RoomDetail',
+ meta: { title: '房间详情', activeMenu: '/system/room' }
+ }
+ ]
+ },
{
path: '/system/device/sn',
component: Layout,
@@ -245,7 +259,8 @@ export const dynamicRoutes = [
meta: { title: '用户详情', activeMenu: '/user/user' }
}
]
- }
+ },
+
]
// 防止连续点击多次路由报错
diff --git a/src/views/system/room/index.vue b/src/views/system/room/index.vue
index ac848b3..98a59c2 100644
--- a/src/views/system/room/index.vue
+++ b/src/views/system/room/index.vue
@@ -109,6 +109,9 @@
{{d.row[column.key]}}
+
+ {{d.row[column.key]}}
+