From b4b3a2af4215258066664e2b37493eaca50b2e21 Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Thu, 17 Feb 2022 09:40:25 +0800 Subject: [PATCH 1/2] fix del bug --- admin/src/pages/examination/option/index.tsx | 8 +- admin/src/pages/examination/service.ts | 5 +- .../examinationrules/attestation/index.tsx | 18 +- .../pages/examinationrules/normal/index.tsx | 181 ++---------------- .../pages/examinationrules/normal/service.ts | 13 +- admin/src/pages/examinationrules/service.ts | 11 ++ 6 files changed, 54 insertions(+), 182 deletions(-) diff --git a/admin/src/pages/examination/option/index.tsx b/admin/src/pages/examination/option/index.tsx index 87b19ea..68d63cb 100644 --- a/admin/src/pages/examination/option/index.tsx +++ b/admin/src/pages/examination/option/index.tsx @@ -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 = () => { { - handleRemove([{ key: record?.examination_id }]); // 调用批量删除函数(如果接口不支持批量需要在service中处理) + handleRemove([{ key: record?.examination_id }], record); // 调用批量删除函数(如果接口不支持批量需要在service中处理) setSelectedRows([]); actionRef.current?.reloadAndRest?.(); }}> diff --git a/admin/src/pages/examination/service.ts b/admin/src/pages/examination/service.ts index e6577bf..a93e010 100644 --- a/admin/src/pages/examination/service.ts +++ b/admin/src/pages/examination/service.ts @@ -82,13 +82,12 @@ export async function updateExamination(data: Record, options?: Rec } /** 删除考试 */ -export async function removeExamination(data: { key: number[] }, options?: Record) { +export async function removeExamination(data: { key: number[]}, options?: Record) { console.log('data:::', data); return request>('/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 || {}), }); } diff --git a/admin/src/pages/examinationrules/attestation/index.tsx b/admin/src/pages/examinationrules/attestation/index.tsx index 67a96b6..7b2b23c 100644 --- a/admin/src/pages/examinationrules/attestation/index.tsx +++ b/admin/src/pages/examinationrules/attestation/index.tsx @@ -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 = () => { > 编辑 , - + { + handleRemove([{ key: record?.id }], record); // 调用批量删除函数(如果接口不支持批量需要在service中处理) + setSelectedRows([]); + actionRef.current?.reloadAndRest?.(); + }}> 删除 , { - 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(false); - const [detailModalVisible, handleDetailModalVisible] = useState(false); - const [updateModalVisible, handleUpdateModalVisible] = useState(false); //const [registrationModalVisible, handleRegistrationModalVisible] = useState(false); - const actionRef = useRef(); const [currentRow, setCurrentRow] = useState(); const [selectedRowsState, setSelectedRows] = useState([]); @@ -209,12 +159,17 @@ const ExaminationRules: React.FC = () => { key="update" onClick={() => { history.push('/examinationrules/normal/step/' + record.id) - }} > 编辑 , - + { + handleRemove([{ key: record?.id }], record); // 调用批量删除函数(如果接口不支持批量需要在service中处理) + setSelectedRows([]); + actionRef.current?.reloadAndRest?.(); + }}> 删除 , { )} - { - setCurrentRow(undefined); // 设置当前行 - handleDetailModalVisible(false); - }} - footer={null} - centered - >{console.log('currentRow', currentRow)} - {currentRow?.name && ( - - 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[] - } - /> - )} - - - { - handleCreateModalVisible(false); - }} - footer={null} - > - - 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) => ( - - - {doms} - - - ), - }} - // action = '' - title="新建" - columns={columns} - /> - - - { - handleUpdateModalVisible(false); - }} - footer={null} - > - {currentRow?.name && ( - - 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) => ( - - - {doms} - - - ), - }} - // action = '' - title="编辑" - columns={getInitialValues(columns, currentRow)} - /> - )} - - ); }; diff --git a/admin/src/pages/examinationrules/normal/service.ts b/admin/src/pages/examinationrules/normal/service.ts index c8c4457..6dcc064 100644 --- a/admin/src/pages/examinationrules/normal/service.ts +++ b/admin/src/pages/examinationrules/normal/service.ts @@ -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) { + console.log('data:::', data); + return request>('/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 || {}), + }); +} \ No newline at end of file diff --git a/admin/src/pages/examinationrules/service.ts b/admin/src/pages/examinationrules/service.ts index b630720..d4f6bbb 100644 --- a/admin/src/pages/examinationrules/service.ts +++ b/admin/src/pages/examinationrules/service.ts @@ -130,4 +130,15 @@ export async function queryRegistrationList( }, ...(options || {}), }); +} + +/** 删除考试规则 */ +export async function removeRules(data: { key: number[] }, options?: Record) { + console.log('data:::', data); + return request>('/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 || {}), + }); } \ No newline at end of file From 764e73196da4e43bb978e08ec27c457db82ee493 Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Thu, 17 Feb 2022 11:34:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8D=87=E7=BA=A7charts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/package.json | 2 +- admin/src/pages/demo/index.tsx | 115 ++++++++++++++++++++++++++++++++- 2 files changed, 113 insertions(+), 4 deletions(-) diff --git a/admin/package.json b/admin/package.json index fa91771..4150cdf 100644 --- a/admin/package.json +++ b/admin/package.json @@ -49,7 +49,7 @@ "not ie <= 10" ], "dependencies": { - "@ant-design/charts": "^0.9.4", + "@ant-design/charts": "^1.3.5", "@ant-design/icons": "^4.5.0", "@ant-design/pro-card": "^1.18.23", "@ant-design/pro-descriptions": "^1.6.8", diff --git a/admin/src/pages/demo/index.tsx b/admin/src/pages/demo/index.tsx index 4f9fba5..9220aa7 100644 --- a/admin/src/pages/demo/index.tsx +++ b/admin/src/pages/demo/index.tsx @@ -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(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( <> @@ -103,6 +210,8 @@ export default () => { Delete + + ) };