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