vue 用穿梭框实现列的展示与不展示
HTML代码 + 注释
<el-dialog
width="40%"
title="自定义展示列"
:visible.sync="customPresentationLog"
append-to-body
class="import-dialog"
:close-on-click-modal="false"
>
<template>
<el-transfer
v-model="valueArr" //展示的数据
:data="dataBorder" // 不展示的数据
:titles="['不展示的列', '展示的列']"
@change="changeColumn" //获取到的是右边框(展示的列的数据)
>
</el-transfer>
<div slot="footer" class="dialog-footer">
<el-button @click="customPresentationLog = false" size="small">取 消</el-button>
<el-button type="primary" @click="submitTansfer()"
:loading="formLoading"
size="small">
{{ formLoading ? '提交中...' : '确 定'}}
</el-button>
</div>
</template>
</el-dialog>
js代码
return:{
valueArr: [],
dataBorder: [],
fieldArr:[],
},
methods: {
//自定义展示列
//在后台返回数据进行赋值
customPresentation() {
$.ajax({
url: "{:url('.....')}",
type: 'POST',
data: {},
responseType: 'json',
success: (result) => {
if (result.code) {
let tmp = result.data;
const data = [];
const notshow = [];
for (let i = 0; i < tmp.length; i++) {
notshow.push({
key: tmp[i].id,
label: tmp[i].filed_mean,
});
if (tmp[i]['type'] == 0) {
data.push(
tmp[i].id
)
}
}
this.oldIdArr = this.valueArr = data;//展示的列
this.dataBorder = notshow;//不展示的列
this.customPresentationLog = true
} else {
this.$message({
message: '查询失败',
type: 'error'
});
}
}
})
},
changeColumn(value, direction, movedKeys) {
console.log(value)
this.fieldArr = value // 赋值
},
}
版权声明:本文为weixin_45849851原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。