Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
frontend
/
qqxb-self-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1f0bd934
authored
Jun 22, 2020
by
cocomilk2012
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
citylist
parent
322cd3d9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
19 deletions
src/components/common/cityList.vue
src/components/common/cityList.vue
View file @
1f0bd934
<
template
>
<div>
<van-picker
show-toolbar
title=
"标题"
:columns=
"columns"
@
change=
"onChange"
/>
<van-picker
show-toolbar
title=
"标题"
:columns=
"columns"
@
confirm=
"onConfirm"
/>
</div>
</
template
>
<
script
lang=
"ts"
>
...
...
@@ -15,18 +20,19 @@ import { Component } from "vue-property-decorator";
})
export
default
class
cityList
extends
Vue
{
private
data
:
any
=
""
;
private
province
:
any
=
""
;
//省份
private
city
:
any
=
[];
//市份
private
area
:
any
=
""
;
//区,县
private
columns
:
any
=
[
{
text
:
""
,
id
:
0
,
text
:
"请选择"
,
children
:
[
{
text
:
""
,
children
:
[{
text
:
""
}]
id
:
0
,
text
:
"请选择"
,
children
:
[{
id
:
0
,
text
:
"请选择"
}]
}
]
}
...
...
@@ -34,32 +40,67 @@ export default class cityList extends Vue {
created
()
{
this
.
$server
.
EmployeeService
.
getCityList
({}).
then
(
res
=>
{
this
.
data
=
res
;
//组建省数据
this
.
data
.
find
((
item
:
any
)
=>
{
let
obj
=
{};
if
(
item
.
parentId
==
0
)
{
this
.
province
=
{
id
:
item
.
id
,
text
:
item
.
name
,
id
:
item
.
id
children
:
[
{
id
:
0
,
text
:
"请选择"
,
children
:
[
{
id
:
0
,
text
:
"请选择"
}
]
}
]
};
this
.
columns
.
push
(
this
.
province
);
}
else
{
obj
=
{
text
:
item
.
name
,
id
:
item
.
id
,
parentId
:
item
.
parentId
};
this
.
city
.
push
(
obj
);
}
});
//组建市数据 [{"name":"北京市","id":1,"parentId":0}]
this
.
columns
.
forEach
((
element
:
any
)
=>
{
let
child
:
any
=
[];
this
.
data
.
forEach
((
data
:
any
)
=>
{
if
(
data
.
parentId
==
element
.
id
&&
element
.
id
>
0
)
{
child
.
push
({
id
:
data
.
id
,
text
:
data
.
name
,
children
:
[{
id
:
0
,
text
:
"请选择"
,
children
:
[]
}]
});
}
});
element
.
children
.
push
(...
child
);
});
//组建县级数据
this
.
columns
.
forEach
((
element
:
any
)
=>
{
element
.
children
.
forEach
((
child
:
any
)
=>
{
let
child_son
:
any
=
[];
this
.
data
.
forEach
((
data
:
any
)
=>
{
if
(
child
.
id
>
0
&&
child
.
id
==
data
.
parentId
)
{
child_son
.
push
({
id
:
data
.
id
,
text
:
data
.
name
,
children
:
[]
});
}
});
child
.
children
.
push
(...
child_son
);
});
});
});
}
onChange
(
picker
:
any
,
values
:
any
)
{
// console.log(values[0]);
// console.log(this.city)
// picker.setColumnValues(1, this.cityData(this.city,35));
picker
.
setColumnValues
(
2
,
this
.
city
);
picker
.
setColumnValues
(
1
,
this
.
city
);
getChildren
(
arr
:
any
)
{}
onConfirm
(
values
:
any
)
{
console
.
log
(
values
);
}
cityData
(
city
:
any
,
provinceId
:
any
)
{
// console.log(city)
...
...
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