Commit 88e26158 authored by 彭俊龙's avatar 彭俊龙

描述控件新增跟随字段隐藏

parent 46d16d2f
......@@ -77,6 +77,11 @@ const layoutWidgets = [
hidden: "{{formData.isText}}",
dependencies: ['IsText'],
},
hideKey:{
title: '跟随字段同步隐藏',
type: 'string',
widget: 'FollowFieldHide',
},
styleHTML: {
title: '控件样式',
type: 'object',
......
......@@ -43,13 +43,24 @@ const XRender = (props, ref) => {
const schemaForm = useMemo(() => {
let schemaForm = formJson ? (isObject(formJson) ? formJson : JSON.parse(formJson)) : {}
console.log(schemaForm, 'schemaForm');
let parent = schemaForm?.properties
let keys = Object.keys(parent);
let parentDatas = keys.map(k=> parent[k].properties)
let fieldDatas = {};
parentDatas.forEach(k=>{
let ks = Object.keys(k)
ks.map(x=> fieldDatas[x] =k[x])
})
console.log(fieldDatas, 'datasdatas');
let parentObj = {}
let array = []
if (isObject(parent)) {
for (let v in parent) {
let hidden = true
let child = parent[v]?.properties
let childObj = {}
if (isObject(child)) {
for (let s in child) {
......@@ -80,6 +91,15 @@ const XRender = (props, ref) => {
if (child[s].isDoing) {
array.push(s)
}
if(child[s].widget === 'TextHTML' && child[s]?.hideKey){
const hideKey = child[s]?.hideKey
if(fieldDatas.hasOwnProperty(hideKey)){
const followData = fieldDatas[hideKey];
if(followData){
child[s].hidden = followData.hidden;
}
}
}
childObj[s] = {
...child[s],
title: ['RelationForm', 'AreaTask'].includes(child[s].widget) ? '' : child[s].title,
......
import { PlusOutlined } from '@ant-design/icons';
import { LoadTableFields, ReloadTableFields } from '../../../../../apis/process';
import React, { useContext, useEffect, useMemo, useState } from 'react';
import { Select } from 'antd'
const FollowFieldHide = props => {
const { value, onChange, addons, disabled } = props;
const { tableNameParent, widget, $id } = addons.formData;
const [fields, setFields] = useState([]);
useEffect(() => {
getFieldData();
}, []);
const getFieldData = async () => {
if (!tableNameParent) {
return message.info('缺少表名!')
}
const { data } = await ReloadTableFields({ tableName: tableNameParent });
if (Array.isArray(data.root)) {
const fields = data.root.map(x=> x.name);
setFields(fields);
}
console.log(data, 'data');
};
return (
<div>
<Select style={{ width: '100%' }} onChange={onChange} value={value} options={fields.map(x=> { return { value: x, label: x }})}/>
</div>
)
};
export default FollowFieldHide;
import FieldNames from './FieldNames'
import FollowFieldHide from './FollowFieldHide'
import Placeholder from './Placeholder'
import PresetValueFileUpload from './PresetValueFileUpload'
import InputDefault from './InputDefault'
......@@ -28,6 +29,7 @@ const groupBase = {
RichTextDefault,
IsHidden,
IsText,
FollowFieldHide
}
export default groupBase
\ No newline at end of file
......@@ -4,10 +4,10 @@ const TextHTML = (props) => {
const { value, onChange, schema } = props
const { isText, contentHTML, contentText, styleHTML } = schema
if (isText) {
return (
<div style={{ color: styleHTML?.color, padding: styleHTML?.padding ? `0 ${styleHTML.padding}%` : '' }}>{contentText}</div>
<div style={{ background: styleHTML?.background, color: styleHTML?.color, padding: styleHTML?.padding ? `0 ${styleHTML.padding}%` : '' }}>{contentText}</div>
)
}
......
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