Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
liyeyun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cfld-frontend
liyeyun
Commits
8f0a61ff
Commit
8f0a61ff
authored
Dec 05, 2023
by
shilei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 列表筛选
parent
b35798b4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
7 deletions
+71
-7
icon-arrow_top.png
src/assets/images/icon-arrow_top.png
+0
-0
reset.scss
src/assets/styles/reset.scss
+3
-0
config.ts
src/components/filter/config.ts
+24
-0
filter-view.vue
src/components/filter/filter-view.vue
+0
-0
useCity.ts
src/composable/useCity.ts
+42
-7
common.ts
src/types/common.ts
+2
-0
No files found.
src/assets/images/icon-arrow_top.png
0 → 100644
View file @
8f0a61ff
320 Bytes
src/assets/styles/reset.scss
View file @
8f0a61ff
...
...
@@ -14,6 +14,9 @@ body {
#app
{
.el-checkbox
{
margin-right
:
20px
;
&
:hover
.el-checkbox__inner
{
border-color
:
#c0322b
;
}
}
.el-checkbox__input.is-checked
.el-checkbox__inner
{
background-color
:
#c0322b
;
...
...
src/components/filter/config.ts
View file @
8f0a61ff
...
...
@@ -154,4 +154,28 @@ export const defaultFiltersConfig = {
unit
:
'm'
,
},
},
// 省
province
:
{
type
:
'select'
,
label
:
'全部区域'
,
key
:
'provinceName'
,
multiple
:
false
,
isAddress
:
true
,
},
// 市
city
:
{
type
:
'select'
,
label
:
'全部城市'
,
key
:
'cityName'
,
multiple
:
false
,
isAddress
:
true
,
},
// 区
region
:
{
type
:
'select'
,
label
:
'全部区县'
,
key
:
'regionName'
,
multiple
:
false
,
isAddress
:
true
,
},
};
src/components/filter/filter-view.vue
View file @
8f0a61ff
This diff is collapsed.
Click to expand it.
src/composable/useCity.ts
View file @
8f0a61ff
import
cityData
from
'@/utils/cities.json'
;
import
{
computed
,
ref
}
from
'vue'
;
import
{
ref
}
from
'vue'
;
export
interface
CityData
{
value
:
string
;
...
...
@@ -16,20 +16,52 @@ export function useAddress() {
const
currentProvince
=
ref
<
CityData
|
null
>
(
null
);
const
currentCity
=
ref
<
CityData
|
null
>
(
null
);
const
currentRegion
=
ref
<
CityData
|
null
>
(
null
);
// 省列表
const
AreaJson
=
cityData
;
function
getProvinces
()
{
const
provinces
=
[];
for
(
let
i
=
0
;
i
<
AreaJson
.
length
;
i
++
)
{
provinces
.
push
({
dictLabel
:
AreaJson
[
i
].
name
,
dictValue
:
AreaJson
[
i
].
name
,
index
:
i
,
});
}
return
provinces
;
}
function
getCity
(
i
:
any
)
{
const
cities
:
any
[]
=
[];
const
idx
=
i
;
for
(
let
index
=
0
;
index
<
AreaJson
[
i
].
children
.
length
;
index
++
)
{
cities
.
push
({
dictLabel
:
AreaJson
[
idx
].
children
[
index
].
name
,
dictValue
:
AreaJson
[
idx
].
children
[
index
].
name
,
index
,
});
}
return
cities
;
}
function
getRegion
(
provinceIdx
:
number
,
cityIdx
:
number
)
{
const
regions
:
any
[]
=
[];
for
(
const
item
of
AreaJson
[
provinceIdx
].
children
[
cityIdx
].
children
)
{
regions
.
push
({
dictLabel
:
item
.
name
,
dictValue
:
item
.
name
,
});
}
return
regions
;
}
/**
* 当前省的市列表
*/
const
currentCityList
=
computed
(()
=>
{
return
currentProvince
.
value
?.
children
||
[];
});
const
currentCityList
=
ref
<
CityData
[]
>
([]);
/**
* 当前市的区列表
*/
const
currentRegionList
=
computed
(()
=>
{
return
currentCity
.
value
?.
children
||
[];
});
const
currentRegionList
=
ref
<
CityData
[]
>
([]);
return
{
cityList
,
...
...
@@ -38,5 +70,8 @@ export function useAddress() {
currentRegion
,
currentCityList
,
currentRegionList
,
getProvinces
,
getCity
,
getRegion
,
};
}
src/types/common.ts
View file @
8f0a61ff
...
...
@@ -56,6 +56,8 @@ export type FilterListItem = {
type
:
string
;
multiple
?:
boolean
;
value
?:
string
|
string
[];
valueLabel
?:
string
|
string
[];
isAddress
?:
boolean
;
plugin
?:
{
type
:
string
;
unit
:
string
;
...
...
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