主题设置列表、复制、查询

master
xialiang 4 years ago
parent 9d6dd5a2cb
commit c0deedcbda

@ -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<TableListItem>[] = [
{
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 (
<img src="https://gw.alipayobjects.com/zos/rmsportal/uMfMFlvUuceEyPpotzlq.png" style={{width:'150px', height:'75px'}} />
<img src={entity.attachment_json.url} style={{ width: '150px', height: '75px' }} />
);
},
},
{
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 (
<div>
<h3>{entity.subject_name}</h3>
<div dangerouslySetInnerHTML={{ __html: entity.subject_describe }} />
</div>
);
},
},
{
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 <Input {...rest} placeholder="请输入异常原因!" />;
}
<div>
{entity.total_chapter_number}<br />
{entity.total_course_number}<br />
{entity.total_course_minutes}
</div>
return defaultRender(item);
);
},
},
// {
// title: '课程数',
// sorter: true,
// dataIndex: 'total_chapter_number',
// },
{
title: '操作',
dataIndex: 'option',
@ -170,8 +180,15 @@ const TableList: React.FC = () => {
</a>,
<a
key="copyAlert"
onClick={() => {
// handleCopyItem({});
onClick={async () => {
// console.log(e, record, 'copy')
const success = await copySubject({ subject_id: record.subject_id });
if (success) {
// handleModalVisible(false);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
>
@ -191,7 +208,7 @@ const TableList: React.FC = () => {
return (
<PageContainer>
<ProTable<TableListItem, TableListPagination>
headerTitle="查询表格"
headerTitle="主题设置"
actionRef={actionRef}
rowKey="subject_id"
options={false}
@ -209,13 +226,25 @@ const TableList: React.FC = () => {
<PlusOutlined />
</Button>,
]}
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}

@ -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<TableListItem>('/api/rule', {
data,
method: 'PUT',
/** 获取主题详情 GET /dsideal_yy/ypt/careerTraining/subject/getSubjectInfo */
export async function getSubjectInfo(
params: {
// query
/** 当前的页码 */
id?: number;
},
options?: Record<string, any>,
) {
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<TableListItem>('/api/rule', {
/** 复制主题 POST /dsideal_yy/ypt/careerTraining/subject/copySubject */
export async function copySubject(data: { [key: string]: any }, options?: { [key: string]: any }) {
return request<TableListItem>('/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<Record<string, any>>('/api/rule', {
data,
method: 'DELETE',
...(options || {}),
});
}
// /** 新建规则 PUT /api/rule */
// export async function updateRule(data: { [key: string]: any }, options?: { [key: string]: any }) {
// return request<TableListItem>('/api/rule', {
// data,
// method: 'PUT',
// ...(options || {}),
// });
// }
// /** 新建规则 POST /api/rule */
// export async function addRule(data: { [key: string]: any }, options?: { [key: string]: any }) {
// return request<TableListItem>('/api/rule', {
// data,
// method: 'POST',
// ...(options || {}),
// });
// }
// /** 删除规则 DELETE /api/rule */
// export async function removeRule(data: { key: number[] }, options?: { [key: string]: any }) {
// return request<Record<string, any>>('/api/rule', {
// data,
// method: 'DELETE',
// ...(options || {}),
// });
// }
/**

@ -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<TableListItem>[] = [
@ -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,
};
}}
>
<Row gutter={24}>
@ -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}

@ -40,7 +40,7 @@ export async function saveRules(data: Record<string, any>, options?: Record<stri
/** 获取考试规则列表 GET /dsideal_yy/zygh/training/examination/getExaminationList */
/** 获取考试规则详情 GET /dsideal_yy/zygh/training/examination/getExaminationList */
export async function queryRulesView(
params: {
// query

Loading…
Cancel
Save