2021-06-11 10:00:22 +08:00
|
|
|
|
<template>
|
2021-07-23 10:11:09 +08:00
|
|
|
|
<div class="pop-custom" v-ele-click-outside="esc">
|
2021-06-11 10:00:22 +08:00
|
|
|
|
<div class="pop-title">{{$t('overall.select')}}</div>
|
|
|
|
|
|
<div class="pop-box custom-labels">
|
2021-07-26 14:05:51 +08:00
|
|
|
|
<div style="height: 100%; border-radius:2%; border:1px solid #DCDFE6; overflow: auto;">
|
2021-06-11 10:00:22 +08:00
|
|
|
|
<!--NotSet 为true不可设置-->
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-for="(item,index) in custom"
|
|
|
|
|
|
:key="index"
|
|
|
|
|
|
class="custom-label"
|
|
|
|
|
|
@click="handler(item,index)"
|
|
|
|
|
|
:id="'element-set-el-'+index"
|
|
|
|
|
|
>
|
2021-06-18 15:25:13 +08:00
|
|
|
|
<i class="cn-icon cn-icon-check" v-if="!allowedAll && !item.allowed && (index === 0 || index === 1 || item.visibility === 'disabled')"></i>
|
|
|
|
|
|
<i v-else class="cn-icon cn-icon-check" v-show="item.show"></i>
|
2021-06-11 10:00:22 +08:00
|
|
|
|
<span>{{item.label}}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="custom-bottom-btns">
|
2021-07-23 10:11:09 +08:00
|
|
|
|
<el-button size="mini" v-if="isCancel" :id="tableId+'-element-set-none'" class="cn-btn cn-btn-size-small-new cn-btn-style-light-new is-cancel" type="button" @click="batchHandler(false)">
|
2021-06-11 10:00:22 +08:00
|
|
|
|
<span class="top-tool-btn-txt">{{$t('overall.clear')}}</span>
|
2021-07-23 10:11:09 +08:00
|
|
|
|
</el-button>
|
|
|
|
|
|
<el-button size="mini" v-if="!isCancel" :id="tableId+'-element-set-all'" class="cn-btn cn-btn-size-small-new cn-btn-style-light-new" type="button" @click="batchHandler(true)">
|
2021-06-11 10:00:22 +08:00
|
|
|
|
<span class="top-tool-btn-txt">{{$t('overall.all')}}</span>
|
2021-07-23 10:11:09 +08:00
|
|
|
|
</el-button>
|
2021-06-11 10:00:22 +08:00
|
|
|
|
<div>
|
2021-07-23 10:11:09 +08:00
|
|
|
|
<el-button size="mini" :id="tableId+'-element-set-esc'" class="cn-btn cn-btn-size-small-new cn-btn-style-light-new" type="button" @click="esc">
|
2021-06-11 10:00:22 +08:00
|
|
|
|
<span class="top-tool-btn-txt">{{$t('overall.esc')}}</span>
|
2021-07-23 10:11:09 +08:00
|
|
|
|
</el-button>
|
2021-07-26 14:05:51 +08:00
|
|
|
|
<el-button size="mini" :id="tableId+'-element-set-save'" class="cn-btn cn-btn-size-small-new cn-btn-style-normal-new" type="button" @click="save" style="background-color: #0091ff;color:#DCDFE6">
|
2021-06-11 10:00:22 +08:00
|
|
|
|
<span class="top-tool-btn-txt">{{$t('overall.save')}}</span>
|
2021-07-23 10:11:09 +08:00
|
|
|
|
</el-button>
|
2021-06-11 10:00:22 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
export default {
|
|
|
|
|
|
props: {
|
|
|
|
|
|
customTableTitle: Array, // 自定义的title
|
|
|
|
|
|
originalTableTitle: Array, // 原始title
|
|
|
|
|
|
tableId: String,
|
|
|
|
|
|
allowedAll: { default: false }
|
|
|
|
|
|
},
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
custom: []
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
created () {
|
2021-06-23 15:57:34 +08:00
|
|
|
|
const localStorageTitle = JSON.parse(localStorage.getItem('cn-tableTitle-' + localStorage.getItem('cn-username') + '-' + this.tableId))
|
2021-06-11 10:00:22 +08:00
|
|
|
|
if (localStorageTitle) {
|
2021-06-23 15:57:34 +08:00
|
|
|
|
localStorage.setItem('cn-tableTitle-' + localStorage.getItem('cn-username') + '-' + this.tableId, JSON.stringify(localStorageTitle))
|
2021-06-11 10:00:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
customTableTitle: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler (n) {
|
|
|
|
|
|
this.custom = JSON.parse(JSON.stringify(n))
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
// 悬浮点击空白隐藏
|
|
|
|
|
|
esc () {
|
|
|
|
|
|
this.$emit('close')
|
|
|
|
|
|
},
|
|
|
|
|
|
// 全选all true 或者全取消cancel false按钮
|
|
|
|
|
|
batchHandler (state) {
|
|
|
|
|
|
for (let index = 0; index < this.custom.length; index++) {
|
|
|
|
|
|
if (this.custom[index].type !== 'title') {
|
|
|
|
|
|
if ((index === 0 || index === 1 || this.custom[index].NotSet)) {
|
|
|
|
|
|
this.custom[index].show = true
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.custom[index].show = state
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 单选
|
|
|
|
|
|
handler (val, index) {
|
|
|
|
|
|
if (!this.allowedAll && !val.allowed && (index === 0 || index === 1 || val.NotSet)) {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.custom[index].show = !this.custom[index].show
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 点击第二个cancel
|
|
|
|
|
|
save () {
|
|
|
|
|
|
this.$emit('update', this.custom)
|
|
|
|
|
|
localStorage.setItem(
|
2021-06-23 15:57:34 +08:00
|
|
|
|
'cn-tableTitle-' + localStorage.getItem('cn-username') + '-' + this.tableId,
|
2021-06-11 10:00:22 +08:00
|
|
|
|
JSON.stringify(this.custom)
|
|
|
|
|
|
)
|
|
|
|
|
|
this.esc()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
|
|
|
|
|
// 点击all是否是全部取消选中,true为是
|
|
|
|
|
|
isCancel () {
|
|
|
|
|
|
let isCancel = true
|
|
|
|
|
|
for (let i = 0; i < this.custom.length; i++) {
|
|
|
|
|
|
if (!this.custom[i].show && this.custom[i].type !== 'title') {
|
|
|
|
|
|
isCancel = false
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return isCancel
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
2021-07-26 14:05:51 +08:00
|
|
|
|
.pop-title{
|
|
|
|
|
|
margin-top: 7px;
|
|
|
|
|
|
}
|
2021-06-11 10:00:22 +08:00
|
|
|
|
.pop-custom {
|
|
|
|
|
|
padding: 0 12px 12px 12px;
|
|
|
|
|
|
border: 1px solid #EBEEF5;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 55px;
|
|
|
|
|
|
right: 20px;
|
|
|
|
|
|
width: 200px;
|
|
|
|
|
|
color: #606266;
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
z-index: 999999;
|
2021-07-26 14:05:51 +08:00
|
|
|
|
box-shadow: inset 0 0 10px #CCC;
|
|
|
|
|
|
box-sizing:border-box
|
2021-06-11 10:00:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
.pop-custom-explore {
|
|
|
|
|
|
top: 33px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.relative-position .pop-custom {
|
|
|
|
|
|
top: 33px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.custom-labels {
|
|
|
|
|
|
margin-top: 12px;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 300px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.custom-labels i {
|
|
|
|
|
|
color: #04b330;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
left: 5px;
|
|
|
|
|
|
top: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.custom-label {
|
|
|
|
|
|
padding: 2px 0 2px 25px;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
cursor: default;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
2021-07-26 14:05:51 +08:00
|
|
|
|
.custom-label:hover{
|
|
|
|
|
|
color: #cccccc;
|
|
|
|
|
|
background-color: #DCDFE6;
|
|
|
|
|
|
}
|
2021-06-11 10:00:22 +08:00
|
|
|
|
.custom-title{
|
|
|
|
|
|
padding: 2px 0 2px 2px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.custom-label-disabled {
|
|
|
|
|
|
cursor: not-allowed;
|
|
|
|
|
|
background: #f1f3f4;
|
|
|
|
|
|
opacity: 0.7;
|
|
|
|
|
|
}
|
|
|
|
|
|
.custom-bottom-btns {
|
|
|
|
|
|
margin-top: 7px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
.unshow {
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|
2021-07-23 10:11:09 +08:00
|
|
|
|
<style scoped>
|
|
|
|
|
|
/deep/ .el-button--mini{
|
|
|
|
|
|
padding: 5px 7px;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|