Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fns_backend
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zhang Xiaojie
fns_backend
Commits
8b04f323
Commit
8b04f323
authored
Oct 21, 2021
by
chenqikuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复地址映射
parent
f02b0639
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
14 deletions
+49
-14
index.ts
src/service/AddressService/index.ts
+41
-8
index.ts
src/utils/StaffUtils/index.ts
+8
-6
No files found.
src/service/AddressService/index.ts
View file @
8b04f323
...
@@ -16,9 +16,37 @@ export default class AddressService {
...
@@ -16,9 +16,37 @@ export default class AddressService {
this
.
max_len_gps
=
10
this
.
max_len_gps
=
10
}
}
getGpses
(
data
:
{
addrs
:
string
[]
}):
Promise
<
string
[]
>
{
// getGpses(data: { addrs: string[] }): Promise<string[]> {
// return new Promise((resolve, reject) => {
// const resultList = [] as string[]
// if (data.addrs.length) {
// for (
// let i = 0;
// i < Math.ceil(data.addrs.length / this.max_len_gps);
// ++i
// ) {
// const reqList = data.addrs.slice(
// i * this.max_len_gps,
// i * this.max_len_gps + this.max_len_gps,
// )
// this.__getGpses(reqList).then((ret) => {
// if (ret.code === 200) {
// resultList.push(...ret.data.gps)
// if (resultList.length === data.addrs.length) {
// resolve(resultList)
// }
// } else {
// reject('解析错误')
// }
// })
// }
// }
// })
// }
getGpses2
(
data
:
{
addrs
:
string
[]
}):
Promise
<
{
[
props
:
string
]:
string
}
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
resultList
=
[]
as
string
[]
const
theMap
=
{}
as
{
[
props
:
string
]:
string
}
if
(
data
.
addrs
.
length
)
{
if
(
data
.
addrs
.
length
)
{
for
(
for
(
let
i
=
0
;
let
i
=
0
;
...
@@ -31,9 +59,14 @@ export default class AddressService {
...
@@ -31,9 +59,14 @@ export default class AddressService {
)
)
this
.
__getGpses
(
reqList
).
then
((
ret
)
=>
{
this
.
__getGpses
(
reqList
).
then
((
ret
)
=>
{
if
(
ret
.
code
===
200
)
{
if
(
ret
.
code
===
200
)
{
resultList
.
push
(...
ret
.
data
.
gps
)
const
locations
=
reqList
if
(
resultList
.
length
===
data
.
addrs
.
length
)
{
const
gpses
=
ret
.
data
.
gps
resolve
(
resultList
)
locations
.
map
((
location
,
index
)
=>
{
theMap
[
location
]
=
gpses
[
index
]
})
if
(
Object
.
keys
(
theMap
).
length
===
data
.
addrs
.
length
)
{
resolve
(
theMap
)
}
}
}
else
{
}
else
{
reject
(
'解析错误'
)
reject
(
'解析错误'
)
...
@@ -47,7 +80,7 @@ export default class AddressService {
...
@@ -47,7 +80,7 @@ export default class AddressService {
if
(
addrs
.
length
>
10
)
{
if
(
addrs
.
length
>
10
)
{
throw
new
Error
(
'长度超过10'
)
throw
new
Error
(
'长度超过10'
)
}
else
{
}
else
{
return
baseAxios
<
{
gps
:
string
[]}
>
({
return
baseAxios
<
{
gps
:
string
[]
}
>
({
url
:
this
.
prefix
+
'/getGps'
,
url
:
this
.
prefix
+
'/getGps'
,
method
:
'post'
,
method
:
'post'
,
data
:
{
data
:
{
...
@@ -71,7 +104,7 @@ export default class AddressService {
...
@@ -71,7 +104,7 @@ export default class AddressService {
// })
// })
// }
// }
getOutlets
(
data
:
{
level
?:
number
;
id
?:
number
,
branch_name
?:
string
})
{
getOutlets
(
data
:
{
level
?:
number
;
id
?:
number
;
branch_name
?:
string
})
{
return
baseAxios
<
iOutLetDetail
[]
>
({
return
baseAxios
<
iOutLetDetail
[]
>
({
url
:
'/address/getOutlets'
,
url
:
'/address/getOutlets'
,
method
:
'post'
,
method
:
'post'
,
...
@@ -119,7 +152,7 @@ export default class AddressService {
...
@@ -119,7 +152,7 @@ export default class AddressService {
url
:
'/address/add'
,
url
:
'/address/add'
,
method
:
'post'
,
method
:
'post'
,
data
:
{
data
:
{
outlets_req
:
[
data
]
outlets_req
:
[
data
]
,
},
},
})
})
}
}
...
...
src/utils/StaffUtils/index.ts
View file @
8b04f323
...
@@ -33,14 +33,14 @@ function getAddressList(dataList: any[]) {
...
@@ -33,14 +33,14 @@ function getAddressList(dataList: any[]) {
}
}
async
function
getAddressLalonObj
(
locationList
:
string
[])
{
async
function
getAddressLalonObj
(
locationList
:
string
[])
{
const
rets
=
await
AddressService
.
getInstance
().
getGpses
({
const
rets
=
await
AddressService
.
getInstance
().
getGpses
2
({
addrs
:
locationList
,
addrs
:
locationList
,
})
})
let
obj
=
{}
as
any
//
let obj = {} as any
locationList
.
forEach
((
item
,
index
)
=>
{
//
locationList.forEach((item, index) => {
obj
[
item
]
=
rets
[
index
]
//
obj[item] = rets[index]
})
//
})
return
obj
return
rets
}
}
function
formatPositionToNumber
(
str
:
string
)
{
function
formatPositionToNumber
(
str
:
string
)
{
...
@@ -181,9 +181,11 @@ export const handle建设银行excelFileChange = (e: Event) => {
...
@@ -181,9 +181,11 @@ export const handle建设银行excelFileChange = (e: Event) => {
const list = (parseJSYHSheet(
const list = (parseJSYHSheet(
Sheets[SheetsKeys[0]],
Sheets[SheetsKeys[0]],
) as unknown) as any[]
) as unknown) as any[]
console.log(list, 'show list');
const locationList = getAddressList((list as unknown) as any)
const locationList = getAddressList((list as unknown) as any)
console.log(JSON.stringify(locationList))
console.log(JSON.stringify(locationList))
getAddressLalonObj(locationList).then((addressLalonObj) => {
getAddressLalonObj(locationList).then((addressLalonObj) => {
console.log(addressLalonObj,' show addressLalonObj');
list.forEach((data) => {
list.forEach((data) => {
data.la_lon = addressLalonObj[data.location]
data.la_lon = addressLalonObj[data.location]
})
})
...
...
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