提交 8ac3aa48 编写于 作者: JunZai's avatar JunZai

update

上级 ecf6d70a
......@@ -2,7 +2,7 @@
<div class="ibiz-group-picker">
<div class="ibiz-group-container">
<div v-if="showTree" class="ibiz-group-tree">
<ibiz-select-tree :NodesData="treeItems" v-model="treeSelectVal" :isShowSearchBar="false" @select="treeSelect"></ibiz-select-tree>
<ibiz-select-tree :NodesData="treeItems" v-model="treeSelectVal" :treeOnly="true" @select="treeSelect"></ibiz-select-tree>
</div>
<div class="ibiz-group-content">
<ibiz-group-card :data="cardItems" text="label" value="id" groupName="group" :multiple="multiple" :defaultSelect="cardSelctVal" @select="groupSelect"></ibiz-group-card>
......@@ -130,7 +130,10 @@ export default class IBizGroupPicker extends Vue {
this.viewParam = JSON.parse(this.viewparam);
this.multiple = this.viewParam.multiple;
if (this.viewParam.selects) {
this.cardSelctVal = this.viewParam.selects;
this.viewParam.selects.forEach((select: any) => {
this.selects.push(select);
this.cardSelctVal.push(select.id)
})
}
this.load();
}
......@@ -161,6 +164,7 @@ export default class IBizGroupPicker extends Vue {
get.then((response: any) => {
if(response.status === 200) {
this.treeItems = response.data;
this.treeItems[0].disabled = false
}
}).catch((error: any) => {
console.log(error)
......@@ -205,7 +209,7 @@ export default class IBizGroupPicker extends Vue {
* @memberof IBizGroupPicker
*/
public groupSelect(event: any) {
if (!event || !event.selects) {
if (!event || !event.select) {
return;
}
if(!this.multiple) {
......@@ -217,7 +221,7 @@ export default class IBizGroupPicker extends Vue {
this.selects.splice(index, 1);
}
} else {
event.selects.forEach((key: string) => {
event.select.forEach((key: string) => {
let index: number = this.selects.findIndex((item: any) => Object.is(key, item.id));
if(index >= 0) {
return;
......@@ -228,22 +232,6 @@ export default class IBizGroupPicker extends Vue {
}
});
}
// 测试 start
// if(!this.multiple) {
// this.selects = [];
// }
// event.forEach((key: string) => {
// let index: number = this.selects.findIndex((item: any) => Object.is(key, item.id));
// if(index >= 0) {
// return;
// }
// let item: any = this.cardItems.find((item: any) => Object.is(key, item.id));
// if (item) {
// this.selects.push(item);
// }
// });
// 测试 end
}
/**
......
......@@ -96,6 +96,14 @@ export default class IBizGroupSelect extends Vue {
*/
@Prop() valueitem: any;
/**
* 填充属性
*
* @type {*}
* @memberof IBizGroupSelect
*/
@Prop() fillmap: any;
/**
* 选中项集合
*
......@@ -114,17 +122,22 @@ export default class IBizGroupSelect extends Vue {
onValueChange(newVal: any) {
this.selects = [];
if (newVal) {
let vals: any[] = newVal.split(',');
let vals2: any[] = [];
let item: any = {};
item.label = newVal.split(',');
if(this.valueitem) {
vals2 = this.data[this.valueitem].split(',');
item.id = this.data[this.valueitem] ? this.data[this.valueitem].split(',') : [];
}
console.log(this.data[this.valueitem])
vals.forEach((val: string, index: number) => {
this.selects.push({
label: val,
id: vals2.length > 0 ? vals2[index] : null
})
if(this.fillmap) {
for(let key in this.fillmap) {
item[this.fillmap[key]] = this.data[key] ? this.data[key].split(',') : [];
}
}
item.label.forEach((val: string, index: number) => {
let _item: any = {};
for(let key in item) {
_item[key] = item[key][index] ? item[key][index] : null;
}
this.selects.push(_item)
})
}
}
......@@ -152,16 +165,13 @@ export default class IBizGroupSelect extends Vue {
viewname: 'ibiz-group-picker',
title: '分组选择'
};
let sels: any = this.selects.map((select: any) => {
return select.id;
})
const context: any = JSON.parse(JSON.stringify(this.context));
const param: any = {};
Object.assign(param, {
hasfilter: this.filter ? true : false,
filtervalue: this.filter ? this.data[this.filter] : '',
multiple: this.multiple,
selects: sels
selects: this.selects
});
let container: Subject<any> = this.$appmodal.openModal(view, context, param);
container.subscribe((result: any) => {
......@@ -182,12 +192,7 @@ export default class IBizGroupSelect extends Vue {
console.log(result)
this.selects = [];
if (result.datas && result.datas.length > 0) {
result.datas.forEach((data: any) => {
this.selects.push({
id: data.id,
label: data.label
})
});
this.selects = result.datas
}
this.setValue()
}
......@@ -212,25 +217,31 @@ export default class IBizGroupSelect extends Vue {
public setValue() {
let item: any = {};
if(this.multiple) {
let label = '';
let value = '';
this.selects.forEach((select: any) => {
label += ',' + select.label;
value += ',' + select.id;
item[this.name] = item[this.name] ? `${item[this.name]},${select.label}` : select.label;
if(this.valueitem) {
item[this.valueitem] = item[this.valueitem] ? `${item[this.valueitem]},${select.id}` : select.id;
}
if(this.fillmap) {
for(let key in this.fillmap) {
item[key] = item[key] ? `${item[key]},${select[this.fillmap[key]]}` : select[this.fillmap[key]];
}
}
});
Object.assign(item, {
label: label ? label.substring(1) : null,
id: value ? value.substring(1) : null
})
} else {
item = this.selects.length > 0 ? this.selects[0] : {};
item[this.name] = this.selects.length > 0 ? this.selects[0].label : null;
if(this.valueitem) {
item[this.valueitem] = this.selects.length > 0 ? this.selects[0].id : null;
}
if(this.name) {
this.$emit('formitemvaluechange', { name: this.name, value: item.label });
if(this.fillmap) {
for(let key in this.fillmap) {
item[key] = this.selects.length > 0 ? this.selects[0][this.fillmap[key]] : null;
}
if(this.valueitem) {
this.$emit('formitemvaluechange', { name: this.valueitem, value: item.id });
}
}
for(let key in item) {
this.$emit('formitemvaluechange', { name: key, value: item[key] });
}
}
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册