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
61cba9a3
authored
Jun 22, 2020
by
lishengfu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
udpate
parent
e3a1f5b8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
35 deletions
src/components/common/cityList.vue
src/router/employee/employee-router.ts
src/views/cityTest.vue
src/components/common/cityList.vue
View file @
61cba9a3
<
template
>
<div>
<van-picker
show-toolbar
title=
"标题"
:columns=
"columns"
@
change=
"
updateCity
"
/>
<van-picker
show-toolbar
title=
"标题"
:columns=
"columns"
@
change=
"
onChange
"
/>
</div>
</
template
>
<
script
lang=
"ts"
>
...
...
@@ -15,6 +15,7 @@ import { Component } from "vue-property-decorator";
})
export
default
class
cityList
extends
Vue
{
private
data
:
any
=
""
;
private
province
:
any
=
""
;
//省份
private
city
:
any
=
[];
//市份
private
area
:
any
=
""
;
//区,县
...
...
@@ -22,57 +23,52 @@ export default class cityList extends Vue {
private
columns
:
any
=
[
{
text
:
""
,
children
:
[]
children
:
[
{
text
:
""
,
children
:
[{
text
:
""
}]
}
]
}
];
created
()
{
this
.
$server
.
EmployeeService
.
getCityList
({}).
then
(
res
=>
{
this
.
data
=
res
;
//展示省份数据
Object
.
values
(
this
.
data
).
map
((
item
:
any
)
=>
{
this
.
data
.
find
((
item
:
any
)
=>
{
let
obj
=
{};
if
(
item
.
parentId
==
0
)
{
this
.
province
=
{
text
:
item
.
name
,
id
:
item
.
id
};
this
.
columns
.
push
(
this
.
province
);
}
else
{
obj
=
{
text
:
item
.
name
,
id
:
item
.
id
,
parentId
:
item
.
parentId
};
this
.
city
.
push
(
obj
);
}
});
//展示市级数据
this
.
columns
.
map
((
i
:
any
)
=>
{
Object
.
values
(
this
.
data
).
map
((
item
:
any
)
=>
{
let
obj
=
{};
if
(
item
.
parentId
!=
0
)
{
obj
=
{
text
:
item
.
name
,
id
:
item
.
id
,
parentId
:
item
.
parentId
};
// console.log(this.city)
this
.
city
.
push
(
obj
);
// this.columns.children[0].push(this.city);
}
});
});
// console.log(this.city)
});
}
updateCity
(
picker
:
any
,
values
:
any
,
index
:
any
)
{
console
.
log
(
values
);
picker
.
setColumnValues
(
1
,
this
.
cityData
(
this
.
city
,
values
[
0
]));
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
);
}
cityData
(
data
:
any
,
provinceId
:
any
)
{
data
.
map
((
item
:
any
)
=>
{
if
(
item
.
text
==
provinceId
)
{
console
.
log
(
provinceId
);
this
.
city
=
item
;
}
});
return
this
.
city
.
map
((
res
:
any
)
=>
{
console
.
log
(
res
)
// return { text: res.name, code: res.code };
});
cityData
(
city
:
any
,
provinceId
:
any
)
{
// console.log(city)
// city.find((item: any) => {
// if (item.parentId == provinceId) {
// console.log(item);
// this.city = item;
// }
// });
}
}
</
script
>
...
...
src/router/employee/employee-router.ts
View file @
61cba9a3
...
...
@@ -137,6 +137,15 @@ export default [
meta
:
{
title
:
'测试页面'
,
}
},
{
// 测试城市选择
path
:
'/cityTest'
,
name
:
'cityTest'
,
component
:
()
=>
import
(
"@/views/cityTest.vue"
),
meta
:
{
title
:
'测试城市列表'
,
}
}
]
\ No newline at end of file
src/views/cityTest.vue
0 → 100644
View file @
61cba9a3
<
template
>
<div
class=
"content"
>
<city-list
/>
</div>
</
template
>
<
script
lang=
"ts"
>
import
Vue
from
"vue"
;
import
{
Button
,
Icon
,
Popup
,
Form
,
Picker
,
Field
,
Toast
}
from
"vant"
;
import
{
Component
}
from
"vue-property-decorator"
;
import
cityList
from
"@/components/common/cityList.vue"
@
Component
({
components
:
{
[
Button
.
name
]:
Button
,
[
Icon
.
name
]:
Icon
,
[
Popup
.
name
]:
Popup
,
[
Form
.
name
]:
Form
,
[
Picker
.
name
]:
Picker
,
[
Field
.
name
]:
Field
,
cityList
}
})
export
default
class
socialInfo
extends
Vue
{
}
</
script
>
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