1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <template>
- <div class="treebox">
- <el-tree show-checkbox ref="tree" @check-change="handleCheckChange" :data="treeList" node-key="o"
- :default-checked-keys="defaultListc" :default-expanded-keys="defaultList"></el-tree>
- </div>
- </template>
- <script>
- export default {
- props: ["defaultList","type"],
- data() {
- return {
- treeList: [],
- opt: [],
- defaultProps: {
- children: 'children',
- label: 'label'
- },
- defaultListc:[]
- };
- },
- methods: {
- getTree(v) {
- this.$http({
- url: "/sysmgr/csysdept/queryAllList",
- method: "post",
- headers: {
- "Content-Type": "application/json",
- },
- data: {
- parentorgid: v
- },
- }).then((res) => {
- this.treeList = res.data;
- });
- },
- handleCheckChange(v) {
- let opt = [];
- let list = this.$refs.tree.getCheckedNodes();
- for (let i = 0; i < list.length; i++) {
- if(this.type == 1){
- opt.push({
- deptCode: list[i].o,
- deptName: list[i].ou
- })
- }else{
- opt.push({
- deptId: list[i].o,
- deptName: list[i].ou
- })
- }
- }
- this.$emit("treeCheck",opt)
- },
- },
- mounted() {},
- created() {
- this.getTree();
- this.defaultListc = this.defaultList;
- },
- watch:{
- type(){
- this.defaultListc = this.defaultList;
- }
- }
- };
- </script>
- <style scoped lang="scss">
- .treebox {
- border: 1px solid #ddd;
- }
- </style>
|