Commit 0e5019ac by luyt

add: 1.GlTableButton,lable为选择框的时候箭头调整 2.GlCombiForm响应式规则重新调整

1 parent 09c7535e
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
......@@ -399,7 +399,8 @@ export default {
label: '生效时间',
name: 'effectiveDate',
type: 'datePicker',
isClear: true
isClear: true,
isHide:true
},
// {
// label: '财务审核状态',
......@@ -538,14 +539,20 @@ export default {
{
// 类型
type: 'el-button',
// 名字 //自定义内容 可以是html结构
name: row => {
return '新增3'
},
// 条件判断
// 名字 //自定义内容 可以是html结构 || 或者字符串
// name: row => {
// return '新增3'
// },
name: '新增3',
// 条件判断 fn 或者不传,默认显示(todo promise)
condition: row => {
return true
},
// condition: (row) => {
// return new Promise((resolve, reject) => {
// setTimeout(resolve(true),2000)
// })
// },
// 属性
attrs: {
type: 'text'
......
......@@ -5,7 +5,7 @@
<!-- @onOk="handleOkFn" @onRest="handleRestFn" :rowNumber="rowNumber" -->
<GLSearch :rowNumber="rowNumber" :expandStyle="expand">
<el-form :ref="formRef" :inline="true" :model="formObj" :rules="formRules" size="small" class="glsx-combi-form-block">
<template v-for="(item, index) in formData">
<template v-for="(item, index) in SearchList">
<el-form-item v-if="!item.isHide" :key="index" :id="item.name" :style="{ ...item.style }" :prop="item.name">
<GLSearchItem :showLabel="item.showLabel">
<div slot="name">
......@@ -114,6 +114,7 @@ export default {
url: '',
uploadType: 'img'
},
SearchList: [],
//操作栏箭头样式
expand: false,
hasExpand: false,
......@@ -177,6 +178,7 @@ export default {
},
mounted() {
this.getSearchItem()
this.getItemNum()
// 判断宽度按,是否显示展开收起
this.getClientWith()
......@@ -192,43 +194,61 @@ export default {
}
},
methods: {
//获取真正渲染条件item
getSearchItem() {
this.SearchList = this.formData.filter(item => !item.isHide)
},
// 展开收起
expandFn() {
this.expand = !this.expand
if (this.expand) {
this.SearchList = this.formData.filter(item => !item.isHide)
} else {
this.getClientWith()
}
},
// 获取item 输入框 的个数
getItemNum() {
const items = document.getElementById('gl-search').getElementsByClassName('search-item').length
this.itemNum = items
this.$nextTick(() => {
const items = document.getElementById('gl-search').getElementsByClassName('search-item').length - 1
// console.log('getSearchItem: ', items)
this.itemNum = items
})
},
// 判断是否有展开收起标志
ifHasExpand(nowCol) {
if (this.itemNum > nowCol * this.rowNumber) {
if (this.itemNum > nowCol * this.rowNumber - 1) {
//有折叠的情况
this.SearchList = this.formData.filter(item => !item.isHide).slice(0, nowCol * this.rowNumber - 1)
//初始化 展开flag为false
this.expand = false
// console.log('this.SearchList: ', this.SearchList)
return true
}
//显示全部
this.SearchList = this.formData.filter(item => !item.isHide)
return false
},
// 监听函数
getClientWith() {
if (this.time) clearTimeout(this.time)
this.time = setTimeout(() => {
const clientWidth = document.documentElement.clientWidth
// console.log('clientWidth: ', clientWidth)
const clientWidth = window.innerWidth
if (clientWidth <= 800) {
// 1列
if (clientWidth <= 1062) {
// 1个1行
this.hasExpand = this.ifHasExpand(1)
} else if (clientWidth <= 1440 && clientWidth > 800) {
// 2列
} else if (clientWidth <= 1440 && clientWidth > 1062) {
// 2个1行
this.hasExpand = this.ifHasExpand(2)
} else if (clientWidth <= 1720 && clientWidth > 1440) {
// 3列
// 3个1行
this.hasExpand = this.ifHasExpand(3)
} else {
// 4列
// 4个1行
this.hasExpand = this.ifHasExpand(4)
}
}, 300)
}, 100)
},
//gl-search 方法
handleOkFn() {
......@@ -267,6 +287,9 @@ export default {
.glsx-combi-form .isBlock {
display: block !important;
}
.el-input--small{
font-size: 14px;
}
/* .glsx-combi-form .el-form-item {
width: 65%;
} */
......
<template>
<!-- :style="{ height: !expandStyle ? 52 * this.rowNumber + 'px' : auto }" -->
<!-- -->
<div class="gl-search" id="gl-search" :style="{ height: !expandStyle ? 52 * this.rowNumber + 'px' : 'auto' }">
<!-- :class="{ transTo: !expand }" -->
<div class="search-list">
......@@ -113,7 +114,7 @@ export default {
// }
},
components: {},
watch: {},
watch: {}
// beforeDestroy() {
// window.removeEventListener('resize', this.getClientWith, false)
// this.time = null
......
<script>
import { hasPermission } from '../../Button'
import { objectType } from '../../../utils/index'
export default {
name: 'GLTableButton',
props: {
......@@ -54,7 +55,7 @@ export default {
onClick={() => {
component.listeners.click(this.buttonItem, component)
}}
domPropsInnerHTML={component.name ? component.name(this.buttonItem) : ''}>
domPropsInnerHTML={component.name ? (objectType(component.name) == 'String' ? component.name : component.name(this.buttonItem)) : ''}>
// {component.name}
</el-button>
)
......@@ -70,7 +71,7 @@ export default {
onClick={() => {
component.listeners.click(this.buttonItem, component)
}}
domPropsInnerHTML={component.name ? component.name(this.buttonItem) : ''}>
domPropsInnerHTML={component.name ? (objectType(component.name) == 'String' ? component.name : component.name(this.buttonItem)) : ''}>
// {component.name}
</GLButton>
)
......@@ -103,14 +104,30 @@ export default {
// //1.筛选过滤条件
const componentList = this.buttonList
.map(item => {
let status
if (item.type == 'el-button' || !item.type) {
status = item.condition(this.buttonItem)
} else if (item.type == 'GLButton') {
status = item.condition(this.buttonItem) && hasPermission.call(this, item.attrs.fn)
}
if (status) {
//不传条件,默认显示
if (!item.condition) {
return item
} else {
let status
if (item.type == 'el-button' || !item.type) {
// if(objectType(item.condition(this.buttonItem)) === 'Promise'){
// console.log('异步')
// //异步
// const res = await item.condition(this.buttonItem)
// console.log('res: ', res);
// status = res
// }else{
// //同步
// status = item.condition(this.buttonItem)
// }
// console.log(objectType(status) )
status = item.condition(this.buttonItem)
} else if (item.type == 'GLButton') {
status = item.condition(this.buttonItem) && hasPermission.call(this, item.attrs.fn)
}
if (status) {
return item
}
}
})
.filter(item => item)
......@@ -130,9 +147,7 @@ export default {
selectComp = (
<el-dropdown class="gl-dropdown">
<span class="el-dropdown-link">
更多<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<span class="el-dropdown-link">更多</span>
<el-dropdown-menu slot="dropdown">{postButtons.map(item => handleVNode(item, true))}</el-dropdown-menu>
</el-dropdown>
)
......
......@@ -19,7 +19,7 @@
</span>
</el-popover>
<span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{ item.formatter(scope.row) }}
{{ item.formatter(scope.row) || '-' }}
</span>
</template>
<template v-else-if="getListApi">
......@@ -29,7 +29,7 @@
</span>
</el-popover>
<span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{ scope.row[item.prop] }}
{{ scope.row[item.prop] || '-' }}
</span>
</template>
<template v-else>
......@@ -40,7 +40,7 @@
{{ tableData[scope.$index][item.prop] | lineEllipsis(item.width, item.line) }}
</span>
</el-popover>
<span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="tableData[scope.$index][item.prop]"></span>
<span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">{{ tableData[scope.$index][item.prop] || '-' }}</span>
</template>
<template v-if="item.addSymbol">
<span v-text="item.addSymbol"></span>
......@@ -86,10 +86,10 @@ export default {
type: String,
default: 'medium'
},
height: {
type: String,
default: ''
},
// height: {
// type: String,
// default: ''
// },
// maxHeight:{
// type:String,
// default:'3000'
......@@ -280,10 +280,15 @@ export default {
computed: {
// 分页计算属性
hasPageComputed() {
if (this.page[this.pageConf.pageNum] <= 1) {
if (!this.hasPage) {
return false
}
if (!this.hasPage) {
//直接传数据的情况
if (this.tableTotal && this.tableTotal > this.page[this.pageConf.pageSize]) {
return true
}
//传list api的情况
if (this.page[this.pageConf.pageNum] <= 1) {
return false
}
return true
......@@ -455,14 +460,14 @@ export default {
padding-left: 14px !important;
padding-right: 14px !important;
}
.glsx-table{
.el-table__empty-text{
.glsx-table {
.el-table__empty-text {
line-height: 1;
}
.emptyBg{
padding-top:4px;
.emptyBg {
padding-top: 4px;
padding-bottom: 4px;
.noDataImg{
.noDataImg {
margin-bottom: 12px;
}
}
......@@ -474,7 +479,7 @@ export default {
// align-items: center;
// height: 100%;
// }
}
}
.el-table__body-wrapper::-webkit-scrollbar {
width: 8px;
height: 8px;
......
......@@ -4,34 +4,34 @@
<template slot-scope="scope">
<slot v-if="item.addHtml" :name="item.addHtml" :scope="scope.row" :prop="item.prop" :width="item.width"></slot>
<template v-else-if="item.formatter">
<el-popover v-if="scope.row[item.prop] && scope.row[item.prop].length >= Math.ceil((item.width-36) / 16) * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="item.formatter(scope.row)">
<el-popover v-if="scope.row[item.prop] && scope.row[item.prop].length >= Math.ceil((item.width - 36) / 16) * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="item.formatter(scope.row)">
<span slot="reference" class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{ item.formatter(scope.row) | lineEllipsis(item.width, item.line) }}
</span>
</el-popover>
<span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="item.formatter(scope.row)"></span>
<span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">{{ item.formatter(scope.row) || '-' }}</span>
</template>
<template v-else-if="getListApi">
<el-popover v-if="scope.row[item.prop] && scope.row[item.prop].length >= Math.ceil((item.width-36) / 16) * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="scope.row[item.prop]">
<el-popover v-if="scope.row[item.prop] && scope.row[item.prop].length >= Math.ceil((item.width - 36) / 16) * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="scope.row[item.prop]">
<span slot="reference" class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{ scope.row[item.prop] | lineEllipsis(item.width, item.line) }}
</span>
</el-popover>
<span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="scope.row[item.prop]"></span>
<span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">{{ scope.row[item.prop] || '-' }}</span>
</template>
<template v-else>
<!-- 大于10或 20个字节长度 -->
<el-popover v-if="tableData[scope.$index][item.prop] && tableData[scope.$index][item.prop].length >= Math.ceil((item.width-36) / 16) * item.line" placement="top" width="200" trigger="hover" :content="tableData[scope.$index][item.prop]">
<el-popover v-if="tableData[scope.$index][item.prop] && tableData[scope.$index][item.prop].length >= Math.ceil((item.width - 36) / 16) * item.line" placement="top" width="200" trigger="hover" :content="tableData[scope.$index][item.prop]">
<span slot="reference" class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{ tableData[scope.$index][item.prop] | lineEllipsis(item.width, item.line) }}
</span>
</el-popover>
<!-- <span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="tableData[scope.$index][item.prop]"></span> -->
<span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{ tableData[scope.$index][item.prop] }}
{{ tableData[scope.$index][item.prop] || '-' }}
</span>
</template>
<template v-if="item.addSymbol">
......@@ -81,4 +81,4 @@ export default {
<style lang="scss">
// .sub-el-table-column {
// }
</style>
\ No newline at end of file
</style>
......@@ -50,6 +50,7 @@ $dackColor: $color-primary-dark30;
color: $dackColor;
border-color: $dackColor;
outline: none;
}
.el-button.is-round {
padding: 12px 20px;
......@@ -59,6 +60,11 @@ $dackColor: $color-primary-dark30;
background-color: $defaultColor;
border-color: $defaultColor;
}
.el-button--primary:active{
color: #fff;
background: $dackColor;
border-color: $dackColor;
}
.el-button--primary:focus,
.el-button--primary:hover {
background: $lightColor;
......
/**
*
* @param {*} value 要判断的值
* @returns 值的类型
*/
export const objectType = (value) =>{
const res = Object.prototype.toString.call(value).slice(8,-1)
return res
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!