Commit 39a62173 authored by zhangwenshuai's avatar zhangwenshuai

修改新业务兼容

parent 990424b2
......@@ -334,6 +334,7 @@ const Cell = (props: CellProps) => {
const value = setFormat(editConfig, columnConfig, changedValue, optionValue);
emitChangeCellData(value, optionValue);
}}
cellRenderProps={cellRenderProps}
style={{
minHeight: cellStyle.height,
borderRadius: 0,
......
......@@ -55,11 +55,9 @@ export default class AirTable extends Component<TableProps, TableState> {
};
if (JSON.stringify(dataSource) !== JSON.stringify(nextProps.dataSource)) {
nextState.dataSource = nextProps.dataSource;
nextState.selectedCell = null;
}
if (JSON.stringify(columns) !== JSON.stringify(nextProps.columns)) {
nextState.columns = nextProps.columns;
nextState.selectedCell = null;
}
return nextState;
}
......@@ -72,7 +70,6 @@ export default class AirTable extends Component<TableProps, TableState> {
dataSource,
tableWidth: width,
tableHeight: height,
selectedCell: null,
};
this.config = {
overscanColumnCount: 5,
......@@ -216,12 +213,6 @@ export default class AirTable extends Component<TableProps, TableState> {
}
};
changeSelectedCell = (key) => {
this.setState({
selectedCell: key,
});
};
// 列伸缩回调
onResizeWidth = (e) => {
const originLeft = (this.tableContainer && this.tableContainer.getBoundingClientRect().x) || 0;
......@@ -312,10 +303,10 @@ export default class AirTable extends Component<TableProps, TableState> {
}
};
// 拖拽排序回调
onDragSorted = (dragColumn:any, dropColumn:any) => {
onDragSorted = (dragColumn: any, dropColumn: any) => {
const { onDragSorted } = this.props;
const { columns } = this.state;
const newColumns:any[] = [];
const newColumns: any[] = [];
columns.map((item) => {
if (dragColumn.orderNo > dropColumn.orderNo) {
if (item.orderNo >= dropColumn.orderNo && item.orderNo <= dragColumn.orderNo) {
......@@ -387,6 +378,7 @@ export default class AirTable extends Component<TableProps, TableState> {
>
<ResizableBox
width={style.width}
height={style.height}
handle={
<span
className={styles.handleWidth}
......@@ -430,7 +422,7 @@ export default class AirTable extends Component<TableProps, TableState> {
}: { showColumns: ColumnProps[]; showData: RowProps; position?: string },
{ columnIndex, key, rowIndex, style }: any,
) => {
const { columns, dataSource, selectedCell } = this.state;
const { columns, dataSource } = this.state;
const {
emitChangeCell,
paginationConfig,
......@@ -507,8 +499,6 @@ export default class AirTable extends Component<TableProps, TableState> {
cellEditable={cellEditable}
rowSelection={position === 'right' ? false : rowSelection}
contentMenu={contentMenu}
selectedCell={selectedCell}
changeSelectedCell={this.changeSelectedCell}
cellKey={key}
position={position}
/>
......
......@@ -6,6 +6,9 @@ import s from './index.less';
export const Tags = (props: any) => {
const { value, origin, componentAttr, columnConfig } = props;
if (!Array.isArray(value) || value.length === 0) return null;
if (value.length === 1 && !value[0].text && !value[0].value) {
return null;
}
const { options, mode } = componentAttr || {};
const outStyle: any = {};
const innerStyle: any = {};
......@@ -18,9 +21,10 @@ export const Tags = (props: any) => {
const getColor = (item: any) => {
let color = '';
if (options && Array.isArray(options) && options.length > 0) {
const obj = options.find((ls) => {
return String(ls.id) === String(item.value);
}) || {};
const obj =
options.find((ls) => {
return String(ls.id) === String(item.value);
}) || {};
color = obj.color || 'e9eef9';
}
return color;
......
......@@ -5,7 +5,7 @@ import { antiAssign } from '../../../../utils/utils';
import s from './index.less';
export const ApolloInputSearch = (props: ApolloInputSearchProps) => {
const { onChange, request, type } = props;
const { onChange, request } = props;
const selfProps = antiAssign(props, ['columnConfig', 'onChange', 'request']);
const changeValue = (value) => {
......@@ -17,7 +17,7 @@ export const ApolloInputSearch = (props: ApolloInputSearchProps) => {
return (
<InputSearch
className={s.select}
request={(val) => { return request({ name: val, fieldValueName: type }); }}
request={request}
fieldNames={{ value: 'fieldValueValue', label: 'fieldValueName' }}
{...selfProps}
onChange={changeValue}
......
......@@ -83,7 +83,6 @@ export interface TableState {
dataSource: RowProps[];
tableHeight?: number;
tableWidth?: number;
selectedCell?: any;
}
export interface CommonProps extends TableProps {
operateConfig?: OperateConfigProps;
......
......@@ -25,7 +25,7 @@ class FormWrap extends Component {
handleSubmit = (e) => {
e.preventDefault();
e.stopPropagation();
const { rowId, form, handleSubmit, data, rowData } = this.props;
const { rowId, form, handleSubmit, data, rowData, detailType } = this.props;
form.validateFieldsAndScroll((err, values) => {
if (!err) {
const newValues: any[] = [];
......@@ -33,7 +33,7 @@ class FormWrap extends Component {
const item = data.find((temp: any) => {
return temp.columnName === key;
});
const { columnType, renderEditForm, readOnlyFlag, dynamicCellConfigDTO } = item;
const { columnType, columnAttrObj, renderEditForm, readOnlyFlag, dynamicCellConfigDTO } = item;
if (readOnlyFlag || (dynamicCellConfigDTO && dynamicCellConfigDTO.readonlyFlag)) {
return;
}
......@@ -44,13 +44,15 @@ class FormWrap extends Component {
detailConfig = config[String(columnType)] || config['1'];
}
const cellValueList = setFormat(detailConfig, item, values[key]);
newValues.push({
const newData: any = {
columnCode: key,
cellValueList,
});
};
newValues.push(newData);
});
if (typeof handleSubmit === 'function') {
handleSubmit({ data: { value: newValues } });
handleSubmit({ data: { value: newValues }, formValues: values, detailType });
}
}
});
......@@ -82,7 +84,7 @@ class FormWrap extends Component {
renderEditForm = (item) => {
const { getFieldDecorator } = this.props.form;
const { rowData } = this.props;
const { rowData, rowId } = this.props;
const {
columnType,
columnName,
......@@ -94,6 +96,7 @@ class FormWrap extends Component {
validateFirst = true,
validateTrigger = 'onChange',
dynamicCellConfigDTO,
cellRenderProps,
} = item;
let detailConfig: any;
if (typeof renderEditForm === 'function') {
......@@ -114,13 +117,15 @@ class FormWrap extends Component {
{getFieldDecorator(columnName, {
validateFirst,
validateTrigger,
rules: [{ required: !!item.requiredFlag, message: '必填项不能为空' }, ...rules],
// rules: [{ required: !!item.requiredFlag, message: '必填项不能为空' }, ...rules],
initialValue: getFormat(detailConfig, item, value),
})(
<EditComp
{...transferColumn}
columnConfig={item}
disabled={disabled}
rowData={{ id: rowId, rowData }}
cellRenderProps={cellRenderProps}
origin="editForm"
form={this.props.form}
/>,
......
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