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
0f897324
Commit
0f897324
authored
Nov 26, 2020
by
张烨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add and delete website
parent
0e528f06
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
102 additions
and
33 deletions
+102
-33
index.js
src/components/BaseForm/index.js
+6
-6
siteConfigDrawer.js
src/pages/webConfig/components/siteConfigDrawer.js
+1
-1
webConfigForm.js
src/pages/webConfig/components/webConfigForm.js
+2
-2
index.js
src/pages/webConfig/index.js
+77
-20
utils.js
src/pages/webConfig/utils.js
+13
-4
api.js
src/services/webConfig/api.js
+3
-0
No files found.
src/components/BaseForm/index.js
View file @
0f897324
...
@@ -36,8 +36,8 @@ const BaseFormItem = itemOption => {
...
@@ -36,8 +36,8 @@ const BaseFormItem = itemOption => {
case
ITEM_TYPE
.
SELECT
:
case
ITEM_TYPE
.
SELECT
:
return
(
return
(
<
Select
{...
rest
}
>
<
Select
{...
rest
}
>
{
options
.
map
(
o
=>
(
{
options
.
map
(
(
o
,
i
)
=>
(
<
Select
.
Option
{...
o
}
/
>
<
Select
.
Option
key
=
{
`item_
${
i
}
`
}
{...
o
}
/
>
))}
))}
<
/Select
>
<
/Select
>
);
);
...
@@ -47,16 +47,16 @@ const BaseFormItem = itemOption => {
...
@@ -47,16 +47,16 @@ const BaseFormItem = itemOption => {
// eslint-disable-next-line no-case-declarations
// eslint-disable-next-line no-case-declarations
return
(
return
(
<
Radio
.
Group
{...
rest
}
>
<
Radio
.
Group
{...
rest
}
>
{
options
.
map
(
o
=>
(
{
options
.
map
(
(
o
,
i
)
=>
(
<
Radio
{...
o
}
/
>
<
Radio
{...
o
}
key
=
{
`item_
${
i
}
`
}
/
>
))}
))}
<
/Radio.Group
>
<
/Radio.Group
>
);
);
case
ITEM_TYPE
.
CHECK_BOX
:
case
ITEM_TYPE
.
CHECK_BOX
:
return
(
return
(
<
Checkbox
.
Group
{...
rest
}
>
<
Checkbox
.
Group
{...
rest
}
>
{
options
.
map
(
o
=>
(
{
options
.
map
(
(
o
,
i
)
=>
(
<
Checkbox
{...
o
}
/
>
<
Checkbox
key
=
{
`item_
${
i
}
`
}
{...
o
}
/
>
))}
))}
<
/Checkbox.Group
>
<
/Checkbox.Group
>
);
);
...
...
src/pages/webConfig/components/siteConfigDrawer.js
View file @
0f897324
...
@@ -37,7 +37,7 @@ export default props => {
...
@@ -37,7 +37,7 @@ export default props => {
});
});
return
;
return
;
}
}
values
.
alarmWays
=
values
.
alarmWays
.
join
(
','
)
;
values
.
alarmWays
=
values
.
alarmWays
?.
join
(
','
)
||
''
;
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line no-unused-expressions
onOk
&&
onOk
(
values
);
onOk
&&
onOk
(
values
);
}}
}}
...
...
src/pages/webConfig/components/webConfigForm.js
View file @
0f897324
...
@@ -6,7 +6,7 @@ import {
...
@@ -6,7 +6,7 @@ import {
getWebThemes
,
getWebThemes
,
}
from
'@/services/webConfig/api'
;
}
from
'@/services/webConfig/api'
;
import
{
Row
,
Col
}
from
'antd'
;
import
{
Row
,
Col
}
from
'antd'
;
import
{
getDefaultGetWebconfig
,
singleStyleData
}
from
'../utils'
;
import
{
getDefaultGetWebconfig
,
singleStyleData
,
webMode
}
from
'../utils'
;
const
WebConfigForm
=
props
=>
{
const
WebConfigForm
=
props
=>
{
const
{
const
{
...
@@ -106,7 +106,7 @@ const WebConfigForm = props => {
...
@@ -106,7 +106,7 @@ const WebConfigForm = props => {
labelCol
=
{{
span
:
6
}}
labelCol
=
{{
span
:
6
}}
wrapperCol
=
{{
span
:
14
}}
wrapperCol
=
{{
span
:
14
}}
onValuesChange
=
{
v
=>
{
onValuesChange
=
{
v
=>
{
if
(
form
&&
v
.
mode
===
'single'
)
{
if
(
form
&&
v
.
mode
===
webMode
.
single
)
{
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'
}]);
...
...
src/pages/webConfig/index.js
View file @
0f897324
...
@@ -6,10 +6,14 @@ import {
...
@@ -6,10 +6,14 @@ import {
getWebconfig
,
getWebconfig
,
postEditWebConfig
,
postEditWebConfig
,
postAddWebSite
,
postAddWebSite
,
deleteWebsite
,
}
from
'@/services/webConfig/api'
;
}
from
'@/services/webConfig/api'
;
import
{
ExclamationCircleOutlined
}
from
'@ant-design/icons'
;
import
Modal
from
'antd/lib/modal/Modal'
;
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'
;
import
{
defaultWebConfigObj
,
webMode
}
from
'./utils'
;
const
{
TabPane
}
=
Tabs
;
const
{
TabPane
}
=
Tabs
;
const
WebConfigPage
=
props
=>
{
const
WebConfigPage
=
props
=>
{
...
@@ -23,7 +27,8 @@ const WebConfigPage = props => {
...
@@ -23,7 +27,8 @@ const WebConfigPage = props => {
const
[
isEdit
,
setIsEdit
]
=
useState
(
true
);
const
[
isEdit
,
setIsEdit
]
=
useState
(
true
);
const
[
submitting
,
setSubmitting
]
=
useState
(
false
);
const
[
submitting
,
setSubmitting
]
=
useState
(
false
);
const
hasIntegerate
=
()
=>
webs
.
some
(
w
=>
w
.
mode
===
'integrate'
);
const
hasIntegerate
=
()
=>
webs
.
some
(
w
=>
w
.
id
.
startsWith
(
webMode
.
integration
));
useEffect
(()
=>
{
useEffect
(()
=>
{
let
canceled
=
{
cancel
:
false
};
let
canceled
=
{
cancel
:
false
};
...
@@ -81,32 +86,67 @@ const WebConfigPage = props => {
...
@@ -81,32 +86,67 @@ const WebConfigPage = props => {
});
});
};
};
const
renderTabPane
=
tabPaneItem
=>
(
const
handleDeleteWeb
=
(
webToOperate
,
closeModal
)
=>
{
<
TabPane
key
=
{
tabPaneItem
.
text
}
tab
=
{
tabPaneItem
.
text
}
>
// eslint-disable-next-line prefer-destructuring
<>
const
client
=
webToOperate
?.
id
?.
split
(
<
span
webToOperate
.
id
.
startsWith
(
webMode
.
single
)
className
=
{
styles
.
link
}
?
webMode
.
single
onClick
=
{()
=>
{
:
webMode
.
integration
,
setToEdit
({
...
configObj
});
)[
1
];
setConfigVisible
(
true
);
if
(
client
)
{
setIsEdit
(
true
);
deleteWebsite
(
client
)
}}
.
then
(
res
=>
{
>
if
(
res
.
success
)
{
查看
/
编辑网站配置
notification
.
success
({
<
/span
>
message
:
`删除网站
${
webToOperate
.
text
}
成功!`
,
<
/
>
duration
:
3
,
<
/TabPane
>
});
);
updateModuleTree
(
userMode
||
'super'
);
}
else
{
notification
.
error
({
message
:
res
.
message
||
`删除网站
${
webToOperate
.
text
}
失败`
,
});
}
// eslint-disable-next-line no-unused-expressions
closeModal
&&
closeModal
();
})
.
catch
(
err
=>
{
// eslint-disable-next-line no-console
console
.
error
(
err
);
notification
.
error
({
message
:
'删除网站失败!'
,
duration
:
5
});
// eslint-disable-next-line no-unused-expressions
closeModal
&&
closeModal
();
});
}
};
const
onEdit
=
(
targetKey
,
action
)
=>
{
const
onEdit
=
(
targetKey
,
action
)
=>
{
// console.log(targetKey, action); // action: add|remove
const
webToOperate
=
webs
.
find
(
w
=>
w
.
id
===
targetKey
);
switch
(
action
)
{
switch
(
action
)
{
case
'add'
:
case
'add'
:
setIsEdit
(
false
);
setIsEdit
(
false
);
setToEdit
(
{}
);
setToEdit
(
defaultWebConfigObj
);
setConfigVisible
(
true
);
setConfigVisible
(
true
);
break
;
break
;
case
'remove'
:
case
'remove'
:
Modal
.
confirm
({
title
:
'删除网站'
,
icon
:
<
ExclamationCircleOutlined
/>
,
content
:
(
<
span
>
删除网站
{
' '
}
<
span
style
=
{{
fontWeight
:
800
,
color
:
'#1890ff'
}}
>
{
webToOperate
.
text
}
<
/span>{' '
}
后将无法恢复
,
确认删除
?
<
/span
>
),
okText
:
'确认'
,
cancelText
:
'取消'
,
onOk
:
closeModal
=>
{
handleDeleteWeb
(
webToOperate
,
closeModal
);
},
});
break
;
break
;
default
:
default
:
}
}
...
@@ -117,7 +157,7 @@ const WebConfigPage = props => {
...
@@ -117,7 +157,7 @@ const WebConfigPage = props => {
};
};
const
handleTabChange
=
v
=>
{
const
handleTabChange
=
v
=>
{
setCurWeb
(
webs
.
find
(
w
=>
w
.
text
===
v
));
setCurWeb
(
webs
.
find
(
w
=>
w
.
id
===
v
));
};
};
const
handleSubmit
=
values
=>
{
const
handleSubmit
=
values
=>
{
...
@@ -156,6 +196,23 @@ const WebConfigPage = props => {
...
@@ -156,6 +196,23 @@ const WebConfigPage = props => {
});
});
};
};
const
renderTabPane
=
tabPaneItem
=>
(
<
TabPane
key
=
{
tabPaneItem
.
id
}
tab
=
{
tabPaneItem
.
text
}
>
<>
<
span
className
=
{
styles
.
link
}
onClick
=
{()
=>
{
setToEdit
({
...
configObj
});
setConfigVisible
(
true
);
setIsEdit
(
true
);
}}
>
查看
/
编辑网站配置
<
/span
>
<
/
>
<
/TabPane
>
);
return
(
return
(
<
PageContainer
>
<
PageContainer
>
<
div
className
=
{
styles
.
webConfigContainer
}
>
<
div
className
=
{
styles
.
webConfigContainer
}
>
...
...
src/pages/webConfig/utils.js
View file @
0f897324
import
{
ITEM_TYPE
}
from
'@/components/BaseForm'
;
import
{
ITEM_TYPE
}
from
'@/components/BaseForm'
;
export
const
webMode
=
{
single
:
'single'
,
integration
:
'integration'
,
};
const
typeContent
=
hasIntegerate
=>
{
const
typeContent
=
hasIntegerate
=>
{
if
(
hasIntegerate
)
{
if
(
hasIntegerate
)
{
return
[];
return
[];
}
}
return
[
return
[
{
{
value
:
'integrate'
,
value
:
webMode
.
integration
,
children
:
'集成网站'
,
children
:
'集成网站'
,
},
},
];
];
...
@@ -47,7 +51,12 @@ const isIntegerate = (mode, hasIntegerate) => {
...
@@ -47,7 +51,12 @@ const isIntegerate = (mode, hasIntegerate) => {
return
hasIntegerate
;
return
hasIntegerate
;
};
};
export
const
defaultWebConfigObj
=
{};
export
const
defaultWebConfigObj
=
{
mode
:
webMode
.
single
,
menu
:
'banner-left'
,
mdi
:
'MDI'
,
hideMap
:
true
,
};
export
const
getDefaultGetWebconfig
=
({
export
const
getDefaultGetWebconfig
=
({
initialValues
=
{},
initialValues
=
{},
...
@@ -81,11 +90,11 @@ export const getDefaultGetWebconfig = ({
...
@@ -81,11 +90,11 @@ export const getDefaultGetWebconfig = ({
mode
:
{
mode
:
{
label
:
'网站类型'
,
label
:
'网站类型'
,
formType
:
ITEM_TYPE
.
SINGLE_RADIO
,
formType
:
ITEM_TYPE
.
SINGLE_RADIO
,
initialValue
:
'single'
,
initialValue
:
webMode
.
single
,
disabled
:
isEdit
,
disabled
:
isEdit
,
options
:
[
options
:
[
{
{
value
:
'single'
,
value
:
webMode
.
single
,
children
:
'一般网站'
,
children
:
'一般网站'
,
},
},
].
concat
(
typeContent
(
hasIntegerate
)),
].
concat
(
typeContent
(
hasIntegerate
)),
...
...
src/services/webConfig/api.js
View file @
0f897324
...
@@ -59,3 +59,6 @@ export const postEditWebConfig = (config, isAdd = false) =>
...
@@ -59,3 +59,6 @@ export const postEditWebConfig = (config, isAdd = false) =>
);
);
export
const
postAddWebSite
=
config
=>
postEditWebConfig
(
config
,
true
);
export
const
postAddWebSite
=
config
=>
postEditWebConfig
(
config
,
true
);
export
const
deleteWebsite
=
client
=>
get
(
`
${
CITY_SERVICE
}
/OMS.svc/W4_DeleteWebsite?_version=9999`
,
{
client
});
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