提交 e46c7331 编写于 作者: ShineKOT's avatar ShineKOT

部门人员选择器BUG修复

上级 7b841b8b
<template> <template>
<div class="app-department-personnel"> <div class="app-department-personnel">
<i-select :multiple="multiple" :transfer="true" transfer-class-name="app-department-personnel-select" v-model="selectsLabel" :disabled="disabled" :clearable="true" @on-open-change="onClick" @on-change="change"> <i-select :multiple="multiple" :transfer="true" transfer-class-name="app-department-personnel-select" :value="selectsLabel" :disabled="disabled" :clearable="true" @on-open-change="onClick" @on-change="change">
<i-option v-for="(item, index) in items" :key="index" :value="item.id" :label="item.label"> <i-option v-for="(item, index) in items" :key="index" :value="item.id" :label="item.label">
{{item.label}} {{item.label}}
</i-option> </i-option>
...@@ -243,7 +243,7 @@ export default class AppDepartmentPersonnel extends Vue { ...@@ -243,7 +243,7 @@ export default class AppDepartmentPersonnel extends Vue {
* @memberof AppDepartmentPersonnel * @memberof AppDepartmentPersonnel
*/ */
@Watch('data',{immediate:true,deep:true}) @Watch('data',{immediate:true,deep:true})
onValueChange(newVal: any, oldVal: any) { onValueChange(newVal: any, oldVal: any) {
this.selects = []; this.selects = [];
this.selectsLabel = []; this.selectsLabel = [];
if (newVal) { if (newVal) {
...@@ -262,11 +262,11 @@ export default class AppDepartmentPersonnel extends Vue { ...@@ -262,11 +262,11 @@ export default class AppDepartmentPersonnel extends Vue {
_item[key] = item[key][index] ? item[key][index] : null; _item[key] = item[key][index] ? item[key][index] : null;
} }
this.selects.push(_item); this.selects.push(_item);
let i = this.items.findIndex((item) => Object.is(item.label,_item.label)); let i = this.items.findIndex((select: any) => Object.is(select.id,_item.id));
if(i < 0){ if(i < 0){
this.items.push(_item); this.items.push(_item);
} }
this.selectsLabel.push(_item.label); this.selectsLabel.push(_item.id);
}) })
} }
if(item.label.length == 0 && item.id.length > 0){ if(item.label.length == 0 && item.id.length > 0){
...@@ -350,11 +350,11 @@ export default class AppDepartmentPersonnel extends Vue { ...@@ -350,11 +350,11 @@ export default class AppDepartmentPersonnel extends Vue {
this.selectsLabel = []; this.selectsLabel = [];
this.selects = [...result.datas]; this.selects = [...result.datas];
this.selects.forEach((select: any)=>{ this.selects.forEach((select: any)=>{
let index = this.items.findIndex((item) => Object.is(item.label, select.label)); let index = this.items.findIndex((item) => Object.is(item.id, select.id));
if(index < 0){ if(index < 0){
this.items.push(select); this.items.push(select);
} }
this.selectsLabel.push(select.label); this.selectsLabel.push(select.id);
}); });
} }
this.setValue(); this.setValue();
...@@ -371,14 +371,14 @@ export default class AppDepartmentPersonnel extends Vue { ...@@ -371,14 +371,14 @@ export default class AppDepartmentPersonnel extends Vue {
if(this.multiple){ if(this.multiple){
if($event.length > 0){ if($event.length > 0){
$event.forEach((select: any)=>{ $event.forEach((select: any)=>{
let index = this.items.findIndex((item) => Object.is(item.label, select)); let index = this.items.findIndex((item) => Object.is(item.id, select));
if (index >= 0) { if (index >= 0) {
this.selects.push(this.items[index]); this.selects.push(this.items[index]);
} }
}); });
} }
}else{ }else{
let index = this.items.findIndex((item) => Object.is(item.label, $event)); let index = this.items.findIndex((item) => Object.is(item.id, $event));
if (index >= 0) { if (index >= 0) {
this.selects.push(this.items[index]); this.selects.push(this.items[index]);
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册