提交 ad6f5e95 编写于 作者: tony001's avatar tony001

zpc --- 更新

上级 7dfd5d2d
<template> <template>
<div class="app-org-select"> <div class="app-org-select">
<ibiz-select-tree :NodesData="NodesData" v-model="selectTreeValue" :multiple="false" @select="treeSelectChange"></ibiz-select-tree> <ibiz-select-tree :NodesData="NodesData" v-model="selectTreeValue" :multiple="multiple" @select="treeSelectChange"></ibiz-select-tree>
</div> </div>
</template> </template>
<script lang = 'ts'> <script lang = 'ts'>
...@@ -140,7 +140,23 @@ export default class AppOrgSelect extends Vue { ...@@ -140,7 +140,23 @@ export default class AppOrgSelect extends Vue {
} }
}else{ }else{
// 多选 // 多选
if(this.fillMap && Object.keys(this.fillMap).length >0){
let tempArray:Array<any> = [];
Object.keys(this.fillMap).forEach((item:any) =>{
if(this.data && this.data[this.fillMap[item]]){
let tempDataArray:Array<any> = (this.data[this.fillMap[item]]).split(",");
tempDataArray.forEach((tempData:any,index:number) =>{
if(tempArray.length < tempDataArray.length){
let singleData:any ={[item]:tempData};
tempArray.push(singleData);
}else{
Object.assign(tempArray[index],{[item]:tempData});
}
})
}
})
this.selectTreeValue = JSON.stringify(tempArray);
}
} }
} }
...@@ -150,13 +166,22 @@ export default class AppOrgSelect extends Vue { ...@@ -150,13 +166,22 @@ export default class AppOrgSelect extends Vue {
* @memberof AppOrgSelect * @memberof AppOrgSelect
*/ */
public loadTreeData(requestUrl:string){ public loadTreeData(requestUrl:string){
if(this.filter){
const result:any = this.$store.getters.getCopyData(this.filter);
if(result){
this.NodesData = result;
return;
}
}
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("加载数据失败");
return; return;
} }
this.NodesData = res.data; this.NodesData = res.data;
console.log(this.NodesData); if(this.filter){
this.$store.commit('addOrgData', { srfkey: this.filter, orgData: res.data });
}
}) })
} }
...@@ -168,7 +193,24 @@ export default class AppOrgSelect extends Vue { ...@@ -168,7 +193,24 @@ export default class AppOrgSelect extends Vue {
public treeSelectChange($event:any){ public treeSelectChange($event:any){
// 多选 // 多选
if(this.multiple){ if(this.multiple){
if($event){
const tempValue:any = JSON.parse($event);
if(this.fillMap && Object.keys(this.fillMap).length >0){
Object.keys(this.fillMap).forEach((item:any) =>{
let tempResult:any ="";
tempValue.forEach((value:any,index:number) =>{
tempResult += index>0?`,${value[item]}`:`${value[item]}`;
})
this.emitValue(this.fillMap[item],tempResult);
})
}
}else{
if(this.fillMap && Object.keys(this.fillMap).length >0){
Object.keys(this.fillMap).forEach((item:any) =>{
this.emitValue(this.fillMap[item],null);
})
}
}
}else{ }else{
// 单选 // 单选
if($event){ if($event){
......
...@@ -88,4 +88,14 @@ export const getCopyData = (state: any) => (srfkey: string) => { ...@@ -88,4 +88,14 @@ export const getCopyData = (state: any) => (srfkey: string) => {
delete state.copyDataMap[srfkey]; delete state.copyDataMap[srfkey];
} }
return copyData; return copyData;
}
/**
* 获取单位数据
*
* @param state
*/
export const getOrgData = (state: any) => (srfkey: string) => {
let orgData = state.orgDataMap[srfkey];
return orgData;
} }
\ No newline at end of file
...@@ -265,4 +265,16 @@ export const addCopyData = (state: any, args: {srfkey: string,copyData: any}) => ...@@ -265,4 +265,16 @@ export const addCopyData = (state: any, args: {srfkey: string,copyData: any}) =>
if(args && args.srfkey && args.copyData){ if(args && args.srfkey && args.copyData){
state.copyDataMap[args.srfkey] = JSON.parse(JSON.stringify(args.copyData)); state.copyDataMap[args.srfkey] = JSON.parse(JSON.stringify(args.copyData));
} }
} }
\ No newline at end of file
/**
* 添加单位数据
*
* @param state
* @param args
*/
export const addOrgData = (state: any, args: {srfkey: string,orgData: any}) => {
if(args && args.srfkey && args.orgData){
state.orgDataMap[args.srfkey] = JSON.parse(JSON.stringify(args.orgData));
}
}
\ No newline at end of file
...@@ -14,4 +14,5 @@ export const rootstate: any = { ...@@ -14,4 +14,5 @@ export const rootstate: any = {
zIndex: 300, zIndex: 300,
viewSplit: {}, viewSplit: {},
copyDataMap:{}, copyDataMap:{},
orgDataMap:{},
} }
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册