<template>
|
<el-dialog
|
v-dialogDrag
|
:close-on-click-modal="false"
|
:destroy-on-close="true"
|
:title="title"
|
:visible.sync="visible"
|
append-to-body="true"
|
class="avue-dialog"
|
style="text-align: center"
|
width="50%"
|
@close="dialogClose">
|
<el-transfer
|
v-model="rightRoleData"
|
v-loading="loading"
|
:data="data"
|
:filter-method="filterMethod"
|
:render-content="renderFunc"
|
:titles="transferTitle"
|
filter-placeholder="关键词搜索"
|
filterable
|
style="text-align: left; display: inline-block;">
|
</el-transfer>
|
<div slot="footer" class="dialog-footer">
|
<div class="valueInfo" v-if="bottomValue">已设置的值为:[{{bottomValue}}]</div>
|
<el-button @click="visible = false" size="small">取 消</el-button>
|
<el-button type="primary" @click="sendHandler" size="small">确 定</el-button>
|
</div>
|
</el-dialog>
|
</template>
|
|
<script>
|
export default {
|
name: "transfer",
|
props: ['title', 'leftRoleData', 'rightRoleData', 'transferTitle' , 'bottomValue'],
|
data() {
|
return {
|
visible: false, // 通过 this.$refs.transfer.visible = true; 开启子组件对话框
|
data: [],
|
loading: false,
|
filterMethod(query, item) {
|
return item.label.indexOf(query) > -1;
|
},
|
renderFunc(h, option) {
|
return <span><i class="el-icon-s-custom"></i> {option.label}</span>;
|
}
|
}
|
},
|
watch: {
|
//渲染穿梭框
|
leftRoleData: {
|
handler(newval) {
|
if (newval) {
|
// 清空data数组
|
this.data = [];
|
newval.forEach((item) => {
|
this.data.push({
|
label: item.name,
|
key: item.oid,
|
});
|
});
|
this.loading = false;
|
}
|
}
|
},
|
},
|
created() {
|
this.loading = true;
|
},
|
methods: {
|
dialogClose() {
|
this.visible = false;
|
this.data = [];
|
this.leftRoleData = [];
|
},
|
sendHandler() {
|
this.$emit('transferSend', this.rightRoleData);
|
this.visible = false;
|
},
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
/deep/ .el-transfer-panel {
|
height: 450px; /* 左右两个穿梭框的高度和宽度 */
|
width: 300px;
|
}
|
|
/deep/ .el-transfer-panel__list.is-filterable {
|
height: 323px; /* 穿梭框列表高度 */
|
}
|
.valueInfo{
|
float: left;
|
border: 1px solid #E9E7E7;
|
display: inline-block;
|
vertical-align: middle;
|
padding: 6px 12px;
|
line-height: 1;
|
}
|
</style>
|