|
|
@@ -7,22 +7,19 @@
|
|
|
:inline="true"
|
|
|
:model="queryParams"
|
|
|
class="-mb-15px"
|
|
|
- label-width="68px"
|
|
|
- >
|
|
|
+ label-width="68px">
|
|
|
<el-form-item label="功能类型" prop="name">
|
|
|
<el-select
|
|
|
v-model="queryParams.type"
|
|
|
class="!w-240px"
|
|
|
clearable
|
|
|
placeholder="请选择功能类型"
|
|
|
- @change="handleQuery"
|
|
|
- >
|
|
|
+ @change="handleQuery">
|
|
|
<el-option
|
|
|
v-for="dict in getIntDictOptions(DICT_TYPE.IOT_THING_MODEL_TYPE)"
|
|
|
:key="dict.value"
|
|
|
:label="dict.label"
|
|
|
- :value="dict.value"
|
|
|
- />
|
|
|
+ :value="dict.value" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
@@ -30,11 +27,19 @@
|
|
|
v-hasPermi="[`iot:thing-model:create`]"
|
|
|
plain
|
|
|
type="primary"
|
|
|
- @click="openForm('create')"
|
|
|
- >
|
|
|
+ @click="openForm('create')">
|
|
|
<Icon class="mr-5px" icon="ep:plus" />
|
|
|
添加功能
|
|
|
</el-button>
|
|
|
+
|
|
|
+ <el-button
|
|
|
+ v-hasPermi="[`iot:thing-model:create`]"
|
|
|
+ plain
|
|
|
+ type="primary"
|
|
|
+ @click="importCommonTing">
|
|
|
+ <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>
|
|
|
@@ -69,16 +74,14 @@
|
|
|
v-hasPermi="[`iot:thing-model:update`]"
|
|
|
link
|
|
|
type="primary"
|
|
|
- @click="openForm('update', scope.row.id)"
|
|
|
- >
|
|
|
+ @click="openForm('update', scope.row.id)">
|
|
|
编辑
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
v-hasPermi="['iot:thing-model:delete']"
|
|
|
link
|
|
|
type="danger"
|
|
|
- @click="handleDelete(scope.row.id)"
|
|
|
- >
|
|
|
+ @click="handleDelete(scope.row.id)">
|
|
|
删除
|
|
|
</el-button>
|
|
|
</template>
|
|
|
@@ -89,17 +92,99 @@
|
|
|
v-model:limit="queryParams.pageSize"
|
|
|
v-model:page="queryParams.pageNo"
|
|
|
:total="total"
|
|
|
- @pagination="getList"
|
|
|
- />
|
|
|
+ @pagination="getList" />
|
|
|
</el-tabs>
|
|
|
</ContentWrap>
|
|
|
|
|
|
<!-- 表单弹窗:添加/修改 -->
|
|
|
<ThingModelForm ref="formRef" @success="getList" />
|
|
|
<ThingModelTSL ref="tslRef" />
|
|
|
+
|
|
|
+ <Dialog v-model="importDialogVisible" title="导入通用物模型" width="1000px">
|
|
|
+ <el-form
|
|
|
+ ref="importQueryFormRef"
|
|
|
+ :inline="true"
|
|
|
+ :model="importQueryParams"
|
|
|
+ class="-mb-15px"
|
|
|
+ label-width="68px">
|
|
|
+ <el-form-item label="功能类型" prop="type">
|
|
|
+ <el-select
|
|
|
+ v-model="importQueryParams.type"
|
|
|
+ class="!w-240px"
|
|
|
+ clearable
|
|
|
+ placeholder="请选择功能类型">
|
|
|
+ <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 label="功能名称" prop="name">
|
|
|
+ <el-input
|
|
|
+ v-model="importQueryParams.name"
|
|
|
+ class="!w-240px"
|
|
|
+ clearable
|
|
|
+ placeholder="请输入功能名称"
|
|
|
+ @keyup.enter="handleImportQuery" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="handleImportQuery">
|
|
|
+ <Icon class="mr-5px" icon="ep:search" />
|
|
|
+ 搜索
|
|
|
+ </el-button>
|
|
|
+ <el-button @click="resetImportQuery">
|
|
|
+ <Icon class="mr-5px" icon="ep:refresh" />
|
|
|
+ 重置
|
|
|
+ </el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <el-table
|
|
|
+ style="margin-top: 15px"
|
|
|
+ v-loading="importLoading"
|
|
|
+ :data="commonThingList"
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
+ :stripe="true"
|
|
|
+ @selection-change="handleImportSelectionChange">
|
|
|
+ <el-table-column type="selection" width="55" />
|
|
|
+ <el-table-column align="center" label="功能类型" prop="type" width="120">
|
|
|
+ <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" min-width="180" />
|
|
|
+ <el-table-column align="center" label="标识符" prop="identifier" min-width="180" />
|
|
|
+ <el-table-column align="center" label="数据类型" min-width="120">
|
|
|
+ <template #default="{ row }">
|
|
|
+ {{ getDataTypeOptionsLabel(row.property?.dataType) ?? '-' }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="left" label="数据定义" min-width="220">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <DataDefinition :data="row" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <div class="mt-15px flex justify-end">
|
|
|
+ <Pagination
|
|
|
+ v-model:limit="importQueryParams.pageSize"
|
|
|
+ v-model:page="importQueryParams.pageNo"
|
|
|
+ :total="importTotal"
|
|
|
+ @pagination="getCommonThingList" />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="closeImportDialog">取消</el-button>
|
|
|
+ <el-button type="primary" :loading="importSubmitting" @click="submitImportCommonThing">
|
|
|
+ 导入
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </Dialog>
|
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
|
-import { ThingModelApi, ThingModelData } from '@/api/iot/thingmodel'
|
|
|
+import { ThingModelApi, ThingModelCommon, ThingModelData } from '@/api/iot/thingmodel'
|
|
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
|
|
import ThingModelForm from './ThingModelForm.vue'
|
|
|
import ThingModelTSL from './ThingModelTSL.vue'
|
|
|
@@ -124,6 +209,20 @@ const queryParams = reactive({
|
|
|
|
|
|
const queryFormRef = ref() // 搜索的表单
|
|
|
const product = inject<Ref<ProductVO>>(IOT_PROVIDE_KEY.PRODUCT) // 注入产品信息
|
|
|
+const importDialogVisible = ref(false)
|
|
|
+const importLoading = ref(false)
|
|
|
+const importSubmitting = ref(false)
|
|
|
+const importTotal = ref(0)
|
|
|
+const commonThingList = ref<ThingModelData[]>([])
|
|
|
+const selectedCommonThingRows = ref<ThingModelData[]>([])
|
|
|
+const importQueryFormRef = ref()
|
|
|
+const importQueryParams = reactive({
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ type: undefined,
|
|
|
+ name: undefined,
|
|
|
+ productId: -1
|
|
|
+})
|
|
|
|
|
|
/** 查询列表 */
|
|
|
const getList = async () => {
|
|
|
@@ -144,6 +243,76 @@ const handleQuery = () => {
|
|
|
getList()
|
|
|
}
|
|
|
|
|
|
+const getCommonThingList = async () => {
|
|
|
+ importLoading.value = true
|
|
|
+ try {
|
|
|
+ const data = await ThingModelCommon.getCommonThingModelPage(importQueryParams)
|
|
|
+ commonThingList.value = data.list
|
|
|
+ importTotal.value = data.total
|
|
|
+ } finally {
|
|
|
+ importLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const handleImportQuery = () => {
|
|
|
+ importQueryParams.pageNo = 1
|
|
|
+ getCommonThingList()
|
|
|
+}
|
|
|
+
|
|
|
+const resetImportQuery = () => {
|
|
|
+ importQueryFormRef.value?.resetFields()
|
|
|
+ importQueryParams.pageNo = 1
|
|
|
+ handleImportQuery()
|
|
|
+}
|
|
|
+
|
|
|
+const handleImportSelectionChange = (selection: ThingModelData[]) => {
|
|
|
+ selectedCommonThingRows.value = selection
|
|
|
+}
|
|
|
+
|
|
|
+const importCommonTing = async () => {
|
|
|
+ importDialogVisible.value = true
|
|
|
+ selectedCommonThingRows.value = []
|
|
|
+ importQueryParams.pageNo = 1
|
|
|
+ await getCommonThingList()
|
|
|
+}
|
|
|
+
|
|
|
+const closeImportDialog = () => {
|
|
|
+ importDialogVisible.value = false
|
|
|
+ selectedCommonThingRows.value = []
|
|
|
+}
|
|
|
+
|
|
|
+const submitImportCommonThing = async () => {
|
|
|
+ if (!selectedCommonThingRows.value.length) {
|
|
|
+ message.warning('请选择要导入的通用物模型')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!product?.value?.id) {
|
|
|
+ message.warning('未获取到当前产品信息')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ importSubmitting.value = true
|
|
|
+ try {
|
|
|
+ await Promise.all(
|
|
|
+ selectedCommonThingRows.value.map(async (item) => {
|
|
|
+ if (!item.id) return
|
|
|
+ const detail = await ThingModelCommon.getCommonThingModel(item.id)
|
|
|
+ await ThingModelApi.createThingModel({
|
|
|
+ ...detail,
|
|
|
+ id: undefined,
|
|
|
+ productId: product.value.id,
|
|
|
+ productKey: product.value.productKey
|
|
|
+ })
|
|
|
+ })
|
|
|
+ )
|
|
|
+ message.success('导入成功')
|
|
|
+ closeImportDialog()
|
|
|
+ await getList()
|
|
|
+ } finally {
|
|
|
+ importSubmitting.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/** 添加/修改操作 */
|
|
|
const formRef = ref()
|
|
|
const openForm = (type: string, id?: number) => {
|