Commit 5fca5b48 authored by 田翔's avatar 田翔

fix: 代码更新

parent bfbfffee
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "4.9.9", "version": "5.0.0",
"description": "4.9.9 隐藏条件修复", "description": "5.0.0 初始调用隐藏规则",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -12,6 +12,8 @@ import { isObject } from '../../utils' ...@@ -12,6 +12,8 @@ import { isObject } from '../../utils'
import { getWatch } from './watch' import { getWatch } from './watch'
import styles from '../../main.less' import styles from '../../main.less'
let watchFns = {}
const XRender = (props, ref) => { const XRender = (props, ref) => {
useImperativeHandle(ref, () => ( useImperativeHandle(ref, () => (
...@@ -27,7 +29,7 @@ const XRender = (props, ref) => { ...@@ -27,7 +29,7 @@ const XRender = (props, ref) => {
const { formJson, values } = schemaValues const { formJson, values } = schemaValues
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext) const { getPrefixCls } = useContext(ConfigProvider.ConfigContext)
const pandaXform = getPrefixCls() const pandaXform = getPrefixCls()
const [startTime, setStartTime] = useState(new Date().getTime()) const startTime = useState(new Date().getTime())
const [initField, setInitField] = useState([]) const [initField, setInitField] = useState([])
const form = useForm() const form = useForm()
...@@ -89,7 +91,8 @@ const XRender = (props, ref) => { ...@@ -89,7 +91,8 @@ const XRender = (props, ref) => {
}, [formJson, values, disabledFields, disabled]) }, [formJson, values, disabledFields, disabled])
const watch = useMemo(() => { const watch = useMemo(() => {
return getWatch({ schema: schemaForm, form, startTime, initField }) watchFns = getWatch({ schema: schemaForm, form, startTime, initField })
return watchFns
}, [schemaForm, form, startTime, initField]) }, [schemaForm, form, startTime, initField])
const getValues = async () => { const getValues = async () => {
...@@ -111,10 +114,13 @@ const XRender = (props, ref) => { ...@@ -111,10 +114,13 @@ const XRender = (props, ref) => {
//初始化时存储外部传的额外数据 //初始化时存储外部传的额外数据
const onMount = () => { const onMount = () => {
// setTimeout(() => { setTimeout(() => {
// setLoading(false) if (isObject(watchFns)) {
// }, 500) for (let key in watchFns) {
// form.setValueByPath('extraData', extraData || { codes: { '事件编号': '12312' } }) watchFns?.[key]()
}
}
}, 1500)
} }
return ( return (
......
...@@ -207,7 +207,6 @@ const getAutoWatch = ({ schema, form, startTime, initField }) => { ...@@ -207,7 +207,6 @@ const getAutoWatch = ({ schema, form, startTime, initField }) => {
let watch = {} let watch = {}
let paths = [] let paths = []
let formValue = form?.getValues() let formValue = form?.getValues()
console.log('form?.getValues()', form?.getValues(), form)
let { relationForm } = formValue let { relationForm } = formValue
const configs = relationForm?.configs || [] const configs = relationForm?.configs || []
const AutoCalculate = getWidgetInfo(schema, 'NumberInput') const AutoCalculate = getWidgetInfo(schema, 'NumberInput')
...@@ -260,7 +259,6 @@ const getAutoWatch = ({ schema, form, startTime, initField }) => { ...@@ -260,7 +259,6 @@ const getAutoWatch = ({ schema, form, startTime, initField }) => {
} }
}) })
} }
console.log('paths', paths)
if (Array.isArray(paths)) { if (Array.isArray(paths)) {
paths.forEach(v => { paths.forEach(v => {
watch[v.path] = () => { watch[v.path] = () => {
...@@ -284,7 +282,6 @@ const getAutoWatch = ({ schema, form, startTime, initField }) => { ...@@ -284,7 +282,6 @@ const getAutoWatch = ({ schema, form, startTime, initField }) => {
} }
}) })
} }
console.log('watch', watch)
return watch return watch
} }
......
...@@ -21,11 +21,10 @@ const RichTextDefault = (props, ref) => { ...@@ -21,11 +21,10 @@ const RichTextDefault = (props, ref) => {
const [editor, setEditor] = useState(null) const [editor, setEditor] = useState(null)
const editorChange = (editor) => { const editorChange = (editor) => {
setText(editor.getHtml()) setText(editor?.getHtml())
} }
const iconClick = () => { const iconClick = () => {
setText(value)
setVisible(true) setVisible(true)
} }
...@@ -36,9 +35,10 @@ const RichTextDefault = (props, ref) => { ...@@ -36,9 +35,10 @@ const RichTextDefault = (props, ref) => {
useEffect(() => { useEffect(() => {
return () => { return () => {
if (editor == null) return if (editor !== null) {
editor.destroy() editor.destroy()
setEditor(null) setEditor(null)
}
} }
}, [editor]) }, [editor])
...@@ -51,6 +51,7 @@ const RichTextDefault = (props, ref) => { ...@@ -51,6 +51,7 @@ const RichTextDefault = (props, ref) => {
onCancel={() => setVisible(false)} onCancel={() => setVisible(false)}
visible={visible} visible={visible}
onOk={onOk} onOk={onOk}
destroyOnClose
> >
<div className={styles.richText}> <div className={styles.richText}>
<Toolbar <Toolbar
...@@ -80,7 +81,7 @@ const RichTextDefault = (props, ref) => { ...@@ -80,7 +81,7 @@ const RichTextDefault = (props, ref) => {
} }
} }
}} }}
value={text} value={value}
onCreated={setEditor} onCreated={setEditor}
onChange={editorChange} onChange={editorChange}
mode="default" mode="default"
......
...@@ -23,7 +23,6 @@ const debounce = (fn) => { ...@@ -23,7 +23,6 @@ const debounce = (fn) => {
const TextInput = (props) => { const TextInput = (props) => {
console.log('props', props)
const preview = sessionStorage.getItem('FormRender') const preview = sessionStorage.getItem('FormRender')
const userInfo = preview === 'preview' ? { fullName: '【本人姓名】', depart: { name: '【本人部门】' } } : window?.globalConfig?.userInfo || { fullName: '【本人姓名】', depart: { name: '【本人部门】' } } const userInfo = preview === 'preview' ? { fullName: '【本人姓名】', depart: { name: '【本人部门】' } } : window?.globalConfig?.userInfo || { fullName: '【本人姓名】', depart: { name: '【本人部门】' } }
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
......
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