<template>
  <div class="ct">
    <el-dialog
      :visible.sync="moveDialog"
      width="55%"
      :show-close="false"
      :close-on-click-modal="false"
    >
      <div class="choose">
        <div class="br">
          <div class="cg">选择分组</div>
          <div class="circle" @click="handleClose">
            <d2-icon-svg name="close" class="icon" />
          </div>
        </div>
      </div>
      <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>
      <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>
</template>

<script>
export default {
  props: {
    moveDialog: {
      type: Boolean,
      default: false
    }
  },
  data() {
    const generateData = _ => {
      const data = [];
      for (let i = 1; i <= 15; i++) {
        data.push({
          key: i,
          label: `备选项 ${i}`
        });
      }
      return data;
    };
    return {
      data: generateData(),
      value: [1],
      value4: [1],
      renderFunc(h, option) {
        return (
          <span>
            {option.key} - {option.label}
          </span>
        );
      }
    };
  },
  methods: {
    handleCancel() {
      this.$emit("handleCancel");
    },
    handleFinish() {
      this.$emit("handleFinish", false);
    },
    handleChange() {},
    handleClose() {
      this.$emit("handleCancel");   
    }
  }
};
</script>

<style scoped>
.choose {
  height: 52px;
  padding: 16px;
  font-size: 16px;
  font-weight: bold;
  color: rgba(56, 56, 56, 1);
  box-sizing: border-box;
  margin-bottom: 20px;
  
}
.br {
  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 {
  padding: 0 !important;
}
.ct >>> .el-dialog__body {
  padding: 0;
}
.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%);
}
</style>
