From c0deedcbda507fbf7dc9faed7bb9d53df53cf1c1 Mon Sep 17 00:00:00 2001 From: xialiang <1818147@qq.com> Date: Tue, 8 Feb 2022 16:30:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A2=98=E8=AE=BE=E7=BD=AE=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E3=80=81=E5=A4=8D=E5=88=B6=E3=80=81=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/pages/course/subject/index.tsx | 139 +++++++++++------- admin/src/pages/course/subject/service.ts | 67 ++++++--- admin/src/pages/course/subject/step/index.tsx | 49 ++++-- admin/src/pages/examinationrules/service.ts | 2 +- 4 files changed, 169 insertions(+), 88 deletions(-) diff --git a/admin/src/pages/course/subject/index.tsx b/admin/src/pages/course/subject/index.tsx index 6c702f5..8c86b25 100644 --- a/admin/src/pages/course/subject/index.tsx +++ b/admin/src/pages/course/subject/index.tsx @@ -10,7 +10,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 { Subject, addSubject, updateSubject, removeSubject, querySubjectList } from './service'; +import { copySubject, addSubject, updateSubject, removeSubject, querySubjectList } from './service'; import type { TableListItem, TableListPagination } from './data'; /** * 添加节点 @@ -91,70 +91,80 @@ const TableList: React.FC = () => { /** 国际化配置 */ const columns: ProColumns[] = [ + { + title: '主题名称', + dataIndex: 'subject_name', + valueType: 'text', + hideInTable: true, + hideInDescriptions: true, + hideInForm: true, + hideInSearch: false, + + }, { title: '图片', dataIndex: 'name', tip: '主题名称是唯一的 key', + hideInSearch: true, render: (dom, entity) => { + // console.log(entity, 'entity') return ( - + ); }, }, { - title: '描述', - dataIndex: 'desc', - valueType: 'textarea', - }, - { - title: '考核学时', - dataIndex: 'callNo', - sorter: true, + title: '创建日期', + dataIndex: 'create_time', + valueType: 'dateRange', + hideInTable: true, hideInForm: true, - renderText: (val: string) => `${val}`, + hideInSearch: false, + }, { - title: '状态', - dataIndex: 'status', - hideInForm: true, - valueEnum: { - 0: { - text: '关闭', - status: 'Default', - }, - 1: { - text: '运行中', - status: 'Processing', - }, - 2: { - text: '已上线', - status: 'Success', - }, - 3: { - text: '异常', - status: 'Error', - }, + title: '主题', + dataIndex: 'subject_describe', + valueType: 'textarea', + hideInSearch: true, + width: "60%", + render: (dom, entity) => { + + return ( + +
+

{entity.subject_name}

+
+
+ + ); }, }, { - title: '课程数', + title: '信息', + dataIndex: 'total_course_minutes', sorter: true, - dataIndex: 'updatedAt', - valueType: 'dateTime', - renderFormItem: (item, { defaultRender, ...rest }, form) => { - const status = form.getFieldValue('status'); + hideInSearch: true, + render: (dom, entity) => { - if (`${status}` === '0') { - return false; - } + return ( - if (`${status}` === '3') { - return ; - } +
+ 章节数:{entity.total_chapter_number}
+ 课程数:{entity.total_course_number}
+ 考核学时:{entity.total_course_minutes}分钟 +
- return defaultRender(item); + ); }, }, + + // { + // title: '课程数', + // sorter: true, + // dataIndex: 'total_chapter_number', + + // }, { title: '操作', dataIndex: 'option', @@ -168,16 +178,23 @@ const TableList: React.FC = () => { > 编辑 , - { - // handleCopyItem({}); + { + // console.log(e, record, 'copy') + const success = await copySubject({ subject_id: record.subject_id }); + if (success) { + // handleModalVisible(false); + if (actionRef.current) { + actionRef.current.reload(); + } + } }} > 复制 , - { // handleCopyItem({}); }} @@ -191,7 +208,7 @@ const TableList: React.FC = () => { return ( - headerTitle="查询表格" + headerTitle="主题设置" actionRef={actionRef} rowKey="subject_id" options={false} @@ -209,13 +226,25 @@ const TableList: React.FC = () => { 新建 , ]} - request={async () => { - const { data } = await querySubjectList({page_size: 20}); // 解构后不用套data - //console.log('datalist', data?.list ) + request={async (value) => { + const { create_time } = value; + if (create_time) { + value.begin_time = create_time[0] + value.end_time = create_time[1] + } + const { data } = await querySubjectList({ + ...value, + page_number: value.current, + page_size: value.pageSize + }); // 解构后不用套data + // console.log('datalist', dataist) return { + current: data?.page_number, + data: data?.list, + pageSize: data?.page_size, success: true, - data: data?.list || [], - total: data?.total_page || 0, + total: data?.total_row || 0, + }; }} columns={columns} diff --git a/admin/src/pages/course/subject/service.ts b/admin/src/pages/course/subject/service.ts index 3ea9dfb..64629a4 100644 --- a/admin/src/pages/course/subject/service.ts +++ b/admin/src/pages/course/subject/service.ts @@ -28,32 +28,65 @@ export async function rule( }); } -/** 新建规则 PUT /api/rule */ -export async function updateRule(data: { [key: string]: any }, options?: { [key: string]: any }) { - return request('/api/rule', { - data, - method: 'PUT', + + +/** 获取主题详情 GET /dsideal_yy/ypt/careerTraining/subject/getSubjectInfo */ +export async function getSubjectInfo( + params: { + // query + /** 当前的页码 */ + id?: number; + }, + options?: Record, +) { + return request('/dsideal_yy/ypt/careerTraining/subject/getSubjectInfo', { + method: 'GET', + params: { + ...params, + }, ...(options || {}), }); } -/** 新建规则 POST /api/rule */ -export async function addRule(data: { [key: string]: any }, options?: { [key: string]: any }) { - return request('/api/rule', { +/** 复制主题 POST /dsideal_yy/ypt/careerTraining/subject/copySubject */ +export async function copySubject(data: { [key: string]: any }, options?: { [key: string]: any }) { + return request('/dsideal_yy/ypt/careerTraining/subject/copySubject', { data, method: 'POST', + requestType: "form", ...(options || {}), }); } -/** 删除规则 DELETE /api/rule */ -export async function removeRule(data: { key: number[] }, options?: { [key: string]: any }) { - return request>('/api/rule', { - data, - method: 'DELETE', - ...(options || {}), - }); -} + + + +// /** 新建规则 PUT /api/rule */ +// export async function updateRule(data: { [key: string]: any }, options?: { [key: string]: any }) { +// return request('/api/rule', { +// data, +// method: 'PUT', +// ...(options || {}), +// }); +// } + +// /** 新建规则 POST /api/rule */ +// export async function addRule(data: { [key: string]: any }, options?: { [key: string]: any }) { +// return request('/api/rule', { +// data, +// method: 'POST', +// ...(options || {}), +// }); +// } + +// /** 删除规则 DELETE /api/rule */ +// export async function removeRule(data: { key: number[] }, options?: { [key: string]: any }) { +// return request>('/api/rule', { +// data, +// method: 'DELETE', +// ...(options || {}), +// }); +// } /** @@ -62,7 +95,7 @@ export async function removeRule(data: { key: number[] }, options?: { [key: stri * @param params * @returns */ - export async function querySubjectList(params: { +export async function querySubjectList(params: { page_size: number; //count: number; }): Promise<{ data: { list: CardListItemDataType[] } }> { diff --git a/admin/src/pages/course/subject/step/index.tsx b/admin/src/pages/course/subject/step/index.tsx index 093be49..5f85aab 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, saveSubject } from '../../option/service'; +import { getSubjectInfo, saveSubject } from '../../option/service'; /** 列表项定义 */ const columns: ProColumns[] = [ @@ -151,12 +151,31 @@ export default () => { stepProps={{ description: false, }} + request={async () => { + + const data = await getSubjectInfo(5); + console.log(data); + + // return { data: bean } + + + }} + + + onFinish={async (value) => { console.log(value, "vvvvv"); - console.log(formRef.current?.getFieldsValue()); - await waitTime(2000); - return true; + const _data = await saveSubject({ + ...value, + attachment_json: `{ "url": "${value.upload[0].response.url}"}` + }); + return { + current: _data?.page_number, + data: _data?.data?.list, + pageSize: _data?.page_size, + total: _data?.total_row || 0, + }; }} > @@ -270,16 +289,16 @@ export default () => { ]} request={async (value) => { - const _data = await saveSubject({ - ...value, - attachment_json: `{ "url": "${value.upload[0].response.url}"}` - }); - return { - current: _data?.page_number, - data: _data?.data?.list, - pageSize: _data?.page_size, - total: _data?.total_row || 0, - }; + // const _data = await saveSubject({ + // ...value, + // attachment_json: `{ "url": "${value.upload[0].response.url}"}` + // }); + // return { + // current: _data?.page_number, + // data: _data?.data?.list, + // pageSize: _data?.page_size, + // total: _data?.total_row || 0, + // }; }} // dataSource={list} columns={columns} @@ -368,7 +387,7 @@ export default () => { - + ); }; \ No newline at end of file diff --git a/admin/src/pages/examinationrules/service.ts b/admin/src/pages/examinationrules/service.ts index 7e282f8..b630720 100644 --- a/admin/src/pages/examinationrules/service.ts +++ b/admin/src/pages/examinationrules/service.ts @@ -40,7 +40,7 @@ export async function saveRules(data: Record, options?: Record