wzyyy 3 yıl önce
ebeveyn
işleme
a28c375f52

+ 1 - 1
package.json

@@ -58,7 +58,7 @@
     "@ant-design/pro-card": "^1.16.2",
     "@ant-design/pro-descriptions": "^1.6.8",
     "@ant-design/pro-form": "^1.18.3",
-    "@ant-design/pro-layout": "^6.27.2",
+    "@ant-design/pro-layout": "6.27.2",
     "@ant-design/pro-list": "^1.21.61",
     "@formily/antd": "2.1.6",
     "@formily/core": "2.1.6",

+ 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('操作成功');

+ 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) =>

+ 16 - 2
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',
@@ -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(),
+                      );
                     }}
                   />
                 }