kn-cli 1.0.60 → 1.0.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/build/build.sh +1 -1
  2. package/build/dev.sh +1 -1
  3. package/package.json +1 -1
  4. package/readme.md +9 -0
  5. package/src/build.js +28 -9
  6. package/templates/template_admin/build.sh +7 -1
  7. package/templates/template_admin/readme.md +8 -0
  8. package/templates/template_app/build.sh +7 -1
  9. package/templates/template_app/readme.md +8 -0
  10. package/templates/template_oa/build.sh +7 -1
  11. package/templates/template_oa/frontend_build.sh +1 -2
  12. package/templates/template_oa/package.json +2 -1
  13. package/templates/template_oa/public/favicon.ico +0 -0
  14. package/templates/template_oa/public/index.html +1 -1
  15. package/templates/template_oa/public/src/_antd.less +0 -21
  16. package/templates/template_oa/public/src/_reset.less +3 -0
  17. package/templates/template_oa/public/src/_variable.less +1 -1
  18. package/templates/template_oa/public/src/assets/images/NY-pop-bg.png +0 -0
  19. package/templates/template_oa/public/src/components/Auth/index.jsx +1 -1
  20. package/templates/template_oa/public/src/components/Dialog/index.jsx +150 -0
  21. package/templates/template_oa/public/src/components/Dialog/index.less +123 -0
  22. package/templates/template_oa/public/src/components/Empty/index.jsx +23 -0
  23. package/templates/template_oa/public/src/components/Empty/index.less +6 -0
  24. package/templates/template_oa/public/src/components/FormRow/index.jsx +39 -0
  25. package/templates/template_oa/public/src/components/FormRow/index.less +67 -0
  26. package/templates/template_oa/public/src/components/FormTable/index.jsx +136 -0
  27. package/templates/template_oa/public/src/components/IFrame/index.less +1 -1
  28. package/templates/template_oa/public/src/components/Layout/Basic/index.jsx +18 -12
  29. package/templates/template_oa/public/src/components/Layout/Basic/index.less +21 -11
  30. package/templates/template_oa/public/src/components/Layout/index.jsx +2 -1
  31. package/templates/template_oa/public/src/components/Nav/index.jsx +163 -100
  32. package/templates/template_oa/public/src/components/Select/DepSelect/index.jsx +47 -0
  33. package/templates/template_oa/public/src/components/Select/StaffSelect/index.jsx +97 -0
  34. package/templates/template_oa/public/src/components/Select/StaffSelect/index.less +24 -0
  35. package/templates/template_oa/public/src/components/Toast/index.less +1 -1
  36. package/templates/template_oa/public/src/components/Upload/index.jsx +358 -0
  37. package/templates/template_oa/public/src/components/title/index.jsx +12 -0
  38. package/templates/template_oa/public/src/components/title/index.less +21 -0
  39. package/templates/template_oa/public/src/mock/cases.js +52 -0
  40. package/templates/template_oa/public/src/mock/index.js +2 -0
  41. package/templates/template_oa/public/src/pages/components/totalRecord/index.jsx +21 -0
  42. package/templates/template_oa/public/src/pages/components/totalRecord/index.less +16 -0
  43. package/templates/template_oa/public/src/pages/login/index.jsx +7 -9
  44. package/templates/template_oa/public/src/pages/my/index.jsx +14 -0
  45. package/templates/template_oa/public/src/pages/video/detail/index.jsx +14 -0
  46. package/templates/template_oa/public/src/pages/video/index.jsx +325 -23
  47. package/templates/template_oa/public/src/pages/video/index.less +3 -0
  48. package/templates/template_oa/public/src/provider/app.jsx +14 -81
  49. package/templates/template_oa/public/src/route.jsx +8 -2
  50. package/templates/template_oa/public/src/services/cases.js +7 -0
  51. package/templates/template_oa/public/src/services/common.js +132 -0
  52. package/templates/template_oa/public/src/services/index.js +42 -8
  53. package/templates/template_oa/public/src/services/video.js +1 -0
  54. package/templates/template_oa/public/src/utils/index.js +61 -1
  55. package/templates/template_oa/readme.md +8 -0
  56. package/templates/template_oa/webpack.api.js +10 -22
  57. package/templates/template_offcial/build.sh +7 -1
  58. package/templates/template_offcial/readme.md +8 -0
  59. package/templates/template_oa/public/favicon.png +0 -0
  60. package/templates/template_oa/public/src/components/mask/index.jsx +0 -47
  61. package/templates/template_oa/public/src/components/mask/index.less +0 -32
  62. package/templates/template_oa/public/src/dictionary/index.js +0 -39
  63. package/templates/template_oa/public/src/provider/menu.jsx +0 -20
  64. package/templates/template_oa/public/src/services/user.js +0 -26
@@ -0,0 +1,67 @@
1
+ // @import '@/_reset.scss';
2
+
3
+ .formRow {
4
+ border: 1px solid #eaeaea;
5
+ & > hgroup {
6
+ max-width: 100%;
7
+ height: 100%;
8
+ }
9
+ //防止超长不换行
10
+ .ant-checkbox-group,
11
+ .ant-radio-group {
12
+ display: flex;
13
+ flex-wrap: wrap;
14
+ }
15
+ .row{
16
+ display: flex;
17
+ align-items: center;
18
+ }
19
+ }
20
+
21
+ .formRowBody{
22
+ display: flex;
23
+ }
24
+ .formRowBody:not(:first-child) {
25
+ .formRow {
26
+ border-top: 0;
27
+ }
28
+ }
29
+ .formRow:not(:first-child) {
30
+ width: 50%;
31
+ border-left: 0;
32
+ & > hgroup {
33
+ width: 2000px;
34
+ }
35
+ }
36
+ .formRow:first-child {
37
+ flex-grow:1;
38
+ }
39
+
40
+ .title {
41
+ display: flex;
42
+ align-items: center;
43
+
44
+ background-color: #f8f8f8;
45
+ color: #666;
46
+ padding: 7px 30px;
47
+ height: 100%;
48
+ font-size: 14px;
49
+ & > div {
50
+ position: relative;
51
+ font-size: inherit;
52
+ width: 130px;
53
+ font-weight: 400;
54
+ &[required]:before {
55
+ font-size: 12px;
56
+ content: '*';
57
+ color: #f04134;
58
+ position: absolute;
59
+ left: -10px;
60
+ }
61
+ }
62
+ }
63
+ .data {
64
+ padding: 3px 9px;
65
+ flex:1;
66
+ flex-wrap: wrap;
67
+ }
@@ -0,0 +1,136 @@
1
+ import React ,{useImperativeHandle,useState,forwardRef} from 'react';
2
+ import uuid from 'js-uuid';
3
+
4
+ const TableFormItem =(props,ref)=> {
5
+ const {Table,form,formItemName,saveLast} = props;
6
+ const getNewId=()=>{
7
+ let ret = uuid.v4();
8
+ return ret;
9
+ }
10
+
11
+ const getInitalValue=(initialValue)=>{
12
+ let tempInitValue=[];
13
+ if(initialValue){
14
+ tempInitValue=initialValue.map((item,idx)=>{
15
+ item._rowKey=getNewId();
16
+ return item;
17
+ });
18
+ }
19
+ return tempInitValue
20
+ }
21
+ const [value,setValue] = useState(()=>(getInitalValue(props.initialValue)));
22
+
23
+ const onChange = (value) => {
24
+ if (props.onChange) {
25
+ props.onChange(value);
26
+ }
27
+ if (props.onRefresh) {
28
+ props.onRefresh(value);
29
+ }
30
+ };
31
+
32
+
33
+ const onCopy=async (record, index, event)=> {
34
+ if (event) event.preventDefault();
35
+ const { getFieldValue } = form;
36
+ const formData = (getFieldValue(formItemName) || []);
37
+
38
+ let newdata = null;
39
+ if(props.onCopy){
40
+ newdata = props.onCopy(record,index);
41
+ if(!newdata)return;
42
+ }else{
43
+ newdata = { ...props.newdata };
44
+ }
45
+ newdata = {...formData[index]};
46
+ newdata._rowKey=getNewId();
47
+
48
+ let newFormData = onInsert(newdata,index);
49
+ onChange(newFormData);
50
+ }
51
+
52
+
53
+ const onDel = (record,index,event) => {
54
+ if (event) event.preventDefault();
55
+ const { getFieldValue, setFieldsValue } = form;
56
+
57
+ const formData = [...(getFieldValue(formItemName) || [])];
58
+ let isLast = formData.length === 1;
59
+ formData.splice(index,1);
60
+ setValue([]);
61
+ setFieldsValue({[formItemName]:[]});
62
+
63
+ setValue(formData);
64
+ setFieldsValue({[formItemName]:formData});
65
+
66
+ if (saveLast && isLast) {
67
+ onAdd(record, index, event)
68
+ } else {
69
+ onChange(formData);
70
+ }
71
+ };
72
+
73
+ const onReset=(initValue,event)=>{
74
+ if (event) event.preventDefault();
75
+ const {setFieldsValue } = form;
76
+ const {initialValue} = props;
77
+
78
+ initValue = initValue||initialValue;
79
+ initValue = getInitalValue(initValue);
80
+
81
+ setValue([]);
82
+ setFieldsValue({[formItemName]:[]})
83
+ setValue(initValue);
84
+ setFieldsValue({[formItemName]:[...initValue]});
85
+ }
86
+
87
+ const onInsert= (newdata,index)=>{
88
+ const { getFieldValue, setFieldsValue } = form;
89
+ const oldData = (getFieldValue(formItemName) || []);
90
+ let formData = [...oldData];
91
+ if(index>=0){
92
+ formData.splice(index+1,0,newdata);
93
+ }else{
94
+ formData.push(newdata);
95
+ }
96
+ setValue([]);
97
+ setFieldsValue({[formItemName]:[]})
98
+ setValue(formData);
99
+ setFieldsValue({[formItemName]:formData})
100
+ return formData;
101
+ }
102
+
103
+ const onAdd = (record, index , event) => {
104
+ if (event) event.preventDefault();
105
+
106
+ let newdata=null;
107
+ if(props.onAdd){
108
+ newdata = props.onAdd(record,index);
109
+ if(!newdata)return;
110
+ }else{
111
+ newdata = { ...props.newdata };
112
+ }
113
+ newdata._rowKey = getNewId();
114
+ let formData = onInsert(newdata,index);
115
+ onChange(formData);
116
+ };
117
+
118
+ useImperativeHandle(ref, () => ({
119
+ onReset,
120
+ }));
121
+
122
+
123
+ return (
124
+
125
+ <Table
126
+ {...{rowKey: '_rowKey',...props.antTableOptions}}
127
+ dataSource={value}
128
+ columns={props.columns({formItemName,onDel, onAdd,onReset,onCopy})}
129
+ />
130
+
131
+ )
132
+ }
133
+
134
+
135
+
136
+ export default forwardRef(TableFormItem);
@@ -1,4 +1,4 @@
1
1
 
2
2
  .iframeWrap{
3
- border:1px solid red;
3
+ // border:1px solid red;
4
4
  }
@@ -7,23 +7,29 @@ import styles from './index.less';
7
7
  const LayoutBasic=(props)=>{
8
8
  const {nav=""} = props;
9
9
  return (
10
- <section className={styles.windowWrap}>
10
+ <section className={styles.htmlWrap}>
11
11
  <Iframe name='header' url={OA_MENU_HOST} className={styles.iframeHeader} />
12
- <section className={styles.centerWrap}>
12
+ <section className={styles.headerSpace}></section>
13
13
 
14
- <div className={styles.crumbs}>
15
- <b>当前位置:</b>
16
- <span>服务</span>
17
- <span style={{ margin: '0 4px' }}>{'>'}</span>
18
- <a>{document.title}</a>
19
- </div>
20
- <section className={styles.content}>
21
- {nav}
22
- <section className={styles.body}>
23
- <Outlet />
14
+ <section className={styles.bodyWrap}>
15
+ <section className={styles.centerWrap}>
16
+ <div className={styles.crumbs}>
17
+ <b>当前位置:</b>
18
+ <span>法务部</span>
19
+ <span style={{ margin: '0 4px' }}>{'>'}</span>
20
+ <a>{document.title}</a>
21
+ </div>
22
+ <section className={styles.content}>
23
+ {nav}
24
+ <section className={styles.body}>
25
+ <Outlet />
26
+ </section>
24
27
  </section>
28
+ <section className={styles.footerSpace}></section>
29
+
25
30
  </section>
26
31
  </section>
32
+
27
33
  </section>
28
34
  )
29
35
  }
@@ -1,44 +1,54 @@
1
1
  @import '~@/_variable.less';
2
2
 
3
- .windowWrap{
3
+ .htmlWrap{
4
4
  width:100%;
5
5
  height:100%;
6
+ overflow: hidden;
7
+ display: block;
8
+ display: flex;
9
+ flex-direction: column;
10
+ }
11
+ .bodyWrap{
12
+ flex:1;
13
+ width: 100%;
6
14
  overflow: auto;
7
15
  overflow: scroll;
8
16
  -webkit-overflow-scrolling: touch;
9
- display: block;
10
- text-align: center;
11
17
  }
12
-
13
18
  .centerWrap {
14
19
  min-width: 1200px;
15
20
  max-width: 1600px;
16
21
  position: relative;
17
- display: inline-block;
22
+ margin: 0 auto;
23
+ padding: 0 20px;
18
24
  z-index:0;
19
- padding-bottom: var(--height-footer);
20
-
21
25
  }
22
-
26
+ .footerSpace{
27
+ width: 100%;
28
+ height:var(--height-footer);
29
+ }
23
30
  .iframeHeader{
24
31
  min-width: 100%;
25
32
  width: 1200px;
26
33
  height: var(--height-header);
27
34
  min-height: var(--height-header);
28
- position: sticky;
35
+ border:1px solid red;
36
+ position: fixed;
29
37
  left:0;
30
38
  top:0;
31
39
  z-index: 2;
32
40
  font-size: 60px;
33
41
  overflow: hidden;
34
- border:1px solid red;
42
+ }
43
+ .headerSpace{
44
+ width: 100%;
45
+ height: var(--height-header);
35
46
  }
36
47
 
37
48
  .crumbs{
38
49
  height: 36px;
39
50
  width: 100%;
40
51
  max-width: 1600px;
41
- padding:0 20px;
42
52
  font-size: 14px;
43
53
  color: #666;
44
54
  margin-bottom: 2px;
@@ -1,14 +1,15 @@
1
1
  import React from 'react';
2
2
  import ProviderApp from '@/provider/app';
3
3
 
4
+
4
5
  import {Outlet} from 'react-router-dom';
5
6
  import { ConfigProvider } from 'antd';
6
7
  import LayoutBasic from './Basic';
7
8
  import LayoutCenterBody from './CenterBody';
8
9
  import zhCN from 'antd/lib/locale/zh_CN';
9
10
 
10
-
11
11
  import styles from './index.less';
12
+ styles;
12
13
 
13
14
  // 站点最基础的layout,用于控制一些全局环境变量
14
15
  const Layout = (props) => {
@@ -1,121 +1,184 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import { Menu } from 'antd';
2
+ import React, { useEffect, useRef, useState } from 'react';
3
+ import {matchPath,useLocation,useNavigate,} from 'react-router-dom';
4
+ import { AppstoreOutlined, MailOutlined, SettingOutlined } from '@ant-design/icons';
5
+ import {useLoading} from '@/hooks';
2
6
 
3
- import { Menu, Spin } from 'antd';
4
- import {GET_LEFT_MENU} from '@/services/auth';
7
+ import styles from './index.less';
5
8
 
6
- import {
7
- SettingOutlined,
8
- HddOutlined,
9
- ProfileOutlined,
10
- FileTextOutlined,
11
- LineChartOutlined,
12
- FundViewOutlined,
13
- ProjectOutlined,
14
- } from '@ant-design/icons';
9
+ const ICON_NAME={
10
+ 'AppstoreOutlined':<AppstoreOutlined />,
11
+ 'MailOutlined':<MailOutlined />,
12
+ 'SettingOutlined':<SettingOutlined />,
13
+ }
15
14
 
16
- import styles from './index.less';
17
15
 
16
+ const SUB_MENU_CONFIG=[
17
+ {
18
+ path:'/video',//匹配菜单路由是/video的菜单
19
+ // routeTemplate:''匹配某个模板菜单的模板
20
+ subRoute:[
21
+ {
22
+ path:'/video/detail',//将video/detail这个路由匹配给菜单/video
23
+ // routeTemplate:''//也可以将某个路由模板匹配给某个菜单
24
+ }
25
+ ]
26
+ },
27
+ ]
18
28
 
29
+ const MenuRoute=[
30
+ {
31
+ label:'内容管理',
32
+ icon:'AppstoreOutlined',
33
+ children:[
34
+ {label:'剧集管理',path:'/video'},
35
+ ]
36
+ },
37
+ {
38
+ label:'用户中心',
39
+ icon:'CustomerServiceOutlined',
40
+ path:'/my'
41
+ },
42
+ ]
19
43
 
20
- export const LayoutByLeftNav = (props) => {
21
- const [loading, setLoading] = useState(true);
22
- const [menuInfo, setMenuInfo] = useState([]);
44
+ const LeftMenu=(props)=>{
23
45
 
24
- useEffect(() => {
25
- GET_LEFT_MENU().then((ret) => {
26
- setMenuInfo(ret.info);
27
- setLoading(false);
28
- });
29
- }, []);
46
+ const loader = useLoading();
47
+ const [menus,setMenus] = useState([]);
48
+ const [openKeys,setOpenKeys] = useState([]);
49
+ const [selectedKeys,setSelectKeys] = useState([]);
50
+ const curRoute = useLocation();
51
+ const nav = useNavigate();
30
52
 
31
- function btnMenu(e) {
32
- let link = e.item.props.link;
33
- location.href = link;
34
- }
53
+ const MENU_KEY_COUNTER=useRef(1);
54
+ const MENU_KEY=useRef({});
35
55
 
36
- function createMenu() {
37
- let openSubs = [];
38
- menuInfo.forEach((sub) => {
39
- if (sub.children && sub.children.length > 0) {
40
- // 强行就展开
41
- openSubs.push(sub.menu_name);
42
- // 如果当前选中的是子目录则展开父级目录
43
- // for (let i = 0; i < sub.children.length; i++) {
44
- // if (props.selected.includes(sub.children[i].menu_name)) {
45
- // openSubs.push(sub.menu_name);
46
- // break;
47
- // }
48
- // }
56
+ const getSubConfig=(menu)=>{
57
+ const {path,routeTemplate}= menu;
58
+ for(let i=0;i<SUB_MENU_CONFIG.length;i++){
59
+ let sub= SUB_MENU_CONFIG[i];
60
+ if(routeTemplate&&sub.routeTemplate&&routeTemplate==sub.routeTemplate){
61
+ return sub.subRoute;
49
62
  }
50
- });
51
-
52
- function getIcon(icon) {
53
- switch (icon) {
54
- case 'investproduct':
55
- return <LineChartOutlined />;
56
- case 'product':
57
- return <HddOutlined />;
58
- case 'manufacturer':
59
- return <ProfileOutlined />;
60
- case 'report':
61
- return <FileTextOutlined />;
62
- case 'system':
63
- return <SettingOutlined />;
64
- case 'ip_product':
65
- return <FundViewOutlined />;
66
- case 'ip_manage':
67
- return <ProjectOutlined />;
63
+ if(path&&sub.path&&path==sub.path){
64
+ return sub.subRoute;
68
65
  }
66
+ }
67
+ return null;
68
+ }
69
69
 
70
- return '';
70
+ const translateMenu=(data={},parent)=>{
71
+ const {label,icon,children,path}= data;
72
+ let myKey = `${MENU_KEY_COUNTER.current}`
73
+ let item ={
74
+ key:myKey,
75
+ label,
76
+ source:data,
77
+ path,
78
+ routepath:parent?`${parent.key}-${myKey}`:myKey
79
+ }
80
+ MENU_KEY.current[myKey] = item;
81
+ MENU_KEY_COUNTER.current++;
82
+ if(icon){
83
+ item.icon= ICON_NAME[icon];
71
84
  }
85
+ let subRoute= getSubConfig(data);
86
+ item.source.subRoute= subRoute;
87
+ if(children){
88
+ item.children = children.map(childData=>{
89
+ return translateMenu(childData,item)
90
+ })
91
+ }
92
+ return item;
93
+ }
72
94
 
73
- return (
74
- <section>
75
- <Menu
76
- selectedKeys={[props.selected]}
77
- defaultOpenKeys={openSubs}
78
- className={styles.nav}
79
- mode='inline'
80
- onClick={btnMenu}
81
- >
82
- {menuInfo.map((sub, subIdx) => {
83
- return sub.children && sub.children.length > 0 ? (
84
- <Menu.SubMenu key={sub.menu_name} icon={getIcon(sub?.icon)} title={sub.menu_name}>
85
- {sub.children
86
- ? sub.children.map((menu, idx) => {
87
- return (
88
- <Menu.Item key={menu.menu_name} link={menu.link_path}>
89
- {menu.menu_name}
90
- </Menu.Item>
91
- );
92
- })
93
- : ''}
94
- </Menu.SubMenu>
95
- ) : (
96
- <Menu.Item key={sub.menu_name} icon={getIcon(sub?.icon)} link={sub.link_path}>
97
- {sub.menu_name}
98
- </Menu.Item>
99
- );
100
- })}
101
- </Menu>
102
- </section>
103
- );
95
+
96
+ window.matchPath=matchPath;
97
+
98
+
99
+ const GET_ROUTE_MENU=(menuList)=>{
100
+ let groupKeys=[];
101
+ for(let key in menuList){
102
+ const menuItem = menuList[key];
103
+ const {path,routeTemplate,subRoute}= menuItem.source;
104
+ if(path){
105
+ let fn = matchPath;
106
+ let match= fn(routeTemplate||path,curRoute.pathname);
107
+ if(!match&&subRoute){
108
+ match= subRoute.some(sub=>{
109
+ let subMatch= fn(sub.routeTemplate||sub.path,curRoute.pathname);
110
+ if(subMatch){
111
+ return true;
112
+ }
113
+ return false;
114
+ })
115
+ }
116
+ if(match){
117
+ groupKeys = menuItem.routepath?menuItem.routepath.split('-'):'';
118
+ }
119
+ }
120
+ }
121
+ return groupKeys;
122
+ }
123
+
124
+ const loadMenu= async ()=>{
125
+ loader.setLoading(true);
126
+ // const req= await GET_LEFT_MENU();
127
+
128
+
129
+ const req= {code:0,info:MenuRoute}
130
+ if(req.info){
131
+ const menuList= req.info.map(menu=>{
132
+ return translateMenu(menu)
133
+ })
134
+ setMenus(menuList);
135
+ }else{
136
+ setMenus([]);
137
+ }
138
+ loader.setLoading(false);
139
+ }
140
+
141
+ useEffect(()=>{
142
+ loadMenu();
143
+ },[])
144
+
145
+ useEffect(()=>{
146
+ let groupKeys= GET_ROUTE_MENU(MENU_KEY.current);
147
+ setOpenKeys(groupKeys);
148
+ let selectKey =groupKeys[groupKeys.length-1];
149
+ setSelectKeys([selectKey])
150
+ },[curRoute,menus]);
151
+
152
+ const onClickMenuItem=(e)=>{
153
+ const { item, key, keyPath, domEvent } = e;
154
+ const menuData = MENU_KEY.current[key];
155
+ if(menuData.path){
156
+ nav(menuData.path);
157
+ }
158
+ }
159
+ const onOpenChange=(keys)=>{
160
+ setOpenKeys(keys);
104
161
  }
105
-
106
162
  return (
107
163
  <section
108
164
  className={styles.wrap}
109
165
  >
110
- {loading ? (
111
- <section className={styles.loadingWrap} >
112
- <Spin />
113
- </section>
114
- ) : (
115
- createMenu()
116
- )}
166
+
167
+ <Menu
168
+ selectedKeys={selectedKeys}
169
+ className={styles.nav}
170
+ openKeys={openKeys}
171
+ onOpenChange={onOpenChange}
172
+ onClick={onClickMenuItem}
173
+ mode="inline"
174
+ items={loader.loading?[]:menus}
175
+ />
176
+
117
177
  </section>
118
- );
119
- };
120
178
 
121
- export default LayoutByLeftNav;
179
+
180
+ )
181
+ }
182
+
183
+ export default LeftMenu;
184
+
@@ -0,0 +1,47 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { Select } from 'antd';
3
+
4
+ /**
5
+ * 所属部门选择器
6
+ */
7
+ function DepSelect(props) {
8
+ const [value, setValue] = useState(props?.value || '');
9
+ const [list] = useState(props.list || null);
10
+
11
+ useEffect(() => {
12
+ if (props?.value) setValue(props.value);
13
+ }, [value]);
14
+
15
+ function filterOption(inputValue, option) {
16
+ if (option.data.ORG_NAME && option.data.ORG_NAME.toLocaleLowerCase().includes(inputValue.toLocaleLowerCase())) {
17
+ return true;
18
+ }
19
+
20
+ return false;
21
+ }
22
+ function onChange(options, selected) {
23
+ setValue(options);
24
+ if (props.onChange) props.onChange(options, selected);
25
+ }
26
+
27
+ return (
28
+ <Select
29
+ value={`${value}`}
30
+ loading={!list}
31
+ style={{ width: '100%' }}
32
+ onChange={onChange}
33
+ showSearch
34
+ filterOption={filterOption}
35
+ >
36
+ {list?.map((item) => {
37
+ return (
38
+ <Select.Option data={item} key={item.ORG_ID} value={`${item.ORG_ID}`}>
39
+ {item.ORG_NAME}
40
+ </Select.Option>
41
+ );
42
+ })}
43
+ </Select>
44
+ );
45
+ }
46
+
47
+ export default DepSelect;