diff --git a/src/views/system/device/device_detail.vue b/src/views/system/device/device_detail.vue index 2d364ad..98c2dd8 100644 --- a/src/views/system/device/device_detail.vue +++ b/src/views/system/device/device_detail.vue @@ -91,7 +91,8 @@
归属信息
- 绑定商户 + 绑定商户 绑定设施
@@ -271,33 +272,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - 搜索 - 重置 - - + 订单列表内容 命令日志内容 @@ -340,6 +315,26 @@ + + + + + + + + + + + + + + + 搜索 + 重置 + + @@ -385,11 +380,13 @@ import { listData } from '@/api/system/dict/data' import { listEquipment } from "@/api/system/equipment" import QrCode from '@/components/QrCode/index.vue' import QRCode from 'qrcode' +import Role from '@/views/system/rule/index.vue' export default { name: "DeviceDetail", components: { - QrCode + QrCode, + Role }, dicts: ['ss_equipment_type', 'ss_equipment_status', 'ss_user_type'], data() { @@ -400,7 +397,7 @@ export default { }, loading: false, isEditing: false, - + // 编辑表单数据 editForm: { deviceId: undefined, @@ -460,11 +457,12 @@ export default { return this.deviceData.sn || '' }, modelTags() { - // 确保返回数组类型 - if (!this.deviceData.modelTags) return [] - return Array.isArray(this.deviceData.modelTags) - ? this.deviceData.modelTags - : this.deviceData.modelTags.split(',').filter(Boolean) + return this.deviceData.modelTags ? this.deviceData.modelTags.map(tag => { + const modelTag = this.modelTagOptions.find(option => option.dictValue === tag); + + + return modelTag ? modelTag.dictLabel : tag; + }) : []; }, facilityTag() { return this.deviceData.facilityName || '--' @@ -472,13 +470,19 @@ export default { }, created() { const deviceId = this.$route.params.deviceId + + this.fetchFacilityOptions() + this.fetchModelTagOptions() if (deviceId) { this.fetchDeviceData(deviceId) } - this.fetchFacilityOptions() - this.fetchModelTagOptions() }, methods: { + toUserDetail(){ + if (this.deviceData.userId) { + this.$router.push(`/user/detail/${this.deviceData.userId}`); + } + }, fetchDeviceData(deviceId) { this.loading = true getDevice(deviceId).then(response => { @@ -486,8 +490,8 @@ export default { // 确保modelTags是数组 this.deviceData = { ...response.data, - modelTags: Array.isArray(response.data.modelTags) - ? response.data.modelTags + modelTags: Array.isArray(response.data.modelTags) + ? response.data.modelTags : (response.data.modelTags ? response.data.modelTags.split(',') : []) } } @@ -512,37 +516,38 @@ export default { }, fetchModelTagOptions() { - listData({ dictType: 'ss_model_tags' }).then(response => { + listData({ dictType: 'sm_model_tag' }).then(response => { this.modelTagOptions = response.rows || [] + console.log(this.modelTagOptions, 'this.modelTagOptions'); }).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; - }); -}, + 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.editForm = { ...this.deviceData, - modelTags: Array.isArray(this.deviceData.modelTags) + modelTags: Array.isArray(this.deviceData.modelTags) ? [...this.deviceData.modelTags] : [] } @@ -611,14 +616,14 @@ export default { }).then(() => { this.$message.success("设备已删除") this.$router.push('/system/device') - }).catch(() => {}) + }).catch(() => { }) }, openBindFacilityDialog() { this.bindFacilityDialogVisible = true this.getFacilityList() }, - + getFacilityList() { this.facilityTableLoading = true listEquipment(this.facilityQueryParams).then(response => { @@ -627,24 +632,24 @@ export default { this.facilityTableLoading = false }) }, - + handleBindFacility(row) { this.$modal.confirm('确认要将该设备绑定到设施"' + row.name + '"吗?').then(() => { - return bindDeviceFacility({ - deviceId: this.deviceData.deviceId, - equipmentId: row.equipmentId + return bindDeviceFacility({ + deviceId: this.deviceData.deviceId, + equipmentId: row.equipmentId }) }).then(() => { this.$modal.msgSuccess("绑定成功") this.bindFacilityDialogVisible = false this.fetchDeviceData(this.deviceData.deviceId) - }).catch(() => {}) + }).catch(() => { }) }, handleOnline(row) { const status = row.status === '8' ? '0' : '8' const statusText = status === '8' ? '禁用' : '启用' - + this.$modal.confirm('确认要' + statusText + '该设备吗?').then(() => { return updateDevice({ deviceId: row.deviceId, @@ -653,7 +658,7 @@ export default { }).then(() => { this.$modal.msgSuccess(statusText + "成功") this.fetchDeviceData(row.deviceId) - }).catch(() => {}) + }).catch(() => { }) }, openBindUserDialog() { @@ -669,7 +674,25 @@ export default { this.userTableLoading = false }) }, + // 搜索按钮操作 + handleUserQuery() { + this.userQueryParams.pageNum = 1; + this.getUserList(); + }, + // 重置按钮操作 + resetUserQuery() { + this.$refs["queryForm"].resetFields(); + this.userQueryParams = { + pageNum: 1, + pageSize: 10, + userName: undefined, + phonenumber: undefined, + status: undefined, + userType: '01' + }; + this.handleUserQuery(); + }, handleBindUser(row) { this.$modal.confirm('确认要将该设备绑定到商户"' + row.userName + '"吗?').then(() => { return bindDeviceUser({ @@ -680,7 +703,7 @@ export default { this.$modal.msgSuccess("绑定成功") this.bindUserDialogVisible = false this.fetchDeviceData(this.deviceData.deviceId) - }).catch(() => {}) + }).catch(() => { }) } } } diff --git a/src/views/system/rule/index.vue b/src/views/system/rule/index.vue index 7434a51..4c192ca 100644 --- a/src/views/system/rule/index.vue +++ b/src/views/system/rule/index.vue @@ -1,8 +1,8 @@