提交 03d42e69 编写于 作者: ibizdev's avatar ibizdev

lab_qyk 发布系统代码

上级 dc2e0751
...@@ -51,21 +51,16 @@ export default class AppOrgSelect extends Vue { ...@@ -51,21 +51,16 @@ export default class AppOrgSelect extends Vue {
*/ */
@Watch('data',{immediate:true,deep:true}) @Watch('data',{immediate:true,deep:true})
onDataChange(newVal: any, oldVal: any) { onDataChange(newVal: any, oldVal: any) {
// 计算出选中值 if(newVal){
// 单选 this.computedSelectedData();
if(!this.multiple){ if(this.filter){
if(this.fillMap && Object.keys(this.fillMap).length >0){ let tempFilterValue:any = this.initBasicData();
let templateValue = {}; // filter值变化才去请求数据
Object.keys(this.fillMap).forEach((item:any) =>{ if(tempFilterValue && (this.copyFilterValue !== tempFilterValue)){
if(this.data && this.data[this.fillMap[item]]){ this.loadTreeData(this.orgDataUrl.replace('${orgid}',tempFilterValue));
Object.assign(templateValue,{[item]:this.data[this.fillMap[item]]}); this.copyFilterValue = tempFilterValue;
} }
})
this.selectTreeValue = JSON.stringify([templateValue]);
} }
}else{
// 多选
} }
} }
...@@ -91,11 +86,11 @@ export default class AppOrgSelect extends Vue { ...@@ -91,11 +86,11 @@ export default class AppOrgSelect extends Vue {
public NodesData:any = []; public NodesData:any = [];
/** /**
* 过滤值 * 备份过滤值
* *
* @memberof AppOrgSelect * @memberof AppOrgSelect
*/ */
public filterValue:any; public copyFilterValue:any;
/** /**
* vue生命周期 * vue生命周期
...@@ -103,8 +98,9 @@ export default class AppOrgSelect extends Vue { ...@@ -103,8 +98,9 @@ export default class AppOrgSelect extends Vue {
* @memberof AppOrgSelect * @memberof AppOrgSelect
*/ */
public created(){ public created(){
this.initBasicData(); if(!this.filter){
this.loadTreeData(); this.loadTreeData(this.orgDataUrl.replace('${orgid}','alls'));
}
} }
/** /**
...@@ -116,25 +112,44 @@ export default class AppOrgSelect extends Vue { ...@@ -116,25 +112,44 @@ export default class AppOrgSelect extends Vue {
// 计算出过滤值 // 计算出过滤值
if(this.filter){ if(this.filter){
if(this.data && this.data[this.filter]){ if(this.data && this.data[this.filter]){
this.filterValue= this.data[this.filter]; return this.data[this.filter];
}else if(this.context && this.context[this.filter]){ }else if(this.context && this.context[this.filter]){
this.filterValue= this.context[this.filter]; return this.context[this.filter];
}else{
return null;
} }
} }
} }
/** /**
* 加载树数据 * 计算选中值
* *
* @memberof AppOrgSelect * @memberof AppOrgSelect
*/ */
public loadTreeData(){ public computedSelectedData(){
let requestUrl:string = ""; // 单选
if(!this.filter){ if(!this.multiple){
requestUrl = this.orgDataUrl.replace('${orgid}','alls'); if(this.fillMap && Object.keys(this.fillMap).length >0){
let templateValue = {};
Object.keys(this.fillMap).forEach((item:any) =>{
if(this.data && this.data[this.fillMap[item]]){
Object.assign(templateValue,{[item]:this.data[this.fillMap[item]]});
}
})
this.selectTreeValue = JSON.stringify([templateValue]);
}
}else{ }else{
requestUrl = this.orgDataUrl.replace('${orgid}',this.filterValue); // 多选
}
} }
/**
* 加载树数据
*
* @memberof AppOrgSelect
*/
public loadTreeData(requestUrl:string){
Http.getInstance().get(requestUrl).then((res:any) =>{ Http.getInstance().get(requestUrl).then((res:any) =>{
if(!res.status && res.status !== 200){ if(!res.status && res.status !== 200){
console.error("加载数据失败"); console.error("加载数据失败");
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册