smart-switch-ui/src/utils/mixins.js

57 lines
1.0 KiB
JavaScript
Raw Normal View History

2024-06-17 11:17:00 +08:00
export const $view = {
props: {
view: {
type: String,
default: null
}
},
computed: {
hasView() {
return (views) => {
if (views == null || views.length === 0) {
return false;
}
let list = views;
if (views instanceof String) {
list = views.split(',');
}
return list != null && list.includes(this.view);
}
},
notHasView() {
return (views) => {
return !this.hasView(views);
}
}
}
}
2024-07-12 16:09:45 +08:00
/**
* 显隐列
**/
export const $showColumns = {
data() {
return {
columns: []
}
},
computed: {
showColumns() {
if (this.columns == null) {
return [];
}
return this.columns.filter(item => item.visible);
},
isShow() {
return (key) => {
if (this.columns == null) {
return false;
}
let column = this.columns.find(item => item.key === key);
return column != null && column.visible;
}
}
},
}