review:【antd】【iot】设备管理相关
This commit is contained in:
@@ -4,6 +4,7 @@ import { requestClient } from '#/api/request';
|
|||||||
|
|
||||||
export namespace IotDeviceApi {
|
export namespace IotDeviceApi {
|
||||||
/** 设备新增/修改 Request VO */
|
/** 设备新增/修改 Request VO */
|
||||||
|
// TODO @haohao:可以降低一些 VO 哈:DeviceSaveReqVO、DeviceRespVO 合并成 Device 就好,类似别的模块
|
||||||
export interface DeviceSaveReqVO {
|
export interface DeviceSaveReqVO {
|
||||||
id?: number; // 设备编号
|
id?: number; // 设备编号
|
||||||
deviceName: string; // 设备名称
|
deviceName: string; // 设备名称
|
||||||
@@ -26,6 +27,7 @@ export namespace IotDeviceApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 设备分页 Request VO */
|
/** 设备分页 Request VO */
|
||||||
|
// TODO @haohao:可以不用 DevicePageReqVO,直接 PageParam 即可,简洁一点。这里的强类型,收益不大;
|
||||||
export interface DevicePageReqVO extends PageParam {
|
export interface DevicePageReqVO extends PageParam {
|
||||||
deviceName?: string; // 设备名称
|
deviceName?: string; // 设备名称
|
||||||
nickname?: string; // 备注名称
|
nickname?: string; // 备注名称
|
||||||
|
|||||||
@@ -24,16 +24,12 @@ interface Props {
|
|||||||
const props = defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
/** 产品列表 */
|
const products = ref<IotProductApi.Product[]>([]); // 产品列表
|
||||||
const products = ref<IotProductApi.Product[]>([]);
|
|
||||||
|
|
||||||
/** 查询参数 */
|
|
||||||
const queryParams = reactive({
|
const queryParams = reactive({
|
||||||
deviceName: '',
|
deviceName: '',
|
||||||
status: undefined as number | undefined,
|
status: undefined as number | undefined,
|
||||||
});
|
}); // 查询参数
|
||||||
|
|
||||||
/** Grid 列定义 */
|
|
||||||
function useGridColumns(): VxeTableGridOptions['columns'] {
|
function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@@ -76,7 +72,6 @@ function useGridColumns(): VxeTableGridOptions['columns'] {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 创建 Grid 实例 */
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid<IotDeviceApi.DeviceRespVO>({
|
const [Grid, gridApi] = useVbenVxeGrid<IotDeviceApi.DeviceRespVO>({
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: useGridColumns(),
|
columns: useGridColumns(),
|
||||||
@@ -164,6 +159,7 @@ onMounted(async () => {
|
|||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<!-- 搜索区域 -->
|
<!-- 搜索区域 -->
|
||||||
|
<!-- TODO @haohao:这个 search 能不能融合到 Grid 里; -->
|
||||||
<div class="mb-4 flex flex-wrap items-center gap-3">
|
<div class="mb-4 flex flex-wrap items-center gap-3">
|
||||||
<Input
|
<Input
|
||||||
v-model:value="queryParams.deviceName"
|
v-model:value="queryParams.deviceName"
|
||||||
@@ -200,12 +196,9 @@ onMounted(async () => {
|
|||||||
|
|
||||||
<!-- 子设备列表 -->
|
<!-- 子设备列表 -->
|
||||||
<Grid>
|
<Grid>
|
||||||
<!-- 所属产品列 -->
|
|
||||||
<template #product="{ row }">
|
<template #product="{ row }">
|
||||||
{{ getProductName(row.productId) }}
|
{{ getProductName(row.productId) }}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 操作列 -->
|
|
||||||
<template #actions="{ row }">
|
<template #actions="{ row }">
|
||||||
<TableAction
|
<TableAction
|
||||||
:actions="[
|
:actions="[
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ async function handleExport() {
|
|||||||
const data = await exportDeviceExcel({
|
const data = await exportDeviceExcel({
|
||||||
...queryParams.value,
|
...queryParams.value,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 999999,
|
pageSize: 999_999,
|
||||||
} as IotDeviceApi.DevicePageReqVO);
|
} as IotDeviceApi.DevicePageReqVO);
|
||||||
downloadFileFromBlobPart({ fileName: '物联网设备.xls', source: data });
|
downloadFileFromBlobPart({ fileName: '物联网设备.xls', source: data });
|
||||||
}
|
}
|
||||||
@@ -414,7 +414,6 @@ onMounted(async () => {
|
|||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 视图切换 -->
|
<!-- 视图切换 -->
|
||||||
<Space :size="4">
|
<Space :size="4">
|
||||||
<Button
|
<Button
|
||||||
@@ -433,8 +432,8 @@ onMounted(async () => {
|
|||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
<!-- 列表视图 -->
|
||||||
<Grid table-title="设备列表" v-show="viewMode === 'list'">
|
<Grid table-title="设备列表" v-show="viewMode === 'list'">
|
||||||
<!-- 所属产品列 -->
|
|
||||||
<template #product="{ row }">
|
<template #product="{ row }">
|
||||||
<a
|
<a
|
||||||
class="cursor-pointer text-primary"
|
class="cursor-pointer text-primary"
|
||||||
@@ -443,8 +442,6 @@ onMounted(async () => {
|
|||||||
{{ products.find((p) => p.id === row.productId)?.name || '-' }}
|
{{ products.find((p) => p.id === row.productId)?.name || '-' }}
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 所属分组列 -->
|
|
||||||
<template #groups="{ row }">
|
<template #groups="{ row }">
|
||||||
<template v-if="row.groupIds?.length">
|
<template v-if="row.groupIds?.length">
|
||||||
<Tag
|
<Tag
|
||||||
@@ -458,8 +455,6 @@ onMounted(async () => {
|
|||||||
</template>
|
</template>
|
||||||
<span v-else>-</span>
|
<span v-else>-</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 操作列 -->
|
|
||||||
<template #actions="{ row }">
|
<template #actions="{ row }">
|
||||||
<TableAction
|
<TableAction
|
||||||
:actions="[
|
:actions="[
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
const data = modalApi.getData<IotDeviceApi.DeviceRespVO>();
|
const data = modalApi.getData<IotDeviceApi.DeviceRespVO>();
|
||||||
if (!data || !data.id) {
|
if (!data || !data.id) {
|
||||||
// 新增:确保 Collapse 折叠
|
// 新增:确保 Collapse 折叠
|
||||||
|
// TODO @haohao:是不是 activeKey 在上面的 112 到 115 就已经处理了哈;
|
||||||
activeKey.value = [];
|
activeKey.value = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -127,6 +128,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
formData.value = await getDevice(data.id);
|
formData.value = await getDevice(data.id);
|
||||||
await formApi.setValues(formData.value);
|
await formApi.setValues(formData.value);
|
||||||
// 如果存在高级字段数据,自动展开 Collapse
|
// 如果存在高级字段数据,自动展开 Collapse
|
||||||
|
// TODO @haohao:默认不用展开哈;
|
||||||
if (
|
if (
|
||||||
formData.value?.nickname ||
|
formData.value?.nickname ||
|
||||||
formData.value?.picUrl ||
|
formData.value?.picUrl ||
|
||||||
|
|||||||
Reference in New Issue
Block a user