2020-01-08 22:19:46 +08:00
|
|
|
|
<template>
|
2021-09-27 15:39:23 +08:00
|
|
|
|
<div class="pop-custom" :class="{'pop-custom-top' : tableClass || operationTrue}" v-clickoutside="esc">
|
2021-11-10 17:40:57 +08:00
|
|
|
|
<div class="pop-title">{{$t('overall.selectColumns')}}</div>
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<div class="pop-box custom-labels">
|
2020-12-14 20:25:24 +08:00
|
|
|
|
<div style="height: 100%; overflow: auto;">
|
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"
|
2021-12-27 15:37:14 +08:00
|
|
|
|
@click.stop="handler(item,index)"
|
2020-01-13 18:48:25 +08:00
|
|
|
|
:id="'element-set-el-'+index"
|
2020-09-08 11:18:18 +08:00
|
|
|
|
:class="{'custom-title orange-font':item.type == 'title','custom-label-disabled':!allowedAll&&!item.allowed && (index==0 || index == 1 || item.NotSet)}"
|
2020-01-08 22:19:46 +08:00
|
|
|
|
>
|
2020-09-10 17:00:32 +08:00
|
|
|
|
<i class="nz-icon nz-icon-check" v-if="!allowedAll&&!item.allowed&&(index==0||index==1||item.visibility=='disabled')"></i>
|
|
|
|
|
|
<i v-else class="nz-icon nz-icon-check" v-show="item.show"></i>
|
2020-01-08 22:19:46 +08:00
|
|
|
|
<span>{{item.label}}</span>
|
|
|
|
|
|
</div>
|
2020-09-08 11:18:18 +08:00
|
|
|
|
|
2020-12-14 20:25:24 +08:00
|
|
|
|
</div>
|
2020-01-08 22:19:46 +08:00
|
|
|
|
</div>
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<div class="custom-bottom-btns">
|
2021-12-27 15:37:14 +08:00
|
|
|
|
<button v-if="isCancel" :id="tableId+'-element-set-none'" class="nz-btn nz-btn-size-small nz-btn-style-light is-cancel" type="button" @click.stop="batchHandler(false)">
|
2020-02-17 18:20:14 +08:00
|
|
|
|
<span class="top-tool-btn-txt">{{$t('overall.clear')}}</span>
|
|
|
|
|
|
</button>
|
2021-12-27 15:37:14 +08:00
|
|
|
|
<button v-if="!isCancel" :id="tableId+'-element-set-all'" class="nz-btn nz-btn-size-small nz-btn-style-light" type="button" @click.stop="batchHandler(true)">
|
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>
|
2021-12-27 15:37:14 +08:00
|
|
|
|
<button :id="tableId+'-element-set-esc'" class="nz-btn nz-btn-size-small nz-btn-style-light" type="button" @click.stop="esc">
|
2022-06-16 15:58:17 +08:00
|
|
|
|
<span class="top-tool-btn-txt">{{$t('overall.cancel')}}</span>
|
2020-02-17 18:20:14 +08:00
|
|
|
|
</button>
|
2021-12-27 15:37:14 +08:00
|
|
|
|
<button :id="tableId+'-element-set-save'" class="nz-btn nz-btn-size-small nz-btn-style-normal" type="button" @click.stop="save">
|
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 {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
props: {
|
|
|
|
|
|
customTableTitle: Array, // 自定义的title
|
|
|
|
|
|
originalTableTitle: Array, // 原始title
|
2021-04-14 18:35:42 +08:00
|
|
|
|
tableId: String,
|
2021-09-26 14:50:22 +08:00
|
|
|
|
allowedAll: { default: false },
|
2021-09-27 15:39:23 +08:00
|
|
|
|
tableClass: Boolean,
|
|
|
|
|
|
operationTrue: Boolean
|
2020-04-23 16:45:59 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
data () {
|
2020-01-08 22:19:46 +08:00
|
|
|
|
return {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
custom: []
|
|
|
|
|
|
}
|
2020-01-08 22:19:46 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
created () {
|
2021-04-14 18:35:42 +08:00
|
|
|
|
const localStorageTitle = JSON.parse(localStorage.getItem('nz-tableTitle-' + localStorage.getItem('nz-username') + '-' + this.tableId))
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (localStorageTitle) {
|
2021-04-14 18:35:42 +08:00
|
|
|
|
localStorage.setItem('nz-tableTitle-' + localStorage.getItem('nz-username') + '-' + this.tableId, 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,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
handler (n) {
|
|
|
|
|
|
this.custom = JSON.parse(JSON.stringify(n))
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-01-08 22:19:46 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 悬浮点击空白隐藏
|
|
|
|
|
|
esc () {
|
|
|
|
|
|
this.$emit('close')
|
2020-01-08 22:19:46 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 全选all true 或者全取消cancel false按钮
|
|
|
|
|
|
batchHandler (state) {
|
2020-08-04 21:53:06 +08:00
|
|
|
|
for (let index = 0; index < this.custom.length; index++) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (this.custom[index].type != 'title') {
|
2020-11-03 17:29:14 +08:00
|
|
|
|
if ((index == 0 || index == 1 || this.custom[index].NotSet)) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.custom[index].show = true
|
2020-11-03 17:29:14 +08:00
|
|
|
|
} else {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.custom[index].show = state
|
2020-11-03 17:29:14 +08:00
|
|
|
|
}
|
2020-01-08 22:19:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 单选
|
|
|
|
|
|
handler (val, index) {
|
|
|
|
|
|
if (!this.allowedAll && !val.allowed && (index == 0 || index == 1 || val.NotSet)) {
|
2020-08-28 16:28:06 +08:00
|
|
|
|
// this.custom[index].show = true;
|
2020-01-08 22:19:46 +08:00
|
|
|
|
} else {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.custom[index].show = !this.custom[index].show
|
2020-01-08 22:19:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 点击第二个cancel
|
|
|
|
|
|
save () {
|
2021-09-13 17:35:45 +08:00
|
|
|
|
if (this.tableId == 'assetTable') {
|
|
|
|
|
|
let customAssetLabel = false
|
|
|
|
|
|
this.custom.forEach(item => {
|
|
|
|
|
|
if (customAssetLabel) {
|
|
|
|
|
|
item.minWidth = item.label.length * 16 + 20
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
if (item.label === 'Label' && item.type == 'title') {
|
|
|
|
|
|
customAssetLabel = true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2021-04-07 09:58:34 +08:00
|
|
|
|
this.$emit('update', this.custom)
|
2020-08-04 21:53:06 +08:00
|
|
|
|
localStorage.setItem(
|
2021-04-14 18:35:42 +08:00
|
|
|
|
'nz-tableTitle-' + localStorage.getItem('nz-username') + '-' + this.tableId,
|
2020-08-04 21:53:06 +08:00
|
|
|
|
JSON.stringify(this.custom)
|
2021-03-19 18:52:19 +08:00
|
|
|
|
)
|
|
|
|
|
|
this.esc()
|
|
|
|
|
|
}
|
2020-01-08 22:19:46 +08:00
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
2021-03-19 18:52:19 +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++) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (!this.custom[i].show && this.custom[i].type != 'title') {
|
|
|
|
|
|
isCancel = false
|
|
|
|
|
|
break
|
2020-02-17 18:20:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return isCancel
|
2020-02-17 18:20:14 +08:00
|
|
|
|
}
|
2020-01-08 22:19:46 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2020-01-08 22:19:46 +08:00
|
|
|
|
</script>
|