Skip to content

Commit

Permalink
#
Browse files Browse the repository at this point in the history
  • Loading branch information
czy21 committed Mar 8, 2024
1 parent f5fb828 commit 8a7e264
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import menus, {MenuModel} from "@/menu";

function recursiveMenu(menus: MenuModel[], parentKey?: string) {
return menus.map((t: MenuModel, i: number) => {
const key = parentKey ? `${parentKey}-${i}` : `${i}`
let key = parentKey ? `${parentKey}-${i}` : `${i}`
if (t.children) {
return (
<Menu.SubMenu
Expand Down
38 changes: 17 additions & 21 deletions src/view/cf-best/cdn/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import stub from "@/init"
import {Button, Form, Table, TreeSelect} from "antd";
import {Button, Cascader, Form, Table} from "antd";

const columns = [
{
Expand Down Expand Up @@ -40,9 +40,7 @@ const columns = [
},
];

const locationOnChange = (value: any, label: any, extra: any) => {
console.log(extra)
}

const CFBestCDN: React.FC = () => {

const [data, setData] = stub.ref.react.useState<any>({})
Expand All @@ -51,11 +49,10 @@ const CFBestCDN: React.FC = () => {

stub.ref.react.useEffect(() => {
stub.api.get("cf-best/cdn/countryTree").then((t: any) => setCountryTree(t.data.data))
handleSearch(query)
}, [query])
handleSearch()
}, [])

const handleSearch = (q?: any) => {
setQuery(q)
const handleSearch = (q: {} = query) => {
stub.api.post("cf-best/cdn/page", stub.ref.lodash.omit(q, "total")).then((t: any) => setData(t.data.data))
}
const [filter] = stub.ref.antd.Form.useForm();
Expand All @@ -67,32 +64,31 @@ const CFBestCDN: React.FC = () => {
autoComplete="off"
layout={"inline"}
>
<Form.Item label={"位置"} name={"location"} style={{width: "20%"}}>
<TreeSelect
showSearch
dropdownStyle={{maxHeight: 400, overflow: 'auto'}}
allowClear
treeCheckable
showCheckedStrategy={"SHOW_PARENT"}
onChange={locationOnChange}
treeData={countryTree}
<Form.Item label={"位置"} name={"locations"} style={{width: "20%"}}>
<Cascader
options={countryTree}
multiple
onChange={(value: any) => setQuery({...query, "locations": value})}
/>
</Form.Item>
<Form.Item>
<Button type="primary" onClick={() => {
console.log(filter.getFieldValue("location"))
}}>
<Button type="primary" onClick={() => handleSearch()}>
查询
</Button>
</Form.Item>
</Form>
<Table dataSource={data.list} columns={columns}
rowKey={(r: any) => r.id}
pagination={{
total: data.total,
current: data.page,
pageSize: data.pageSize,
showTotal: ((total: number, range: [number, number]) => `第 ${range[0]}-${range[1]} 条/总共 ${total} 条`),
onChange: (page, pageSize) => setQuery({...query, "page": page, "pageSize": pageSize})
onChange: (page, pageSize) => {
const q = {...query, "page": page, "pageSize": pageSize}
setQuery(q)
handleSearch(q)
}
}}
/>
</div>
Expand Down

0 comments on commit 8a7e264

Please sign in to comment.