Commit 36dd90bc authored by 田翔's avatar 田翔

fix: 带颜色选项支持颜色选择

parent c8a681da
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "6.10.19", "version": "6.10.20",
"description": "6.10.19 关联表单选中不显示配置问题", "description": "6.10.20 带颜色选项支持颜色选择",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -57,10 +57,25 @@ const layoutWidgets = [ ...@@ -57,10 +57,25 @@ const layoutWidgets = [
displayType: 'row', displayType: 'row',
labelWidth: 75, labelWidth: 75,
}, },
isText: {
title: '是否为纯文本',
type: 'boolean',
widget: 'IsText',
default: false,
},
contentText: {
title: '纯文本内容',
type: 'string',
widget: 'ContentText',
hidden: "{{!formData.isText}}",
dependencies: ['IsText'],
},
contentHTML: { contentHTML: {
title: '控件内容', title: '富文本内容',
type: 'string', type: 'string',
widget: 'ContentHTML', widget: 'ContentHTML',
hidden: "{{formData.isText}}",
dependencies: ['IsText'],
}, },
styleHTML: { styleHTML: {
title: '控件样式', title: '控件样式',
......
...@@ -12,6 +12,13 @@ import { isObject, getFieldInfo } from '../../utils' ...@@ -12,6 +12,13 @@ import { isObject, getFieldInfo } from '../../utils'
import { getWatch } from './watch' import { getWatch } from './watch'
import styles from '../../main.less' import styles from '../../main.less'
const getLabelWidth = (schema) => {
if (['TextHTML', 'RelationForm', 'AreaTask'].includes(schema.widget)) {
return 1
}
return 110
}
const XRender = (props, ref) => { const XRender = (props, ref) => {
useImperativeHandle(ref, () => ( useImperativeHandle(ref, () => (
...@@ -77,7 +84,7 @@ const XRender = (props, ref) => { ...@@ -77,7 +84,7 @@ const XRender = (props, ref) => {
...child[s], ...child[s],
title: ['RelationForm', 'AreaTask'].includes(child[s].widget) ? '' : child[s].title, title: ['RelationForm', 'AreaTask'].includes(child[s].widget) ? '' : child[s].title,
titleShow: child[s].title || child[s].titleShow, titleShow: child[s].title || child[s].titleShow,
labelWidth: ['RelationForm', 'AreaTask'].includes(child[s].widget) ? 1 : 110, labelWidth: getLabelWidth(child[s]),
presetValue: value || child[s].presetValue || '', presetValue: value || child[s].presetValue || '',
textDefalut: child[s].presetValue, textDefalut: child[s].presetValue,
formDisabled: disabled, formDisabled: disabled,
......
import React, { useEffect } from 'react'
import { Switch } from 'antd'
const IsText = (props) => {
const { value, onChange, addons } = props
const switchChange = (checked) => {
if (addons) {
onChange(checked)
}
}
return (
<Switch
checked={value}
checkedChildren={'纯文本'}
unCheckedChildren={'富文本'}
onChange={switchChange}
>
</Switch>
)
}
export default IsText
\ No newline at end of file
...@@ -11,6 +11,7 @@ import HiddenCondition from './HiddenCondition' ...@@ -11,6 +11,7 @@ import HiddenCondition from './HiddenCondition'
import SwitchDefault from './SwitchDefault' import SwitchDefault from './SwitchDefault'
import RichTextDefault from './RichTextDefault' import RichTextDefault from './RichTextDefault'
import IsHidden from './IsHidden' import IsHidden from './IsHidden'
import IsText from './IsText'
const groupBase = { const groupBase = {
FieldNames, FieldNames,
...@@ -26,6 +27,7 @@ const groupBase = { ...@@ -26,6 +27,7 @@ const groupBase = {
SwitchDefault, SwitchDefault,
RichTextDefault, RichTextDefault,
IsHidden, IsHidden,
IsText,
} }
export default groupBase export default groupBase
\ No newline at end of file
...@@ -6,6 +6,7 @@ import DragTable from '../../../../components/DragTable' ...@@ -6,6 +6,7 @@ import DragTable from '../../../../components/DragTable'
import { CheckOutlined, DeleteOutlined, MenuOutlined } from '@ant-design/icons' import { CheckOutlined, DeleteOutlined, MenuOutlined } from '@ant-design/icons'
import { colors } from '../../../../../constant' import { colors } from '../../../../../constant'
import { getNanoid } from '../../../../../utils' import { getNanoid } from '../../../../../utils'
import { SketchPicker } from 'react-color'
const SimpleList = (props) => { const SimpleList = (props) => {
...@@ -14,6 +15,8 @@ const SimpleList = (props) => { ...@@ -14,6 +15,8 @@ const SimpleList = (props) => {
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
const [text, setText] = useState('') const [text, setText] = useState('')
const [loading, setLoading] = useState(true) const [loading, setLoading] = useState(true)
const [currentColor, setCurrentColor] = useState('')
const [currentRgba, setCurrentRgba] = useState('')
useEffect(() => { useEffect(() => {
if (addons) { if (addons) {
...@@ -103,7 +106,31 @@ const SimpleList = (props) => { ...@@ -103,7 +106,31 @@ const SimpleList = (props) => {
<div> <div>
<div className={styles.colorTop}> <div className={styles.colorTop}>
<div className={styles.topLeft}>请选择颜色</div> <div className={styles.topLeft}>请选择颜色</div>
<div className={styles.topRight} onClick={() => rest(index)}>重置</div> <div className={styles.topRight}>
<Popconfirm
overlayClassName={styles.Popconfirmtitle}
placement="topLeft"
icon={false}
title={
<SketchPicker width="217px" color={currentColor} onChange={e => {
setCurrentRgba(`rgb(${e.rgb.r}, ${e.rgb.g}, ${e.rgb.b})`)
setCurrentColor(e.hex)
}} />
}
onConfirm={() => {
let array = []
value.forEach((v, i2) => {
if (index === i2) {
v.color = currentRgba
}
array.push({ ...v })
})
onChange(array)
}}
>
<div className={styles.colorsSelect}></div>
</Popconfirm>
</div>
</div> </div>
<div className={styles.colorBox}> <div className={styles.colorBox}>
{ {
...@@ -154,7 +181,7 @@ const SimpleList = (props) => { ...@@ -154,7 +181,7 @@ const SimpleList = (props) => {
return columns.filter(v => v.dataIndex !== 'color') return columns.filter(v => v.dataIndex !== 'color')
} }
return columns return columns
}, [value, color]) }, [value, color, currentColor])
const switchChange = (checked) => { const switchChange = (checked) => {
addons.setValue('color', checked) addons.setValue('color', checked)
......
...@@ -3,56 +3,81 @@ ...@@ -3,56 +3,81 @@
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
.box { .box {
padding: 0 5px; padding: 0 5px;
.item { .item {
margin-top: 5px; margin-top: 5px;
} }
} }
.footer { .footer {
margin-top: 4px; margin-top: 4px;
span { span {
display: inline-block; display: inline-block;
color: #1495ff; color: #1495ff;
&:nth-child(2) { &:nth-child(2) {
margin: 0 5px; margin: 0 5px;
width: 2px; width: 2px;
height: 11px; height: 11px;
background: #a5a5a5; background: #a5a5a5;
} }
&:hover { &:hover {
cursor: pointer; cursor: pointer;
} }
} }
} }
} }
.colorTop { .colorTop {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
.topLeft { .topLeft {
font-size: 15px; font-size: 15px;
font-weight: 700; font-weight: 700;
color: #707070; color: #707070;
} }
.topRight { .topRight {
font-size: 12px; font-size: 12px;
color: #41b3ec; color: #41b3ec;
&:hover { &:hover {
cursor: pointer; cursor: pointer;
} }
} }
} }
.colorBox { .colorBox {
width: 130px; width: 130px;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
} }
.colorsSelect {
width: 20px;
height: 20px;
border: 1px solid #40a9ff;
border-radius: 2px;
background: linear-gradient(135deg, rgb(255, 77, 79), rgb(115, 209, 61), rgb(89, 126, 247), rgb(54, 207, 201));
&:hover {
cursor: pointer;
}
}
.colors { .colors {
width: 20px; width: 20px;
height: 20px; height: 20px;
border-radius: 50%; border-radius: 50%;
margin-top: 6px; margin-top: 6px;
margin-left: 6px; margin-left: 6px;
&:hover { &:hover {
cursor: pointer; cursor: pointer;
} }
......
import React, { useMemo, useEffect, useState } from 'react'
import { Input } from 'antd'
import { PlusOutlined } from '@ant-design/icons'
import Drag from '../../../../components/Drag'
const ContentText = (props) => {
const { value, addons, onChange } = props
const { title } = addons.formData
const [visible, setVisible] = useState(false)
const [areaValue, setAreaValue] = useState('')
const inputChange = (e) => {
onChange(e.target.value)
}
const areaChange = (e) => {
setAreaValue(e.target.value)
}
const onOk = () => {
onChange(areaValue)
setVisible(false)
}
const onCancel = () => {
setVisible(false)
}
const iconClick = () => {
setAreaValue(value)
setVisible(true)
}
return (
<div>
<Input
value={value}
onChange={inputChange}
addonAfter={<PlusOutlined onClick={iconClick} />}
/>
<Drag
width='500px'
getContainer={false}
title={props.schema.title || '图标选择'}
visible={visible}
onOk={onOk}
onCancel={onCancel}
>
<Input.TextArea rows={5} value={areaValue} onChange={areaChange} />
</Drag>
</div>
)
}
export default ContentText
\ No newline at end of file
...@@ -4,6 +4,7 @@ import Formatting from './Formatting'; ...@@ -4,6 +4,7 @@ import Formatting from './Formatting';
import DecimalDigits from './DecimalDigits'; import DecimalDigits from './DecimalDigits';
import FileTypeSelect from './FileTypeSelect'; import FileTypeSelect from './FileTypeSelect';
import ContentHTML from './ContentHTML'; import ContentHTML from './ContentHTML';
import ContentText from './ContentText';
import StyleHTML from './StyleHTML'; import StyleHTML from './StyleHTML';
import RadioGroupW from './RadioGroupW'; import RadioGroupW from './RadioGroupW';
import CheckBoxGroup from './CheckBoxGroup'; import CheckBoxGroup from './CheckBoxGroup';
...@@ -15,6 +16,7 @@ const groupStyle = { ...@@ -15,6 +16,7 @@ const groupStyle = {
DecimalDigits, DecimalDigits,
FileTypeSelect, FileTypeSelect,
ContentHTML, ContentHTML,
ContentText,
StyleHTML, StyleHTML,
RadioGroupW, RadioGroupW,
CheckBoxGroup, CheckBoxGroup,
......
...@@ -3,7 +3,13 @@ import React from 'react' ...@@ -3,7 +3,13 @@ import React from 'react'
const TextHTML = (props) => { const TextHTML = (props) => {
const { value, onChange, schema } = props const { value, onChange, schema } = props
const { contentHTML, styleHTML } = schema const { isText, contentHTML, contentText, styleHTML } = schema
if (isText) {
return (
<div>{contentText}</div>
)
}
return ( return (
<div style={{ width: '100%', ...styleHTML }}> <div style={{ width: '100%', ...styleHTML }}>
......
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