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