提交 3d7f223f 编写于 作者: WodahsOrez's avatar WodahsOrez

lxm--面板和多数据部件数据流向

上级 832be3bc
<template>
<div :class="['app-list', this.items.length > 0 ? '' : 'app-list-empty' ]">
<div v-if="items.length > 0" style="height:100%;">
<#if ctrl.render??>
${ctrl.render.code}
<#else>
<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}' :inputData="item" :parentRef="thisRef"></layout_${panel.getName()}>
<#elseif ctrl.itemRender??>
${ctrl.itemRender.code}
<#else>
{{item.srfmajortext}}
</#if>
</div>
</#if>
</div>
<div v-else>
暂无数据
<div v-if="items.length > 0" style="height:100%;">
<#if ctrl.render??>
${ctrl.render.code}
<#else>
<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()>
<@ibizindent blank=16>
${P.getCtrlCode(panel, 'CONTROL.html').code}
</@ibizindent>
<#elseif ctrl.itemRender??>
${ctrl.itemRender.code}
<#else>
{{item.srfmajortext}}
</#if>
</div>
</#if>
</div>
<div v-else>
暂无数据
</div>
</div>
</template>
<#ibizinclude>
......@@ -395,7 +397,7 @@
const removeData = () => {
let keys: any[] = [];
datas.forEach((data: any) => {
keys.push(data.srfkey);
keys.push(data.srfkey);
});
let _removeAction = keys.length > 1 ? 'removeBatch' : this.removeAction ;
const context:any = JSON.parse(JSON.stringify(this.context));
......@@ -446,6 +448,60 @@
return removeData;
}
/**
* 保存
*
* @param {*} $event
* @returns {Promise<any>}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public async save(args: any[], params?: any, $event?: any, xData?: any){
let _this = this;
let successItems:any = [];
let errorItems:any = [];
let errorMessage:any = [];
for (const item of _this.items) {
try {
if(Object.is(item.rowDataState, 'create')){
if(!this.createAction){
this.$Notice.error({ title: '错误', desc: '${view.getName()}视图列表createAction参数未配置' });
}else{
Object.assign(item,{viewparams:this.viewparams});
let response = await this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
successItems.push(JSON.parse(JSON.stringify(response.data)));
}
}else if(Object.is(item.rowDataState, 'update')){
if(!this.updateAction){
this.$Notice.error({ title: '错误', desc: '${view.getName()}视图列表updateAction参数未配置' });
}else{
Object.assign(item,{viewparams:this.viewparams});
<#if de??>
if(item.${appde.getCodeName()?lower_case}){
Object.assign(this.context,{${appde.getCodeName()?lower_case}:item.${appde.getCodeName()?lower_case}});
}
</#if>
let response = await this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
successItems.push(JSON.parse(JSON.stringify(response.data)));
}
}
} catch (error) {
errorItems.push(JSON.parse(JSON.stringify(item)));
errorMessage.push(error);
}
}
this.$emit('save', successItems);
this.refresh();
if(errorItems.length === 0){
this.$Notice.success({ title: '', desc: '保存成功!' });
}else{
errorItems.forEach((item:any,index:number)=>{
this.$Notice.error({ title: '保存失败', desc: item.majorentityname+'保存失败!' });
console.error(errorMessage[index]);
});
}
return successItems;
}
/**
* 选择数据
* @memberof ${srfclassname('${ctrl.codeName}')}
......
......@@ -34,12 +34,14 @@
<a v-for="(item,index) in items" :key="index" :href = "item.starturl">
<i-col <#if ctrl.getCardColLG() gt 0> :lg="${ctrl.getCardColLG()?c}"</#if><#if ctrl.getCardColMD() gt 0> :md="${ctrl.getCardColMD()?c}"</#if><#if ctrl.getCardColSM() gt 0> :sm="${ctrl.getCardColSM()?c}"</#if><#if ctrl.getCardColXS() gt 0> :xs="${ctrl.getCardColXS()?c}"</#if> style="<#if ctrl.getCardHeight() gt 0>height: ${ctrl.getCardHeight()?c}<#else>min-height: 170</#if>px;<#if ctrl.getCardWidth() gt 0> width: ${ctrl.getCardWidth()?c}px;</#if>margin-bottom: 10px;">
<el-card shadow="always" :class="[ item.isselected === true ? 'isselected' : false, 'single-card-data' ]" @click.native="handleClick(item)" @dblclick.native="handleDblClick(item)">
<#if ctrl.getItemPSLayoutPanel()??>
<#assign panel = ctrl.getItemPSLayoutPanel()>
<layout_${panel.getName()} name='${panel.name}' :inputData="item"></layout_${panel.getName()}>
<#elseif ctrl.itemRender??>
<#if ctrl.getItemPSLayoutPanel()??>
<#assign panel = ctrl.getItemPSLayoutPanel()>
<@ibizindent blank=24>
${P.getCtrlCode(panel, 'CONTROL.html').code}
</@ibizindent>
<#elseif ctrl.itemRender??>
${ctrl.itemRender.code}
<#else>
<#else>
<img v-if="item.srficonpath" :src="item.srficonpath" class="single-card-img" />
<img v-else src="/assets/img/noimage.png" class="single-card-img" />
<div class="single-card-default">
......@@ -47,7 +49,7 @@
{{item.srfmajortext}}
</Tooltip>
</div>
</#if>
</#if>
</el-card>
</i-col>
</a>
......
......@@ -112,7 +112,7 @@ import CodeListService from "@service/app/codelist-service";
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Watch('inputData',{immediate:true})
async onInputDataChange(newVal: any, oldVal: any){
public onInputDataChange(newVal: any, oldVal: any){
if(newVal){
await this.computedUIData(newVal);
this.panelLogic({ name: '', newVal: null, oldVal: null });
......@@ -126,125 +126,27 @@ import CodeListService from "@service/app/codelist-service";
* @param codelistArray 代码表模型数组
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public async computedUIData(newVal:any){
let codelistArray:Array<any> = [];
public computedUIData(newVal: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);
}
this.data[item.name] = newVal[item.prop];
})
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 Mob
*/
public async computePanelData(){
let codelistArray:Array<any> = [];
public computeOutputData(){
let panelData: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,true);
this.dataModel.getDataItems().forEach((item:any) =>{
if(item.codelist){
panelData[item.prop] = res.get(item.codelist.tag).get(this.data[item.name]);
}else{
panelData[item.prop] = this.data[item.name];
}
})
}else{
this.dataModel.getDataItems().forEach((item:any) =>{
panelData[item.prop] = this.data[item.name];
})
}
panelData[item.prop] = this.data[item.name];
})
}
this.panelData = Object.assign(JSON.parse(JSON.stringify(this.inputData)),panelData);
}
/**
* 获取所有代码表
*
* @param codelistArray 代码表模型数组
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public getAllCodeList(codelistArray:Array<any>,reverse:boolean = false):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) =>{
if(reverse){
tempCodeListMap.set(codeListItem.text,codeListItem.value);
}else{
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(`----<#noparse>${codeListObject.tag}</#noparse>----代码表不存在`);
}
}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(`----<#noparse>${codeListObject.tag}</#noparse>----代码表不存在`);
});
}
})
this.panelData = Object.assign(JSON.parse(JSON.stringify(this.inputData)),panelData);
}
/**
......@@ -256,7 +158,7 @@ import CodeListService from "@service/app/codelist-service";
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public async uiAction(row: any, tag: any, $event: any) {
await this.computePanelData();
await this.computeOutputData();
<#if ctrl.getPSAppViewLogics()??>
<#list ctrl.getPSAppViewLogics() as logic>
<#if logic.getPSAppViewUIAction().getPSUIAction()??>
......@@ -336,6 +238,15 @@ import CodeListService from "@service/app/codelist-service";
}
data[$event.name] = $event.value;
this.panelEditItemChange(data, $event.name, $event.value);
// 面板数据变化事件
if((this.dataModel.getDataItems instanceof Function) && this.dataModel.getDataItems().length >0){
let modelitem =this.dataModel.getDataItems().find((item:any) =>{
return item.name === $event.name;
})
if(modelitem){
this.$emit('panelDataChange',{[modelitem.prop]: $event.value});
}
}
}
/**
......
<#assign content>
:parentRef="thisRef"
:inputData="item"
@panelDataChange="($event)=>{Object.assign(item,$event)}"
</#assign>
<#ibizinclude>
../@MACRO/HTML/DEFAULT.html.ftl
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册