|
|
|
@ -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}
|
|
|
|
|