diff --git a/admin/config/config.ts b/admin/config/config.ts index 9e06a27..15c9f95 100644 --- a/admin/config/config.ts +++ b/admin/config/config.ts @@ -211,17 +211,10 @@ export default defineConfig({ ], }, { - path: '/history', icon: 'table', name: '生涯考试历史', - routes: [ - { - name: '历史统计', - icon: 'smile', - path: '/history/analysis', - component: './history/analysis', - }, - ], + path: '/history/analysis', + component: './history/analysis', }, { path: '/demo', diff --git a/admin/src/pages/examination/certificate/index copy.tsx b/admin/src/pages/examination/certificate/index copy.tsx new file mode 100644 index 0000000..a87a405 --- /dev/null +++ b/admin/src/pages/examination/certificate/index copy.tsx @@ -0,0 +1,415 @@ +import React, { useState, useRef } from 'react'; +import { useRequest } 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, 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'; +import UpdateForm from './components/UpdateForm'; +import { saveCertificate, removeCertificate, queryCertificateList } from '../service'; +import type { TableListItem, TableListPagination } from '../data'; +import type { DataItem } from '@antv/data-set/lib/transform/tag-cloud'; + +/** + * 添加证书 + * + * @param fields + */ + +const handleAdd = async (fields: TableListItem) => { + const hide = message.loading('正在添加'); + + try { + await saveCourse({ ...fields }); + hide(); + message.success('添加成功'); + return true; + } catch (error) { + hide(); + message.error('添加失败请重试!'); + return false; + } +}; + +/** + * 更新证书 + * + * @param fields + */ +const handleUpdate = async (fields: FormValueType, currentRow?: TableListItem) => { + const hide = message.loading('正在配置'); + + try { + await saveCourse({ + ...currentRow, + ...fields, + }); + hide(); + message.success('配置成功'); + return true; + } catch (error) { + hide(); + message.error('配置失败请重试!'); + return false; + } +}; + +/** + * 删除证书 + * + * @param selectedRows + */ +const handleRemove = async (selectedRows: TableListItem[]) => { + const hide = message.loading('正在删除'); + if (!selectedRows) return true; + + try { + await removeCourse({ + key: selectedRows.map((row) => row.key), + }); + hide(); + message.success('删除成功,即将刷新'); + return true; + } catch (error) { + hide(); + message.error('删除失败,请重试'); + return false; + } +}; + +const CourseList: React.FC = () => { + /** 更新窗口的弹窗 */ + const [createModalVisible, handleCreateModalVisible] = useState(false); + const [detailModalVisible, handleDetailModalVisible] = useState(false); + const [updateModalVisible, handleUpdateModalVisible] = useState(false); + + + const actionRef = useRef(); + const [currentRow, setCurrentRow] = useState(); + const [selectedRowsState, setSelectedRows] = useState([]); + + /** 列表项定义 */ + const columns: ProColumns[] = [ + { + title: '序号', + key: 'index', + valueType: 'indexBorder', + width: 48, + }, + { + title: '证件名称', + dataIndex: 'examination_name', + valueType: 'text', + hideInTable: false, + hideInForm: false, + hideInSearch: false, + }, + { + 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, + + }, + + { + title: '制证状态', + dataIndex: 'status_type', + sorter: false, + 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: '考试完成' }, + }, + }, + + + { + title: '操作', + dataIndex: 'option', + valueType: 'option', + render: (_dom: any, record: React.SetStateAction) => [ + { + //console.log('entity', entity); + setCurrentRow(record); + handleDetailModalVisible(true); + }} + > + 查看 + , + { + handleUpdateModalVisible(true); + setCurrentRow(record); + }} + > + 编辑 + , + + 删除 + , + ], + }, + ]; + + return ( + + + headerTitle={false} + actionRef={actionRef} + rowKey="course_id" + options={false} + search={{ + labelWidth: 120, + }} + // toolBarRender={() => [ + // , + // ]} + 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 queryCertificateList(); + + 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} + {' '} + 项    + + } + > + + + + )} + { + setCurrentRow(undefined); // 设置当前行 + handleDetailModalVisible(false); + }} + footer={null} + centered + >{console.log('currentRow', currentRow)} + {currentRow?.name && ( + + column={2} + /* title={currentRow?.name} */ + dataSource={currentRow} + /* + request={async () => ({ + data: currentRow || {}, + })}*/ + params={{ + id: currentRow?.course_id, + }} + columns={ + columns + //columns.slice(0, columns.length - 1) as ProDescriptionsItemProps[] + } + /> + )} + + + { + handleCreateModalVisible(false); + }} + footer={null} + > + + layout="horizontal" + layoutType="Form" + labelCol={{ span: 8 }} + wrapperCol={{ span: 12 }} + onFinish={async (values: any) => { + // 表单处理 + console.log('columns:', columns); + console.log('values:', values); + + }} + submitter={{ + render: (props, doms) => ( + + + {doms} + + + ), + }} + // action = '' + title="新建" + columns={columns} + /> + + + { + handleUpdateModalVisible(false); + }} + footer={null} + > + {currentRow?.name && ( + + layout="horizontal" + layoutType="Form" + labelCol={{ span: 8 }} + wrapperCol={{ span: 12 }} + onFinish={async (values) => { + console.log(values); + }} + submitter={{ + render: (props, doms) => ( + + + {doms} + + + ), + }} + // action = '' + title="编辑" + columns={getInitialValues(columns, currentRow)} + /> + )} + + + ); +}; + +export default CourseList; diff --git a/admin/src/pages/examination/certificate/index.tsx b/admin/src/pages/examination/certificate/index.tsx index 8f4b76d..5786e21 100644 --- a/admin/src/pages/examination/certificate/index.tsx +++ b/admin/src/pages/examination/certificate/index.tsx @@ -170,7 +170,7 @@ const CourseList: React.FC = () => { }, { - title: '状态', + title: '制证状态', dataIndex: 'status_type', sorter: false, valueType: 'text', @@ -196,28 +196,12 @@ const CourseList: React.FC = () => { } return defaultRender(_); }, - render: (dom, entity) => { - switch (entity.status_type) { - case 0: - return "待报名" - break; - case 1: - return "报名中" - break; - case 2: - return "待考试" - break; - case 3: - return "考试中" - break; - case 4: - return "考试完成"; - break; - default: - return "" - break; - } - // return entity.status_type; + valueEnum: { + 0: { text: '待报名' }, + 1: { text: '报名中' }, + 2: { text: '待考试' }, + 3: { text: '考试中' }, + 4: { text: '考试完成' }, }, }, @@ -227,16 +211,7 @@ const CourseList: React.FC = () => { dataIndex: 'option', valueType: 'option', render: (_dom: any, record: React.SetStateAction) => [ - { - //console.log('entity', entity); - setCurrentRow(record); - handleDetailModalVisible(true); - }} - > - 查看 - , + { @@ -244,7 +219,7 @@ const CourseList: React.FC = () => { setCurrentRow(record); }} > - 编辑 + 查看名单 , 删除 diff --git a/admin/src/pages/examination/option/index.tsx b/admin/src/pages/examination/option/index.tsx index 9b71551..ca93d90 100644 --- a/admin/src/pages/examination/option/index.tsx +++ b/admin/src/pages/examination/option/index.tsx @@ -2,9 +2,10 @@ import React, { useState, useRef } from 'react'; import { useRequest, history } from 'umi'; import { PlusOutlined, TagsOutlined, UploadOutlined } from '@ant-design/icons'; -import { Button, message, Input, Drawer, Modal, Col, Row, Space, Upload, Form } from 'antd'; +import { Button, message, Input, Drawer, Modal, Col, Row, Space, Upload, Form, Popconfirm } from 'antd'; import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; -import type { ProColumns, ActionType } from '@ant-design/pro-table'; +import type { ActionType } from '@ant-design/pro-table'; +import type { ProColumns } from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table'; import type { ProFormColumnsType } from '@ant-design/pro-form'; import { BetaSchemaForm, ModalForm, ProFormText, ProFormTextArea } from '@ant-design/pro-form'; @@ -12,30 +13,11 @@ 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 { querySubjectList, saveExamination, removeExamination, queryExaminationList, queryRulesList } from '../service'; +import { querySubjectList, updateExamination, removeExamination, queryExaminationList, queryRulesList } from '../service'; import type { TableListItem, TableListPagination } from './data'; import type { DataItem } from '@antv/data-set/lib/transform/tag-cloud'; -import RegistrationList from '../registration'; -/** - * 添加考试 - * - * @param fields - */ -const handleAdd = async (fields: TableListItem) => { - const hide = message.loading('正在添加'); - try { - await saveExamination({ ...fields }); - hide(); - message.success('添加成功'); - return true; - } catch (error) { - hide(); - message.error('添加失败请重试!'); - return false; - } -}; /** * 更新考试 @@ -43,12 +25,12 @@ const handleAdd = async (fields: TableListItem) => { * @param fields */ -const handleUpdate = async (fields: FormValueType, currentRow?: TableListItem) => { +const handleUpdate = async (fields: FormValueType) => { const hide = message.loading('正在配置'); + console.log(fields, '111111111'); try { - await saveExamination({ - ...currentRow, + await updateExamination({ ...fields, }); hide(); @@ -119,21 +101,10 @@ const ExaminationList: React.FC = () => { ] }, }, - // { - // title: '创建日期', - // dataIndex: 'create_time', - // valueType: 'dataTimeRange', - // sorter: false, - // hideInTable: false, - // hideInForm: true, - // hideInSearch: true, - // renderText: (val: string) => `${val}`, - // }, { title: '报名时间', dataIndex: 'apply_time', valueType: 'dateTimeRange', - sorter: false, hideInTable: false, hideInForm: false, hideInSearch: true, @@ -153,8 +124,6 @@ const ExaminationList: React.FC = () => { title: '考试时间', valueType: 'dateTimeRange', dataIndex: 'examination_time', - sorter: false, - hideInTable: false, hideInForm: false, formItemProps: { rules: [ @@ -164,12 +133,20 @@ const ExaminationList: React.FC = () => { }, ] }, + hideInSearch: true, render: (dom, entity) => { return entity.examination_start_time + " - " + entity.examination_end_time; }, }, - + { + title: '创建时间', + dataIndex: 'create_time', + valueType: 'dateTimeRange', + hideInTable: true, + hideInForm: true, + hideInSearch: false, + }, { title: '关联主题', dataIndex: 'subject_id', @@ -201,7 +178,7 @@ const ExaminationList: React.FC = () => { }, { title: '关联的规则', - dataIndex: 'rule_id', + dataIndex: 'rules_id', valueType: 'select', hideInTable: true, hideInForm: false, @@ -229,9 +206,10 @@ const ExaminationList: React.FC = () => { { title: '在线学习时长(分钟)', dataIndex: 'learning_time', - sorter: false, valueType: 'text', hideInForm: false, + hideInSearch: true, + hideInTable: true, renderText: (val: string) => `${val}`, formItemProps: { rules: [ @@ -244,11 +222,13 @@ const ExaminationList: React.FC = () => { }, { - title: '课程主题开放时间', + title: '课程开放时间', dataIndex: 'course_time', - sorter: false, + valueType: 'dateTimeRange', + hideInTable: true, hideInForm: false, + hideInSearch: true, renderText: (val: string) => `${val}`, formItemProps: { rules: [ @@ -263,47 +243,75 @@ const ExaminationList: React.FC = () => { { title: '试卷数量', dataIndex: 'paper_count', - sorter: false, valueType: 'text', + hideInSearch: true, hideInForm: true, renderText: (val: string) => `${val}`, }, { title: '报考人数', dataIndex: 'apply_person_count', - sorter: false, valueType: 'text', + hideInSearch: true, hideInForm: true, - renderText: (val: string) => `${val}`, + render: (dom, entity) => { + return entity.pass_count + "人/" + entity.apply_person_count + "人"; + }, }, { title: '状态', dataIndex: 'status_type', - sorter: false, hideInForm: true, - hideInSearch: true, - renderText: (val: string) => `${val}`, + hideInSearch: false, + valueEnum: { + 0: { text: '待报名' }, + 1: { text: '报名中' }, + 2: { text: '待考试' }, + 3: { text: '考试中' }, + 4: { text: '考试完成' }, + }, }, - { title: '操作', dataIndex: 'option', valueType: 'option', render: (_dom: any, record: React.SetStateAction) => [ - { - //console.log('entity', entity); - setCurrentRow(record); - handleDetailModalVisible(true); + + { + const success = await updateExamination({ + examination_id: record.examination_id, + b_use: record.b_use == 1 ? 0 : 1, + rules_id: record.rules_id + }); + if (success) { + // handleModalVisible(false); + if (actionRef.current) { + actionRef.current.reload(); + } + } }} > - 查看 - , + + {record.b_use == 1 ? "已发布" : "未发布"} + + + + , { + console.log(record, 'record') handleUpdateModalVisible(true); + record.apply_time = [record.apply_start_time, record.apply_end_time] + record.examination_time = [record.examination_end_time, record.examination_end_time] + record.apply_time = [record.apply_start_time, record.apply_end_time] + + + setCurrentRow(record); }} > @@ -324,7 +332,18 @@ const ExaminationList: React.FC = () => { ], }, ]; - + /** 获取列数据初始值 */ + const getInitialValues = (cols: any[], vals: any) => { + console.log('getInitialValues-columns', columns); + console.log('getInitialValues-values', vals); + const initialValues: any[] = []; + cols.forEach((column: { dataIndex: string }) => { + const key: any = column?.dataIndex || ''; + initialValues.push({ ...column, initialValue: key ? vals[key] : '' }); + }); + console.log('initialValues::', initialValues); + return initialValues || []; + }; return ( @@ -352,8 +371,8 @@ const ExaminationList: React.FC = () => { value.start_time = create_time[0] value.end_time = create_time[1] } - - + console.log('form _data', value) + delete value.create_time const _data = await queryExaminationList( { ...value, @@ -361,7 +380,6 @@ const ExaminationList: React.FC = () => { page_size: value.pageSize } ); - console.log(_data, 'form _data') return { current: _data?.pageNumber, data: _data?.table_List, @@ -476,30 +494,65 @@ const ExaminationList: React.FC = () => { schemaForm.setFieldsValue({ rule_id: "" }) } }} + onFinish={async (values: any) => { // 表单处理 - console.log('columns:', columns); - console.log('values:', values); + //console.log('columns:', columns); + console.log('values1:', values); + //return false; + // 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], + examination_start_time: values.examination_time[0], + examination_end_time: values.examination_time[0] + } - // if (params.id) { - // fileds = { ...fileds, id: params.id } - // } - // console.log(fileds, 'fileds', params); - // // return false - // await saveRules({ - // ...fileds, - // b_use: 0, - // rules_type: 1, - // start_time: fileds.dateRange[0], - // end_time: fileds.dateRange[1] - // }); + delete params.apply_time + delete params.course_time + delete params.examination_time - // // await waitTime(2000); - // return true; + await handleUpdate(params); + handleCreateModalVisible(false); + actionRef.current?.reloadAndRest?.(); + }} - }} + /* + onFinish={async (values: any) => { + // 表单处理 + console.log('columns:', columns); + console.log('values:', values); + + // if (params.id) { + // fileds = { ...fileds, id: params.id } + // } + // console.log(fileds, 'fileds', params); + // // return false + const res = await updateExamination({ + ...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[0], + examination_start_time: values.examination_time[0], + examination_end_time: values.examination_time[0], + }); + console.log(res, 'resresresres'); + + // // await waitTime(2000); + // return true; + + + + }} + + */ + submitter={{ render: (props, doms) => ( @@ -525,7 +578,7 @@ const ExaminationList: React.FC = () => { }} footer={null} > - {currentRow?.name && ( + {currentRow?.examination_id && ( layout="horizontal" layoutType="Form" diff --git a/admin/src/pages/examination/service.ts b/admin/src/pages/examination/service.ts index 8e6db73..db0f983 100644 --- a/admin/src/pages/examination/service.ts +++ b/admin/src/pages/examination/service.ts @@ -71,11 +71,12 @@ export async function queryCertificateList( }); } -/** 新建/修改考试 POST /dsideal_yy/ypt/careerTraining/course/save */ -export async function saveExamination(data: Record, options?: Record) { - return request('/dsideal_yy/ypt/careerTraining/course/save', { +/** 新建/修改考试 POST /dsideal_yy/zygh/training/examination/updateExamination */ +export async function updateExamination(data: Record, options?: Record) { + return request('/dsideal_yy/zygh/training/examination/updateExamination', { data, method: 'POST', + requestType: "form", ...(options || {}), }); } diff --git a/admin/src/pages/history/analysis/components/IntroduceRow.tsx b/admin/src/pages/history/analysis/components/IntroduceRow.tsx index 042c4fb..9d36b27 100644 --- a/admin/src/pages/history/analysis/components/IntroduceRow.tsx +++ b/admin/src/pages/history/analysis/components/IntroduceRow.tsx @@ -1,6 +1,6 @@ import { InfoCircleOutlined } from '@ant-design/icons'; import { TinyArea, TinyColumn } from '@ant-design/charts'; -import { Col, Progress, Row, Tooltip } from 'antd'; +import { Card, Col, Progress, Row, Tabs, DatePicker } from 'antd'; import numeral from 'numeral'; import { ChartCard, Field } from './Charts'; @@ -8,72 +8,108 @@ import type { DataItem } from '../data.d'; import Trend from './Trend'; import Yuan from '../utils/Yuan'; import styles from '../style.less'; - +const { RangePicker } = DatePicker; const topColResponsiveProps = { xs: 24, sm: 12, md: 12, lg: 12, - xl: 6, + xl: 12, style: { marginBottom: 24 }, }; const IntroduceRow = ({ loading, visitData }: { loading: boolean; visitData: DataItem[] }) => ( - - - - - - - - - - - - - - - - - - + + } + size="large" + tabBarStyle={{ marginBottom: 24 }} > - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + ); export default IntroduceRow;