addGroup.vue 5.01 KB
Newer Older
wengjianling's avatar
wengjianling committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
<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>