Showing
4 changed files
with
110 additions
and
73 deletions
@@ -4,6 +4,7 @@ export * from './qx-sort-condition'; | @@ -4,6 +4,7 @@ export * from './qx-sort-condition'; | ||
4 | export * from './qx-base-icon'; | 4 | export * from './qx-base-icon'; |
5 | export * from './qx-tags-input'; | 5 | export * from './qx-tags-input'; |
6 | export * from './qx-user-selector'; | 6 | export * from './qx-user-selector'; |
7 | +export * from './qx-org-selector'; | ||
7 | export * from './qx-form-select'; | 8 | export * from './qx-form-select'; |
8 | export * from './qx-app-selector'; | 9 | export * from './qx-app-selector'; |
9 | export * from './utils'; | 10 | export * from './utils'; |
@@ -4,18 +4,13 @@ import { useEffect, useState } from 'react'; | @@ -4,18 +4,13 @@ import { useEffect, useState } from 'react'; | ||
4 | import type { OptionField, WidgetField } from '../type'; | 4 | import type { OptionField, WidgetField } from '../type'; |
5 | import { getUsefulFieldProp } from '../util'; | 5 | import { getUsefulFieldProp } from '../util'; |
6 | import { QxFieldItem } from '@qx/common'; | 6 | import { QxFieldItem } from '@qx/common'; |
7 | -import { useLocation } from 'react-router'; | ||
8 | import { getFieldOptions } from '../../service'; | 7 | import { getFieldOptions } from '../../service'; |
9 | import './style.less'; | 8 | import './style.less'; |
10 | 9 | ||
11 | const QxFieldSelect: React.FC = (props: any) => { | 10 | const QxFieldSelect: React.FC = (props: any) => { |
11 | + const {appCode, funCode, schema} = props | ||
12 | const [fields, setFields] = useState<WidgetField[] | OptionField[]>([]); | 12 | const [fields, setFields] = useState<WidgetField[] | OptionField[]>([]); |
13 | - const schemaProps = props.schema.props; | ||
14 | - // @ts-ignore | ||
15 | - const {query} = useLocation(); | ||
16 | - | ||
17 | - const appCode = query?.appCode|| props?.appCode || '8yo7v'; | ||
18 | - const funCode = query?.funCode|| props?.funCode ||'2eg66'; | 13 | + const schemaProps = schema?.props; |
19 | const includeFields = (list: WidgetField[] | OptionField[]) => { | 14 | const includeFields = (list: WidgetField[] | OptionField[]) => { |
20 | // console.log(list,schemaProps.viewable); | 15 | // console.log(list,schemaProps.viewable); |
21 | // @ts-ignore | 16 | // @ts-ignore |
src/qx-org-selector/index.md
0 → 100644
1 | +### 选部门组件 | ||
2 | + | ||
3 | +```tsx | ||
4 | +/** | ||
5 | + * debug: true | ||
6 | + */ | ||
7 | +import { QxOrgSelector } from '@qx/common'; | ||
8 | +import React from 'react'; | ||
9 | +import { request } from '@qx/common'; | ||
10 | + | ||
11 | +export default () => { | ||
12 | + return ( | ||
13 | + <div> | ||
14 | + <QxOrgSelector request={request} /> | ||
15 | + </div> | ||
16 | + ); | ||
17 | +}; | ||
18 | +``` | ||
19 | + | ||
20 | +### 弹框 | ||
21 | + | ||
22 | +```tsx | ||
23 | +import {QxOrgSelector} from '@qx/common'; | ||
24 | +import React, {useState} from 'react'; | ||
25 | +import {request} from '@qx/common'; | ||
26 | + | ||
27 | +export default () => { | ||
28 | + const [visible, setVisible] = useState(false) | ||
29 | + return ( | ||
30 | + <div> | ||
31 | + <div onClick={()=> setVisible(true)}>点一下</div> | ||
32 | + <QxOrgSelector.Dialog | ||
33 | + request={request} | ||
34 | + checkStrictly | ||
35 | + title={'添加部门'} | ||
36 | + visible={visible} | ||
37 | + multiple={true} | ||
38 | + onOk={(orgIds: any) => { | ||
39 | + console.log(orgIds,'lllll') | ||
40 | + }} | ||
41 | + onCancel={() => { | ||
42 | + setVisible(false); | ||
43 | + }} | ||
44 | + /> | ||
45 | + </div> | ||
46 | + ); | ||
47 | +}; | ||
48 | +``` | ||
49 | + | ||
50 | +## API | ||
51 | + | ||
52 | +| 参数 | 说明 | 类型 | 默认值 | | ||
53 | +| ------------ | ------------------------ | ------------------ | ------ | | ||
54 | +| onChange | 选的人变化时的回调 | function(value) | - | | ||
55 | +| defaultValue | 默认值 | string[] | - | | ||
56 | +| disabled | 禁用 | bool | - | | ||
57 | +| multiple | 是否多选 | bool | - | | ||
58 | +| max | 最多选几个,ps:没有控制 | number | - | | ||
59 | +| readOnly | 只读 | bool | - | | ||
60 | +| value | | string[] \| string | | |
@@ -6,77 +6,26 @@ | @@ -6,77 +6,26 @@ | ||
6 | */ | 6 | */ |
7 | import { QxUserSelector } from '@qx/common'; | 7 | import { QxUserSelector } from '@qx/common'; |
8 | import React from 'react'; | 8 | import React from 'react'; |
9 | -import request from 'umi-request'; | ||
10 | - | ||
11 | -request.interceptors.request.use((url, options) => { | ||
12 | - if (url.startsWith('/api/')) { | ||
13 | - return { url, options }; | ||
14 | - } | ||
15 | - const headers = { Authorization: 'dev_session:ZGuqjkCF3GMzorijXw7' }; | ||
16 | - // headers['SERVER-IP'] = '192.168.181.112'; | ||
17 | - | ||
18 | - const fullUrl = url.startsWith('http') | ||
19 | - ? url | ||
20 | - : `http://10.9.1.180/qx-api${url}`; | ||
21 | - return { | ||
22 | - url: fullUrl, | ||
23 | - options: { | ||
24 | - ...options, | ||
25 | - ...{ | ||
26 | - headers: { ...headers, ...(options.customHeaders || {}) }, | ||
27 | - isInternal: true, | ||
28 | - timeout: 30000, | ||
29 | - }, | ||
30 | - }, | ||
31 | - }; | ||
32 | -}); | ||
33 | - | ||
34 | -request.interceptors.response.use(async (response, options) => { | ||
35 | - if (response.status !== 200) { | ||
36 | - return Promise.reject(response); | ||
37 | - } | ||
38 | - | ||
39 | - if (!response.headers.get('content-type')?.includes('application/json')) { | ||
40 | - return response.blob(); | ||
41 | - } | ||
42 | - | ||
43 | - const body = await response.clone().json(); | ||
44 | - | ||
45 | - // 按正常逻辑处理"文件上传"系列接口 | ||
46 | - const fsUploadApis = ['/file/checkFile', '/file/uploadByExist', '/fss/file/']; | ||
47 | - const isFsUploadApis = fsUploadApis.filter( | ||
48 | - (api: string) => options.url.indexOf(api) !== -1, | ||
49 | - ); | ||
50 | - if (isFsUploadApis.length > 0) { | ||
51 | - return Promise.resolve(body || null); | ||
52 | - } | ||
53 | - | ||
54 | - if (body.success) { | ||
55 | - return Promise.resolve(body.data || null); | ||
56 | - } | ||
57 | - | ||
58 | - console.error('网络请求出错:', body.msg); | ||
59 | - | ||
60 | - return Promise.reject(body); | ||
61 | -}); | 9 | +import { request } from '@qx/common'; |
62 | 10 | ||
63 | export default () => { | 11 | export default () => { |
64 | return ( | 12 | return ( |
65 | <div> | 13 | <div> |
66 | - <QxUserSelector | ||
67 | - request={request} | ||
68 | - params={{ | ||
69 | - org: [{ relType: 'APPOINT_ORG', relIds: [''] }], | ||
70 | - pos: null, | ||
71 | - range: [ | ||
72 | - 'ORG:MubDrwZm8IMxuLDU9FM', | ||
73 | - 'ORG:a0WZVI96GAdoI5g9IwX', | ||
74 | - 'ORG:QPLEku2yJU8hmbpLTtg', | ||
75 | - ], | ||
76 | - }} | ||
77 | - /> | 14 | + <QxUserSelector request={request} /> |
15 | + | ||
78 | <br /> | 16 | <br /> |
79 | - <QxUserSelector request={request} /> | 17 | + <QxUserSelector |
18 | + request={request} | ||
19 | + params={{ | ||
20 | + org: [{ relType: 'APPOINT_ORG', relIds: [''] }], | ||
21 | + pos: null, | ||
22 | + range: [ | ||
23 | + 'ORG:MubDrwZm8IMxuLDU9FM', | ||
24 | + 'ORG:a0WZVI96GAdoI5g9IwX', | ||
25 | + 'ORG:QPLEku2yJU8hmbpLTtg', | ||
26 | + ], | ||
27 | + }} | ||
28 | + /> | ||
80 | <br /> | 29 | <br /> |
81 | <QxUserSelector | 30 | <QxUserSelector |
82 | readOnly | 31 | readOnly |
@@ -89,6 +38,38 @@ export default () => { | @@ -89,6 +38,38 @@ export default () => { | ||
89 | }; | 38 | }; |
90 | ``` | 39 | ``` |
91 | 40 | ||
41 | +### 弹框 | ||
42 | + | ||
43 | +```tsx | ||
44 | +/** | ||
45 | + * debug: true | ||
46 | + */ | ||
47 | +import {QxUserSelector} from '@qx/common'; | ||
48 | +import React, {useState} from 'react'; | ||
49 | +import {request} from '@qx/common'; | ||
50 | + | ||
51 | +export default () => { | ||
52 | + const [visible, setVisible] = useState(false) | ||
53 | + return ( | ||
54 | + <div> | ||
55 | + <div onClick={()=> setVisible(true)}>点一下</div> | ||
56 | + <QxUserSelector.Dialog | ||
57 | + request={request} | ||
58 | + title={'添加人员'} | ||
59 | + visible={visible} | ||
60 | + multiple={true} | ||
61 | + onOk={(userIds: any) => { | ||
62 | + console.log(userIds,'lllll') | ||
63 | + }} | ||
64 | + onCancel={() => { | ||
65 | + setVisible(false); | ||
66 | + }} | ||
67 | + /> | ||
68 | + </div> | ||
69 | + ); | ||
70 | +}; | ||
71 | +``` | ||
72 | + | ||
92 | ## API | 73 | ## API |
93 | 74 | ||
94 | | 参数 | 说明 | 类型 | 默认值 | | 75 | | 参数 | 说明 | 类型 | 默认值 | |