Commit 05d5a740 authored by XieZhiXiong's avatar XieZhiXiong

feat: 添加虚假的分页

parent 7af88ab6
.config-table {
:global {
.ant-pagination-options-size-changer {
&.ant-select {
width: auto !important;
}
}
}
}
\ No newline at end of file
...@@ -2,16 +2,20 @@ ...@@ -2,16 +2,20 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2021-05-28 15:24:56 * @Date: 2021-05-28 15:24:56
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-01 14:44:31 * @LastEditTime: 2021-06-18 15:57:10
* @Description: * @Description:
*/ */
import React from 'react'; import React, { useState } from 'react';
import { Popconfirm, Button, Row, Col } from 'antd'; import { Popconfirm, Button, Row, Col } from 'antd';
import theme from '../../../../../../../../config/lingxi.theme.config'; import theme from '../../../../../../../../config/lingxi.theme.config';
import PolymericTable from '@/components/PolymericTable'; import PolymericTable from '@/components/PolymericTable';
import { EditableColumns } from '@/components/PolymericTable/interface'; import { EditableColumns } from '@/components/PolymericTable/interface';
import { pagingArr } from './utils';
import ComingCtl, { ValueType as ComingCtlValueType } from '../ComingCtl'; import ComingCtl, { ValueType as ComingCtlValueType } from '../ComingCtl';
import Search from '../Search'; import Search from '../Search';
import styles from './index.less';
const PAGE_SIZE = 5;
const ComingConfigTable = (props) => { const ComingConfigTable = (props) => {
const { const {
...@@ -20,6 +24,9 @@ const ComingConfigTable = (props) => { ...@@ -20,6 +24,9 @@ const ComingConfigTable = (props) => {
editable, editable,
} = props; } = props;
const { roleId } = (props.props['x-component-props'] || {}); const { roleId } = (props.props['x-component-props'] || {});
const [keyword, setKeyword] = useState('');
const [page, setPage] = useState(1);
const [size, setSize] = useState(PAGE_SIZE);
const handleDelete = (id: number) => { const handleDelete = (id: number) => {
const newData = [...value]; const newData = [...value];
...@@ -70,12 +77,25 @@ const ComingConfigTable = (props) => { ...@@ -70,12 +77,25 @@ const ComingConfigTable = (props) => {
}, },
]; ];
const handleSearch = (next: string) => {
setKeyword(next);
setPage(1);
};
const handleConfirm = (value: ComingCtlValueType[]) => { const handleConfirm = (value: ComingCtlValueType[]) => {
mutators.change(value); mutators.change(value);
}; };
const handlePaginationChange = (current: number, pageSize: number) => {
setPage(current);
setSize(pageSize);
};
const filtered = keyword ? value.filter((item) => item.fieldLocalName.includes(keyword)) : [...value];
const dataSource = pagingArr(page, size, filtered);
return ( return (
<> <div className={styles['config-table']}>
<Row <Row
justify="space-between" justify="space-between"
style={{ style={{
...@@ -91,17 +111,26 @@ const ComingConfigTable = (props) => { ...@@ -91,17 +111,26 @@ const ComingConfigTable = (props) => {
/> />
</Col> </Col>
<Col span={6}> <Col span={6}>
<Search value={''} onChange={() => {}} onSearch={() => {}} /> <Search onSearch={handleSearch} />
</Col> </Col>
</Row> </Row>
<PolymericTable <PolymericTable
rowKey="id" rowKey="id"
dataSource={value} dataSource={dataSource}
columns={columns} columns={columns}
loading={false} loading={false}
pagination={null} pagination={(
!editable
? {
current: page,
pageSize: size,
total: filtered.length,
}
: null
)}
onPaginationChange={handlePaginationChange}
/> />
</> </div>
); );
}; };
......
/*
* @Author: XieZhiXiong
* @Date: 2021-06-18 14:56:03
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-18 15:26:10
* @Description:
*/
export function pagingArr(page, size, arr) {
const sub = [...arr];
const star = (page - 1) * size;
const end = star + size;
return sub.slice(star, end);
};
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* @LastEditTime: 2021-06-08 16:27:02 * @LastEditTime: 2021-06-08 16:27:02
* @Description: 搜索组件 * @Description: 搜索组件
*/ */
import React from 'react'; import React, { useState, useEffect } from 'react';
import { Input, Button } from 'antd'; import { Input, Button } from 'antd';
import styles from './index.less'; import styles from './index.less';
...@@ -13,15 +13,15 @@ interface IProps { ...@@ -13,15 +13,15 @@ interface IProps {
/** /**
* 值 * 值
*/ */
value: string, value?: string,
/** /**
* 输入改变触发事件 * 输入改变触发事件
*/ */
onChange: (value: string) => void, onChange?: (value: string) => void,
/** /**
* 搜索事触发事件 * 搜索事触发事件
*/ */
onSearch: (value: string) => void, onSearch?: (value: string) => void,
/** /**
* 点击重置按钮触发事件 * 点击重置按钮触发事件
*/ */
...@@ -41,8 +41,18 @@ const MySearch: React.FC<IProps> = (props: IProps) => { ...@@ -41,8 +41,18 @@ const MySearch: React.FC<IProps> = (props: IProps) => {
searchOnResetAction, searchOnResetAction,
...rest ...rest
} = props; } = props;
const [keyword, setKeyword] = useState('');
useEffect(() => {
if ('value' in props) {
setKeyword(value);
}
}, [value]);
const handleChange = (e) => { const handleChange = (e) => {
if (!('value' in props)) {
setKeyword(e.target.value);
}
if (onChange) { if (onChange) {
onChange(e.target.value); onChange(e.target.value);
} }
...@@ -68,7 +78,7 @@ const MySearch: React.FC<IProps> = (props: IProps) => { ...@@ -68,7 +78,7 @@ const MySearch: React.FC<IProps> = (props: IProps) => {
<div className={styles.search}> <div className={styles.search}>
<Input.Search <Input.Search
style={{ width: '200px', marginRight: 16 }} style={{ width: '200px', marginRight: 16 }}
value={props.value || ''} value={keyword}
onChange={handleChange} onChange={handleChange}
onSearch={handleSearch} onSearch={handleSearch}
{...rest} {...rest}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2021-05-27 16:13:05 * @Date: 2021-05-27 16:13:05
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-01 14:56:14 * @LastEditTime: 2021-06-18 15:54:33
* @Description: * @Description:
*/ */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
...@@ -153,6 +153,11 @@ const FlowRuleForm: React.FC<MemberFormProps> = ({ ...@@ -153,6 +153,11 @@ const FlowRuleForm: React.FC<MemberFormProps> = ({
} }
}; };
const isAdd = !id && isEdit;
const configIdsProps = {
isAdd,
};
return ( return (
<Spin spinning={infoLoading}> <Spin spinning={infoLoading}>
<PageHeaderWrapper <PageHeaderWrapper
...@@ -161,7 +166,7 @@ const FlowRuleForm: React.FC<MemberFormProps> = ({ ...@@ -161,7 +166,7 @@ const FlowRuleForm: React.FC<MemberFormProps> = ({
}} }}
onBack={() => history.goBack()} onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />} backIcon={<ReutrnEle description="返回" />}
title={!id ? isEdit ? '新增会员管理流程规则' : '查看会员管理流程规则' : '编辑会员管理流程规则会员'} title={!id ? '新增会员管理流程规则' : isEdit ? '编辑会员管理流程规则会员' : '查看会员管理流程规则'}
extra={[ extra={[
(isEdit ? ( (isEdit ? (
<Button <Button
...@@ -190,6 +195,9 @@ const FlowRuleForm: React.FC<MemberFormProps> = ({ ...@@ -190,6 +195,9 @@ const FlowRuleForm: React.FC<MemberFormProps> = ({
PlatformConfigTable, PlatformConfigTable,
ComingConfigTable, ComingConfigTable,
}} }}
expressionScope={{
configIdsProps,
}}
effects={($, actions) => { effects={($, actions) => {
createEffects($, actions); createEffects($, actions);
onFormInputChange$().subscribe(() => { onFormInputChange$().subscribe(() => {
......
...@@ -147,9 +147,7 @@ const formSchema: ISchema = { ...@@ -147,9 +147,7 @@ const formSchema: ISchema = {
configIds: { configIds: {
type: 'string', type: 'string',
'x-component': 'ComingConfigTable', 'x-component': 'ComingConfigTable',
'x-component-props': { 'x-component-props': {},
},
}, },
}, },
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment