diff --git a/blocks/procomponents/src/service.ts b/blocks/procomponents/src/service.ts index d3fa2a4..3b4b55b 100644 --- a/blocks/procomponents/src/service.ts +++ b/blocks/procomponents/src/service.ts @@ -1,7 +1,6 @@ // @ts-ignore import { request } from 'umi'; import { TableListItem } from './data'; -import type { ProFormColumnsType } from '@ant-design/pro-form'; /** 获取考点数据结构 GET /api/dataSource?key=examination&schema=true&data=false */ export async function schemaExamination( diff --git a/package.json b/package.json index 285a3d1..910ba73 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "@antv/l7-react": "^2.1.9", "@umijs/block-sdk": "^2.3.0", "@umijs/route-utils": "^1.0.36", - "ahooks": "^2.0.0", + "ahooks": "^3.0.5", "ahooks-v2": "^2.10.15", "antd": "^4.14.0", "bizcharts": "^3.5.3-beta.0", @@ -81,7 +81,7 @@ "react-fittext": "^1.0.0", "react-helmet-async": "^1.0.4", "react-router": "^4.3.1", - "umi": "^3.5.0", + "umi": "^3.5.20", "umi-block-convertor": "^1.0.1", "umi-request": "^1.4.0", "umi-serve": "^1.9.10" diff --git a/src/pages/ListTableList2/index.tsx b/src/pages/ListTableList2/index.tsx index ca132a9..04ed75e 100644 --- a/src/pages/ListTableList2/index.tsx +++ b/src/pages/ListTableList2/index.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useRef, useState } from 'react'; -import { useRequest } from 'ahooks-v2'; +import { useRequest } from 'umi'; import type { ActionType } from '@ant-design/pro-table'; // import type { ProFormColumnsType } from '@ant-design/pro-form'; @@ -7,7 +7,7 @@ import { PageContainer } from '@ant-design/pro-layout'; import ProTable from '@ant-design/pro-table'; import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions'; import ProDescriptions from '@ant-design/pro-descriptions'; -import { BetaSchemaForm} from '@ant-design/pro-form'; +import { BetaSchemaForm } from '@ant-design/pro-form'; import { Button, Col, Modal, Row, Space } from 'antd'; import { MobileOutlined, PhoneOutlined, PlusOutlined } from '@ant-design/icons'; @@ -18,7 +18,7 @@ import type { DataItem } from '../dashboard/analysis/data'; export type TableListItem = { id: string; code: number; - name: string; + name: string; creator: string; status: string; createdAt: number; @@ -41,82 +41,110 @@ export default () => { useEffect(() => { const _data = data || []; let idx = -1; - idx = _data?.findIndex((val: { dataIndex: string; })=>{ return val.dataIndex === 'publicTelephone' }) || -1; - if(idx !== -1){ - _data[idx] = {..._data[idx], renderText: (val: string) => `${(val || '').replace(/(\d{2})(\d{2})(\d{4})/,"$1**$3")}`} + idx = + _data?.findIndex((val: { dataIndex: string }) => { + return val.dataIndex === 'publicTelephone'; + }) || -1; + if (idx !== -1) { + _data[idx] = { + ..._data[idx], + renderText: (val: string) => `${(val || '').replace(/(\d{2})(\d{2})(\d{4})/, '$1**$3')}`, + }; } /** 渲染复合数据项 */ - idx = _data?.findIndex((val: { dataIndex: string; })=>{ return val.dataIndex === 'examiner' }) || -1; - if(idx !== -1){ + idx = + _data?.findIndex((val: { dataIndex: string }) => { + return val.dataIndex === 'examiner'; + }) || -1; + if (idx !== -1) { _data[idx] = { - ..._data[idx], + ..._data[idx], render: (text: any) => ( <> {text?.realname} - {text?.tel} - {text?.mobile} + + {text?.tel} + + + {text?.mobile} + - ) - } + ), + }; } /** 添加序号和操作列 */ - setColumns( - [ - { - title: '序号', - key: 'index', - valueType: 'indexBorder', - render: (text: React.ReactNode, _: any, index: number) =>{ - if(ref && ref?.current && ref?.current?.pageInfo){ - return `${(ref?.current?.pageInfo?.current - 1) * (ref.current.pageInfo?.pageSize) + (index + 1)}`; - }else{ - return ''; - } - }, - width: 48, + setColumns([ + { + title: '序号', + key: 'index', + valueType: 'indexBorder', + render: (text: React.ReactNode, _: any, index: number) => { + if (ref && ref?.current && ref?.current?.pageInfo) { + return `${ + (ref?.current?.pageInfo?.current - 1) * ref.current.pageInfo?.pageSize + (index + 1) + }`; + } else { + return ''; + } }, - ..._data, - { - title: '操作', - width: 180, - key: 'option', - valueType: 'option', - render: (_dom: any, entity: React.SetStateAction) => [ - { + width: 48, + }, + ..._data, + { + title: '操作', + width: 180, + key: 'option', + valueType: 'option', + render: (_dom: any, entity: React.SetStateAction) => [ + { console.log('entity', entity); setCurrentRow(entity); setShowDetail(true); - }} >查看, - { - console.log('columns1', columns) + }} + > + 查看 + , + { + console.log('columns1', columns); setCurrentRow(entity); setShowUpdate(true); - console.log('columns2', columns) - }} >编辑, - { + console.log('columns2', columns); + }} + > + 编辑 + , + { // - }} >删除, - ], - } - ] - ); + }} + > + 删除 + , + ], + }, + ]); }, [data]); /** 获取列数据初始值 */ const getInitialValues = (cols: any[], vals: any) => { - console.log('getInitialValues-columns', columns) - console.log('getInitialValues-values', vals) + console.log('getInitialValues-columns', columns); + console.log('getInitialValues-values', vals); const initialValues: any[] = []; - cols.forEach((column: { dataIndex: string; }) => { + cols.forEach((column: { dataIndex: string }) => { const key: any = column?.dataIndex || ''; - initialValues.push({...column, initialValue: key ? vals[key] : ''}) - }) - console.log('initialValues::',initialValues) - return initialValues || [] - } - + initialValues.push({ ...column, initialValue: key ? vals[key] : '' }); + }); + console.log('initialValues::', initialValues); + return initialValues || []; + }; + return ( @@ -135,43 +163,52 @@ export default () => { /*toolbar={{ title: '高级表格', tooltip: '这是一个标题提示', - }}*/ + }}*/ toolBarRender={() => [ - + , ]} /> { setCurrentRow(undefined); // 设置当前行 setShowDetail(false); }} - footer={null}> + footer={null} + > {currentRow?.name && ( - - column={2} - /* title={currentRow?.name} */ - dataSource={currentRow} - /* + + column={2} + /* title={currentRow?.name} */ + dataSource={currentRow} + /* request={async () => ({ data: currentRow || {}, })}*/ - params={{ - id: currentRow?.id, - }} - columns={columns.slice(0, columns.length - 1) as ProDescriptionsItemProps[]} - /> - )} + params={{ + id: currentRow?.id, + }} + columns={ + columns.slice(0, columns.length - 1) as ProDescriptionsItemProps[] + } + /> + )} { @@ -179,10 +216,10 @@ export default () => { }} footer={null} > - - layout = 'horizontal' - layoutType = 'Form' - labelCol = {{ span: 8 }} + + layout="horizontal" + layoutType="Form" + labelCol={{ span: 8 }} wrapperCol={{ span: 12 }} onFinish={async (values) => { console.log(values); @@ -197,45 +234,45 @@ export default () => { ), }} // action = '' - title = "新建" - columns = {columns} + title="新建" + columns={columns} /> { setShowUpdate(false); }} - footer={null}> + footer={null} + > {currentRow?.name && ( - - layout = 'horizontal' - layoutType = 'Form' - labelCol = {{ span: 8 }} - wrapperCol={{ span: 12 }} - onFinish={async (values) => { - console.log(values); - }} - submitter={{ - render: (props, doms) => ( - - - {doms} - - - ), - }} - // action = '' - title = "编辑" - columns = {getInitialValues(columns, currentRow)} - /> - )} + + layout="horizontal" + layoutType="Form" + labelCol={{ span: 8 }} + wrapperCol={{ span: 12 }} + onFinish={async (values) => { + console.log(values); + }} + submitter={{ + render: (props, doms) => ( + + + {doms} + + + ), + }} + // action = '' + title="编辑" + columns={getInitialValues(columns, currentRow)} + /> + )} - - + ); -}; \ No newline at end of file +}; diff --git a/src/pages/ListTableList2/service.ts b/src/pages/ListTableList2/service.ts index f4b5486..8931062 100644 --- a/src/pages/ListTableList2/service.ts +++ b/src/pages/ListTableList2/service.ts @@ -2,12 +2,6 @@ /* eslint-disable */ import { request } from 'umi'; import { TableListItem } from './data'; -import type { ProFormColumnsType } from '@ant-design/pro-form'; - -type DataItem = { - name: string; - state: string; -}; /** 获取考点数据结构 GET /api/dataSource?key=examination&schema=true&data=false */ export async function schemaExamination( @@ -56,7 +50,10 @@ export async function dataExamination( } /** 新建考点 PUT /api/dataSource?key=examination */ -export async function updateExamination(data: { [key: string]: any }, options?: { [key: string]: any }) { +export async function updateExamination( + data: { [key: string]: any }, + options?: { [key: string]: any }, +) { return request('/api/examination', { data, method: 'PUT', @@ -65,7 +62,10 @@ export async function updateExamination(data: { [key: string]: any }, options?: } /** 新建考点 POST /api/dataSource?key=examination */ -export async function addExamination(data: { [key: string]: any }, options?: { [key: string]: any }) { +export async function addExamination( + data: { [key: string]: any }, + options?: { [key: string]: any }, +) { return request('/api/examination', { data, method: 'POST', diff --git a/src/pages/user/Login/index.tsx b/src/pages/user/Login/index.tsx index 90aea52..2624b30 100644 --- a/src/pages/user/Login/index.tsx +++ b/src/pages/user/Login/index.tsx @@ -1,8 +1,4 @@ -import { - LockOutlined, - MobileOutlined, - UserOutlined, -} from '@ant-design/icons'; +import { LockOutlined, MobileOutlined, UserOutlined } from '@ant-design/icons'; import { Alert, message, Tabs } from 'antd'; import React, { useState } from 'react'; import { ProFormCaptcha, ProFormCheckbox, ProFormText, LoginForm } from '@ant-design/pro-form'; @@ -48,10 +44,7 @@ const Login: React.FC = () => { // 登录 const msg = await login({ ...values, type }); if (msg.status === 'ok') { - const defaultLoginSuccessMessage = intl.formatMessage({ - id: 'pages.login.success', - defaultMessage: '登录成功!', - }); + const defaultLoginSuccessMessage = '登录成功!'; message.success(defaultLoginSuccessMessage); await fetchUserInfo(); /** 此方法会跳转到 redirect 参数所在的位置 */ @@ -65,10 +58,7 @@ const Login: React.FC = () => { // 如果失败去设置用户错误信息 setUserLoginState(msg); } catch (error) { - const defaultLoginFailureMessage = intl.formatMessage({ - id: 'pages.login.failure', - defaultMessage: '登录失败,请重试!', - }); + const defaultLoginFailureMessage = '登录失败,请重试!'; message.error(defaultLoginFailureMessage); } }; @@ -82,36 +72,23 @@ const Login: React.FC = () => {
} - title="基础数据" - subTitle="DSBase Universal V1.0" + title="大数据上报平台" + subTitle="考务管理 V1.0.0" initialValues={{ autoLogin: true, }} - actions={[ - - ]} + actions={[]} onFinish={async (values) => { await handleSubmit(values as API.LoginParams); }} > - - + + {status === 'error' && loginType === 'account' && ( - + )} {type === 'account' && ( <> @@ -122,10 +99,7 @@ const Login: React.FC = () => { size: 'large', prefix: , }} - placeholder={intl.formatMessage({ - id: 'pages.login.username.placeholder', - defaultMessage: '用户名: admin or user', - })} + placeholder="用户名: admin or user" rules={[ { required: true, @@ -145,10 +119,7 @@ const Login: React.FC = () => { size: 'large', prefix: , }} - placeholder={intl.formatMessage({ - id: 'pages.login.password.placeholder', - defaultMessage: '密码: ant.design', - })} + placeholder="密码: ant.design" rules={[ { required: true, @@ -252,14 +223,14 @@ const Login: React.FC = () => { }} > - + <>自动登录 - + <>忘记密码