diff --git a/.vscode/settings.json b/.vscode/settings.json
index 54be7d8c..e4ec7cd1 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -86,7 +86,7 @@
"source.fixAll.eslint": "explicit"
},
"[vue]": {
- "editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
+ "editor.defaultFormatter": "Vue.volar"
},
"i18n-ally.localesPaths": ["src/locales"],
"i18n-ally.keystyle": "nested",
diff --git a/src/api/iot/devicemodel/index.ts b/src/api/iot/devicemodel/index.ts
index 77aa1048..566414ab 100644
--- a/src/api/iot/devicemodel/index.ts
+++ b/src/api/iot/devicemodel/index.ts
@@ -32,8 +32,8 @@ export const DeviceModelApi = {
},
// 删除采集设备模型
- deleteDeviceModel: async (id: number) => {
- return await request.delete({ url: `/iot/device-model/delete?id=` + id })
+ deleteDeviceModel: async (ids: string) => {
+ return await request.delete({ url: `/iot/device-model/delete?ids=` + ids })
},
// 复制采集设备模型
@@ -46,8 +46,8 @@ export const DeviceModelApi = {
return await request.download({ url: `/iot/device-model/export-excel`, params })
},
- // 获得采集设备模型列表
- getDeviceModelList: async () => {
- return await request.get({ url: `/iot/device-model/list`})
- },
+ // 获得采集设备模型列表
+ getDeviceModelList: async () => {
+ return await request.get({ url: `/iot/device-model/list` })
+ },
}
diff --git a/src/api/iot/devicemodelattribute/index.ts b/src/api/iot/devicemodelattribute/index.ts
index cbfee946..c589c9cc 100644
--- a/src/api/iot/devicemodelattribute/index.ts
+++ b/src/api/iot/devicemodelattribute/index.ts
@@ -37,8 +37,8 @@ export const DeviceModelAttributeApi = {
},
// 删除采集设备模型-点位管理
- deleteDeviceModelAttribute: async (id: number) => {
- return await request.delete({ url: `/iot/device-model-attribute/delete?id=` + id })
+ deleteDeviceModelAttribute: async (ids: string) => {
+ return await request.delete({ url: `/iot/device-model-attribute/delete?ids=` + ids })
},
// 导出采集设备模型-点位管理 Excel
diff --git a/src/views/iot/devicemodel/components/DeviceModelAttributeForm.vue b/src/views/iot/devicemodel/components/DeviceModelAttributeForm.vue
index 78a2145c..304d050d 100644
--- a/src/views/iot/devicemodel/components/DeviceModelAttributeForm.vue
+++ b/src/views/iot/devicemodel/components/DeviceModelAttributeForm.vue
@@ -12,23 +12,17 @@
-
-
-
-
-
-
+
+
+
+
+
@@ -44,7 +38,7 @@
-
+
\ No newline at end of file
+
diff --git a/src/views/iot/devicemodel/components/ModelAttributeList.vue b/src/views/iot/devicemodel/components/ModelAttributeList.vue
index 58c894f8..fbf560c2 100644
--- a/src/views/iot/devicemodel/components/ModelAttributeList.vue
+++ b/src/views/iot/devicemodel/components/ModelAttributeList.vue
@@ -73,6 +73,14 @@
>
新增
+
+ 批量删除
+
-
+
+
@@ -145,7 +162,7 @@ import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { DeviceModelAttributeApi, DeviceModelAttributeVO } from '@/api/iot/devicemodelattribute'
import DeviceModelAttributeForm from './DeviceModelAttributeForm.vue'
-import {DeviceAttributeTypeApi, DeviceAttributeTypeVO} from "@/api/iot/deviceattributetype";
+import { DeviceAttributeTypeApi, DeviceAttributeTypeVO } from '@/api/iot/deviceattributetype'
const props = defineProps<{
id?: number // id(主表的关联字段)
@@ -156,6 +173,8 @@ const typeList = ref([]) // 列表
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
+const tableRef = ref()
+
const loading = ref(false) // 列表的加载中
const list = ref([]) // 列表的数据
const total = ref(0) // 列表的总页数
@@ -177,6 +196,11 @@ const queryParams = reactive({
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中
+const selectedIds = ref([])
+const handleSelectionChange = (rows: any[]) => {
+ selectedIds.value = rows?.map((row) => row.id).filter((id) => id !== undefined) ?? []
+}
+
/** 监听主表的关联字段的变化,加载对应的子表数据 */
watch(
() => props.id,
@@ -232,18 +256,32 @@ const openForm = (type: string, id?: number) => {
/** 删除按钮操作 */
-const handleDelete = async (id: number) => {
+const buildIdsParam = (ids: number | number[]) => {
+ return Array.isArray(ids) ? ids.join(',') : String(ids)
+}
+
+const handleDelete = async (ids: number | number[]) => {
try {
// 删除的二次确认
await message.delConfirm()
// 发起删除
- await DeviceModelAttributeApi.deleteDeviceModelAttribute(id)
+ await DeviceModelAttributeApi.deleteDeviceModelAttribute(buildIdsParam(ids))
message.success(t('common.delSuccess'))
+ selectedIds.value = []
+ tableRef.value?.clearSelection?.()
// 刷新列表
await getList()
} catch {}
}
+const handleBatchDelete = async () => {
+ if (!selectedIds.value.length) {
+ message.error('请选择需要删除的数据')
+ return
+ }
+ await handleDelete(selectedIds.value)
+}
+
/** 导出按钮操作 */
const handleExport = async () => {
try {
diff --git a/src/views/iot/devicemodel/index.vue b/src/views/iot/devicemodel/index.vue
index 077037a6..79f6ec17 100644
--- a/src/views/iot/devicemodel/index.vue
+++ b/src/views/iot/devicemodel/index.vue
@@ -1,45 +1,20 @@
-
+
-
+
-
+
-
-
-
+
+
+
@@ -64,23 +39,20 @@
/>
-->
- 搜索
- 重置
-
+
+ 搜索
+
+
+ 重置
+
+
新增
-
+
+ 批量删除
+
+
导出
@@ -89,13 +61,9 @@
-
+
+
@@ -104,50 +72,26 @@
-
+
点位
-
+
复制
-
+
编辑
-
+
删除
-
+
@@ -163,7 +107,7 @@