vue-element Transfer 穿梭框

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  // 赋值
  	},
  	
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值