From 7b13fecca0c19accfea8654e8b562c89bb54be13 Mon Sep 17 00:00:00 2001 From: xialiang <1818147@qq.com> Date: Fri, 28 Jan 2022 16:24:54 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=80=83=E8=AF=95=E3=80=81=E5=88=B6?= =?UTF-8?q?=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/examination/certificate/index.tsx | 131 +++++++++++++----- admin/src/pages/examination/option/index.tsx | 53 ++++++- admin/src/pages/examination/service.ts | 30 +++- 3 files changed, 177 insertions(+), 37 deletions(-) diff --git a/admin/src/pages/examination/certificate/index.tsx b/admin/src/pages/examination/certificate/index.tsx index d094a77..8f4b76d 100644 --- a/admin/src/pages/examination/certificate/index.tsx +++ b/admin/src/pages/examination/certificate/index.tsx @@ -1,7 +1,7 @@ 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 } from 'antd'; +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'; @@ -12,13 +12,14 @@ import type { FormValueType } from './components/UpdateForm'; import UpdateForm from './components/UpdateForm'; import { saveCertificate, removeCertificate, queryCertificateList } from '../service'; import type { TableListItem, TableListPagination } from '../data'; -import { DataItem } from '@antv/data-set/lib/transform/tag-cloud'; +import type { DataItem } from '@antv/data-set/lib/transform/tag-cloud'; /** * 添加证书 * * @param fields */ + const handleAdd = async (fields: TableListItem) => { const hide = message.loading('正在添加'); @@ -86,7 +87,7 @@ const CourseList: React.FC = () => { const [detailModalVisible, handleDetailModalVisible] = useState(false); const [updateModalVisible, handleUpdateModalVisible] = useState(false); - + const actionRef = useRef(); const [currentRow, setCurrentRow] = useState(); const [selectedRowsState, setSelectedRows] = useState([]); @@ -96,21 +97,21 @@ const CourseList: React.FC = () => { { title: '序号', key: 'index', - valueType: 'indexBorder', + valueType: 'indexBorder', width: 48, }, { - title: '考试名称', + title: '证件名称', dataIndex: 'examination_name', valueType: 'text', hideInTable: false, hideInForm: false, - hideInSearch: true, + hideInSearch: false, }, { title: '创建日期', dataIndex: 'create_time', - valueType: 'text', + valueType: 'text', sorter: false, hideInTable: false, hideInForm: false, @@ -120,7 +121,7 @@ const CourseList: React.FC = () => { { title: '报名开始日期', dataIndex: 'apply_start_time', - valueType: 'text', + valueType: 'text', sorter: false, hideInTable: false, hideInForm: false, @@ -128,14 +129,16 @@ const CourseList: React.FC = () => { renderText: (val: string) => `${val}`, }, { - title: '考试开始时间', - valueType: 'text', + title: '考试时间', + valueType: 'dateTimeRange', dataIndex: 'examination_start_time', sorter: false, hideInTable: false, hideInForm: false, - hideInSearch: true, - renderText: (val: string) => `${val}`, + hideInSearch: false, + render: (dom, entity) => { + return entity.examination_start_time + " - " + entity.examination_end_time + }, }, { title: '试卷数量', @@ -143,6 +146,7 @@ const CourseList: React.FC = () => { sorter: false, valueType: 'text', hideInForm: false, + hideInSearch: true, renderText: (val: string) => `${val}`, }, { @@ -151,17 +155,73 @@ const CourseList: React.FC = () => { 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, - hideInForm: true, - hideInSearch: true, - renderText: (val: string) => `${val}`, + 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(_); + }, + 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; + }, }, + { title: '操作', dataIndex: 'option', @@ -203,24 +263,31 @@ const CourseList: React.FC = () => { search={{ labelWidth: 120, }} - toolBarRender={() => [ - , - ]} + // toolBarRender={() => [ + // , + // ]} request={async (value) => { - const _data = await queryCertificateList(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?.page_number, - data: _data?.data?.list, - pageSize: _data?.page_size, - total: _data?.total_row || 0, + current: _data?.pageNumber, + data: _data?.table_List, + pageSize: _data?.pageSize, + total: _data?.totalRow || 0, }; }} // dataSource={list} @@ -265,7 +332,7 @@ const CourseList: React.FC = () => { }} footer={null} centered - >{ console.log('currentRow',currentRow)} + >{console.log('currentRow', currentRow)} {currentRow?.name && ( column={2} diff --git a/admin/src/pages/examination/option/index.tsx b/admin/src/pages/examination/option/index.tsx index 4350c66..f55791a 100644 --- a/admin/src/pages/examination/option/index.tsx +++ b/admin/src/pages/examination/option/index.tsx @@ -2,7 +2,7 @@ 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 } from 'antd'; +import { Button, message, Input, Drawer, Modal, Col, Row, Space, Upload, Form } 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'; @@ -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 { querySubjectList, saveExamination, removeExamination, queryExaminationList } from '../service'; +import { querySubjectList, saveExamination, 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'; @@ -89,7 +89,7 @@ const ExaminationList: React.FC = () => { const [detailModalVisible, handleDetailModalVisible] = useState(false); const [updateModalVisible, handleUpdateModalVisible] = useState(false); //const [registrationModalVisible, handleRegistrationModalVisible] = useState(false); - + const [schemaForm] = Form.useForm(); const actionRef = useRef(); const [currentRow, setCurrentRow] = useState(); const [selectedRowsState, setSelectedRows] = useState([]); @@ -146,7 +146,7 @@ const ExaminationList: React.FC = () => { }, { - title: '关联1主题', + title: '关联主题', dataIndex: 'subject_id', valueType: 'text', hideInTable: true, @@ -165,6 +165,45 @@ const ExaminationList: React.FC = () => { return sinfo; }, + formItemProps: { + rules: [ + { + required: true, + message: '此项为必填项', + }, + ] + }, + }, + { + title: '关联的规则', + dataIndex: 'subject_id2', + valueType: 'text', + hideInTable: true, + hideInForm: false, + hideInSearch: true, + request: async (e, a) => { + console.log(e, a, 'OOOOOOOOO'); + + const { data: Items } = await queryRulesList({}); + // 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; + }, + formItemProps: { + rules: [ + { + required: true, + message: '此项为必填项', + }, + ] + }, }, { title: '试卷数量', @@ -370,10 +409,16 @@ const ExaminationList: React.FC = () => { footer={null} > + form={schemaForm} layout="horizontal" layoutType="Form" labelCol={{ span: 8 }} wrapperCol={{ span: 12 }} + onValuesChange={(values: any) => { + console.log('values:', values); + const { subject_id } = values + schemaForm.setFields({ subject_id2: [{ name: "1", value: "1" }, { name: "2", value: "2" }] }) + }} onFinish={async (values: any) => { // 表单处理 console.log('columns:', columns); diff --git a/admin/src/pages/examination/service.ts b/admin/src/pages/examination/service.ts index aa34b5d..f318615 100644 --- a/admin/src/pages/examination/service.ts +++ b/admin/src/pages/examination/service.ts @@ -62,7 +62,7 @@ export async function queryCertificateList( /** 页面的容量 */ page_size?: number; success?: boolean; - }>('/api/zygh/training/examination/getCertificateList', { + }>('/dsideal_yy/zygh/training/examination/getExaminationList', { method: 'GET', params: { ...params, @@ -137,4 +137,32 @@ export async function queryRegistrationList( }, ...(options || {}), }); +} + + +/** 获取考试规则列表 GET /dsideal_yy/zygh/training/examination/getExaminationList */ +export async function queryRulesList( + params: { + // query + /** 当前的页码 */ + current?: number; + /** 页面的容量 */ + pageSize?: number; + }, + options?: Record, +) { + return request<{ + data: TableListItem[]; + /** 列表的内容总数 */ + total_row?: number; + /** 页面的容量 */ + page_size?: number; + success?: boolean; + }>('/dsideal_yy/zygh/training/rules/getRulesList', { + method: 'GET', + params: { + ...params, + }, + ...(options || {}), + }); } \ No newline at end of file From 281fe6b5bd163f275cdf356fa0c7fe818ddd031d Mon Sep 17 00:00:00 2001 From: xialiang <1818147@qq.com> Date: Sat, 29 Jan 2022 11:01:08 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=B8=BB=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/pages/course/subject/step/index.tsx | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/admin/src/pages/course/subject/step/index.tsx b/admin/src/pages/course/subject/step/index.tsx index 07ddf64..093be49 100644 --- a/admin/src/pages/course/subject/step/index.tsx +++ b/admin/src/pages/course/subject/step/index.tsx @@ -23,7 +23,7 @@ import ProFormRichEdit from '../components/ProFormRichEdit'; import type { ActionType, ProColumns } from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table'; import type { TableListItem, TableListPagination } from '../../option/data'; -import { queryCourseList } from '../../option/service'; +import { queryCourseList, saveSubject } from '../../option/service'; /** 列表项定义 */ const columns: ProColumns[] = [ @@ -213,9 +213,23 @@ export default () => { stepProps={{ description: false, }} - onFinish={async () => { - console.log(formRef.current?.getFieldsValue()); + onFinish={async (fileds) => { + 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] + }); + + // await waitTime(2000); return true; + }} >
@@ -255,7 +269,11 @@ export default () => { , ]} request={async (value) => { - const _data = await queryCourseList(value); + + const _data = await saveSubject({ + ...value, + attachment_json: `{ "url": "${value.upload[0].response.url}"}` + }); return { current: _data?.page_number, data: _data?.data?.list, From 9d6dd5a2cb838c04abfee2303b7630a478418187 Mon Sep 17 00:00:00 2001 From: xialiang <1818147@qq.com> Date: Sat, 29 Jan 2022 11:01:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=B8=BB=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/pages/course/option/service.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/admin/src/pages/course/option/service.ts b/admin/src/pages/course/option/service.ts index 749f773..5c68eb0 100644 --- a/admin/src/pages/course/option/service.ts +++ b/admin/src/pages/course/option/service.ts @@ -82,6 +82,15 @@ export async function queryCourseView(data: Record, options?: Recor +/** 新建/修改主题 POST /dsideal_yy/ypt/careerTraining/subject/saveSubject */ +export async function saveSubject(data: Record, options?: Record) { + return request('/dsideal_yy/ypt/careerTraining/subject/saveSubject', { + data, + method: 'POST', + requestType: 'form', + ...(options || {}), + }); +} @@ -90,8 +99,7 @@ export async function queryCourseView(data: Record, options?: Recor - -/** 新建/修改课程 POST /dsideal_yy/ypt/careerTraining/course/save */ +/** 新建/修改课程标签 POST /dsideal_yy/ypt/careerTraining/course/save */ export async function saveTag(data: Record, options?: Record) { return request('/dsideal_yy/ypt/careerTraining/tag/save', { data,