Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivWeb
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
CivWeb
Commits
d7d60fc6
Commit
d7d60fc6
authored
Sep 11, 2023
by
杨思琦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 站点获取修改
parent
4f07d3f9
Pipeline
#78708
passed with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
145 additions
and
151 deletions
+145
-151
BasicLayout.js
src/layouts/BasicLayout.js
+6
-3
Site.js
src/layouts/Site.js
+139
-148
No files found.
src/layouts/BasicLayout.js
View file @
d7d60fc6
...
@@ -326,6 +326,7 @@ const Layout = props => {
...
@@ -326,6 +326,7 @@ const Layout = props => {
const
[
cityData
,
setCityData
]
=
useState
({});
const
[
cityData
,
setCityData
]
=
useState
({});
const
[
siteLoading
,
setSiteLoading
]
=
useState
(
false
);
const
[
siteLoading
,
setSiteLoading
]
=
useState
(
false
);
const
[
siteAction
,
setSiteAction
]
=
useState
(()
=>
new
Site
(
props
,
setSiteLoading
));
const
[
siteAction
,
setSiteAction
]
=
useState
(()
=>
new
Site
(
props
,
setSiteLoading
));
const
[
cityLoading
,
setCityLoading
]
=
useState
(
false
);
const
[
menuLoading
,
setMenuLoading
]
=
useState
(
true
);
const
[
menuLoading
,
setMenuLoading
]
=
useState
(
true
);
const
[
subLoading
,
setSubLoading
]
=
useState
(
true
);
const
[
subLoading
,
setSubLoading
]
=
useState
(
true
);
const
[
initWebContent
,
setInitWebContent
]
=
useState
(
false
);
const
[
initWebContent
,
setInitWebContent
]
=
useState
(
false
);
...
@@ -387,13 +388,15 @@ const Layout = props => {
...
@@ -387,13 +388,15 @@ const Layout = props => {
props
.
global
.
userInfo
&&
props
.
global
.
userInfo
&&
props
.
global
.
userInfo
.
token
!==
null
&&
props
.
global
.
userInfo
.
token
!==
null
&&
props
.
global
.
userInfo
.
loginName
&&
props
.
global
.
userInfo
.
loginName
&&
Object
.
keys
(
cityData
).
length
===
0
Object
.
keys
(
cityData
).
length
===
0
&&
!
cityLoading
)
{
)
{
siteAction
.
getCityStationsForUser
().
then
(
res
=>
{
setCityLoading
(
true
);
siteAction
.
getCityStationsForUser
(
props
.
global
.
userInfo
?.
Groups
).
then
(
res
=>
{
setCityData
(
res
);
setCityData
(
res
);
});
});
}
}
},
[
cityData
,
props
.
global
,
props
.
global
.
userInfo
,
siteAction
]);
},
[
cityData
,
cityLoading
,
props
.
global
,
props
.
global
.
userInfo
,
siteAction
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
window
?.
globalConfig
?.
isIntegration
>=
1
)
{
if
(
window
?.
globalConfig
?.
isIntegration
>=
1
)
{
...
...
src/layouts/Site.js
View file @
d7d60fc6
...
@@ -53,167 +53,149 @@ class Site {
...
@@ -53,167 +53,149 @@ class Site {
}
}
}
}
getCityStationsForUser
()
{
getCityStationsForUser
(
response
)
{
const
{
token
}
=
this
.
globalConfig
.
userInfo
;
const
self
=
this
;
const
self
=
this
;
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
// eslint-disable-next-line no-undef
// eslint-disable-next-line no-undef
appService
if
(
response
)
{
.
getAllGroupsInfoForUser
({
const
result
=
response
||
[];
token
,
let
city
=
self
.
weatherCity
;
'request.preventCache'
:
new
Date
().
getTime
(),
let
arr
=
[];
ignoreSite
:
true
,
self
.
globalConfig
.
userInfo
.
groupType
=
''
;
})
self
.
globalConfig
.
userInfo
.
Groups
=
result
;
.
then
(
res
=>
{
// eslint-disable-next-line no-array-constructor
if
(
res
&&
res
.
code
===
0
)
{
self
.
globalConfig
.
userInfo
.
Industries
=
new
Array
();
const
result
=
res
.
data
||
[];
if
(
self
.
globalConfig
.
userInfo
.
Groups
&&
self
.
globalConfig
.
userInfo
.
Groups
.
length
)
{
let
city
=
self
.
weatherCity
;
self
.
globalConfig
.
userInfo
.
Groups
.
forEach
(
group
=>
{
let
arr
=
[];
if
(
group
.
industry
&&
self
.
globalConfig
.
userInfo
.
Industries
.
indexOf
(
group
.
industry
)
<
0
)
self
.
globalConfig
.
userInfo
.
groupType
=
''
;
self
.
globalConfig
.
userInfo
.
Industries
.
push
(
group
.
industry
);
self
.
globalConfig
.
userInfo
.
Groups
=
result
;
});
// eslint-disable-next-line no-array-constructor
}
self
.
globalConfig
.
userInfo
.
Industries
=
new
Array
();
if
(
if
(
self
.
globalConfig
.
userInfo
.
Groups
&&
self
.
globalConfig
.
userInfo
.
Groups
.
length
)
{
self
.
globalConfig
.
userInfo
&&
self
.
globalConfig
.
userInfo
.
Groups
.
forEach
(
group
=>
{
self
.
globalConfig
.
userInfo
.
site
&&
if
(
group
.
industry
&&
self
.
globalConfig
.
userInfo
.
Industries
.
indexOf
(
group
.
industry
)
<
0
)
self
.
globalConfig
.
userInfo
.
Groups
&&
self
.
globalConfig
.
userInfo
.
Industries
.
push
(
group
.
industry
);
self
.
globalConfig
.
userInfo
.
Groups
.
length
});
)
{
}
// eslint-disable-next-line no-underscore-dangle
if
(
const
_indestryItem
=
self
.
globalConfig
.
userInfo
.
Groups
.
find
(
self
.
globalConfig
.
userInfo
&&
// eslint-disable-next-line eqeqeq
self
.
globalConfig
.
userInfo
.
site
&&
item
=>
item
.
site
===
self
.
globalConfig
.
userInfo
.
site
,
self
.
globalConfig
.
userInfo
.
Groups
&&
);
self
.
globalConfig
.
userInfo
.
Groups
.
length
if
(
_indestryItem
&&
_indestryItem
.
industry
)
{
)
{
self
.
globalConfig
.
Industry
=
_indestryItem
.
industry
;
// eslint-disable-next-line no-underscore-dangle
}
const
_indestryItem
=
self
.
globalConfig
.
userInfo
.
Groups
.
find
(
}
// eslint-disable-next-line eqeqeq
item
=>
item
.
site
===
self
.
globalConfig
.
userInfo
.
site
,
);
if
(
_indestryItem
&&
_indestryItem
.
industry
)
{
self
.
globalConfig
.
Industry
=
_indestryItem
.
industry
;
}
}
let
allStation
=
[];
let
allStation
=
[];
let
projectStation
=
[];
let
projectStation
=
[];
self
.
showStations
=
[];
self
.
showStations
=
[];
if
(
self
.
globalConfig
.
Industry
)
{
if
(
self
.
globalConfig
.
Industry
)
{
allStation
=
result
.
filter
(
item
=>
item
.
industry
===
self
.
globalConfig
.
Industry
);
allStation
=
result
.
filter
(
item
=>
item
.
industry
===
self
.
globalConfig
.
Industry
);
self
.
showStations
=
allStation
.
filter
(
item
=>
item
.
promoteIndex
&&
item
.
promoteIndex
>
0
);
self
.
showStations
=
allStation
.
filter
(
item
=>
item
.
promoteIndex
&&
item
.
promoteIndex
>
0
);
projectStation
=
allStation
.
filter
(
item
=>
!
item
.
promoteIndex
);
projectStation
=
allStation
.
filter
(
item
=>
!
item
.
promoteIndex
);
}
else
{
}
else
{
allStation
=
result
;
allStation
=
result
;
}
}
if
(
allStation
.
length
)
{
if
(
allStation
.
length
)
{
let
allChoice
=
false
;
let
allChoice
=
false
;
allStation
.
forEach
(
val
=>
{
allStation
.
forEach
(
val
=>
{
if
(
val
.
promoteIndex
===
0
)
{
if
(
val
.
promoteIndex
===
0
)
{
allChoice
=
true
;
allChoice
=
true
;
}
});
if
(
!
allChoice
)
{
// me.$el.find('#changeCityWays').hide();
// me.$el.find('.LMBcityBox').hide();
// me.$el.find('div.cities').css('min-width', 'initial');
// me.$el.find('.focusStations').addClass('LMBcolumnList');
}
if
(
allStation
.
length
>
120
)
{
// $(me.el).find("div.cities div.cityContent").css("height", '335px');
}
// eslint-disable-next-line no-underscore-dangle
let
_enterprise
=
null
;
if
(
self
.
globalConfig
.
userInfo
.
site
&&
self
.
globalConfig
.
userInfo
.
site
.
length
)
{
_enterprise
=
allStation
.
filter
(
enterprise
=>
// eslint-disable-next-line eqeqeq
enterprise
.
site
===
self
.
globalConfig
.
userInfo
.
site
,
);
}
if
(
_enterprise
&&
_enterprise
.
length
)
{
if
(
_enterprise
[
0
].
groupName
.
indexOf
(
'演示'
>=
0
))
{
arr
[
0
]
=
_enterprise
[
0
].
groupName
;
}
else
{
arr
=
_enterprise
[
0
].
city
.
split
(
'/'
);
}
const
tmp
=
_enterprise
[
0
].
city
.
split
(
'/'
)[
1
];
city
=
tmp
.
substr
(
0
,
tmp
.
length
-
1
);
self
.
globalConfig
.
userInfo
.
groupType
=
_enterprise
[
0
].
groupType
;
}
else
{
arr
=
allStation
[
0
].
city
.
split
(
'/'
);
const
tmp
=
arr
[
1
];
city
=
tmp
.
substr
(
0
,
tmp
.
length
-
1
);
self
.
globalConfig
.
userInfo
.
groupType
=
allStation
[
0
].
groupType
;
}
}
if
(
allStation
.
length
>
0
)
{
self
.
currentStationName
=
arr
[
arr
.
length
-
1
];
self
.
citySelector
=
self
.
AvailableofRegionName
(
projectStation
);
self
.
siteCityList
=
self
.
buildCitySelectTemple
(
projectStation
);
}
}
// 只有演示环境出现友好提示
});
if
(
allStation
.
length
===
self
.
showStations
.
length
)
{
if
(
!
allChoice
)
{
self
.
isOnlyDisplay
=
true
;
// me.$el.find('#changeCityWays').hide();
// me.$el.find('.LMBcityBox').hide();
// me.$el.find('div.cities').css('min-width', 'initial');
// me.$el.find('.focusStations').addClass('LMBcolumnList');
}
if
(
allStation
.
length
>
120
)
{
// $(me.el).find("div.cities div.cityContent").css("height", '335px');
}
// eslint-disable-next-line no-underscore-dangle
let
_enterprise
=
null
;
if
(
self
.
globalConfig
.
userInfo
.
site
&&
self
.
globalConfig
.
userInfo
.
site
.
length
)
{
_enterprise
=
allStation
.
filter
(
enterprise
=>
// eslint-disable-next-line eqeqeq
enterprise
.
site
===
self
.
globalConfig
.
userInfo
.
site
,
);
}
if
(
_enterprise
&&
_enterprise
.
length
)
{
if
(
_enterprise
[
0
].
groupName
.
indexOf
(
'演示'
>=
0
))
{
arr
[
0
]
=
_enterprise
[
0
].
groupName
;
}
else
{
}
else
{
self
.
citySelector
=
self
.
AvailableofRegionName
(
projectStation
);
arr
=
_enterprise
[
0
].
city
.
split
(
'/'
);
self
.
siteCityList
=
self
.
buildCitySelectTemple
(
projectStation
);
}
}
const
tmp
=
_enterprise
[
0
].
city
.
split
(
'/'
)[
1
];
city
=
tmp
.
substr
(
0
,
tmp
.
length
-
1
);
self
.
globalConfig
.
userInfo
.
groupType
=
_enterprise
[
0
].
groupType
;
}
else
{
arr
=
allStation
[
0
].
city
.
split
(
'/'
);
const
tmp
=
arr
[
1
];
city
=
tmp
.
substr
(
0
,
tmp
.
length
-
1
);
self
.
globalConfig
.
userInfo
.
groupType
=
allStation
[
0
].
groupType
;
}
}
if
(
allStation
.
length
>
0
)
{
self
.
currentStationName
=
arr
[
arr
.
length
-
1
];
self
.
citySelector
=
self
.
AvailableofRegionName
(
projectStation
);
self
.
siteCityList
=
self
.
buildCitySelectTemple
(
projectStation
);
}
// 只有演示环境出现友好提示
if
(
allStation
.
length
===
self
.
showStations
.
length
)
{
self
.
isOnlyDisplay
=
true
;
}
else
{
self
.
citySelector
=
self
.
AvailableofRegionName
(
projectStation
);
self
.
siteCityList
=
self
.
buildCitySelectTemple
(
projectStation
);
}
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line no-unused-expressions
self
.
updateConfig
&&
self
.
updateConfig
(
self
.
globalConfig
);
self
.
updateConfig
&&
self
.
updateConfig
(
self
.
globalConfig
);
const
stations
=
self
.
insertYSStation
();
const
stations
=
self
.
insertYSStation
();
if
(
city
)
{
if
(
city
)
{
// eslint-disable-next-line no-undef
// eslint-disable-next-line no-undef
appService
appService
.
getWeather
({
.
getWeather
({
city
,
city
,
'request.preventCache'
:
new
Date
().
getTime
(),
'request.preventCache'
:
new
Date
().
getTime
(),
ignoreSite
:
true
,
ignoreSite
:
true
,
})
})
// eslint-disable-next-line no-shadow
// eslint-disable-next-line no-shadow
.
then
(
res
=>
{
.
then
(
res
=>
{
if
(
res
.
say
.
statusCode
===
ERR_OK
)
{
if
(
res
.
say
.
statusCode
===
ERR_OK
)
{
const
firtValue
=
res
.
getMe
[
0
];
const
firtValue
=
res
.
getMe
[
0
];
if
(
firtValue
.
cityName
)
{
if
(
firtValue
.
cityName
)
{
const
text
=
firtValue
.
forcastFirst
.
split
(
' '
)[
1
];
const
text
=
firtValue
.
forcastFirst
.
split
(
' '
)[
1
];
const
imgPath
=
firtValue
.
presentPictureFirst
.
replace
(
'gif'
,
'svg'
);
const
imgPath
=
firtValue
.
presentPictureFirst
.
replace
(
'gif'
,
'svg'
);
resolve
({
stations
,
allStation
,
weathers
:
{
icon
:
`https://panda-water.cn/web4/assets/images/weather2/
${
imgPath
}
`
,
text
:
`
${
text
}
${
firtValue
.
temperatureFirst
}
`
,
},
siteCityList
:
self
.
siteCityList
,
citySelector
:
self
.
citySelector
,
currentStationName
:
self
.
currentStationName
,
});
}
}
else
{
resolve
({
stations
,
allStation
,
siteCityList
:
self
.
siteCityList
,
citySelector
:
self
.
citySelector
,
currentStationName
:
self
.
currentStationName
,
weathers
:
{},
});
}
})
.
catch
(
error
=>
{
resolve
({
resolve
({
stations
,
stations
,
allStation
,
allStation
,
currentStationName
:
self
.
currentStationName
,
weathers
:
{
weathers
:
{},
icon
:
`https://panda-water.cn/web4/assets/images/weather2/
${
imgPath
}
`
,
text
:
`
${
text
}
${
firtValue
.
temperatureFirst
}
`
,
},
siteCityList
:
self
.
siteCityList
,
siteCityList
:
self
.
siteCityList
,
citySelector
:
self
.
citySelector
,
citySelector
:
self
.
citySelector
,
currentStationName
:
self
.
currentStationName
,
});
});
}
}
else
{
resolve
({
stations
,
allStation
,
siteCityList
:
self
.
siteCityList
,
citySelector
:
self
.
citySelector
,
currentStationName
:
self
.
currentStationName
,
weathers
:
{},
});
});
}
else
{
}
})
.
catch
(
error
=>
{
resolve
({
resolve
({
stations
,
stations
,
allStation
,
allStation
,
...
@@ -222,9 +204,18 @@ class Site {
...
@@ -222,9 +204,18 @@ class Site {
siteCityList
:
self
.
siteCityList
,
siteCityList
:
self
.
siteCityList
,
citySelector
:
self
.
citySelector
,
citySelector
:
self
.
citySelector
,
});
});
}
});
}
}
else
{
});
resolve
({
stations
,
allStation
,
currentStationName
:
self
.
currentStationName
,
weathers
:
{},
siteCityList
:
self
.
siteCityList
,
citySelector
:
self
.
citySelector
,
});
}
}
});
});
}
}
...
...
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