|
@@ -2,16 +2,23 @@ import Header from '@/components/Header'
|
|
import { tenderStore } from '@/store/mobx'
|
|
import { tenderStore } from '@/store/mobx'
|
|
import consts from '@/utils/consts'
|
|
import consts from '@/utils/consts'
|
|
import dayjs from 'dayjs'
|
|
import dayjs from 'dayjs'
|
|
-import React, { useEffect, useState } from 'react'
|
|
|
|
|
|
+import React, { useEffect, useState, useMemo } from 'react'
|
|
import { useActivate } from 'react-activation'
|
|
import { useActivate } from 'react-activation'
|
|
import { Link } from 'react-router-dom'
|
|
import { Link } from 'react-router-dom'
|
|
import { apiGetSafeSurvey } from './api'
|
|
import { apiGetSafeSurvey } from './api'
|
|
|
|
+import ColumnChart from './columnChart'
|
|
import './index.scss'
|
|
import './index.scss'
|
|
import PieChart from './pieChart'
|
|
import PieChart from './pieChart'
|
|
-interface charListType {
|
|
|
|
- [key: string]: number
|
|
|
|
|
|
+export interface SafeColumnCharType {
|
|
|
|
+ name: 'rectifyed' | 'submit'
|
|
|
|
+ month: string
|
|
|
|
+ count: number
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+export interface SafeLineChartType {
|
|
|
|
+ month: string
|
|
|
|
+ percentage: number
|
|
|
|
+}
|
|
interface iRectifyData {
|
|
interface iRectifyData {
|
|
auditName: string
|
|
auditName: string
|
|
createTime: string
|
|
createTime: string
|
|
@@ -22,22 +29,25 @@ interface iRectifyData {
|
|
interface iSummaryState {
|
|
interface iSummaryState {
|
|
approvalTotal: number
|
|
approvalTotal: number
|
|
rectifyTotal: number
|
|
rectifyTotal: number
|
|
- rectifyedData: charListType
|
|
|
|
rectifyedTotal: number
|
|
rectifyedTotal: number
|
|
rectifylist: iRectifyData[]
|
|
rectifylist: iRectifyData[]
|
|
- submitData: charListType
|
|
|
|
|
|
+ columnarData: SafeColumnCharType[]
|
|
|
|
+ lineData: SafeLineChartType[]
|
|
}
|
|
}
|
|
const Summary: React.FC<{}> = () => {
|
|
const Summary: React.FC<{}> = () => {
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
initData()
|
|
initData()
|
|
}, [])
|
|
}, [])
|
|
|
|
+ useActivate(() => {
|
|
|
|
+ initData()
|
|
|
|
+ })
|
|
const [ state, setState ] = useState<iSummaryState>({
|
|
const [ state, setState ] = useState<iSummaryState>({
|
|
approvalTotal: 0,
|
|
approvalTotal: 0,
|
|
rectifyTotal: 0,
|
|
rectifyTotal: 0,
|
|
rectifyedTotal: 0,
|
|
rectifyedTotal: 0,
|
|
- rectifyedData: {},
|
|
|
|
rectifylist: [],
|
|
rectifylist: [],
|
|
- submitData: {}
|
|
|
|
|
|
+ columnarData: [],
|
|
|
|
+ lineData: []
|
|
})
|
|
})
|
|
useActivate(() => initData())
|
|
useActivate(() => initData())
|
|
const initData = async () => {
|
|
const initData = async () => {
|
|
@@ -47,6 +57,27 @@ const Summary: React.FC<{}> = () => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ const pieData = useMemo(() => {
|
|
|
|
+ const data = [
|
|
|
|
+ {
|
|
|
|
+ type: '审批中',
|
|
|
|
+ value: state.approvalTotal
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ type: '整改中',
|
|
|
|
+ value: state.rectifyTotal
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ type: '已整改',
|
|
|
|
+ value: state.rectifyedTotal
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ return data
|
|
|
|
+ }, [ state.approvalTotal, state.rectifyTotal, state.rectifyedTotal ])
|
|
|
|
+
|
|
|
|
+ const columnCharData = useMemo(() => {
|
|
|
|
+ return { columnData: state.columnarData, lineData: state.lineData }
|
|
|
|
+ }, [ state.columnarData, state.lineData ])
|
|
const handleDate = (createTime: string) => {
|
|
const handleDate = (createTime: string) => {
|
|
return dayjs(new Date()).diff(dayjs(createTime), 'day') + '天'
|
|
return dayjs(new Date()).diff(dayjs(createTime), 'day') + '天'
|
|
}
|
|
}
|
|
@@ -72,10 +103,15 @@ const Summary: React.FC<{}> = () => {
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div className="pi-flex-treble pi-mg-left-30 card">
|
|
<div className="pi-flex-treble pi-mg-left-30 card">
|
|
- <PieChart></PieChart>
|
|
|
|
|
|
+ <PieChart data={pieData}></PieChart>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <div className="card echarts-column-chart mt-3">
|
|
|
|
+ <h5 className="pi-fz-25 pi-fw-5">整改趋势</h5>
|
|
|
|
+ <div className="pi-width-100P">
|
|
|
|
+ <ColumnChart data={columnCharData}></ColumnChart>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- <div className="card h-400 mt-3"></div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
)
|