This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/common/elementSet.vue

226 lines
6.8 KiB
Vue
Raw Normal View History

<template>
<div
class="pop-elementset"
:style="{opacity:(eventfixedVal.shezhi==1),left:(eventfixedVal.shezhi==1 ? event_positionx : -2000)+'px',top:(event_positiony)+'px'}"
>
2020-02-17 18:20:14 +08:00
<!--<div class="pop-top-btns">
2020-01-17 16:06:35 +08:00
<button type="button" @click="shezhiControl('ok')" class="nz-btn nz-btn-size-alien nz-btn-size-small nz-btn-style-light nz-btn-min-width-35" id="element-set-ok">
<span class="pop-top-btn-icon"><i class="nz-icon nz-icon-edit"></i></span>
<span class="pop-top-btn-txt">{{$t('overall.save')}}</span>
</button>
2020-01-17 16:06:35 +08:00
<button type="button" @click="shezhiControl('cancel')" class="nz-btn nz-btn-size-alien nz-btn-size-small nz-btn-style-light nz-btn-min-width-35" id="element-set-esc">
<span class="pop-top-btn-icon"><i class="el-icon-close"></i></span>
<span class="pop-top-btn-txt">{{$t('overall.esc')}}</span>
</button>
2020-02-17 18:20:14 +08:00
</div>-->
2020-01-17 16:06:35 +08:00
<div class="pop-title">{{$t('overall.select')}}</div>
<div class="pop-box elementset-labels">
<el-scrollbar style="height: 100%;">
<div
v-for="(item,index) in dropColRes"
:key="index"
class="elementset-label"
:class="!allowedAll&&(index==0 || index == 1) ? 'elementset-label-disabled' : ''"
:title="item.visibility == 'disabled' ? other.inDevelopment : ''"
@click="addcol(item,index)"
:id="'element-set-el-'+index"
>
<i class="el-icon-check" v-if="!allowedAll&&(index==0||index==1||item.visibility=='disabled')"></i>
<i v-else class="el-icon-check" v-show="item.show"></i>
<span>{{item.label}}</span>
</div>
</el-scrollbar>
</div>
<div class="elementset-bottom-btns">
2020-02-17 18:20:14 +08:00
<button v-if="isCancel" type="button" @click="dropAll(false)" class="nz-btn nz-btn-size-small nz-btn-style-light nz-btn-min-width-35 is-cancel">
<span class="top-tool-btn-txt">{{$t('overall.clear')}}</span>
</button>
<button v-if="!isCancel" type="button" @click="dropAll(true)" class="nz-btn nz-btn-size-small nz-btn-style-light nz-btn-min-width-35">
<span class="top-tool-btn-txt">{{$t('overall.all')}}</span>
</button>
2020-02-17 18:20:14 +08:00
<div>
<button type="button" @click="shezhiControl('cancel')" class="nz-btn nz-btn-size-small nz-btn-style-light nz-btn-min-width-35">
<span class="top-tool-btn-txt">{{$t('overall.esc')}}</span>
</button>
<button type="button" @click="shezhiControl('ok')" class="nz-btn nz-btn-size-small nz-btn-style-normal nz-btn-min-width-35">
<span class="top-tool-btn-txt">{{$t('overall.save')}}</span>
</button>
</div>
<!--<button type="button" @click="dropAll(false)" class="nz-btn nz-btn-size-normal nz-btn-style-light">
<span class="top-tool-btn-txt">{{$t('overall.cancel')}}</span>
2020-02-17 18:20:14 +08:00
</button>-->
</div>
</div>
</template>
<script>
export default {
// props: ["dropCol","tableTitle","path"],
props:{
dropCol:{},
tableTitle:{},
path:{},
allowedAll:{default:false},
},
data() {
return {
other: this.$t("overall.other"),
event_positiony: 0,
event_positionx: 0,
eventfixedVal: {},
dropColRes: JSON.parse(JSON.stringify(this.dropCol)),
titles: JSON.parse(JSON.stringify(this.tableTitle))
};
},
mounted() {},
created() {
let localStorageTitle=JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path));
if(localStorageTitle){
for(let title of this.titles){
for(let lsTitle of localStorageTitle){
if(lsTitle.prop === title.prop){
lsTitle.label=title.label;
}
}
}
localStorage.setItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path,JSON.stringify(localStorageTitle))
}
},
watch: {
dropCol: {
immediate: true,
deep: true,
handler(data) {
this.dropColRes = JSON.parse(JSON.stringify(data));
},
},
position: {
//监听设置icon的显示位置
handler(data) {
this.event_positiony = data.positiony;
this.event_positionx = data.positionx;
},
immediate: true
},
eventfixed: {
handler(data) {
if (data)
this.eventfixedVal = data;
},
immediate: true
}
},
methods: {
//悬浮点击空白隐藏
elementsetHide() {
this.eventfixedVal.shezhi = 0;
this.$emit('close');
},
//点击全选all或者cancel按钮
dropAll(state) {
for (let index = 0; index < this.dropColRes.length; index++) {
if (index == 0 || index == 1) {
this.dropColRes[index].show = true;
} else {
this.dropColRes[index].show = state;
}
}
},
//下拉选项选择
addcol(val, index) {
if (!this.allowedAll&&(index == 0 || index == 1)) {
this.dropColRes[index].show = true;
} else {
this.dropColRes[index].show = !this.dropColRes[index].show;
}
},
//点击第二个cancel
shezhiControl(t) {
if (t == "ok") {
this.$emit("tablelable", JSON.parse(JSON.stringify(this.dropColRes)));
localStorage.setItem(
"nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + ((typeof this.path != 'undefined') ? this.path : this.$route.path),
JSON.stringify(this.tablelable)
);
} else {
this.dropColRes = JSON.parse(JSON.stringify(this.tablelable));
}
this.elementsetHide();
},
},
computed: {
eventfixed() {
return this.$store.state.eventfixed;
},
position() {
return this.$store.state.position;
},
tablelable() {
return this.$store.state.tablelable;
},
2020-02-17 18:20:14 +08:00
//点击all是否是全部取消选中true为是
isCancel() {
let isCancel = true;
for (let i = 0; i < this.dropColRes.length; i++) {
if (!this.dropColRes[i].show) {
isCancel = false;
break;
}
}
return isCancel;
}
}
};
</script>
<style lang="scss" scoped>
.pop-elementset {
2020-01-17 16:06:35 +08:00
padding: 0 12px 12px 12px;
border: 1px solid #EBEEF5;
2020-01-17 16:06:35 +08:00
box-shadow: $pop-box-shadow;
position: fixed;
top: 0;
left: 10px;
width: 200px;
color: #606266;
background: #fff;
border-radius: 4px;
z-index: 999;
}
.elementset-labels {
2020-02-17 18:20:14 +08:00
margin-top: 12px;
width: 100%;
height: 300px;
}
.elementset-labels i {
color: #04b330;
font-size: 14px;
position: absolute;
left: 5px;
top: 6px;
}
.elementset-label {
padding: 2px 0 2px 25px;
position: relative;
cursor: default;
font-size: 14px;
}
.elementset-label-disabled {
cursor: not-allowed;
background: #f1f3f4;
opacity: 0.7;
}
.elementset-bottom-btns {
margin-top: 7px;
2020-02-17 18:20:14 +08:00
display: flex;
justify-content: space-between;
align-items: center;
}
.unshow {
display: none;
}
</style>