Commit da0be9dd authored by zhangwenshuai's avatar zhangwenshuai

修改ts类型

parent f3572e8e
import React from 'react'; import React from 'react';
import { message, Popover, Modal } from 'antd'; import { message, Popover, Modal } from 'antd';
import { config } from './config'; import { config } from './config';
import style from './Cell.less'; import style from './Cell.less';
import _ from 'lodash'; import _ from 'lodash';
......
...@@ -8,6 +8,9 @@ export default class TableColumn extends PureComponent<ColumnProps> { ...@@ -8,6 +8,9 @@ export default class TableColumn extends PureComponent<ColumnProps> {
render() { render() {
let { type, title, width = 200, columnAttrObj = {} } = this.props; let { type, title, width = 200, columnAttrObj = {} } = this.props;
if(!config[String(type)]){
type='1';
}
let icon = config[String(type)] && config[String(type)].icon; let icon = config[String(type)] && config[String(type)].icon;
if (String(type) === '13' && !columnAttrObj.isMultiple) { if (String(type) === '13' && !columnAttrObj.isMultiple) {
icon = 'iconziduan-lianxiangdanxuan'; icon = 'iconziduan-lianxiangdanxuan';
......
...@@ -2,7 +2,7 @@ import React from 'react'; ...@@ -2,7 +2,7 @@ import React from 'react';
import { EditCellProps, EditCellState } from './interface'; import { EditCellProps, EditCellState } from './interface';
import FormHelper from '../utils/formHelper'; import FormHelper from '../utils/formHelper';
const formatData = (columns: [], rowData: [], noEdit?: boolean) => { const formatData = (columns: any[], rowData: any[], noEdit?: boolean) => {
const temp: any[] = []; const temp: any[] = [];
columns.forEach((item: any) => { columns.forEach((item: any) => {
const value: any = rowData.find((itemData: any) => { const value: any = rowData.find((itemData: any) => {
...@@ -17,14 +17,14 @@ const formatData = (columns: [], rowData: [], noEdit?: boolean) => { ...@@ -17,14 +17,14 @@ const formatData = (columns: [], rowData: [], noEdit?: boolean) => {
}); });
return temp; return temp;
}; };
const formHelp = (columns: [], record: any, item: any) => { const formHelp = (columns: any[], record: any, item: any) => {
const list = formatData(columns, record.rowData); const list = formatData(columns, record.rowData);
const itemsConfig = FormHelper.getFormData({ list, rowLocked: record.isLocked }); const itemsConfig = FormHelper.getFormData({ list, rowLocked: record.isLocked });
return itemsConfig.find((temp: any) => { return itemsConfig.find((temp: any) => {
return temp.columnName === item.columnName; return temp.columnName === item.columnName;
}); });
}; };
export default class EditCell extends React.Component { export default class EditCell extends React.Component<EditCellProps, EditCellState> {
static getDerivedStateFromProps(nextProps: EditCellProps, prevState: EditCellState) { static getDerivedStateFromProps(nextProps: EditCellProps, prevState: EditCellState) {
const { prevProps } = prevState; const { prevProps } = prevState;
let columnConfig = formHelp(nextProps.columns, nextProps.rowData, nextProps.columnConfig); let columnConfig = formHelp(nextProps.columns, nextProps.rowData, nextProps.columnConfig);
......
...@@ -13,6 +13,10 @@ import IconFont from './base/extra/iconFont'; ...@@ -13,6 +13,10 @@ import IconFont from './base/extra/iconFont';
import scrollbarSize from '../utils/scrollbarSize'; import scrollbarSize from '../utils/scrollbarSize';
export default class AirTable extends Component<TableProps, TableState> { export default class AirTable extends Component<TableProps, TableState> {
private indexCount: any;
config: any;
memoizeLeftCount: Function;
memoizeData: Function;
static getDerivedStateFromProps(nextProps: TableProps, prevState: TableState) { static getDerivedStateFromProps(nextProps: TableProps, prevState: TableState) {
const { prevProps } = prevState; const { prevProps } = prevState;
let nextState: TableState = { let nextState: TableState = {
...@@ -144,7 +148,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -144,7 +148,7 @@ export default class AirTable extends Component<TableProps, TableState> {
const flag = this.getCheckedAll(); const flag = this.getCheckedAll();
let result = []; let result = [];
if (flag) { if (flag) {
result = temp.concat(dataSource).filter((v:any) => { result = temp.concat(dataSource).filter((v: any) => {
return ( return (
temp.some((item: any) => { temp.some((item: any) => {
return item.id === v.id; return item.id === v.id;
...@@ -170,7 +174,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -170,7 +174,7 @@ export default class AirTable extends Component<TableProps, TableState> {
// 下拉加载 // 下拉加载
onScrollRow = ({ clientHeight, scrollTop }: any) => { onScrollRow = ({ clientHeight, scrollTop }: any) => {
const height = clientHeight + scrollTop || 0; const height = clientHeight + scrollTop || 0;
const { dataSource = [], } = this.state; const { dataSource = [] } = this.state;
const { rowHeight } = this.config; const { rowHeight } = this.config;
const { onScroll } = this.props; const { onScroll } = this.props;
const offset = 100; const offset = 100;
...@@ -183,7 +187,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -183,7 +187,7 @@ export default class AirTable extends Component<TableProps, TableState> {
renderHeaderCell = ({ columnIndex, key, rowIndex, style }: any) => { renderHeaderCell = ({ columnIndex, key, rowIndex, style }: any) => {
const { columns } = this.state; const { columns } = this.state;
if (columns.length === 0) return null; if (columns.length === 0) return null;
const { columnType, columnChsName, width } = columns[columnIndex] || {}; const { columnType, columnChsName, width, columnAttrObj } = columns[columnIndex] || {};
if (columnIndex === 0) { if (columnIndex === 0) {
return ( return (
<div key={key} className={styles.leftHeaderCell} style={{ ...style, width: width || 200 }}> <div key={key} className={styles.leftHeaderCell} style={{ ...style, width: width || 200 }}>
...@@ -191,14 +195,14 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -191,14 +195,14 @@ export default class AirTable extends Component<TableProps, TableState> {
<Checkbox checked={this.getCheckedAll()} onClick={this.changeCheckboxAll} /> <Checkbox checked={this.getCheckedAll()} onClick={this.changeCheckboxAll} />
</div> </div>
<div className={styles.cellContent}> <div className={styles.cellContent}>
<Column type={String(columnType)} title={columnChsName} width={width} /> <Column type={String(columnType)} title={columnChsName} width={width} columnAttrObj={columnAttrObj} />
</div> </div>
</div> </div>
); );
} }
return ( return (
<div className={styles.leftHeaderCell} key={key} style={{ ...style, width: width || 200 }}> <div className={styles.leftHeaderCell} key={key} style={{ ...style, width: width || 200 }}>
<Column type={String(columnType)} title={columnChsName} width={width} /> <Column type={String(columnType)} title={columnChsName} width={width} columnAttrObj={columnAttrObj} />
</div> </div>
); );
}; };
...@@ -239,7 +243,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -239,7 +243,7 @@ export default class AirTable extends Component<TableProps, TableState> {
const { const {
updateData, updateData,
hasGroup, hasGroup,
showForm=()=>{}, showForm = () => {},
delData, delData,
getData, getData,
extraMenu, extraMenu,
...@@ -248,7 +252,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -248,7 +252,7 @@ export default class AirTable extends Component<TableProps, TableState> {
noDel, noDel,
tableId, tableId,
flush, flush,
showHistory=()=>{}, showHistory = () => {},
} = this.props; } = this.props;
if (columns.length === 0 || data.length === 0) { if (columns.length === 0 || data.length === 0) {
return; return;
...@@ -346,7 +350,11 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -346,7 +350,11 @@ export default class AirTable extends Component<TableProps, TableState> {
> >
{filterRowData.groupHistoryCount && filterRowData.groupHistoryCount > 1 && ( {filterRowData.groupHistoryCount && filterRowData.groupHistoryCount > 1 && (
<span className={styles.countNo}> <span className={styles.countNo}>
{`(${filterRowData.groupHistoryCount > 99 ? '99+' : filterRowData.groupHistoryCount})`} {`(${
filterRowData.groupHistoryCount > 99
? '99+'
: filterRowData.groupHistoryCount
})`}
</span> </span>
)} )}
</div> </div>
...@@ -491,8 +499,10 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -491,8 +499,10 @@ export default class AirTable extends Component<TableProps, TableState> {
<AutoSizer disableHeight> <AutoSizer disableHeight>
{({ width }: any) => { {({ width }: any) => {
// 如果列太少不满一屏时,列头宽度按列计算 // 如果列太少不满一屏时,列头宽度按列计算
const headerWidth:number = columnWidth * columnCount < width ? columnWidth * columnCount : width; const headerWidth: number =
return ( <div> columnWidth * columnCount < width ? columnWidth * columnCount : width;
return (
<div>
{ {
//右侧表头 //右侧表头
<div <div
...@@ -542,7 +552,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -542,7 +552,7 @@ export default class AirTable extends Component<TableProps, TableState> {
height={height} height={height}
onScroll={(...arg: Array<Object>) => { onScroll={(...arg: Array<Object>) => {
onScroll(...arg); onScroll(...arg);
this.onScrollRow(...arg); this.onScrollRow(arg[0]);
}} }}
cellRenderer={this.renderBodyCell.bind(this, data)} cellRenderer={this.renderBodyCell.bind(this, data)}
columns={columns} columns={columns}
...@@ -552,7 +562,8 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -552,7 +562,8 @@ export default class AirTable extends Component<TableProps, TableState> {
</div> </div>
} }
</div> </div>
)}} );
}}
</AutoSizer> </AutoSizer>
</div> </div>
</div> </div>
......
...@@ -12,135 +12,135 @@ export const config: any = { ...@@ -12,135 +12,135 @@ export const config: any = {
detail: require('./detail/input').default, detail: require('./detail/input').default,
icon: require('../../assets/type/text.png'), icon: require('../../assets/type/text.png'),
}, },
'2': { // '2': {
name: '模糊搜索单选', // name: '模糊搜索单选',
component: require('./edit/search').default, // component: require('./edit/search').default,
getFormatter: GetFormatter['SEARCH'], // getFormatter: GetFormatter['SEARCH'],
setFormatter: SetFormatter['SEARCH'], // setFormatter: SetFormatter['SEARCH'],
componentAttr: { // componentAttr: {
allowClear: true, // allowClear: true,
}, // },
detail: require('./detail/search').default, // detail: require('./detail/search').default,
}, // },
'3': { // '3': {
name: '多行文本', // name: '多行文本',
component: require('./edit/textarea').default, // component: require('./edit/textarea').default,
getFormatter: GetFormatter['TEXTAREA'], // getFormatter: GetFormatter['TEXTAREA'],
setFormatter: SetFormatter['TEXTAREA'], // setFormatter: SetFormatter['TEXTAREA'],
componentAttr: { // componentAttr: {
autosize: { minRows: 3 }, // autosize: { minRows: 3 },
}, // },
detail: require('./detail/textarea').default, // detail: require('./detail/textarea').default,
}, // },
'4': { // '4': {
name: '附件上传', // name: '附件上传',
component: require('./edit/upload').default, // component: require('./edit/upload').default,
getFormatter: GetFormatter['UPLOAD'], // getFormatter: GetFormatter['UPLOAD'],
setFormatter: SetFormatter['UPLOAD'], // setFormatter: SetFormatter['UPLOAD'],
detail: require('./detail/upload').default, // detail: require('./detail/upload').default,
}, // },
'5': { // '5': {
name: '复选', // name: '复选',
component: require('./edit/checkbox').default, // 暂未添加 // component: require('./edit/checkbox').default, // 暂未添加
getFormatter: GetFormatter['CHECKBOX'], // getFormatter: GetFormatter['CHECKBOX'],
setFormatter: SetFormatter['CHECKBOX'], // setFormatter: SetFormatter['CHECKBOX'],
detail: require('./detail/checkbox').default, // detail: require('./detail/checkbox').default,
}, // },
'6': { // '6': {
name: '下拉单选', // name: '下拉单选',
component: require('./edit/select').default, // component: require('./edit/select').default,
componentAttr: { // componentAttr: {
labelInValue: true, // labelInValue: true,
allowClear: true, // allowClear: true,
}, // },
getFormatter: GetFormatter['SELECT'], // getFormatter: GetFormatter['SELECT'],
setFormatter: SetFormatter['SELECT'], // setFormatter: SetFormatter['SELECT'],
detail: require('./detail/select').default, // detail: require('./detail/select').default,
}, // },
'7': { // '7': {
name: '下拉多选', // name: '下拉多选',
component: require('./edit/multiple-select').default, // component: require('./edit/multiple-select').default,
componentAttr: { // componentAttr: {
labelInValue: true, // labelInValue: true,
mode: 'tags', // mode: 'tags',
maxTagCount: 3, // maxTagCount: 3,
}, // },
getFormatter: GetFormatter['MULTIPLE_SELECT'], // getFormatter: GetFormatter['MULTIPLE_SELECT'],
setFormatter: SetFormatter['MULTIPLE_SELECT'], // setFormatter: SetFormatter['MULTIPLE_SELECT'],
detail: require('./detail/multiple-select').default, // detail: require('./detail/multiple-select').default,
}, // },
'8': { // '8': {
name: '评级', // name: '评级',
component: require('./edit/rate').default, // component: require('./edit/rate').default,
componentAttr: { // componentAttr: {
allowClear: true, // allowClear: true,
character: <Icon type="like" theme="filled" />, // character: <Icon type="like" theme="filled" />,
}, // },
getFormatter: GetFormatter['RATE'], // getFormatter: GetFormatter['RATE'],
setFormatter: SetFormatter['RATE'], // setFormatter: SetFormatter['RATE'],
detail: require('./detail/rate').default, // detail: require('./detail/rate').default,
}, // },
'9': { // '9': {
name: '数字输入', // name: '数字输入',
component: require('./edit/number').default, // component: require('./edit/number').default,
componentAttr: { // componentAttr: {
precision: 2, // precision: 2,
}, // },
setFormatter: SetFormatter['NUMBER'], // setFormatter: SetFormatter['NUMBER'],
getFormatter: GetFormatter['NUMBER'], // getFormatter: GetFormatter['NUMBER'],
detail: require('./detail/number').default, // detail: require('./detail/number').default,
}, // },
'10': { // '10': {
name: '百分比', // name: '百分比',
component: require('./edit/percentage').default, // 暂未添加 // component: require('./edit/percentage').default, // 暂未添加
setFormatter: SetFormatter['PERCENTAGE'], // setFormatter: SetFormatter['PERCENTAGE'],
getFormatter: GetFormatter['PERCENTAGE'], // getFormatter: GetFormatter['PERCENTAGE'],
detail: require('./detail/percentage').default, // detail: require('./detail/percentage').default,
}, // },
'11': { // '11': {
name: '日期', // name: '日期',
component: require('./edit/date').default, // component: require('./edit/date').default,
componentAttr: { // componentAttr: {
format: formatStr, // format: formatStr,
showTime: true, // showTime: true,
}, // },
getFormatter: GetFormatter['DATE'], // getFormatter: GetFormatter['DATE'],
setFormatter: SetFormatter['DATE'], // setFormatter: SetFormatter['DATE'],
detail: require('./detail/date').default, // detail: require('./detail/date').default,
}, // },
'12': { // '12': {
name: '引用', // name: '引用',
component: require('./edit/link').default, // 暂未添加 // component: require('./edit/link').default, // 暂未添加
getFormatter: GetFormatter['LINK'], // getFormatter: GetFormatter['LINK'],
setFormatter: SetFormatter['LINK'], // setFormatter: SetFormatter['LINK'],
detail: require('./detail/link').default, // detail: require('./detail/link').default,
}, // },
'13': { // '13': {
name: '模糊搜索多选', // name: '模糊搜索多选',
component: require('./edit/multiple-search').default, // component: require('./edit/multiple-search').default,
getFormatter: GetFormatter['MULTIPLE_SEARCH'], // getFormatter: GetFormatter['MULTIPLE_SEARCH'],
setFormatter: SetFormatter['MULTIPLE_SEARCH'], // setFormatter: SetFormatter['MULTIPLE_SEARCH'],
componentAttr: { // componentAttr: {
allowClear: true, // allowClear: true,
}, // },
detail: require('./detail/multiple-search').default, // detail: require('./detail/multiple-search').default,
}, // },
'14': { // '14': {
name: '树组件', // name: '树组件',
component: require('./edit/tree-select').default, // component: require('./edit/tree-select').default,
placeholder: '请选择', // placeholder: '请选择',
getFormatter: GetFormatter['TREE_SELECT'], // getFormatter: GetFormatter['TREE_SELECT'],
setFormatter: SetFormatter['TREE_SELECT'], // setFormatter: SetFormatter['TREE_SELECT'],
detail: require('./detail/tree-select').default, // detail: require('./detail/tree-select').default,
}, // },
'15': { // '15': {
name: '文本选择', // name: '文本选择',
component: require('./edit/text-select').default, // component: require('./edit/text-select').default,
getFormatter: GetFormatter['TEXT_SELECT'], // getFormatter: GetFormatter['TEXT_SELECT'],
setFormatter: SetFormatter['TEXT_SELECT'], // setFormatter: SetFormatter['TEXT_SELECT'],
componentAttr: { // componentAttr: {
allowClear: true, // allowClear: true,
}, // },
detail: require('./detail/text-select').default, // detail: require('./detail/text-select').default,
}, // },
}; };
...@@ -2,7 +2,7 @@ import React from 'react'; ...@@ -2,7 +2,7 @@ import React from 'react';
import { config } from '../config'; import { config } from '../config';
import styles from './styles.less'; import styles from './styles.less';
import { transferAttr } from '../_utils/transferAttr'; import { transferAttr } from '../_utils/transferAttr';
import { BaseComponentProps } from '../../../component/interface'; import { BaseComponentProps } from '../../interface';
import Text from './input'; import Text from './input';
// 此方法为高阶组件,不应再render里面频繁调用,防止频繁实例化,带来性能上的浪费 // 此方法为高阶组件,不应再render里面频繁调用,防止频繁实例化,带来性能上的浪费
...@@ -32,7 +32,6 @@ export const getDetail = (type: string) => { ...@@ -32,7 +32,6 @@ export const getDetail = (type: string) => {
componentAttr={transferColumn} componentAttr={transferColumn}
formatter={NodeObj.getFormatter} formatter={NodeObj.getFormatter}
value={value} value={value}
onChange={this.onChange}
/> />
</div> </div>
); );
......
import React from 'react'; import React from 'react';
import styles from './index.less'; import styles from './index.less';
import {BaseComponentProps} from '@/apollo-table/component/interface'; import {BaseComponentProps} from '../../../interface';
export default function Detail(props:BaseComponentProps) { export default function Detail(props:BaseComponentProps) {
const value = props.formatter ? props.formatter(props.value) : props.value; const value = props.formatter ? props.formatter(props.value) : props.value;
......
export interface CommonProps { export interface CommonProps {
columnConfig: any; columnConfig: any;
placeholder?:string;
formatter?: Function; formatter?: Function;
onChange?: Function; onChange?: Function;
} }
......
...@@ -4,11 +4,12 @@ import styles from './styles.less'; ...@@ -4,11 +4,12 @@ import styles from './styles.less';
import { InputProps } from '../editInterface'; import { InputProps } from '../editInterface';
export default function(props: InputProps) { export default function(props: InputProps) {
const { value, maxLength } = props; const { value, maxLength, placeholder } = props;
const inputProps = { value, maxLength, placeholder };
return ( return (
<div className={styles.container}> <div className={styles.container}>
<Input className={styles.input} {...props} /> <Input className={styles.input} {...inputProps} />
{maxLength && ( {maxLength && (
<span className={styles.wordNumber}> <span className={styles.wordNumber}>
已输入{(value || '').length || 0}/{maxLength} 已输入{(value || '').length || 0}/{maxLength}
......
...@@ -45,7 +45,7 @@ export const getComponent = (type: string) => { ...@@ -45,7 +45,7 @@ export const getComponent = (type: string) => {
} }
return newValue; return newValue;
}; };
const com = class extends React.Component { 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 { prevProps } = prevState;
...@@ -90,7 +90,7 @@ export const getComponent = (type: string) => { ...@@ -90,7 +90,7 @@ export const getComponent = (type: string) => {
render() { render() {
const { ...others } = this.props; const { ...others } = this.props;
const { columnConfig } = this.props; const { columnConfig, value } = this.state;
const { columnAttrObj, columnType } = columnConfig || {}; const { columnAttrObj, columnType } = columnConfig || {};
let transferColumn = transferAttr(columnType, { let transferColumn = transferAttr(columnType, {
...(NodeObj.componentAttr || {}), ...(NodeObj.componentAttr || {}),
...@@ -100,7 +100,7 @@ export const getComponent = (type: string) => { ...@@ -100,7 +100,7 @@ export const getComponent = (type: string) => {
...others, ...others,
...(transferColumn || {}), ...(transferColumn || {}),
}; };
return <Node {...newProps} value={this.state.value} onChange={this.onChange} />; return <Node {...newProps} value={value} onChange={this.onChange} />;
} }
}; };
com.Detail = getDetail(type); com.Detail = getDetail(type);
......
...@@ -6,75 +6,75 @@ export const config:any = { ...@@ -6,75 +6,75 @@ export const config:any = {
component: getComponent('1'), component: getComponent('1'),
icon: 'iconziduan-danhangwenben', icon: 'iconziduan-danhangwenben',
}, },
'2': { // '2': {
name: '超链接', // name: '超链接',
component: getComponent('2'), // component: getComponent('2'),
icon: 'iconziduan-chaolianjie', // icon: 'iconziduan-chaolianjie',
}, // },
'3': { // '3': {
name: '多行文本', // name: '多行文本',
component: getComponent('3'), // component: getComponent('3'),
icon: 'iconziduan-duohangwenben', // icon: 'iconziduan-duohangwenben',
}, // },
'4': { // '4': {
name: '附件上传', // name: '附件上传',
component: getComponent('4'), // component: getComponent('4'),
icon: 'iconziduan-fujian', // icon: 'iconziduan-fujian',
}, // },
'5': { // '5': {
name: '复选', // name: '复选',
component: getComponent('5'), // component: getComponent('5'),
icon: 'iconziduan-fuxuan', // icon: 'iconziduan-fuxuan',
}, // },
'6': { // '6': {
name: '下拉单选', // name: '下拉单选',
component: getComponent('6'), // component: getComponent('6'),
icon: 'iconziduan-xiala', // icon: 'iconziduan-xiala',
}, // },
'7': { // '7': {
name: '下拉多选', // name: '下拉多选',
component: getComponent('7'), // component: getComponent('7'),
icon: 'iconziduan-xialaduoxuan', // icon: 'iconziduan-xialaduoxuan',
}, // },
'8': { // '8': {
name: '评级', // name: '评级',
component: getComponent('8'), // component: getComponent('8'),
icon: 'iconziduan-pingji', // icon: 'iconziduan-pingji',
}, // },
'9': { // '9': {
name: '数字输入', // name: '数字输入',
component: getComponent('9'), // component: getComponent('9'),
icon: 'iconziduan-shuzi', // icon: 'iconziduan-shuzi',
}, // },
'10': { // '10': {
name: '百分比', // name: '百分比',
component: getComponent('10'), // component: getComponent('10'),
icon: 'iconziduan-baifenbi', // icon: 'iconziduan-baifenbi',
}, // },
'11': { // '11': {
name: '日期', // name: '日期',
component: getComponent('11'), // component: getComponent('11'),
icon: 'iconziduan-riqi', // icon: 'iconziduan-riqi',
}, // },
'12': { // '12': {
name: '引用', // name: '引用',
component: getComponent('12'), // component: getComponent('12'),
icon: 'iconziduan-yinyong', // icon: 'iconziduan-yinyong',
}, // },
'13': { // '13': {
name: '模糊搜索多选', // name: '模糊搜索多选',
component: getComponent('13'), // component: getComponent('13'),
icon: 'iconziduan-lianxiangduoxuan', // icon: 'iconziduan-lianxiangduoxuan',
}, // },
'14': { // '14': {
name: '树结构', // name: '树结构',
component: getComponent('14'), // component: getComponent('14'),
icon: 'iconziduan-ren', // icon: 'iconziduan-ren',
}, // },
'15': { // '15': {
name: '文本搜索框', // name: '文本搜索框',
component: getComponent('15'), // component: getComponent('15'),
icon: 'iconziduan-lianxiangdanxuan', // icon: 'iconziduan-lianxiangdanxuan',
}, // },
}; };
export default config; export default config;
import React from 'react'; import React from 'react';
import * as PropTypes from 'prop-types';
import styles from './index.less'; import styles from './index.less';
import { CommonProps, CommonState } from './interface'; import { CommonProps, CommonState } from './interface';
import Table from './Table'; import Table from './Table';
import Data from './data';
const {cols,list} = Data;
class AirTable extends React.Component<CommonProps, CommonState> { class AirTable extends React.Component<CommonProps, CommonState> {
static propTypes = {
dataSource: PropTypes.array,
columns: PropTypes.array,
tableId: PropTypes.number,
};
static defaultProps = {
dataSource: list,
columns: cols,
tableId: 1,
};
static getDerivedStateFromProps(nextProps: CommonProps, prevState: CommonState) { static getDerivedStateFromProps(nextProps: CommonProps, prevState: CommonState) {
const { prevProps } = prevState; const { prevProps } = prevState;
...@@ -39,22 +25,29 @@ class AirTable extends React.Component<CommonProps, CommonState> { ...@@ -39,22 +25,29 @@ class AirTable extends React.Component<CommonProps, CommonState> {
constructor(props: CommonProps) { constructor(props: CommonProps) {
super(props); super(props);
const { columns, dataSource, tableId } = props;
this.state = { this.state = {
columns,
dataSource,
tableId,
prevProps: props, prevProps: props,
columns: [],
dataSource: [],
tableId: 1,
}; };
} }
onScroll = () => {};
render() { render() {
const { columns, dataSource, tableId } = this.state; const { columns, dataSource, tableId } = this.state;
const operateConfig = {};
return ( return (
<div className={styles.container}> <div className={styles.container}>
<div className={styles.tableContainer}> <div className={styles.tableContainer}>
<Table columns={columns} dataSource={dataSource} tableId={tableId} /> <Table
columns={columns}
dataSource={dataSource}
tableId={tableId}
onScroll={this.onScroll}
operateConfig={operateConfig}
/>
</div> </div>
</div> </div>
); );
......
import React from 'react'; import React from 'react';
export interface CommonProps { export interface CommonProps {
columns?: []; columns: any[];
dataSource?: []; dataSource: any[];
tableId?: number; tableId: number;
checked?: []; checked?: any[];
columnWidth?: number; columnWidth?: number;
} }
export interface CommonState { export interface CommonState {
prevProps: CommonProps; prevProps: CommonProps;
columns?: []; columns: any[];
dataSource?: []; dataSource: any[];
tableId?: number; tableId: number;
checked?: []; checked?: any[];
columnWidth?: number; columnWidth?: number;
} }
export interface TableProps extends CommonProps {} export interface TableProps extends CommonProps {
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;
}
export interface TableState extends CommonState { export interface TableState extends CommonState {
prevProps: TableProps; prevProps: TableProps;
height: number;
} }
export interface ColumnProps { export interface ColumnProps {
type: string; type: string;
title: string; title: string;
width?: number; width?: number;
columnAttrObj?: any;
} }
export interface BaseComponentProps { export interface BaseComponentProps {
value: []; value: any[] | undefined;
columnConfig: any; columnConfig: any;
formatter?: Function; formatter?: Function;
onChange?: Function; onChange?: Function;
changeParams?: Function;
} }
export interface BaseComponentState { export interface BaseComponentState {
prevProps: BaseComponentProps; prevProps: BaseComponentProps;
value: []; value: any[] | undefined;
columnConfig: any; columnConfig: any;
} }
export interface CellProps { export interface CellProps {
columns: []; columns: any[];
columnConfig: any; columnConfig: any;
rowData: []; rowData: any;
cellData: []; cellData: any;
tableId: number;
changeChecked?: Function;
hasGroup?: boolean;
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; prevProps: CellProps;
columns: []; editValue: any[];
columnConfig: any; originValue: any[];
rowData: []; isEditVisible: boolean;
editValue: []; isMenuVisible: boolean;
originValue: [];
} }
export interface EditCellProps { export interface EditCellProps {
columns: []; columns: any[];
columnConfig: any; columnConfig: any;
rowData: []; rowData: any;
value: any; value: any[];
tableId: number;
cellData: any;
rowId: number;
component: any;
onChange: Function;
componentAttr?: any;
columnObj?: any;
record: any;
} }
export interface EditCellState { export interface EditCellState {
prevProps: EditCellProps; prevProps: EditCellProps;
......
...@@ -26,7 +26,9 @@ const getLocalData = ({ getLocalDataMethod }: any) => { ...@@ -26,7 +26,9 @@ const getLocalData = ({ getLocalDataMethod }: any) => {
} else { } else {
// console.log('没有找到获取本地数据的方法getLocalDataMethod'); // console.log('没有找到获取本地数据的方法getLocalDataMethod');
} }
//@ts-ignore
} else if (window.mtBridge) { } else if (window.mtBridge) {
//@ts-ignore
localData = window.mtBridge.data.localData || {}; localData = window.mtBridge.data.localData || {};
} else { } else {
// console.log('没有找到native交互桥mtBridge'); // console.log('没有找到native交互桥mtBridge');
......
...@@ -5,7 +5,7 @@ function checkCookieAuth() { ...@@ -5,7 +5,7 @@ function checkCookieAuth() {
return navigator.cookieEnabled; return navigator.cookieEnabled;
} }
const storage = { const storage:any = {
getItem(key: string) { getItem(key: string) {
try { try {
const value = localStorage.getItem(key); const value = localStorage.getItem(key);
......
import React from 'react'; import React from 'react';
import { render } from 'react-dom'; import { render } from 'react-dom';
import ApolloTable from '../src/apollo-table'; import ApolloTable from '../apollo-table';
import Data from './data';
render(<ApolloTable>hh</ApolloTable>, document.getElementById('root')); const { cols, list } = Data;
render(<ApolloTable columns={cols} dataSource={list} tableId={1} />, document.getElementById('root'));
{ {
"compilerOptions": { "compilerOptions": {
/* Basic Options */ "outDir": "./dist/",
// "incremental": true, /* Enable incremental compilation */ "sourceMap": false,
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "noImplicitAny": false,
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "module": "commonjs",
"lib": [ "target": "es5",
"es2016", "jsx": "react",
"dom" "esModuleInterop": true
], /* Specify library files to be included in the compilation. */ },
// "allowJs": true, /* Allow javascript files to be compiled. */ "include": ["./typings.d.ts"],
// "checkJs": true, /* Report errors in .js files. */ "files": [
"jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ "./src/test/index.tsx",
"declaration": false, /* Generates corresponding '.d.ts' file. */ "./src/test/data.ts",
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ "./src/apollo-table/index.tsx",
// "sourceMap": true, /* Generates corresponding '.map' file. */ "./src/apollo-table/component/index.tsx",
// "outFile": "./", /* Concatenate and emit output to single file. */ "./src/apollo-table/component/interface.tsx",
"outDir": "./dist", /* Redirect output structure to the directory. */ "./src/apollo-table/component/config.ts",
// "rootDir": "./test", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ "./src/apollo-table/component/Table.tsx",
// "composite": true, /* Enable project compilation */ "./src/apollo-table/component/Column.tsx",
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ "./src/apollo-table/component/base/index.tsx",
"removeComments": true, /* Do not emit comments to output. */ "./src/apollo-table/component/base/config.tsx",
// "noEmit": true, /* Do not emit outputs. */ ]
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
"typeRoots": [
"node_modules/@types"
], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
"emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
} }
...@@ -31,11 +31,11 @@ module.exports = { ...@@ -31,11 +31,11 @@ module.exports = {
mode: 'development', mode: 'development',
entry: './src/test/index.tsx', entry: './src/test/index.tsx',
output: { output: {
filename: '[name].js', filename: 'bundle.js',
path: path.join(__dirname, 'dist'), path: path.resolve(__dirname, 'dist'),
}, },
resolve: { resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json', '.less'], extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
alias: { alias: {
'@': path.resolve(__dirname, 'src'), '@': path.resolve(__dirname, 'src'),
}, },
...@@ -73,6 +73,16 @@ module.exports = { ...@@ -73,6 +73,16 @@ module.exports = {
'less-loader', 'less-loader',
], ],
}, },
{
test: /\.css$/,
// include: [path.resolve(__dirname, 'src')],
use: [
'style-loader',
{
loader: 'css-loader',
},
],
},
{ {
test: /\.(jpg|png|gif)$/, test: /\.(jpg|png|gif)$/,
use: { use: {
......
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