Commit c15ef361 by 匡雅琴

省市下拉组件(未完成)

1 parent 3349b08f
......@@ -52,6 +52,10 @@
title: 'GLCombiForm',
link: '/components/GLCombiForm'
},
{
title: 'GLProvince',
link: '/components/GLProvince'
},
]
}]
})
......
This diff could not be displayed because it is too large.
......@@ -24,7 +24,7 @@
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"concurrently": "^7.0.0",
"concurrently": "^7.1.0",
"del": "^6.0.0",
"gulp-autoprefixer": "^8.0.0",
"gulp-concat": "^2.6.1",
......@@ -33,6 +33,7 @@
"gulp-sass": "^5.0.0",
"node-sass": "^4.14.1",
"sass-loader": "^8.0.0",
"vue-template-compiler": "^2.6.11"
"vue-template-compiler": "^2.6.11",
"vuese": "^1.4.7"
}
}
......@@ -19,7 +19,7 @@
</GLDialog> -->
<hr />
<h3>el-table调整</h3>
<GLTable ref="liveRoomRef" :tableParams="tableParams" :tableData="tableData" max-height="250">
<GLTable ref="liveRoomRef" :tableParams="tableParams" :tableData="tableData" max-height="250">
<span slot="shareImgUrl" slot-scope="scope">
<img class="img-60" :src="scope.scope.shareImgUrl" />
</span>
......@@ -115,6 +115,9 @@
<!-- 测试 GLFooter -->
<GLFooter></GLFooter>
<!-- 测试 GLProvince -->
<GLProvince ref="provinceForm2" :subdistrict="subdistrict" @selectProvince="selectProvince" @selectCity="selectCity" @selectTown="selectTown"></GLProvince>
</div>
</template>
<script>
......@@ -125,7 +128,7 @@ export default {
visible: false,
tableParams: {
listName: 'list',
// 行数据的key
// 行数据的key
mutiSelectUniqueKey: 'id',
// 多选ref的名称
mutiSelectName: 'list',
......@@ -447,15 +450,15 @@ export default {
isClear: true,
pickerOptions: 'beforeRangePickerOptions',
//label 显示隐藏
showLabel:false,
showLabel: false
},
{
label: '生效时间',
name: 'effectiveDate',
type: 'datePicker',
isClear: true,
isHide:true
},
isHide: true
}
// {
// label: '财务审核状态',
// name: 'auditStatus',
......@@ -555,7 +558,7 @@ export default {
attrs: {
type: 'text',
//boolean或者函数
disabled:(row,condition)=>{
disabled: (row, condition) => {
return true
}
},
......@@ -588,7 +591,7 @@ export default {
},
attrs: {
type: 'text',
fn:'1-1-1-1'
fn: '1-1-1-1'
},
listeners: {
click: this.conditionFn
......@@ -615,7 +618,7 @@ export default {
attrs: {
type: 'text',
//boolean或者函数, 参数 row ,config
disabled:(row,condition)=>{
disabled: (row, condition) => {
return true
}
},
......@@ -640,9 +643,14 @@ export default {
click: this.conditionFn
}
}
]
],
// 测试省市组件
subdistrict: 3
}
},
mounted() {
this.$refs.provinceForm2.provinceList()
},
methods: {
subscribe(child) {
child.call('push', { src: this.src })
......@@ -662,8 +670,18 @@ export default {
console.log('您点击了取消')
},
//test table 更多 单行数据 ,单行的配置项
conditionFn(row,config) {
conditionFn(row, config) {
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)
}
}
}
......
<!-- <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>
......@@ -12,6 +8,7 @@
{
data() {
return {
demo1: true,
subdistrict: 3
}
},
......@@ -28,11 +25,17 @@
selectTown(townName, townCode) {
console.log(townName, townCode)
},
},
mounted() {
console.log(this)
// 获取省市信息(可传值,具体看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文件介绍)
// const p = this.$refs.provinceForm.provinceList()
// p.then(r => {
......@@ -44,7 +47,7 @@
# 用来作为 markdown 代码的示例部分
<!-- <div v-if="demo1"> -->
<div v-if="demo1">
```html
<template>
......@@ -52,6 +55,7 @@
<GLProvince ref="provinceForm2" :subdistrict="subdistrict" @selectProvince="selectProvince" @selectCity="selectCity" @selectTown="selectTown"></GLProvince>
</template>
<script>
import { GLProvince } from 'glsx-components'
export default {
data() {
return {
......@@ -70,17 +74,18 @@
}
},
mounted() {
this.$refs.provinceForm.provinceList()
this.$refs.provinceForm.init(provinceName, cityName, townName)
const p = this.$refs.provinceForm.provinceList()
p.then(r => {
console.log(r)
})
this.$refs.provinceForm1.provinceList()
this.$refs.provinceForm2.provinceList()
// this.$refs.provinceForm.init(provinceName, cityName, townName)
// const p = this.$refs.provinceForm.provinceList()
// p.then(r => {
// console.log(r)
// })
}
}
</script>
```
<!-- </div> -->
</div>
<!-- </content> -->
<template>
<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-option v-for="item in AllData" :key="item.adcode" :label="item.name" :value="item.name" @click.native="selectProvince(item)"></el-option>
</el-select>
......@@ -15,7 +15,6 @@
</template>
<script>
let map
export default {
name: 'GLProvince',
props: {
......@@ -40,9 +39,9 @@ export default {
// 所有数据
AllData: [],
// 城市列表
cityList: [{ adcode: '', name: '全部' }],
cityList: [],
// 地区列表
townList: [{ adcode: '', name: '全部' }],
townList: [],
provinceForm: {
// 省份名称
provinceName: '',
......@@ -86,11 +85,10 @@ export default {
})
**/
// 获取省市信息
provinceList(params) {
params.subdistrict ? '' : (params.subdistrict = this.subdistrict)
provinceList(params = {}) {
params ? (params.subdistrict ? '' : (params.subdistrict = this.subdistrict)) : (params.subdistrict = this.subdistrict)
let data = ''
for (let key in params) {
console.log(params[key])
data += '&' + key + '=' + params[key]
}
let path = `https://restapi.amap.com/v3/config/district?key=d22348363c34c266f772ae9b635eef2a`
......@@ -118,21 +116,23 @@ export default {
this.provinceForm.provinceName = item.name
this.cityList = item.districts
this.provinceForm.provinceCode = item.adcode
this.cityList.map(itm => {
if (itm.name.indexOf(city) != -1) {
this.provinceForm.cityCode = itm.adcode
this.provinceForm.cityName = itm.name
this.townList = itm.districts
if (town) {
this.townList.map(itmx => {
if (itmx.name.indexOf(town) != -1) {
this.provinceForm.townCode = itmx.adcode
this.provinceForm.townName = itmx.name
}
})
if (city) {
this.cityList.map(itm => {
if (itm.name.indexOf(city) != -1) {
this.provinceForm.cityCode = itm.adcode
this.provinceForm.cityName = itm.name
this.townList = itm.districts
if (town) {
this.townList.map(itmx => {
if (itmx.name.indexOf(town) != -1) {
this.provinceForm.townCode = itmx.adcode
this.provinceForm.townName = itmx.name
}
})
}
}
}
})
})
}
}
})
}
......@@ -140,6 +140,7 @@ export default {
// 选择省
selectProvince(val) {
this.provinceForm.cityName = ''
this.provinceForm.townName = ''
this.cityList = val.districts
this.$emit('selectProvince', val.name, val.adcode)
},
......
......@@ -21,16 +21,17 @@ import GLSearch from './GlSearch'
import GLSearchItem from './GlSearchItem'
import GLCombiForm from './GlCombiForm'
import GLTableButton from './GlTableButton'
import GLProvince from './GLProvince'
//el原始组件
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);
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
const install = function(Vue) {
const install = function (Vue) {
// 注册全局过滤器(一次性注册)
Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key])
......@@ -58,5 +59,6 @@ export default {
GLSearch,
GLSearchItem,
GLCombiForm,
GLTableButton
GLTableButton,
GLProvince
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!