|
|
@@ -1,10 +1,10 @@
|
|
|
-import {PageContainer} from '@ant-design/pro-layout';
|
|
|
-import type {ActionType, ProColumns} from '@jetlinks/pro-table';
|
|
|
-import type {DeviceInstance} from '@/pages/device/Instance/typings';
|
|
|
+import { PageContainer } from '@ant-design/pro-layout';
|
|
|
+import type { ActionType, ProColumns } from '@jetlinks/pro-table';
|
|
|
+import type { DeviceInstance } from '@/pages/device/Instance/typings';
|
|
|
import moment from 'moment';
|
|
|
-import {Badge, Button, Dropdown, Menu, message, Tooltip} from 'antd';
|
|
|
-import {useEffect, useRef, useState} from 'react';
|
|
|
-import {useHistory, useIntl} from 'umi';
|
|
|
+import { Badge, Button, Dropdown, Menu, message, Tooltip } from 'antd';
|
|
|
+import { useEffect, useRef, useState } from 'react';
|
|
|
+import { useHistory, useIntl } from 'umi';
|
|
|
import {
|
|
|
CheckCircleOutlined,
|
|
|
DeleteOutlined,
|
|
|
@@ -16,20 +16,22 @@ import {
|
|
|
StopOutlined,
|
|
|
SyncOutlined,
|
|
|
} from '@ant-design/icons';
|
|
|
-import {model} from '@formily/reactive';
|
|
|
+import { model } from '@formily/reactive';
|
|
|
import Service from '@/pages/device/Instance/service';
|
|
|
-import type {MetadataItem} from '@/pages/device/Product/typings';
|
|
|
+import type { MetadataItem } from '@/pages/device/Product/typings';
|
|
|
import Save from './Save';
|
|
|
import Export from './Export';
|
|
|
import Import from './Import';
|
|
|
import Process from './Process';
|
|
|
import SearchComponent from '@/components/SearchComponent';
|
|
|
-import {PermissionButton, ProTableCard} from '@/components';
|
|
|
+import { PermissionButton, ProTableCard } from '@/components';
|
|
|
import SystemConst from '@/utils/const';
|
|
|
import Token from '@/utils/token';
|
|
|
import DeviceCard from '@/components/ProTableCard/CardItems/device';
|
|
|
-import {getMenuPathByParams, MENUS_CODE} from '@/utils/menu';
|
|
|
-import {useLocation} from '@/hooks';
|
|
|
+import { getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
|
|
|
+import { useLocation } from '@/hooks';
|
|
|
+import { service as deptService } from '@/pages/system/Department';
|
|
|
+import { service as categoryService } from '@/pages/device/Category';
|
|
|
|
|
|
export const statusMap = new Map();
|
|
|
statusMap.set('在线', 'success');
|
|
|
@@ -254,6 +256,98 @@ const Instance = () => {
|
|
|
filterMultiple: false,
|
|
|
},
|
|
|
{
|
|
|
+ dataIndex: 'categoryId',
|
|
|
+ title: '产品分类',
|
|
|
+ valueType: 'treeSelect',
|
|
|
+ hideInTable: true,
|
|
|
+ fieldProps: {
|
|
|
+ fieldNames: {
|
|
|
+ label: 'name',
|
|
|
+ value: 'id',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ request: () =>
|
|
|
+ categoryService
|
|
|
+ .queryTree({
|
|
|
+ paging: false,
|
|
|
+ })
|
|
|
+ .then((resp: any) => resp.result),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: 'productId$product-info',
|
|
|
+ title: '接入方式',
|
|
|
+ valueType: 'select',
|
|
|
+ hideInTable: true,
|
|
|
+ request: () =>
|
|
|
+ service.queryGatewayList().then((resp) =>
|
|
|
+ resp.result.map((item: any) => ({
|
|
|
+ label: item.name,
|
|
|
+ value: `accessId is ${item.id}`,
|
|
|
+ })),
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: 'deviceType',
|
|
|
+ title: '设备类型',
|
|
|
+ valueType: 'select',
|
|
|
+ hideInTable: true,
|
|
|
+ valueEnum: {
|
|
|
+ device: {
|
|
|
+ text: '直连设备',
|
|
|
+ status: 'device',
|
|
|
+ },
|
|
|
+ childrenDevice: {
|
|
|
+ text: '网关子设备',
|
|
|
+ status: 'childrenDevice',
|
|
|
+ },
|
|
|
+ gateway: {
|
|
|
+ text: '网关设备',
|
|
|
+ status: 'gateway',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: 'id$dim-assets',
|
|
|
+ title: '所属部门',
|
|
|
+ valueType: 'treeSelect',
|
|
|
+ hideInTable: true,
|
|
|
+ fieldProps: {
|
|
|
+ fieldNames: {
|
|
|
+ label: 'name',
|
|
|
+ value: 'value',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ request: () =>
|
|
|
+ deptService
|
|
|
+ .queryOrgThree({
|
|
|
+ paging: false,
|
|
|
+ })
|
|
|
+ .then((resp) => {
|
|
|
+ const formatValue = (list: any[]) => {
|
|
|
+ const _list: any[] = [];
|
|
|
+ list.forEach((item) => {
|
|
|
+ if (item.children) {
|
|
|
+ item.children = formatValue(item.children);
|
|
|
+ }
|
|
|
+ _list.push({
|
|
|
+ ...item,
|
|
|
+ value: JSON.stringify({
|
|
|
+ assetType: 'device',
|
|
|
+ targets: [
|
|
|
+ {
|
|
|
+ type: 'org',
|
|
|
+ id: item.id,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ }),
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return _list;
|
|
|
+ };
|
|
|
+ return formatValue(resp.result);
|
|
|
+ }),
|
|
|
+ },
|
|
|
+ {
|
|
|
title: intl.formatMessage({
|
|
|
id: 'pages.table.description',
|
|
|
defaultMessage: '说明',
|