mirror of
https://gitee.com/myxzgzs/boyue-ui-admin-vue3
synced 2025-08-09 17:02:43 +08:00
【功能修改】IoT:设备详情的代码优化
This commit is contained in:
parent
99b24c107c
commit
3ea61c51ef
@ -637,7 +637,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
|
|||||||
hidden: true,
|
hidden: true,
|
||||||
activeMenu: '/iot/device'
|
activeMenu: '/iot/device'
|
||||||
},
|
},
|
||||||
component: () => import('@/views/iot/device/detail/index.vue')
|
component: () => import('@/views/iot/device/device/detail/index.vue')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@
|
|||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { DeviceApi, DeviceVO } from '@/api/iot/device'
|
import { DeviceApi, DeviceVO } from '@/api/iot/device/device'
|
||||||
import { DeviceGroupApi } from '@/api/iot/device/group'
|
import { DeviceGroupApi } from '@/api/iot/device/group'
|
||||||
import { DeviceTypeEnum, ProductApi, ProductVO } from '@/api/iot/product/product'
|
import { DeviceTypeEnum, ProductApi, ProductVO } from '@/api/iot/product/product'
|
||||||
import { UploadImg } from '@/components/UploadFile'
|
import { UploadImg } from '@/components/UploadFile'
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { DeviceApi } from '@/api/iot/device'
|
import { DeviceApi } from '@/api/iot/device/device'
|
||||||
import { DeviceGroupApi } from '@/api/iot/device/group'
|
import { DeviceGroupApi } from '@/api/iot/device/group'
|
||||||
|
|
||||||
defineOptions({ name: 'IoTDeviceGroupForm' })
|
defineOptions({ name: 'IoTDeviceGroupForm' })
|
||||||
|
@ -53,10 +53,9 @@
|
|||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { DeviceApi, DeviceHistoryDataVO, DeviceVO } from '@/api/iot/device'
|
import { DeviceApi, DeviceHistoryDataVO, DeviceVO } from '@/api/iot/device/device'
|
||||||
import { ProductVO } from '@/api/iot/product/product'
|
import { ProductVO } from '@/api/iot/product/product'
|
||||||
import { beginOfDay, dateFormatter, endOfDay, formatDate } from '@/utils/formatTime'
|
import { beginOfDay, dateFormatter, endOfDay, formatDate } from '@/utils/formatTime'
|
||||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
|
||||||
|
|
||||||
const props = defineProps<{ product: ProductVO; device: DeviceVO }>()
|
const props = defineProps<{ product: ProductVO; device: DeviceVO }>()
|
||||||
|
|
||||||
|
@ -35,24 +35,22 @@
|
|||||||
<DeviceForm ref="formRef" @success="emit('refresh')" />
|
<DeviceForm ref="formRef" @success="emit('refresh')" />
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import DeviceForm from '@/views/iot/device/device/DeviceForm.vue'
|
||||||
import DeviceForm from '@/views/iot/device/DeviceForm.vue'
|
|
||||||
import { ProductVO } from '@/api/iot/product/product'
|
import { ProductVO } from '@/api/iot/product/product'
|
||||||
import { DeviceVO } from '@/api/iot/device'
|
import { DeviceVO } from '@/api/iot/device/device'
|
||||||
import { useRouter } from 'vue-router'
|
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
// 操作修改
|
const { product, device } = defineProps<{ product: ProductVO; device: DeviceVO }>()
|
||||||
|
const emit = defineEmits(['refresh'])
|
||||||
|
|
||||||
|
/** 操作修改 */
|
||||||
const formRef = ref()
|
const formRef = ref()
|
||||||
const openForm = (type: string, id?: number) => {
|
const openForm = (type: string, id?: number) => {
|
||||||
formRef.value.open(type, id)
|
formRef.value.open(type, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { product, device } = defineProps<{ product: ProductVO; device: DeviceVO }>()
|
|
||||||
const emit = defineEmits(['refresh'])
|
|
||||||
|
|
||||||
/** 复制到剪贴板方法 */
|
/** 复制到剪贴板方法 */
|
||||||
const copyToClipboard = async (text: string) => {
|
const copyToClipboard = async (text: string) => {
|
||||||
try {
|
try {
|
||||||
@ -63,11 +61,7 @@ const copyToClipboard = async (text: string) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 跳转到产品详情页面 */
|
||||||
* 跳转到产品详情页面
|
|
||||||
*
|
|
||||||
* @param productId 产品 ID
|
|
||||||
*/
|
|
||||||
const goToProductDetail = (productId: number) => {
|
const goToProductDetail = (productId: number) => {
|
||||||
router.push({ name: 'IoTProductDetail', params: { id: productId } })
|
router.push({ name: 'IoTProductDetail', params: { id: productId } })
|
||||||
}
|
}
|
||||||
|
@ -79,16 +79,14 @@
|
|||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
|
||||||
import { DICT_TYPE } from '@/utils/dict'
|
import { DICT_TYPE } from '@/utils/dict'
|
||||||
import { ProductVO } from '@/api/iot/product/product'
|
import { ProductVO } from '@/api/iot/product/product'
|
||||||
import { formatDate } from '@/utils/formatTime'
|
import { formatDate } from '@/utils/formatTime'
|
||||||
import { DeviceVO } from '@/api/iot/device'
|
import { DeviceVO } from '@/api/iot/device/device'
|
||||||
|
|
||||||
const message = useMessage() // 消息提示
|
const message = useMessage() // 消息提示
|
||||||
|
|
||||||
const { product, device } = defineProps<{ product: ProductVO; device: DeviceVO }>() // 定义 Props
|
const { product, device } = defineProps<{ product: ProductVO; device: DeviceVO }>() // 定义 Props
|
||||||
|
|
||||||
const emit = defineEmits(['refresh']) // 定义 Emits
|
const emit = defineEmits(['refresh']) // 定义 Emits
|
||||||
|
|
||||||
const activeNames = ref(['basicInfo']) // 展示的折叠面板
|
const activeNames = ref(['basicInfo']) // 展示的折叠面板
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ProductVO } from '@/api/iot/product/product'
|
import { ProductVO } from '@/api/iot/product/product'
|
||||||
import { DeviceApi, DeviceDataVO, DeviceVO } from '@/api/iot/device'
|
import { DeviceApi, DeviceDataVO, DeviceVO } from '@/api/iot/device/device'
|
||||||
import { dateFormatter } from '@/utils/formatTime'
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
import DeviceDataDetail from './DeviceDataDetail.vue'
|
import DeviceDataDetail from './DeviceDataDetail.vue'
|
||||||
|
|
||||||
|
@ -21,17 +21,17 @@
|
|||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useTagsViewStore } from '@/store/modules/tagsView'
|
import { useTagsViewStore } from '@/store/modules/tagsView'
|
||||||
import { DeviceApi, DeviceVO } from '@/api/iot/device'
|
import { DeviceApi, DeviceVO } from '@/api/iot/device/device'
|
||||||
import { DeviceTypeEnum, ProductApi, ProductVO } from '@/api/iot/product/product'
|
import { DeviceTypeEnum, ProductApi, ProductVO } from '@/api/iot/product/product'
|
||||||
import DeviceDetailsHeader from '@/views/iot/device/detail/DeviceDetailsHeader.vue'
|
import DeviceDetailsHeader from './DeviceDetailsHeader.vue'
|
||||||
import DeviceDetailsInfo from '@/views/iot/device/detail/DeviceDetailsInfo.vue'
|
import DeviceDetailsInfo from './DeviceDetailsInfo.vue'
|
||||||
import DeviceDetailsModel from '@/views/iot/device/detail/DeviceDetailsModel.vue'
|
import DeviceDetailsModel from './DeviceDetailsModel.vue'
|
||||||
|
|
||||||
defineOptions({ name: 'IoTDeviceDetail' })
|
defineOptions({ name: 'IoTDeviceDetail' })
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const id = route.params.id // 编号
|
const id = Number(route.params.id) // 将字符串转换为数字
|
||||||
const loading = ref(true) // 加载中
|
const loading = ref(true) // 加载中
|
||||||
const product = ref<ProductVO>({} as ProductVO) // 产品详情
|
const product = ref<ProductVO>({} as ProductVO) // 产品详情
|
||||||
const device = ref<DeviceVO>({} as DeviceVO) // 设备详情
|
const device = ref<DeviceVO>({} as DeviceVO) // 设备详情
|
||||||
@ -42,7 +42,6 @@ const getDeviceData = async (id: number) => {
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
device.value = await DeviceApi.getDevice(id)
|
device.value = await DeviceApi.getDevice(id)
|
||||||
console.log(product.value)
|
|
||||||
await getProductData(device.value.productId)
|
await getProductData(device.value.productId)
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
@ -64,5 +63,6 @@ onMounted(async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
await getDeviceData(id)
|
await getDeviceData(id)
|
||||||
|
activeTab.value = route.query.tab as string
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -242,10 +242,10 @@
|
|||||||
class="flex-1 !px-2 !h-[32px] !ml-[10px] text-[13px]"
|
class="flex-1 !px-2 !h-[32px] !ml-[10px] text-[13px]"
|
||||||
type="info"
|
type="info"
|
||||||
plain
|
plain
|
||||||
@click="openLog(item.id)"
|
@click="openModel(item.id)"
|
||||||
>
|
>
|
||||||
<Icon icon="ep:tickets" class="mr-1" />
|
<Icon icon="ep:tickets" class="mr-1" />
|
||||||
日志
|
数据
|
||||||
</el-button>
|
</el-button>
|
||||||
<div class="mx-[10px] h-[20px] w-[1px] bg-[#dcdfe6]"></div>
|
<div class="mx-[10px] h-[20px] w-[1px] bg-[#dcdfe6]"></div>
|
||||||
<el-button
|
<el-button
|
||||||
@ -321,7 +321,7 @@
|
|||||||
>
|
>
|
||||||
查看
|
查看
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button link type="primary" @click="openLog(scope.row.id)"> 日志 </el-button>
|
<el-button link type="primary" @click="openModel(scope.row.id)"> 日志 </el-button>
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="primary"
|
type="primary"
|
||||||
@ -360,7 +360,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { DICT_TYPE, getIntDictOptions, getDictLabel } from '@/utils/dict'
|
import { DICT_TYPE, getIntDictOptions, getDictLabel } from '@/utils/dict'
|
||||||
import { dateFormatter } from '@/utils/formatTime'
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
import { DeviceApi, DeviceVO, DeviceStatusEnum } from '@/api/iot/device'
|
import { DeviceApi, DeviceVO, DeviceStatusEnum } from '@/api/iot/device/device'
|
||||||
import DeviceForm from './DeviceForm.vue'
|
import DeviceForm from './DeviceForm.vue'
|
||||||
import { ProductApi, ProductVO } from '@/api/iot/product/product'
|
import { ProductApi, ProductVO } from '@/api/iot/product/product'
|
||||||
import { DeviceGroupApi, DeviceGroupVO } from '@/api/iot/device/group'
|
import { DeviceGroupApi, DeviceGroupVO } from '@/api/iot/device/group'
|
||||||
@ -483,9 +483,9 @@ const openGroupForm = () => {
|
|||||||
groupFormRef.value.open(selectedIds.value)
|
groupFormRef.value.open(selectedIds.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 打开日志 */
|
/** 打开物模型数据 */
|
||||||
const openLog = (id: number) => {
|
const openModel = (id: number) => {
|
||||||
push({ name: 'IoTDeviceDetail', params: { id }, query: { tab: 'log' } })
|
push({ name: 'IoTDeviceDetail', params: { id }, query: { tab: 'model' } })
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 初始化 **/
|
/** 初始化 **/
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ProductApi, ProductVO } from '@/api/iot/product/product'
|
import { ProductApi, ProductVO } from '@/api/iot/product/product'
|
||||||
import { DeviceApi } from '@/api/iot/device'
|
import { DeviceApi } from '@/api/iot/device/device'
|
||||||
import ProductDetailsHeader from './ProductDetailsHeader.vue'
|
import ProductDetailsHeader from './ProductDetailsHeader.vue'
|
||||||
import ProductDetailsInfo from './ProductDetailsInfo.vue'
|
import ProductDetailsInfo from './ProductDetailsInfo.vue'
|
||||||
import ProductTopic from './ProductTopic.vue'
|
import ProductTopic from './ProductTopic.vue'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user