addGroup.vue 8.97 KB
Newer Older
wengjianling's avatar
wengjianling committed
1 2 3 4 5
<template>
  <div class="ct">
    <el-dialog
      title="创建子部门"
      :visible.sync="addDialog"
xd's avatar
xd committed
6
      width="58%"
wengjianling's avatar
wengjianling committed
7 8 9
      :show-close="false"
      :close-on-click-modal="false"
    >
xd's avatar
xd committed
10
      <el-form :model="addForm" label-width="auto" ref="addStore" :rules="rules" >
xd's avatar
xd committed
11
        <el-form-item label="部门名称:" prop="label">
xd's avatar
xd committed
12 13
          <el-input
            size="small"
xd's avatar
xd committed
14
            v-model="addForm.label"
xd's avatar
xd committed
15 16 17 18
            placeholder="请输入部门名称"
            style="width: 50%;"
          />
        </el-form-item>
xd's avatar
xd committed
19
        <el-form-item label="上级部门:" prop="parentId">
xd's avatar
xd committed
20
          <el-cascader v-model="addForm.parentId" :options="orgTree" :props="deptOption" :show-all-levels="false"  clearable style="width: 50%;" @change="handleDpetChange"></el-cascader>
xd's avatar
xd committed
21
        </el-form-item>
xd's avatar
xd committed
22
        <el-form-item label="门店名称:" prop="oyStallName">
xd's avatar
xd committed
23 24
           <el-input
            size="small"
xd's avatar
xd committed
25
            v-model="addForm.oyStallName"
xd's avatar
xd committed
26 27 28 29
            placeholder="请输入门店名称"
            style="width: 50%;"
          />
        </el-form-item>
xd's avatar
xd committed
30 31 32 33 34 35 36
        <el-form-item label="是否设置详细信息:">
            <el-radio-group v-model="detail" @change="handleDetailChange">
              <el-radio :label="1"></el-radio>
              <el-radio :label="2"></el-radio>
            </el-radio-group>
        </el-form-item>
        <el-form-item label="门店Id:" prop="oyStallCode" v-if="detail == 1">
xd's avatar
xd committed
37 38
           <el-input
            size="small"
xd's avatar
xd committed
39
            v-model="addForm.oyStallCode"
xd's avatar
xd committed
40 41 42 43
            placeholder="请输入门店Id"
            style="width: 50%;"
          />
        </el-form-item>
xd's avatar
xd committed
44
        <el-form-item label="门店会员id:" prop="oyStallMemberId" v-if="detail == 1">
xd's avatar
xd committed
45 46
          <el-input
            size="small"
xd's avatar
xd committed
47
            v-model="addForm.oyStallMemberId"
xd's avatar
xd committed
48 49 50 51
            placeholder="门店会员id:"
            style="width: 50%;"
          />
        </el-form-item>
xd's avatar
xd committed
52 53 54 55 56 57 58 59 60 61
        <el-form-item label="设置主管:" prop="clerkId" v-if="detail == 1">
          <el-cascader :props="props" v-model="deptId" :options="parentDeptList" :show-all-levels="false"  filterable style="width: 30%;margin-right:15px;" @change="handleParentChange" ></el-cascader>
          <el-select v-model="addForm.clerkId" filterable multiple placeholder="请选择" style="width: 30%;" clearble>
            <el-option
              v-for="item in peopleList"
              :key="item.id"
              :label="item.userName"
              :value="item.id">
            </el-option>
          </el-select>
xd's avatar
xd committed
62 63
        </el-form-item>
      </el-form>
wengjianling's avatar
wengjianling committed
64 65
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleAddCancel" size="small">取 消</el-button>
xd's avatar
xd committed
66 67
        <el-button type="primary" @click="handleAddFinish" size="small">确 定</el-button>
      </span> 
wengjianling's avatar
wengjianling committed
68 69 70 71 72 73
    </el-dialog>
    <div></div>
  </div>
</template>

<script>
xd's avatar
xd committed
74
import { addGroup, getWxAllDeptList, getAllMemberList,getGroupById,getAllPeopleList,getOrgTree } from "@/api/in/mail";
wengjianling's avatar
wengjianling committed
75 76 77 78 79 80 81 82 83 84
import { log } from "util";

export default {
  props: {
    addDialog: {
      type: Boolean,
      default: false
    }
  },
  data() {
xd's avatar
xd committed
85 86 87 88 89 90 91 92 93
    // 中英文验证规则
    const nameValidate = (rule, value, callback) => {
      let reg = /^[a-zA-Z\u4e00-\u9fa5]+$/
      if (!reg.test(value)) {
        callback(new Error("含有非法字符(只能输入字母、汉字)!"))
      } else {
        callback()
      }
    }
wengjianling's avatar
wengjianling committed
94 95
    return {
      treeData: [],
xd's avatar
xd committed
96 97
      group_name: "",
      shop_code: "",
wengjianling's avatar
wengjianling committed
98
      showTree: false,
xd's avatar
xd committed
99
      
wengjianling's avatar
wengjianling committed
100
      params: {
xd's avatar
xd committed
101 102 103 104 105 106 107
        d_name: "",
        d_parentId: "",
        code: ""
      },
      checked: false,
      ////
      addForm: {
xd's avatar
xd committed
108 109 110 111 112
        label: '',
        parentId: '',
        oyStallName: '',
        oyStallMemberId: '',
        oyStallCode: '',
xd's avatar
xd committed
113
        clerkId: []
xd's avatar
xd committed
114
      },
xd's avatar
xd committed
115 116
      detail: 2,
      deptId: '',
xd's avatar
xd committed
117 118 119
      // 上级部门
      parentDeptList: [],
      peopleList: [],
xd's avatar
xd committed
120
      orgTree: [],
xd's avatar
xd committed
121
      rules: {
xd's avatar
xd committed
122
        label: [
xd's avatar
xd committed
123 124 125
          { required: true, message: "请输入部门名称", trigger: "blur" },
          { max: 50, message: "长度在50个字符以内", trigger: "blur" }
        ],
xd's avatar
xd committed
126
        parentId: [{ required: true, message: "请选择上级部门", trigger: "change" }]
xd's avatar
xd committed
127

wengjianling's avatar
wengjianling committed
128
      },
xd's avatar
xd committed
129 130 131
      deptOption: {
          value: 'id',
          children: 'children',
xd's avatar
xd committed
132 133 134 135 136 137
          lazy: true,
          emitPath: false,
          checkStrictly: true,
          lazyLoad (node, resolve) {
            const { level } = node;
            setTimeout(() => {
xd's avatar
xd committed
138
              const nodes = Array.from(level)
xd's avatar
xd committed
139 140 141 142
                .map(item => ({
                  value: level.id,
                  label: level.label,
                  leaf: level >= 2
xd's avatar
xd committed
143
                }))
xd's avatar
xd committed
144 145 146 147
              // 通过调用resolve将子节点数据返回,通知组件数据加载完成
              resolve(nodes);
            }, 1000);
          }
xd's avatar
xd committed
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
      },
       props: {
          value: 'id',
          children: 'children',
          lazy: true,
          emitPath: false,
          checkStrictly: true,
          lazyLoad (node, resolve) {
            const { level } = node;
            setTimeout(() => {
              const nodes = Array.from(level)
                .map(item => ({
                  value: level.id,
                  label: level.label,
                  leaf: level >= 2
                }))
              // 通过调用resolve将子节点数据返回,通知组件数据加载完成
              resolve(nodes);
            }, 1000);
          }     
xd's avatar
xd committed
168 169
        }
    }
wengjianling's avatar
wengjianling committed
170 171
  },
  created() {
xd's avatar
xd committed
172
    this.getOrgTree()
wengjianling's avatar
wengjianling committed
173 174
  },
  methods: {
xd's avatar
xd committed
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
    handleDpetChange(val) {
      console.log(val,'val')   
    },
    getOrgTree() {
      getOrgTree().then(res => {
        this.orgTree = [res.data.organizations]
      });
    },
    handleDetailChange(val) {
      this.deptId = ''
      this.addForm.clerkId = []
      this.peopleList = []
      if(val == 1) {
        this.getDeptList()
      }
    },
    handleParentChange(val) {      
      this.addForm.clerkId = []
      if(this.detail == 1) {
        this.getGroupMember(val)
      }             
    },
    getDeptList() {
xd's avatar
xd committed
198
      getWxAllDeptList()
xd's avatar
xd committed
199
        .then(res => {
xd's avatar
xd committed
200 201
          console.log(res,'全部部门')
          this.parentDeptList = res.data
xd's avatar
xd committed
202 203
        })
        .catch(err => {
xd's avatar
xd committed
204
          console.log(err)
xd's avatar
xd committed
205 206
        });
    },
wengjianling's avatar
wengjianling committed
207
    handleAddCancel() {
xd's avatar
xd committed
208
      this.$emit("handleAddCancel")
wengjianling's avatar
wengjianling committed
209 210
    },
    handleAddFinish() {
xd's avatar
xd committed
211 212 213 214 215 216
      const clerkIds = this.addForm.clerkId+""
      let data = Object.assign(this.addForm,{ clerkIds })
      delete data.clerkId
      addGroup(data).then(res => {
        console.log(res)
      })
wengjianling's avatar
wengjianling committed
217
      // console.log(addGroup)
xd's avatar
xd committed
218
      this.$emit("handleAddFinish")
wengjianling's avatar
wengjianling committed
219
    },
xd's avatar
xd committed
220
    // 获取所有人员
xd's avatar
xd committed
221
    getGroupMember(id) {
xd's avatar
xd committed
222 223 224
      getAllPeopleList({ id }).then(res => {
        console.log(res,'人员')      
        this.peopleList = res.data
xd's avatar
xd committed
225
      })
xd's avatar
xd committed
226
    },
xd's avatar
xd committed
227
   /*  handleNodeClick(item, node, self) {
wengjianling's avatar
wengjianling committed
228 229
      // console.log(item,node,self)
      this.params.d_parentId = item.id;
xd's avatar
xd committed
230
      this.paramsForShow.father_name = item.label;
wengjianling's avatar
wengjianling committed
231
    },
xd's avatar
xd committed
232
    checkChange(item, node, self) {},
wengjianling's avatar
wengjianling committed
233
    showTreeData() {
xd's avatar
xd committed
234
      this.showTree = !this.showTree;
wengjianling's avatar
wengjianling committed
235
    },
xd's avatar
xd committed
236 237
 */
    
wengjianling's avatar
wengjianling committed
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
  }
};
</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 {
xd's avatar
xd committed
304
  content: "* ";
wengjianling's avatar
wengjianling committed
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
  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;
xd's avatar
xd committed
320
  border: 1px solid #dcdfe6;
wengjianling's avatar
wengjianling committed
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
  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>