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
Hide 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
>
<
template
>
<div>
<div>
<van-picker
show-toolbar
title=
"标题"
:columns=
"columns"
@
change=
"onChange"
/>
<van-picker
show-toolbar
title=
"标题"
:columns=
"columns"
@
confirm=
"onConfirm"
/>
</div>
</div>
</
template
>
</
template
>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
...
@@ -15,18 +20,19 @@ import { Component } from "vue-property-decorator";
...
@@ -15,18 +20,19 @@ import { Component } from "vue-property-decorator";
})
})
export
default
class
cityList
extends
Vue
{
export
default
class
cityList
extends
Vue
{
private
data
:
any
=
""
;
private
data
:
any
=
""
;
private
province
:
any
=
""
;
//省份
private
province
:
any
=
""
;
//省份
private
city
:
any
=
[];
//市份
private
city
:
any
=
[];
//市份
private
area
:
any
=
""
;
//区,县
private
area
:
any
=
""
;
//区,县
private
columns
:
any
=
[
private
columns
:
any
=
[
{
{
text
:
""
,
id
:
0
,
text
:
"请选择"
,
children
:
[
children
:
[
{
{
text
:
""
,
id
:
0
,
children
:
[{
text
:
""
}]
text
:
"请选择"
,
children
:
[{
id
:
0
,
text
:
"请选择"
}]
}
}
]
]
}
}
...
@@ -34,32 +40,67 @@ export default class cityList extends Vue {
...
@@ -34,32 +40,67 @@ export default class cityList extends Vue {
created
()
{
created
()
{
this
.
$server
.
EmployeeService
.
getCityList
({}).
then
(
res
=>
{
this
.
$server
.
EmployeeService
.
getCityList
({}).
then
(
res
=>
{
this
.
data
=
res
;
this
.
data
=
res
;
//组建省数据
this
.
data
.
find
((
item
:
any
)
=>
{
this
.
data
.
find
((
item
:
any
)
=>
{
let
obj
=
{};
let
obj
=
{};
if
(
item
.
parentId
==
0
)
{
if
(
item
.
parentId
==
0
)
{
this
.
province
=
{
this
.
province
=
{
id
:
item
.
id
,
text
:
item
.
name
,
text
:
item
.
name
,
id
:
item
.
id
children
:
[
{
id
:
0
,
text
:
"请选择"
,
children
:
[
{
id
:
0
,
text
:
"请选择"
}
]
}
]
};
};
this
.
columns
.
push
(
this
.
province
);
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
)
{
getChildren
(
arr
:
any
)
{}
// console.log(values[0]);
// console.log(this.city)
onConfirm
(
values
:
any
)
{
// picker.setColumnValues(1, this.cityData(this.city,35));
console
.
log
(
values
);
picker
.
setColumnValues
(
2
,
this
.
city
);
picker
.
setColumnValues
(
1
,
this
.
city
);
}
}
cityData
(
city
:
any
,
provinceId
:
any
)
{
cityData
(
city
:
any
,
provinceId
:
any
)
{
// console.log(city)
// 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