UNPKG

wui-print

Version:

前端打印插件,包含打印设计器、打印表单、打印API

50 lines (49 loc) 1.35 kB
import { camelToKebab } from "../print-designer-utils"; const createGridStyle = ({ styleConfig } = {}) => { if (!styleConfig) { styleConfig = {}; } let styleText = ""; Object.keys(styleConfig).forEach((key, index) => { if (key.indexOf("_") >= 0) { return false; } if (!!styleConfig[key] || styleConfig[key] === 0) { styleText += `${camelToKebab(key)}:${styleConfig[key]};`; } }); return styleText; }; const createGridItemStyle = ({ styleConfig, props } = {}) => { if (!styleConfig) { styleConfig = {}; } let styleText = ""; Object.keys(styleConfig).forEach((key, index) => { if (key.indexOf("_") >= 0) { return false; } if (!!styleConfig[key] || styleConfig[key] === 0) { styleText += `${camelToKebab(key)}:${styleConfig[key]};`; } }); if (!!props) { styleText += createGridItemStyleByProps({ props }); } return styleText; }; const createGridItemStyleByProps = ({ props } = {}) => { let styleText = ""; if (!props) { return styleText; } let span = !!props.span ? Number(props.span) : 0; let flexWidth = ((span / 24) * 100).toFixed(7); styleText += `flex:0 0 ${flexWidth}%`; return styleText; }; export default { createGridStyle, createGridItemStyle, createGridItemStyleByProps };