move.vue 5.84 KB
Newer Older
xd's avatar
xd committed
1
<template>
xd's avatar
xd committed
2 3
  <div class="ct">
    <el-dialog
xd's avatar
xd committed
4
      title="请选择分组"
xd's avatar
xd committed
5
      :visible.sync="moveDialog"
xd's avatar
xd committed
6
      width="30%"
xd's avatar
xd committed
7 8 9
      :show-close="false"
      :close-on-click-modal="false"
    >
xd's avatar
xd committed
10 11 12 13 14 15 16
      <!-- <div class="choose">
        <div class="title">
          <div class="cg">选择分组</div>
          <div class="circle" @click="handleClose">
            <d2-icon-svg name="close" class="icon" />
          </div>
        </div>
xd's avatar
xd committed
17
        <tree-transfer
xd's avatar
xd committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31
          :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">
xd's avatar
xd committed
32 33 34 35 36
          <div class="cg">选择分组</div>
          <div class="circle" @click="handleClose">
            <d2-icon-svg name="close" class="icon" />
          </div>
        </div>
xd's avatar
xd committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
        <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>
xd's avatar
xd committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
        </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>

xd's avatar
xd committed
69
      <span slot="footer" class="dialog-footer">
xd's avatar
xd committed
70 71 72 73
        <el-button @click="handleCancel" size="small">取 消</el-button>
        <el-button type="primary" @click="handleFinish" size="small"
          >确 定</el-button
        >
xd's avatar
xd committed
74 75
      </span>
    </el-dialog>
xd's avatar
xd committed
76
    <div></div>
xd's avatar
xd committed
77 78 79 80
  </div>
</template>

<script>
xd's avatar
xd committed
81
import { getGroup, moveMember } from "@/api/in/mail";
xd's avatar
xd committed
82 83
import { log } from "util";

xd's avatar
xd committed
84 85 86 87 88
export default {
  props: {
    moveDialog: {
      type: Boolean,
      default: false
xd's avatar
xd committed
89 90 91 92
    },
    idList: {
      type: Array,
      default: () => []
xd's avatar
xd committed
93 94
    }
  },
xd's avatar
xd committed
95
  data() {
xd's avatar
xd committed
96
    return {
xd's avatar
xd committed
97 98 99 100 101 102
      orgData: {
        label: "name",
        children: "adminStallList",
        id: "id"
      },
      treeData: []
xd's avatar
xd committed
103
    };
xd's avatar
xd committed
104
  },
xd's avatar
xd committed
105 106 107
  created() {
    this.getList();
  },
xd's avatar
xd committed
108
  methods: {
xd's avatar
xd committed
109 110
    handleCancel() {
      this.$emit("handleCancel");
xd's avatar
xd committed
111
    },
xd's avatar
xd committed
112
    handleFinish() {
xd's avatar
xd committed
113 114 115
      let groupId = this.$refs.tree.getCheckedKeys()[0]
      let data = {
        stallIds: groupId,
xd's avatar
xd committed
116
        userIds: this.idList+','
xd's avatar
xd committed
117 118
      }
      moveMember(data).then(res=> {
xd's avatar
xd committed
119
        this.$emit("handleFinish", false);
xd's avatar
xd committed
120
      })
xd's avatar
xd committed
121
      
xd's avatar
xd committed
122
    },
xd's avatar
xd committed
123
    /* handleChange() {},
xd's avatar
xd committed
124
    handleClose() {
xd's avatar
xd committed
125
      this.$emit("handleCancel");
xd's avatar
xd committed
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
    },
    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);
    },
xd's avatar
xd committed
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
    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]);
        }
xd's avatar
xd committed
161
      }
xd's avatar
xd committed
162 163 164 165 166 167 168 169 170 171 172 173 174
    },

    getList() {
      getGroup().then(res => {
        console.log(res, "移动的数据获取");
        let obj = {
          name: "未分组",
          id: 0
        };
        res.data = [obj, ...res.data];
        this.treeData = res.data;
      });
    }
xd's avatar
xd committed
175 176 177 178
  }
};
</script>

xd's avatar
xd committed
179
<style scoped>
xd's avatar
xd committed
180 181 182 183 184 185 186
.tree >>> .is-leaf + .el-checkbox .el-checkbox__inner {
  display: inline-block;
}
.tree >>> .el-checkbox .el-checkbox__inner {
  display: none;
}

xd's avatar
xd committed
187 188 189 190 191 192 193
.choose {
  padding: 16px;
  font-size: 16px;
  font-weight: bold;
  color: rgba(56, 56, 56, 1);
  box-sizing: border-box;
}
xd's avatar
xd committed
194
.title {
xd's avatar
xd committed
195 196 197
  display: flex;
  align-items: center;
  justify-content: space-between;
xd's avatar
xd committed
198 199
  /* border-bottom: 1px solid #f8f8f8; */
  padding-bottom: 10px;
xd's avatar
xd committed
200 201 202 203 204 205
}
.transfer-footer {
  margin-left: 20px;
  padding: 6px 5px;
}
.ct >>> .el-dialog__header {
xd's avatar
xd committed
206
  border-bottom: 1px solid #f8f8f8;
xd's avatar
xd committed
207 208
}
.ct >>> .el-dialog__body {
xd's avatar
xd committed
209
  padding: 20px 40px;
xd's avatar
xd committed
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
}
.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%);
}
xd's avatar
xd committed
230
.br {
xd's avatar
xd committed
231 232 233
  border-top: 1px solid #f8f8f8;
  border-bottom: 1px solid #f8f8f8;
  padding: 24px 0;
xd's avatar
xd committed
234
}
xd's avatar
xd committed
235
</style>