| | |
| | | </el-form-item> |
| | | <!-- 父级id --> |
| | | <el-form-item class="optionItem" label="父级:" prop="parentId"> |
| | | <el-select v-model="things.parentId" placeholder="请选择所属类型" :disabled="things.level===1"> |
| | | <el-select ref="projectApplicant" v-model="things.parentId" placeholder="请选择所属类型" :disabled="things.level===1"> |
| | | <el-option :value="mylabel"> |
| | | <el-tree ref="tree" :check-strictly="true" :data="parentList" :props="defaultProps" show-checkbox |
| | | <el-tree ref="tree" :check-strictly="true" :data="parentList" :props="defaultProps" |
| | | @node-click="handleCheck" |
| | | @check-change="handleCheck" default-expand-all node-key="id"> |
| | | </el-tree> |
| | | </el-option> |
| | |
| | | item.children = []; |
| | | }) |
| | | } else if (index === 3) { |
| | | |
| | | |
| | | this.parentList = this.addChildren(await this.getTypeThird(), await this.getTypeSecond()); |
| | | console.log(this.parentList); |
| | | } else { |
| | |
| | | return parentArr; |
| | | }, |
| | | handleCheck(data, checked) { |
| | | console.log(this.selectOrg.orgsid,data,checked); |
| | | //只能点击最后一级 |
| | | if(checked.childNodes.length == 0){ |
| | | this.things.parentId = data.name; |
| | | console.log(this.selectOrg.orgsid); |
| | | // 获取当前选择的id在数组中的索引 |
| | | const indexs = this.selectOrg.orgsid.indexOf(data.id) |
| | | // 如果不存在数组中,并且数组中已经有一个id并且checked为true的时候,代表不能再次选择。 |
| | | if (indexs < 0 && this.selectOrg.orgsid.length === 1 && checked) { |
| | | this.$message({ |
| | | message: '只能选择一个区域!', |
| | | type: 'error', |
| | | showClose: true |
| | | }) |
| | | // 设置已选择的节点为false 很重要 |
| | | this.$refs.tree.setChecked(data, false) |
| | | } else if (this.selectOrg.orgsid.length === 0 && checked) { |
| | | // 发现数组为空 并且是已选择 |
| | | // 防止数组有值,首先清空,再push |
| | | this.selectOrg.orgsid = [] |
| | | this.selectOrg.orgsid.push(data.id) |
| | | } else if ( |
| | | indexs >= 0 && |
| | | this.selectOrg.orgsid.length === 1 && |
| | | !checked |
| | | ) { |
| | | // 再次直接进行赋值为空操作 |
| | | this.selectOrg.orgsid = [] |
| | | } |
| | | let _this = this; |
| | | _this.$refs.projectApplicant.blur(); |
| | | this.selectOrg.orgsid = [] |
| | | this.selectOrg.orgsid.push(data.id) |
| | | }else { |
| | | return |
| | | } |
| | | // // 获取当前选择的id在数组中的索引 |
| | | // const indexs = this.selectOrg.orgsid.indexOf(data.id) |
| | | // // 如果不存在数组中,并且数组中已经有一个id并且checked为true的时候,代表不能再次选择。 |
| | | // if (indexs < 0 && this.selectOrg.orgsid.length === 1 && checked) { |
| | | // this.$message({ |
| | | // message: '只能选择一个区域!', |
| | | // type: 'error', |
| | | // showClose: true |
| | | // }) |
| | | // // 设置已选择的节点为false 很重要 |
| | | // this.$refs.tree.setChecked(data, false) |
| | | // } else if (this.selectOrg.orgsid.length === 0 && checked) { |
| | | // // 发现数组为空 并且是已选择 |
| | | // // 防止数组有值,首先清空,再push |
| | | // let _this = this; |
| | | // _this.$refs.projectApplicant.blur(); |
| | | // this.selectOrg.orgsid = [] |
| | | // this.selectOrg.orgsid.push(data.id) |
| | | // } else if ( |
| | | // indexs >= 0 && |
| | | // this.selectOrg.orgsid.length === 1 && |
| | | // !checked |
| | | // ) { |
| | | // // 再次直接进行赋值为空操作 |
| | | // this.selectOrg.orgsid = [] |
| | | // } |
| | | }, |
| | | }, |
| | | props: ['changeDialog'] |
| | |
| | | // font-size: 10px; |
| | | // } |
| | | } |
| | | </style> |
| | | </style> |