Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivManage
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
CivManage
Commits
5cef5fc3
Commit
5cef5fc3
authored
Nov 25, 2020
by
张烨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 网站配置回显
parent
a54591f2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
39 deletions
+64
-39
siteConfigDrawer.js
src/pages/webConfig/components/siteConfigDrawer.js
+4
-3
webConfigForm.js
src/pages/webConfig/components/webConfigForm.js
+6
-10
index.js
src/pages/webConfig/index.js
+30
-13
index.less
src/pages/webConfig/index.less
+6
-0
utils.js
src/pages/webConfig/utils.js
+18
-13
No files found.
src/pages/webConfig/components/siteConfigDrawer.js
View file @
5cef5fc3
...
...
@@ -3,12 +3,12 @@ import { Drawer } from 'antd';
import
WebConfigForm
from
'./webConfigForm'
;
export
default
props
=>
{
const
{
visible
,
onClose
,
config
,
hasIntegerate
}
=
props
;
const
{
visible
,
onClose
,
config
,
hasIntegerate
,
isEdit
}
=
props
;
return
(
<
Drawer
title
=
{
config
?
'编辑网站'
:
'添加
网站'
}
width
=
{
5
20
}
title
=
{
isEdit
?
'查看/编辑网站配置'
:
'新增
网站'
}
width
=
{
6
20
}
closable
onClose
=
{
onClose
}
visible
=
{
visible
}
...
...
@@ -16,6 +16,7 @@ export default props => {
>
<
WebConfigForm
hasIntegerate
=
{
hasIntegerate
}
isEdit
=
{
isEdit
}
config
=
{
config
}
onCancel
=
{
onClose
}
onOk
=
{
values
=>
{
...
...
src/pages/webConfig/components/webConfigForm.js
View file @
5cef5fc3
...
...
@@ -9,11 +9,10 @@ import { Row, Col } from 'antd';
import
{
getDefaultGetWebconfig
,
singleStyleData
}
from
'../utils'
;
const
WebConfigForm
=
props
=>
{
const
{
hasIntegerate
,
config
,
onCancel
,
onSubmit
,
onOk
}
=
props
;
const
{
hasIntegerate
,
config
,
onCancel
,
onSubmit
,
onOk
,
isEdit
}
=
props
;
const
[
webThemes
,
setWebThemes
]
=
useState
([]);
const
[
mapConfigs
,
setMapConfigs
]
=
useState
([]);
const
[
loginPages
,
setLoginPages
]
=
useState
([]);
const
[
webType
,
setWebType
]
=
useState
();
const
[
form
,
setForm
]
=
useState
(
null
);
const
getForm
=
f
=>
{
...
...
@@ -48,12 +47,12 @@ const WebConfigForm = props => {
initialValues
:
config
,
hasIntegerate
,
webThemes
,
webType
,
onGetThemes
,
loginPages
,
mapConfigs
,
onGetLoginPages
,
onGetMapConfig
,
isEdit
,
});
const
formConfig
=
{
...
...
@@ -97,13 +96,10 @@ const WebConfigForm = props => {
labelCol
=
{{
span
:
6
}}
wrapperCol
=
{{
span
:
14
}}
onValuesChange
=
{
v
=>
{
if
(
v
.
type
)
{
setWebType
(
v
.
type
);
if
(
form
)
{
const
sty
=
form
.
getFieldValue
(
'style'
);
if
(
!
singleStyleData
[
sty
])
{
form
.
setFieldsValue
([{
name
:
'style'
,
value
:
'platform'
}]);
}
if
(
form
&&
v
.
mode
===
'single'
)
{
const
sty
=
form
.
getFieldValue
(
'style'
);
if
(
!
singleStyleData
[
sty
])
{
form
.
setFieldsValue
([{
name
:
'style'
,
value
:
'platform'
}]);
}
}
}}
...
...
src/pages/webConfig/index.js
View file @
5cef5fc3
...
...
@@ -19,47 +19,61 @@ const WebConfigPage = props => {
const
[
curWeb
,
setCurWeb
]
=
useState
(
null
);
// 当前展示的web
const
[
configObj
,
setConfigObj
]
=
useState
({});
// 获取当前的web的配置
const
[
toEdit
,
setToEdit
]
=
useState
(
null
);
// 编辑展示用的配置
const
[
isEdit
,
setIsEdit
]
=
useState
(
true
);
const
hasIntegerate
=
()
=>
webs
.
some
(
w
=>
w
.
webTyp
e
===
'integrate'
);
const
hasIntegerate
=
()
=>
webs
.
some
(
w
=>
w
.
mod
e
===
'integrate'
);
useEffect
(()
=>
{
let
canceled
=
false
;
getWebModuleTree
(
userMode
||
'super'
).
then
(
res
=>
{
const
websArr
=
[
res
.
data
.
filter
(
d
=>
d
.
id
===
'Web4IntegrateStation'
)
.
map
(
r
=>
r
.
children
.
map
(
i
=>
({
...
i
,
webType
:
'integrate'
}))),
res
.
data
.
filter
(
d
=>
d
.
id
===
'Web4SingleStation'
)
.
map
(
r
=>
r
.
children
.
map
(
i
=>
({
...
i
,
webType
:
'single'
}))),
.
map
(
r
=>
r
.
children
),
res
.
data
.
filter
(
d
=>
d
.
id
===
'Web4SingleStation'
).
map
(
r
=>
r
.
children
),
].
flat
(
2
);
setWebs
(
websArr
);
setCurWeb
(
websArr
[
0
]);
setLoading
(
false
);
if
(
!
canceled
)
{
setWebs
(
websArr
);
setCurWeb
(
websArr
[
0
]);
setLoading
(
false
);
}
});
return
()
=>
{
canceled
=
true
;
};
},
[]);
useEffect
(()
=>
{
let
canceled
=
false
;
if
(
!
curWeb
)
return
;
const
title
=
curWeb
.
text
;
// eslint-disable-next-line no-unused-expressions
getWebconfig
(
curWeb
.
text
).
then
(
res
=>
{
setConfigObj
(
res
);
if
(
title
===
curWeb
.
text
)
{
setToEdit
(
res
);
if
(
!
canceled
)
{
setConfigObj
(
res
);
if
(
title
===
curWeb
.
text
)
{
setToEdit
(
res
);
}
}
});
// eslint-disable-next-line consistent-return
return
()
=>
{
canceled
=
true
;
};
},
[
curWeb
]);
const
renderTabPane
=
tabPaneItem
=>
(
<
TabPane
key
=
{
tabPaneItem
.
text
}
tab
=
{
tabPaneItem
.
text
}
>
<>
<
span
className
=
{
styles
.
link
}
onClick
=
{()
=>
{
setToEdit
(
configObj
);
setToEdit
(
{
...
configObj
}
);
setConfigVisible
(
true
);
setIsEdit
(
true
);
}}
>
查看配置
查看
/
编辑网站
配置
<
/span
>
<
/
>
<
/TabPane
>
...
...
@@ -69,6 +83,8 @@ const WebConfigPage = props => {
// console.log(targetKey, action); // action: add|remove
switch
(
action
)
{
case
'add'
:
setIsEdit
(
false
);
setToEdit
({});
setConfigVisible
(
true
);
break
;
case
'remove'
:
...
...
@@ -92,6 +108,7 @@ const WebConfigPage = props => {
{
webs
.
map
(
renderTabPane
)}
<
/Tabs
>
<
SiteConfig
isEdit
=
{
isEdit
}
visible
=
{
configVisible
}
onClose
=
{
onDrawerClose
}
config
=
{
toEdit
}
...
...
src/pages/webConfig/index.less
View file @
5cef5fc3
...
...
@@ -2,6 +2,12 @@
position: absolute;
width: 100%;
height: 100%;
.link{
color: #2f54eb;
cursor: pointer;
user-select: none;
border-bottom: 1px solid #2f54eb;
}
.ant-tabs-content-holder>.ant-tabs-content.ant-tabs-content-top{
position: absolute;
width: 100%;
...
...
src/pages/webConfig/utils.js
View file @
5cef5fc3
...
...
@@ -6,7 +6,7 @@ const typeContent = hasIntegerate => {
}
return
[
{
value
:
'
a
'
,
value
:
'
integrate
'
,
children
:
'集成网站'
,
},
];
...
...
@@ -29,6 +29,7 @@ export const menuStyle = {
'banner-big'
:
'标题栏-大'
,
table
:
'左侧'
,
dock
:
'底部'
,
'banner-left-noShrink'
:
'标题栏-左-不收'
,
};
export
const
MDILabel
=
{
MDI
:
'多标签模式'
,
...
...
@@ -39,23 +40,25 @@ export const notificationTypes = {
MQTT
:
'MQTT消息'
,
};
const
isIntegerate
=
(
webTyp
e
,
hasIntegerate
)
=>
{
if
(
typeof
webTyp
e
!==
'undefined'
)
{
return
webType
===
'a
'
;
const
isIntegerate
=
(
mod
e
,
hasIntegerate
)
=>
{
if
(
typeof
mod
e
!==
'undefined'
)
{
return
mode
===
'single
'
;
}
return
hasIntegerate
;
};
export
const
defaultWebConfigObj
=
{};
export
const
getDefaultGetWebconfig
=
({
initialValues
=
{},
hasIntegerate
,
webThemes
,
onGetThemes
,
webType
,
loginPages
,
onGetLoginPages
,
mapConfigs
,
onGetMapConfig
,
isEdit
,
})
=>
{
const
config
=
{
title
:
{
...
...
@@ -75,13 +78,14 @@ export const getDefaultGetWebconfig = ({
formType
:
ITEM_TYPE
.
INPUT
,
allowClear
:
true
,
},
typ
e
:
{
mod
e
:
{
label
:
'网站类型'
,
formType
:
ITEM_TYPE
.
SINGLE_RADIO
,
initialValue
:
'b'
,
initialValue
:
'single'
,
disabled
:
isEdit
,
options
:
[
{
value
:
'
b
'
,
value
:
'
single
'
,
children
:
'一般网站'
,
},
].
concat
(
typeContent
(
hasIntegerate
)),
...
...
@@ -106,7 +110,7 @@ export const getDefaultGetWebconfig = ({
},
],
},
banner
l
ogo
:
{
banner
L
ogo
:
{
label
:
'标题logo'
,
formType
:
ITEM_TYPE
.
IMGSHOP
,
rules
:
[
...
...
@@ -119,6 +123,7 @@ export const getDefaultGetWebconfig = ({
client
:
{
label
:
'虚拟目录'
,
formType
:
ITEM_TYPE
.
INPUT
,
disabled
:
isEdit
,
allowClear
:
true
,
size
:
'small'
,
rules
:
[
...
...
@@ -169,7 +174,7 @@ export const getDefaultGetWebconfig = ({
formType
:
ITEM_TYPE
.
SELECT
,
initialValue
:
''
,
options
:
Object
.
keys
(
isIntegerate
(
webTyp
e
,
hasIntegerate
)
isIntegerate
(
initialValues
.
mod
e
,
hasIntegerate
)
?
integrateStyleData
:
singleStyleData
,
).
map
(
k
=>
({
...
...
@@ -223,6 +228,7 @@ export const getDefaultGetWebconfig = ({
hideMap
:
{
label
:
'按需加载地图'
,
formType
:
ITEM_TYPE
.
SINGLE_RADIO
,
optionType
:
'button'
,
options
:
[
{
value
:
true
,
...
...
@@ -255,9 +261,8 @@ export const getDefaultGetWebconfig = ({
};
if
(
initialValues
)
{
Object
.
keys
(
config
).
forEach
(
k
=>
{
if
(
initialValues
[
k
])
{
config
[
k
].
initialValue
=
initialValues
[
k
];
}
config
[
k
].
initialValue
=
typeof
initialValues
[
k
]
!==
'undefined'
?
initialValues
[
k
]
:
''
;
});
}
return
config
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment