feat(): 增加根据行政区划来展示到报率
parent
9c71543438
commit
c1710d36fb
|
|
@ -12,11 +12,12 @@ import dblOption from './dblOption.js'
|
|||
import moment from 'moment';
|
||||
import './index.less'
|
||||
export default function Czrz() {
|
||||
const user = JSON.parse(sessionStorage.getItem('user'))
|
||||
const [newColumns, setNewColumns] = useState([])
|
||||
const [tableList, setTableList] = useState([])
|
||||
const [adcd, setAdcd] = useState('420000000000000')
|
||||
const [adcd, setAdcd] = useState(user?.adcd)
|
||||
const [treeList, setTreeList] = useState([])
|
||||
const [selectedKeys, setSelectedKeys] = useState(['420000000000000'])
|
||||
const [selectedKeys, setSelectedKeys] = useState([user?.adcd])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [SearchBottom, setSearchBottom] = useState(false)
|
||||
const [adcdList, setAdcdList] = useState([])
|
||||
|
|
@ -26,6 +27,7 @@ export default function Czrz() {
|
|||
const [subTableData, setSubTableData] = useState([])
|
||||
const qsoptions = useMemo(() => {
|
||||
if (dayArr.length > 0 && selectedObject) {
|
||||
console.log("adcdList",adcdList);
|
||||
return qsOption(dayArr, selectedObject, hbobj, adcdList)
|
||||
} else {
|
||||
return {}
|
||||
|
|
@ -65,7 +67,7 @@ export default function Czrz() {
|
|||
align: "center",
|
||||
render: (text, record) => (
|
||||
<span>
|
||||
{record.ratelen > 0 ? (record.ratesum * 100 / record.ratelen).toFixed(2) : '-'}%
|
||||
{record?.ratelen > 0 ? (record?.ratesum * 100 / record?.ratelen).toFixed(2) : '-'}%
|
||||
</span>
|
||||
)
|
||||
},
|
||||
|
|
@ -236,8 +238,8 @@ export default function Czrz() {
|
|||
const dayarr = [];
|
||||
const adlist = [];
|
||||
let hbobj = {
|
||||
adcd: '420000000000',
|
||||
adnm: '湖北省',
|
||||
adcd: user?.adcd,
|
||||
adnm: user?.adnm,
|
||||
ratesum: 0,
|
||||
ratelen: 0
|
||||
};
|
||||
|
|
@ -334,7 +336,7 @@ export default function Czrz() {
|
|||
align: "center",
|
||||
render: (text, record) => (
|
||||
<span>
|
||||
{(record[it]?.rate * 100).toFixed(2)}%
|
||||
{(record?.[it]?.rate * 100).toFixed(2)}%
|
||||
</span>
|
||||
)
|
||||
}))
|
||||
|
|
@ -342,12 +344,33 @@ export default function Czrz() {
|
|||
console.log("hbobj", newhbobj);
|
||||
console.log("adlist", adlist);
|
||||
setHbobj(newhbobj);
|
||||
adlist.forEach(item => {
|
||||
if (item.adcd == '420381450000') {
|
||||
item.adcd = "420391000000"
|
||||
}
|
||||
if (item.adcd == '421302000000') {
|
||||
item.adcd = "421303000000"
|
||||
}
|
||||
if (item.adcd == '420821450000') {
|
||||
item.adcd = "420891000000"
|
||||
}
|
||||
})
|
||||
|
||||
setAdcdList(adlist);
|
||||
filterdata(adlist, newhbobj)
|
||||
}
|
||||
|
||||
const filterdata = (adlist, newhbobj) => {
|
||||
let reg = /00000000$/;
|
||||
if (newhbobj.adnm != '湖北省' && newhbobj.adcd.substring(4) == '00000000000') {
|
||||
const cityPrefix = newhbobj.adcd.substring(0, 4);
|
||||
reg = new RegExp(`^(${cityPrefix}\\d{2})(000000)$`);
|
||||
} else if ((newhbobj.adnm != '湖北省' && newhbobj.adcd.substring(6) == '000000000')) {
|
||||
reg = new RegExp(`^${newhbobj.adcd.substring(0,12)}$`)
|
||||
}
|
||||
// else if (newhbobj.adcd = '420381450000000') {
|
||||
// reg = new RegExp(`^${newhbobj.adcd.substring(0,12)}$`)
|
||||
// }
|
||||
const list = [];
|
||||
|
||||
for (let i = 0; i < adlist.length; i++) {
|
||||
|
|
@ -374,20 +397,32 @@ export default function Czrz() {
|
|||
}
|
||||
console.log("list", list);
|
||||
console.log("newhbobj", newhbobj);
|
||||
setTableList([newhbobj, ...list]);
|
||||
const addArr = newhbobj.adnm != '湖北省' ? list : [newhbobj, ...list];
|
||||
setTableList(addArr);
|
||||
}
|
||||
|
||||
const treeData = async (adcd) => {
|
||||
const hbobj = {
|
||||
adcd: "420000000000000",
|
||||
adnm: "湖北省",
|
||||
const treeData = async (user) => {
|
||||
const obj = {
|
||||
adcd: user.adcd,
|
||||
adnm: user.adnm,
|
||||
children: [],
|
||||
}
|
||||
try {
|
||||
const res = await xyt_httpget2(apiurl.ptjs.treeList + adcd)
|
||||
const res = await xyt_httpget2(apiurl.ptjs.treeList + user.adcd)
|
||||
if (res.code == 200) {
|
||||
hbobj.children = res.data;
|
||||
setTreeList([hbobj]);
|
||||
res.data.forEach((item) => {
|
||||
if (item.adnm == '武当山特区') {
|
||||
item.adnm = '武当山'
|
||||
// item.adcd = '420381450000000'
|
||||
}
|
||||
if (item.adnm == '屈家岭管理区') {
|
||||
item.adnm = '屈家岭'
|
||||
// item.adcd = '420821450000000'
|
||||
}
|
||||
});
|
||||
// const filterData = res.data.filter(item => item.adnm !="屈家岭管理区")
|
||||
obj.children =res.data;
|
||||
setTreeList([obj]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
|
@ -433,8 +468,18 @@ export default function Czrz() {
|
|||
try {
|
||||
const res = await xyt_httpget2(apiurl.ptjs.treeList + key)
|
||||
if (res.code == 200) {
|
||||
const filterData =res.data.filter(item => item.adcd != '420891000000000')
|
||||
const results = dataUpdate(filterData)
|
||||
res.data.forEach((item) => {
|
||||
if (item.adnm == '武当山特区') {
|
||||
item.adnm = '武当山'
|
||||
// item.adcd = '420381450000000'
|
||||
}
|
||||
if (item.adnm == '屈家岭管理区') {
|
||||
item.adnm = '屈家岭'
|
||||
// item.adcd = '420821450000000'
|
||||
}
|
||||
});
|
||||
// const filterData =res.data.filter(item => item.adcd != '420891000000000')
|
||||
const results = res.data
|
||||
setTreeList(origin =>
|
||||
updateTreeData(origin, key, results.map(item => ({ ...item, isLeaf: true })))
|
||||
)
|
||||
|
|
@ -463,6 +508,9 @@ export default function Czrz() {
|
|||
}
|
||||
});
|
||||
setTableList([filterData])
|
||||
} else if (adcd == '420821450000000') {
|
||||
const filterData = adcdList.find(item => item.adcd == adcd.substring(0,12));
|
||||
setTableList([filterData])
|
||||
}
|
||||
}
|
||||
setSelectedKeys(keys)
|
||||
|
|
@ -506,7 +554,6 @@ export default function Czrz() {
|
|||
});
|
||||
|
||||
console.log("sellist", sellist);
|
||||
|
||||
setSubTableData(sellist)
|
||||
}
|
||||
// 下载测站离线表
|
||||
|
|
@ -536,9 +583,8 @@ export default function Czrz() {
|
|||
getData(params)
|
||||
}
|
||||
}, [searchVal])
|
||||
|
||||
useEffect(() => {
|
||||
treeData("420000000000000")
|
||||
treeData(user)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -552,7 +598,7 @@ export default function Czrz() {
|
|||
})
|
||||
if (!selectObj) return
|
||||
selectObj.isBl = selectObj?.adcd.substring(4) != '00000000' ? true : false
|
||||
const type = selectObj?.adcd == '420000000000' ? 'province' : 'city'
|
||||
const type = selectObj?.adcd == "420000000000000" ? 'province' : 'city'
|
||||
// const type = 'province';
|
||||
console.log("adcd", subStrAdcd);
|
||||
setSelectObject(selectObj)
|
||||
|
|
@ -563,6 +609,7 @@ export default function Czrz() {
|
|||
|
||||
return (
|
||||
<div className='page'>
|
||||
{user.adcd.substring(4) == '00000000000' &&
|
||||
<div className='left'>
|
||||
<Card>
|
||||
{
|
||||
|
|
@ -571,7 +618,7 @@ export default function Czrz() {
|
|||
treeData={treeList}
|
||||
fieldNames={{ title: 'adnm', key: "adcd" }}
|
||||
loadData={onLoadData}
|
||||
defaultExpandedKeys={["420000000000000"]}
|
||||
defaultExpandedKeys={[user?.adcd]}
|
||||
selectedKeys={selectedKeys}
|
||||
onSelect={onSelect}
|
||||
/> :
|
||||
|
|
@ -580,7 +627,8 @@ export default function Czrz() {
|
|||
|
||||
</Card>
|
||||
</div>
|
||||
<div className='right' style={{ overflow: "auto" }}>
|
||||
}
|
||||
<div className='right' style={{ overflow: "auto",width:user.adcd.substring(4) == '00000000000' ? '80%':'100%' }}>
|
||||
|
||||
<Card style={{ display: 'flex', flexDirection: 'column' }}>
|
||||
<div className='flex' style={{ alignItems: 'center', marginRight: 10, marginBottom: 20 }}>
|
||||
|
|
|
|||
|
|
@ -40,17 +40,16 @@ export default function qsOption(timeList, listObj, hbobj, list) {
|
|||
itemStyle: itemStyle,
|
||||
data: []
|
||||
}
|
||||
// 湖北省
|
||||
// // 湖北省
|
||||
for (let d = chartTimeList.length - 1; d > -1; d--) {
|
||||
let yval = parseFloat((hbobj[chartTimeList[d]]?.rate * 100).toFixed(2));
|
||||
hbSeriseData.push(yval);
|
||||
}
|
||||
|
||||
if (listObj.isBl) {
|
||||
const dd = listObj.adcd.substring(0,4) + '00000000'
|
||||
const cityAdcd = list.find(item => item.adcd == dd);
|
||||
for (let d = chartTimeList.length - 1; d > -1; d--){
|
||||
let yval = parseFloat((cityAdcd[chartTimeList[d]]?.rate * 100).toFixed(2));
|
||||
let yval = parseFloat((cityAdcd?.[chartTimeList[d]]?.rate * 100).toFixed(2));
|
||||
addSerise1.name = cityAdcd?.adnm;
|
||||
addSerise1.data.push(yval);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue