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

update

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