diff --git a/package.json b/package.json index 33d725b..9e65b84 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,8 @@ "craco-less": "^3.0.1", "crypto-js": "^4.2.0", "dayjs": "^1.11.12", + "echarts": "^5.6.0", + "echarts-for-react": "^3.0.2", "http-proxy-middleware": "^2.0.6", "moment": "^2.30.1", "ol": "^9.1.0", diff --git a/src/views/Ptjs/Czdbl/dblOption.js b/src/views/Ptjs/Czdbl/dblOption.js new file mode 100644 index 0000000..afaebab --- /dev/null +++ b/src/views/Ptjs/Czdbl/dblOption.js @@ -0,0 +1,96 @@ +export default function dblOption(sellist,selday) { + let itemStyle = { + normal: { + label: { + show: true, + formatter: '{c}%' + }, + labelLine: { + show: true + } + } + } + const seriesData = []; + const serdata = { + type: 'bar', + itemStyle: itemStyle, + data: [] + }; + + const yAxisData = []; + for (let si = 0; si < sellist.length; si++) { + let obj = sellist[si]; + yAxisData.push(obj.adnm); + serdata.data.push(parseFloat((obj[selday]?.rate * 100).toFixed(2))); + } + if (serdata.data.length > 0) { + seriesData.push(serdata); + } + + return { + title: { + text: '日到报率详情', + textStyle: { + fontSize: 16 + }, + left: 'center' + }, + color: ['#1fbcd2', '#a23746'], + tooltip: { + formatter: '{b}, {c}%' + }, + grid: { + left:'12%' + }, + legend: { data: [] }, + toolbox: { + show: true, + orient: 'vertical', + feature: { + dataZoom: { + show: true, + title: { + zoom: '区域缩放', + back: '区域缩放还原', + } + }, + magicType: { + show: true, + title: { + line: '切换为折线图', + bar: '切换为柱状图', + }, + type: ['line', 'bar'] + }, + restore: { + show: true, + title: '还原' + }, + saveAsImage: { + show: true, + title: '保存为图片' + } + } + }, + xAxis: { + type: 'value', + axisLabel: { + formatter: '{value}%' + }, + axisLine: { + show: true, + }, + axisTick: { + show: true, + } + }, + yAxis: { + type: 'category', + data: yAxisData, + axisLabel: { + interval: 0 + } + }, + series: seriesData + } +} \ No newline at end of file diff --git a/src/views/Ptjs/Czdbl/index.js b/src/views/Ptjs/Czdbl/index.js index 11df331..f9a9997 100644 --- a/src/views/Ptjs/Czdbl/index.js +++ b/src/views/Ptjs/Czdbl/index.js @@ -5,6 +5,9 @@ import ToolBottom from './toolBottom.js'; import apiurl from '../../../models/apiurl' import { xyt_httpget2 } from "../../../utils/request" import { resJson } from './res.js'; +import ReactEcharts from 'echarts-for-react'; +import qsOption from './qsOption.js' +import dblOption from './dblOption.js' import moment from 'moment'; export default function Czrz() { const [newColumns, setNewColumns] = useState([]) @@ -15,6 +18,25 @@ export default function Czrz() { const [loading, setLoading] = useState(false) const [SearchBottom, setSearchBottom] = useState(false) const [adcdList, setAdcdList] = useState([]) + const [dayArr, setDayArr] = useState([]) + const [hbobj, setHbobj] = useState() + const [selectedObject, setSelectObject] = useState() + const [subTableData, setSubTableData] = useState([]) + const qsoptions = useMemo(() => { + if (dayArr.length > 0 && selectedObject) { + return qsOption(dayArr, selectedObject, hbobj) + } else { + return {} + } + }, [dayArr, selectedObject, hbobj]) + + const dblOptions = useMemo(() => { + if (subTableData.length > 0 && SearchBottom) { + return dblOption(subTableData, SearchBottom.operTime) + } else { + return {} + } + }, [subTableData, SearchBottom]) const columns = [ { title: '序号', @@ -47,6 +69,16 @@ export default function Czrz() { }, ] const detailsColumns = [ + { + title: '序号', + dataIndex: 'inx', + key: 'inx', + width: 80, + align: "center", + render: (text, record, index) => { + return {index + 1} + } + }, { title: '行政区划', dataIndex: 'adnm', @@ -64,10 +96,10 @@ export default function Czrz() { width: 100, align: "center", render: (text, record) => ( - - {record[SearchBottom?.operTime]?.ontpcnt?.pp} - - ) + + {record[SearchBottom?.operTime]?.ontpcnt?.pp} + + ) }, { title: '离线', @@ -76,10 +108,10 @@ export default function Czrz() { width: 100, align: "center", render: (text, record) => ( - - {record[SearchBottom?.operTime]?.offtpcnt?.pp} - - ) + + {record[SearchBottom?.operTime]?.offtpcnt?.pp} + + ) }, ] }, @@ -93,10 +125,10 @@ export default function Czrz() { width: 100, align: "center", render: (text, record) => ( - - {record[SearchBottom?.operTime]?.ontpcnt?.zz} - - ) + + {record[SearchBottom?.operTime]?.ontpcnt?.zz} + + ) }, { title: '离线', @@ -105,10 +137,10 @@ export default function Czrz() { width: 100, align: "center", render: (text, record) => ( - - {record[SearchBottom?.operTime]?.offtpcnt?.zz} - - ) + + {record[SearchBottom?.operTime]?.offtpcnt?.zz} + + ) }, ] }, @@ -122,10 +154,10 @@ export default function Czrz() { width: 100, align: "center", render: (text, record) => ( - - {record[SearchBottom?.operTime]?.ontpcnt?.wf} - - ) + + {record[SearchBottom?.operTime]?.ontpcnt?.wf} + + ) }, { title: '离线', @@ -134,10 +166,10 @@ export default function Czrz() { width: 100, align: "center", render: (text, record) => ( - - {record[SearchBottom?.operTime]?.offtpcnt?.wf} - - ) + + {record[SearchBottom?.operTime]?.offtpcnt?.wf} + + ) }, ] }, @@ -148,10 +180,10 @@ export default function Czrz() { width: 100, align: "center", render: (text, record) => ( - - {(record[SearchBottom?.operTime].rate * 100).toFixed(2)}% - - ) + + {(record[SearchBottom?.operTime]?.rate * 100).toFixed(2)}% + + ) }, { title: '总在线率', @@ -160,12 +192,12 @@ export default function Czrz() { width: 150, align: "center", render: (text, record) => { - return - { record.ratelen > 0 ? ( record.ratesum * 100 / record.ratelen ).toFixed(2) : '-'}% - + return + {record.ratelen > 0 ? (record.ratesum * 100 / record.ratelen).toFixed(2) : '-'}% + } - + }, ] const newDetailsColumns = useMemo(() => { @@ -178,9 +210,9 @@ export default function Czrz() { align: "center", render: (v, r, i) => {i + 1} } - return [tmObj,...detailsColumns] + return [tmObj, ...detailsColumns] } - },[SearchBottom]) + }, [SearchBottom]) const [searchVal, setSearchVal] = useState(false) const width = useMemo(() => newColumns.reduce((total, cur) => total + (cur.width), 0), [newColumns]); @@ -189,14 +221,15 @@ export default function Czrz() { try { const res = await xyt_httpget2(apiurl.ptjs.czdbl, params) if (res.code == 200) { + res.data['429000000000'] = { ...res.data["429021000000"], adcd: '429000000000' } proccess(res.data) - + } } catch (error) { console.log(error); } } - const [hbobj, setHbobj] = useState() + const proccess = (results) => { const dayarr = []; const adlist = []; @@ -216,7 +249,7 @@ export default function Czrz() { adlist.push(adobj); - if (/00000000$/.test(adcd) || adcd === '429021000000') { + if (/00000000$/.test(adcd)) { for (let k in adobj) { if (!/^[0-9]{4}/.test(k)) { continue; @@ -290,6 +323,7 @@ export default function Czrz() { } }); console.log("dayarr", dayarr); + setDayArr(dayarr) const dayarrColumns = dayarr.map(it => ({ title: it, dataIndex: it, @@ -328,14 +362,15 @@ export default function Czrz() { obj.ratesum += obj[day].rate; obj.ratelen += 1; } - if (reg.test(adcd) || adcd === '429021000000') { + if (reg.test(adcd)) { list.push(obj); } } - if (list.length > 0) { + if (list.length > 0) { setLoading(false) } console.log("list", list); + console.log("newhbobj", newhbobj); setTableList([newhbobj, ...list]); } @@ -389,51 +424,52 @@ export default function Czrz() { console.log(error); } } - const onSelect = (keys,arr) => { - console.log(keys,arr); + const onSelect = (keys, arr) => { + console.log(keys, arr); setSelectedKeys(keys) setAdcd(keys[0]) } - - // 子表格数据 - const [subTableData, setSubTableData] = useState([]) - const filterSondata = (selectedObj, type, adlist, selday) => { + // 子表格数据 + + const filterSondata = (selectedObj, type, adlist, selday) => { const sellist = []; if (selectedObj && type != 'province') { let adreg = new RegExp('^' + selectedObj.adcd.substring(0, 4)); - for (let si = 0; si < adlist.length; si++) { - let obj = adlist[si]; - if ((adreg.test(obj.adcd) && obj.adcd != selectedObj.adcd) || - (selectedObj.adcd === '429021000000' && obj.adcd === '429021000000')) { - sellist.push(obj); + let obj = adlist[si]; + if (selectedObj.isBl) { + if ((adreg.test(obj.adcd) && obj.adcd == selectedObj.adcd)) { + sellist.push(obj); + } + } else if ((adreg.test(obj.adcd) && obj.adcd != selectedObj.adcd)) { + sellist.push(obj); } - } - } - if (selectedObj && type == 'province') { - let adreg = /00000000$/; + } + } - for (let si = 0; si < adlist.length; si++) { - let obj = adlist[si]; + if (selectedObj && type == 'province') { + let adreg = /00000000$/; - if ((adreg.test(obj.adcd) || obj.adcd === '429021000000') && obj.adcd != selectedObj.adcd) { - sellist.push(obj); - } - } - } + for (let si = 0; si < adlist.length; si++) { + let obj = adlist[si]; - sellist.sort(function (o1, o2) { - if (o1[selday].rate > o2[selday].rate) { - return 1; - } else { - return -1; - } + if ((adreg.test(obj.adcd)) && obj.adcd != selectedObj.adcd) { + sellist.push(obj); + } + } + } + sellist.sort(function (o1, o2) { + if (o1[selday]?.rate > o2[selday]?.rate) { + return 1; + } else { + return -1; + } }); - console.log("sellist",sellist); - + console.log("sellist", sellist); + setSubTableData(sellist) - } + } useEffect(() => { if (searchVal) { const params = { @@ -456,64 +492,88 @@ export default function Czrz() { return item } }) - const type = selectObj?.adcd == '420000000000' ? 'province':'city' + selectObj.isBl = selectObj?.adcd.substring(4) != '00000000' ? true : false + const type = selectObj?.adcd == '420000000000' ? 'province' : 'city' // const type = 'province'; - console.log("adcd",subStrAdcd); - - filterSondata(selectObj,type,adcdList,SearchBottom.operTime) + console.log("adcd", subStrAdcd); + setSelectObject(selectObj) + filterSondata(selectObj, type, adcdList, SearchBottom.operTime) } - }, [adcd,SearchBottom,adcdList,hbobj]) - - + }, [adcd, SearchBottom, adcdList, hbobj]) + + return (
+ 测站到报率
+