Commit c15ef361 by 匡雅琴

省市下拉组件(未完成)

1 parent 3349b08f
...@@ -52,6 +52,10 @@ ...@@ -52,6 +52,10 @@
title: 'GLCombiForm', title: 'GLCombiForm',
link: '/components/GLCombiForm' link: '/components/GLCombiForm'
}, },
{
title: 'GLProvince',
link: '/components/GLProvince'
},
] ]
}] }]
}) })
......
This diff could not be displayed because it is too large.
...@@ -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"
} }
} }
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</GLDialog> --> </GLDialog> -->
<hr /> <hr />
<h3>el-table调整</h3> <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"> <span slot="shareImgUrl" slot-scope="scope">
<img class="img-60" :src="scope.scope.shareImgUrl" /> <img class="img-60" :src="scope.scope.shareImgUrl" />
</span> </span>
...@@ -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>
...@@ -125,7 +128,7 @@ export default { ...@@ -125,7 +128,7 @@ export default {
visible: false, visible: false,
tableParams: { tableParams: {
listName: 'list', listName: 'list',
// 行数据的key // 行数据的key
mutiSelectUniqueKey: 'id', mutiSelectUniqueKey: 'id',
// 多选ref的名称 // 多选ref的名称
mutiSelectName: 'list', mutiSelectName: 'list',
...@@ -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)
} }
} }
} }
......
<!-- <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> -->
<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,21 +116,23 @@ export default { ...@@ -118,21 +116,23 @@ 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
this.cityList.map(itm => { if (city) {
if (itm.name.indexOf(city) != -1) { this.cityList.map(itm => {
this.provinceForm.cityCode = itm.adcode if (itm.name.indexOf(city) != -1) {
this.provinceForm.cityName = itm.name this.provinceForm.cityCode = itm.adcode
this.townList = itm.districts this.provinceForm.cityName = itm.name
if (town) { this.townList = itm.districts
this.townList.map(itmx => { if (town) {
if (itmx.name.indexOf(town) != -1) { this.townList.map(itmx => {
this.provinceForm.townCode = itmx.adcode if (itmx.name.indexOf(town) != -1) {
this.provinceForm.townName = itmx.name this.provinceForm.townCode = itmx.adcode
} this.provinceForm.townName = itmx.name
}) }
})
}
} }
} })
}) }
} }
}) })
} }
...@@ -140,6 +140,7 @@ export default { ...@@ -140,6 +140,7 @@ 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)
}, },
......
...@@ -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
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!