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

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

parent 46d16d2f
...@@ -77,6 +77,11 @@ const layoutWidgets = [ ...@@ -77,6 +77,11 @@ const layoutWidgets = [
hidden: "{{formData.isText}}", hidden: "{{formData.isText}}",
dependencies: ['IsText'], dependencies: ['IsText'],
}, },
hideKey:{
title: '跟随字段同步隐藏',
type: 'string',
widget: 'FollowFieldHide',
},
styleHTML: { styleHTML: {
title: '控件样式', title: '控件样式',
type: 'object', type: 'object',
......
...@@ -43,13 +43,24 @@ const XRender = (props, ref) => { ...@@ -43,13 +43,24 @@ const XRender = (props, ref) => {
const schemaForm = useMemo(() => { const schemaForm = useMemo(() => {
let schemaForm = formJson ? (isObject(formJson) ? formJson : JSON.parse(formJson)) : {} let schemaForm = formJson ? (isObject(formJson) ? formJson : JSON.parse(formJson)) : {}
console.log(schemaForm, 'schemaForm');
let parent = schemaForm?.properties 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 parentObj = {}
let array = [] let array = []
if (isObject(parent)) { if (isObject(parent)) {
for (let v in parent) { for (let v in parent) {
let hidden = true let hidden = true
let child = parent[v]?.properties let child = parent[v]?.properties
let childObj = {} let childObj = {}
if (isObject(child)) { if (isObject(child)) {
for (let s in child) { for (let s in child) {
...@@ -80,6 +91,15 @@ const XRender = (props, ref) => { ...@@ -80,6 +91,15 @@ const XRender = (props, ref) => {
if (child[s].isDoing) { if (child[s].isDoing) {
array.push(s) 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] = { childObj[s] = {
...child[s], ...child[s],
title: ['RelationForm', 'AreaTask'].includes(child[s].widget) ? '' : child[s].title, 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 FieldNames from './FieldNames'
import FollowFieldHide from './FollowFieldHide'
import Placeholder from './Placeholder' import Placeholder from './Placeholder'
import PresetValueFileUpload from './PresetValueFileUpload' import PresetValueFileUpload from './PresetValueFileUpload'
import InputDefault from './InputDefault' import InputDefault from './InputDefault'
...@@ -28,6 +29,7 @@ const groupBase = { ...@@ -28,6 +29,7 @@ const groupBase = {
RichTextDefault, RichTextDefault,
IsHidden, IsHidden,
IsText, IsText,
FollowFieldHide
} }
export default groupBase export default groupBase
\ No newline at end of file
...@@ -7,7 +7,7 @@ const TextHTML = (props) => { ...@@ -7,7 +7,7 @@ const TextHTML = (props) => {
if (isText) { if (isText) {
return ( 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