Commit 8c64d2b9 authored by 高天阳's avatar 高天阳

面板收起展开

parent a3f3dc15
<template> <template>
<el-row type="flex"> <el-row type="flex">
<el-col :span="hmCollapse" class="detail-content" style="margin:0 auto"> <el-col :span="options.panel_span" class="detail-content" style="margin:0 auto">
<!--<h2 class="title">面板页面</h2>--> <!--<h2 class="title">面板页面</h2>-->
<el-card class="box-card" :style="hmStyle"> <el-card class="box-card" :style="options.panel_style">
<div slot="header" class="clearfix" :class="hmTitleClass"> <div slot="header" class="clearfix" :class="options.title_class" @click="toggle()">
<span>{{hmTitle}}</span> <span>{{options.title}}</span>
</div> </div>
<div :style="hmPanelHeight" :class="hmContentClass"> <div :style="options.content_height" :class="options.content_class" v-show="collapse">
<span>{{hmContentText}}</span>
<slot></slot> <slot></slot>
</div> </div>
</el-card> </el-card>
...@@ -27,106 +26,33 @@ ...@@ -27,106 +26,33 @@
components: {}, components: {},
props: { props: {
/** /**
* 组件所使用的表定义schema。表定义schema,请使用 model2codejs 从pdm文件生成schema。 * 在面板页传入面板对象
* 对于所有毫末科技的组件,必须传schema,以完成数据的交互
*/ */
schema: { options: {
type: Object, type: Object,
required: true required: true
},
/**
* 指定要显示的列。默认为根据schema得到的所有列。完整示例为:
* [
* {
* "name": "姓名",
* "code": "username",
* "render": function(value){
* return "<a href='value'></a>"
* }
* },
* "mobile",
* "sexual"
* ]
*/
columns: {
type: Array,
required: false,
validator: function(value) {
if (typeof value !== 'object') {
console.warn(`传入的columns不符合要求,必须是数组`)
return false
}
return true
}
},
/**
* 在面板页传入面板标题
*/
hmTitle: {
type: String,
required: false
},
/**
* 在面板页传入标题类名
*/
hmTitleClass: {
type: String,
required: false
},
/**
* 在面板页传入内容类名
*/
hmContentClass: {
type: String,
required: false
},
/**
* 在面板页传入内容
*/
hmContentText: {
type: String,
required: false
},
/**
* 在面板页传入面板样式
*/
hmStyle: {
type: Object,
required: false
},
/**
* 在面板页传入面板内容高度
*/
hmPanelHeight: {
type: Object,
required: false
},
/**
* 在面板页传入面板宽度
*/
hmCollapse: {
type: Number,
required: false
},
showFields: {
type: Object,
required: false
} }
}, },
data() { data() {
return { return {
list: null, collapse: true
detail: null,
showColumns: [] // 要显示的列数据
} }
}, },
computed: { computed: {
}, },
filters: { filters: {
}, },
created() {}, created() {
},
methods: { methods: {
toggle() {
if (this.options.canCollapse) {
this.collapse = !this.collapse
console.log('收起展开')
} else {
console.log('不可收起')
}
},
validate() { validate() {
const self = this const self = this
// this.columns数组元素本身必须是string或者object. 且必须是schema中定义的列 // this.columns数组元素本身必须是string或者object. 且必须是schema中定义的列
......
<template> <template>
<div> <div>
<hm-panel :schema="schema['HmUser']" :hmTitle="titleBak" :hmContentClass="hmContentClass" <hm-panel :options="options">
:hmStyle="styleBak" :hmPanelHeight="panelHeightBak" :hmCollapse="collapseBak">
<hm-complex-detail :schema="schema['HmUser']" :tableId="userId"> <hm-complex-detail :schema="schema['HmUser']" :tableId="userId">
</hm-complex-detail> </hm-complex-detail>
</hm-panel> </hm-panel>
<hm-panel :schema="schema['HmUser']" :hmTitle="hmTitle" :hmTitleClass="hmTitleClass" <hm-panel :options="options2">
:hmContentText="hmContentText" :hmStyle="hmStyle" :hmPanelHeight="hmPanelHeight" :hmCollapse="collapses">
<hm-complex-form :schema="schema['HmUser']" :fields="showFields"> <hm-complex-form :schema="schema['HmUser']" :fields="showFields">
</hm-complex-form> </hm-complex-form>
</hm-panel> </hm-panel>
...@@ -39,34 +37,38 @@ ...@@ -39,34 +37,38 @@
filters: { filters: {
}, },
created() { created() {
this.schema = schema this.options = {
this.userId = '0e26566e953449a7a7500c34be39fd26' title: '面版名称',
this.userId2 = '1efff63125954583b0ac5a9c252b9041' panel_class: 'center',
this.hmTitle = '面版名称' title_class: 'weight',
this.hmTitleClass = 'center' content_class: 'center',
this.hmContentClass = 'center' panel_style: {
this.hmContentText = '面板文字'
this.hmStyle = {
width: '80%',
background: '#42b983',
margin: '0 auto'
}
this.hmPanelHeight = {
height: '400px'
}
this.collapses = 22
this.showFields = ['username', 'loginid', 'password', 'mobile', 'email']
this.showFields2 = ['mobile', 'loginid']
this.titleBak = '测试面板'
this.styleBak = {
width: '100%', width: '100%',
marginTop: '20px', marginTop: '20px',
marginBottom: '20px' marginBottom: '20px'
},
panel_span: 22,
content_height: {
height: '600px'
},
canCollapse: true
} }
this.panelHeightBak = { this.options2 = {
height: '500px' title: '测试面板',
panel_class: 'center',
title_class: 'center',
content_class: 'center',
panel_style: {
width: '80%',
background: '#42b983',
margin: '0 auto'
},
panel_span: 20,
canCollapse: false
} }
this.collapseBak = 22 this.schema = schema
this.userId = '0e26566e953449a7a7500c34be39fd26'
this.showFields = ['username', 'loginid', 'password', 'mobile', 'email']
}, },
methods: {} methods: {}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment