fix del bug

master
zhengpengju 3 years ago
parent 4c1d2152a5
commit b4b3a2af42

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