...
|
...
|
@@ -2,19 +2,17 @@ import { BlockOutlined } from '@ant-design/icons'; |
2
|
2
|
import { useSetState } from 'ahooks';
|
3
|
3
|
import { Button } from 'antd';
|
4
|
4
|
import cls from 'classnames';
|
5
|
|
-import React, { useCallback, useRef } from 'react';
|
|
5
|
+import React, {useCallback, useEffect, useRef, useState} from 'react';
|
6
|
6
|
import { QxAppSelector } from '../qx-app-selector';
|
7
|
7
|
import type { InputSelectProps } from '../qx-input-select';
|
8
|
8
|
import { QxInputSelect } from '../qx-input-select';
|
9
|
9
|
|
10
|
10
|
import './styles.less';
|
|
11
|
+import {getAppFromList} from "./service";
|
11
|
12
|
|
12
|
13
|
const prefix = 'qx-form-select';
|
13
|
14
|
|
14
|
|
-/**
|
15
|
|
- * 选择数据源
|
16
|
|
- */
|
17
|
|
-export const QxFormSelect: React.FC<FormSelectProps> = (props) => {
|
|
15
|
+const FormSelectMain: React.FC<FormSelectProps>= (props)=> {
|
18
|
16
|
const {
|
19
|
17
|
className,
|
20
|
18
|
options = [],
|
...
|
...
|
@@ -106,6 +104,33 @@ export const QxFormSelect: React.FC<FormSelectProps> = (props) => { |
106
|
104
|
) : null}
|
107
|
105
|
</div>
|
108
|
106
|
);
|
|
107
|
+}
|
|
108
|
+
|
|
109
|
+/**
|
|
110
|
+ * 选择数据源
|
|
111
|
+ */
|
|
112
|
+export const QxFormSelect: React.FC<FormSelectProps> = (props) => {
|
|
113
|
+ const { options= [] as any , optionId } = props;
|
|
114
|
+ const [selectOptions, setSelectOptions] = useState([])
|
|
115
|
+
|
|
116
|
+ useEffect(() => {
|
|
117
|
+ console.log(optionId,'llllloptions')
|
|
118
|
+ if(optionId && !options?.length) {
|
|
119
|
+ getAppFromList(optionId).then((res: any)=> {
|
|
120
|
+ if(res?.length){
|
|
121
|
+ setSelectOptions(res)
|
|
122
|
+ } else {
|
|
123
|
+ setSelectOptions([])
|
|
124
|
+ }
|
|
125
|
+ }).catch(()=> {
|
|
126
|
+ setSelectOptions([])
|
|
127
|
+ })
|
|
128
|
+ } else {
|
|
129
|
+ setSelectOptions(options)
|
|
130
|
+ }
|
|
131
|
+ }, []);
|
|
132
|
+
|
|
133
|
+ return <FormSelectMain {...props} options={selectOptions}/>
|
109
|
134
|
};
|
110
|
135
|
|
111
|
136
|
interface FormSelectProps extends InputSelectProps {
|
...
|
...
|
@@ -115,6 +140,7 @@ interface FormSelectProps extends InputSelectProps { |
115
|
140
|
request?: any;
|
116
|
141
|
disabled?: boolean;
|
117
|
142
|
popupOnBody?: boolean;
|
|
143
|
+ optionId?: string; // 获取options传入表单的appId
|
118
|
144
|
}
|
119
|
145
|
interface FormSelectState {
|
120
|
146
|
visible: boolean;
|
...
|
...
|
|