2020-01-08 22:19:46 +08:00
|
|
|
|
<template>
|
2023-03-24 14:27:34 +08:00
|
|
|
|
<div class="pop-custom" :class="{'pop-custom-top' : tableClass || operationTrue}" v-clickoutside="esc" @click.stop>
|
2023-03-14 10:52:30 +08:00
|
|
|
|
<div class="pop-title" @click.stop>{{$t('overall.selectColumns')}}</div>
|
|
|
|
|
|
<div class="pop-box custom-labels" @click.stop>
|
2020-12-14 20:25:24 +08:00
|
|
|
|
<div style="height: 100%; overflow: auto;">
|
2020-08-05 11:18:55 +08:00
|
|
|
|
<!--NotSet 为true不可设置-->
|
2023-05-17 16:43:27 +08:00
|
|
|
|
<draggable
|
|
|
|
|
|
v-model="custom"
|
|
|
|
|
|
:move="move"
|
|
|
|
|
|
@start="start"
|
|
|
|
|
|
@end="end"
|
|
|
|
|
|
:scroll-sensitivity="30"
|
|
|
|
|
|
:options="{
|
|
|
|
|
|
dragClass:'drag-elementSet-class',
|
|
|
|
|
|
fallbackClass:'fallback-class',
|
|
|
|
|
|
forceFallback:true,
|
|
|
|
|
|
ghostClass:'chart-ghost',
|
|
|
|
|
|
chosenClass:'chosen-class',
|
|
|
|
|
|
scroll:true,
|
|
|
|
|
|
filter: '.drag-disabled',
|
|
|
|
|
|
animation: 150,
|
|
|
|
|
|
handle: '.drag-sort'
|
|
|
|
|
|
}"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-for="(item,index) in custom"
|
|
|
|
|
|
v-if="item.type!=='title'&&item.type!=='label'"
|
|
|
|
|
|
:key="index"
|
|
|
|
|
|
class="custom-label"
|
|
|
|
|
|
@click.stop="handler(item,index)"
|
|
|
|
|
|
:id="'element-set-el-'+index"
|
|
|
|
|
|
:class="{'custom-title orange-font':item.type == 'title','custom-label-disabled':!allowedAll&&!item.allowed && (index==0 || index == 1 || item.NotSet),'drag-disabled':index==0 || index == 1 || item.NotSet}"
|
|
|
|
|
|
>
|
|
|
|
|
|
<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>
|
2023-08-17 14:34:01 +08:00
|
|
|
|
<span :title="item.label">{{item.label}}</span>
|
2023-05-17 16:43:27 +08:00
|
|
|
|
<i class="nz-icon nz-icon-sort drag-sort" v-if="index!==0 && index !== 1 && !item.NotSet" @click.stop></i>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</draggable>
|
|
|
|
|
|
<!-- asset Attributes -->
|
|
|
|
|
|
<draggable
|
|
|
|
|
|
v-model="custom"
|
|
|
|
|
|
:move="move"
|
|
|
|
|
|
@start="start"
|
|
|
|
|
|
@end="end"
|
|
|
|
|
|
:scroll-sensitivity="30"
|
|
|
|
|
|
:options="{
|
|
|
|
|
|
dragClass:'drag-elementSet-class',
|
|
|
|
|
|
fallbackClass:'fallback-class',
|
|
|
|
|
|
forceFallback:true,
|
|
|
|
|
|
ghostClass:'chart-ghost',
|
|
|
|
|
|
chosenClass:'chosen-class',
|
|
|
|
|
|
scroll:true,
|
|
|
|
|
|
filter: '.drag-disabled',
|
|
|
|
|
|
animation: 150,
|
|
|
|
|
|
handle: '.drag-sort'
|
|
|
|
|
|
}"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-for="(item,index) in custom"
|
|
|
|
|
|
v-if="item.type==='title'||item.type==='label'"
|
|
|
|
|
|
:key="index"
|
|
|
|
|
|
class="custom-label"
|
|
|
|
|
|
@click.stop="handler(item,index)"
|
|
|
|
|
|
:id="'element-set-el-'+index"
|
|
|
|
|
|
:class="{'custom-title orange-font':item.type == 'title','custom-label-disabled':!allowedAll&&!item.allowed && (index==0 || index == 1 || item.NotSet),'drag-disabled':index==0 || index == 1 || item.NotSet}"
|
|
|
|
|
|
>
|
|
|
|
|
|
<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>
|
2023-08-17 14:34:01 +08:00
|
|
|
|
<span :title="item.label">{{item.label}}</span>
|
2023-05-17 16:43:27 +08:00
|
|
|
|
<i class="nz-icon nz-icon-sort drag-sort" v-if="index!==0 && index !== 1 && !item.NotSet" @click.stop></i>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</draggable>
|
2020-12-14 20:25:24 +08:00
|
|
|
|
</div>
|
2020-01-08 22:19:46 +08:00
|
|
|
|
</div>
|
2023-03-14 10:52:30 +08:00
|
|
|
|
<div class="custom-bottom-btns" @click.stop>
|
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>
|
2023-08-30 17:30:36 +08:00
|
|
|
|
<button :id="tableId+'-element-set-save'" class="nz-btn nz-btn-size-small nz-btn-style-normal" :class="{'nz-btn-disabled': !custom.length}" :disabled="!custom.length" 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>
|
2023-05-17 16:43:27 +08:00
|
|
|
|
import draggable from 'vuedraggable'
|
2020-01-08 22:19:46 +08:00
|
|
|
|
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
|
|
|
|
},
|
2023-05-17 16:43:27 +08:00
|
|
|
|
components: {
|
|
|
|
|
|
draggable
|
|
|
|
|
|
},
|
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 () {
|
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') {
|
2022-07-22 17:37:35 +08:00
|
|
|
|
if ((index == 0 || index == 1 || this.custom[index].NotSet || this.custom[index].visibility == 'disabled')) {
|
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) {
|
2022-07-22 17:37:35 +08:00
|
|
|
|
if (!this.allowedAll && !val.allowed && (index == 0 || index == 1 || val.NotSet || val.visibility == 'disabled')) {
|
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 () {
|
2024-04-24 16:37:51 +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)
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.esc()
|
2023-05-17 16:43:27 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 禁止拖动的对象
|
|
|
|
|
|
move (e) {
|
|
|
|
|
|
const index = e.relatedContext.index
|
|
|
|
|
|
const item = e.relatedContext.element
|
|
|
|
|
|
if (index == 0 || index == 1 || item.NotSet) return false
|
|
|
|
|
|
return true
|
|
|
|
|
|
},
|
|
|
|
|
|
start () {
|
|
|
|
|
|
document.body.classList.add('isDrag')
|
|
|
|
|
|
},
|
|
|
|
|
|
end () {
|
|
|
|
|
|
document.body.classList.remove('isDrag')
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
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>
|