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
47754fe1
Commit
47754fe1
authored
Nov 25, 2020
by
张烨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: web配置保存
parent
5f10a8db
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
141 additions
and
43 deletions
+141
-43
siteConfigDrawer.js
src/pages/webConfig/components/siteConfigDrawer.js
+22
-3
webConfigForm.js
src/pages/webConfig/components/webConfigForm.js
+11
-1
index.js
src/pages/webConfig/index.js
+93
-38
utils.js
src/pages/webConfig/utils.js
+3
-0
api.js
src/services/webConfig/api.js
+12
-1
No files found.
src/pages/webConfig/components/siteConfigDrawer.js
View file @
47754fe1
import
React
from
'react'
;
import
React
from
'react'
;
import
{
Drawer
}
from
'antd'
;
import
{
Drawer
,
notification
}
from
'antd'
;
import
WebConfigForm
from
'./webConfigForm'
;
import
WebConfigForm
from
'./webConfigForm'
;
import
{
postEditWebConfig
}
from
'@/services/webConfig/api'
;
export
default
props
=>
{
export
default
props
=>
{
const
{
visible
,
onClose
,
config
,
hasIntegerate
,
isEdit
}
=
props
;
const
{
visible
,
onClose
,
config
,
hasIntegerate
,
isEdit
,
onOk
,
submitting
,
}
=
props
;
return
(
return
(
<
Drawer
<
Drawer
...
@@ -19,8 +28,18 @@ export default props => {
...
@@ -19,8 +28,18 @@ export default props => {
isEdit
=
{
isEdit
}
isEdit
=
{
isEdit
}
config
=
{
config
}
config
=
{
config
}
onCancel
=
{
onClose
}
onCancel
=
{
onClose
}
submitting
=
{
submitting
}
onOk
=
{
values
=>
{
onOk
=
{
values
=>
{
console
.
log
(
values
);
if
(
!
values
.
homePage
&&
values
.
hideMap
)
{
notification
.
error
({
message
:
'在按需加载地图的模式下,请配置主页路径'
,
duration
:
'3'
,
});
return
;
}
values
.
alarmWays
=
values
.
alarmWays
.
join
(
','
);
// eslint-disable-next-line no-unused-expressions
onOk
&&
onOk
(
values
);
}}
}}
/
>
/
>
<
/Drawer
>
<
/Drawer
>
...
...
src/pages/webConfig/components/webConfigForm.js
View file @
47754fe1
...
@@ -9,7 +9,15 @@ import { Row, Col } from 'antd';
...
@@ -9,7 +9,15 @@ 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
,
isEdit
}
=
props
;
const
{
hasIntegerate
,
config
,
onCancel
,
onSubmit
,
onOk
,
isEdit
,
submitting
,
}
=
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
([]);
...
@@ -45,6 +53,7 @@ const WebConfigForm = props => {
...
@@ -45,6 +53,7 @@ const WebConfigForm = props => {
const
itemsMap
=
getDefaultGetWebconfig
({
const
itemsMap
=
getDefaultGetWebconfig
({
initialValues
:
config
,
initialValues
:
config
,
submitting
,
hasIntegerate
,
hasIntegerate
,
webThemes
,
webThemes
,
onGetThemes
,
onGetThemes
,
...
@@ -76,6 +85,7 @@ const WebConfigForm = props => {
...
@@ -76,6 +85,7 @@ const WebConfigForm = props => {
htmlType
:
'submit'
,
htmlType
:
'submit'
,
type
:
'primary'
,
type
:
'primary'
,
size
:
'middle'
,
size
:
'middle'
,
loading
:
submitting
,
style
:
{
style
:
{
marginLeft
:
'10px'
,
marginLeft
:
'10px'
,
},
},
...
...
src/pages/webConfig/index.js
View file @
47754fe1
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
PageContainer
from
'@/components/BasePageContainer'
;
import
PageContainer
from
'@/components/BasePageContainer'
;
import
{
Tabs
}
from
'antd'
;
import
{
notification
,
Spin
,
Tabs
}
from
'antd'
;
import
{
import
{
getWebModuleTree
,
getWebModuleTree
,
getWebConfigByName
,
getWebconfig
,
getWebconfig
,
postEditWebConfig
,
}
from
'@/services/webConfig/api'
;
}
from
'@/services/webConfig/api'
;
import
{
cancelled
}
from
'redux-saga/effects'
;
import
styles
from
'./index.less'
;
import
styles
from
'./index.less'
;
import
SiteConfig
from
'./components/siteConfigDrawer'
;
import
SiteConfig
from
'./components/siteConfigDrawer'
;
import
{
appConnector
}
from
'@/containers/App/store'
;
import
{
appConnector
}
from
'@/containers/App/store'
;
...
@@ -20,47 +21,65 @@ const WebConfigPage = props => {
...
@@ -20,47 +21,65 @@ const WebConfigPage = props => {
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
[
isEdit
,
setIsEdit
]
=
useState
(
true
);
const
[
submitting
,
setSubmitting
]
=
useState
(
false
);
const
hasIntegerate
=
()
=>
webs
.
some
(
w
=>
w
.
mode
===
'integrate'
);
const
hasIntegerate
=
()
=>
webs
.
some
(
w
=>
w
.
mode
===
'integrate'
);
useEffect
(()
=>
{
useEffect
(()
=>
{
let
canceled
=
false
;
let
canceled
=
{
cancel
:
false
};
getWebModuleTree
(
userMode
||
'super'
).
then
(
res
=>
{
setLoading
(
true
);
updateModuleTree
(
userMode
||
'super'
,
canceled
);
return
()
=>
{
canceled
.
cancel
=
true
;
};
},
[]);
useEffect
(()
=>
{
let
canceled
=
{
cancel
:
false
};
if
(
!
curWeb
)
return
;
const
title
=
curWeb
.
text
;
updateWebconfig
(
title
,
canceled
);
// eslint-disable-next-line consistent-return
return
()
=>
{
canceled
.
cancel
=
true
;
};
},
[
curWeb
]);
const
updateModuleTree
=
(
userModePrama
,
canceled
=
{
cancel
:
false
})
=>
{
getWebModuleTree
(
userModePrama
).
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
(
r
=>
r
.
children
),
res
.
data
.
filter
(
d
=>
d
.
id
===
'Web4SingleStation'
).
map
(
r
=>
r
.
children
),
res
.
data
.
filter
(
d
=>
d
.
id
===
'Web4SingleStation'
).
map
(
r
=>
r
.
children
),
].
flat
(
2
);
].
flat
(
2
);
if
(
!
canceled
)
{
if
(
!
canceled
.
cancel
)
{
setWebs
(
websArr
);
setWebs
(
websArr
);
setCurWeb
(
websArr
[
0
]);
if
(
!
curWeb
)
setCurWeb
(
websArr
[
0
]);
setLoading
(
false
);
setLoading
(
false
);
}
}
});
});
return
()
=>
{
};
canceled
=
true
;
};
},
[]);
useEffect
((
)
=>
{
const
updateWebconfig
=
(
webTitle
,
canceled
=
{
cancel
:
false
}
)
=>
{
let
canceled
=
false
;
setLoading
(
true
)
;
if
(
!
curWeb
)
return
;
return
getWebconfig
(
webTitle
)
const
title
=
curWeb
.
text
;
.
then
(
res
=>
{
// eslint-disable-next-line no-unused-expressions
setLoading
(
false
);
getWebconfig
(
curWeb
.
text
).
then
(
res
=>
{
if
(
!
canceled
.
cancel
)
{
if
(
!
canceled
)
{
setConfigObj
(
res
);
setConfigObj
(
res
);
if
(
webTitle
===
curWeb
.
text
)
{
if
(
title
===
curWeb
.
text
)
{
setToEdit
(
res
);
setToEdit
(
res
);
}
}
}
}
}
)
});
.
catch
(
err
=>
{
// eslint-disable-next-line consistent-return
setLoading
(
false
);
return
()
=>
{
// eslint-disable-next-line no-console
canceled
=
true
;
console
.
error
(
err
)
;
}
;
})
;
}
,
[
curWeb
])
;
};
const
renderTabPane
=
tabPaneItem
=>
(
const
renderTabPane
=
tabPaneItem
=>
(
<
TabPane
key
=
{
tabPaneItem
.
text
}
tab
=
{
tabPaneItem
.
text
}
>
<
TabPane
key
=
{
tabPaneItem
.
text
}
tab
=
{
tabPaneItem
.
text
}
>
...
@@ -101,19 +120,55 @@ const WebConfigPage = props => {
...
@@ -101,19 +120,55 @@ const WebConfigPage = props => {
setCurWeb
(
webs
.
find
(
w
=>
w
.
text
===
v
));
setCurWeb
(
webs
.
find
(
w
=>
w
.
text
===
v
));
};
};
const
handleSubmit
=
values
=>
{
setSubmitting
(
true
);
if
(
isEdit
)
{
postEditWebConfig
(
values
)
.
then
(
res
=>
{
setSubmitting
(
false
);
if
(
res
.
success
)
{
setCurWeb
({
...
curWeb
,
text
:
values
.
title
});
notification
.
success
({
message
:
'保存成功!'
,
duration
:
3
,
});
updateModuleTree
(
userMode
||
'super'
);
}
else
{
notification
.
warning
({
message
:
res
.
message
||
'编辑失败!'
,
duration
:
5
,
});
}
})
.
catch
(
err
=>
{
notification
.
success
({
message
:
'编辑失败!'
,
duration
:
5
,
});
// eslint-disable-next-line no-console
console
.
error
(
err
);
setSubmitting
(
false
);
});
}
};
return
(
return
(
<
PageContainer
loading
=
{
loading
}
>
<
PageContainer
>
<
div
className
=
{
styles
.
webConfigContainer
}
>
<
div
className
=
{
styles
.
webConfigContainer
}
>
<
Tabs
type
=
"editable-card"
onEdit
=
{
onEdit
}
onChange
=
{
handleTabChange
}
>
<
Spin
spinning
=
{
loading
||
submitting
}
>
{
webs
.
map
(
renderTabPane
)}
<
Tabs
type
=
"editable-card"
onEdit
=
{
onEdit
}
onChange
=
{
handleTabChange
}
>
<
/Tabs
>
{
webs
.
map
(
renderTabPane
)}
<
SiteConfig
<
/Tabs
>
isEdit
=
{
isEdit
}
<
SiteConfig
visible
=
{
configVisible
}
isEdit
=
{
isEdit
}
onClose
=
{
onDrawerClose
}
visible
=
{
configVisible
}
config
=
{
toEdit
}
onClose
=
{
onDrawerClose
}
hasIntegerate
=
{
hasIntegerate
()}
config
=
{
toEdit
}
/
>
onOk
=
{
handleSubmit
}
submitting
=
{
submitting
}
hasIntegerate
=
{
hasIntegerate
()}
/
>
<
/Spin
>
<
/div
>
<
/div
>
<
/PageContainer
>
<
/PageContainer
>
);
);
...
...
src/pages/webConfig/utils.js
View file @
47754fe1
...
@@ -263,6 +263,9 @@ export const getDefaultGetWebconfig = ({
...
@@ -263,6 +263,9 @@ export const getDefaultGetWebconfig = ({
Object
.
keys
(
config
).
forEach
(
k
=>
{
Object
.
keys
(
config
).
forEach
(
k
=>
{
config
[
k
].
initialValue
=
config
[
k
].
initialValue
=
typeof
initialValues
[
k
]
!==
'undefined'
?
initialValues
[
k
]
:
''
;
typeof
initialValues
[
k
]
!==
'undefined'
?
initialValues
[
k
]
:
''
;
if
(
k
===
'alarmWays'
)
{
config
[
k
].
initialValue
=
config
[
k
].
initialValue
.
split
(
','
);
}
});
});
}
}
return
config
;
return
config
;
...
...
src/services/webConfig/api.js
View file @
47754fe1
import
qs
from
'qs'
;
import
qs
from
'qs'
;
import
{
CITY_SERVICE
,
get
,
PUBLISH_SERVICE
}
from
'../index'
;
import
{
CITY_SERVICE
,
get
,
PUBLISH_SERVICE
,
post
,
postForm
}
from
'../index'
;
export
const
getWebModuleTree
=
userMode
=>
export
const
getWebModuleTree
=
userMode
=>
get
(
get
(
...
@@ -25,3 +25,14 @@ export const getMapCofigs = () =>
...
@@ -25,3 +25,14 @@ export const getMapCofigs = () =>
export
const
getWebconfig
=
title
=>
export
const
getWebconfig
=
title
=>
get
(
`
${
CITY_SERVICE
}
/OMS.svc/W4_GetWebsite`
,
{
title
});
get
(
`
${
CITY_SERVICE
}
/OMS.svc/W4_GetWebsite`
,
{
title
});
export
const
postEditWebConfig
=
config
=>
post
(
`
${
CITY_SERVICE
}
/OMS.svc/W4_EditWebsite?_version=9999`
,
qs
.
stringify
({
config
:
JSON
.
stringify
(
config
)
}),
{
headers
:
{
'content-Type'
:
'application/x-www-form-urlencoded; charset=UTF-8'
,
},
},
);
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