Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
scrm-micro-settings
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c1579bd0
authored
Apr 21, 2022
by
匡雅琴
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
省市组件
1 parent
adedc9ff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
38 deletions
src/components/province-city/index.vue
src/views/account/components/baseInfo.vue
src/views/baseInfo/editInfo.vue
src/components/province-city/index.vue
View file @
c1579bd
<
template
>
<div>
<el-form
ref=
"provinceForm"
:model=
"provinceForm"
label-width=
"80px"
inline=
"true"
class=
"province"
>
<el-select
v-model=
"provinceForm.provinceName"
clearable
placeholder=
"选择省份
"
@
change=
"selectProvince"
class=
"select-padding"
>
<el-form
ref=
"provinceForm"
:model=
"provinceForm"
inline=
"true"
class=
"province"
>
<el-select
:size=
"size"
v-model=
"provinceForm.provinceName"
clearable
placeholder=
"选择省份"
:style=
"
{ width: defaultWidth }
" @change="selectProvince" class="select-padding">
<el-option
v-for=
"item in AllData"
:key=
"item.adcode"
:label=
"item.name"
:value=
"item.name"
@
click
.
native=
"selectProvince(item)"
></el-option>
</el-select>
<el-select
v-model=
"provinceForm.cityName"
clearable
placeholder=
"选择您所在的市"
style=
"width: 250px
"
@
change=
"selectCity"
class=
"select-padding"
>
<el-select
:size=
"size"
v-model=
"provinceForm.cityName"
clearable
placeholder=
"选择市"
:style=
"
{ width: defaultWidth }
" @change="selectCity" class="select-padding">
<el-option
v-for=
"item in cityList"
:key=
"item.adcode"
:label=
"item.name"
:value=
"item.name"
@
click
.
native=
"selectCity(item)"
></el-option>
</el-select>
<el-select
v-if=
"subdistrict == 3"
:size=
"size"
v-model=
"provinceForm.townName"
clearable
placeholder=
"选择区"
:style=
"
{ width: defaultWidth }" @change="selectTown" class="select-padding">
<el-option
v-for=
"item in townList"
:key=
"item.adcode"
:label=
"item.name"
:value=
"item.name"
@
click
.
native=
"selectTown(item)"
></el-option>
</el-select>
</el-form>
</div>
</
template
>
<
script
>
let
map
import
{
provinceList
}
from
'./index'
export
default
{
name
:
'Province'
,
props
:
{
subdistrict
:
{
type
:
Number
,
default
:
2
},
defaultWidth
:
{
type
:
String
,
default
:
'150px'
}
},
data
()
{
return
{
provinceList
:
provinceList
(),
AllData
:
[],
cityList
:
[{
adcode
:
''
,
name
:
'全部'
}],
townList
:
[{
adcode
:
''
,
name
:
'全部'
}],
provinceForm
:
{
provinceName
:
''
,
// 省值
cityName
:
''
,
// 市值
townName
:
''
,
provinceCode
:
''
,
cityCode
:
''
cityCode
:
''
,
townCode
:
''
}
}
},
mounted
()
{},
mounted
()
{
this
.
mapInit
()
},
methods
:
{
// 省市回显
init
(
province
,
city
)
{
this
.
provinceForm
=
{
provinceName
:
province
,
cityName
:
city
}
this
.
mapInit
(
province
,
city
)
// this.mapInit(province, city)
if
(
province
)
{
this
.
AllData
.
map
(
item
=>
{
if
(
item
.
name
.
indexOf
(
province
)
!=
-
1
)
{
this
.
provinceForm
.
provinceName
=
item
.
name
this
.
cityList
=
item
.
districtList
this
.
provinceForm
.
provinceCode
=
item
.
adcode
this
.
cityList
.
map
(
itm
=>
{
if
(
itm
.
name
.
indexOf
(
city
)
!=
-
1
)
{
this
.
provinceForm
.
cityCode
=
itm
.
adcode
this
.
provinceForm
.
cityName
=
itm
.
name
}
})
}
})
}
},
// 选择省
selectProvince
(
val
)
{
this
.
provinceForm
.
cityName
=
''
this
.
cityList
=
val
.
districtList
this
.
$emit
(
'
ge
tProvince'
,
val
.
name
,
val
.
adcode
)
this
.
$emit
(
'
selec
tProvince'
,
val
.
name
,
val
.
adcode
)
},
// 选择市
selectCity
(
val
)
{
this
.
$emit
(
'getCity'
,
val
.
name
,
val
.
adcode
)
this
.
provinceForm
.
townName
=
''
this
.
townList
=
val
.
districtList
this
.
$emit
(
'selectCity'
,
val
.
name
,
val
.
adcode
)
},
// 选择区
selectTown
(
val
)
{
this
.
$emit
(
'selectTown'
,
val
.
name
,
val
.
adcode
)
},
mapInit
(
provinceName
,
cityName
)
{
mapInit
()
{
map
=
new
AMap
.
Map
(
'district'
,
{
resizeEnable
:
true
})
AMap
.
plugin
([
'AMap.DistrictSearch'
],
()
=>
{
var
opts
=
{
subdistrict
:
3
,
//返回下一级行政区
subdistrict
:
this
.
subdistrict
,
//返回下一级行政区
level
:
'city'
,
//查询的范围
showbiz
:
true
//查询行政级别为 市
}
var
districtSearch
=
new
AMap
.
DistrictSearch
(
opts
)
districtSearch
.
search
(
'中国'
,
(
status
,
result
)
=>
{
this
.
AllData
=
result
.
districtList
[
0
].
districtList
if
(
provinceName
)
{
this
.
AllData
.
map
(
item
=>
{
if
(
item
.
name
.
indexOf
(
provinceName
)
!=
-
1
)
{
this
.
provinceForm
.
provinceName
=
item
.
name
this
.
cityList
=
item
.
districtList
this
.
provinceForm
.
provinceCode
=
item
.
adcode
this
.
cityList
.
map
(
itm
=>
{
if
(
itm
.
name
.
indexOf
(
cityName
)
!=
-
1
)
{
this
.
provinceForm
.
cityCode
=
itm
.
adcode
this
.
provinceForm
.
cityName
=
itm
.
name
// console.log(itm.name)
// this.$set(this.provinceForm, 'cityName', itm.name)
}
})
}
})
}
// if (provinceName) {
// this.AllData.map(item => {
// if (item.name.indexOf(provinceName) != -1) {
// this.provinceForm.provinceName = item.name
// this.cityList = item.districtList
// this.provinceForm.provinceCode = item.adcode
// this.cityList.map(itm => {
// if (itm.name.indexOf(cityName) != -1) {
// this.provinceForm.cityCode = itm.adcode
// this.provinceForm.cityName = itm.name
// }
// })
// }
// })
// }
})
})
}
...
...
src/views/account/components/baseInfo.vue
View file @
c1579bd
...
...
@@ -48,7 +48,7 @@
<el-col
:span=
"24"
>
<el-form-item
size=
"small"
label=
"商户地址"
class=
"form-row"
>
<!-- 省市 -->
<ProvinceCity
ref=
"provinceForm"
@
getProvince=
"getProvince"
@
getCity=
"ge
tCity"
></ProvinceCity>
<ProvinceCity
ref=
"provinceForm"
@
selectProvince=
"selectProvince"
@
selectCity=
"selec
tCity"
></ProvinceCity>
<el-input
readonly
v-model=
"accountAddForm.merchantAddress"
placeholder=
"请选择商户地址"
></el-input>
<el-button
type=
"primary"
class=
"form-btn"
@
click=
"hanleSelectMap"
>
选择地址
</el-button>
</el-form-item>
...
...
@@ -315,7 +315,7 @@ export default {
this
.
$refs
.
provinceForm
.
init
(
province
,
city
)
},
// 获取省
ge
tProvince
(
provinceName
,
provinceCode
)
{
selec
tProvince
(
provinceName
,
provinceCode
)
{
this
.
$set
(
this
.
accountAddForm
,
'merchantAddress'
,
''
)
// 强制更新 merchantAddress
this
.
$forceUpdate
()
...
...
@@ -323,7 +323,7 @@ export default {
this
.
accountAddForm
.
provinceCode
=
provinceCode
},
// 获取市
ge
tCity
(
cityName
,
cityCode
)
{
selec
tCity
(
cityName
,
cityCode
)
{
this
.
accountAddForm
.
cityName
=
cityName
this
.
accountAddForm
.
cityCode
=
cityCode
this
.
$set
(
this
.
accountAddForm
,
'merchantAddress'
,
''
)
...
...
@@ -383,8 +383,6 @@ export default {
mounted
()
{
this
.
getUserInfo
()
// this.$refs.provinceForm.getProvinceList()
this
.
$refs
.
provinceForm
.
mapInit
()
}
}
</
script
>
...
...
src/views/baseInfo/editInfo.vue
View file @
c1579bd
...
...
@@ -12,7 +12,7 @@
<div
class=
"information-form-box"
>
<el-form
ref=
"baseForm"
:model=
"infoForm"
class=
"account-body-form"
label-width=
"120px"
>
<el-form-item
size=
"small"
label=
"商户地址"
class=
"map-row"
>
<Province
ref=
"provinceForm"
@
getProvince=
"getProvince"
@
getCity=
"ge
tCity"
></Province>
<Province
ref=
"provinceForm"
:subdistrict=
"subdistrict"
@
selectProvince=
"selectProvince"
@
selectCity=
"selec
tCity"
></Province>
<el-input
class=
"input-width"
v-model=
"infoForm.merchantAddress"
placeholder=
"请选择商户地址"
readonly=
"readonly"
></el-input>
<el-button
@
click=
"hanleSelectMap"
type=
"primary"
>
选择地址
</el-button>
</el-form-item>
...
...
@@ -64,6 +64,7 @@ export default {
},
data
()
{
return
{
subdistrict
:
2
,
checkedAll
:
false
,
filterText
:
''
,
dialogMapVisible
:
false
,
...
...
@@ -138,7 +139,7 @@ export default {
this
.
$refs
.
brandListTree
.
getCheckedArr
=
brandName
}
// 省市回显
this
.
$refs
.
provinceForm
.
mapI
nit
(
this
.
infoForm
.
provinceName
,
this
.
infoForm
.
cityName
)
this
.
$refs
.
provinceForm
.
i
nit
(
this
.
infoForm
.
provinceName
,
this
.
infoForm
.
cityName
)
if
(
!
this
.
infoForm
.
merchantBrandMain
)
{
this
.
infoForm
.
merchantBrandMain
=
[]
}
else
{
...
...
@@ -173,6 +174,7 @@ export default {
var
fullAddress
=
this
.
$refs
.
mapForm
.
geocoderAddress
.
addressComponent
// 获取省市
var
provincecode
=
this
.
$refs
.
mapForm
.
geocoderAddress
.
adcode
console
.
log
(
fullAddress
)
var
province
=
fullAddress
.
province
var
city
=
fullAddress
.
city
const
municipalities
=
[
'北京市'
,
'天津市'
,
'上海市'
,
'重庆市'
]
...
...
@@ -200,13 +202,13 @@ export default {
this
.
$refs
.
provinceForm
.
init
(
province
,
city
)
},
// 获取省
ge
tProvince
(
provinceName
,
provinceCode
)
{
selec
tProvince
(
provinceName
,
provinceCode
)
{
this
.
infoForm
.
merchantAddress
=
''
this
.
infoForm
.
provinceName
=
provinceName
this
.
infoForm
.
provinceCode
=
provinceCode
},
// 获取市
ge
tCity
(
cityName
,
cityCode
)
{
selec
tCity
(
cityName
,
cityCode
)
{
this
.
infoForm
.
cityName
=
cityName
this
.
infoForm
.
cityCode
=
cityCode
this
.
infoForm
.
merchantAddress
=
''
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment