100011797 3 лет назад
Родитель
Сommit
f756bb346d

+ 4 - 4
config/proxy.ts

@@ -9,14 +9,14 @@
 export default {
   dev: {
     '/api': {
-      target: 'http://192.168.32.28:8844/',
-      ws: 'ws://192.168.32.28:8844/',
+      // target: 'http://192.168.32.28:8844/',
+      // ws: 'ws://192.168.32.28:8844/',
       // 开发环境
       // target: 'http://120.79.18.123:8844/',
       // ws: 'ws://120.79.18.123:8844/',
       // 测试环境
-      // target: 'http://120.77.179.54:8844/',
-      // ws: 'ws://120.77.179.54:8844/',
+      target: 'http://120.77.179.54:8844/',
+      ws: 'ws://120.77.179.54:8844/',
       // target: 'http://192.168.32.65:8844/',
       // ws: 'ws://192.168.32.65:8844/',
       //v2环境

+ 24 - 5
src/pages/iot-card/CardManagement/Detail/index.tsx

@@ -1,7 +1,7 @@
 import { PageContainer } from '@ant-design/pro-layout';
 import { Card, Col, Descriptions, Row } from 'antd';
 import { EditOutlined } from '@ant-design/icons';
-import { PermissionButton, DashBoard } from '@/components';
+import { PermissionButton, DashBoard, Ellipsis } from '@/components';
 import SaveModal from '../SaveModal';
 import { useCallback, useEffect, useRef, useState } from 'react';
 import type { CardManagement } from '@/pages/iot-card/CardManagement/typing';
@@ -20,6 +20,7 @@ const DefaultEchartsOptions: any = {
   grid: {
     top: '5%',
     left: '2%',
+    right: '3%',
     bottom: 20,
   },
   tooltip: {
@@ -118,6 +119,7 @@ const CardDetail = () => {
             data: resp.data,
             type: 'line',
             color: '#FBA500',
+            smooth: true,
             areaStyle: {
               color: {
                 type: 'linear',
@@ -159,6 +161,7 @@ const CardDetail = () => {
             data: resp.data,
             type: 'line',
             color: '#498BEF',
+            smooth: true,
             areaStyle: {
               color: {
                 type: 'linear',
@@ -200,6 +203,7 @@ const CardDetail = () => {
             data: resp.data,
             type: 'line',
             color: '#58E1D3',
+            smooth: true,
             areaStyle: {
               color: {
                 type: 'linear',
@@ -229,7 +233,13 @@ const CardDetail = () => {
   const getEcharts = useCallback(
     (data: any) => {
       if (!params.id) return;
-      getData(data.time.start, data.time.end).then((resp) => {
+      let startTime = data.time.start;
+      let endTime = data.time.end;
+      if (data.time.type === 'week' || data.time.type === 'month') {
+        startTime = moment(data.time.start).startOf('days').valueOf();
+        endTime = moment(data.time.end).startOf('days').valueOf();
+      }
+      getData(startTime, endTime).then((resp) => {
         setOptions({
           ...DefaultEchartsOptions,
           xAxis: {
@@ -242,6 +252,7 @@ const CardDetail = () => {
               data: resp.data,
               type: 'line',
               color: '#498BEF',
+              smooth: true,
               areaStyle: {
                 color: {
                   type: 'linear',
@@ -287,7 +298,8 @@ const CardDetail = () => {
             setVisible(false);
           }}
           onOk={() => {
-            getDetail();
+            getDetail(params.id);
+            setVisible(false);
           }}
         />
       )}
@@ -336,7 +348,14 @@ const CardDetail = () => {
                 {detail.residualFlow ? detail.residualFlow.toFixed(2) + ' M' : ''}
               </Descriptions.Item>
               <Descriptions.Item label={'状态'}>{detail?.cardState?.text}</Descriptions.Item>
-              <Descriptions.Item label={'说明'}>{detail?.describe}</Descriptions.Item>
+              <Descriptions.Item label={'说明'}>
+                <Ellipsis
+                  title={detail?.describe}
+                  tooltip={{ placement: 'topLeft' }}
+                  style={{ maxWidth: 300 }}
+                  limitWidth={300}
+                />
+              </Descriptions.Item>
             </Descriptions>
           </Card>
         </Col>
@@ -359,7 +378,7 @@ const CardDetail = () => {
                 onParamsChange={getEcharts}
               />
             </Col>
-            <Col flex={'520px'}>
+            <Col flex={'550px'}>
               <Card>
                 <div
                   style={{

+ 1 - 1
src/pages/iot-card/CardManagement/SaveModal.tsx

@@ -38,7 +38,7 @@ const Save = (props: SaveType) => {
     if (formData) {
       setLoading(true);
       const resp =
-        props.type === 'add' ? await service.add(formData) : await service.update(formData);
+        props.type === 'add' ? await service.add(formData) : await service.edit(formData);
       setLoading(false);
       if (resp.status === 200) {
         message.success('操作成功');

+ 14 - 10
src/pages/iot-card/CardManagement/index.tsx

@@ -49,6 +49,9 @@ const CardManagementNode = () => {
   const intl = useIntl();
   const history = useHistory();
   const location = useLocation();
+  const deleteItems = useRef<any>();
+
+  deleteItems.current = new Map();
 
   useEffect(() => {
     const { state } = location;
@@ -464,9 +467,10 @@ const CardManagementNode = () => {
             popConfirm={{
               title: '确认删除吗?',
               onConfirm: async () => {
-                service.removeCards(bindKeys).then((res) => {
+                service.removeCards([...deleteItems.current.values()]).then((res) => {
                   if (res.status === 200) {
                     setBindKeys([]);
+                    deleteItems.current.clear();
                     message.success('操作成功');
                     actionRef?.current?.reload();
                   }
@@ -578,25 +582,25 @@ const CardManagementNode = () => {
           onChange: (selectedRowKeys) => {
             setBindKeys(selectedRowKeys);
           },
-          onSelect: (_, selected) => {
+          onSelect: (record, selected) => {
             if (selected) {
-              // InstanceModel.selectedRows.set(record.id, record?.state?.value);
+              deleteItems.current.set(record.id, record);
             } else {
-              // InstanceModel.selectedRows.delete(record.id);
+              deleteItems.current.delete(record.id);
             }
-            // setBindKeys([...InstanceModel.selectedRows.keys()]);
+            setBindKeys([...deleteItems.current.keys()]);
           },
           onSelectAll: (selected, _, changeRows) => {
             if (selected) {
-              changeRows.forEach(() => {
-                // InstanceModel.selectedRows.set(item.id, item?.state?.value);
+              changeRows.forEach((item: any) => {
+                deleteItems.current.set(item.id, item);
               });
             } else {
-              changeRows.forEach(() => {
-                // InstanceModel.selectedRows.delete(item.id);
+              changeRows.forEach((item: any) => {
+                deleteItems.current.delete(item.id);
               });
             }
-            // setBindKeys([...InstanceModel.selectedRows.keys()]);
+            setBindKeys([...deleteItems.current.keys()]);
           },
         }}
         headerTitle={[

+ 2 - 0
src/pages/iot-card/CardManagement/service.ts

@@ -8,6 +8,8 @@ const basePath = `/${SystemConst.API_BASE}`;
 class Service extends BaseService<CardManagement> {
   add = (data: any) => this.PATCH(`${this.uri}`, data);
 
+  edit = (data: any) => this.PUT(`${this.uri}/${data.id}`, data);
+
   queryById = (id: string) => request(`${this.uri}/${id}`, { method: 'GET' });
 
   queryDeviceList = (data: any) =>

+ 17 - 3
src/pages/iot-card/Dashboard/index.tsx

@@ -89,6 +89,7 @@ const Dashboard = () => {
             data: resp.data,
             type: 'line',
             color: '#FBA500',
+            smooth: true,
             areaStyle: {
               color: {
                 type: 'linear',
@@ -129,6 +130,7 @@ const Dashboard = () => {
             data: resp.data,
             type: 'line',
             color: '#498BEF',
+            smooth: true,
             areaStyle: {
               color: {
                 type: 'linear',
@@ -169,6 +171,7 @@ const Dashboard = () => {
             data: resp.data,
             type: 'line',
             color: '#58E1D3',
+            smooth: true,
             areaStyle: {
               color: {
                 type: 'linear',
@@ -196,7 +199,14 @@ const Dashboard = () => {
   };
 
   const getEcharts = (data: any) => {
-    getData(data.time.start, data.time.end).then((resp) => {
+    console.log(data);
+    let startTime = data.time.start;
+    let endTime = data.time.end;
+    if (data.time.type === 'week' || data.time.type === 'month') {
+      startTime = moment(data.time.start).startOf('days').valueOf();
+      endTime = moment(data.time.end).startOf('days').valueOf();
+    }
+    getData(startTime, endTime).then((resp) => {
       setOptions({
         ...DefaultEchartsOptions,
         xAxis: {
@@ -209,6 +219,7 @@ const Dashboard = () => {
             data: resp.data,
             type: 'line',
             color: '#498BEF',
+            smooth: true,
             areaStyle: {
               color: {
                 type: 'linear',
@@ -274,7 +285,7 @@ const Dashboard = () => {
       <div className={'iot-card-dash-board'}>
         <DashBoardTopCard>
           <DashBoardTopCard.Item
-            title="日流量消耗"
+            title="日流量消耗"
             value={
               <>
                 <span>{dayTotal.toFixed(2)}</span>
@@ -342,7 +353,10 @@ const Dashboard = () => {
                     defaultValue={[moment().subtract(6, 'days'), moment(new Date(), 'YYYY-MM-DD')]}
                     format={'YYYY-MM-DD'}
                     onChange={(dates) => {
-                      getTopRang(dates?.[0].valueOf(), dates?.[1].valueOf());
+                      getTopRang(
+                        dates?.[0].startOf('days').valueOf(),
+                        dates?.[1].endOf('days').valueOf(),
+                      );
                     }}
                   />
                 }

+ 3 - 2
src/pages/iot-card/Home/index.tsx

@@ -44,6 +44,7 @@ export default () => {
   ]);
 
   const { permission: paltformPermission } = PermissionButton.usePermission('iot-card/Platform');
+  const { permission: cardPermission } = PermissionButton.usePermission('iot-card/CardManagement');
 
   const history = useHistory();
 
@@ -144,14 +145,14 @@ export default () => {
       key: 'EQUIPMENT',
       name: '平台对接',
       english: 'STEP1',
-      auth: !!paltformPermission.update,
+      auth: !!paltformPermission.add,
       url: platformUrl,
     },
     {
       key: 'SCREEN',
       name: '物联卡管理',
       english: 'STEP2',
-      auth: !!cardUrl,
+      auth: !!cardPermission.add,
       url: cardUrl,
       param: { save: true },
     },

+ 1 - 1
src/pages/iot-card/Platform/index.tsx

@@ -194,7 +194,7 @@ const Platform = () => {
                 history.push(url);
               }}
               style={{ marginRight: 12 }}
-              isPermission={permission.update}
+              isPermission={permission.add}
               key="button"
               icon={<PlusOutlined />}
               type="primary"

+ 270 - 0
src/pages/system/Menu/Setting/baseMenu.ts

@@ -3206,4 +3206,274 @@ export default [
       },
     ],
   },
+  //物联卡
+  {
+    path: '5Hpl',
+    sortIndex: 4,
+    level: 1,
+    owner: 'iot',
+    name: '物联卡',
+    code: 'iot-card',
+    url: '/iot-card',
+    icon: 'icon-yunyunjieru',
+    permissions: [],
+    children: [
+      {
+        path: '5Hpl-mghg',
+        sortIndex: 1,
+        level: 1,
+        owner: 'iot',
+        name: '首页',
+        code: 'iot-card/Home',
+        url: '/iot-card/Home',
+        icon: 'icon-shujumoni',
+        status: 1,
+        permissions: [
+          {
+            permission: 'network-flow',
+            actions: ['query'],
+          },
+        ],
+        accessSupport: {
+          text: '不支持',
+          value: 'unsupported',
+        },
+      },
+      {
+        path: '5Hpl-4VFS',
+        sortIndex: 2,
+        level: 1,
+        owner: 'iot',
+        name: '仪表盘',
+        code: 'iot-card/Dashboard',
+        url: '/iot-card/Dashboard',
+        icon: 'icon-keshihua',
+        permissions: [
+          {
+            permission: 'network-flow',
+            actions: ['query'],
+          },
+        ],
+      },
+      {
+        path: '5Hpl-O2m8',
+        sortIndex: 3,
+        level: 2,
+        owner: 'iot',
+        name: '物联卡管理',
+        code: 'iot-card/CardManagement',
+        url: '/iot-card/CardManagement',
+        icon: 'icon-chanpinfenlei',
+        status: 1,
+        permissions: [],
+        buttons: [
+          {
+            id: 'sync',
+            name: '同步',
+            permissions: [
+              {
+                permission: 'IotCard-management',
+                actions: ['sync'],
+              },
+            ],
+          },
+          {
+            id: 'import',
+            name: '导入',
+            permissions: [
+              {
+                permission: 'IotCard-management',
+                actions: ['import'],
+              },
+            ],
+          },
+          {
+            id: 'export',
+            name: '导出',
+            permissions: [
+              {
+                permission: 'IotCard-management',
+                actions: ['export'],
+              },
+            ],
+          },
+          {
+            id: 'delete',
+            name: '删除',
+            permissions: [
+              {
+                permission: 'IotCard-management',
+                actions: ['delete'],
+              },
+            ],
+          },
+          {
+            id: 'active',
+            name: '激活',
+            permissions: [
+              {
+                permission: 'IotCard-management',
+                actions: ['active'],
+              },
+            ],
+          },
+          {
+            id: 'bind',
+            name: '绑定',
+            permissions: [
+              {
+                permission: 'IotCard-management',
+                actions: ['action'],
+              },
+            ],
+          },
+          {
+            id: 'add',
+            name: '新增',
+            permissions: [
+              {
+                permission: 'IotCard-management',
+                actions: ['save'],
+              },
+            ],
+          },
+          {
+            id: 'action',
+            name: '启/禁用',
+            permissions: [
+              {
+                permission: 'IotCard-management',
+                actions: ['save'],
+              },
+            ],
+          },
+          {
+            id: 'update',
+            name: '编辑',
+            permissions: [
+              {
+                permission: 'IotCard-management',
+                actions: ['save'],
+              },
+            ],
+          },
+          {
+            id: 'view',
+            name: '查看',
+            permissions: [
+              {
+                permission: 'IotCard-management',
+                actions: ['query'],
+              },
+            ],
+          },
+        ],
+      },
+      {
+        path: '5Hpl-ZjAG',
+        sortIndex: 4,
+        level: 2,
+        owner: 'iot',
+        name: '充值管理',
+        code: 'iot-card/Recharge',
+        url: '/iot-card/Recharge',
+        icon: 'icon-caidanguanli',
+        status: 1,
+        permissions: [],
+        buttons: [
+          {
+            id: 'pay',
+            name: '充值',
+            permissions: [
+              {
+                permission: 'IotCard-management',
+                actions: ['pay'],
+              },
+            ],
+          },
+        ],
+      },
+      {
+        path: '5Hpl-eS9h',
+        sortIndex: 5,
+        level: 2,
+        owner: 'iot',
+        name: '平台接入',
+        code: 'iot-card/Platform',
+        url: '/iot-card/Platform',
+        icon: 'icon-wangguanzishebei',
+        status: 1,
+        permissions: [],
+        buttons: [
+          {
+            id: 'action',
+            name: '启/禁用',
+            permissions: [
+              {
+                permission: 'platform',
+                actions: ['save'],
+              },
+            ],
+          },
+          {
+            id: 'delete',
+            name: '删除',
+            permissions: [
+              {
+                permission: 'platform',
+                actions: ['delete'],
+              },
+            ],
+          },
+          {
+            id: 'update',
+            name: '编辑',
+            permissions: [
+              {
+                permission: 'platform',
+                actions: ['save'],
+              },
+            ],
+          },
+          {
+            id: 'add',
+            name: '新增',
+            permissions: [
+              {
+                permission: 'platform',
+                actions: ['save'],
+              },
+            ],
+          },
+          {
+            id: 'view',
+            name: '查看',
+            permissions: [
+              {
+                permission: 'platform',
+                actions: ['query'],
+              },
+            ],
+          },
+        ],
+      },
+      {
+        path: '5Hpl-cL34',
+        sortIndex: 6,
+        level: 1,
+        owner: 'iot',
+        name: '操作记录',
+        code: 'iot-card/Record',
+        url: '/iot-card/Record',
+        icon: 'icon-rizhifuwu',
+        status: 1,
+        permissions: [
+          {
+            permission: 'network-card',
+            actions: ['query'],
+          },
+        ],
+      },
+    ],
+  },
 ];