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

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

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