Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
npm
/
glsx-components
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 c15ef361
authored
Jun 14, 2022
by
匡雅琴
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
省市下拉组件(未完成)
1 parent
3349b08f
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
35 deletions
documents/index.html
package-lock.json
package.json
src/App.vue
src/packages/GLProvince/src/GLPrrovince.md → src/packages/GLProvince/src/GLProvince.md
src/packages/GLProvince/src/index.vue
src/packages/index.js
documents/index.html
View file @
c15ef36
...
@@ -52,6 +52,10 @@
...
@@ -52,6 +52,10 @@
title
:
'GLCombiForm'
,
title
:
'GLCombiForm'
,
link
:
'/components/GLCombiForm'
link
:
'/components/GLCombiForm'
},
},
{
title
:
'GLProvince'
,
link
:
'/components/GLProvince'
},
]
]
}]
}]
})
})
...
...
package-lock.json
View file @
c15ef36
This diff could not be displayed because it is too large.
package.json
View file @
c15ef36
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
"devDependencies"
:
{
"devDependencies"
:
{
"@vue/cli-plugin-babel"
:
"~4.5.0"
,
"@vue/cli-plugin-babel"
:
"~4.5.0"
,
"@vue/cli-service"
:
"~4.5.0"
,
"@vue/cli-service"
:
"~4.5.0"
,
"concurrently"
:
"^7.
0
.0"
,
"concurrently"
:
"^7.
1
.0"
,
"del"
:
"^6.0.0"
,
"del"
:
"^6.0.0"
,
"gulp-autoprefixer"
:
"^8.0.0"
,
"gulp-autoprefixer"
:
"^8.0.0"
,
"gulp-concat"
:
"^2.6.1"
,
"gulp-concat"
:
"^2.6.1"
,
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
"gulp-sass"
:
"^5.0.0"
,
"gulp-sass"
:
"^5.0.0"
,
"node-sass"
:
"^4.14.1"
,
"node-sass"
:
"^4.14.1"
,
"sass-loader"
:
"^8.0.0"
,
"sass-loader"
:
"^8.0.0"
,
"vue-template-compiler"
:
"^2.6.11"
"vue-template-compiler"
:
"^2.6.11"
,
"vuese"
:
"^1.4.7"
}
}
}
}
src/App.vue
View file @
c15ef36
...
@@ -115,6 +115,9 @@
...
@@ -115,6 +115,9 @@
<!-- 测试 GLFooter -->
<!-- 测试 GLFooter -->
<GLFooter></GLFooter>
<GLFooter></GLFooter>
<!-- 测试 GLProvince -->
<GLProvince
ref=
"provinceForm2"
:subdistrict=
"subdistrict"
@
selectProvince=
"selectProvince"
@
selectCity=
"selectCity"
@
selectTown=
"selectTown"
></GLProvince>
</div>
</div>
</template>
</template>
<
script
>
<
script
>
...
@@ -447,15 +450,15 @@ export default {
...
@@ -447,15 +450,15 @@ export default {
isClear
:
true
,
isClear
:
true
,
pickerOptions
:
'beforeRangePickerOptions'
,
pickerOptions
:
'beforeRangePickerOptions'
,
//label 显示隐藏
//label 显示隐藏
showLabel
:
false
,
showLabel
:
false
},
},
{
{
label
:
'生效时间'
,
label
:
'生效时间'
,
name
:
'effectiveDate'
,
name
:
'effectiveDate'
,
type
:
'datePicker'
,
type
:
'datePicker'
,
isClear
:
true
,
isClear
:
true
,
isHide
:
true
isHide
:
true
}
,
}
// {
// {
// label: '财务审核状态',
// label: '财务审核状态',
// name: 'auditStatus',
// name: 'auditStatus',
...
@@ -555,7 +558,7 @@ export default {
...
@@ -555,7 +558,7 @@ export default {
attrs
:
{
attrs
:
{
type
:
'text'
,
type
:
'text'
,
//boolean或者函数
//boolean或者函数
disabled
:
(
row
,
condition
)
=>
{
disabled
:
(
row
,
condition
)
=>
{
return
true
return
true
}
}
},
},
...
@@ -588,7 +591,7 @@ export default {
...
@@ -588,7 +591,7 @@ export default {
},
},
attrs
:
{
attrs
:
{
type
:
'text'
,
type
:
'text'
,
fn
:
'1-1-1-1'
fn
:
'1-1-1-1'
},
},
listeners
:
{
listeners
:
{
click
:
this
.
conditionFn
click
:
this
.
conditionFn
...
@@ -615,7 +618,7 @@ export default {
...
@@ -615,7 +618,7 @@ export default {
attrs
:
{
attrs
:
{
type
:
'text'
,
type
:
'text'
,
//boolean或者函数, 参数 row ,config
//boolean或者函数, 参数 row ,config
disabled
:
(
row
,
condition
)
=>
{
disabled
:
(
row
,
condition
)
=>
{
return
true
return
true
}
}
},
},
...
@@ -640,9 +643,14 @@ export default {
...
@@ -640,9 +643,14 @@ export default {
click
:
this
.
conditionFn
click
:
this
.
conditionFn
}
}
}
}
]
],
// 测试省市组件
subdistrict
:
3
}
}
},
},
mounted
()
{
this
.
$refs
.
provinceForm2
.
provinceList
()
},
methods
:
{
methods
:
{
subscribe
(
child
)
{
subscribe
(
child
)
{
child
.
call
(
'push'
,
{
src
:
this
.
src
})
child
.
call
(
'push'
,
{
src
:
this
.
src
})
...
@@ -662,8 +670,18 @@ export default {
...
@@ -662,8 +670,18 @@ export default {
console
.
log
(
'您点击了取消'
)
console
.
log
(
'您点击了取消'
)
},
},
//test table 更多 单行数据 ,单行的配置项
//test table 更多 单行数据 ,单行的配置项
conditionFn
(
row
,
config
)
{
conditionFn
(
row
,
config
)
{
console
.
log
(
'row: '
,
row
)
console
.
log
(
'row: '
,
row
)
},
// 测试省市方法
selectProvince
(
provinceName
,
provinceCode
)
{
console
.
log
(
provinceName
,
provinceCode
)
},
selectCity
(
cityName
,
cityCode
)
{
console
.
log
(
cityName
,
cityCode
)
},
selectTown
(
townName
,
townCode
)
{
console
.
log
(
townName
,
townCode
)
}
}
}
}
}
}
...
...
src/packages/GLProvince/src/GLPr
r
ovince.md
→
src/packages/GLProvince/src/GLProvince.md
View file @
c15ef36
<!-- <content>
-->
<!-- <content>
-->
<!-- 只展示省市 -->
<!-- 不需要传subdistrict,默认为2,只展示省市 -->
<GLProvince
ref=
"provinceForm1"
@
selectProvince=
"selectProvince"
@
selectCity=
"selectCity"
></GLProvince>
<!-- <GLProvince ref="provinceForm1" @selectProvince="selectProvince" @selectCity="selectCity"></GLProvince>
-->
<!-- 展示省市区 -->
<GLProvince ref="provinceForm2" :subdistrict="subdistrict" @selectProvince="selectProvince" @selectCity="selectCity" @selectTown="selectTown"></GLProvince>
<GLProvince ref="provinceForm2" :subdistrict="subdistrict" @selectProvince="selectProvince" @selectCity="selectCity" @selectTown="selectTown"></GLProvince>
...
@@ -12,6 +8,7 @@
...
@@ -12,6 +8,7 @@
{
{
data() {
data() {
return {
return {
demo1: true,
subdistrict: 3
subdistrict: 3
}
}
},
},
...
@@ -28,11 +25,17 @@
...
@@ -28,11 +25,17 @@
selectTown(townName, townCode) {
selectTown(townName, townCode) {
console.log(townName, townCode)
console.log(townName, townCode)
},
},
},
mounted() {
mounted() {
console.log(this)
// 获取省市信息(可传值,具体看index.vue文件介绍)
// 获取省市信息(可传值,具体看index.vue文件介绍)
this.$refs.provinceForm.provinceList()
// this.$refs.provinceForm1.provinceList
setTimeout(() => {
this.$refs.provinceForm2.provinceList()
})
// 省市区回显
// 省市区回显
this.$refs.provinceForm.init(provinceName, cityName, townName)
//
this.$refs.provinceForm.init(provinceName, cityName, townName)
// 如果不需要展示组件,只需要获取数据的话,返回的是promise对象(可传值,具体看index.vue文件介绍)
// 如果不需要展示组件,只需要获取数据的话,返回的是promise对象(可传值,具体看index.vue文件介绍)
// const p = this.$refs.provinceForm.provinceList()
// const p = this.$refs.provinceForm.provinceList()
// p.then(r => {
// p.then(r => {
...
@@ -44,7 +47,7 @@
...
@@ -44,7 +47,7 @@
# 用来作为 markdown 代码的示例部分
# 用来作为 markdown 代码的示例部分
<
!-- <div v-if="demo1">
--
>
<
div v-if="demo1"
>
```
html
```
html
<template>
<template>
...
@@ -52,6 +55,7 @@
...
@@ -52,6 +55,7 @@
<GLProvince
ref=
"provinceForm2"
:subdistrict=
"subdistrict"
@
selectProvince=
"selectProvince"
@
selectCity=
"selectCity"
@
selectTown=
"selectTown"
></GLProvince>
<GLProvince
ref=
"provinceForm2"
:subdistrict=
"subdistrict"
@
selectProvince=
"selectProvince"
@
selectCity=
"selectCity"
@
selectTown=
"selectTown"
></GLProvince>
</template>
</template>
<script>
<script>
import
{
GLProvince
}
from
'glsx-components'
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
...
@@ -70,17 +74,18 @@
...
@@ -70,17 +74,18 @@
}
}
},
},
mounted
()
{
mounted
()
{
this
.
$refs
.
provinceForm
.
provinceList
()
this
.
$refs
.
provinceForm1
.
provinceList
()
this
.
$refs
.
provinceForm
.
init
(
provinceName
,
cityName
,
townName
)
this
.
$refs
.
provinceForm2
.
provinceList
()
const
p
=
this
.
$refs
.
provinceForm
.
provinceList
()
// this.$refs.provinceForm.init(provinceName, cityName, townName)
p
.
then
(
r
=>
{
// const p = this.$refs.provinceForm.provinceList()
console
.
log
(
r
)
// p.then(r => {
})
// console.log(r)
// })
}
}
}
}
</script>
</script>
```
```
<
!-- </div>
--
>
<
/div
>
<!-- </content>
-->
<!-- </content>
-->
src/packages/GLProvince/src/index.vue
View file @
c15ef36
<
template
>
<
template
>
<div
v-if=
"provinceView"
>
<div
v-if=
"provinceView"
>
<el-form
ref=
"provinceForm"
:model=
"provinceForm"
inline=
"true"
class=
"province"
>
<el-form
ref=
"provinceForm"
:model=
"provinceForm"
:
inline=
"true"
class=
"province"
>
<el-select
size=
"small"
v-model=
"provinceForm.provinceName"
clearable
placeholder=
"选择省份"
:style=
"
{ width: defaultWidth }" @change="selectProvince" class="select-padding">
<el-select
size=
"small"
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-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>
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
</
template
>
</
template
>
<
script
>
<
script
>
let
map
export
default
{
export
default
{
name
:
'GLProvince'
,
name
:
'GLProvince'
,
props
:
{
props
:
{
...
@@ -40,9 +39,9 @@ export default {
...
@@ -40,9 +39,9 @@ export default {
// 所有数据
// 所有数据
AllData
:
[],
AllData
:
[],
// 城市列表
// 城市列表
cityList
:
[
{
adcode
:
''
,
name
:
'全部'
}
],
cityList
:
[],
// 地区列表
// 地区列表
townList
:
[
{
adcode
:
''
,
name
:
'全部'
}
],
townList
:
[],
provinceForm
:
{
provinceForm
:
{
// 省份名称
// 省份名称
provinceName
:
''
,
provinceName
:
''
,
...
@@ -86,11 +85,10 @@ export default {
...
@@ -86,11 +85,10 @@ export default {
})
})
**/
**/
// 获取省市信息
// 获取省市信息
provinceList
(
params
)
{
provinceList
(
params
=
{}
)
{
params
.
subdistrict
?
''
:
(
params
.
subdistrict
=
this
.
subdistrict
)
params
?
(
params
.
subdistrict
?
''
:
(
params
.
subdistrict
=
this
.
subdistrict
))
:
(
params
.
subdistrict
=
this
.
subdistrict
)
let
data
=
''
let
data
=
''
for
(
let
key
in
params
)
{
for
(
let
key
in
params
)
{
console
.
log
(
params
[
key
])
data
+=
'&'
+
key
+
'='
+
params
[
key
]
data
+=
'&'
+
key
+
'='
+
params
[
key
]
}
}
let
path
=
`https://restapi.amap.com/v3/config/district?key=d22348363c34c266f772ae9b635eef2a`
let
path
=
`https://restapi.amap.com/v3/config/district?key=d22348363c34c266f772ae9b635eef2a`
...
@@ -118,6 +116,7 @@ export default {
...
@@ -118,6 +116,7 @@ export default {
this
.
provinceForm
.
provinceName
=
item
.
name
this
.
provinceForm
.
provinceName
=
item
.
name
this
.
cityList
=
item
.
districts
this
.
cityList
=
item
.
districts
this
.
provinceForm
.
provinceCode
=
item
.
adcode
this
.
provinceForm
.
provinceCode
=
item
.
adcode
if
(
city
)
{
this
.
cityList
.
map
(
itm
=>
{
this
.
cityList
.
map
(
itm
=>
{
if
(
itm
.
name
.
indexOf
(
city
)
!=
-
1
)
{
if
(
itm
.
name
.
indexOf
(
city
)
!=
-
1
)
{
this
.
provinceForm
.
cityCode
=
itm
.
adcode
this
.
provinceForm
.
cityCode
=
itm
.
adcode
...
@@ -134,12 +133,14 @@ export default {
...
@@ -134,12 +133,14 @@ export default {
}
}
})
})
}
}
}
})
})
}
}
},
},
// 选择省
// 选择省
selectProvince
(
val
)
{
selectProvince
(
val
)
{
this
.
provinceForm
.
cityName
=
''
this
.
provinceForm
.
cityName
=
''
this
.
provinceForm
.
townName
=
''
this
.
cityList
=
val
.
districts
this
.
cityList
=
val
.
districts
this
.
$emit
(
'selectProvince'
,
val
.
name
,
val
.
adcode
)
this
.
$emit
(
'selectProvince'
,
val
.
name
,
val
.
adcode
)
},
},
...
...
src/packages/index.js
View file @
c15ef36
...
@@ -21,16 +21,17 @@ import GLSearch from './GlSearch'
...
@@ -21,16 +21,17 @@ import GLSearch from './GlSearch'
import
GLSearchItem
from
'./GlSearchItem'
import
GLSearchItem
from
'./GlSearchItem'
import
GLCombiForm
from
'./GlCombiForm'
import
GLCombiForm
from
'./GlCombiForm'
import
GLTableButton
from
'./GlTableButton'
import
GLTableButton
from
'./GlTableButton'
import
GLProvince
from
'./GLProvince'
//el原始组件
//el原始组件
const
ElComponent
=
[
Table
,
TableColumn
,
Popover
,
Button
,
ButtonGroup
,
Loading
,
Input
,
Form
,
FormItem
,
Pagination
,
Tooltip
,
Icon
,
Select
,
Option
,
DatePicker
,
Dropdown
,
DropdownItem
,
DropdownMenu
]
const
ElComponent
=
[
Table
,
TableColumn
,
Popover
,
Button
,
ButtonGroup
,
Loading
,
Input
,
Form
,
FormItem
,
Pagination
,
Tooltip
,
Icon
,
Select
,
Option
,
DatePicker
,
Dropdown
,
DropdownItem
,
DropdownMenu
]
// 存储组件列表
// 存储组件列表
const
components
=
[
TestComp
,
GLExternal
,
GLButton
,
GLDialog
,
GLTable
,
GLFooter
,
GLSearch
,
GLSearchItem
,
GLCombiForm
,
GLTableButton
].
concat
(
ElComponent
)
const
components
=
[
TestComp
,
GLExternal
,
GLButton
,
GLDialog
,
GLTable
,
GLFooter
,
GLSearch
,
GLSearchItem
,
GLCombiForm
,
GLTableButton
,
GLProvince
].
concat
(
ElComponent
)
// console.log('components: ', components);
// console.log('components: ', components);
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
const
install
=
function
(
Vue
)
{
const
install
=
function
(
Vue
)
{
// 注册全局过滤器(一次性注册)
// 注册全局过滤器(一次性注册)
Object
.
keys
(
filters
).
forEach
(
key
=>
{
Object
.
keys
(
filters
).
forEach
(
key
=>
{
Vue
.
filter
(
key
,
filters
[
key
])
Vue
.
filter
(
key
,
filters
[
key
])
...
@@ -58,5 +59,6 @@ export default {
...
@@ -58,5 +59,6 @@ export default {
GLSearch
,
GLSearch
,
GLSearchItem
,
GLSearchItem
,
GLCombiForm
,
GLCombiForm
,
GLTableButton
GLTableButton
,
GLProvince
}
}
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