2020-01-08 22:19:46 +08:00
|
|
|
|
<template>
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<div class="pop-custom" v-clickoutside="esc">
|
2020-01-17 16:06:35 +08:00
|
|
|
|
<div class="pop-title">{{$t('overall.select')}}</div>
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<div class="pop-box custom-labels">
|
2020-01-08 22:19:46 +08:00
|
|
|
|
<el-scrollbar style="height: 100%;">
|
2020-08-05 11:18:55 +08:00
|
|
|
|
<!--NotSet 为true不可设置-->
|
2020-01-08 22:19:46 +08:00
|
|
|
|
<div
|
2020-08-04 21:53:06 +08:00
|
|
|
|
v-for="(item,index) in custom"
|
2020-01-08 22:19:46 +08:00
|
|
|
|
:key="index"
|
2020-08-04 21:53:06 +08:00
|
|
|
|
class="custom-label"
|
2020-08-05 11:18:55 +08:00
|
|
|
|
:class="!allowedAll && (index==0 || index == 1 || item.NotSet) ? 'custom-label-disabled' : ''"
|
2020-08-04 21:53:06 +08:00
|
|
|
|
@click="handler(item,index)"
|
2020-01-13 18:48:25 +08:00
|
|
|
|
:id="'element-set-el-'+index"
|
2020-01-08 22:19:46 +08:00
|
|
|
|
>
|
2020-04-23 16:45:59 +08:00
|
|
|
|
<i class="el-icon-check" v-if="!allowedAll&&(index==0||index==1||item.visibility=='disabled')"></i>
|
2020-01-08 22:19:46 +08:00
|
|
|
|
<i v-else class="el-icon-check" v-show="item.show"></i>
|
|
|
|
|
|
<span>{{item.label}}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-scrollbar>
|
|
|
|
|
|
</div>
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<div class="custom-bottom-btns">
|
|
|
|
|
|
<button v-if="isCancel" type="button" @click="batchHandler(false)" class="nz-btn nz-btn-size-small nz-btn-style-light nz-btn-min-width-35 is-cancel">
|
2020-02-17 18:20:14 +08:00
|
|
|
|
<span class="top-tool-btn-txt">{{$t('overall.clear')}}</span>
|
|
|
|
|
|
</button>
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<button v-if="!isCancel" type="button" @click="batchHandler(true)" class="nz-btn nz-btn-size-small nz-btn-style-light nz-btn-min-width-35">
|
2020-01-08 22:19:46 +08:00
|
|
|
|
<span class="top-tool-btn-txt">{{$t('overall.all')}}</span>
|
|
|
|
|
|
</button>
|
2020-02-17 18:20:14 +08:00
|
|
|
|
<div>
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<button type="button" @click="esc" class="nz-btn nz-btn-size-small nz-btn-style-light nz-btn-min-width-35">
|
2020-02-17 18:20:14 +08:00
|
|
|
|
<span class="top-tool-btn-txt">{{$t('overall.esc')}}</span>
|
|
|
|
|
|
</button>
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<button type="button" @click="save" class="nz-btn nz-btn-size-small nz-btn-style-normal nz-btn-min-width-35">
|
2020-02-17 18:20:14 +08:00
|
|
|
|
<span class="top-tool-btn-txt">{{$t('overall.save')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
2020-01-08 22:19:46 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
export default {
|
2020-04-23 16:45:59 +08:00
|
|
|
|
props:{
|
2020-08-04 21:53:06 +08:00
|
|
|
|
customTableTitle: Array, //自定义的title
|
|
|
|
|
|
originalTableTitle: Array, //原始title
|
|
|
|
|
|
path: String,
|
|
|
|
|
|
allowedAll: {default: false},
|
2020-04-23 16:45:59 +08:00
|
|
|
|
},
|
2020-01-08 22:19:46 +08:00
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2020-08-04 21:53:06 +08:00
|
|
|
|
custom: [],
|
2020-01-08 22:19:46 +08:00
|
|
|
|
};
|
|
|
|
|
|
},
|
2020-01-16 15:48:49 +08:00
|
|
|
|
created() {
|
2020-08-04 21:53:06 +08:00
|
|
|
|
let localStorageTitle = JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path));
|
|
|
|
|
|
if (localStorageTitle ){
|
|
|
|
|
|
for (let title of this.originalTableTitle) {
|
|
|
|
|
|
for (let lsTitle of localStorageTitle) {
|
|
|
|
|
|
if (lsTitle.prop === title.prop){
|
|
|
|
|
|
lsTitle.label = title.label;
|
2020-01-16 15:48:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-08-04 21:53:06 +08:00
|
|
|
|
localStorage.setItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path, JSON.stringify(localStorageTitle))
|
2020-01-16 15:48:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
},
|
2020-01-08 22:19:46 +08:00
|
|
|
|
watch: {
|
2020-08-04 21:53:06 +08:00
|
|
|
|
customTableTitle: {
|
2020-01-08 22:19:46 +08:00
|
|
|
|
immediate: true,
|
|
|
|
|
|
deep: true,
|
2020-08-04 21:53:06 +08:00
|
|
|
|
handler(n) {
|
|
|
|
|
|
this.custom = JSON.parse(JSON.stringify(n));
|
2020-01-08 22:19:46 +08:00
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
//悬浮点击空白隐藏
|
2020-08-04 21:53:06 +08:00
|
|
|
|
esc() {
|
2020-03-24 19:22:24 +08:00
|
|
|
|
this.$emit('close');
|
2020-01-08 22:19:46 +08:00
|
|
|
|
},
|
2020-08-04 21:53:06 +08:00
|
|
|
|
//全选all true 或者全取消cancel false按钮
|
|
|
|
|
|
batchHandler(state) {
|
|
|
|
|
|
for (let index = 0; index < this.custom.length; index++) {
|
2020-08-05 11:18:55 +08:00
|
|
|
|
if (index == 0 || index == 1 || this.custom[index].NotSet) {
|
2020-08-04 21:53:06 +08:00
|
|
|
|
this.custom[index].show = true;
|
2020-01-08 22:19:46 +08:00
|
|
|
|
} else {
|
2020-08-04 21:53:06 +08:00
|
|
|
|
this.custom[index].show = state;
|
2020-01-08 22:19:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-08-04 21:53:06 +08:00
|
|
|
|
//单选
|
|
|
|
|
|
handler(val, index) {
|
2020-08-05 11:18:55 +08:00
|
|
|
|
if (!this.allowedAll && (index == 0 || index == 1 || val.NotSet)) {
|
2020-08-04 21:53:06 +08:00
|
|
|
|
this.custom[index].show = true;
|
2020-01-08 22:19:46 +08:00
|
|
|
|
} else {
|
2020-08-04 21:53:06 +08:00
|
|
|
|
this.custom[index].show = !this.custom[index].show;
|
2020-01-08 22:19:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
//点击第二个cancel
|
2020-08-04 21:53:06 +08:00
|
|
|
|
save() {
|
|
|
|
|
|
this.$emit('update:customTableTitle', this.custom);
|
|
|
|
|
|
localStorage.setItem(
|
|
|
|
|
|
"nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + ((typeof this.path != 'undefined') ? this.path : this.$route.path),
|
|
|
|
|
|
JSON.stringify(this.custom)
|
|
|
|
|
|
);
|
|
|
|
|
|
this.esc();
|
2020-01-08 22:19:46 +08:00
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
2020-02-17 18:20:14 +08:00
|
|
|
|
//点击all是否是全部取消选中,true为是
|
|
|
|
|
|
isCancel() {
|
|
|
|
|
|
let isCancel = true;
|
2020-08-04 21:53:06 +08:00
|
|
|
|
for (let i = 0; i < this.custom.length; i++) {
|
|
|
|
|
|
if (!this.custom[i].show) {
|
2020-02-17 18:20:14 +08:00
|
|
|
|
isCancel = false;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return isCancel;
|
|
|
|
|
|
}
|
2020-01-08 22:19:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<style lang="scss">
|
|
|
|
|
|
.pop-custom {
|
2020-01-17 16:06:35 +08:00
|
|
|
|
padding: 0 12px 12px 12px;
|
2020-01-08 22:19:46 +08:00
|
|
|
|
border: 1px solid #EBEEF5;
|
2020-01-17 16:06:35 +08:00
|
|
|
|
box-shadow: $pop-box-shadow;
|
2020-08-04 21:53:06 +08:00
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 83px;
|
|
|
|
|
|
right: 0;
|
2020-01-08 22:19:46 +08:00
|
|
|
|
width: 200px;
|
|
|
|
|
|
color: #606266;
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
border-radius: 4px;
|
2020-05-28 17:32:23 +08:00
|
|
|
|
z-index: 999999;
|
2020-01-08 22:19:46 +08:00
|
|
|
|
}
|
2020-08-04 21:53:06 +08:00
|
|
|
|
.relative-position .pop-custom {
|
|
|
|
|
|
top: 33px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.custom-labels {
|
2020-02-17 18:20:14 +08:00
|
|
|
|
margin-top: 12px;
|
2020-01-08 22:19:46 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 300px;
|
|
|
|
|
|
}
|
2020-08-04 21:53:06 +08:00
|
|
|
|
.custom-labels i {
|
2020-01-08 22:19:46 +08:00
|
|
|
|
color: #04b330;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
left: 5px;
|
|
|
|
|
|
top: 6px;
|
|
|
|
|
|
}
|
2020-08-04 21:53:06 +08:00
|
|
|
|
.custom-label {
|
2020-01-08 22:19:46 +08:00
|
|
|
|
padding: 2px 0 2px 25px;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
cursor: default;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
2020-08-04 21:53:06 +08:00
|
|
|
|
.custom-label-disabled {
|
2020-01-08 22:19:46 +08:00
|
|
|
|
cursor: not-allowed;
|
|
|
|
|
|
background: #f1f3f4;
|
|
|
|
|
|
opacity: 0.7;
|
|
|
|
|
|
}
|
2020-08-04 21:53:06 +08:00
|
|
|
|
.custom-bottom-btns {
|
2020-01-08 22:19:46 +08:00
|
|
|
|
margin-top: 7px;
|
2020-02-17 18:20:14 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: center;
|
2020-01-08 22:19:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
.unshow {
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|