diff --git a/src/api/iot/deviceattributetype/index.ts b/src/api/iot/deviceattributetype/index.ts
index 9fd62b9b..ec154893 100644
--- a/src/api/iot/deviceattributetype/index.ts
+++ b/src/api/iot/deviceattributetype/index.ts
@@ -5,6 +5,7 @@ export interface DeviceAttributeTypeVO {
id: number // ID
code: string // 分类编码
name: string // 分类名称
+ sort: number // 分类顺序
remark: string // 备注
}
@@ -31,8 +32,8 @@ export const DeviceAttributeTypeApi = {
},
// 删除采集点分类
- deleteDeviceAttributeType: async (id: number) => {
- return await request.delete({ url: `/iot/device-attribute-type/delete?id=` + id })
+ deleteDeviceAttributeType: async (ids: string) => {
+ return await request.delete({ url: `/iot/device-attribute-type/delete?ids=` + ids })
},
// 导出采集点分类 Excel
@@ -40,8 +41,8 @@ export const DeviceAttributeTypeApi = {
return await request.download({ url: `/iot/device-attribute-type/export-excel`, params })
},
- // 获得采集点分类列表
- getDeviceAttributeTypeList: async () => {
- return await request.get({ url: `/iot/device-attribute-type/list`})
- },
+ // 获得采集点分类列表
+ getDeviceAttributeTypeList: async () => {
+ return await request.get({ url: `/iot/device-attribute-type/list` })
+ },
}
diff --git a/src/views/iot/deviceattributetype/DeviceAttributeTypeForm.vue b/src/views/iot/deviceattributetype/DeviceAttributeTypeForm.vue
index 56604e6a..05666689 100644
--- a/src/views/iot/deviceattributetype/DeviceAttributeTypeForm.vue
+++ b/src/views/iot/deviceattributetype/DeviceAttributeTypeForm.vue
@@ -13,6 +13,9 @@
+
+
+
@@ -40,11 +43,13 @@ const formData = ref({
id: undefined,
code: undefined,
name: undefined,
+ sort: 0,
remark: undefined,
})
const formRules = reactive({
code: [{ required: true, message: '分类编码不能为空', trigger: 'blur' }],
name: [{ required: true, message: '分类名称不能为空', trigger: 'blur' }],
+ sort: [{ required: true, message: '分类顺序不能为空', trigger: 'blur' }],
})
const formRef = ref() // 表单 Ref
@@ -59,6 +64,7 @@ const open = async (type: string, id?: number) => {
formLoading.value = true
try {
formData.value = await DeviceAttributeTypeApi.getDeviceAttributeType(id)
+ ;(formData.value as any).sort = Number((formData.value as any).sort ?? 0)
} finally {
formLoading.value = false
}
@@ -75,6 +81,7 @@ const submitForm = async () => {
formLoading.value = true
try {
const data = formData.value as unknown as DeviceAttributeTypeVO
+ data.sort = Number((data as any).sort ?? 0)
if (formType.value === 'create') {
await DeviceAttributeTypeApi.createDeviceAttributeType(data)
message.success(t('common.createSuccess'))
@@ -96,8 +103,9 @@ const resetForm = () => {
id: undefined,
code: undefined,
name: undefined,
+ sort: 0,
remark: undefined,
}
formRef.value?.resetFields()
}
-
\ No newline at end of file
+
diff --git a/src/views/iot/deviceattributetype/index.vue b/src/views/iot/deviceattributetype/index.vue
index 27b2fd22..bb2c1e2c 100644
--- a/src/views/iot/deviceattributetype/index.vue
+++ b/src/views/iot/deviceattributetype/index.vue
@@ -26,7 +26,7 @@
class="!w-240px"
/>
-
+
+
搜索
重置
@@ -57,6 +57,14 @@
>
新增
+
+ 批量删除
+
-
+
+
+
-
+
([]) // 列表的数据
const total = ref(0) // 列表的总页数
@@ -143,6 +163,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) ?? []
+}
+
/** 查询列表 */
const getList = async () => {
loading.value = true
@@ -174,18 +199,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 DeviceAttributeTypeApi.deleteDeviceAttributeType(id)
+ await DeviceAttributeTypeApi.deleteDeviceAttributeType(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 {