From 5886ebbef99411f6b652db3f285241d9a6c203c8 Mon Sep 17 00:00:00 2001 From: xialiang <1818147@qq.com> Date: Wed, 9 Mar 2022 14:54:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E8=AF=95=E7=BB=B4=E6=8A=A4=E3=80=81?= =?UTF-8?q?=E6=8A=A5=E5=90=8D=E7=AE=A1=E7=90=86=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/examination/registration/index.tsx | 150 ++++++++++++------ admin/src/pages/examination/service.ts | 37 ++--- web/src/components/Footer/index.tsx | 2 +- 3 files changed, 110 insertions(+), 79 deletions(-) diff --git a/admin/src/pages/examination/registration/index.tsx b/admin/src/pages/examination/registration/index.tsx index eb5a3e8..86b1fef 100644 --- a/admin/src/pages/examination/registration/index.tsx +++ b/admin/src/pages/examination/registration/index.tsx @@ -1,6 +1,6 @@ /** 认证考试规则 */ import React, { useState, useRef } from 'react'; -import { useRequest } from 'umi'; +import { useParams, useRequest } from 'umi'; import { ExportOutlined, PlusOutlined, TagsOutlined, UploadOutlined } from '@ant-design/icons'; import { Button, message, Input, Drawer, Modal, Col, Row, Space, Upload } from 'antd'; import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; @@ -11,7 +11,7 @@ import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions'; import ProDescriptions from '@ant-design/pro-descriptions'; import type { FormValueType } from './components/UpdateForm'; import UpdateForm from './components/UpdateForm'; -import { saveRegistration, removeRegistration, queryRegistrationList } from '../service'; +import { saveRegistration, removeRegistration, getExaminationPersonApplyList, getAsyncOrgTree } from '../service'; import type { TableListItem, TableListPagination } from './data'; import type { DataItem } from '@antv/data-set/lib/transform/tag-cloud'; @@ -84,10 +84,19 @@ const handleRemove = async (selectedRows: TableListItem[]) => { }; const RegistrationList: React.FC = () => { + const params = useParams(); /** 更新窗口的弹窗 */ const [createModalVisible, handleCreateModalVisible] = useState(false); const [detailModalVisible, handleDetailModalVisible] = useState(false); const [updateModalVisible, handleUpdateModalVisible] = useState(false); + const [provinceId, setProvinceId] = useState("100007") + const [cityId, setCityId] = useState("0") + const [areaId, setAreaId] = useState("0") + const [exportData, setExportData] = useState({ + examination_id: Number(params.id), + + }) + const actionRef = useRef(); @@ -95,6 +104,16 @@ const RegistrationList: React.FC = () => { const [selectedRowsState, setSelectedRows] = useState([]); + /** 获取列数据初始值 */ + const getInitialValues = (cols: any[], vals: any) => { + const initialValues: any[] = []; + cols.forEach((column: { dataIndex: string }) => { + const key: any = column?.dataIndex || ''; + initialValues.push({ ...column, initialValue: key ? vals[key] : '' }); + }); + return initialValues || []; + }; + /** 列表项定义 */ const columns: ProColumns[] = [ { @@ -105,13 +124,14 @@ const RegistrationList: React.FC = () => { }, { title: '姓名', - dataIndex: 'username', + dataIndex: 'person_name', valueType: 'text', hideInTable: false, hideInForm: false, hideInSearch: true, }, { + title: '市', dataIndex: 'city_name', valueType: 'text', @@ -119,22 +139,56 @@ const RegistrationList: React.FC = () => { hideInTable: false, hideInForm: false, hideInSearch: false, - renderText: (val: string) => `${val}`, + colSize: 1, + request: async (params) => { + + const Items = await getAsyncOrgTree({ + org_id: provinceId, + org_type: 1, + get_next: 1 + }); + console.log('queryCourseListByTag...', Items) + const courses = [{ label: "全部", value: "0" }] + for (let i = 0; i < Items?.length; i++) { + courses.push({ label: Items[i]?.name, value: Items[i]?.id }) + } + console.log(courses, 'courses:::'); + return courses; + }, }, { title: '区县', - dataIndex: 'area_name', + dataIndex: 'district_name', valueType: 'text', sorter: false, hideInTable: false, hideInForm: false, hideInSearch: false, - renderText: (val: string) => `${val}`, + dependencies: ['city_name'], + request: async (params) => { + const courses = [{ label: "全部", value: "0" }] + + if (params.city_name) { + console.log(params, 'params') + const Items = await getAsyncOrgTree({ + org_id: params.city_name, + org_type: 2, + get_next: 1 + }); + console.log('queryCourseListByTag...', Items) + for (let i = 0; i < Items?.length; i++) { + courses.push({ label: Items[i]?.name, value: Items[i]?.id }) + } + console.log(courses, 'courses:::'); + } + return courses; + + }, }, { title: '学校', valueType: 'text', - dataIndex: 'org_name', + dataIndex: 'bureau_name', sorter: false, hideInTable: false, hideInForm: false, @@ -152,44 +206,17 @@ const RegistrationList: React.FC = () => { }, { title: '考试时间', - dataIndex: 'create_time', + dataIndex: 'examination_time', valueType: 'dateRange', sorter: true, - hideInTable: true, + hideInTable: false, hideInForm: true, hideInSearch: false, - - //renderText: (val: string) => `${val}`, - }, - { - title: '操作', - dataIndex: 'option', - valueType: 'option', - render: (_dom: any, record: React.SetStateAction) => [ - { - //console.log('entity', entity); - setCurrentRow(record); - handleDetailModalVisible(true); - }} - > - 查看 - , - { - handleUpdateModalVisible(true); - setCurrentRow(record); - }} - > - 编辑 - , - - 删除 - , - ], + render: (dom, entity) => { + return entity.examination_start_time + "-" + entity.examination_end_time; + }, }, + ]; return ( @@ -202,33 +229,54 @@ const RegistrationList: React.FC = () => { search={{ labelWidth: 120, }} + toolBarRender={() => [ , ]} request={async (value) => { - const _data = await queryRegistrationList(value); + + console.log('value', value); + let examination_time = {} + if (value.examination_time) { + examination_time = { + examination_start_time: value.examination_time[0], + examination_end_time: value.examination_time[1] + } + } + value = { + ...value, + page_number: value.current, + page_size: value.pageSize, + city_id: cityId, + district_id: areaId, + examination_id: params.id, + ...examination_time + } + + // setExportData(value) + const _data = await getExaminationPersonApplyList(value); + return { current: _data?.page_number, - data: _data?.data?.list, + data: _data?.table_List, pageSize: _data?.page_size, total: _data?.total_row || 0, }; }} // dataSource={list} - columns={columns} - rowSelection={{ - onChange: (_, selectedRows) => { - setSelectedRows(selectedRows); - }, - }} + columns={getInitialValues(columns, { city_name: cityId, area_name: areaId })} + // rowSelection={{ + // onChange: (_, selectedRows) => { + // setSelectedRows(selectedRows); + // }, + // }} /* pagination={{ showTotal: (total) => { diff --git a/admin/src/pages/examination/service.ts b/admin/src/pages/examination/service.ts index a93e010..1bdbe8d 100644 --- a/admin/src/pages/examination/service.ts +++ b/admin/src/pages/examination/service.ts @@ -82,10 +82,10 @@ export async function updateExamination(data: Record, options?: Rec } /** 删除考试 */ -export async function removeExamination(data: { key: number[]}, options?: Record) { +export async function removeExamination(data: { key: number[] }, options?: Record) { console.log('data:::', data); return request>('/dsideal_yy/zygh/training/examination/delExamination', { - data: { examination_id: data?.key[0], rules_id: options?.rules_id}, // 当前接口不支持批量操作 + data: { examination_id: data?.key[0], rules_id: options?.rules_id }, // 当前接口不支持批量操作 method: 'POST', requestType: 'form', }); @@ -118,30 +118,11 @@ export async function queryExaminationView(data: Record, options?: }); } -/** 获取报名列表 GET Mock /api/queryRegistrationList */ -export async function queryRegistrationList( - params: { - // query - /** 当前的页码 */ - current?: number; - /** 页面的容量 */ - pageSize?: number; - }, - options?: Record, -) { - return request<{ - data: TableListItem[]; - /** 列表的内容总数 */ - total?: number; - success?: boolean; - }>('/api/getRegistrationList', { - method: 'GET', - params: { - ...params, - }, - ...(options || {}), - }); -} + + + + + /** 获取考试规则列表 GET /dsideal_yy/zygh/training/examination/getExaminationList */ @@ -218,4 +199,6 @@ export async function getAsyncOrgTree(params: { return request('dsideal_yy/org/getAsyncOrgTree', { params, }); -} \ No newline at end of file +} + + diff --git a/web/src/components/Footer/index.tsx b/web/src/components/Footer/index.tsx index ad1be5a..7106b64 100644 --- a/web/src/components/Footer/index.tsx +++ b/web/src/components/Footer/index.tsx @@ -1,7 +1,7 @@ import { DefaultFooter } from '@ant-design/pro-layout'; export default () => { - const defaultMessage = '东北师大理想软件股份有限公司'; + const defaultMessage = '东北师大理想软件股份有限公司
123'; const currentYear = new Date().getFullYear(); return (