fangmingyue 2 年 前
コミット
0b25bec4f5
共有3 個のファイルを変更した63 個の追加49 個の削除を含む
  1. 17
    10
      src/pages/home/components/AssignedCharts.jsx
  2. 1
    1
      src/pages/home/components/EscalationCharts.jsx
  3. 45
    38
      src/pages/home/components/RangeDate.jsx

+ 17
- 10
src/pages/home/components/AssignedCharts.jsx ファイルの表示

70
             emphasis: {
70
             emphasis: {
71
               focus: 'series'
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
       setCondition({
82
       setCondition({
83
         num: 7,
83
         num: 7,
84
         statType: 'issue_daily',
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
     } else if (typ == 2) {
88
     } else if (typ == 2) {
89
       setCondition({
89
       setCondition({
90
         num: dt[0].daysInMonth(),
90
         num: dt[0].daysInMonth(),
91
         statType: 'issue_daily',
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
     } else if (typ == 3) {
95
     } else if (typ == 3) {
96
       setCondition({
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
     // console.log('dt,typ', dt, typ);
112
     // console.log('dt,typ', dt, typ);
106
   }
113
   }
107
 
114
 

+ 1
- 1
src/pages/home/components/EscalationCharts.jsx ファイルの表示

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

+ 45
- 38
src/pages/home/components/RangeDate.jsx ファイルの表示

1
 import React, { useState } from 'react';
1
 import React, { useState } from 'react';
2
-import { Card, DatePicker, Button } from 'antd';
2
+import { Radio, DatePicker, Button } from 'antd';
3
 import * as dayjs from 'dayjs';
3
 import * as dayjs from 'dayjs';
4
 // import * as isLeapYear from 'dayjs/plugin/isLeapYear' // 导入插件
4
 // import * as isLeapYear from 'dayjs/plugin/isLeapYear' // 导入插件
5
 // import 'dayjs/locale/zh-cn' // 导入本地化语言
5
 // import 'dayjs/locale/zh-cn' // 导入本地化语言
9
   const { onChange } = props;
9
   const { onChange } = props;
10
 
10
 
11
   const { RangePicker } = DatePicker;
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
   return (
55
   return (
54
     <div>
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
     </div>
66
     </div>
60
   )
67
   )
61
 }
68
 }