From 41520e5cf9c7372ad3f8784191b201dd8e85f4e8 Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Wed, 23 Feb 2022 10:36:45 +0800 Subject: [PATCH] fix --- admin/src/pages/demo/index.tsx | 46 +++- admin/src/pages/examination/option/index.tsx | 17 +- .../analysis/components/IntroduceRow.tsx | 259 +++++++++--------- admin/src/pages/history/analysis/style.less | 13 + web/src/pages/course/list/index.tsx | 69 +++-- 5 files changed, 245 insertions(+), 159 deletions(-) diff --git a/admin/src/pages/demo/index.tsx b/admin/src/pages/demo/index.tsx index 9220aa7..b3eb0f2 100644 --- a/admin/src/pages/demo/index.tsx +++ b/admin/src/pages/demo/index.tsx @@ -1,5 +1,5 @@ import { DingdingOutlined, UploadOutlined } from '@ant-design/icons'; -import { Button, Card, Steps, Result, Descriptions, Modal, Input, Upload, Popconfirm } from 'antd'; +import { Button, Card, Steps, Result, Descriptions, Modal, Input, Upload, Popconfirm, Menu } from 'antd'; import { Fragment, useEffect, useRef, useState } from 'react'; import { GridContent } from '@ant-design/pro-layout'; import { Line } from '@ant-design/charts'; @@ -10,6 +10,8 @@ import 'react-quill/dist/quill.snow.css' import ProDescriptions, { ProDescriptionsItemProps } from '@ant-design/pro-descriptions'; import { TableListItem } from '../ListTableList2'; import { v4 as uuidv4 } from 'uuid'; +import { queryCourseList } from '../course/option/service'; +import { useRequest } from 'umi'; const { Step } = Steps; @@ -124,18 +126,58 @@ export default () => { {} ]; const [chartData, setChartData] = useState([data, data]); + + const [selectedCourse, setSelectedCourse] = useState(0); + const [menu, setMenu] = useState(); + /** 获取课程数据 */ + const { data: listData } = useRequest(() => { + return queryCourseList(); + }); + + useEffect(() => { + console.log('listData', listData) setInterval(() => { setChartData(Math.random() > 0.5 ? [data, data] : [data2, data2]); }, 1000); - }, []); + + + + /** 生成菜单 */ + const menuItems = []; + + if(listData?.length > 0){ + console.log('push'); + listData.list.forEach((item: {code: number, name: string})=>{ + menuItems.push({item?.course_name}) + }) + } + setMenu( + { + console.log('menu11', value); + console.log('menu11', value.key); + //setMenu({ name: listData[Number(value?.key)]?.name, value: Number(value?.key)}); + }} + > + {menuItems} + + ); + + + + + + }, [listData, selectedCourse]); + const config = { data: chartData, xField: "year", yField: ["value", "count"] }; + return( <> + {menu} { saveInputRef.current.focus({}) diff --git a/admin/src/pages/examination/option/index.tsx b/admin/src/pages/examination/option/index.tsx index 68d63cb..41ca3d7 100644 --- a/admin/src/pages/examination/option/index.tsx +++ b/admin/src/pages/examination/option/index.tsx @@ -33,6 +33,7 @@ const handleUpdate = async (fields: FormValueType) => { try { await updateExamination({ ...fields, + }); hide(); message.success('配置成功'); @@ -523,7 +524,6 @@ const ExaminationList: React.FC = () => { delete params.course_time delete params.examination_time - await handleUpdate(params); handleCreateModalVisible(false); actionRef.current?.reloadAndRest?.(); @@ -596,8 +596,21 @@ const ExaminationList: React.FC = () => { console.log('values', values); //const url = values?.upload[0]?.url?.replace('/dsideal_yy/html/','') || values?.upload[0]?.response?.url; //console.log('url', url) - await handleUpdate({ + const params = { ...values, + apply_start_time: values?.apply_time[0], + apply_end_time: values?.apply_time[1], + course_start_time: values?.course_time[0], + course_end_time: values?.course_time[1], + examination_start_time: values?.examination_time[0], + examination_end_time: values?.examination_time[1] + } + + delete params.apply_time + delete params.course_time + delete params.examination_time + await handleUpdate({ + ...params, examination_id: currentRow?.examination_id, }); handleUpdateModalVisible(false); // 隐藏编辑窗口 diff --git a/admin/src/pages/history/analysis/components/IntroduceRow.tsx b/admin/src/pages/history/analysis/components/IntroduceRow.tsx index 67f8748..267d4a3 100644 --- a/admin/src/pages/history/analysis/components/IntroduceRow.tsx +++ b/admin/src/pages/history/analysis/components/IntroduceRow.tsx @@ -1,6 +1,6 @@ -import { useEffect, useRef, useState } from 'react'; +import { useEffect, useMemo, useRef, useState } from 'react'; import { TinyArea, TinyColumn } from '@ant-design/charts'; -import { Card, Col, Progress, Row, Tabs, DatePicker, Select, Form, Statistic, Button } from 'antd'; +import { Card, Col, Progress, Row, Tabs, DatePicker, Select, Form, Statistic, Button, Spin, Space } from 'antd'; import numeral from 'numeral'; import { ChartCard, Field } from './Charts'; import type { DataItem } from '../data.d'; @@ -12,6 +12,7 @@ import styles from '../style.less'; import ProForm, { ProFormSelect } from '@ant-design/pro-form'; import { useRequest } from 'umi'; const { RangePicker } = DatePicker; + const topColResponsiveProps = { xs: 24, sm: 4, @@ -27,15 +28,16 @@ const layout = { wrapperCol: { span: 16 }, }; - - - const IntroduceRow = ({ loading, visitData }: { loading: boolean; visitData: DataItem[] }) => { const [provinceId, setProvinceId] = useState("100007") const [cityList, setCityList] = useState([]); const [areaList, setAreaList] = useState([]); const [schoolList, setSchoolList] = useState([]); + + const [options, setOptions] = useState([]); + const [fetching, setFetching] = useState(false); + const fetchRef = useRef(0); const { loading: courseBrowseTimesLoading, data: eduUnitList = null } = useRequest(() => getEduUnitList({ random_num: 277470, @@ -55,31 +57,30 @@ const IntroduceRow = ({ loading, visitData }: { loading: boolean; visitData: Dat }); - - - - - - const [form] = Form.useForm(); - - // eslint-disable-next-line react-hooks/exhaustive-deps - useEffect(async () => { - const cityData = await getAsyncOrgTree({ + // 获取市数据 + const { data: cityData, loading: cityLoading } = useRequest(() => { + return getAsyncOrgTree({ org_id: provinceId, org_type: 1, get_next: 1 }); - setCityList(cityData || []); - - - - + },{ + formatResult: (result) => { + console.log('result') + return result; + } + }); + const [form] = Form.useForm(); - }, []); + // eslint-disable-next-line react-hooks/exhaustive-deps + useEffect(() => { + console.log('cityData', cityData); + setCityList(cityData || []); + }, [cityData]); - const getAreaData = async (e) => { + const getAreaData = async (e: any) => { // console.log(e, 'eeeeeeeeeeeee2ee'); const areaData = await getAsyncOrgTree({ org_id: e, @@ -88,17 +89,11 @@ const IntroduceRow = ({ loading, visitData }: { loading: boolean; visitData: Dat }); form.setFieldsValue({ area: 0 }) setAreaList(areaData || []); - - - } - let timeout: NodeJS.Timeout | null; - const getSchoolData = async (e, callback) => { + const getSchoolData = async () => { - // timeout = setTimeout(async () => { - try { - schoolData = await getEduUnitList({ + const schoolData = await getEduUnitList({ random_num: 277470, area_id: provinceId, edu_type: -1, @@ -109,21 +104,8 @@ const IntroduceRow = ({ loading, visitData }: { loading: boolean; visitData: Dat pageSize: 1000, school_type: -1, showPassWord: true, - }).then((e) => { - callback(e.table_List) - console.log(e.table_List); - setSchoolList(e.table_List || []) - - }); - } catch (error) { - // error.message; // "Oops!" - } - - // }, 500); - - // console.log(schoolList, 'schoolList 1'); - - + }) + retrun [{label:'aaaa', value:'1111'},{label:'aaaa', value:'1111'}] } @@ -137,105 +119,116 @@ const IntroduceRow = ({ loading, visitData }: { loading: boolean; visitData: Dat }; - return ( - -
- -
+ /** + * 学校下拉搜索 + * @param value + */ + const handleSearch = async (value: any) => { + if (value >= 'a' && value <= 'z') { + return false; + } + if (value) { + console.log('value::', value) + // setOptions([{ORG_NAME:"aaa", ORG_ID:"111"},{ORG_NAME:"aab", ORG_ID:"112"}]) + const { table_List } = await getEduUnitList({ + random_num: 277470, + area_id: provinceId, + edu_type: -1, + // main_school_id: 200125116, + org_name: value, + org_type: 2, + pageNumber: 1, + pageSize: 1000, + school_type: -1, + showPassWord: true, + }); + setOptions(table_List); + } else { + setOptions([]); + } + }; -
- - - - - - - - - - - - - - - - - - { getAreaData(id) }} + // defaultValue={provinceId} + > + + { + cityList.forEach((e) => { + return + }) + } + + + + + + +