Commit 11ccbb7e by luyt

feat:新增GLDrawer组件

1 parent 46533e97
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
...@@ -75,6 +75,10 @@ ...@@ -75,6 +75,10 @@
title: 'GLImage', title: 'GLImage',
link: '/components/GLImage' link: '/components/GLImage'
}, },
{
title: 'GLDrawer',
link: '/components/GLDrawer'
},
] ]
}, },
{ {
......
...@@ -228,6 +228,34 @@ ...@@ -228,6 +228,34 @@
:preview-src-list="srcList" :preview-src-list="srcList"
:appendToBody="false" :appendToBody="false"
></GLImage> ></GLImage>
<hr />
<!-- 测试GLDrawer -->
<el-button type="primary" @click="drawer = !drawer">测试GLDrawer(左右)</el-button>
<el-button type="primary" @click="drawer1 = !drawer1">测试GLDrawer(上下)</el-button>
<GLDrawer
@onOk="handleOk2"
@onCancel="handleCancel2"
title="我是标题"
:visible.sync="drawer"
:direction="direction"
:before-close="handleClose">
<!-- <span>我来啦!</span> -->
<el-table :data="gridData">
<el-table-column property="date" label="日期" width="350"></el-table-column>
<el-table-column property="name" label="姓名" width="100"></el-table-column>
<el-table-column property="address" width="100" label="地址"></el-table-column>
</el-table>
</GLDrawer>
<GLDrawer
@onOk="handleOk2"
@onCancel="handleCancel2"
title="我是标题"
:visible.sync="drawer1"
:direction="direction1"
:before-close="handleClose">
<span>我来啦!</span>
</GLDrawer>
<hr />
</div> </div>
</template> </template>
<script> <script>
...@@ -858,7 +886,37 @@ export default { ...@@ -858,7 +886,37 @@ export default {
srcList: [ srcList: [
'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg', 'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg' 'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg'
] ],
// 测试GLDrawer
drawer:false,
direction: 'rtl',
drawer1:false,
direction1: 'ttb',
gridData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}],
} }
}, },
mounted() { mounted() {
...@@ -1178,12 +1236,24 @@ export default { ...@@ -1178,12 +1236,24 @@ export default {
}, },
//测试table配置项 //测试table配置项
changeFn(checkList,checkAttrList){ changeFn(checkList,checkAttrList){
console.log('checkList,checkAttrList: ', checkList,checkAttrList); // console.log('checkList,checkAttrList: ', checkList,checkAttrList);
}, },
end(list){ end(list){
console.log('list: ', list); console.log('list: ', list);
} },
// 测试GLDrawer
handleClose(done){
console.log('测试GLDrawer')
done();
},
handleOk2() {
console.log('点击确定')
},
handleCancel2() {
console.log('点击取消')
},
} }
} }
......
...@@ -16,6 +16,10 @@ import { ...@@ -16,6 +16,10 @@ import {
GLSearchItem, GLSearchItem,
GLCombiForm, GLCombiForm,
GLTableButton, GLTableButton,
GLTabs,
GLTableOption,
GLImage,
GLDrawer,
// 业务 // 业务
GLProvince, GLProvince,
GLBcTest, GLBcTest,
...@@ -44,3 +48,7 @@ Vue.use(GLProvince) ...@@ -44,3 +48,7 @@ Vue.use(GLProvince)
Vue.use(GLBcTest) Vue.use(GLBcTest)
Vue.use(GLEditor) Vue.use(GLEditor)
Vue.use(GLFull) Vue.use(GLFull)
Vue.use(GLTabs)
Vue.use(GLTableOption)
Vue.use(GLImage)
Vue.use(GLDrawer)
...@@ -24,10 +24,10 @@ import '@/theme/theme.scss' ...@@ -24,10 +24,10 @@ import '@/theme/theme.scss'
// // import '../dist/glsx-components.css' // // import '../dist/glsx-components.css'
// //开发完成后,本地测试使用我们第二次封装的组件 // //开发完成后,本地测试使用我们第二次封装的组件
import './index' // import './index'
//开发完成后,打包后本地测试,我们第二次封装的组件 //开发完成后,打包后本地测试,我们第二次封装的组件
// import './localtest/index' import './localtest/index'
Vue.config.productionTip = false Vue.config.productionTip = false
......
import GLDrawer from './src/index.vue'
// 为组件提供 install 安装方法,供按需引入
GLDrawer.install = function(Vue) {
Vue.component(GLDrawer.name, GLDrawer)
}
// 默认导出组件
export default GLDrawer
\ No newline at end of file \ No newline at end of file
<!-- <content> -->
<el-button type="primary" @click="drawer = !drawer">测试GLDrawer(左右)</el-button>
<el-button type="primary" @click="drawer1 = !drawer1">测试GLDrawer(上下)</el-button>
<GLDrawer
@onOk="handleOk2"
@onCancel="handleCancel2"
title="我是标题"
:visible.sync="drawer"
:direction="direction"
:before-close="handleClose">
<!-- <span>我来啦!</span> -->
<el-table :data="gridData">
<el-table-column property="date" label="日期" width="350"></el-table-column>
<el-table-column property="name" label="姓名" width="100"></el-table-column>
<el-table-column property="address" width="100" label="地址"></el-table-column>
</el-table>
</GLDrawer>
<GLDrawer
@onOk="handleOk2"
@onCancel="handleCancel2"
title="我是标题"
:visible.sync="drawer1"
:direction="direction1"
:before-close="handleClose">
<span>我来啦!</span>
</GLDrawer>
<el-button type="warning" @click="toggleShow(1)">显示代码</el-button>
```js {mixin:true}
{
data() {
return {
demo1: true,
// 测试GLDrawer
drawer:false,
direction: 'rtl',
drawer1:false,
direction1: 'ttb',
gridData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}],
}
},
methods:{
btnClick(){
alert('点击')
},
toggleShow(num){
// console.log(123)
this['demo' + num] = !this['demo' + num]
},
// 测试GLDrawer
handleClose(done){
console.log('测试GLDrawer')
done();
},
handleOk2() {
console.log('点击确定')
},
handleCancel2() {
console.log('点击取消')
},
}
}
```
# 用来作为 markdown 代码的示例部分
<div v-if="demo1">
```html
<template>
<el-button type="primary" @click="drawer = !drawer">测试GLDrawer(左右)</el-button>
<el-button type="primary" @click="drawer1 = !drawer1">测试GLDrawer(上下)</el-button>
<GLDrawer
@onOk="handleOk2"
@onCancel="handleCancel2"
title="我是标题"
:visible.sync="drawer"
:direction="direction"
:before-close="handleClose">
<!-- <span>我来啦!</span> -->
<el-table :data="gridData">
<el-table-column property="date" label="日期" width="350"></el-table-column>
<el-table-column property="name" label="姓名" width="100"></el-table-column>
<el-table-column property="address" width="100" label="地址"></el-table-column>
</el-table>
</GLDrawer>
<GLDrawer
@onOk="handleOk2"
@onCancel="handleCancel2"
title="我是标题"
:visible.sync="drawer1"
:direction="direction1"
:before-close="handleClose">
<span>我来啦!</span>
</GLDrawer>
</template>
<script>
export default {
data() {
return {
// 测试GLDrawer
drawer:false,
direction: 'rtl',
drawer1:false,
direction1: 'ttb',
gridData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}],
}
},
methods: {
btnClick() {
alert('点击')
},
// 测试GLDrawer
handleClose(done){
console.log('测试GLDrawer')
done();
},
handleOk2() {
console.log('点击确定')
},
handleCancel2() {
console.log('点击取消')
},
}
}
</script>
```
</div>
<!-- </content> -->
\ No newline at end of file \ No newline at end of file
<script>
export default {
name: 'GLDrawer',
inheritAttrs: false,
props: {
hasFooter: {
type: Boolean,
default: true
}
},
render() {
const renderbtns = () => {
return (
<div class="gl-drawer-btn">
<el-button plain size="small" class="btn-three" onClick={this.cancel}>
取消
</el-button>
<el-button type="primary" size="small" class="btn-three" onClick={this.ok}>
提交
</el-button>
</div>
)
}
const keys = Object.keys(this.$slots)
return (
<el-drawer
class="gl-drawer"
{...{
attrs: this.$attrs,
on: this.$listeners,
scopedSlots: {
...this.$scopedSlots,
default: props => {
return (
<div class="gl-content-wrap">
<div class="gl-content">
{
// @vuese
// 无,插槽与el-drawer一致
this.$scopedSlots.default()
}
</div>
{renderbtns()}
</div>
)
}
}
}}>
{keys.map(name => {
if (name === 'default') {
return (
<div class="gl-content-wrap">
<div class="gl-content">
<template slot={name}>
{
// @vuese
// 无,插槽与el-drawer一致
this.$slots[name]
}
</template>
</div>
{renderbtns()}
</div>
)
} else {
return <template slot={name}>{this.$slots[name]}</template>
}
})}
</el-drawer>
)
},
methods: {
ok() {
// 这是确认事件
this.$emit('onOk')
},
cancel() {
// 这是取消事件
this.$emit('onCancel')
}
}
}
</script>
<style lang="scss">
.gl-drawer {
.el-drawer {
width: auto !important;
height: auto !important;
}
.ltr,
.rtl {
min-width: 432px;
max-width: 1008px;
}
.ttb,
.btt {
min-height: 320px;
max-height: 630px;
}
.el-drawer__header {
font-weight: 500;
font-size: 20px;
color: #333333;
margin-bottom: 16px;
padding: 16px 20px 0;
line-height: 1;
}
.el-dialog__close {
font-weight: 500;
color: #666;
}
.el-drawer__close-btn {
height: 22px;
}
.el-drawer__body {
padding: 20px 20px 16px;
display: flex;
.gl-content-wrap {
flex: 1;
display: flex;
flex-direction: column;
.gl-content {
flex: 1;
}
.gl-drawer-btn {
margin-top: 16px;
display: flex;
justify-content: flex-end;
}
}
}
}
</style>
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
*/ */
// 导入颜色选择器组件 // 导入颜色选择器组件
// import '@/plugins/element.js' // import '@/plugins/element.js'
import { Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip, Icon, Select, Option, DatePicker, Dropdown, DropdownItem, DropdownMenu, Dialog, MessageBox, Tabs, TabPane ,Checkbox,CheckboxGroup,Image} from '@/plugins/element.js' import { Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip, Icon, Select, Option, DatePicker, Dropdown, DropdownItem, DropdownMenu, Dialog, MessageBox, Tabs, TabPane ,Checkbox,CheckboxGroup,Image,Drawer} from '@/plugins/element.js'
import '@/theme/theme.scss' import '@/theme/theme.scss'
// 一次性注册所有的过滤器 本地测试 // 一次性注册所有的过滤器 本地测试
...@@ -24,6 +24,7 @@ import GLTableButton from './GlTableButton' ...@@ -24,6 +24,7 @@ import GLTableButton from './GlTableButton'
import GLTabs from './GLTabs' import GLTabs from './GLTabs'
import GLTableOption from './GLTableOption' import GLTableOption from './GLTableOption'
import GLImage from './GLImage' import GLImage from './GLImage'
import GLDrawer from './GLDrawer'
// 导入业务组件 // 导入业务组件
import GLProvince from './GLProvince' import GLProvince from './GLProvince'
...@@ -33,13 +34,13 @@ import GLEditor from './Editor' ...@@ -33,13 +34,13 @@ import GLEditor from './Editor'
import GLBcTest from '@/bcPackages/GLBcTest' import GLBcTest from '@/bcPackages/GLBcTest'
//el原始组件 //el原始组件
const ElComponent = [Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip, Icon, Select, Option, DatePicker, Dropdown, DropdownItem, DropdownMenu, Dialog, MessageBox, Tabs, TabPane,Checkbox,CheckboxGroup,Image] const ElComponent = [Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip, Icon, Select, Option, DatePicker, Dropdown, DropdownItem, DropdownMenu, Dialog, MessageBox, Tabs, TabPane,Checkbox,CheckboxGroup,Image,Drawer]
// 业务组件导入列表 // 业务组件导入列表
const BcComponent = [GLBcTest] const BcComponent = [GLBcTest]
// 存储组件列表 // 存储组件列表
const components = [TestComp, GLExternal, GLButton, GLDialog, GLTable, GLFooter, GLSearch, GLSearchItem, GLCombiForm, GLTableButton, GLProvince, GLFull, GLEditor, GLTabs,GLTableOption,GLImage].concat(ElComponent).concat(BcComponent) const components = [TestComp, GLExternal, GLButton, GLDialog, GLTable, GLFooter, GLSearch, GLSearchItem, GLCombiForm, GLTableButton, GLProvince, GLFull, GLEditor, GLTabs,GLTableOption,GLImage,GLDrawer].concat(ElComponent).concat(BcComponent)
// console.log('components: ', components); // console.log('components: ', components);
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册 // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
...@@ -91,8 +92,10 @@ export default { ...@@ -91,8 +92,10 @@ export default {
GLSearchItem, GLSearchItem,
GLCombiForm, GLCombiForm,
GLTableButton, GLTableButton,
GLTabs,
GLTableOption, GLTableOption,
GLImage, GLImage,
GLDrawer,
//业务组件 //业务组件
GLProvince, GLProvince,
GLBcTest, GLBcTest,
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
*/ */
import Vue from 'vue' import Vue from 'vue'
import { Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip, Icon, Select, Option, DatePicker, Dropdown, DropdownItem,DropdownMenu, Dialog,MessageBox, Tabs, TabPane,Checkbox,CheckboxGroup,Image} from 'element-ui' import { Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip, Icon, Select, Option, DatePicker, Dropdown, DropdownItem,DropdownMenu, Dialog,MessageBox, Tabs, TabPane,Checkbox,CheckboxGroup,Image,Drawer} from 'element-ui'
// import 'element-ui/lib/theme-chalk/index.css' //todo 按需引入插件样式 // import 'element-ui/lib/theme-chalk/index.css' //todo 按需引入插件样式
import 'element-ui/lib/theme-chalk/table.css' import 'element-ui/lib/theme-chalk/table.css'
import 'element-ui/lib/theme-chalk/table-column.css' import 'element-ui/lib/theme-chalk/table-column.css'
...@@ -31,6 +31,7 @@ import 'element-ui/lib/theme-chalk/tab-pane.css' ...@@ -31,6 +31,7 @@ import 'element-ui/lib/theme-chalk/tab-pane.css'
import 'element-ui/lib/theme-chalk/checkbox.css' import 'element-ui/lib/theme-chalk/checkbox.css'
import 'element-ui/lib/theme-chalk/checkbox-group.css' import 'element-ui/lib/theme-chalk/checkbox-group.css'
import 'element-ui/lib/theme-chalk/image.css' import 'element-ui/lib/theme-chalk/image.css'
import 'element-ui/lib/theme-chalk/drawer.css'
// 解决 ElTable 自动宽度高度导致的「ResizeObserver loop limit exceeded」问题 // 解决 ElTable 自动宽度高度导致的「ResizeObserver loop limit exceeded」问题
...@@ -66,9 +67,11 @@ Vue.use(TabPane) ...@@ -66,9 +67,11 @@ Vue.use(TabPane)
Vue.use(Checkbox) Vue.use(Checkbox)
Vue.use(CheckboxGroup) Vue.use(CheckboxGroup)
Vue.use(Image) Vue.use(Image)
Vue.use(Drawer)
// Vue.use(MessageBox) // Vue.use(MessageBox)
Vue.prototype.$confirm = MessageBox.confirm Vue.prototype.$confirm = MessageBox.confirm
//打包后的组件dist 测试组件可能需要的 //打包后的组件dist 测试组件可能需要的
export { Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip, Icon, Select, Option, DatePicker, Dropdown, DropdownItem,DropdownMenu,Dialog,MessageBox, Tabs, TabPane,Checkbox,CheckboxGroup,Image } export { Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip, Icon, Select, Option, DatePicker, Dropdown, DropdownItem,DropdownMenu,Dialog,MessageBox, Tabs, TabPane,Checkbox,CheckboxGroup,Image,Drawer }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!