Commit cdafc0f7 authored by zhangwenshuai's avatar zhangwenshuai

update

parent b2aecf3c
@import '../../common'; @import '../../common';
.cell { .detailCell {
max-width: 100%; display: flex;
min-width: 100%; align-items: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
height: 100%; height: 100%;
font-size: @textFontGen;
&.disabled { padding: 0 10px;
background: @disabledColor;
}
.cellContent {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
height: 100%;
font-size: 14px;
}
} }
.editCell {
.editPop { position: absolute;
width: 300px; z-index: 1;
width: 100%;
:global(.ant-popover-inner){ top: 0;
box-shadow: none; left: 0;
}
:global(.ant-popover-inner-content) {
padding: 0;
border: 1px solid @primaryColor;
border-radius: 2px;
}
}
.menuPop {
width: 110px;
:global(.ant-popover-inner-content) {
padding: @paddingSmX 0;
border-radius: @borderRadius;
background: #333333;
}
.menuContainer {
.splitLine {
height: 1px;
background: white;
opacity: 0.2;
}
.menu {
display: flex;
height: 28px;
padding: 0 @paddingGen;
align-items: center;
cursor: pointer;
&:hover {
background: rgba(216, 216, 216, 0.1);
}
.menuIcon {
width: 12px;
margin-right: @marginSmX;
color: white;
font-size: @textFontGen;
display: flex;
}
.menuTitle {
font-size: @textFontGen;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: white;
}
}
}
} }
This diff is collapsed.
@import '../../common'; @import '../../common';
.tableCell {
&.sortCol {
background: @hoverColor;
}
}
.indexCell {
padding: 0 10px;
display: flex;
justify-content: flex-start;
align-items: center;
height: 100%;
&.disabled {
background: @disabledColor;
&:hover {
box-shadow: none;
}
}
&:hover {
box-shadow: inset 0 0 0 1px @operateColor;
.showFormBtnCls {
.showFormBtn {
display: initial;
}
}
.unchecked {
display: initial;
}
.no {
display: none;
}
.addCls {
.addIcon {
display: initial;
}
}
}
.cellNo {
display: flex;
align-items: center;
min-width: 50px;
}
.cellContent {
flex: 1;
overflow: hidden;
height: 100%;
display: flex;
align-items: center;
.firstCell {
min-width: 0;
max-width: 80%;
}
.empty {
min-width: 80%;
}
.historyCount {
margin: @marginSmX;
cursor: pointer;
.countNo {
color: @primaryColor;
}
}
}
.addCls {
width: 20px;
text-align: center;
cursor: pointer;
height: 16px;
.addIcon {
display: none;
color: @primaryColor;
}
}
.unchecked {
display: none;
}
.no {
width: 17px;
display: block;
text-align: center;
white-space: nowrap;
}
.showFormBtnCls {
margin: 0 5px;
width: 18px;
cursor: pointer;
.showFormBtn {
display: none;
width: 18px;
border-radius: 50%;
&:hover {
background: #d0f0fd;
}
}
}
}
.GridRow { .GridRow {
position: relative; position: relative;
display: flex; display: flex;
...@@ -171,11 +61,6 @@ ...@@ -171,11 +61,6 @@
width: 100%; width: 100%;
outline: none; outline: none;
} }
.bodyRow {
width: 100%;
box-sizing: border-box;
}
.bodyCell { .bodyCell {
width: 100%; font-size: 20px;
height: 100%;
} }
This diff is collapsed.
export const formatStr = 'YYYY-MM-DD HH:mm:ss'; export const formatStr = 'YYYY-MM-DD HH:mm:ss';
export const emptyModel = [{ text: '', value: '' }]; export const emptyModel = [{ text: '', value: '' }];
const emptyFormat = (value) => {};
export const SetFormatter = { export const SetFormatter = {
INPUT: (event) => { INPUT: (event) => {
const node = event.currentTarget || {}; const node = event.currentTarget || {};
...@@ -16,9 +17,11 @@ export const SetFormatter = { ...@@ -16,9 +17,11 @@ export const SetFormatter = {
})); }));
} }
}, },
TEXTAREA: (event) => { TEXTAREA: (value) => {
const node = event.currentTarget || {}; if (!value) {
return [{ value: node.value, text: node.value }]; return emptyModel;
}
return [{ value: value, text: value }];
}, },
UPLOAD: (val) => { UPLOAD: (val) => {
if (!val) return null; if (!val) return null;
......
...@@ -25,7 +25,8 @@ export const config: any = { ...@@ -25,7 +25,8 @@ export const config: any = {
getFormatter: GetFormatter['TEXTAREA'], getFormatter: GetFormatter['TEXTAREA'],
setFormatter: SetFormatter['TEXTAREA'], setFormatter: SetFormatter['TEXTAREA'],
componentAttr: { componentAttr: {
autosize: { minRows: 3 }, autoSize: true,
emitTrigger: 'onBlur',
}, },
detail: require('./detail/textarea').default, detail: require('./detail/textarea').default,
}, },
......
...@@ -26,14 +26,7 @@ export const getDetail = (type: string) => { ...@@ -26,14 +26,7 @@ export const getDetail = (type: string) => {
const transferColumn = transferAttr(columnType, newProps); const transferColumn = transferAttr(columnType, newProps);
return ( return (
<div className={styles.container}> <Detail {...this.props} componentAttr={transferColumn} formatter={NodeObj.getFormatter} value={value} />
<Detail
{...this.props}
componentAttr={transferColumn}
formatter={NodeObj.getFormatter}
value={value}
/>
</div>
); );
} }
}; };
......
import { DatePickerProps } from 'antd/es/date-picker/interface'; import { DatePickerProps } from 'antd/es/date-picker/interface';
import { TextAreaProps } from 'antd/es/input';
export interface CommonProps { export interface CommonProps {
value: any[] | undefined; onEmitChange?: Function;
placeholder?: string; emitTrigger?: string;
formatter?: Function;
onChange: any;
disabled?: boolean;
} }
export interface InputProps extends CommonProps { export interface InputProps extends CommonProps {
maxLength: number; maxLength: number;
...@@ -18,9 +16,8 @@ export interface LinkState { ...@@ -18,9 +16,8 @@ export interface LinkState {
prevProps: LinkProps; prevProps: LinkProps;
value: any[]; value: any[];
} }
export interface TextAreaProps extends CommonProps { export interface ApolloTextAreaProps extends TextAreaProps, CommonProps {
maxLength: number; value: string | undefined;
autosize?: boolean | any;
} }
export interface SearchProps extends CommonProps { export interface SearchProps extends CommonProps {
type: string; type: string;
......
import React from 'react'; import React, { useEffect, useState } from 'react';
import { Input } from 'antd'; import { Input } from 'antd';
import styles from './styles.less'; import styles from './styles.less';
import { TextAreaProps } from '../editInterface'; import { antiAssign } from '@/apollo-table/utils/utils';
import { ApolloTextAreaProps } from '../editInterface';
export default function(props: TextAreaProps) { const TextArea = (props: ApolloTextAreaProps) => {
const { maxLength, value, disabled, placeholder, autosize } = props; const { maxLength, onChange, emitTrigger, onEmitChange } = props;
const selfProps = { value, disabled, placeholder, autosize }; const selfProps = antiAssign(props, ['value', 'onChange', 'emitTrigger', 'onEmitChange']);
const [value, setValue] = useState(props.value);
useEffect(() => {
setValue(props.value);
}, [props.value]);
const changeValue = (e) => {
setValue(e.target.value);
if (typeof onChange === 'function') {
onChange(e.target.value);
}
if (!emitTrigger || emitTrigger === 'onChange') {
emitChange(e);
}
};
const emitChange = (e) => {
if (typeof onEmitChange === 'function') {
onEmitChange(e.target.value);
}
};
if (emitTrigger === 'onBlur') {
selfProps.onBlur = emitChange;
}
return ( return (
<div className={styles.container}> <div className={styles.container}>
<Input.TextArea className={styles.input} {...selfProps} /> <Input.TextArea className={styles.input} {...selfProps} value={value} onChange={changeValue} />
{maxLength ? ( {maxLength && (
<span className={styles.wordNumber}>{`已输入${(value || '').length || 0}/${maxLength}`}</span> <span className={styles.wordNumber}>{`已输入${(value || '').length}/${maxLength}`}</span>
) : null} )}
</div> </div>
); );
} };
export default TextArea;
.container{ .container {
position: relative; position: relative;
top:0; top: 0;
left: 0; left: 0;
.input{ .input {
padding-bottom: 18px; padding-bottom: 18px;
} }
textarea{ textarea {
padding-bottom: 18px; padding-bottom: 18px;
} }
.wordNumber{ .wordNumber {
position: absolute; position: absolute;
right:12px; right: 12px;
bottom: 2px; bottom: 2px;
color:#E1E1E1FF; color: #e1e1e1ff;
font-size: 12px; font-size: 12px;
} }
} }
...@@ -17,11 +17,8 @@ export const getComponent = (type: string) => { ...@@ -17,11 +17,8 @@ export const getComponent = (type: string) => {
console.error(type + '组件未定义'); console.error(type + '组件未定义');
return; return;
} }
const setFormat = (columnConfig: any, values: any[]) => { const setFormat = (columnConfig: any, value: any[]) => {
const { columnAttrObj, columnType } = columnConfig || {}; const { columnAttrObj, columnType } = columnConfig || {};
if (!values || values.length <= 0) return undefined;
const value = values[0] || undefined;
if (!value) return undefined;
const transferColumn = transferAttr(columnType, { const transferColumn = transferAttr(columnType, {
...(NodeObj.componentAttr || {}), ...(NodeObj.componentAttr || {}),
...(columnAttrObj || {}), ...(columnAttrObj || {}),
...@@ -30,67 +27,59 @@ export const getComponent = (type: string) => { ...@@ -30,67 +27,59 @@ export const getComponent = (type: string) => {
return value; return value;
}; };
const getFormat = (columnConfig: any, values: any) => { const getFormat = (columnConfig: any, value: any) => {
const { columnAttrObj, columnType } = columnConfig || {}; const { columnAttrObj, columnType } = columnConfig || {};
if (!values || !Array.isArray(values) || values.length <= 0) return undefined; if (!value || !Array.isArray(value) || value.length <= 0) return undefined;
const newValue = values.filter((item) => {
return item.value || item.value === 0 || item.label || item.text;
});
const transferColumn = transferAttr(columnType, { const transferColumn = transferAttr(columnType, {
...(NodeObj.componentAttr || {}), ...(NodeObj.componentAttr || {}),
...(columnAttrObj || {}), ...(columnAttrObj || {}),
}); });
if (NodeObj.getFormatter) { if (NodeObj.getFormatter) {
return NodeObj.getFormatter(newValue, transferColumn); return NodeObj.getFormatter(value, transferColumn);
} }
return newValue; return value;
}; };
const com: any = class Base extends React.Component<BaseComponentProps, BaseComponentState> { const com: any = class Base extends React.Component<BaseComponentProps, BaseComponentState> {
static getDerivedStateFromProps(nextProps: BaseComponentProps, prevState: BaseComponentState) { static getDerivedStateFromProps(nextProps: BaseComponentProps, prevState: BaseComponentState) {
const { prevProps } = prevState; const { columnConfig } = prevState;
let nextState: BaseComponentState = { let nextState: BaseComponentState = {
...prevState, ...prevState,
prevProps: nextProps,
columnConfig: nextProps.columnConfig,
value: getFormat(nextProps.columnConfig, nextProps.value),
}; };
if (JSON.stringify(prevProps.columnConfig) !== JSON.stringify(nextProps.columnConfig)) { if (JSON.stringify(columnConfig) !== JSON.stringify(nextProps.columnConfig)) {
nextState.columnConfig = nextProps.columnConfig; nextState.columnConfig = nextProps.columnConfig;
} }
if (JSON.stringify(nextProps.value) !== JSON.stringify(nextProps.value)) {
nextState.value = getFormat(nextProps.columnConfig, nextProps.value);
}
return nextState; return nextState;
} }
constructor(props: BaseComponentProps) { constructor(props: BaseComponentProps) {
super(props); super(props);
const { columnConfig } = props;
this.state = { this.state = {
prevProps: props, columnConfig,
value: undefined,
columnConfig: {},
}; };
} }
onChange = ({ changedValue, isBlur }: any) => { onChange = (changedValue: any) => {
const { columnConfig } = this.state; const { columnConfig } = this.state;
const { onChange, changeParams } = this.props; const { onChange } = this.props;
let value = setFormat(columnConfig, changedValue); let value = setFormat(columnConfig, changedValue);
// 置空默认逻辑
if (value && value.length === 0) {
value = emptyModel;
}
if (typeof onChange === 'function') { if (typeof onChange === 'function') {
onChange(value); onChange(value);
} }
if (typeof changeParams === 'function') { };
changeParams({ value, changedValue, isBlur }); // 触发修改回调
onEmitChange = (changedValue: any) => {
const { columnConfig } = this.state;
const { onEmitChange } = this.props;
let value = setFormat(columnConfig, changedValue);
if (typeof onEmitChange === 'function') {
onEmitChange(value,changedValue);
} }
}; };
render() { render() {
const { ...others } = this.props; const { value, ...others } = this.props;
const { columnConfig, value } = this.state; const { columnConfig } = this.state;
const { columnAttrObj, columnType } = columnConfig || {}; const { columnAttrObj, columnType } = columnConfig || {};
let transferColumn = transferAttr(columnType, { let transferColumn = transferAttr(columnType, {
...(NodeObj.componentAttr || {}), ...(NodeObj.componentAttr || {}),
...@@ -100,7 +89,14 @@ export const getComponent = (type: string) => { ...@@ -100,7 +89,14 @@ export const getComponent = (type: string) => {
...others, ...others,
...(transferColumn || {}), ...(transferColumn || {}),
}; };
return <Node {...newProps} value={value} onChange={this.onChange} />; return (
<Node
{...newProps}
value={getFormat(columnConfig, value)}
onChange={this.onChange}
onEmitChange={this.onEmitChange}
/>
);
} }
}; };
com.Detail = getDetail(type); com.Detail = getDetail(type);
......
...@@ -5,32 +5,26 @@ import Table from './Table'; ...@@ -5,32 +5,26 @@ import Table from './Table';
class AirTable extends React.Component<CommonProps, CommonState> { class AirTable extends React.Component<CommonProps, CommonState> {
static getDerivedStateFromProps(nextProps: CommonProps, prevState: CommonState) { static getDerivedStateFromProps(nextProps: CommonProps, prevState: CommonState) {
const { prevProps } = prevState; const { columns, dataSource } = prevState;
let nextState: CommonState = { let nextState: CommonState = {
...prevState, ...prevState,
prevProps: nextProps,
}; };
if (JSON.stringify(prevProps.dataSource) !== JSON.stringify(nextProps.dataSource)) { if (JSON.stringify(dataSource) !== JSON.stringify(nextProps.dataSource)) {
nextState.dataSource = nextProps.dataSource; nextState.dataSource = nextProps.dataSource;
} }
if (JSON.stringify(prevProps.columns) !== JSON.stringify(nextProps.columns)) { if (JSON.stringify(columns) !== JSON.stringify(nextProps.columns)) {
nextState.columns = nextProps.columns; nextState.columns = nextProps.columns;
} }
if (prevProps.tableId !== nextProps.tableId) {
nextState.tableId = nextProps.tableId;
}
return nextState; return nextState;
} }
constructor(props: CommonProps) { constructor(props: CommonProps) {
super(props); super(props);
const { columns, dataSource, tableId } = props; const { columns, dataSource } = props;
this.state = { this.state = {
prevProps: props,
columns, columns,
dataSource, dataSource,
tableId,
}; };
} }
...@@ -42,20 +36,20 @@ class AirTable extends React.Component<CommonProps, CommonState> { ...@@ -42,20 +36,20 @@ class AirTable extends React.Component<CommonProps, CommonState> {
}; };
render() { render() {
const { columns, dataSource, tableId } = this.state; const { columns, dataSource } = this.state;
const { rowStyle, rowClassName } = this.props; const { rowStyle, rowClassName, distanceToLoad, emitChangeCell, bordered } = this.props;
const operateConfig = {};
return ( return (
<div className={styles.container}> <div className={styles.container}>
<div className={styles.tableContainer}> <div className={styles.tableContainer}>
<Table <Table
columns={columns} columns={columns}
dataSource={dataSource} dataSource={dataSource}
tableId={tableId}
onScroll={this.onScroll} onScroll={this.onScroll}
operateConfig={operateConfig}
rowStyle={rowStyle} rowStyle={rowStyle}
rowClassName={rowClassName} rowClassName={rowClassName}
distanceToLoad={distanceToLoad}
emitChangeCell={emitChangeCell}
bordered={bordered}
/> />
</div> </div>
</div> </div>
......
import React from 'react'; import React from 'react';
export interface CommonProps { export interface OperateConfigProps {
menusGroup?: Object[];
buttonsGroup?: Object[];
moreGroup?: Object[];
}
export interface LoadConfigProps {
onScroll?: Function;
distanceToLoad?: number;
}
export interface EmitChangeProps {
emitChangeCell: Function;
emitChangeRow?: Function;
emitChangeColumns?: Function;
emitChangeOperate?: Function;
}
export interface TableProps extends LoadConfigProps {
columns: any[]; columns: any[];
dataSource: any[]; dataSource: any[];
tableId: number;
checked?: any[];
columnWidth?: number;
rowClassName?: string | Function; rowClassName?: string | Function;
rowStyle?: Object | Function; rowStyle?: Object | Function;
rowRenderer?: Function; rowRenderer?: Function;
onScroll?:Function; bordered?: boolean;
height?: number;
width?: number;
emitChangeCell: Function;
} }
export interface TableState {
export interface CommonState {
prevProps: CommonProps;
columns: any[]; columns: any[];
dataSource: any[]; dataSource: any[];
tableId: number; tableHeight?: number;
checked?: any[]; tableWidth?: number;
columnWidth?: number;
} }
export interface CommonProps extends TableProps {
export interface TableProps extends CommonProps { operateConfig?: OperateConfigProps;
onScroll: Function;
operateConfig: any;
changeChecked?: Function;
hasGroup?: boolean;
updateData?: Function;
showForm?: Function;
showHistory?: Function;
delData?: Function;
getData?: Function;
flush?: Function;
extraMenu?: any;
noAdd?: boolean;
noEdit?: boolean;
noDel?: boolean;
rowClassName?: string | Function;
rowStyle?: Object | Function;
rowRenderer?: Function;
rowBorder?:string;
} }
export interface TableState extends CommonState { export interface CommonState extends TableState {}
prevProps: TableProps;
tableHeight: number;
tableWidth: number;
}
export interface RowRendererParams { export interface RowRendererParams {
rowClassName?: string|Function; rowClassName?: string | Function;
columns: Array<any>; columns: Array<any>;
rowIndex: number; rowIndex: number;
isScrolling: boolean; isScrolling: boolean;
...@@ -74,39 +66,24 @@ export interface BaseComponentProps { ...@@ -74,39 +66,24 @@ export interface BaseComponentProps {
columnConfig: any; columnConfig: any;
formatter?: Function; formatter?: Function;
onChange?: Function; onChange?: Function;
changeParams?: Function; onEmitChange?: Function;
} }
export interface BaseComponentState { export interface BaseComponentState {
prevProps: BaseComponentProps; // value: any[] | undefined;
value: any[] | undefined;
columnConfig: any; columnConfig: any;
} }
export interface CellProps { export interface CellProps {
columns: any[]; rowIndex: number;
columnIndex: number;
columnConfig: any; columnConfig: any;
rowData: any; rowData: any;
cellData: any; cellData: any;
tableId: number; emitChangeCell: Function;
changeChecked?: Function; cellClassName?: string;
hasGroup?: boolean; cellStyle: object;
updateData?: Function;
showForm?: any;
showHistory?: Function;
delData?: Function;
getData?: Function;
flush?: Function;
extraMenu?: any;
noAdd?: boolean;
noEdit?: boolean;
noDel?: boolean;
overlayClassName?: string;
} }
export interface CellState { export interface CellState {
prevProps: CellProps; status: string;
editValue: any[];
originValue: any[];
isEditVisible: boolean;
isMenuVisible: boolean;
} }
export interface EditCellProps { export interface EditCellProps {
columns: any[]; columns: any[];
......
...@@ -27,7 +27,7 @@ export function getStrLeng(str: string) { ...@@ -27,7 +27,7 @@ export function getStrLeng(str: string) {
* @returns {string} 返回随机字符串 * @returns {string} 返回随机字符串
*/ */
export function getRandom(len:number = 6, type?:string, extra?:string) { export function getRandom(len: number = 6, type?: string, extra?: string) {
let num = '0123456789'; let num = '0123456789';
let letter = 'abcdefghigklmnopqrstuvwxyz'; let letter = 'abcdefghigklmnopqrstuvwxyz';
let upLetter = letter.toUpperCase(); let upLetter = letter.toUpperCase();
...@@ -54,7 +54,68 @@ export function getRandom(len:number = 6, type?:string, extra?:string) { ...@@ -54,7 +54,68 @@ export function getRandom(len:number = 6, type?:string, extra?:string) {
str += extra; str += extra;
} }
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
result += str[Math.floor(Math.random() * str.length)] result += str[Math.floor(Math.random() * str.length)];
} }
return result; return result;
} }
/**
* 提出原对象中指定属性
* @param src 原对象
* @param anti 属性名称数组
*/
export function antiAssign(src: object, anti: string[]) {
const result = _.assign({}, src);
Object.keys(result).map((key) => {
if (anti.includes(key)) {
delete result[key];
}
});
return result;
}
/**
* 合并样式class
* @param className 原样式名
* @param mergeClassName 合并样式名或方法
* @param mergeData 合并样式方法的参数
*/
export function getMergeClassName(
className: string | undefined,
mergeClassName: string | Function | undefined,
mergeData?: any,
): string {
if (!className) {
className = '';
}
if (!mergeClassName) {
mergeClassName = '';
}
if (typeof mergeClassName === 'function') {
className = `${className} ${mergeClassName(mergeData)}`;
} else {
className = `${className} ${mergeClassName}`;
}
return className;
}
/**
* 合并样式style
* @param style 原样式
* @param mergeStyle 合并样式对象或方法
* @param mergeData 合并样式方法的参数
*/
export function getMergeStyle(style: any, mergeStyle: object | Function | undefined, mergeData: any) {
if (!style) {
style = {};
}
if (!mergeStyle) {
mergeStyle = {};
}
if (typeof mergeStyle === 'function') {
_.assign(style, mergeStyle(mergeData));
} else {
_.assign(style, mergeStyle);
}
return style;
}
.row{
color: green;
}
import React, { useState, useEffect, useCallback } from 'react'; import React, { useState, useEffect, useCallback } from 'react';
import _ from 'lodash'; import _ from 'lodash';
import ApolloTable from '../apollo-table'; import ApolloTable from '../apollo-table';
import { getColumnConfig, getDataSource } from './serives'; import { getColumnConfig, getDataSource, addOrUpdateDataSource } from './serives';
import { message } from 'antd'; import { message } from 'antd';
import s from './demo1.less';
const rowStyle = ({ index, record }) => { const rowStyle = ({ rowIndex }) => {
const style: any = {}; const style: any = {};
if (index % 3 === 0) { if (rowIndex % 3 === 0) {
style.fontSize = '20px';
style.background = 'red'; style.background = 'red';
} }
return style; return style;
...@@ -41,10 +43,11 @@ const Demo1 = (props) => { ...@@ -41,10 +43,11 @@ const Demo1 = (props) => {
hasNextPage: false, hasNextPage: false,
nextPage: 1, nextPage: 1,
}); });
const [flush,setFlush]=useState(false);
useEffect(() => { useEffect(() => {
const getDataList = async () => { const getDataList = async () => {
const data = { const data = {
pageNum: pageConfig.nextPage, pageNum: pageConfig.pageNum,
pageSize: pageConfig.pageSize, pageSize: pageConfig.pageSize,
}; };
const res = await getDataSource({ tableId, data }); const res = await getDataSource({ tableId, data });
...@@ -59,7 +62,7 @@ const Demo1 = (props) => { ...@@ -59,7 +62,7 @@ const Demo1 = (props) => {
}, [pageConfig.pageNum]); }, [pageConfig.pageNum]);
const fetchData = useCallback(async (isClean: boolean) => { const fetchData = useCallback(async (isClean: boolean) => {
const data = { const data = {
pageNum: isClean ? 1 : pageConfig.nextPage, pageNum: isClean ? 1 : pageConfig.pageNum,
pageSize: pageConfig.pageSize, pageSize: pageConfig.pageSize,
}; };
const res = await getDataSource({ tableId, data }); const res = await getDataSource({ tableId, data });
...@@ -76,13 +79,21 @@ const Demo1 = (props) => { ...@@ -76,13 +79,21 @@ const Demo1 = (props) => {
} }
}; };
const debounceScroll = _.debounce(onScroll, 400); const debounceScroll = _.debounce(onScroll, 400);
const emitChangeCell = async ({ rowId, value }) => {
const res = await addOrUpdateDataSource({ data: { id: rowId, value } });
if (res && res.success) {
fetchData(true);
}
};
return ( return (
<ApolloTable <ApolloTable
rowStyle={rowStyle} rowStyle={rowStyle}
columns={columns} columns={columns}
dataSource={dataSource} dataSource={dataSource}
tableId={tableId}
onScroll={debounceScroll} onScroll={debounceScroll}
emitChangeCell={emitChangeCell}
bordered={true}
rowClassName={s.row}
/> />
); );
}; };
......
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