fangmingyue hace 2 años
padre
commit
0b25bec4f5

+ 17
- 10
src/pages/home/components/AssignedCharts.jsx Ver fichero

@@ -70,7 +70,7 @@ export default React.forwardRef((props, ref) => {
70 70
             emphasis: {
71 71
               focus: 'series'
72 72
             },
73
-            data: res.map(x => x.name)
73
+            data: res.map(x => x.value)
74 74
           }
75 75
         ]
76 76
       })
@@ -82,26 +82,33 @@ export default React.forwardRef((props, ref) => {
82 82
       setCondition({
83 83
         num: 7,
84 84
         statType: 'issue_daily',
85
-        startDate: dt[0].format('YY-MM-DD'),
86
-        endDate: dt[1].format('YY-MM-DD'),
85
+        startDate: dt[0].format('YYYY-MM-DD'),
86
+        endDate: dt[1].format('YYYY-MM-DD'),
87 87
       })
88 88
     } else if (typ == 2) {
89 89
       setCondition({
90 90
         num: dt[0].daysInMonth(),
91 91
         statType: 'issue_daily',
92
-        startDate: dt[0].format('YY-MM-DD'),
93
-        endDate: dt[1].format('YY-MM-DD'),
92
+        startDate: dt[0].format('YYYY-MM-DD'),
93
+        endDate: dt[1].format('YYYY-MM-DD'),
94 94
       })
95 95
     } else if (typ == 3) {
96 96
       setCondition({
97
-        num: 365,
98
-        statType: 'issue_daily',
99
-        startDate: dt[0].format('YY-MM-DD'),
100
-        endDate: dt[1].format('YY-MM-DD'),
97
+        num: 12,
98
+        statType: 'issue_monthly',
99
+        startDate: dt[0].format('YYYY-MM'),
100
+        endDate: dt[1].format('YYYY-MM'),
101 101
       })
102
+    } else {
103
+      // setCondition({
104
+      //   num: dt[0].daysInMonth(),
105
+      //   statType: 'issue_daily',
106
+      //   startDate: dt[0].format('YYYY-MM-DD'),
107
+      //   endDate: dt[1].format('YYYY-MM-DD'),
108
+      // })
102 109
     }
103 110
 
104
-    console.log('dt天数', dt[0].format('MM-DD'));
111
+    // console.log('dt天数', dt[0].format('MM-DD'));
105 112
     // console.log('dt,typ', dt, typ);
106 113
   }
107 114
 

+ 1
- 1
src/pages/home/components/EscalationCharts.jsx Ver fichero

@@ -10,7 +10,7 @@ export default (props) => {
10 10
   // const [id, setId] = useState({});
11 11
   const [orgList, setOrgList] = useState([]);
12 12
   const [orgId, setOrgId] = useState();
13
-  console.log('orgId', orgId);
13
+  console.log('orgList', orgList[0]);
14 14
 
15 15
   React.useEffect(() => {
16 16
     getSysOrg({ pageSize: 500 }).then((res) => {

+ 45
- 38
src/pages/home/components/RangeDate.jsx Ver fichero

@@ -1,5 +1,5 @@
1 1
 import React, { useState } from 'react';
2
-import { Card, DatePicker, Button } from 'antd';
2
+import { Radio, DatePicker, Button } from 'antd';
3 3
 import * as dayjs from 'dayjs';
4 4
 // import * as isLeapYear from 'dayjs/plugin/isLeapYear' // 导入插件
5 5
 // import 'dayjs/locale/zh-cn' // 导入本地化语言
@@ -9,53 +9,60 @@ export default (props) => {
9 9
   const { onChange } = props;
10 10
 
11 11
   const { RangePicker } = DatePicker;
12
-  const [date, setDate] = useState([]);
12
+  const [pickerValue, setPickerValue] = useState([]);
13
+  const [dtType, setDtType] = useState('2');
14
+  const dtTypeRef = React.useRef(dtType);
13 15
 
14
-  const updateDate = (dt, typ) => {
15
-    if (onChange) {
16
-      onChange(dt, typ);
17
-    }
18
-
19
-    setDate(dt);
16
+  const onRadioChange = e => {
17
+    const value = e.target.value;
18
+    setDtType(value);
19
+    dtTypeRef.current = value;
20
+    console.log('dtTypeRef.current', dtTypeRef.current)
20 21
   }
21 22
 
22
-  const onWeek = () => {
23
-    updateDate(
24
-      [
25
-        dayjs().startOf('week').add(1, 'day'),
26
-        dayjs().endOf('week').add(1, 'day')
27
-      ],
28
-      1
29
-    );
30
-  }
31 23
 
32
-  const onMonth = () => {
33
-    updateDate([
34
-      dayjs().startOf('month'),
35
-      dayjs().endOf('month')
36
-    ], 2)
37
-    // console.log('fangfang', dayjs().endOf('month'));
24
+  const onPickerChange = e => {
25
+    setPickerValue(e);
38 26
   }
39 27
 
40
-  const onYear = () => {
41
-    updateDate([
42
-      dayjs().startOf('year'),
43
-      dayjs().endOf('year')
44
-    ], 3)
45
-    // console.log('fangfang', dayjs().endOf('year'));
46
-  }
28
+  React.useEffect(() => {
29
+    if (dtType == 1) {
30
+      setPickerValue(
31
+        [
32
+          dayjs().startOf('week').add(1, 'day'),
33
+          dayjs().endOf('week').add(1, 'day')
34
+        ]
35
+      );
36
+    } else if (dtType == 2) {
37
+      setPickerValue([
38
+        dayjs().startOf('month'),
39
+        dayjs().endOf('month')
40
+      ])
41
+    } else if (dtType == 3) {
42
+      setPickerValue([
43
+        dayjs().startOf('year'),
44
+        dayjs().endOf('year')
45
+      ])
46
+    }
47
+  }, [dtType]);
47 48
 
48
-  const onRange = (e) => {
49
-    updateDate(e, 0);
50
-  }
49
+  React.useEffect(() => {
50
+    if (pickerValue && pickerValue.length > 1 && onChange) {
51
+      onChange(pickerValue, dtTypeRef.current);
52
+    }
53
+  }, [pickerValue]);
51 54
 
52
-  // console.log('data', data)
53 55
   return (
54 56
     <div>
55
-      <Button onClick={onWeek} type="text">本周</Button>
56
-      <Button onClick={onMonth} type="text">本月</Button>
57
-      <Button onClick={onYear} type="text">本年</Button>
58
-      <RangePicker onChange={onRange} value={date} />
57
+      <Radio.Group value={dtType} onChange={onRadioChange} style={{ marginRight: '20px' }}>
58
+        <Radio.Button value="1" type="text">本周</Radio.Button>
59
+        <Radio.Button value="2" type="text">本月</Radio.Button>
60
+        <Radio.Button value="3" type="text">本年</Radio.Button>
61
+      </Radio.Group>
62
+      <RangePicker
63
+        value={pickerValue}
64
+        onChange={onPickerChange}
65
+      />
59 66
     </div>
60 67
   )
61 68
 }