|
|
@@ -141,13 +141,15 @@
|
|
|
</el-form>
|
|
|
|
|
|
<el-table
|
|
|
+ ref="importTableRef"
|
|
|
style="margin-top: 15px"
|
|
|
v-loading="importLoading"
|
|
|
:data="commonThingList"
|
|
|
+ row-key="id"
|
|
|
:show-overflow-tooltip="true"
|
|
|
:stripe="true"
|
|
|
@selection-change="handleImportSelectionChange">
|
|
|
- <el-table-column type="selection" width="55" />
|
|
|
+ <el-table-column type="selection" width="55" :reserve-selection="true" />
|
|
|
<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" />
|
|
|
@@ -184,6 +186,7 @@
|
|
|
</Dialog>
|
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
|
+import { nextTick } from 'vue'
|
|
|
import { ThingModelApi, ThingModelCommon, ThingModelData } from '@/api/iot/thingmodel'
|
|
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
|
|
import ThingModelForm from './ThingModelForm.vue'
|
|
|
@@ -215,7 +218,9 @@ const importSubmitting = ref(false)
|
|
|
const importTotal = ref(0)
|
|
|
const commonThingList = ref<ThingModelData[]>([])
|
|
|
const selectedCommonThingRows = ref<ThingModelData[]>([])
|
|
|
+const selectedCommonThingMap = ref<Record<number, ThingModelData>>({})
|
|
|
const importQueryFormRef = ref()
|
|
|
+const importTableRef = ref()
|
|
|
const importQueryParams = reactive({
|
|
|
pageNo: 1,
|
|
|
pageSize: 10,
|
|
|
@@ -252,6 +257,9 @@ const getCommonThingList = async () => {
|
|
|
} finally {
|
|
|
importLoading.value = false
|
|
|
}
|
|
|
+
|
|
|
+ await nextTick()
|
|
|
+ restoreImportSelection()
|
|
|
}
|
|
|
|
|
|
const handleImportQuery = () => {
|
|
|
@@ -266,12 +274,36 @@ const resetImportQuery = () => {
|
|
|
}
|
|
|
|
|
|
const handleImportSelectionChange = (selection: ThingModelData[]) => {
|
|
|
- selectedCommonThingRows.value = selection
|
|
|
+ const currentPageIds = new Set(
|
|
|
+ commonThingList.value.map((item) => item.id).filter((id): id is number => typeof id === 'number')
|
|
|
+ )
|
|
|
+
|
|
|
+ currentPageIds.forEach((id) => {
|
|
|
+ delete selectedCommonThingMap.value[id]
|
|
|
+ })
|
|
|
+
|
|
|
+ selection.forEach((item) => {
|
|
|
+ if (typeof item.id === 'number') {
|
|
|
+ selectedCommonThingMap.value[item.id] = item
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ selectedCommonThingRows.value = Object.values(selectedCommonThingMap.value)
|
|
|
+}
|
|
|
+
|
|
|
+const restoreImportSelection = () => {
|
|
|
+ if (!importTableRef.value) return
|
|
|
+
|
|
|
+ commonThingList.value.forEach((item) => {
|
|
|
+ const selected = typeof item.id === 'number' && !!selectedCommonThingMap.value[item.id]
|
|
|
+ importTableRef.value.toggleRowSelection(item, selected)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const importCommonTing = async () => {
|
|
|
importDialogVisible.value = true
|
|
|
selectedCommonThingRows.value = []
|
|
|
+ selectedCommonThingMap.value = {}
|
|
|
importQueryParams.pageNo = 1
|
|
|
await getCommonThingList()
|
|
|
}
|
|
|
@@ -279,6 +311,8 @@ const importCommonTing = async () => {
|
|
|
const closeImportDialog = () => {
|
|
|
importDialogVisible.value = false
|
|
|
selectedCommonThingRows.value = []
|
|
|
+ selectedCommonThingMap.value = {}
|
|
|
+ importTableRef.value?.clearSelection()
|
|
|
}
|
|
|
|
|
|
const submitImportCommonThing = async () => {
|