From 7cdd9ffd5e1775ef7614a03116c9548d5594e371 Mon Sep 17 00:00:00 2001 From: K <1175047471@qq.com> Date: Fri, 15 Mar 2024 14:37:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?-=20=E8=AE=BE=E5=A4=87=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 2 +- src/api/device-manage/group/index.ts | 64 +++++++++ src/api/device-manage/group/types.ts | 12 ++ .../group/components/BindingDeviceDrawer.vue | 101 +++++++++++++++ .../group/components/GroupFormModal.vue | 86 +++++++++++++ .../group/components/GroupList.vue | 96 ++++++++++++++ .../device-manage/group/components/index.ts | 2 + src/views/device-manage/group/data.ts | 60 +++++++++ src/views/device-manage/group/index.vue | 121 ++++++++++++++++++ 9 files changed, 543 insertions(+), 1 deletion(-) create mode 100644 src/api/device-manage/group/index.ts create mode 100644 src/api/device-manage/group/types.ts create mode 100644 src/views/device-manage/group/components/BindingDeviceDrawer.vue create mode 100644 src/views/device-manage/group/components/GroupFormModal.vue create mode 100644 src/views/device-manage/group/components/GroupList.vue create mode 100644 src/views/device-manage/group/components/index.ts create mode 100644 src/views/device-manage/group/data.ts create mode 100644 src/views/device-manage/group/index.vue diff --git a/src/App.vue b/src/App.vue index e8dc6190..b9caa254 100644 --- a/src/App.vue +++ b/src/App.vue @@ -19,7 +19,7 @@ const componentSize = computed(() => appStore.getComponentSize) useTitle() function transformCellText(props: TransformCellTextProps) { - if (!props.text || !props.text.length) + if (!props.text || (Array.isArray(props.text) && !props.text.length)) return '-' return props.text diff --git a/src/api/device-manage/group/index.ts b/src/api/device-manage/group/index.ts new file mode 100644 index 00000000..a13f6c55 --- /dev/null +++ b/src/api/device-manage/group/index.ts @@ -0,0 +1,64 @@ +import type { DeviceGroup, GetdeviceListByGroupParams } from './types' +import { defHttp } from '@/utils/http/axios' + +export function getDeviceGroupTree() { + return defHttp.get({ + url: '/deviceGroup/tree', + }) +} + +export function getDevicegroupDetail(id: string) { + return defHttp.get({ + url: '/deviceGroup/detail', + params: { + id, + }, + }) +} + +export function getDeviceListByGroup(params: GetdeviceListByGroupParams) { + return defHttp.get({ + url: '/device/pageByGroup', + params, + }) +} + +export function createDeviceGroup(data: Partial) { + return defHttp.post({ + url: '/deviceGroup/save', + data, + }) +} + +export function updateDeviceGroup(data: Partial) { + return defHttp.post({ + url: '/deviceGroup/update', + data, + }) +} + +export function deleteDevicegroup(id: string) { + return defHttp.post({ + url: `/deviceGroup/remove?id=${id}`, + }) +} + +export function bindingDeviceToGroup(deviceGroupId: string, deviceIds: string) { + return defHttp.post({ + url: '/deviceGroup/bindDevice', + data: { + deviceGroupId, + deviceIds, + }, + }) +} + +export function unbindingDeviceFromGroup(deviceGroupId: string, deviceIds: string) { + return defHttp.post({ + url: '/deviceGroup/unbindDevice', + data: { + deviceGroupId, + deviceIds, + }, + }) +} diff --git a/src/api/device-manage/group/types.ts b/src/api/device-manage/group/types.ts new file mode 100644 index 00000000..efec1276 --- /dev/null +++ b/src/api/device-manage/group/types.ts @@ -0,0 +1,12 @@ +export interface DeviceGroup { + id: string + parentId: string + groupName: string + remark: string +} + +export interface GetdeviceListByGroupParams extends PageParam { + groupId?: string + productId?: string + deviceSn?: string +} diff --git a/src/views/device-manage/group/components/BindingDeviceDrawer.vue b/src/views/device-manage/group/components/BindingDeviceDrawer.vue new file mode 100644 index 00000000..fecdfddf --- /dev/null +++ b/src/views/device-manage/group/components/BindingDeviceDrawer.vue @@ -0,0 +1,101 @@ + + + diff --git a/src/views/device-manage/group/components/GroupFormModal.vue b/src/views/device-manage/group/components/GroupFormModal.vue new file mode 100644 index 00000000..996a0daa --- /dev/null +++ b/src/views/device-manage/group/components/GroupFormModal.vue @@ -0,0 +1,86 @@ + + + diff --git a/src/views/device-manage/group/components/GroupList.vue b/src/views/device-manage/group/components/GroupList.vue new file mode 100644 index 00000000..1f2ee7cf --- /dev/null +++ b/src/views/device-manage/group/components/GroupList.vue @@ -0,0 +1,96 @@ + + + + + diff --git a/src/views/device-manage/group/components/index.ts b/src/views/device-manage/group/components/index.ts new file mode 100644 index 00000000..39614a1d --- /dev/null +++ b/src/views/device-manage/group/components/index.ts @@ -0,0 +1,2 @@ +export { default as GroupList } from './GroupList.vue' +export { default as BindingDeviceDrawer } from './BindingDeviceDrawer.vue' diff --git a/src/views/device-manage/group/data.ts b/src/views/device-manage/group/data.ts new file mode 100644 index 00000000..9f255d17 --- /dev/null +++ b/src/views/device-manage/group/data.ts @@ -0,0 +1,60 @@ +import { h } from 'vue' +import { Tag } from 'ant-design-vue' +import type { BasicColumn, FormSchema } from '@/components/Table' +import { useSharedProducts } from '@/views/subscription/list/data' + +export function useColumns(): BasicColumn[] { + const { products } = useSharedProducts() + return [ + { + title: '所属产品', + dataIndex: 'productId', + customRender({ value }) { + return products.value.find(item => item.id === value)?.productName + }, + }, + { + title: '设备序列号', + dataIndex: 'deviceSn', + }, + { + title: '是否在线', + dataIndex: 'isOnline', + customRender({ value }) { + return h(Tag, { + color: value ? 'green' : 'default', + }, () => value ? '在线' : '离线') + }, + }, + ] +} + +export function useSearchFormSchemas(): FormSchema[] { + const { products } = useSharedProducts() + return [ + { + label: '所属产品', + field: 'productId', + component: 'Select', + componentProps: { + options: products as any, + showSearch: true, + fieldNames: { + label: 'productName', + value: 'id', + }, + }, + colProps: { + span: 8, + }, + }, + { + label: '设备序列号', + field: 'deviceSn', + component: 'Input', + colProps: { + span: 8, + }, + }, + ] +} diff --git a/src/views/device-manage/group/index.vue b/src/views/device-manage/group/index.vue new file mode 100644 index 00000000..9452d099 --- /dev/null +++ b/src/views/device-manage/group/index.vue @@ -0,0 +1,121 @@ + + +