提交 c1122ace authored 作者: 钟是志's avatar 钟是志

29127 违纪,H5应用增加卡片组件

上级 b7a21c62
...@@ -2,33 +2,65 @@ import React, { Fragment, useEffect, useRef } from 'react'; ...@@ -2,33 +2,65 @@ import React, { Fragment, useEffect, useRef } from 'react';
import { WhiteSpace, WingBlank } from 'antd-mobile'; import { WhiteSpace, WingBlank } from 'antd-mobile';
export default function MobileCard(props) { export default function MobileCard(props) {
const { value = {}, onChange, json, otherProps = {} } = props; const { value = {}, onChange, json } = props;
useEffect(() => {}, [value]); let otherProps = {};
const dataSource = value?.dataSource || [ if (json?.otherProps) {
{ otherProps = json?.otherProps;
name: '罗成', try {
type: '待知晓', // mode = multiple 就支持下拉多选了
time: '2022-04-14 16:31:05', otherProps = new Function(otherProps)();
}, } catch (e) {
]; console.log('MobileCard组件获取otherProps 报错', e);
const { columns, primaryKey } = otherProps; otherProps = null;
console.log(columns); }
}
if(!otherProps){
return null;
}
const dataSource = value?.dataSource || otherProps?.defaultDataSource || [];
const { columns = [], primaryKey = '', style = {} } = otherProps;
console.log(otherProps);
return ( return (
<> <>
{dataSource.map((g, index) => { {dataSource.map((g, index) => {
return ( return (
<div key={g[primaryKey]} style={{ <div key={g[primaryKey]} style={style}>
padding: '15px 0', <WingBlank>
backgroundColor: '#ebebef', {columns.map((c, cIndex) => {
}}> const { style: cStyle, data: cData } = c;
<WingBlank> return (
{columns.map((c, cIndex) => { <div key={c.key} style={cStyle || {}}>
return <div key={c.key}> {cData.map((h, hIndex) => {
111222333444 let hProps = h.props || {};
</div>; const clickFunction =
})} typeof hProps.handleClick === 'function'
</WingBlank> ? () => {
</div>); return hProps.handleClick(g, h.key || h, value);
}
: undefined;
if (h.diyProps && typeof h.diyProps === 'function') {
hProps = h.diyProps(g, h.key || h, value) || {};
}
return (
<div style={hProps.style} onClick={clickFunction} key={hIndex}>
{hProps.children ? (
<>{hProps.children}</>
) : (
<>
{h.type === 'dataIndex' && index + 1}
{(h.type === 'dataSource' && g[h.key]) || ''}
{h.type === 'chinese' && h.value}
</>
)}
</div>
);
})}
</div>
);
})}
</WingBlank>
</div>
);
})} })}
</> </>
); );
......
...@@ -2137,7 +2137,7 @@ export default class TableCom extends Component { ...@@ -2137,7 +2137,7 @@ export default class TableCom extends Component {
if (!value || value === 'null') { if (!value || value === 'null') {
return <div/>; return <div/>;
} }
cm = <MobileCard value={value}/>; cm = <MobileCard value={value} json={json}/>;
break; break;
case 'WangEditor': case 'WangEditor':
let textV = obj[dataColumn.base52]; let textV = obj[dataColumn.base52];
...@@ -3573,22 +3573,12 @@ ${obj[dataColumn.base52]} ...@@ -3573,22 +3573,12 @@ ${obj[dataColumn.base52]}
})(<WangEditor json={json} dataColumn={dataColumn} disabled={disabled} uuid={uuid}/>); })(<WangEditor json={json} dataColumn={dataColumn} disabled={disabled} uuid={uuid}/>);
break; break;
case 'MobileCard': case 'MobileCard':
if (json?.otherProps) {
otherProps = json?.otherProps;
try {
// mode = multiple 就支持下拉多选了
otherProps = new Function(otherProps)();
} catch (e) {
otherProps = {};
}
}
cm = getFieldDecorator(dataColumn.base52, { cm = getFieldDecorator(dataColumn.base52, {
initialValue: initValue, initialValue: initValue,
})( })(
<MobileCard <MobileCard
json={json} json={json}
uuid={uuid} uuid={uuid}
otherProps={otherProps}
/>); />);
break; break;
case 'RichText': case 'RichText':
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论