Commit 824d962f authored by zhangwenshuai's avatar zhangwenshuai

update apolloTable

parent 9eebc114
...@@ -250,7 +250,7 @@ const Cell = (props: CellProps) => { ...@@ -250,7 +250,7 @@ const Cell = (props: CellProps) => {
const EditComp: any = editConfig.cellComp; const EditComp: any = editConfig.cellComp;
const transferColumn = transferAttr(columnType, { const transferColumn = transferAttr(columnType, {
...(config.componentAttr || {}), ...(editConfig.componentAttr || {}),
...(columnConfig.columnAttrObj || {}), ...(columnConfig.columnAttrObj || {}),
}); });
const newProps = { const newProps = {
......
...@@ -47,8 +47,10 @@ export const GetFormatter = { ...@@ -47,8 +47,10 @@ export const GetFormatter = {
}, },
MULTIPLE_SELECT: (val) => { MULTIPLE_SELECT: (val) => {
// 处理成[{}]结构 // 处理成[{}]结构
const obj = val[0] || {}; if (!Array.isArray(val) || val.length === 0) return undefined;
return { key: obj.value, label: obj.text }; return val.map((item) => {
return { key: item.value, label: item.text };
});
}, },
TEXT_SELECT: (val) => { TEXT_SELECT: (val) => {
return GetFormatter.SELECT(val); return GetFormatter.SELECT(val);
......
...@@ -6,15 +6,16 @@ ...@@ -6,15 +6,16 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
align-items: center; align-items: center;
.text {
width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.itemBgTxt { .itemBgTxt {
position: absolute; position: absolute;
z-index: -1; z-index: -1;
visibility: hidden; visibility: hidden;
} }
} }
.text {
width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
word-break: break-all;
}
...@@ -5,7 +5,7 @@ import styles from './index.less'; ...@@ -5,7 +5,7 @@ import styles from './index.less';
import { InputProps } from '../detailInterface'; import { InputProps } from '../detailInterface';
export const ApolloInputDetail = (props: InputProps) => { export const ApolloInputDetail = (props: InputProps) => {
const { className } = props; const { className, origin } = props;
const value = props.formatter ? props.formatter(props.value) : props.value; const value = props.formatter ? props.formatter(props.value) : props.value;
if (!value) { if (!value) {
return null; return null;
...@@ -25,6 +25,10 @@ export const ApolloInputDetail = (props: InputProps) => { ...@@ -25,6 +25,10 @@ export const ApolloInputDetail = (props: InputProps) => {
} }
}, [value]); }, [value]);
if (origin === 'detailForm') {
return <div className={classNames(styles.text, className)}>{value}</div>;
}
if (typeof value === 'string') { if (typeof value === 'string') {
return ( return (
<div className={styles.container} ref={container}> <div className={styles.container} ref={container}>
......
...@@ -5,9 +5,9 @@ import { antiAssign } from '../../../../utils/utils'; ...@@ -5,9 +5,9 @@ import { antiAssign } from '../../../../utils/utils';
import styles from './styles.less'; import styles from './styles.less';
export const ApolloSelect = (props: ApolloSelectProps) => { export const ApolloSelect = (props: ApolloSelectProps) => {
const { options = [], onChange, isMultiple, isMobile } = props; const { options = [], onChange, isMultiple } = props;
const selfProps = antiAssign(props, ['columnConfig', 'onChange', 'isMultiple', 'options']); const selfProps = antiAssign(props, ['columnConfig', 'onChange', 'isMultiple', 'options']);
const changeValue = (value, option) => { const changeValue = (value: any, option: any) => {
if (typeof onChange === 'function') { if (typeof onChange === 'function') {
onChange(value, option); onChange(value, option);
} }
...@@ -16,9 +16,12 @@ export const ApolloSelect = (props: ApolloSelectProps) => { ...@@ -16,9 +16,12 @@ export const ApolloSelect = (props: ApolloSelectProps) => {
if (isMultiple) { if (isMultiple) {
selfProps.mode = 'multiple'; selfProps.mode = 'multiple';
} }
return ( return (
<Select className={styles.select} {...selfProps} onChange={changeValue}> <Select
className={styles.select}
{...selfProps}
onChange={changeValue}
>
{options.map((item) => { {options.map((item) => {
return ( return (
<Select.Option key={item.id} value={item.id}> <Select.Option key={item.id} value={item.id}>
......
...@@ -14,9 +14,10 @@ import { Form, Button } from 'antd'; ...@@ -14,9 +14,10 @@ import { Form, Button } from 'antd';
import styles from './index.less'; import styles from './index.less';
import { config } from '../component/base/config'; import { config } from '../component/base/config';
import { transferAttr } from '../component/base/_utils/transferAttr'; import { transferAttr } from '../component/base/_utils/transferAttr';
import { getFormat } from '../component/base'; import { getFormat, setFormat } from '../component/base';
import { Provider } from '../component/context'; import { Provider } from '../component/context';
import { defaultLocale } from '@/submodule/components/apolloTable/locale'; import { defaultLocale } from '@/submodule/components/apolloTable/locale';
import _ from 'lodash';
const FormItem = Form.Item; const FormItem = Form.Item;
...@@ -24,17 +25,36 @@ class FormWrap extends Component { ...@@ -24,17 +25,36 @@ class FormWrap extends Component {
handleSubmit = (e) => { handleSubmit = (e) => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
const { rowId, form, handleSubmit } = this.props; const { rowId, form, handleSubmit, data, rowData } = this.props;
form.validateFieldsAndScroll((err, values) => { form.validateFieldsAndScroll((err, values) => {
if (!err) { if (!err) {
const result = []; const newValues: any[] = [];
Object.keys(values).map((el) => { _.keys(values).map((key) => {
result.push({ const item = data.find((temp: any) => {
columnCode: el, return temp.columnName === key;
cellValueList: values[el], });
const { columnType, renderEditForm, readOnlyFlag, dynamicCellConfigDTO } = item;
if (readOnlyFlag || (dynamicCellConfigDTO && dynamicCellConfigDTO.readonlyFlag)) {
return;
}
let detailConfig: any;
if (typeof renderEditForm === 'function') {
detailConfig = renderEditForm({ cellData: values[key], rowData, columnConfig: item });
} else {
detailConfig = config[String(columnType)] || config['1'];
}
// if(key==='contactList'){
// debugger
// }
const cellValueList = setFormat(detailConfig, item, values[key]);
newValues.push({
columnCode: key,
cellValueList,
}); });
}); });
handleSubmit({ data: { id: rowId, value: result } }); if (typeof handleSubmit === 'function') {
handleSubmit({ data: { value: newValues } });
}
} }
}); });
}; };
...@@ -98,7 +118,7 @@ class FormWrap extends Component { ...@@ -98,7 +118,7 @@ class FormWrap extends Component {
validateFirst, validateFirst,
validateTrigger, validateTrigger,
rules: [{ required: !!item.requiredFlag }, ...rules], rules: [{ required: !!item.requiredFlag }, ...rules],
// initialValue: getFormat(detailConfig, item, value), initialValue: getFormat(detailConfig, item, value),
})(<EditComp {...transferColumn} columnConfig={item} disabled={readOnlyFlag} />)} })(<EditComp {...transferColumn} columnConfig={item} disabled={readOnlyFlag} />)}
</FormItem> </FormItem>
); );
...@@ -135,6 +155,7 @@ class FormWrap extends Component { ...@@ -135,6 +155,7 @@ class FormWrap extends Component {
{data.map((item: any, i: number) => { {data.map((item: any, i: number) => {
return ( return (
<div <div
key={i}
className={styles.item} className={styles.item}
style={{ style={{
width: `${100 / colsNum}%`, width: `${100 / colsNum}%`,
...@@ -200,4 +221,4 @@ function onValuesChange(props, changedValues, allValues) { ...@@ -200,4 +221,4 @@ function onValuesChange(props, changedValues, allValues) {
} }
} }
export default Form.create({ name: 'form_view', mapPropsToFields, onValuesChange })(FormWrap); export default Form.create({ name: 'form_view' })(FormWrap);
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