addGroup.vue 5.01 KB
<template>
  <div class="ct">
    <el-dialog
      title="创建子部门"
      :visible.sync="addDialog"
      width="30%"
      :show-close="false"
      :close-on-click-modal="false"
    >
      <div class="config_item">
        <label class="config_name">部门名称</label>
        <el-input class="config_value" v-model="params.d_name" placeholder="请输入部门名称" />
      </div>

      <div class="config_item">
        <span class="config_name">上级部门</span>
        <div>
          <div @click="showTreeData" class="config_value father_group">
            <span class="father_name_text">{{ paramsForShow.father_name }}</span>
            <span :class="showTree ? 'arrow_up' : 'arrow_down'"></span>
          </div>
          
        </div>
      </div>

      <div class="tree_data" v-if="showTree">
        <el-tree
          ref="tree"
          class="tree"
          :check-strictly="true"
          :data="treeData"
          node-key="id"
          @node-click="handleNodeClick"
          @check-change="checkChange"
        >
        </el-tree>
      </div>

      <div class="config_item">
        <label class="config_name">店铺编号</label>
        <el-input class="config_value" v-model="params.code" placeholder="请输入店铺编号" />
      </div>
      <div class="tips" v-if="checked">请将表单填写完整</div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleAddCancel" size="small">取 消</el-button>
        <el-button type="primary" @click="handleAddFinish" size="small"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <div></div>
  </div>
</template>

<script>
import { addGroup, getOrgTree } from "@/api/in/mail";
import { log } from "util";

export default {
  props: {
    addDialog: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      treeData: [],
      group_name: '',
      shop_code: '',
      showTree: false,
      paramsForShow: {
        name: '',
        father_name: '',
        code: ''
      },
      params: {
        d_name: '',
        d_parentId: '',
        code: ''
      },
      checked: false
    };
  },
  created() {
    this.getList()
  },
  methods: {
    handleAddCancel() {
      this.$emit("handleAddCancel");
    },
    handleAddFinish() {

      if(!this.params.d_name || !this.params.d_parentId || !this.params.code) {
        this.checked = true
        return
      }
      addGroup(this.params).then(res=> {
        // console.log(res)
      })
      // console.log(addGroup)
      this.$emit("handleAddFinish");
    },
    handleNodeClick(item, node, self) {
      // console.log(item,node,self)
      this.params.d_parentId = item.id;
      this.paramsForShow.father_name = item.label
    },
    checkChange(item, node, self) {
      
    },
    showTreeData() {
      this.showTree = !this.showTree
    },

    getList() {
      getOrgTree().then(res => {
        console.log(res.data.organizations)
        this.treeData = [res.data.organizations];
      }).catch(err => {
        console.log(err)
      });
    }
  }
};
</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;
}
.config_item {
  display: flex;
  flex-direction: row;
  align-items: center;
}
.config_name:before {
  content: '* ';
  color: red;
}
.config_name {
  width: 80px;
  text-align: center;
  margin-right: 10px;
}
.config_value {
  width: 230px;
}
.father_group {
  margin: 10px 0;
  width: 228px;
  height: 38px;
  border-radius: 4px;
  border: 1px solid #DCDFE6;
  position: relative;
}
.arrow_down {
  width: 0;
  height: 0;
  border-width: 5px;
  border-style: solid;
  border-color: #ccc transparent transparent transparent;
  position: absolute;
  right: 10px;
  top: 20px;
}
.arrow_up {
  width: 0;
  height: 0;
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent #ccc transparent;
  position: absolute;
  right: 10px;
  top: 15px;
}
.tree_data {
  margin-left: 90px;
}
.father_name_text {
  line-height: 38px;
  padding-left: 15px;
}
.tips {
  width: 100%;
  text-align: center;
  color: red;
  margin: 5px 0;
}
</style>