From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/views/iot/thingmodel/index.vue | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 176 insertions(+), 0 deletions(-)
diff --git a/src/views/iot/thingmodel/index.vue b/src/views/iot/thingmodel/index.vue
new file mode 100644
index 0000000..3502bfa
--- /dev/null
+++ b/src/views/iot/thingmodel/index.vue
@@ -0,0 +1,176 @@
+<!-- 浜у搧鐨勭墿妯″瀷鍒楄〃 -->
+<template>
+ <ContentWrap>
+ <!-- 鎼滅储宸ヤ綔鏍� -->
+ <el-form
+ ref="queryFormRef"
+ :inline="true"
+ :model="queryParams"
+ class="-mb-15px"
+ label-width="68px"
+ >
+ <el-form-item label="鍔熻兘绫诲瀷" prop="name">
+ <el-select
+ v-model="queryParams.type"
+ class="!w-240px"
+ clearable
+ placeholder="璇烽�夋嫨鍔熻兘绫诲瀷"
+ @change="handleQuery"
+ >
+ <el-option
+ v-for="dict in getIntDictOptions(DICT_TYPE.IOT_THING_MODEL_TYPE)"
+ :key="dict.value"
+ :label="dict.label"
+ :value="dict.value"
+ />
+ </el-select>
+ </el-form-item>
+ <el-form-item>
+ <el-button
+ v-hasPermi="[`iot:thing-model:create`]"
+ plain
+ type="primary"
+ @click="openForm('create')"
+ >
+ <Icon class="mr-5px" icon="ep:plus" />
+ 娣诲姞鍔熻兘
+ </el-button>
+ <el-button v-hasPermi="[`iot:thing-model:query`]" plain type="success" @click="openTSL">
+ TSL
+ </el-button>
+ </el-form-item>
+ </el-form>
+ </ContentWrap>
+
+ <!-- 鍒楄〃 -->
+ <ContentWrap>
+ <el-tabs>
+ <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
+ <el-table-column align="center" label="鍔熻兘绫诲瀷" prop="type">
+ <template #default="scope">
+ <dict-tag :type="DICT_TYPE.IOT_THING_MODEL_TYPE" :value="scope.row.type" />
+ </template>
+ </el-table-column>
+ <el-table-column align="center" label="鍔熻兘鍚嶇О" prop="name" />
+ <el-table-column align="center" label="鏍囪瘑绗�" prop="identifier" />
+ <el-table-column align="center" label="鏁版嵁绫诲瀷" prop="identifier">
+ <template #default="{ row }">
+ {{ getDataTypeOptionsLabel(row.property?.dataType) ?? '-' }}
+ </template>
+ </el-table-column>
+ <el-table-column align="left" label="鏁版嵁瀹氫箟" prop="identifier">
+ <template #default="{ row }">
+ <DataDefinition :data="row" />
+ </template>
+ </el-table-column>
+ <el-table-column align="center" label="鎿嶄綔">
+ <template #default="scope">
+ <el-button
+ v-hasPermi="[`iot:thing-model:update`]"
+ link
+ type="primary"
+ @click="openForm('update', scope.row.id)"
+ >
+ 缂栬緫
+ </el-button>
+ <el-button
+ v-hasPermi="['iot:thing-model:delete']"
+ link
+ type="danger"
+ @click="handleDelete(scope.row.id)"
+ >
+ 鍒犻櫎
+ </el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ <!-- 鍒嗛〉 -->
+ <Pagination
+ v-model:limit="queryParams.pageSize"
+ v-model:page="queryParams.pageNo"
+ :total="total"
+ @pagination="getList"
+ />
+ </el-tabs>
+ </ContentWrap>
+
+ <!-- 琛ㄥ崟寮圭獥锛氭坊鍔�/淇敼 -->
+ <ThingModelForm ref="formRef" @success="getList" />
+ <ThingModelTSL ref="tslRef" />
+</template>
+<script lang="ts" setup>
+import { ThingModelApi, ThingModelData } from '@/api/iot/thingmodel'
+import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
+import ThingModelForm from './ThingModelForm.vue'
+import ThingModelTSL from './ThingModelTSL.vue'
+import { ProductVO } from '@/api/iot/product/product'
+import { getDataTypeOptionsLabel, IOT_PROVIDE_KEY } from '@/views/iot/utils/constants'
+import { DataDefinition } from './components'
+
+defineOptions({ name: 'IoTThingModel' })
+
+const { t } = useI18n() // 鍥介檯鍖�
+const message = useMessage() // 娑堟伅寮圭獥
+
+const loading = ref(true) // 鍒楄〃鐨勫姞杞戒腑
+const list = ref<ThingModelData[]>([]) // 鍒楄〃鐨勬暟鎹�
+const total = ref(0) // 鍒楄〃鐨勬�婚〉鏁�
+const queryParams = reactive({
+ pageNo: 1,
+ pageSize: 10,
+ type: undefined,
+ productId: -1
+})
+
+const queryFormRef = ref() // 鎼滅储鐨勮〃鍗�
+const product = inject<Ref<ProductVO>>(IOT_PROVIDE_KEY.PRODUCT) // 娉ㄥ叆浜у搧淇℃伅
+
+/** 鏌ヨ鍒楄〃 */
+const getList = async () => {
+ loading.value = true
+ try {
+ queryParams.productId = product?.value?.id || -1
+ const data = await ThingModelApi.getThingModelPage(queryParams)
+ list.value = data.list
+ total.value = data.total
+ } finally {
+ loading.value = false
+ }
+}
+
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+ queryParams.pageNo = 1
+ getList()
+}
+
+/** 娣诲姞/淇敼鎿嶄綔 */
+const formRef = ref()
+const openForm = (type: string, id?: number) => {
+ formRef.value.open(type, id)
+}
+
+/** 灞曠ず鐗╂ā鍨� TSL */
+const tslRef = ref()
+const openTSL = () => {
+ tslRef.value?.open()
+}
+
+/** 鍒犻櫎鎸夐挳鎿嶄綔 */
+const handleDelete = async (id: number) => {
+ try {
+ // 鍒犻櫎鐨勪簩娆$‘璁�
+ await message.delConfirm()
+ // 鍙戣捣鍒犻櫎
+ await ThingModelApi.deleteThingModel(id)
+ message.success(t('common.delSuccess'))
+ // 鍒锋柊鍒楄〃
+ await getList()
+ } catch {}
+}
+
+/** 鍒濆鍖� **/
+onMounted(() => {
+ getList()
+})
+</script>
--
Gitblit v1.8.0