|
@@ -1,44 +1,117 @@
|
|
|
import Header from '@/components/Header'
|
|
|
-import React from 'react'
|
|
|
-import { RouteProps } from 'react-router'
|
|
|
+import { tenderStore } from '@/store/mobx'
|
|
|
+import consts from '@/utils/consts'
|
|
|
+import dayjs from 'dayjs'
|
|
|
+import React, { useEffect, useState, useMemo } from 'react'
|
|
|
+import { useActivate } from 'react-activation'
|
|
|
+import { Link } from 'react-router-dom'
|
|
|
+import { apiGetqualitySurvey } from './api'
|
|
|
+import ColumnChart from './columnChart'
|
|
|
import './index.scss'
|
|
|
+import PieChart from './pieChart'
|
|
|
+export interface QualityColumnCharType {
|
|
|
+ name: 'rectifyed' | 'submit'
|
|
|
+ month: string
|
|
|
+ count: number
|
|
|
+}
|
|
|
|
|
|
+export interface QualityLineChartType {
|
|
|
+ month: string
|
|
|
+ percentage: number
|
|
|
+}
|
|
|
+interface iRectifyData {
|
|
|
+ auditName: string
|
|
|
+ createTime: string
|
|
|
+ id: string
|
|
|
+ inspectionDetail: string
|
|
|
+ status: number
|
|
|
+}
|
|
|
+interface iSummaryState {
|
|
|
+ approvalTotal: number
|
|
|
+ rectifyTotal: number
|
|
|
+ rectifyedTotal: number
|
|
|
+ rectifylist: iRectifyData[]
|
|
|
+ columnarData: QualityColumnCharType[]
|
|
|
+ lineData: QualityLineChartType[]
|
|
|
+}
|
|
|
+const Summary: React.FC<{}> = () => {
|
|
|
+ const [ state, setState ] = useState<iSummaryState>({
|
|
|
+ approvalTotal: 0,
|
|
|
+ rectifyTotal: 0,
|
|
|
+ rectifyedTotal: 0,
|
|
|
+ rectifylist: [],
|
|
|
+ columnarData: [],
|
|
|
+ lineData: []
|
|
|
+ })
|
|
|
+ useEffect(() => {
|
|
|
+ initData()
|
|
|
+ }, [ tenderStore.bid ])
|
|
|
+ useActivate(() => {
|
|
|
+ initData()
|
|
|
+ })
|
|
|
+ useActivate(() => initData())
|
|
|
+ const initData = async () => {
|
|
|
+ const { data, code = -1 } = await apiGetqualitySurvey(tenderStore.bid)
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ setState({ ...state, ...data })
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-const Summary:React.FC<RouteProps> = (props) => {
|
|
|
- // console.log(props.location?.state)
|
|
|
-
|
|
|
- // useActivate(() => {
|
|
|
- // BidHander()
|
|
|
- // })
|
|
|
- // useEffect(() => {
|
|
|
- // BidHander()
|
|
|
- // }, [])
|
|
|
- // const BidHander = () => {
|
|
|
- // if (Object.keys(props.location?.state as object).length) {
|
|
|
- // // console.log(props.location?.state)
|
|
|
+ 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 { id = '', name = '' } = props.location?.state as {id: string;name: string}
|
|
|
- // id && (tenderStore.saveBidsectionId(id))
|
|
|
- // name && (tenderStore.saveName(name))
|
|
|
- // }
|
|
|
- // }
|
|
|
+ const columnCharData = useMemo(() => {
|
|
|
+ return { columnData: state.columnarData, lineData: state.lineData }
|
|
|
+ }, [ state.columnarData, state.lineData ])
|
|
|
+ const handleDate = (createTime: string) => {
|
|
|
+ return dayjs(new Date()).diff(dayjs(createTime), 'day') + '天'
|
|
|
+ }
|
|
|
return (
|
|
|
<div className="wrap-contaniner">
|
|
|
<Header title="巡检概况"></Header>
|
|
|
<div className="wrap-content m-3 pi-flex-column pi-justify-start">
|
|
|
<div className="pi-justify-start">
|
|
|
<div className="pi-flex-twice card pi-flex-column">
|
|
|
- <header className="card-title">整改中 (23) </header>
|
|
|
+ <header className="card-title">整改中 ({state.rectifyTotal}) </header>
|
|
|
<div>
|
|
|
- <p>检查路面清洗,路面污染严重</p>
|
|
|
- <p>检查路面清洗,路面污染严重</p>
|
|
|
- <p>检查路面清洗,路面污染严重</p>
|
|
|
- <p>检查路面清洗,路面污染严重</p>
|
|
|
+ {state.rectifylist.map(item => {
|
|
|
+ return (
|
|
|
+ <div key={item.id} className="pi-justify-between pi-lh-18 pi-height-18">
|
|
|
+ <Link to={{ pathname: '/console/quality/content/detail/info', state: { saveId: item.id } }}>{item.inspectionDetail}</Link>
|
|
|
+ <div className="pi-align-center">
|
|
|
+ <span className="pi-mg-right-5">{item.auditName}</span>
|
|
|
+ <span className="pi-badge danger">{handleDate(item.createTime)}</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ })}
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div className="pi-flex-treble pi-mg-left-30 card"></div>
|
|
|
+ <div className="pi-flex-treble pi-mg-left-30 card">
|
|
|
+ <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 className="card h-400 mt-3"></div>
|
|
|
</div>
|
|
|
</div>
|
|
|
)
|