From 6b7a27ace185e579c90fe6d06f6c0e8e688f1567 Mon Sep 17 00:00:00 2001 From: xialiang <1818147@qq.com> Date: Tue, 15 Feb 2022 09:34:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=B9=E8=AE=AD=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/config/config.ts | 2 +- .../pages/examination/certificate/index.tsx | 23 +- .../pages/examination/certificate/person.tsx | 274 +++++------------- admin/src/pages/examination/option/index.tsx | 10 +- .../pages/examinationrules/normal/index.tsx | 2 +- admin/src/pages/training/option/index.tsx | 118 +++++--- admin/src/pages/training/option/service.ts | 30 +- 7 files changed, 200 insertions(+), 259 deletions(-) diff --git a/admin/config/config.ts b/admin/config/config.ts index 7455e69..2416ba9 100644 --- a/admin/config/config.ts +++ b/admin/config/config.ts @@ -212,7 +212,7 @@ export default defineConfig({ name: '制证名单', icon: 'smile', hideInMenu: true, - path: '/examination/certificate/person/:id', + path: '/examination/certificate/person/:id/:accreditation_status', component: './examination/certificate/person', }, ], diff --git a/admin/src/pages/examination/certificate/index.tsx b/admin/src/pages/examination/certificate/index.tsx index a083766..7972932 100644 --- a/admin/src/pages/examination/certificate/index.tsx +++ b/admin/src/pages/examination/certificate/index.tsx @@ -171,7 +171,7 @@ const CourseList: React.FC = () => { { title: '制证状态', - dataIndex: 'status_type', + dataIndex: 'accreditation_status', sorter: false, valueType: 'text', hideInForm: false, @@ -185,23 +185,16 @@ const CourseList: React.FC = () => { return ( // value 和 onchange 会通过 form 自动注入。 ); } return defaultRender(_); }, valueEnum: { - 0: { text: '待报名' }, - 1: { text: '报名中' }, - 2: { text: '待考试' }, - 3: { text: '考试中' }, - 4: { text: '考试完成' }, + 0: { text: '未制证' }, + 1: { text: '已制证' }, }, }, @@ -215,14 +208,14 @@ const CourseList: React.FC = () => { { - history.push('/examination/certificate/person/' + record.examination_id) + history.push('/examination/certificate/person/' + record.examination_id + "/" + record.accreditation_status) }} > 查看名单 , - - 删除 + + 导出名单 , ], }, diff --git a/admin/src/pages/examination/certificate/person.tsx b/admin/src/pages/examination/certificate/person.tsx index b2a4165..39ae0a3 100644 --- a/admin/src/pages/examination/certificate/person.tsx +++ b/admin/src/pages/examination/certificate/person.tsx @@ -1,11 +1,12 @@ import React, { useState, useRef } from 'react'; -import { useRequest } from 'umi'; +import { useRequest, useParams } from 'umi'; import { PlusOutlined, TagsOutlined, UploadOutlined } from '@ant-design/icons'; import { Button, message, Input, Drawer, Modal, Col, Row, Space, Upload, Select } from 'antd'; import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; import type { ProColumns, ActionType } from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table'; -import { BetaSchemaForm, ModalForm, ProFormInstance, ProFormText, ProFormTextArea } from '@ant-design/pro-form'; +import type { ProFormInstance } from '@ant-design/pro-form'; +import { BetaSchemaForm, ModalForm, ProFormText, ProFormTextArea } from '@ant-design/pro-form'; import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions'; import ProDescriptions from '@ant-design/pro-descriptions'; import type { FormValueType } from './components/UpdateForm'; @@ -86,7 +87,7 @@ const CourseList: React.FC = () => { const [createModalVisible, handleCreateModalVisible] = useState(false); const [detailModalVisible, handleDetailModalVisible] = useState(false); const [updateModalVisible, handleUpdateModalVisible] = useState(false); - + const params = useParams(); const actionRef = useRef(); const formRef = useRef(); @@ -103,18 +104,40 @@ const CourseList: React.FC = () => { width: 48, }, { - title: '证件名称', + title: '姓名', + dataIndex: 'person_name', + valueType: 'text', + hideInSearch: true, + }, + { + title: '市', + dataIndex: 'city_name', + valueType: 'text', + hideInSearch: true, + }, + { + title: '区县', + dataIndex: 'district_name', + valueType: 'text', + hideInSearch: true, + }, + { + title: '学校', + dataIndex: 'bureau_name', + valueType: 'text', + hideInSearch: true, + }, + { + title: '证书类型', dataIndex: 'examination_name', valueType: 'text', - hideInTable: false, - hideInForm: false, hideInSearch: true, }, { title: '市', dataIndex: 'city_id', valueType: 'select', - hideInTable: false, + hideInTable: true, hideInForm: false, hideInSearch: false, request: async () => { @@ -124,17 +147,10 @@ const CourseList: React.FC = () => { get_next: 1 }).then(); const option = [] - data?.map((e, i) => { - console.log(e, i); - option.push({ label: e.name, value: e.id }) }) - console.log('city:', data); - // for (let i = 0; i < Items.length; i++) { - // tags.push({ label: Items[i].tag_name, value: Items[i].tag_id }) - // } return option; }, }, @@ -142,98 +158,39 @@ const CourseList: React.FC = () => { title: '区', dataIndex: 'district_id', valueType: 'select', - hideInTable: false, + hideInTable: true, hideInForm: false, hideInSearch: false, dependencies: ['city_id'], request: async (params) => { - console.log(params, 'params::::'); - console.log(formRef, 'formRef::::'); - console.log(formRef.current?.getFieldsValue(['district_id'])); - + if (params.city_id) { + console.log(params, 'params::::'); + console.log(formRef, 'formRef::::'); + console.log(formRef.current?.getFieldsValue(['district_id'])); - const data = await getAsyncOrgTree({ - org_id: params.city_id, - org_type: 2, - get_next: 1 - }).then(); - formRef.current?.setFieldsValue({district_id:{}}) - const option = [] - data?.map((e, i) => { - console.log(e, i); + const data = await getAsyncOrgTree({ + org_id: params.city_id, + org_type: 2, + get_next: 1 + }).then(); + formRef.current?.setFieldsValue({ district_id: {} }) + const option = [] - option.push({ label: e.name, value: e.id }) - }) - console.log('area:', data); + data?.map((e, i) => { + console.log(e, i); - // for (let i = 0; i < Items.length; i++) { - // tags.push({ label: Items[i].tag_name, value: Items[i].tag_id }) - // } - return option; - }, - }, - { - title: '创建日期', - dataIndex: 'create_time', - valueType: 'text', - sorter: false, - hideInTable: false, - hideInForm: false, - hideInSearch: true, - renderText: (val: string) => `${val}`, - }, - { - title: '报名开始日期', - dataIndex: 'apply_start_time', - valueType: 'text', - sorter: false, - hideInTable: false, - hideInForm: false, - hideInSearch: true, - renderText: (val: string) => `${val}`, - }, - { - title: '考试时间', - valueType: 'dateTimeRange', - dataIndex: 'examination_start_time', - sorter: false, - hideInTable: false, - hideInForm: false, - hideInSearch: false, - render: (dom, entity) => { - return entity.examination_start_time + " - " + entity.examination_end_time - }, - }, - { - title: '试卷数量', - dataIndex: 'paper_count', - sorter: false, - valueType: 'text', - hideInForm: false, - hideInSearch: true, - renderText: (val: string) => `${val}`, - }, - { - title: '报考人数', - dataIndex: 'apply_person_count', - sorter: false, - valueType: 'text', - hideInForm: false, - hideInSearch: true, - - renderText: (val: string) => `${val}`, - }, - { - title: '通过人数', - dataIndex: 'apply_person_count', - sorter: false, - valueType: 'text', - hideInForm: false, - hideInSearch: true, + option.push({ label: e.name, value: e.id }) + }) + console.log('area:', data); + // for (let i = 0; i < Items.length; i++) { + // tags.push({ label: Items[i].tag_name, value: Items[i].tag_id }) + // } + return option; + } + }, }, - { title: '制证状态', dataIndex: 'status_type', @@ -241,65 +198,12 @@ const CourseList: React.FC = () => { valueType: 'text', hideInForm: false, hideInSearch: false, - renderFormItem: (_, { type, defaultRender, formItemProps, fieldProps, ...rest }, form) => { - if (type === 'form') { - return null; - } - const status = form.getFieldValue('state'); - if (status !== 'open') { - return ( - // value 和 onchange 会通过 form 自动注入。 - - ); - } - return defaultRender(_); - }, - valueEnum: { - 0: { text: '待报名' }, - 1: { text: '报名中' }, - 2: { text: '待考试' }, - 3: { text: '考试中' }, - 4: { text: '考试完成' }, + render: (dom, entity) => { + return params.accreditation_status == 1 ? "已制证" : "未制证"; }, }, - { - title: '操作', - dataIndex: 'option', - valueType: 'option', - render: (_dom: any, record: React.SetStateAction) => [ - { - //console.log('entity', entity); - setCurrentRow(record); - handleDetailModalVisible(true); - }} - > - 查看 - , - { - handleUpdateModalVisible(true); - setCurrentRow(record); - }} - > - 编辑 - , - - 删除 - , - ], - }, ]; return ( @@ -325,57 +229,33 @@ const CourseList: React.FC = () => { // , // ]} request={async (value) => { - // console.log(value, 'form value') - // const { create_time } = value; - // if (create_time) { - // value.start_time = create_time[0] - // value.end_time = create_time[1] - // } - // const _data = await getExaminationPersonApplyList({ - // ...value, - // page_number: value.current, - // page_size: value.pageSize - // }); - - // return { - // current: _data?.pageNumber, - // data: _data?.table_List, - // pageSize: _data?.pageSize, - // total: _data?.totalRow || 0, - // }; + console.log(value, 'form value') + const { create_time } = value; + if (create_time) { + value.start_time = create_time[0] + value.end_time = create_time[1] + } + const _data = await getExaminationPersonApplyList({ + ...value, + examination_id: params.id, + city_id: value.city_id ? value.city_id : 0, + district_id: value.district_id ? value.district_id : 0, + page_number: value.current, + page_size: value.pageSize + }); + + return { + current: _data?.pageNumber, + data: _data?.table_List, + pageSize: _data?.pageSize, + total: _data?.totalRow || 0, + }; }} // dataSource={list} columns={columns} rowSelection={false} /> - {selectedRowsState?.length > 0 && ( - - 已选择{' '} - - {selectedRowsState.length} - {' '} - 项    - - } - > - - - - )} + { // values.attachment_json.response.file.response.url const params = { ...values, - apply_end_time: values.apply_time[0], - apply_start_time: values.apply_time[1], - course_end_time: values.course_time[0], - course_start_time: values.course_time[1], + 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[0] + examination_end_time: values.examination_time[1] } delete params.apply_time diff --git a/admin/src/pages/examinationrules/normal/index.tsx b/admin/src/pages/examinationrules/normal/index.tsx index ce30577..e39c1c3 100644 --- a/admin/src/pages/examinationrules/normal/index.tsx +++ b/admin/src/pages/examinationrules/normal/index.tsx @@ -146,7 +146,7 @@ const ExaminationRules: React.FC = () => { hideInForm: false, hideInSearch: false, request: async () => { - const { data: Items } = await querySubjectList({page_size: 1000}); + const { data: Items } = await querySubjectList({ page_size: 1000 }); // console.log(Items, ')))'); const sinfo = [] diff --git a/admin/src/pages/training/option/index.tsx b/admin/src/pages/training/option/index.tsx index 1f4a56c..e08ea8f 100644 --- a/admin/src/pages/training/option/index.tsx +++ b/admin/src/pages/training/option/index.tsx @@ -9,7 +9,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 { queryTrainList, saveTrain, removeTrain, queryOrgTree, queryValueByKey } from './service'; +import { queryTrainList, saveTrain, removeTrain, queryOrgTree, queryValueByKey, querySubjectList } from './service'; import type { TableListItem, TableListPagination } from './data'; import { useRequest } from 'umi'; @@ -87,7 +87,7 @@ interface OrgTreeForOaItem { name?: string; } -interface children { +interface children { title?: string; value?: number; children?: children[]; @@ -98,28 +98,28 @@ const getJsonTree = (data: [], pId: number) => { //console.log('getJsonTree..', data) const itemArr = []; for (let i = 0; i < data.length; i++) { - const node: OrgTreeForOaItem = data[i]; - //console.log('f') - //console.log('node?.pId',node?.pId) - //console.log('pId',pId) - if (node?.pId === Number(pId)) { - console.log('if') - const treeNode: children = {}; - treeNode.value = node?.id; - treeNode.title = node?.name; - //treeNode.url = node.url; - //treeNode.icon = node.icon; + const node: OrgTreeForOaItem = data[i]; + //console.log('f') + //console.log('node?.pId',node?.pId) + //console.log('pId',pId) + if (node?.pId === Number(pId)) { + console.log('if') + const treeNode: children = {}; + treeNode.value = node?.id; + treeNode.title = node?.name; + //treeNode.url = node.url; + //treeNode.icon = node.icon; - //eslint-disable-next-line @typescript-eslint/no-unused-vars - treeNode.children = getJsonTree(data, node?.id || 0); - itemArr.push(treeNode); - } + //eslint-disable-next-line @typescript-eslint/no-unused-vars + treeNode.children = getJsonTree(data, node?.id || 0); + itemArr.push(treeNode); + } } return itemArr; }; const TableList: React.FC = () => { - + const { data, loading } = useRequest(() => { return queryValueByKey({}); }); @@ -132,19 +132,20 @@ const TableList: React.FC = () => { const actionRef = useRef(); const [currentRow, setCurrentRow] = useState(); const [selectedRowsState, setSelectedRows] = useState([]); + const [orgTree, setOrgTree] = useState([]); const columns: ProColumns[] = [ { title: '序号', key: 'index', - valueType: 'indexBorder', - render: (text: React.ReactNode, _: any, index: number) =>{ - if(actionRef && actionRef?.current && actionRef?.current?.pageInfo){ - return `${(actionRef?.current?.pageInfo?.current - 1) * (actionRef.current.pageInfo?.pageSize) + (index + 1)}`; - }else{ + valueType: 'indexBorder', + render: (text: React.ReactNode, _: any, index: number) => { + if (actionRef && actionRef?.current && actionRef?.current?.pageInfo) { + return `${(actionRef?.current?.pageInfo?.current - 1) * (actionRef.current.pageInfo?.pageSize) + (index + 1)}`; + } else { return ''; - } - }, + } + }, width: 48, }, { @@ -155,18 +156,19 @@ const TableList: React.FC = () => { { title: '培训对象', valueType: 'treeSelect', - fieldProps: (form, config)=>{ - return {multiple: true} + fieldProps: (form, config) => { + return { multiple: true } }, dataIndex: 'org_names', request: async () => { const Value = await queryValueByKey({}); const orgId = Value['common.org.id'] ? Value['common.org.id'] : 0; // 平台全局设置 const tree = await queryOrgTree({ - org_id: Number(orgId), - org_type: 2, - school_type:1, + org_id: Number(orgId), + org_type: 2, + school_type: 1, }) + setOrgTree(tree.table_List) console.log('orgId', orgId) console.log('tree.table_List', tree.table_List) return getJsonTree(tree.table_List, orgId) @@ -175,6 +177,27 @@ const TableList: React.FC = () => { hideInForm: false, //renderText: (val: string) => `${val}`, }, + { + title: '关联主题', + dataIndex: 'subject_id', + valueType: 'text', + hideInTable: true, + hideInForm: false, + hideInSearch: false, + request: async () => { + const { data: Items } = await querySubjectList({ page_size: 1000 }); + // console.log(Items, ')))'); + + const sinfo = [] + for (let i = 0; i < Items.list.length; i++) { + // console.log(Items.list[i], ">>>") + sinfo.push({ label: Items.list[i].subject_name, value: Items.list[i].subject_id }) + } + console.log(sinfo, 'sinfo'); + + return sinfo; + }, + }, { title: '开始时间', dataIndex: 'start_time', @@ -191,10 +214,11 @@ const TableList: React.FC = () => { }, { title: '培训时间', - valueType: 'dateTimeRange', + valueType: 'dateTimeRange', dataIndex: 'datetime', sorter: false, hideInForm: false, + hideInTable: true, renderText: (val: string) => `${val}`, }, { @@ -245,6 +269,7 @@ const TableList: React.FC = () => { search={{ labelWidth: 120, }} + toolBarRender={() => [ , ]} request={async (value) => { - const _data = await queryTrainList(value); + const _data = await queryTrainList(value); return { current: _data?.page_number, data: _data?.data?.list, @@ -315,11 +340,36 @@ const TableList: React.FC = () => { layoutType="Form" labelCol={{ span: 8 }} wrapperCol={{ span: 12 }} + onFinish={async (values: any) => { // 表单处理 - console.log('columns:', columns); - console.log('values:', values); + //console.log('columns:', columns); + console.log('values1:', values, orgTree); + //return false; + // values.attachment_json.response.file.response.url + const params = { + ...values, + end_time: values.datetime[1], + start_time: values.datetime[0], + } + delete params.datetime + console.log(123); + + const tree = orgTree.filter((item, idx, self) => { + console.log(item.id); + + return (values.org_names.find(item.id) >= 0) + }); + console.log(321); + console.log(tree, 'tree'); + + // delete params.course_time + // delete params.examination_time + + // await handleUpdate(params); + // handleCreateModalVisible(false); + // actionRef.current?.reloadAndRest?.(); }} submitter={{ render: (props, doms) => ( diff --git a/admin/src/pages/training/option/service.ts b/admin/src/pages/training/option/service.ts index f455479..c25a02d 100644 --- a/admin/src/pages/training/option/service.ts +++ b/admin/src/pages/training/option/service.ts @@ -1,6 +1,6 @@ -import { ParamsType } from '@ant-design/pro-table/node_modules/@ant-design/pro-provider'; +import type { ParamsType } from '@ant-design/pro-table/node_modules/@ant-design/pro-provider'; import { request } from 'umi'; -import { TableListItem } from './data'; +import type { TableListItem } from './data'; /** 获取课程列表 GET /dsideal_yy/ypt/careerTraining/train/list */ export async function queryTrainList( @@ -11,7 +11,7 @@ export async function queryTrainList( /** 页面的容量 */ pageSize?: number; }, - options?: { [key: string]: any }, + options?: Record, ) { return request<{ data: TableListItem[]; @@ -30,7 +30,7 @@ export async function queryTrainList( } /** 新建/修改课程 POST /dsideal_yy/ypt/careerTraining/train/save */ -export async function saveTrain(data: { [key: string]: any }, options?: { [key: string]: any }) { +export async function saveTrain(data: Record, options?: Record) { return request('/dsideal_yy/ypt/careerTraining/train/save', { data, method: 'POST', @@ -39,7 +39,7 @@ export async function saveTrain(data: { [key: string]: any }, options?: { [key: } /** 删除课程 POST /dsideal_yy/ypt/careerTraining/train/delete */ -export async function removeTrain(data: { key: number[] }, options?: { [key: string]: any }) { +export async function removeTrain(data: { key: number[] }, options?: Record) { return request>('/dsideal_yy/ypt/careerTraining/train/delete', { data, method: 'POST', @@ -48,7 +48,7 @@ export async function removeTrain(data: { key: number[] }, options?: { [key: str } /** 查看课程(仅仅获取课程详情,不标记浏览量)GET /dsideal_yy/ypt/careerTraining/course/view */ -export async function queryTrainView(data: { [key: string]: any }, options?: { [key: string]: any }) { +export async function queryTrainView(data: Record, options?: Record) { return request('/dsideal_yy/ypt/careerTraining/train/view', { data, method: 'POST', @@ -73,3 +73,21 @@ export async function queryValueByKey( params, }); } + + + +/** + * 获取主题列表 + * http://10.10.14.252:8080/workspace/myWorkspace.do?projectId=382#6426 + * @param params + * @returns + */ +export async function querySubjectList(params: { + page_size: number; + //count: number; +}): Promise<{ data: { list: CardListItemDataType[] } }> { + return request('/dsideal_yy/ypt/careerTraining/subject/listSubject', { + params, + }); +} +