Commit 09c7535e by luyt

add:table更多按钮添加fn权限判断

1 parent 21510632
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
......@@ -30,7 +30,7 @@
<el-button v-if="scope.scope.liveStatus != '101'" type="text" @click="handleDelete(scope.scope)">删除</el-button> -->
<!-- test 更多操作 -->
<GLTableButton :buttonList="buttonList" :buttonItem="scope"></GLTableButton>
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton>
</span>
</GLTable>
<hr />
......@@ -352,7 +352,7 @@ export default {
selectWidth: '110px',
selectOption: [
{
label: '客户姓名',
label: '客户姓名客户姓名客户姓名',
name: 'customerName'
},
{
......@@ -520,7 +520,7 @@ export default {
}
},
{
type: 'el-button',
type: 'GLButton',
name: row => {
return '新增2'
},
......@@ -528,7 +528,8 @@ export default {
return true
},
attrs: {
type: 'text'
type: 'text',
fn:'1-1-1-1'
},
listeners: {
click: this.conditionFn
......
import GLButton from './src/index.js'
import GLButton ,{ hasPermission }from './src/index.js'
// import from './src/index.js'
// 为组件提供 install 安装方法,供按需引入
GLButton.install = function(Vue, permissions) {
Vue.prototype.$GLBUTTION_PERMISSIONS = permissions
Vue.component(GLButton.name, GLButton)
}
export {hasPermission}
// 默认导出组件
export default GLButton
export default GLButton;
......@@ -21,6 +21,19 @@ function permission(ctx) {
return DISPLAY.NONE
}
export function hasPermission(fn, display) {
const router = getRoutes(this)
// console.log(router.meta.permissions);
return (router && router.meta && router.meta.permissions && router.meta.permissions.includes(fn)) || display === DISPLAY.DISABLED
}
function getRoutes(ctx) {
const {
$GLBUTTION_PERMISSIONS: { routes = [], routerBase }
} = ctx
return routes.find(route => location.pathname === `${routerBase}${route.path.split(':/')[0]}`)
}
export default {
functional: true,
name: 'GLButton',
......
......@@ -2,12 +2,13 @@
<template>
<div class="glsx-combi-formwrap">
<div class="glsx-combi-form">
<GLSearch @onOk="handleOkFn" @onRest="handleRestFn" :rowNumber="rowNumber">
<!-- @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">
<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" >
<GLSearchItem :showLabel="item.showLabel">
<div slot="name">
<span v-if="!item.isHide && item.tips" class="tips-block" slot="label">
<span class="tips-label">{{ item.label }}</span>
<el-tooltip popper-class="tooltip-class" effect="dark" :content="item.tips" :placement="item.placement || 'top'">
......@@ -23,6 +24,8 @@
<el-select v-model="searchSelectObj[item.selectName].attr" placeholder="请选择" @change="item.handleSelectChange">
<el-option v-for="(subItem, subIndex) in item.selectOption" :key="subIndex" :label="subItem.label" :value="subItem.name"></el-option>
</el-select>
<i class="el-icon-caret-bottom"></i>
:
</div>
</div>
......@@ -73,6 +76,20 @@
</GLSearchItem>
</el-form-item>
</template>
<el-form-item>
<GLSearchItem :showLabel="false">
<div class="gl-operate">
<div class="operate">
<el-button size="small" type="primary" @click="handleOkFn">查询</el-button>
<el-button size="small" @click="handleRestFn">重置</el-button>
<el-button type="text" size="small" @click="expandFn" v-if="hasExpand">
<span>{{ !expand ? '展开' : '收起' }}</span>
<i class="expand" :class="classIcon"></i>
</el-button>
</div>
</div>
</GLSearchItem>
</el-form-item>
<slot name="footer"></slot>
</el-form>
</GLSearch>
......@@ -96,7 +113,12 @@ export default {
dialogObj: {
url: '',
uploadType: 'img'
}
},
//操作栏箭头样式
expand: false,
hasExpand: false,
itemNum: 0,
time: null
}
},
......@@ -154,13 +176,60 @@ export default {
}
},
mounted() {},
mounted() {
this.getItemNum()
// 判断宽度按,是否显示展开收起
this.getClientWith()
window.addEventListener('resize', this.getClientWith, false)
},
components: {
GLSearch,
GLSearchItem
},
computed: {
classIcon() {
return !this.expand ? 'el-icon-arrow-down' : 'el-icon-arrow-up'
}
},
methods: {
// 展开收起
expandFn() {
this.expand = !this.expand
},
// 获取item 输入框 的个数
getItemNum() {
const items = document.getElementById('gl-search').getElementsByClassName('search-item').length
this.itemNum = items
},
// 判断是否有展开收起标志
ifHasExpand(nowCol) {
if (this.itemNum > nowCol * this.rowNumber) {
return true
}
return false
},
// 监听函数
getClientWith() {
if (this.time) clearTimeout(this.time)
this.time = setTimeout(() => {
const clientWidth = document.documentElement.clientWidth
// console.log('clientWidth: ', clientWidth)
if (clientWidth <= 800) {
// 1列
this.hasExpand = this.ifHasExpand(1)
} else if (clientWidth <= 1440 && clientWidth > 800) {
// 2列
this.hasExpand = this.ifHasExpand(2)
} else if (clientWidth <= 1720 && clientWidth > 1440) {
// 3列
this.hasExpand = this.ifHasExpand(3)
} else {
// 4列
this.hasExpand = this.ifHasExpand(4)
}
}, 300)
},
//gl-search 方法
handleOkFn() {
this.$emit('handleOk')
......@@ -180,6 +249,10 @@ export default {
handleInputBlur(e, item) {
item.inputBlur && item.inputBlur(e, item)
}
},
beforeDestroy() {
window.removeEventListener('resize', this.getClientWith, false)
this.time = null
}
}
</script>
......@@ -365,19 +438,30 @@ export default {
transform: translateX(-50%);
}
#selectlabel {
display: flex;
align-items: center;
.el-select {
width: 100% !important;
.el-input__suffix {
display: none;
}
.el-input--suffix .el-input__inner {
padding-right: 0;
padding-left: 0;
}
.el-input__inner {
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
// border-top-right-radius: 0px;
// border-bottom-right-radius: 0px;
border: 0px;
text-align: right;
}
}
}
.select-inp {
.el-input__inner {
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
}
// .el-input__inner {
// border-top-left-radius: 0px;
// border-bottom-left-radius: 0px;
// }
}
.muti-imgs .img-btns {
......
<template>
<div class="gl-search" id="gl-search" :style="{ height: !expand ? 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' }">
<!-- :class="{ transTo: !expand }" -->
<div class="search-list">
<!-- 默认插槽 -->
......@@ -14,38 +15,8 @@
></el-input>
</div>
</div> -->
<!-- <div class="search-item">
<div class="name">我是文本输入框</div>
<div class="input">
<el-input
size="small"
v-model="input"
placeholder="请输入内容"
></el-input>
</div>
</div> -->
<!-- <div class="search-item">
<div class="name">我是文本输入框</div>
<div class="input">
<el-input
size="small"
v-model="input"
placeholder="请输入内容"
></el-input>
</div>
</div>
<div class="search-item">
<div class="name">我是文本输入框</div>
<div class="input">
<el-input
size="small"
v-model="input"
placeholder="请输入内容"
></el-input>
</div>
</div> -->
</div>
<div class="gl-operate">
<!-- <div class="gl-operate">
<div class="operate">
<el-button size="small" type="primary" @click="handleOk">查询</el-button>
<el-button size="small" @click="handleRest">重置</el-button>
......@@ -53,10 +24,8 @@
<span>{{ !expand ? '展开' : '收起' }}</span>
<i class="expand" :class="classIcon"></i>
</el-button>
<!-- <i class="el-icon-arrow-down expand"></i> -->
<!-- <i class="el-icon-arrow-up"></i> -->
</div>
</div>
</div> -->
</div>
</template>
......@@ -64,87 +33,91 @@
export default {
name: 'GLSearch',
props: {
// 多少行显示-展开收起按钮
// // 多少行显示-展开收起按钮
rowNumber: {
type: Number,
default: 2
},
//条件栏展开收起的样式
expandStyle: {
type: Boolean,
default: false
}
},
data() {
return {
// input: '',
expand: false,
itemNum: 0,
time: null,
hasExpand: false
// expand: false,
// itemNum: 0,
// time: null,
// hasExpand: false
}
},
created() {},
mounted() {
this.getItemNum()
// 判断宽度按,是否显示展开收起
this.getClientWith()
window.addEventListener('resize', this.getClientWith, false)
},
computed: {
classIcon() {
return !this.expand ? 'el-icon-arrow-down' : 'el-icon-arrow-up'
}
// this.getItemNum()
// // 判断宽度按,是否显示展开收起
// this.getClientWith()
// window.addEventListener('resize', this.getClientWith, false)
},
// computed: {
// classIcon() {
// return !this.expand ? 'el-icon-arrow-down' : 'el-icon-arrow-up'
// }
// },
methods: {
// 展开收起
expandFn() {
this.expand = !this.expand
},
// 获取item 输入框 的个数
getItemNum() {
const items = document.getElementById('gl-search').getElementsByClassName('search-item').length
this.itemNum = items
},
// 判断是否有展开收起标志
ifHasExpand(nowCol) {
if (this.itemNum > nowCol * this.rowNumber) {
return true
}
return false
},
// 监听函数
getClientWith() {
if (this.time) clearTimeout(this.time)
this.time = setTimeout(() => {
const clientWidth = document.documentElement.clientWidth
// console.log('clientWidth: ', clientWidth)
if (clientWidth <= 800) {
// 1列
this.hasExpand = this.ifHasExpand(1)
} else if (clientWidth <= 1440 && clientWidth > 800) {
// 2列
this.hasExpand = this.ifHasExpand(2)
} else if (clientWidth <= 1720 && clientWidth > 1440) {
// 3列
this.hasExpand = this.ifHasExpand(3)
} else {
// 4列
this.hasExpand = this.ifHasExpand(4)
}
}, 300)
},
handleOk() {
// 点击确定的回调
this.$emit('onOk')
},
handleRest() {
// 点击重置的回调
this.$emit('onRest')
}
// // 展开收起
// expandFn() {
// this.expand = !this.expand
// },
// // 获取item 输入框 的个数
// getItemNum() {
// const items = document.getElementById('gl-search').getElementsByClassName('search-item').length
// this.itemNum = items
// },
// // 判断是否有展开收起标志
// ifHasExpand(nowCol) {
// if (this.itemNum > nowCol * this.rowNumber) {
// return true
// }
// return false
// },
// // 监听函数
// getClientWith() {
// if (this.time) clearTimeout(this.time)
// this.time = setTimeout(() => {
// const clientWidth = document.documentElement.clientWidth
// // console.log('clientWidth: ', clientWidth)
// if (clientWidth <= 800) {
// // 1列
// this.hasExpand = this.ifHasExpand(1)
// } else if (clientWidth <= 1440 && clientWidth > 800) {
// // 2列
// this.hasExpand = this.ifHasExpand(2)
// } else if (clientWidth <= 1720 && clientWidth > 1440) {
// // 3列
// this.hasExpand = this.ifHasExpand(3)
// } else {
// // 4列
// this.hasExpand = this.ifHasExpand(4)
// }
// }, 300)
// },
// handleOk() {
// // 点击确定的回调
// this.$emit('onOk')
// },
// handleRest() {
// // 点击重置的回调
// this.$emit('onRest')
// }
},
components: {},
watch: {},
beforeDestroy() {
window.removeEventListener('resize', this.getClientWith, false)
this.time = null
}
// beforeDestroy() {
// window.removeEventListener('resize', this.getClientWith, false)
// this.time = null
// }
}
</script>
<style lang="scss">
......
<script>
import { hasPermission } from '../../Button'
export default {
name: 'GLTableButton',
props: {
......@@ -38,7 +39,9 @@ export default {
// ]
}
},
mounted() {},
mounted() {
// console.log(hasPermission.call(this, '1-1-1-1'))
},
render() {
/**
* 创建el button 实例
......@@ -100,7 +103,12 @@ export default {
// //1.筛选过滤条件
const componentList = this.buttonList
.map(item => {
const status = item.condition(this.buttonItem)
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) {
return item
}
......
......@@ -83,6 +83,9 @@ $dackColor: $color-primary-dark30;
border-color: $dackColor;
color: #fff;
}
.el-button--primary.is-plain{
background: #fff;
}
.el-select .el-input__inner:focus {
border-color: $dackColor;
}
......@@ -277,6 +280,9 @@ $dackColor: $color-primary-dark30;
background-color: $defaultColor;
}
/* 表格 */
.el-table{
width:99.9% !important;
}
.el-table .el-table__cell{
height: 56px;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!