xialiang 3 years ago
commit fd213010f2

@ -1,8 +1,9 @@
import { DingdingOutlined, UploadOutlined } from '@ant-design/icons';
import { Button, Card, Steps, Result, Descriptions, Modal, Input, Upload, Popconfirm } from 'antd';
import { Fragment, useRef, useState } from 'react';
import { Fragment, useEffect, useRef, useState } from 'react';
import { GridContent } from '@ant-design/pro-layout';
import { Line } from '@ant-design/charts';
import { DualAxes } from "@ant-design/charts";
import styles from './index.less';
import ReactQuill from 'react-quill';
import 'react-quill/dist/quill.snow.css'
@ -16,7 +17,102 @@ const { Step } = Steps;
export default () => {
const uuid = uuidv4()
console.log('uuid', uuidv4());
const data = [
{
year: "1991",
value: 3,
count: 10
},
{
year: "1992",
value: 4,
count: 4
},
{
year: "1993",
value: 3.5,
count: 5
},
{
year: "1994",
value: 5,
count: 5
},
{
year: "1995",
value: 4.9,
count: 4.9
},
{
year: "1996",
value: 6,
count: 35
},
{
year: "1997",
value: 7,
count: 7
},
{
year: "1998",
value: 9,
count: 1
},
{
year: "1999",
value: 13,
count: 20
}
];
const data2 = [
{
year: "1991",
value: 30,
count: 100
},
{
year: "1992",
value: 40,
count: 40
},
{
year: "1993",
value: 3.5,
count: 50
},
{
year: "1994",
value: 5,
count: 50
},
{
year: "1995",
value: 40.9,
count: 24.9
},
{
year: "1996",
value: 6,
count: 395
},
{
year: "1997",
value: 7,
count: 79
},
{
year: "1998",
value: 99,
count: 1
},
{
year: "1999",
value: 193,
count: 20
}
];
const [modalVisible, handleModalVisible] = useState<boolean>(false);
const saveInputRef = useRef();
//const currentRow = {course_name:'课程0001'};
@ -27,6 +123,17 @@ export default () => {
{dataIndex: "course_name", hideInDescriptions: false, hideInForm: false,hideInSearch: true,hideInTable: false, title: "课程名称1", valueType: "text"},
{}
];
const [chartData, setChartData] = useState([data, data]);
useEffect(() => {
setInterval(() => {
setChartData(Math.random() > 0.5 ? [data, data] : [data2, data2]);
}, 1000);
}, []);
const config = {
data: chartData,
xField: "year",
yField: ["value", "count"]
};
return(
<>
<Input value={123} ref={saveInputRef} />
@ -103,6 +210,8 @@ export default () => {
<Popconfirm title="Are you sure" okText="Yes" cancelText="No">
<a href="#">Delete</a>
</Popconfirm>
<DualAxes {...config} />
</>
)
};

@ -16,6 +16,7 @@ import UpdateForm from './components/UpdateForm';
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 { ConsoleMessage } from 'puppeteer-core';
@ -48,14 +49,15 @@ const handleUpdate = async (fields: FormValueType) => {
*
* @param selectedRows
*/
const handleRemove = async (selectedRows: TableListItem[]) => {
const handleRemove = async (selectedRows: TableListItem[], currentRow) => {
console.log('selectedRows', selectedRows)
const hide = message.loading('正在删除');
if (!selectedRows) return true;
try {
await removeExamination({
key: selectedRows.map((row) => row.key),
});
},currentRow);
hide();
message.success('删除成功,即将刷新');
return true;
@ -320,7 +322,7 @@ const ExaminationList: React.FC = () => {
<a
key="remove"
onClick={ () => {
handleRemove([{ key: record?.examination_id }]); // 调用批量删除函数如果接口不支持批量需要在service中处理
handleRemove([{ key: record?.examination_id }], record); // 调用批量删除函数如果接口不支持批量需要在service中处理
setSelectedRows([]);
actionRef.current?.reloadAndRest?.();
}}>

@ -82,13 +82,12 @@ export async function updateExamination(data: Record<string, any>, options?: Rec
}
/** 删除考试 */
export async function removeExamination(data: { key: number[] }, options?: Record<string, any>) {
export async function removeExamination(data: { key: number[]}, options?: Record<string, any>) {
console.log('data:::', data);
return request<Record<string, any>>('/dsideal_yy/zygh/training/examination/delExamination', {
data: { examination_id: data?.key[0] }, // 当前接口不支持批量操作
data: { examination_id: data?.key[0], rules_id: options?.rules_id}, // 当前接口不支持批量操作
method: 'POST',
requestType: 'form',
...(options || {}),
});
}

@ -10,7 +10,7 @@ import { BetaSchemaForm, ModalForm, ProFormText, ProFormTextArea } from '@ant-de
import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions';
import ProDescriptions from '@ant-design/pro-descriptions';
import type { FormValueType } from './components/UpdateForm';
import { querySubjectList, saveExamination, removeExamination, queryRulesList } from '../service';
import { querySubjectList, saveExamination, removeExamination, queryRulesList, removeRules } from '../service';
import type { TableListItem, TableListPagination } from './data';
import type { DataItem } from '@antv/data-set/lib/transform/tag-cloud';
@ -60,18 +60,18 @@ const handleUpdate = async (fields: FormValueType, currentRow?: TableListItem) =
};
/**
*
*
*
* @param selectedRows
*/
const handleRemove = async (selectedRows: TableListItem[]) => {
const handleRemove = async (selectedRows: TableListItem[], currentRow) => {
const hide = message.loading('正在删除');
if (!selectedRows) return true;
try {
await removeExamination({
await removeRules({
key: selectedRows.map((row) => row.key),
});
}, currentRow);
hide();
message.success('删除成功,即将刷新');
return true;
@ -213,7 +213,13 @@ const ExaminationRules: React.FC = () => {
>
</a>,
<a key="subscribeAlert" href="https://procomponents.ant.design/">
<a
key="remove"
onClick={ () => {
handleRemove([{ key: record?.id }], record); // 调用批量删除函数如果接口不支持批量需要在service中处理
setSelectedRows([]);
actionRef.current?.reloadAndRest?.();
}}>
</a>,
<a

@ -11,68 +11,23 @@ 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, queryRulesList } from '../service';
import { querySubjectList, queryRulesList, removeRules } 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 saveExamination({ ...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 saveExamination({
...currentRow,
...fields,
});
hide();
message.success('操作成功');
return true;
} catch (error) {
hide();
message.error('操作失败请重试!');
return false;
}
};
/**
*
*
*
* @param selectedRows
*/
const handleRemove = async (selectedRows: TableListItem[]) => {
const handleRemove = async (selectedRows: TableListItem[], currentRow) => {
const hide = message.loading('正在删除');
if (!selectedRows) return true;
try {
await removeExamination({
await removeRules({
key: selectedRows.map((row) => row.key),
});
}, currentRow);
hide();
message.success('删除成功,即将刷新');
return true;
@ -84,12 +39,7 @@ const handleRemove = async (selectedRows: TableListItem[]) => {
};
const ExaminationRules: React.FC = () => {
/** 更新窗口的弹窗 */
const [createModalVisible, handleCreateModalVisible] = useState<boolean>(false);
const [detailModalVisible, handleDetailModalVisible] = useState<boolean>(false);
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
//const [registrationModalVisible, handleRegistrationModalVisible] = useState<boolean>(false);
const actionRef = useRef<ActionType>();
const [currentRow, setCurrentRow] = useState<TableListItem>();
const [selectedRowsState, setSelectedRows] = useState<TableListItem[]>([]);
@ -209,12 +159,17 @@ const ExaminationRules: React.FC = () => {
key="update"
onClick={() => {
history.push('/examinationrules/normal/step/' + record.id)
}}
>
</a>,
<a key="subscribeAlert" href="https://procomponents.ant.design/">
<a
key="remove"
onClick={ () => {
handleRemove([{ key: record?.id }], record); // 调用批量删除函数如果接口不支持批量需要在service中处理
setSelectedRows([]);
actionRef.current?.reloadAndRest?.();
}}>
</a>,
<a
@ -308,118 +263,6 @@ const ExaminationRules: React.FC = () => {
<Button type="primary"></Button>
</FooterToolbar>
)}
<Modal
title={currentRow?.examination_name || '考试详细'}
width="60%"
visible={detailModalVisible}
onCancel={() => {
setCurrentRow(undefined); // 设置当前行
handleDetailModalVisible(false);
}}
footer={null}
centered
>{console.log('currentRow', currentRow)}
{currentRow?.name && (
<ProDescriptions<TableListItem>
column={2}
/* title={currentRow?.name} */
dataSource={currentRow}
/*
request={async () => ({
data: currentRow || {},
})}*/
params={{
id: currentRow?.examination_id,
}}
columns={
columns
//columns.slice(0, columns.length - 1) as ProDescriptionsItemProps<TableListItem>[]
}
/>
)}
</Modal>
<Modal
title="新建考试"
//
width="60%"
visible={createModalVisible}
destroyOnClose
onCancel={() => {
handleCreateModalVisible(false);
}}
footer={null}
>
<BetaSchemaForm<DataItem>
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) => (
<Row>
<Col span={12} offset={8}>
<Space>{doms}</Space>
</Col>
</Row>
),
}}
// action = ''
title="新建"
columns={columns}
/>
</Modal>
<Modal
title="编辑"
width="60%"
visible={updateModalVisible}
destroyOnClose
onCancel={() => {
handleUpdateModalVisible(false);
}}
footer={null}
>
{currentRow?.name && (
<BetaSchemaForm<DataItem>
layout="horizontal"
layoutType="Form"
labelCol={{ span: 8 }}
wrapperCol={{ span: 12 }}
onFinish={async (values) => {
console.log('currentRow', currentRow)
//const url = values?.upload[0]?.url?.replace('/dsideal_yy/html/','') || values?.upload[0]?.response?.url;
//console.log('url', url)
await handleUpdate({
...values,
examination_id: currentRow?.examination_id,
});
handleUpdateModalVisible(false); // 隐藏编辑窗口
actionRef.current?.reloadAndRest?.();
console.log(values);
}}
submitter={{
render: (props, doms) => (
<Row>
<Col span={12} offset={8}>
<Space>{doms}</Space>
</Col>
</Row>
),
}}
// action = ''
title="编辑"
columns={getInitialValues(columns, currentRow)}
/>
)}
</Modal>
</PageContainer>
);
};

@ -28,7 +28,7 @@ export async function querySubjectList(params: {
});
}
/dsideal_yy/zygh/training/rules/delRules
@ -67,3 +67,14 @@ export async function updateFakeList(
},
});
}
/** 删除考试规则 */
export async function removeRules(data: { key: number[] }, options?: Record<string, any>) {
console.log('data:::', data);
return request<Record<string, any>>('/dsideal_yy/zygh/training/rules/delRules', {
data: { id: data?.key[0], rules_type: options?.rules_type, subject_id: options?.subject_id}, // 当前接口不支持批量操作
method: 'POST',
requestType: 'form',
...(options || {}),
});
}

@ -130,4 +130,15 @@ export async function queryRegistrationList(
},
...(options || {}),
});
}
/** 删除考试规则 */
export async function removeRules(data: { key: number[] }, options?: Record<string, any>) {
console.log('data:::', data);
return request<Record<string, any>>('/dsideal_yy/zygh/training/rules/delRules', {
data: { id: data?.key[0], rules_type: options?.rules_type, subject_id: options?.subject_id}, // 当前接口不支持批量操作
method: 'POST',
requestType: 'form',
...(options || {}),
});
}
Loading…
Cancel
Save