Commit 8f76c90a authored by zhangwenshuai's avatar zhangwenshuai

update apolloTable

parent a4d36973
...@@ -30,6 +30,9 @@ const Cell = (props: CellProps) => { ...@@ -30,6 +30,9 @@ const Cell = (props: CellProps) => {
rowSelection, rowSelection,
columns, columns,
contentMenu, contentMenu,
selectedCell,
cellKey,
changeSelectedCell,
} = props; } = props;
const { const {
columnType, columnType,
...@@ -157,10 +160,17 @@ const Cell = (props: CellProps) => { ...@@ -157,10 +160,17 @@ const Cell = (props: CellProps) => {
const detail = ( const detail = (
<div <div
className={s.detailCell} className={selectedCell === cellKey ? classNames(s.detailCell, s.selected) : s.detailCell}
onDoubleClick={() => { onClick={() => {
if (selectedCell === cellKey) {
cellEditable && !readOnlyFlag && setStatus('edit'); cellEditable && !readOnlyFlag && setStatus('edit');
} else {
changeSelectedCell && changeSelectedCell(cellKey);
}
}} }}
// onDoubleClick={() => {
// cellEditable && !readOnlyFlag && setStatus('edit');
// }}
style={style} style={style}
> >
{rowSelection && columnIndex === 0 && <div className={s.checkbox}>{getCheckbox()}</div>} {rowSelection && columnIndex === 0 && <div className={s.checkbox}>{getCheckbox()}</div>}
......
...@@ -29,6 +29,18 @@ ...@@ -29,6 +29,18 @@
color: @textPrimaryColor; color: @textPrimaryColor;
font-weight: @weightSemiblod; font-weight: @weightSemiblod;
display: flex; display: flex;
&.required:before {
display: inline-block;
margin-right: 4px;
color: #f5222d;
font-size: 14px;
font-family: SimSun, sans-serif;
line-height: 1;
content: '*';
vertical-align: top;
position: relative;
top: 5px;
}
.tipContainer{ .tipContainer{
margin-left: @marginSmX; margin-left: @marginSmX;
cursor: pointer; cursor: pointer;
......
...@@ -75,6 +75,7 @@ export default class TableColumn extends PureComponent<ColumnProps> { ...@@ -75,6 +75,7 @@ export default class TableColumn extends PureComponent<ColumnProps> {
questionText, questionText,
rowSelection, rowSelection,
icon, icon,
required,
} = this.props; } = this.props;
const { value = [] } = sortConfig || {}; const { value = [] } = sortConfig || {};
const sort = value.find((item: any) => { const sort = value.find((item: any) => {
...@@ -86,7 +87,7 @@ export default class TableColumn extends PureComponent<ColumnProps> { ...@@ -86,7 +87,7 @@ export default class TableColumn extends PureComponent<ColumnProps> {
{rowSelection && columnIndex === 0 && <div className={s.checkbox}>{this.getCheckbox()}</div>} {rowSelection && columnIndex === 0 && <div className={s.checkbox}>{this.getCheckbox()}</div>}
<div className={s.colBrief} style={{ marginLeft: showIndex && columnIndex === 0 ? '40px' : 0 }}> <div className={s.colBrief} style={{ marginLeft: showIndex && columnIndex === 0 ? '40px' : 0 }}>
{icon && <div className={s.colIcon}>{icon()}</div>} {icon && <div className={s.colIcon}>{icon()}</div>}
<span className={s.colTitle}> <span className={required ? classNames(s.colTitle, s.required) : s.colTitle}>
{columnChsName} {columnChsName}
{questionText && ( {questionText && (
<Tooltip title={questionText}> <Tooltip title={questionText}>
......
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
right: 0; right: 0;
z-index: 1; z-index: 1;
} }
:global(.ReactVirtualized__Grid__innerScrollContainer){
overflow: unset !important;
}
} }
.leftSideHeaderContainer, .leftSideHeaderContainer,
......
...@@ -48,9 +48,11 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -48,9 +48,11 @@ export default class AirTable extends Component<TableProps, TableState> {
}; };
if (JSON.stringify(dataSource) !== JSON.stringify(nextProps.dataSource)) { if (JSON.stringify(dataSource) !== JSON.stringify(nextProps.dataSource)) {
nextState.dataSource = nextProps.dataSource; nextState.dataSource = nextProps.dataSource;
nextState.selectedCell = null;
} }
if (JSON.stringify(columns) !== JSON.stringify(nextProps.columns)) { if (JSON.stringify(columns) !== JSON.stringify(nextProps.columns)) {
nextState.columns = nextProps.columns; nextState.columns = nextProps.columns;
nextState.selectedCell = null;
} }
return nextState; return nextState;
} }
...@@ -63,6 +65,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -63,6 +65,7 @@ export default class AirTable extends Component<TableProps, TableState> {
dataSource, dataSource,
tableWidth: width, tableWidth: width,
tableHeight: height, tableHeight: height,
selectedCell: null,
}; };
this.config = { this.config = {
overscanColumnCount: 5, overscanColumnCount: 5,
...@@ -206,6 +209,12 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -206,6 +209,12 @@ export default class AirTable extends Component<TableProps, TableState> {
} }
}; };
changeSelectedCell=(key)=>{
this.setState({
selectedCell:key
})
}
// 渲染表头 // 渲染表头
renderHeaderCell = ( renderHeaderCell = (
{ showColumns, position }: { showColumns: ColumnProps[]; position?: string }, { showColumns, position }: { showColumns: ColumnProps[]; position?: string },
...@@ -221,6 +230,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -221,6 +230,7 @@ export default class AirTable extends Component<TableProps, TableState> {
sortFlag, sortFlag,
questionText, questionText,
icon, icon,
requiredFlag,
} = showColumns[columnIndex]; } = showColumns[columnIndex];
return ( return (
<div className={styles.headerCell} key={key} style={style}> <div className={styles.headerCell} key={key} style={style}>
...@@ -237,6 +247,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -237,6 +247,7 @@ export default class AirTable extends Component<TableProps, TableState> {
rowSelection={position === 'right' ? false : rowSelection} rowSelection={position === 'right' ? false : rowSelection}
dataSource={dataSource} dataSource={dataSource}
icon={icon} icon={icon}
required={requiredFlag}
/> />
</div> </div>
); );
...@@ -303,7 +314,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -303,7 +314,7 @@ export default class AirTable extends Component<TableProps, TableState> {
{ showColumns, showData, position }: { showColumns: ColumnProps[]; showData: RowProps; position?: string }, { showColumns, showData, position }: { showColumns: ColumnProps[]; showData: RowProps; position?: string },
{ columnIndex, key, rowIndex, cellClassName, cellStyle }: any, { columnIndex, key, rowIndex, cellClassName, cellStyle }: any,
) => { ) => {
const { columns, dataSource } = this.state; const { columns, dataSource, selectedCell } = this.state;
const { const {
emitChangeCell, emitChangeCell,
paginationConfig, paginationConfig,
...@@ -339,6 +350,9 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -339,6 +350,9 @@ export default class AirTable extends Component<TableProps, TableState> {
cellEditable={cellEditable} cellEditable={cellEditable}
rowSelection={position === 'right' ? false : rowSelection} rowSelection={position === 'right' ? false : rowSelection}
contentMenu={contentMenu} contentMenu={contentMenu}
selectedCell={selectedCell}
changeSelectedCell={this.changeSelectedCell}
cellKey={key}
/> />
); );
}; };
......
...@@ -2,6 +2,9 @@ import React from 'react'; ...@@ -2,6 +2,9 @@ import React from 'react';
import { Input } from 'antd'; import { Input } from 'antd';
import styles from './styles.less'; import styles from './styles.less';
import { ApolloLinkProps } from '../editInterface'; import { ApolloLinkProps } from '../editInterface';
import addIcon from '../../../../assets/addIcon.png';
import delIcon from '../../../../assets/delIcon.png';
import { Consumer } from '../../../context';
export const ApolloLink = (props: ApolloLinkProps) => { export const ApolloLink = (props: ApolloLinkProps) => {
const { onChange, value } = props; const { onChange, value } = props;
...@@ -32,33 +35,43 @@ export const ApolloLink = (props: ApolloLinkProps) => { ...@@ -32,33 +35,43 @@ export const ApolloLink = (props: ApolloLinkProps) => {
} }
}; };
return (
<Consumer>
{({ locale }) => {
return ( return (
<div className={styles.container}> <div className={styles.container}>
{value {value &&
&& value.map((link, i) => { value.map((link, i) => {
return ( return (
<div key={i} className={styles.content}> <div key={i} className={styles.content}>
<div className={styles.row}> <div className={styles.row}>
<span className={styles.label}>text:</span> <span className={styles.label}>{locale.linkText}</span>
<Input className={styles.input} value={link.text} onChange={changeText.bind(null, i)} /> <Input
className={styles.input}
value={link.text}
onChange={changeText.bind(null, i)}
/>
</div> </div>
<div className={styles.row}> <div className={styles.row}>
<span className={styles.label}>url:</span> <span className={styles.label}>{locale.linkUrl}</span>
<Input <Input
className={styles.input} className={styles.input}
value={link.value} value={link.value}
onChange={changeValue.bind(null, i)} onChange={changeValue.bind(null, i)}
/> />
<div className={styles.delContainer} onClick={delLink.bind(null, i)}> <div className={styles.delContainer} onClick={delLink.bind(null, i)}>
Del <img alt="" className={styles.delIcon} src={delIcon} />
</div> </div>
</div> </div>
</div> </div>
); );
})} })}
<div className={styles.btn} onClick={addLink}> <div className={styles.btn} onClick={addLink}>
Add <img alt="" className={styles.icon} src={addIcon} />
</div> </div>
</div> </div>
); );
}}
</Consumer>
);
}; };
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
background: white; background: white;
padding: @paddingSmX; padding: @paddingSmX;
border: 1px solid @primaryColor; border: 1px solid @primaryColor;
min-height: 100%;
user-select: none;
.content { .content {
border-bottom: 1px solid @borderColor; border-bottom: 1px solid @borderColor;
.row { .row {
...@@ -14,8 +16,10 @@ ...@@ -14,8 +16,10 @@
align-items: center; align-items: center;
padding: @paddingSmX 0; padding: @paddingSmX 0;
.label { .label {
width: 60px; width: 40px;
font-size: @textFontSm; font-size: @textFontSm;
text-align: right;
padding-right: @paddingSm;
} }
.input { .input {
flex: 1; flex: 1;
...@@ -24,15 +28,18 @@ ...@@ -24,15 +28,18 @@
width: 20px; width: 20px;
text-align: center; text-align: center;
cursor: pointer; cursor: pointer;
.del { .delIcon {
font-size: @textFontSm; width: 14px;
} }
} }
} }
} }
.btn { .btn {
width: 20px;
padding: @paddingSmX;
display: inline-block;
.icon{ .icon{
font-size: @textFontSm; width: 12px;
cursor: pointer; cursor: pointer;
} }
} }
......
.search { .search {
width: 100%; width: 100%;
height: 100%; height: 100%;
border-radius: 0;
:global(.ant-select-selector) { :global(.ant-select-selector) {
height: 100% !important; height: 100% !important;
align-items: center; align-items: center;
} }
:global(.ant-select-selection-search-input){ :global(.ant-select-selection) {
width: 100%;
min-height: 100%;
border-radius: 0;
display: flex;
align-items: center;
}
:global(.ant-select-selection-search-input) {
height: 100% !important; height: 100% !important;
} }
} }
.select { .select {
width: 100%; width: 100%;
height: 100%; height: 100%;
border-radius: 0;
:global(.ant-select-selector) { :global(.ant-select-selector) {
height: 100% !important; height: 100% !important;
align-items: center; align-items: center;
} }
:global(.ant-select-selection) {
width: 100%;
min-height: 100%;
border-radius: 0;
display: flex;
align-items: center;
}
} }
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
.add { .add {
cursor: pointer; cursor: pointer;
font-size: @textFontGen; font-size: @textFontGen;
.addIcon{
width: 12px;
}
} }
.picContainer { .picContainer {
margin-left: @marginSmX; margin-left: @marginSmX;
......
...@@ -4,8 +4,9 @@ import { ApolloUploadProps } from '../editInterface'; ...@@ -4,8 +4,9 @@ import { ApolloUploadProps } from '../editInterface';
import { antiAssign } from '../../../../utils/utils'; import { antiAssign } from '../../../../utils/utils';
import s from './index.less'; import s from './index.less';
import Upload from '../../extra/upload'; import Upload from '../../extra/upload';
import addIcon from '../../../../assets/addIcon.png';
export const ApolloUpload = (props:ApolloUploadProps) => { export const ApolloUpload = (props: ApolloUploadProps) => {
const { isMultiple, onEmitChange } = props; const { isMultiple, onEmitChange } = props;
const selfProps = antiAssign(props, ['onChange', 'value']); const selfProps = antiAssign(props, ['onChange', 'value']);
if (isMultiple) { if (isMultiple) {
...@@ -56,10 +57,10 @@ export const ApolloUpload = (props:ApolloUploadProps) => { ...@@ -56,10 +57,10 @@ export const ApolloUpload = (props:ApolloUploadProps) => {
return ( return (
<div className={s.container} onClick={onClickContainer}> <div className={s.container} onClick={onClickContainer}>
<div className={s.add} onClick={toggleUploadDialog.bind(null, true)}> <div className={s.add} onClick={toggleUploadDialog.bind(null, true)}>
Add <img alt="" className={s.addIcon} src={addIcon} />
</div> </div>
{value {value &&
&& value.map((item, i) => { value.map((item, i) => {
return ( return (
<div key={i} className={s.picContainer}> <div key={i} className={s.picContainer}>
<Tooltip placement="bottom" title={item.name}> <Tooltip placement="bottom" title={item.name}>
......
.suffixIcon { .searchContainer {
width: 12px; width: 100%;
height: 12px; height: 100%;
:global(.ant-select-selection){
min-height: 100%;
}
} }
import React from 'react'; import React from 'react';
import { Spin, Select } from 'antd'; import { Spin, Select } from 'antd';
import lodash from 'lodash'; import lodash from 'lodash';
import s from './index.less';
interface Props { interface Props {
initDataType?: undefined | 'onfocus'; // 初始化请求方式 initDataType?: undefined | 'onfocus'; // 初始化请求方式
...@@ -224,7 +225,6 @@ class AssociationSearch extends React.Component<Props, State> { ...@@ -224,7 +225,6 @@ class AssociationSearch extends React.Component<Props, State> {
const { data, fetching, value } = this.state; const { data, fetching, value } = this.state;
const { selfCom, autoFocus, onChange, ...rest } = this.props; const { selfCom, autoFocus, onChange, ...rest } = this.props;
return ( return (
<div>
<Select <Select
filterOption={false} filterOption={false}
{...rest} {...rest}
...@@ -245,8 +245,6 @@ class AssociationSearch extends React.Component<Props, State> { ...@@ -245,8 +245,6 @@ class AssociationSearch extends React.Component<Props, State> {
); );
})} })}
</Select> </Select>
{selfCom || null}
</div>
); );
} }
} }
......
.container { .container {
.upload { .upload {
} }
.addIcon {
cursor: pointer;
width: 12px;
}
} }
...@@ -5,6 +5,7 @@ import s from './index.less'; ...@@ -5,6 +5,7 @@ import s from './index.less';
import { antiAssign, getRandom } from '../../../../utils/utils'; import { antiAssign, getRandom } from '../../../../utils/utils';
import { checkoutFileType } from './utils'; import { checkoutFileType } from './utils';
import Preview from './preview'; import Preview from './preview';
import addIcon from '../../../../assets/addIcon.png';
message.config({ message.config({
maxCount: 1, maxCount: 1,
...@@ -143,7 +144,7 @@ const UploadCom = (props) => { ...@@ -143,7 +144,7 @@ const UploadCom = (props) => {
showDownloadIcon: true, showDownloadIcon: true,
}} }}
> >
Add <img alt="" className={s.addIcon} src={addIcon} />
</Upload> </Upload>
<Preview ref={previewModel} /> <Preview ref={previewModel} />
</div> </div>
......
...@@ -161,19 +161,19 @@ export default class Filter extends Component<Props, State> { ...@@ -161,19 +161,19 @@ export default class Filter extends Component<Props, State> {
}; };
// 保存筛选匹配值 // 保存筛选匹配值
saveFilterList = () => { saveFilterList = (locale) => {
const { filterConfig } = this.state; const { filterConfig } = this.state;
for (let i = 0; i < filterConfig.length; i++) { for (let i = 0; i < filterConfig.length; i++) {
// 筛选条件值为undefined或[]或[{text:'',value:''}]都算空,不能提交 // 筛选条件值为undefined或[]或[{text:'',value:''}]都算空,不能提交
if ( if (
!filterConfig[i].colName || !filterConfig[i].colName
!filterConfig[i].operationCode || || !filterConfig[i].operationCode
!filterConfig[i].colValues || || !filterConfig[i].colValues
filterConfig[i].colValues.length === 0 || || filterConfig[i].colValues.length === 0
(!filterConfig[i].colValues && filterConfig[i].colValues !== 0) || || (!filterConfig[i].colValues && filterConfig[i].colValues !== 0)
(!filterConfig[i].colValues[0].text && filterConfig[i].colValues[0].text !== 0) || (!filterConfig[i].colValues[0].text && filterConfig[i].colValues[0].text !== 0)
) { ) {
message.error('Filter conditions cannot be empty.'); message.error(locale.filterEmpty);
return; return;
} }
} }
...@@ -287,7 +287,7 @@ export default class Filter extends Component<Props, State> { ...@@ -287,7 +287,7 @@ export default class Filter extends Component<Props, State> {
<div <div
role="presentation" role="presentation"
className={classNames(styles.btn, styles.search)} className={classNames(styles.btn, styles.search)}
onClick={this.saveFilterList} onClick={this.saveFilterList.bind(null, locale)}
> >
{locale.filterSearch} {locale.filterSearch}
</div> </div>
......
...@@ -78,6 +78,7 @@ export interface TableState { ...@@ -78,6 +78,7 @@ export interface TableState {
dataSource: RowProps[]; dataSource: RowProps[];
tableHeight?: number; tableHeight?: number;
tableWidth?: number; tableWidth?: number;
selectedCell?:any;
} }
export interface CommonProps extends TableProps { export interface CommonProps extends TableProps {
operateConfig?: OperateConfigProps; operateConfig?: OperateConfigProps;
...@@ -99,6 +100,7 @@ export interface BaseComponentState { ...@@ -99,6 +100,7 @@ export interface BaseComponentState {
columnConfig: ColumnProps; columnConfig: ColumnProps;
} }
export interface CellProps { export interface CellProps {
cellKey:string;
rowIndex: number; rowIndex: number;
columnIndex: number; columnIndex: number;
columnConfig: ColumnProps; columnConfig: ColumnProps;
...@@ -115,6 +117,8 @@ export interface CellProps { ...@@ -115,6 +117,8 @@ export interface CellProps {
cellEditable?: boolean; cellEditable?: boolean;
rowSelection?: any; rowSelection?: any;
contentMenu?: any; contentMenu?: any;
selectedCell?:any;
changeSelectedCell?:Function;
} }
export interface EditCellProps { export interface EditCellProps {
......
...@@ -5,6 +5,7 @@ export const defaultLocale: any = { ...@@ -5,6 +5,7 @@ export const defaultLocale: any = {
filterAdd: '添加', filterAdd: '添加',
filterSearch: '查询', filterSearch: '查询',
filterReset: '重置', filterReset: '重置',
filterEmpty: '筛选条件不能为空',
selectedConditions: '已选条件:', selectedConditions: '已选条件:',
saveShortcut: '新建快捷筛选', saveShortcut: '新建快捷筛选',
clearFilter: '重置', clearFilter: '重置',
...@@ -19,6 +20,8 @@ export const defaultLocale: any = { ...@@ -19,6 +20,8 @@ export const defaultLocale: any = {
select: '请选择', select: '请选择',
text: '请输入', text: '请输入',
alreadyInput: '已输入', alreadyInput: '已输入',
linkText: '文本:',
linkUrl: 'url:',
}, },
en: { en: {
empty: 'It’s empty here.', empty: 'It’s empty here.',
...@@ -26,6 +29,7 @@ export const defaultLocale: any = { ...@@ -26,6 +29,7 @@ export const defaultLocale: any = {
filterAdd: 'Add', filterAdd: 'Add',
filterSearch: 'Search', filterSearch: 'Search',
filterReset: 'Reset', filterReset: 'Reset',
filterEmpty: 'Filter conditions cannot be empty.',
selectedConditions: 'Selected conditions:', selectedConditions: 'Selected conditions:',
saveShortcut: 'Save as a shortcut', saveShortcut: 'Save as a shortcut',
clearFilter: 'Clear filters', clearFilter: 'Clear filters',
...@@ -40,5 +44,7 @@ export const defaultLocale: any = { ...@@ -40,5 +44,7 @@ export const defaultLocale: any = {
select: 'please select', select: 'please select',
text: 'please input', text: 'please input',
alreadyInput: 'Entered', alreadyInput: 'Entered',
linkText: 'text:',
linkUrl: 'url:',
}, },
}; };
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