Skip to content

Commit

Permalink
fix: 修复场景联动-消息通知-内置参数无效问题
Browse files Browse the repository at this point in the history
* fix: bug#10264、10420、10476、10913

* fix: 修复场景联动-消息通知-内置参数无效问题

* fix: bug#9892
  • Loading branch information
XieYongHong authored Apr 25, 2023
1 parent 4017687 commit 90ee84c
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 19 deletions.
6 changes: 4 additions & 2 deletions src/components/FMonacoEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { connect, mapProps } from '@formily/react';
import { useCallback, useEffect, useRef, useState } from 'react';
import type { MonacoEditorProps } from 'react-monaco-editor/lib/types';

interface Props extends MonacoEditorProps {}
interface Props extends MonacoEditorProps {
warpStyle?: any
}

export const JMonacoEditor = (props: Props) => {
const [loading, setLoading] = useState(false);
Expand Down Expand Up @@ -36,7 +38,7 @@ export const JMonacoEditor = (props: Props) => {
setLoading(true);
}, 100);
}}
style={{ height: '100%', width: '100%' }}
style={{ height: '100%', width: '100%', ...(props.warpStyle || {}) }}
>
{loading && (
<MonacoEditor
Expand Down
6 changes: 3 additions & 3 deletions src/pages/notice/Config/Detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,8 @@ const Detail = observer(() => {
return (
<PageContainer>
<Card>
<Row>
<Col span={10}>
<Row gutter={24}>
<Col span={12}>
<Form className={styles.form} form={form} layout={'vertical'}>
<SchemaField scope={{ useAsyncDataSource, getTypes }} schema={schema} />
<FormButtonGroup.Sticky>
Expand All @@ -823,7 +823,7 @@ const Detail = observer(() => {
</FormButtonGroup.Sticky>
</Form>
</Col>
<Col span={12} push={2}>
<Col span={12}>
{docMap?.[typeItem]?.[providerItem]}
</Col>
</Row>
Expand Down
9 changes: 6 additions & 3 deletions src/pages/notice/Template/Detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,9 @@ const Detail = observer(() => {
height: 250,
theme: 'vs',
language: 'json',
warpStyle: {
border: "1px solid #d9d9d9"
},
editorDidMount: (editor1: any) => {
editor1.onDidScrollChange?.(() => {
editor1.getAction('editor.action.formatDocument').run();
Expand Down Expand Up @@ -1755,8 +1758,8 @@ const Detail = observer(() => {
return (
<PageContainer>
<Card>
<Row>
<Col span={10}>
<Row gutter={24}>
<Col span={12}>
<Form className={styles.form} form={form} layout={'vertical'}>
<SchemaField
schema={schema}
Expand Down Expand Up @@ -1789,7 +1792,7 @@ const Detail = observer(() => {
</FormButtonGroup.Sticky>
</Form>
</Col>
<Col span={12} push={2}>
<Col span={12}>
{docMap?.[typeItem]?.[providerItem]}
</Col>
</Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,28 @@ import Org from './components/variableItem/org';
import Tag from './components/variableItem/tag';
import BuildIn from './components/variableItem/buildIn';
import InputFile from './components/variableItem/inputFile';
import { forwardRef, useCallback, useImperativeHandle } from 'react';
import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
import {cloneDeep} from "lodash";

interface Props {
name: number;
value?: any;
options?: Record<string, any>
optionsChange?: (v: Array<string | undefined>) => void
}

export default forwardRef((props: Props, ref) => {
const [form] = Form.useForm();
const typeComponents = (item: any) => {
const options = useRef<Array<string | undefined>>(props.options?.otherColumns || [])

const optionsChange = (v: string | undefined, index: number) => {
options.current[index] = v
props.optionsChange?.([...options.current])
}

const typeComponents = (item: any, index: number) => {
const type = item.expands?.businessType || item.type;
options.current[index] = undefined
switch (type) {
case 'user':
return <User />;
Expand All @@ -29,7 +40,9 @@ export default forwardRef((props: Props, ref) => {
case 'link':
return <Input placeholder={'请输入' + item.name} />;
default:
return <BuildIn data={item} name={props.name} />;
return <BuildIn data={item} name={props.name} optionsChange={(v) => {
optionsChange(v, index)
}} />;
}
};

Expand Down Expand Up @@ -141,13 +154,13 @@ export default forwardRef((props: Props, ref) => {
};

useImperativeHandle(ref, () => ({
save: saveBtn,
save: saveBtn
}));

return NotifyModel.variable.length ? (
<div>
<Form form={form} layout={'vertical'}>
{(NotifyModel?.variable || []).map((item) => {
{(NotifyModel?.variable || []).map((item, index) => {
const type = item.expands?.businessType || item?.type;
let initialValue = undefined;
const rules = getRules(item, type);
Expand Down Expand Up @@ -188,7 +201,7 @@ export default forwardRef((props: Props, ref) => {
required={type !== 'file' ? true : false}
rules={rules}
>
{typeComponents(item)}
{typeComponents(item, index)}
</Form.Item>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface BuiltInProps {
value?: ChangeType;
data?: any;
onChange?: (value: ChangeType) => void;
optionsChange?: (value?: string) => void
name: number;
}

Expand All @@ -26,7 +27,7 @@ export default (props: BuiltInProps) => {

const [builtInList, setBuiltInList] = useState<any[]>([]);

const onChange = (_source: string = 'fixed', _value?: any, _upperKey?: string) => {
const onChange = (_source: string = 'fixed', _value?: any, _upperKey?: string, options?: string) => {
const obj: ChangeType = {
source: _source,
};
Expand All @@ -39,6 +40,8 @@ export default (props: BuiltInProps) => {
if (props.onChange) {
props.onChange(obj);
}
props.optionsChange?.(options)

};

// const treeDataChildrenFilter: any = (arr: any[], type: string) => {
Expand Down Expand Up @@ -121,8 +124,10 @@ export default (props: BuiltInProps) => {
<TreeSelect
value={upperKey}
treeData={builtInList}
onChange={(key) => {
onChange(source, undefined, key);
onChange={(key, extra) => {
const item = extra?.[0]?.props
let option = item?.metadata ? item.column : undefined
onChange(source, undefined, key, option);
}}
fieldNames={{ label: 'name', value: 'id' }}
placeholder={'请选择参数'}
Expand Down
9 changes: 8 additions & 1 deletion src/pages/rule-engine/Scene/Save/action/notify/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const NotifyModel = model<{
export default observer((props: Props) => {
const WayRef = useRef<{ save: any }>();
const VariableRef = useRef<{ save: any }>();
const otherColumns = useRef<Array<string | undefined>>([])

useEffect(() => {
NotifyModel.notify = {
Expand All @@ -82,7 +83,11 @@ export default observer((props: Props) => {
<VariableDefinitions
value={NotifyModel.notify.variables}
name={props.name}
options={props.options}
ref={VariableRef}
optionsChange={(v) => {
otherColumns.current = v
}}
/>
);
default:
Expand Down Expand Up @@ -134,7 +139,9 @@ export default observer((props: Props) => {
const resp = await VariableRef.current?.save();
if (resp) {
NotifyModel.notify.variables = resp;
const { options, ...extra } = NotifyModel.notify;
let { options, ...extra } = NotifyModel.notify;
const columns = new Set([...(options?.columns || []), ...otherColumns.current.filter(item => item)])
Object.assign(options, {columns: [...columns.values()], otherColumns: otherColumns.current})
props.save(
{
notify: { ...extra },
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16591,7 +16591,7 @@ reserved-words@^0.1.2:

resize-observer-polyfill@^1.5.0:
version "1.5.1"
resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"
resolved "https://registry.npmmirror.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"
integrity sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==

resize-observer-polyfill@^1.5.1:
Expand Down

0 comments on commit 90ee84c

Please sign in to comment.