<template> <div class="ct"> <el-dialog title="请选择分组" :visible.sync="moveDialog" width="30%" :show-close="false" :close-on-click-modal="false" > <!-- <div class="choose"> <div class="title"> <div class="cg">选择分组</div> <div class="circle" @click="handleClose"> <d2-icon-svg name="close" class="icon" /> </div> </div> <tree-transfer :title="title" :button_text="['添加', '删除']" :from_data="fromData" :to_data="toData" :defaultProps="{ label: 'label' }" @addBtn="add" @removeBtn="remove" :mode="mode" height="540px" :filter="false" openAll > </tree-transfer> <div class="title"> <div class="cg">选择分组</div> <div class="circle" @click="handleClose"> <d2-icon-svg name="close" class="icon" /> </div> </div> <div class="br"> <div style="text-align: center"> <el-transfer style="text-align: left; display: inline-block" v-model="value4" :left-default-checked="[]" :right-default-checked="[]" :titles="['选择', '已选']" :button-texts="['删除', '添加']" @change="handleChange" :data="data" > <span slot-scope="{ option }" >{{ option.key }} - {{ option.label }}</span > </el-transfer> </div> </div> </div> --> <el-tree ref="tree" class="tree" show-checkbox :check-strictly="true" :data="treeData" :props="orgData" node-key="id" @node-click="handleNodeClick" @check-change="checkChange" > </el-tree> <span slot="footer" class="dialog-footer"> <el-button @click="handleCancel" size="small">取 消</el-button> <el-button type="primary" @click="handleFinish" size="small" >确 定</el-button > </span> </el-dialog> <div></div> </div> </template> <script> import { getGroup, moveMember } from "@/api/in/mail"; import { log } from "util"; export default { props: { moveDialog: { type: Boolean, default: false }, idList: { type: Array, default: () => [] } }, data() { return { orgData: { label: "name", children: "adminStallList", id: "id" }, treeData: [] }; }, created() { this.getList(); }, methods: { handleCancel() { this.$emit("handleCancel"); }, handleFinish() { let groupId = this.$refs.tree.getCheckedKeys()[0] let data = { stallIds: groupId, userIds: this.idList+',' } moveMember(data).then(res=> { this.$emit("handleFinish", false); }) }, /* handleChange() {}, handleClose() { this.$emit("handleCancel"); }, changeMode() { if (this.mode == "transfer") { this.mode = "addressList"; } else { this.mode = "transfer"; } }, add(fromData, toData, obj) { // 树形穿梭框模式transfer时,返回参数为左侧树移动后数据、右侧树移动后数据、移动的{keys,nodes,halfKeys,halfNodes}对象 // 通讯录模式addressList时,返回参数为右侧收件人列表、右侧抄送人列表、右侧密送人列表 console.log("fromData:", fromData); console.log("toData:", toData); console.log("obj:", obj); }, remove(fromData, toData, obj) { // 树形穿梭框模式transfer时,返回参数为左侧树移动后数据、右侧树移动后数据、移动的{keys,nodes,halfKeys,halfNodes}对象 // 通讯录模式addressList时,返回参数为右侧收件人列表、右侧抄送人列表、右侧密送人列表 console.log("fromData:", fromData); console.log("toData:", toData); console.log("obj:", obj); }, */ handleNodeClick(item, node, self) { //自己定义的editCheckId,防止单选出现混乱 this.editCheckId = item.id; this.$refs.tree.setCheckedKeys([item.id]); }, checkChange(item, node, self) { if (node == true) { this.editCheckId = item.id; this.$refs.tree.setCheckedKeys([item.id]); } else { if (this.editCheckId == item.id) { this.$refs.tree.setCheckedKeys([item.id]); } } }, getList() { getGroup().then(res => { console.log(res, "移动的数据获取"); let obj = { name: "未分组", id: 0 }; res.data = [obj, ...res.data]; this.treeData = res.data; }); } } }; </script> <style scoped> .tree >>> .is-leaf + .el-checkbox .el-checkbox__inner { display: inline-block; } .tree >>> .el-checkbox .el-checkbox__inner { display: none; } .choose { padding: 16px; font-size: 16px; font-weight: bold; color: rgba(56, 56, 56, 1); box-sizing: border-box; } .title { display: flex; align-items: center; justify-content: space-between; /* border-bottom: 1px solid #f8f8f8; */ padding-bottom: 10px; } .transfer-footer { margin-left: 20px; padding: 6px 5px; } .ct >>> .el-dialog__header { border-bottom: 1px solid #f8f8f8; } .ct >>> .el-dialog__body { padding: 20px 40px; } .ct >>> .el-transfer-panel { width: 250px; } .circle { width: 30px; height: 30px; line-height: 30px; border-radius: 50%; border: 1px solid rgba(208, 2, 27, 1); position: relative; } .circle >>> .icon { width: 28px; height: 28px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); } .br { border-top: 1px solid #f8f8f8; border-bottom: 1px solid #f8f8f8; padding: 24px 0; } </style>