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

zpc --- 支持面板代码表

上级 6186b421
......@@ -7,7 +7,7 @@
<div v-for = "item in items" :key="item.srfmajortext" :class="['app-list-item', {'isSelect': item.isselected === true ? true : false}]" @click="handleClick(item)" @dblclick="handleDblClick(item)">
<#if ctrl.getItemPSLayoutPanel()??>
<#assign panel = ctrl.getItemPSLayoutPanel()>
<layout_${panel.getName()} name='${panel.name}' :data="item"></layout_${panel.getName()}>
<layout_${panel.getName()} name='${panel.name}' :inputData="item"></layout_${panel.getName()}>
<#elseif ctrl.itemRender??>
${ctrl.itemRender.code}
<#else>
......
<template>
${P.getPartCode(item,'PANEL').code}
</template>
<#assign import_block>
import ${srfclassname('${ctrl.codeName}')}Model from './${srffilepath2(ctrl.codeName)}-${ctrl.getControlType()?lower_case}-model';
import CodeListService from "@service/app/codelist-service";
</#assign>
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
</#ibizinclude>
......@@ -17,6 +21,13 @@
}
return [this.data];
}
/**
* 接口实现
*
* @returns {*}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
getData() {
return this.data;
}
......@@ -27,7 +38,134 @@
* @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop() public data?: any;
@Prop() public inputData?: any;
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public codeListService:CodeListService = new CodeListService({ $store:this.$store });
/**
* 数据模型对象
*
* @type {${srfclassname('${ctrl.codeName}')}Model}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public dataModel:${srfclassname('${ctrl.codeName}')}Model = new ${srfclassname('${ctrl.codeName}')}Model();
/**
* UI数据对象
*
* @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public data:any = {};
/**
* 监听数据对象
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Watch('inputData',{immediate:true})
async onInputDataChange(newVal: any, oldVal: any){
if(newVal){
await this.computedUIData(newVal);
this.$forceUpdate();
}
}
/**
* 计算UI展示数据
*
* @param codelistArray 代码表模型数组
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public async computedUIData(newVal:any){
let codelistArray:Array<any> = [];
if((this.dataModel.getDataItems instanceof Function) && this.dataModel.getDataItems().length >0){
this.dataModel.getDataItems().forEach((item:any) =>{
if(item.codelist){
codelistArray.push(item.codelist);
}
})
if(codelistArray.length >0){
let res:any = await this.getAllCodeList(codelistArray);
this.dataModel.getDataItems().forEach((item:any) =>{
if(item.codelist){
this.data[item.name] = res.get(item.codelist.tag).get(newVal[item.prop]);
}else{
this.data[item.name] = newVal[item.prop];
}
})
}else{
this.dataModel.getDataItems().forEach((item:any) =>{
this.data[item.name] = newVal[item.prop];
})
}
}
}
/**
* 获取所有代码表
*
* @param codelistArray 代码表模型数组
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public getAllCodeList(codelistArray:Array<any>):Promise<any>{
return new Promise((resolve:any,reject:any) =>{
let codeListMap:Map<string,any> = new Map();
let promiseArray:Array<any> = [];
codelistArray.forEach((item:any) =>{
if(!codeListMap.get(item.tag)){
promiseArray.push(this.getCodeList(item));
Promise.all(promiseArray).then((result:any) =>{
if(result && result.length >0){
result.forEach((codeList:any) =>{
let tempCodeListMap:Map<number,any> = new Map();
if(codeList.length >0){
codeList.forEach((codeListItem:any) =>{
tempCodeListMap.set(codeListItem.value,codeListItem.text);
})
}
codeListMap.set(item.tag,tempCodeListMap);
})
resolve(codeListMap);
}
})
}
})
})
}
/**
* 获取代码表
*
* @param codeListObject 传入代码表对象
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public getCodeList(codeListObject:any):Promise<any>{
return new Promise((resolve:any,reject:any) =>{
if(codeListObject.tag && Object.is(codeListObject.codelistType,"STATIC")){
const codelist = this.$store.getters.getCodeList(codeListObject.tag);
if (codelist) {
resolve([...JSON.parse(JSON.stringify(codelist.items))]);
} else {
resolve([]);
console.log(`----${codeListObject.tag}----代码表不存在`);
}
}else if(codeListObject.tag && Object.is(codeListObject.codelistType,"DYNAMIC")){
this.codeListService.getItems(codeListObject.tag).then((res:any) => {
resolve(res);
}).catch((error:any) => {
resolve([]);
console.log(`----${codeListObject.tag}----代码表不存在`);
});
}
})
}
<#if ctrl.getAllPSPanelItems()??>
<#list ctrl.getAllPSPanelItems() as panelItem>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册