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

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

上级 a99dd598
...@@ -8,16 +8,19 @@ export default function MobileCard(props) { ...@@ -8,16 +8,19 @@ export default function MobileCard(props) {
otherProps = json?.otherProps; otherProps = json?.otherProps;
try { try {
let arg = {}; let arg = {};
if(typeof getArguments === 'function'){ if (typeof getArguments === 'function') {
arg = getArguments({base52: dataColumn.base52}, function() {}); arg = getArguments({ base52: dataColumn.base52 }, function() {});
} }
otherProps = new Function('functionArguments', 'tableComProps', otherProps)(arg, tableComProps); otherProps = new Function('functionArguments', 'tableComProps', otherProps)(
arg,
tableComProps,
);
} catch (e) { } catch (e) {
console.log('MobileCard组件获取otherProps 报错', e); console.log('MobileCard组件获取otherProps 报错', e);
otherProps = null; otherProps = null;
} }
} }
if(!otherProps){ if (!otherProps) {
return null; return null;
} }
const dataSource = value?.dataSource || otherProps?.defaultDataSource || []; const dataSource = value?.dataSource || otherProps?.defaultDataSource || [];
...@@ -25,18 +28,42 @@ export default function MobileCard(props) { ...@@ -25,18 +28,42 @@ export default function MobileCard(props) {
return ( return (
<> <>
{dataSource.map((g, index) => { {dataSource.map((g, index) => {
// const clickFunction = // 点击整个块
// typeof g.handleClick === 'function'
// ? e => {
// if (e && e.stopPropagation) {
// e.stopPropagation();
// e.preventDefault();
// }
// return g.handleClick(g, value);
// }
// : undefined;
return ( return (
<div key={g[primaryKey]} style={style}> <div key={g[primaryKey]} style={style}>
<WingBlank> <WingBlank>
{columns.map((c, cIndex) => { {columns.map((c, cIndex) => {
const { style: cStyle, data: cData } = c; const { style: cStyle, data: cData } = c;
const clickFunction = // 点击某一行
typeof c.handleClick === 'function'
? e => {
if (e && e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
return c.handleClick(g, c, value);
}
: undefined;
return ( return (
<div key={c.key} style={cStyle || {}}> <div key={c.key} style={cStyle || {}} onClick={clickFunction}>
{cData.map((h, hIndex) => { {cData.map((h, hIndex) => {
let hProps = h.props || {}; let hProps = h.props || {};
const clickFunction = const clickFunction = // 点击某一个单元格
typeof hProps.handleClick === 'function' typeof hProps.handleClick === 'function'
? () => { ? e => {
if (e && e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
return hProps.handleClick(g, h.key || h, value); return hProps.handleClick(g, h.key || h, value);
} }
: undefined; : undefined;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论