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
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
30 deletions
+55
-30
siteConfigDrawer.js
src/pages/webConfig/components/siteConfigDrawer.js
+4
-3
webConfigForm.js
src/pages/webConfig/components/webConfigForm.js
+3
-7
index.js
src/pages/webConfig/index.js
+24
-7
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';
...
@@ -3,12 +3,12 @@ import { Drawer } from 'antd';
import
WebConfigForm
from
'./webConfigForm'
;
import
WebConfigForm
from
'./webConfigForm'
;
export
default
props
=>
{
export
default
props
=>
{
const
{
visible
,
onClose
,
config
,
hasIntegerate
}
=
props
;
const
{
visible
,
onClose
,
config
,
hasIntegerate
,
isEdit
}
=
props
;
return
(
return
(
<
Drawer
<
Drawer
title
=
{
config
?
'编辑网站'
:
'添加
网站'
}
title
=
{
isEdit
?
'查看/编辑网站配置'
:
'新增
网站'
}
width
=
{
5
20
}
width
=
{
6
20
}
closable
closable
onClose
=
{
onClose
}
onClose
=
{
onClose
}
visible
=
{
visible
}
visible
=
{
visible
}
...
@@ -16,6 +16,7 @@ export default props => {
...
@@ -16,6 +16,7 @@ export default props => {
>
>
<
WebConfigForm
<
WebConfigForm
hasIntegerate
=
{
hasIntegerate
}
hasIntegerate
=
{
hasIntegerate
}
isEdit
=
{
isEdit
}
config
=
{
config
}
config
=
{
config
}
onCancel
=
{
onClose
}
onCancel
=
{
onClose
}
onOk
=
{
values
=>
{
onOk
=
{
values
=>
{
...
...
src/pages/webConfig/components/webConfigForm.js
View file @
5cef5fc3
...
@@ -9,11 +9,10 @@ import { Row, Col } from 'antd';
...
@@ -9,11 +9,10 @@ import { Row, Col } from 'antd';
import
{
getDefaultGetWebconfig
,
singleStyleData
}
from
'../utils'
;
import
{
getDefaultGetWebconfig
,
singleStyleData
}
from
'../utils'
;
const
WebConfigForm
=
props
=>
{
const
WebConfigForm
=
props
=>
{
const
{
hasIntegerate
,
config
,
onCancel
,
onSubmit
,
onOk
}
=
props
;
const
{
hasIntegerate
,
config
,
onCancel
,
onSubmit
,
onOk
,
isEdit
}
=
props
;
const
[
webThemes
,
setWebThemes
]
=
useState
([]);
const
[
webThemes
,
setWebThemes
]
=
useState
([]);
const
[
mapConfigs
,
setMapConfigs
]
=
useState
([]);
const
[
mapConfigs
,
setMapConfigs
]
=
useState
([]);
const
[
loginPages
,
setLoginPages
]
=
useState
([]);
const
[
loginPages
,
setLoginPages
]
=
useState
([]);
const
[
webType
,
setWebType
]
=
useState
();
const
[
form
,
setForm
]
=
useState
(
null
);
const
[
form
,
setForm
]
=
useState
(
null
);
const
getForm
=
f
=>
{
const
getForm
=
f
=>
{
...
@@ -48,12 +47,12 @@ const WebConfigForm = props => {
...
@@ -48,12 +47,12 @@ const WebConfigForm = props => {
initialValues
:
config
,
initialValues
:
config
,
hasIntegerate
,
hasIntegerate
,
webThemes
,
webThemes
,
webType
,
onGetThemes
,
onGetThemes
,
loginPages
,
loginPages
,
mapConfigs
,
mapConfigs
,
onGetLoginPages
,
onGetLoginPages
,
onGetMapConfig
,
onGetMapConfig
,
isEdit
,
});
});
const
formConfig
=
{
const
formConfig
=
{
...
@@ -97,15 +96,12 @@ const WebConfigForm = props => {
...
@@ -97,15 +96,12 @@ const WebConfigForm = props => {
labelCol
=
{{
span
:
6
}}
labelCol
=
{{
span
:
6
}}
wrapperCol
=
{{
span
:
14
}}
wrapperCol
=
{{
span
:
14
}}
onValuesChange
=
{
v
=>
{
onValuesChange
=
{
v
=>
{
if
(
v
.
type
)
{
if
(
form
&&
v
.
mode
===
'single'
)
{
setWebType
(
v
.
type
);
if
(
form
)
{
const
sty
=
form
.
getFieldValue
(
'style'
);
const
sty
=
form
.
getFieldValue
(
'style'
);
if
(
!
singleStyleData
[
sty
])
{
if
(
!
singleStyleData
[
sty
])
{
form
.
setFieldsValue
([{
name
:
'style'
,
value
:
'platform'
}]);
form
.
setFieldsValue
([{
name
:
'style'
,
value
:
'platform'
}]);
}
}
}
}
}
}}
}}
onFinish
=
{
values
=>
{
onFinish
=
{
values
=>
{
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line no-unused-expressions
...
...
src/pages/webConfig/index.js
View file @
5cef5fc3
...
@@ -19,47 +19,61 @@ const WebConfigPage = props => {
...
@@ -19,47 +19,61 @@ const WebConfigPage = props => {
const
[
curWeb
,
setCurWeb
]
=
useState
(
null
);
// 当前展示的web
const
[
curWeb
,
setCurWeb
]
=
useState
(
null
);
// 当前展示的web
const
[
configObj
,
setConfigObj
]
=
useState
({});
// 获取当前的web的配置
const
[
configObj
,
setConfigObj
]
=
useState
({});
// 获取当前的web的配置
const
[
toEdit
,
setToEdit
]
=
useState
(
null
);
// 编辑展示用的配置
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
(()
=>
{
useEffect
(()
=>
{
let
canceled
=
false
;
getWebModuleTree
(
userMode
||
'super'
).
then
(
res
=>
{
getWebModuleTree
(
userMode
||
'super'
).
then
(
res
=>
{
const
websArr
=
[
const
websArr
=
[
res
.
data
res
.
data
.
filter
(
d
=>
d
.
id
===
'Web4IntegrateStation'
)
.
filter
(
d
=>
d
.
id
===
'Web4IntegrateStation'
)
.
map
(
r
=>
r
.
children
.
map
(
i
=>
({
...
i
,
webType
:
'integrate'
}))),
.
map
(
r
=>
r
.
children
),
res
.
data
res
.
data
.
filter
(
d
=>
d
.
id
===
'Web4SingleStation'
).
map
(
r
=>
r
.
children
),
.
filter
(
d
=>
d
.
id
===
'Web4SingleStation'
)
.
map
(
r
=>
r
.
children
.
map
(
i
=>
({
...
i
,
webType
:
'single'
}))),
].
flat
(
2
);
].
flat
(
2
);
if
(
!
canceled
)
{
setWebs
(
websArr
);
setWebs
(
websArr
);
setCurWeb
(
websArr
[
0
]);
setCurWeb
(
websArr
[
0
]);
setLoading
(
false
);
setLoading
(
false
);
}
});
});
return
()
=>
{
canceled
=
true
;
};
},
[]);
},
[]);
useEffect
(()
=>
{
useEffect
(()
=>
{
let
canceled
=
false
;
if
(
!
curWeb
)
return
;
if
(
!
curWeb
)
return
;
const
title
=
curWeb
.
text
;
const
title
=
curWeb
.
text
;
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line no-unused-expressions
getWebconfig
(
curWeb
.
text
).
then
(
res
=>
{
getWebconfig
(
curWeb
.
text
).
then
(
res
=>
{
if
(
!
canceled
)
{
setConfigObj
(
res
);
setConfigObj
(
res
);
if
(
title
===
curWeb
.
text
)
{
if
(
title
===
curWeb
.
text
)
{
setToEdit
(
res
);
setToEdit
(
res
);
}
}
}
});
});
// eslint-disable-next-line consistent-return
return
()
=>
{
canceled
=
true
;
};
},
[
curWeb
]);
},
[
curWeb
]);
const
renderTabPane
=
tabPaneItem
=>
(
const
renderTabPane
=
tabPaneItem
=>
(
<
TabPane
key
=
{
tabPaneItem
.
text
}
tab
=
{
tabPaneItem
.
text
}
>
<
TabPane
key
=
{
tabPaneItem
.
text
}
tab
=
{
tabPaneItem
.
text
}
>
<>
<>
<
span
<
span
className
=
{
styles
.
link
}
onClick
=
{()
=>
{
onClick
=
{()
=>
{
setToEdit
(
configObj
);
setToEdit
(
{
...
configObj
}
);
setConfigVisible
(
true
);
setConfigVisible
(
true
);
setIsEdit
(
true
);
}}
}}
>
>
查看配置
查看
/
编辑网站
配置
<
/span
>
<
/span
>
<
/
>
<
/
>
<
/TabPane
>
<
/TabPane
>
...
@@ -69,6 +83,8 @@ const WebConfigPage = props => {
...
@@ -69,6 +83,8 @@ const WebConfigPage = props => {
// console.log(targetKey, action); // action: add|remove
// console.log(targetKey, action); // action: add|remove
switch
(
action
)
{
switch
(
action
)
{
case
'add'
:
case
'add'
:
setIsEdit
(
false
);
setToEdit
({});
setConfigVisible
(
true
);
setConfigVisible
(
true
);
break
;
break
;
case
'remove'
:
case
'remove'
:
...
@@ -92,6 +108,7 @@ const WebConfigPage = props => {
...
@@ -92,6 +108,7 @@ const WebConfigPage = props => {
{
webs
.
map
(
renderTabPane
)}
{
webs
.
map
(
renderTabPane
)}
<
/Tabs
>
<
/Tabs
>
<
SiteConfig
<
SiteConfig
isEdit
=
{
isEdit
}
visible
=
{
configVisible
}
visible
=
{
configVisible
}
onClose
=
{
onDrawerClose
}
onClose
=
{
onDrawerClose
}
config
=
{
toEdit
}
config
=
{
toEdit
}
...
...
src/pages/webConfig/index.less
View file @
5cef5fc3
...
@@ -2,6 +2,12 @@
...
@@ -2,6 +2,12 @@
position: absolute;
position: absolute;
width: 100%;
width: 100%;
height: 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{
.ant-tabs-content-holder>.ant-tabs-content.ant-tabs-content-top{
position: absolute;
position: absolute;
width: 100%;
width: 100%;
...
...
src/pages/webConfig/utils.js
View file @
5cef5fc3
...
@@ -6,7 +6,7 @@ const typeContent = hasIntegerate => {
...
@@ -6,7 +6,7 @@ const typeContent = hasIntegerate => {
}
}
return
[
return
[
{
{
value
:
'
a
'
,
value
:
'
integrate
'
,
children
:
'集成网站'
,
children
:
'集成网站'
,
},
},
];
];
...
@@ -29,6 +29,7 @@ export const menuStyle = {
...
@@ -29,6 +29,7 @@ export const menuStyle = {
'banner-big'
:
'标题栏-大'
,
'banner-big'
:
'标题栏-大'
,
table
:
'左侧'
,
table
:
'左侧'
,
dock
:
'底部'
,
dock
:
'底部'
,
'banner-left-noShrink'
:
'标题栏-左-不收'
,
};
};
export
const
MDILabel
=
{
export
const
MDILabel
=
{
MDI
:
'多标签模式'
,
MDI
:
'多标签模式'
,
...
@@ -39,23 +40,25 @@ export const notificationTypes = {
...
@@ -39,23 +40,25 @@ export const notificationTypes = {
MQTT
:
'MQTT消息'
,
MQTT
:
'MQTT消息'
,
};
};
const
isIntegerate
=
(
webTyp
e
,
hasIntegerate
)
=>
{
const
isIntegerate
=
(
mod
e
,
hasIntegerate
)
=>
{
if
(
typeof
webTyp
e
!==
'undefined'
)
{
if
(
typeof
mod
e
!==
'undefined'
)
{
return
webType
===
'a
'
;
return
mode
===
'single
'
;
}
}
return
hasIntegerate
;
return
hasIntegerate
;
};
};
export
const
defaultWebConfigObj
=
{};
export
const
getDefaultGetWebconfig
=
({
export
const
getDefaultGetWebconfig
=
({
initialValues
=
{},
initialValues
=
{},
hasIntegerate
,
hasIntegerate
,
webThemes
,
webThemes
,
onGetThemes
,
onGetThemes
,
webType
,
loginPages
,
loginPages
,
onGetLoginPages
,
onGetLoginPages
,
mapConfigs
,
mapConfigs
,
onGetMapConfig
,
onGetMapConfig
,
isEdit
,
})
=>
{
})
=>
{
const
config
=
{
const
config
=
{
title
:
{
title
:
{
...
@@ -75,13 +78,14 @@ export const getDefaultGetWebconfig = ({
...
@@ -75,13 +78,14 @@ export const getDefaultGetWebconfig = ({
formType
:
ITEM_TYPE
.
INPUT
,
formType
:
ITEM_TYPE
.
INPUT
,
allowClear
:
true
,
allowClear
:
true
,
},
},
typ
e
:
{
mod
e
:
{
label
:
'网站类型'
,
label
:
'网站类型'
,
formType
:
ITEM_TYPE
.
SINGLE_RADIO
,
formType
:
ITEM_TYPE
.
SINGLE_RADIO
,
initialValue
:
'b'
,
initialValue
:
'single'
,
disabled
:
isEdit
,
options
:
[
options
:
[
{
{
value
:
'
b
'
,
value
:
'
single
'
,
children
:
'一般网站'
,
children
:
'一般网站'
,
},
},
].
concat
(
typeContent
(
hasIntegerate
)),
].
concat
(
typeContent
(
hasIntegerate
)),
...
@@ -106,7 +110,7 @@ export const getDefaultGetWebconfig = ({
...
@@ -106,7 +110,7 @@ export const getDefaultGetWebconfig = ({
},
},
],
],
},
},
banner
l
ogo
:
{
banner
L
ogo
:
{
label
:
'标题logo'
,
label
:
'标题logo'
,
formType
:
ITEM_TYPE
.
IMGSHOP
,
formType
:
ITEM_TYPE
.
IMGSHOP
,
rules
:
[
rules
:
[
...
@@ -119,6 +123,7 @@ export const getDefaultGetWebconfig = ({
...
@@ -119,6 +123,7 @@ export const getDefaultGetWebconfig = ({
client
:
{
client
:
{
label
:
'虚拟目录'
,
label
:
'虚拟目录'
,
formType
:
ITEM_TYPE
.
INPUT
,
formType
:
ITEM_TYPE
.
INPUT
,
disabled
:
isEdit
,
allowClear
:
true
,
allowClear
:
true
,
size
:
'small'
,
size
:
'small'
,
rules
:
[
rules
:
[
...
@@ -169,7 +174,7 @@ export const getDefaultGetWebconfig = ({
...
@@ -169,7 +174,7 @@ export const getDefaultGetWebconfig = ({
formType
:
ITEM_TYPE
.
SELECT
,
formType
:
ITEM_TYPE
.
SELECT
,
initialValue
:
''
,
initialValue
:
''
,
options
:
Object
.
keys
(
options
:
Object
.
keys
(
isIntegerate
(
webTyp
e
,
hasIntegerate
)
isIntegerate
(
initialValues
.
mod
e
,
hasIntegerate
)
?
integrateStyleData
?
integrateStyleData
:
singleStyleData
,
:
singleStyleData
,
).
map
(
k
=>
({
).
map
(
k
=>
({
...
@@ -223,6 +228,7 @@ export const getDefaultGetWebconfig = ({
...
@@ -223,6 +228,7 @@ export const getDefaultGetWebconfig = ({
hideMap
:
{
hideMap
:
{
label
:
'按需加载地图'
,
label
:
'按需加载地图'
,
formType
:
ITEM_TYPE
.
SINGLE_RADIO
,
formType
:
ITEM_TYPE
.
SINGLE_RADIO
,
optionType
:
'button'
,
options
:
[
options
:
[
{
{
value
:
true
,
value
:
true
,
...
@@ -255,9 +261,8 @@ export const getDefaultGetWebconfig = ({
...
@@ -255,9 +261,8 @@ export const getDefaultGetWebconfig = ({
};
};
if
(
initialValues
)
{
if
(
initialValues
)
{
Object
.
keys
(
config
).
forEach
(
k
=>
{
Object
.
keys
(
config
).
forEach
(
k
=>
{
if
(
initialValues
[
k
])
{
config
[
k
].
initialValue
=
config
[
k
].
initialValue
=
initialValues
[
k
];
typeof
initialValues
[
k
]
!==
'undefined'
?
initialValues
[
k
]
:
''
;
}
});
});
}
}
return
config
;
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