提交 1584a59a 编写于 作者: ibizdev's avatar ibizdev

zoo457790531 发布系统代码 [ibz-disk,存储]

上级 cfa083c3
[
{
"srfkey": "DynamicModelStatus",
"emptytext": "未定义",
"codelisttype":"static",
"items": [
{
"id": "0",
"label": "未激活",
"text": "未激活",
"class":"",
"data":"",
"codename":"Item_0",
"color": "rgba(245, 158, 18, 1)",
"value": "0",
"disabled": false
}
, {
"id": "1",
"label": "已激活",
"text": "已激活",
"class":"",
"data":"",
"codename":"Item_1",
"color": "rgba(100, 235, 22, 1)",
"value": "1",
"disabled": false
}
]
},
{
"srfkey": "SysOperator",
"emptytext": "未定义",
"codelisttype":"dynamic",
......
......@@ -15,6 +15,22 @@
"viewname": "SDFileGridView",
"viewtag": "795a12a2bfb63a98ce5bb80310509360"
},
"metadynamicmodeldynainsteditview": {
"title": "动态模型编辑视图",
"caption": "动态模型",
"viewtype": "DEEDITVIEW",
"viewmodule": "lite",
"viewname": "MetaDynamicModelDynaInstEditView",
"viewtag": "92d51d41db51a671793ee8dc8876f9e9"
},
"metadynamicmodelgridview": {
"title": "动态模型",
"caption": "动态模型",
"viewtype": "DEGRIDVIEW",
"viewmodule": "lite",
"viewname": "MetaDynamicModelGridView",
"viewtag": "af9cfc34d957186380a012e322abff0c"
},
"sdindexview": {
"title": "ibizlab-disk",
"caption": "ibizlab-disk",
......@@ -22,5 +38,21 @@
"viewmodule": "disk",
"viewname": "SDIndexView",
"viewtag": "c0a8e8c1058d9a5cdb5a6edbf9855886"
},
"metadynamicmodeldynainstgridview": {
"title": "动态模型表格视图",
"caption": "动态模型表格视图",
"viewtype": "DEGRIDVIEW",
"viewmodule": "lite",
"viewname": "MetaDynamicModelDynaInstGridView",
"viewtag": "cec3236f5a1f742f9b91f313506ccc6c"
},
"metadynamicmodeleditview": {
"title": "动态模型编辑视图",
"caption": "动态模型",
"viewtype": "DEEDITVIEW",
"viewmodule": "lite",
"viewname": "MetaDynamicModelEditView",
"viewtag": "e8892afaebe9a899e5d528d5b55d3cc5"
}
}
......@@ -39,7 +39,8 @@ export class AuthServiceRegister {
* @memberof AuthServiceRegister
*/
protected init(): void {
this.allAuthService.set('sdfile', () => import('@/authservice/sdfile/sdfile-auth-service'));
this.allAuthService.set('metadynamicmodel', () => import('@/authservice/meta-dynamic-model/meta-dynamic-model-auth-service'));
this.allAuthService.set('sdfile', () => import('@/authservice/sdfile/sdfile-auth-service'));
}
/**
......
import AuthService from '../auth-service';
/**
* 动态模型权限服务对象基类
*
* @export
* @class MetaDynamicModelAuthServiceBase
* @extends {AuthService}
*/
export default class MetaDynamicModelAuthServiceBase extends AuthService {
/**
* Creates an instance of MetaDynamicModelAuthServiceBase.
*
* @param {*} [opts={}]
* @memberof MetaDynamicModelAuthServiceBase
*/
constructor(opts: any = {}) {
super(opts);
}
/**
* 根据当前数据获取实体操作标识
*
* @param {*} mainSateOPPrivs 传入数据操作标识
* @returns {any}
* @memberof MetaDynamicModelAuthServiceBase
*/
public getOPPrivs(mainSateOPPrivs:any):any{
let curDefaultOPPrivs:any = this.getSysOPPrivs();
let copyDefaultOPPrivs:any = JSON.parse(JSON.stringify(curDefaultOPPrivs));
if(mainSateOPPrivs){
Object.assign(curDefaultOPPrivs,mainSateOPPrivs);
}
// 统一资源优先
Object.keys(curDefaultOPPrivs).forEach((name:string) => {
if(this.sysOPPrivsMap.get(name) && copyDefaultOPPrivs[name] === 0){
curDefaultOPPrivs[name] = copyDefaultOPPrivs[name];
}
});
return curDefaultOPPrivs;
}
}
\ No newline at end of file
import MetaDynamicModelAuthServiceBase from './meta-dynamic-model-auth-service-base';
/**
* 动态模型权限服务对象
*
* @export
* @class MetaDynamicModelAuthService
* @extends {MetaDynamicModelAuthServiceBase}
*/
export default class MetaDynamicModelAuthService extends MetaDynamicModelAuthServiceBase {
/**
* Creates an instance of MetaDynamicModelAuthService.
*
* @param {*} [opts={}]
* @memberof MetaDynamicModelAuthService
*/
constructor(opts: any = {}) {
super(opts);
}
}
\ No newline at end of file
import metadynamicmodel_BO_CN from '@locale/lanres/entities/meta-dynamic-model/meta-dynamic-model_BO_CN';
import sdfile_BO_CN from '@locale/lanres/entities/sdfile/sdfile_BO_CN';
import components_BO_CN from '@locale/lanres/components/components_BO_CN';
import codelist_BO_CN from '@locale/lanres/codelist/codelist_BO_CN';
......@@ -128,6 +129,7 @@ function getAppLocale(){
menus: {
sdindexview: {
menuitem1: commonLogic.appcommonhandle("文件",null),
menuitem2: commonLogic.appcommonhandle("动态模型",null),
},
},
formpage:{
......@@ -222,6 +224,7 @@ function getAppLocale(){
},
},
entities: {
metadynamicmodel: metadynamicmodel_BO_CN(),
sdfile: sdfile_BO_CN(),
},
components: components_BO_CN(),
......
import metadynamicmodel_en_US from '@locale/lanres/entities/meta-dynamic-model/meta-dynamic-model_en_US';
import sdfile_en_US from '@locale/lanres/entities/sdfile/sdfile_en_US';
import components_en_US from '@locale/lanres/components/components_en_US';
import codelist_en_US from '@locale/lanres/codelist/codelist_en_US';
......@@ -128,6 +129,7 @@ function getAppLocale(){
menus: {
sdindexview: {
menuitem1: commonLogic.appcommonhandle("文件",null),
menuitem2: commonLogic.appcommonhandle("动态模型",null),
},
},
formpage:{
......@@ -223,6 +225,7 @@ function getAppLocale(){
},
},
entities: {
metadynamicmodel: metadynamicmodel_en_US(),
sdfile: sdfile_en_US(),
},
components: components_en_US(),
......
import metadynamicmodel_zh_CN from '@locale/lanres/entities/meta-dynamic-model/meta-dynamic-model_zh_CN';
import sdfile_zh_CN from '@locale/lanres/entities/sdfile/sdfile_zh_CN';
import components_zh_CN from '@locale/lanres/components/components_zh_CN';
import codelist_zh_CN from '@locale/lanres/codelist/codelist_zh_CN';
......@@ -128,6 +129,7 @@ function getAppLocale(){
menus: {
sdindexview: {
menuitem1: commonLogic.appcommonhandle("文件",null),
menuitem2: commonLogic.appcommonhandle("动态模型",null),
},
},
formpage:{
......@@ -222,6 +224,7 @@ function getAppLocale(){
},
},
entities: {
metadynamicmodel: metadynamicmodel_zh_CN(),
sdfile: sdfile_zh_CN(),
},
components: components_zh_CN(),
......
......@@ -2,6 +2,11 @@ import commonLogic from '@/locale/logic/common/common-logic';
function getLocaleResourceBase(){
const data:any = {
DynamicModelStatus: {
"0": commonLogic.appcommonhandle("未激活",null),
"1": commonLogic.appcommonhandle("已激活",null),
"empty": commonLogic.appcommonhandle("",null)
},
SysOperator: {
"empty": commonLogic.appcommonhandle("",null),
},
......
......@@ -2,6 +2,11 @@ import commonLogic from '@/locale/logic/common/common-logic';
function getLocaleResourceBase(){
const data:any = {
DynamicModelStatus: {
"0": commonLogic.appcommonhandle("未激活",null),
"1": commonLogic.appcommonhandle("已激活",null),
"empty": commonLogic.appcommonhandle("",null)
},
SysOperator: {
"empty": commonLogic.appcommonhandle("",null),
},
......
......@@ -2,6 +2,11 @@ import commonLogic from '@/locale/logic/common/common-logic';
function getLocaleResourceBase(){
const data:any = {
DynamicModelStatus: {
"0": commonLogic.appcommonhandle("未激活",null),
"1": commonLogic.appcommonhandle("已激活",null),
"empty": commonLogic.appcommonhandle("",null),
},
SysOperator: {
"empty": commonLogic.appcommonhandle("",null),
},
......
import MetaDynamicModel_BO_CN_Base from './meta-dynamic-model_BO_CN_base';
function getLocaleResource(){
const MetaDynamicModel_BO_CN_OwnData = {};
const targetData = Object.assign(MetaDynamicModel_BO_CN_Base(), MetaDynamicModel_BO_CN_OwnData);
return targetData;
}
export default getLocaleResource;
\ No newline at end of file
import commonLogic from '@/locale/logic/common/common-logic';
function getLocaleResourceBase(){
const data:any = {
fields: {
dynainstid: commonLogic.appcommonhandle("动态实例",null),
system_id: commonLogic.appcommonhandle("系统",null),
configid: commonLogic.appcommonhandle("配置标识",null),
configname: commonLogic.appcommonhandle("配置名称",null),
pdynainstid: commonLogic.appcommonhandle("父实例",null),
modelfile: commonLogic.appcommonhandle("文件",null),
status: commonLogic.appcommonhandle("状态",null),
},
views: {
dynainsteditview: {
caption: commonLogic.appcommonhandle("动态模型",null),
title: commonLogic.appcommonhandle("动态模型编辑视图",null),
},
gridview: {
caption: commonLogic.appcommonhandle("动态模型",null),
title: commonLogic.appcommonhandle("动态模型",null),
},
dynainstgridview: {
caption: commonLogic.appcommonhandle("动态模型表格视图",null),
title: commonLogic.appcommonhandle("动态模型表格视图",null),
},
editview: {
caption: commonLogic.appcommonhandle("动态模型",null),
title: commonLogic.appcommonhandle("动态模型编辑视图",null),
},
},
main_form: {
details: {
group1: commonLogic.appcommonhandle("动态模型基本信息",null),
formpage1: commonLogic.appcommonhandle("基本信息",null),
srforikey: commonLogic.appcommonhandle("",null),
srfkey: commonLogic.appcommonhandle("配置标识",null),
srfmajortext: commonLogic.appcommonhandle("配置名称",null),
srftempmode: commonLogic.appcommonhandle("",null),
srfuf: commonLogic.appcommonhandle("",null),
srfdeid: commonLogic.appcommonhandle("",null),
srfsourcekey: commonLogic.appcommonhandle("",null),
configname: commonLogic.appcommonhandle("配置名称",null),
formitem: commonLogic.appcommonhandle("文件",null),
systemid: commonLogic.appcommonhandle("系统",null),
pdynainstid: commonLogic.appcommonhandle("父实例",null),
configid: commonLogic.appcommonhandle("配置标识",null),
},
uiactions: {
},
},
dynainst_form: {
details: {
druipart1: commonLogic.appcommonhandle("副本",null),
tabpage1: commonLogic.appcommonhandle("副本",null),
tabpanel1: commonLogic.appcommonhandle("",null),
group1: commonLogic.appcommonhandle("动态模型基本信息",null),
formpage1: commonLogic.appcommonhandle("基本信息",null),
srforikey: commonLogic.appcommonhandle("",null),
srfkey: commonLogic.appcommonhandle("配置标识",null),
srfmajortext: commonLogic.appcommonhandle("配置名称",null),
srftempmode: commonLogic.appcommonhandle("",null),
srfuf: commonLogic.appcommonhandle("",null),
srfdeid: commonLogic.appcommonhandle("",null),
srfsourcekey: commonLogic.appcommonhandle("",null),
configname: commonLogic.appcommonhandle("配置名称",null),
formitem: commonLogic.appcommonhandle("文件",null),
systemid: commonLogic.appcommonhandle("系统",null),
configid: commonLogic.appcommonhandle("配置标识",null),
},
uiactions: {
},
},
main_grid: {
columns: {
configname: commonLogic.appcommonhandle("配置名称",null),
systemid: commonLogic.appcommonhandle("系统",null),
dynainstid: commonLogic.appcommonhandle("动态实例",null),
status: commonLogic.appcommonhandle("状态",null),
},
nodata:commonLogic.appcommonhandle("",null),
uiactions: {
},
},
default_searchform: {
details: {
formpage1: commonLogic.appcommonhandle("常规条件",null),
},
uiactions: {
},
},
dynainsteditviewtoolbar_toolbar: {
tbitem3: {
caption: commonLogic.appcommonhandle("保存",null),
tip: commonLogic.appcommonhandle("保存",null),
},
tbitem4: {
caption: commonLogic.appcommonhandle("保存并新建",null),
tip: commonLogic.appcommonhandle("保存并新建",null),
},
tbitem5: {
caption: commonLogic.appcommonhandle("保存并关闭",null),
tip: commonLogic.appcommonhandle("保存并关闭",null),
},
tbitem6: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem7: {
caption: commonLogic.appcommonhandle("删除并关闭",null),
tip: commonLogic.appcommonhandle("删除并关闭",null),
},
tbitem8: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem12: {
caption: commonLogic.appcommonhandle("新建",null),
tip: commonLogic.appcommonhandle("新建",null),
},
tbitem13: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem14: {
caption: commonLogic.appcommonhandle("拷贝",null),
tip: commonLogic.appcommonhandle("拷贝",null),
},
tbitem16: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem23: {
caption: commonLogic.appcommonhandle("第一个记录",null),
tip: commonLogic.appcommonhandle("第一个记录",null),
},
tbitem24: {
caption: commonLogic.appcommonhandle("上一个记录",null),
tip: commonLogic.appcommonhandle("上一个记录",null),
},
tbitem25: {
caption: commonLogic.appcommonhandle("下一个记录",null),
tip: commonLogic.appcommonhandle("下一个记录",null),
},
tbitem26: {
caption: commonLogic.appcommonhandle("最后一个记录",null),
tip: commonLogic.appcommonhandle("最后一个记录",null),
},
tbitem21: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem22: {
caption: commonLogic.appcommonhandle("帮助",null),
tip: commonLogic.appcommonhandle("帮助",null),
},
},
gridviewtoolbar_toolbar: {
tbitem1_publish: {
caption: commonLogic.appcommonhandle("发布模型",null),
tip: commonLogic.appcommonhandle("发布模型",null),
},
tbitem2: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem3: {
caption: commonLogic.appcommonhandle("新建",null),
tip: commonLogic.appcommonhandle("新建",null),
},
tbitem4: {
caption: commonLogic.appcommonhandle("编辑",null),
tip: commonLogic.appcommonhandle("编辑",null),
},
tbitem6: {
caption: commonLogic.appcommonhandle("拷贝",null),
tip: commonLogic.appcommonhandle("拷贝",null),
},
tbitem7: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem8: {
caption: commonLogic.appcommonhandle("删除",null),
tip: commonLogic.appcommonhandle("删除",null),
},
tbitem9: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem13: {
caption: commonLogic.appcommonhandle("导出",null),
tip: commonLogic.appcommonhandle("导出",null),
},
tbitem10: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem16: {
caption: commonLogic.appcommonhandle("其它",null),
tip: commonLogic.appcommonhandle("其它",null),
},
tbitem21: {
caption: commonLogic.appcommonhandle("导出数据模型",null),
tip: commonLogic.appcommonhandle("导出数据模型",null),
},
tbitem23: {
caption: commonLogic.appcommonhandle("数据导入",null),
tip: commonLogic.appcommonhandle("数据导入",null),
},
tbitem17: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem19: {
caption: commonLogic.appcommonhandle("过滤",null),
tip: commonLogic.appcommonhandle("过滤",null),
},
tbitem18: {
caption: commonLogic.appcommonhandle("帮助",null),
tip: commonLogic.appcommonhandle("帮助",null),
},
},
editviewtoolbar_toolbar: {
tbitem1: {
caption: commonLogic.appcommonhandle("保存并关闭",null),
tip: commonLogic.appcommonhandle("保存并关闭",null),
},
tbitem2: {
caption: commonLogic.appcommonhandle("关闭",null),
tip: commonLogic.appcommonhandle("关闭",null),
},
},
dynainstgridviewtoolbar_toolbar: {
tbitem1_publish: {
caption: commonLogic.appcommonhandle("发布模型",null),
tip: commonLogic.appcommonhandle("发布模型",null),
},
tbitem2: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem3: {
caption: commonLogic.appcommonhandle("新建",null),
tip: commonLogic.appcommonhandle("新建",null),
},
tbitem4: {
caption: commonLogic.appcommonhandle("编辑",null),
tip: commonLogic.appcommonhandle("编辑",null),
},
tbitem6: {
caption: commonLogic.appcommonhandle("拷贝",null),
tip: commonLogic.appcommonhandle("拷贝",null),
},
tbitem7: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem8: {
caption: commonLogic.appcommonhandle("删除",null),
tip: commonLogic.appcommonhandle("删除",null),
},
tbitem9: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem13: {
caption: commonLogic.appcommonhandle("导出",null),
tip: commonLogic.appcommonhandle("导出",null),
},
tbitem10: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem16: {
caption: commonLogic.appcommonhandle("其它",null),
tip: commonLogic.appcommonhandle("其它",null),
},
tbitem21: {
caption: commonLogic.appcommonhandle("导出数据模型",null),
tip: commonLogic.appcommonhandle("导出数据模型",null),
},
tbitem23: {
caption: commonLogic.appcommonhandle("数据导入",null),
tip: commonLogic.appcommonhandle("数据导入",null),
},
tbitem17: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem19: {
caption: commonLogic.appcommonhandle("过滤",null),
tip: commonLogic.appcommonhandle("过滤",null),
},
tbitem18: {
caption: commonLogic.appcommonhandle("帮助",null),
tip: commonLogic.appcommonhandle("帮助",null),
},
},
};
return data;
}
export default getLocaleResourceBase;
\ No newline at end of file
import MetaDynamicModel_en_US_Base from './meta-dynamic-model_en_US_base';
function getLocaleResource(){
const MetaDynamicModel_en_US_OwnData = {};
const targetData = Object.assign(MetaDynamicModel_en_US_Base(), MetaDynamicModel_en_US_OwnData);
return targetData;
}
export default getLocaleResource;
\ No newline at end of file
import commonLogic from '@/locale/logic/common/common-logic';
function getLocaleResourceBase(){
const data:any = {
fields: {
dynainstid: commonLogic.appcommonhandle("动态实例",null),
system_id: commonLogic.appcommonhandle("系统",null),
configid: commonLogic.appcommonhandle("配置标识",null),
configname: commonLogic.appcommonhandle("配置名称",null),
pdynainstid: commonLogic.appcommonhandle("父实例",null),
modelfile: commonLogic.appcommonhandle("文件",null),
status: commonLogic.appcommonhandle("状态",null),
},
views: {
dynainsteditview: {
caption: commonLogic.appcommonhandle("动态模型",null),
title: commonLogic.appcommonhandle("动态模型编辑视图",null),
},
gridview: {
caption: commonLogic.appcommonhandle("动态模型",null),
title: commonLogic.appcommonhandle("动态模型",null),
},
dynainstgridview: {
caption: commonLogic.appcommonhandle("动态模型表格视图",null),
title: commonLogic.appcommonhandle("动态模型表格视图",null),
},
editview: {
caption: commonLogic.appcommonhandle("动态模型",null),
title: commonLogic.appcommonhandle("动态模型编辑视图",null),
},
},
main_form: {
details: {
group1: commonLogic.appcommonhandle("动态模型基本信息",null),
formpage1: commonLogic.appcommonhandle("基本信息",null),
srforikey: commonLogic.appcommonhandle("",null),
srfkey: commonLogic.appcommonhandle("配置标识",null),
srfmajortext: commonLogic.appcommonhandle("配置名称",null),
srftempmode: commonLogic.appcommonhandle("",null),
srfuf: commonLogic.appcommonhandle("",null),
srfdeid: commonLogic.appcommonhandle("",null),
srfsourcekey: commonLogic.appcommonhandle("",null),
configname: commonLogic.appcommonhandle("配置名称",null),
formitem: commonLogic.appcommonhandle("文件",null),
systemid: commonLogic.appcommonhandle("系统",null),
pdynainstid: commonLogic.appcommonhandle("父实例",null),
configid: commonLogic.appcommonhandle("配置标识",null),
},
uiactions: {
},
},
dynainst_form: {
details: {
druipart1: commonLogic.appcommonhandle("副本",null),
tabpage1: commonLogic.appcommonhandle("副本",null),
tabpanel1: commonLogic.appcommonhandle("",null),
group1: commonLogic.appcommonhandle("动态模型基本信息",null),
formpage1: commonLogic.appcommonhandle("基本信息",null),
srforikey: commonLogic.appcommonhandle("",null),
srfkey: commonLogic.appcommonhandle("配置标识",null),
srfmajortext: commonLogic.appcommonhandle("配置名称",null),
srftempmode: commonLogic.appcommonhandle("",null),
srfuf: commonLogic.appcommonhandle("",null),
srfdeid: commonLogic.appcommonhandle("",null),
srfsourcekey: commonLogic.appcommonhandle("",null),
configname: commonLogic.appcommonhandle("配置名称",null),
formitem: commonLogic.appcommonhandle("文件",null),
systemid: commonLogic.appcommonhandle("系统",null),
configid: commonLogic.appcommonhandle("配置标识",null),
},
uiactions: {
},
},
main_grid: {
columns: {
configname: commonLogic.appcommonhandle("配置名称",null),
systemid: commonLogic.appcommonhandle("系统",null),
dynainstid: commonLogic.appcommonhandle("动态实例",null),
status: commonLogic.appcommonhandle("状态",null),
},
nodata:commonLogic.appcommonhandle("",null),
uiactions: {
},
},
default_searchform: {
details: {
formpage1: commonLogic.appcommonhandle("常规条件",null),
},
uiactions: {
},
},
dynainsteditviewtoolbar_toolbar: {
tbitem3: {
caption: commonLogic.appcommonhandle("Save",null),
tip: commonLogic.appcommonhandle("Save",null),
},
tbitem4: {
caption: commonLogic.appcommonhandle("Save And New",null),
tip: commonLogic.appcommonhandle("Save And New",null),
},
tbitem5: {
caption: commonLogic.appcommonhandle("Save And Close",null),
tip: commonLogic.appcommonhandle("Save And Close Window",null),
},
tbitem6: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem7: {
caption: commonLogic.appcommonhandle("Remove And Close",null),
tip: commonLogic.appcommonhandle("Remove And Close Window",null),
},
tbitem8: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem12: {
caption: commonLogic.appcommonhandle("New",null),
tip: commonLogic.appcommonhandle("New",null),
},
tbitem13: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem14: {
caption: commonLogic.appcommonhandle("Copy",null),
tip: commonLogic.appcommonhandle("Copy {0}",null),
},
tbitem16: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem23: {
caption: commonLogic.appcommonhandle("第一个记录",null),
tip: commonLogic.appcommonhandle("第一个记录",null),
},
tbitem24: {
caption: commonLogic.appcommonhandle("上一个记录",null),
tip: commonLogic.appcommonhandle("上一个记录",null),
},
tbitem25: {
caption: commonLogic.appcommonhandle("下一个记录",null),
tip: commonLogic.appcommonhandle("下一个记录",null),
},
tbitem26: {
caption: commonLogic.appcommonhandle("最后一个记录",null),
tip: commonLogic.appcommonhandle("最后一个记录",null),
},
tbitem21: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem22: {
caption: commonLogic.appcommonhandle("Help",null),
tip: commonLogic.appcommonhandle("Help",null),
},
},
gridviewtoolbar_toolbar: {
tbitem1_publish: {
caption: commonLogic.appcommonhandle("发布模型",null),
tip: commonLogic.appcommonhandle("发布模型",null),
},
tbitem2: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem3: {
caption: commonLogic.appcommonhandle("New",null),
tip: commonLogic.appcommonhandle("New",null),
},
tbitem4: {
caption: commonLogic.appcommonhandle("Edit",null),
tip: commonLogic.appcommonhandle("Edit {0}",null),
},
tbitem6: {
caption: commonLogic.appcommonhandle("Copy",null),
tip: commonLogic.appcommonhandle("Copy {0}",null),
},
tbitem7: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem8: {
caption: commonLogic.appcommonhandle("Remove",null),
tip: commonLogic.appcommonhandle("Remove {0}",null),
},
tbitem9: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem13: {
caption: commonLogic.appcommonhandle("Export",null),
tip: commonLogic.appcommonhandle("Export {0} Data To Excel",null),
},
tbitem10: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem16: {
caption: commonLogic.appcommonhandle("其它",null),
tip: commonLogic.appcommonhandle("其它",null),
},
tbitem21: {
caption: commonLogic.appcommonhandle("Export Data Model",null),
tip: commonLogic.appcommonhandle("导出数据模型",null),
},
tbitem23: {
caption: commonLogic.appcommonhandle("数据导入",null),
tip: commonLogic.appcommonhandle("数据导入",null),
},
tbitem17: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem19: {
caption: commonLogic.appcommonhandle("Filter",null),
tip: commonLogic.appcommonhandle("Filter",null),
},
tbitem18: {
caption: commonLogic.appcommonhandle("Help",null),
tip: commonLogic.appcommonhandle("Help",null),
},
},
editviewtoolbar_toolbar: {
tbitem1: {
caption: commonLogic.appcommonhandle("Save And Close",null),
tip: commonLogic.appcommonhandle("Save And Close Window",null),
},
tbitem2: {
caption: commonLogic.appcommonhandle("关闭",null),
tip: commonLogic.appcommonhandle("关闭",null),
},
},
dynainstgridviewtoolbar_toolbar: {
tbitem1_publish: {
caption: commonLogic.appcommonhandle("发布模型",null),
tip: commonLogic.appcommonhandle("发布模型",null),
},
tbitem2: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem3: {
caption: commonLogic.appcommonhandle("New",null),
tip: commonLogic.appcommonhandle("New",null),
},
tbitem4: {
caption: commonLogic.appcommonhandle("Edit",null),
tip: commonLogic.appcommonhandle("Edit {0}",null),
},
tbitem6: {
caption: commonLogic.appcommonhandle("Copy",null),
tip: commonLogic.appcommonhandle("Copy {0}",null),
},
tbitem7: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem8: {
caption: commonLogic.appcommonhandle("Remove",null),
tip: commonLogic.appcommonhandle("Remove {0}",null),
},
tbitem9: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem13: {
caption: commonLogic.appcommonhandle("Export",null),
tip: commonLogic.appcommonhandle("Export {0} Data To Excel",null),
},
tbitem10: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem16: {
caption: commonLogic.appcommonhandle("其它",null),
tip: commonLogic.appcommonhandle("其它",null),
},
tbitem21: {
caption: commonLogic.appcommonhandle("Export Data Model",null),
tip: commonLogic.appcommonhandle("导出数据模型",null),
},
tbitem23: {
caption: commonLogic.appcommonhandle("数据导入",null),
tip: commonLogic.appcommonhandle("数据导入",null),
},
tbitem17: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem19: {
caption: commonLogic.appcommonhandle("Filter",null),
tip: commonLogic.appcommonhandle("Filter",null),
},
tbitem18: {
caption: commonLogic.appcommonhandle("Help",null),
tip: commonLogic.appcommonhandle("Help",null),
},
},
};
return data;
}
export default getLocaleResourceBase;
\ No newline at end of file
import MetaDynamicModel_zh_CN_Base from './meta-dynamic-model_zh_CN_base';
function getLocaleResource(){
const MetaDynamicModel_zh_CN_OwnData = {};
const targetData = Object.assign(MetaDynamicModel_zh_CN_Base(), MetaDynamicModel_zh_CN_OwnData);
return targetData;
}
export default getLocaleResource;
\ No newline at end of file
import commonLogic from '@/locale/logic/common/common-logic';
function getLocaleResourceBase(){
const data:any = {
fields: {
dynainstid: commonLogic.appcommonhandle("动态实例",null),
system_id: commonLogic.appcommonhandle("系统",null),
configid: commonLogic.appcommonhandle("配置标识",null),
configname: commonLogic.appcommonhandle("配置名称",null),
pdynainstid: commonLogic.appcommonhandle("父实例",null),
modelfile: commonLogic.appcommonhandle("文件",null),
status: commonLogic.appcommonhandle("状态",null),
},
views: {
dynainsteditview: {
caption: commonLogic.appcommonhandle("动态模型",null),
title: commonLogic.appcommonhandle("动态模型编辑视图",null),
},
gridview: {
caption: commonLogic.appcommonhandle("动态模型",null),
title: commonLogic.appcommonhandle("动态模型",null),
},
dynainstgridview: {
caption: commonLogic.appcommonhandle("动态模型表格视图",null),
title: commonLogic.appcommonhandle("动态模型表格视图",null),
},
editview: {
caption: commonLogic.appcommonhandle("动态模型",null),
title: commonLogic.appcommonhandle("动态模型编辑视图",null),
},
},
main_form: {
details: {
group1: commonLogic.appcommonhandle("动态模型基本信息",null),
formpage1: commonLogic.appcommonhandle("基本信息",null),
srforikey: commonLogic.appcommonhandle("",null),
srfkey: commonLogic.appcommonhandle("配置标识",null),
srfmajortext: commonLogic.appcommonhandle("配置名称",null),
srftempmode: commonLogic.appcommonhandle("",null),
srfuf: commonLogic.appcommonhandle("",null),
srfdeid: commonLogic.appcommonhandle("",null),
srfsourcekey: commonLogic.appcommonhandle("",null),
configname: commonLogic.appcommonhandle("配置名称",null),
formitem: commonLogic.appcommonhandle("文件",null),
systemid: commonLogic.appcommonhandle("系统",null),
pdynainstid: commonLogic.appcommonhandle("父实例",null),
configid: commonLogic.appcommonhandle("配置标识",null),
},
uiactions: {
},
},
dynainst_form: {
details: {
druipart1: commonLogic.appcommonhandle("副本",null),
tabpage1: commonLogic.appcommonhandle("副本",null),
tabpanel1: commonLogic.appcommonhandle("",null),
group1: commonLogic.appcommonhandle("动态模型基本信息",null),
formpage1: commonLogic.appcommonhandle("基本信息",null),
srforikey: commonLogic.appcommonhandle("",null),
srfkey: commonLogic.appcommonhandle("配置标识",null),
srfmajortext: commonLogic.appcommonhandle("配置名称",null),
srftempmode: commonLogic.appcommonhandle("",null),
srfuf: commonLogic.appcommonhandle("",null),
srfdeid: commonLogic.appcommonhandle("",null),
srfsourcekey: commonLogic.appcommonhandle("",null),
configname: commonLogic.appcommonhandle("配置名称",null),
formitem: commonLogic.appcommonhandle("文件",null),
systemid: commonLogic.appcommonhandle("系统",null),
configid: commonLogic.appcommonhandle("配置标识",null),
},
uiactions: {
},
},
main_grid: {
columns: {
configname: commonLogic.appcommonhandle("配置名称",null),
systemid: commonLogic.appcommonhandle("系统",null),
dynainstid: commonLogic.appcommonhandle("动态实例",null),
status: commonLogic.appcommonhandle("状态",null),
},
nodata:commonLogic.appcommonhandle("",null),
uiactions: {
},
},
default_searchform: {
details: {
formpage1: commonLogic.appcommonhandle("常规条件",null),
},
uiactions: {
},
},
dynainsteditviewtoolbar_toolbar: {
tbitem3: {
caption: commonLogic.appcommonhandle("保存",null),
tip: commonLogic.appcommonhandle("保存",null),
},
tbitem4: {
caption: commonLogic.appcommonhandle("保存并新建",null),
tip: commonLogic.appcommonhandle("保存并新建",null),
},
tbitem5: {
caption: commonLogic.appcommonhandle("保存并关闭",null),
tip: commonLogic.appcommonhandle("保存并关闭",null),
},
tbitem6: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem7: {
caption: commonLogic.appcommonhandle("删除并关闭",null),
tip: commonLogic.appcommonhandle("删除并关闭",null),
},
tbitem8: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem12: {
caption: commonLogic.appcommonhandle("新建",null),
tip: commonLogic.appcommonhandle("新建",null),
},
tbitem13: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem14: {
caption: commonLogic.appcommonhandle("拷贝",null),
tip: commonLogic.appcommonhandle("拷贝",null),
},
tbitem16: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem23: {
caption: commonLogic.appcommonhandle("第一个记录",null),
tip: commonLogic.appcommonhandle("第一个记录",null),
},
tbitem24: {
caption: commonLogic.appcommonhandle("上一个记录",null),
tip: commonLogic.appcommonhandle("上一个记录",null),
},
tbitem25: {
caption: commonLogic.appcommonhandle("下一个记录",null),
tip: commonLogic.appcommonhandle("下一个记录",null),
},
tbitem26: {
caption: commonLogic.appcommonhandle("最后一个记录",null),
tip: commonLogic.appcommonhandle("最后一个记录",null),
},
tbitem21: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem22: {
caption: commonLogic.appcommonhandle("帮助",null),
tip: commonLogic.appcommonhandle("帮助",null),
},
},
gridviewtoolbar_toolbar: {
tbitem1_publish: {
caption: commonLogic.appcommonhandle("发布模型",null),
tip: commonLogic.appcommonhandle("发布模型",null),
},
tbitem2: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem3: {
caption: commonLogic.appcommonhandle("新建",null),
tip: commonLogic.appcommonhandle("新建",null),
},
tbitem4: {
caption: commonLogic.appcommonhandle("编辑",null),
tip: commonLogic.appcommonhandle("编辑",null),
},
tbitem6: {
caption: commonLogic.appcommonhandle("拷贝",null),
tip: commonLogic.appcommonhandle("拷贝",null),
},
tbitem7: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem8: {
caption: commonLogic.appcommonhandle("删除",null),
tip: commonLogic.appcommonhandle("删除",null),
},
tbitem9: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem13: {
caption: commonLogic.appcommonhandle("导出",null),
tip: commonLogic.appcommonhandle("导出",null),
},
tbitem10: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem16: {
caption: commonLogic.appcommonhandle("其它",null),
tip: commonLogic.appcommonhandle("其它",null),
},
tbitem21: {
caption: commonLogic.appcommonhandle("导出数据模型",null),
tip: commonLogic.appcommonhandle("导出数据模型",null),
},
tbitem23: {
caption: commonLogic.appcommonhandle("数据导入",null),
tip: commonLogic.appcommonhandle("数据导入",null),
},
tbitem17: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem19: {
caption: commonLogic.appcommonhandle("过滤",null),
tip: commonLogic.appcommonhandle("过滤",null),
},
tbitem18: {
caption: commonLogic.appcommonhandle("帮助",null),
tip: commonLogic.appcommonhandle("帮助",null),
},
},
editviewtoolbar_toolbar: {
tbitem1: {
caption: commonLogic.appcommonhandle("保存并关闭",null),
tip: commonLogic.appcommonhandle("保存并关闭",null),
},
tbitem2: {
caption: commonLogic.appcommonhandle("关闭",null),
tip: commonLogic.appcommonhandle("关闭",null),
},
},
dynainstgridviewtoolbar_toolbar: {
tbitem1_publish: {
caption: commonLogic.appcommonhandle("发布模型",null),
tip: commonLogic.appcommonhandle("发布模型",null),
},
tbitem2: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem3: {
caption: commonLogic.appcommonhandle("新建",null),
tip: commonLogic.appcommonhandle("新建",null),
},
tbitem4: {
caption: commonLogic.appcommonhandle("编辑",null),
tip: commonLogic.appcommonhandle("编辑",null),
},
tbitem6: {
caption: commonLogic.appcommonhandle("拷贝",null),
tip: commonLogic.appcommonhandle("拷贝",null),
},
tbitem7: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem8: {
caption: commonLogic.appcommonhandle("删除",null),
tip: commonLogic.appcommonhandle("删除",null),
},
tbitem9: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem13: {
caption: commonLogic.appcommonhandle("导出",null),
tip: commonLogic.appcommonhandle("导出",null),
},
tbitem10: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem16: {
caption: commonLogic.appcommonhandle("其它",null),
tip: commonLogic.appcommonhandle("其它",null),
},
tbitem21: {
caption: commonLogic.appcommonhandle("导出数据模型",null),
tip: commonLogic.appcommonhandle("导出数据模型",null),
},
tbitem23: {
caption: commonLogic.appcommonhandle("数据导入",null),
tip: commonLogic.appcommonhandle("数据导入",null),
},
tbitem17: {
caption: commonLogic.appcommonhandle("-",null),
tip: commonLogic.appcommonhandle("",null),
},
tbitem19: {
caption: commonLogic.appcommonhandle("过滤",null),
tip: commonLogic.appcommonhandle("过滤",null),
},
tbitem18: {
caption: commonLogic.appcommonhandle("帮助",null),
tip: commonLogic.appcommonhandle("帮助",null),
},
},
};
return data;
}
export default getLocaleResourceBase;
\ No newline at end of file
......@@ -27,6 +27,24 @@ mock.onGet('v7/sdindex-viewappmenu').reply((config: any) => {
textcls: '',
appfunctag: 'Auto1',
resourcetag: '',
},
{
id: '4AD5C30C-D39B-42EC-9418-70615CA75A3C',
name: 'menuitem2',
text: '动态模型',
type: 'MENUITEM',
counterid: '',
tooltip: '动态模型',
expanded: false,
separator: false,
hidden: false,
hidesidebar: false,
opendefault: false,
iconcls: '',
icon: '',
textcls: '',
appfunctag: 'AppFunc',
resourcetag: '',
},
],
}];
......
......@@ -8,6 +8,37 @@ mock.onGet('./assets/json/data-dictionary.json').reply((config: any) => {
let status = MockAdapter.mockStatus(config);
return [status, [
{
srfkey: "DynamicModelStatus",
emptytext: "未定义",
"codelisttype":"static",
items: [
{
id: "0",
label: "未激活",
text: "未激活",
"class":"",
"data":"",
"codename":"Item_0",
"color": "rgba(245, 158, 18, 1)",
value: "0",
disabled: false,
},
{
id: "1",
label: "已激活",
text: "已激活",
"class":"",
"data":"",
"codename":"Item_1",
"color": "rgba(100, 235, 22, 1)",
value: "1",
disabled: false,
},
]
},
{
"srfkey": "SysOperator",
"emptytext": "未定义",
"codelisttype":"dynamic",
......
import qs from 'qs';
import { MockAdapter } from '@/mock/mock-adapter';
const mock = MockAdapter.getInstance();
// 模拟数据
const mockDatas: Array<any> = [
];
//getwflink
mock.onGet(new RegExp(/^\/wfcore\/ibzdisk-app-web\/metadynamicmodels\/[a-zA-Z0-9\-\;]+\/usertasks\/[a-zA-Z0-9\-\;]+\/ways$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: getwflink");
console.table({url:config.url, method: config.method, data:config.data});
console.groupEnd();
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, {}];
}
return [status,[
{"sequenceFlowId":"dfdsfdsfdsfdsfds","sequenceFlowName":"同意",
"taskId":"aaaaddddccccddddd","processDefinitionKey":"support-workorders-approve-v1",
"processInstanceId":"ddlfldldfldsfds","refViewKey":""},
{"sequenceFlowId":"ddssdfdfdfdfsfdf","sequenceFlowName":"不同意",
"taskId":"aaaaddddccccddddd","processDefinitionKey":"support-workorders-approve-v1",
"processInstanceId":"ddfdsldlfdlldsf","refViewKey":"workorder_ltform_editview"}
]];
});
// getwfstep
mock.onGet(new RegExp(/^\/wfcore\/ibzdisk-app-web\/metadynamicmodels\/process-definitions-nodes$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: getwfstep");
console.table({url:config.url, method: config.method, data:config.data});
console.groupEnd();
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, {}];
}
return [status, [
{"userTaskId":"sddfddfd-dfdf-fdfd-fdf-dfdfd",
"userTaskName":"待审",
"cnt":0,
"processDefinitionKey":"support-workorders-approve-v1",
"processDefinitionName":"工单审批流程v1"
},
{"userTaskId":"sddfddfd-dfdf-fdfd-fdf-87927",
"userTaskName":"待分配",
"cnt":3,
"processDefinitionKey":"support-workorders-approve-v1",
"processDefinitionName":"工单审批流程v1"}
]];
});
// createBatch
mock.onPost(new RegExp(/^\/metadynamicmodels\/batch$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: createBatch");
console.table({url:config.url, method: config.method, data:config.data});
console.groupEnd();
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, {}];
}
return [status, {}];
});
// updateBatch
mock.onPut(new RegExp(/^\/metadynamicmodels\/batch$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: updateBatch");
console.table({url:config.url, method: config.method, data:config.data});
console.groupEnd();
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, {}];
}
return [status, {}];
});
// removeBatch
mock.onDelete(new RegExp(/^\/metadynamicmodels\/batch$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: removeBatch");
console.table({url:config.url, method: config.method, data:config.data});
console.groupEnd();
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, {}];
}
return [status, {}];
});
// Select
mock.onGet(new RegExp(/^\/metadynamicmodels\/([a-zA-Z0-9\-\;]{1,35})\/select$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: Select");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['configid'];
const matchArray:any = new RegExp(/^\/metadynamicmodels\/([a-zA-Z0-9\-\;]{1,35})\/select$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
let items = mockDatas ? mockDatas : [];
let _items = items.find((item: any) => Object.is(item.configid, tempValue.configid));
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(_items);
console.groupEnd();
console.groupEnd();
return [status, _items];
});
// Create
mock.onPost(new RegExp(/^\/metadynamicmodels\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: Create");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['configid'];
const matchArray:any = new RegExp(/^\/metadynamicmodels\/([a-zA-Z0-9\-\;]{1,35})$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(mockDatas[0]);
console.groupEnd();
console.groupEnd();
return [status, mockDatas[0]];
});
// Update
mock.onPut(new RegExp(/^\/metadynamicmodels\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: Update");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['configid'];
const matchArray:any = new RegExp(/^\/metadynamicmodels\/([a-zA-Z0-9\-\;]{1,35})$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.configid, tempValue.configid));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['configid'] == tempValue['configid'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// GetDraft
mock.onGet(new RegExp(/^\/metadynamicmodels\/getdraft$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: GetDraft");
console.table({url:config.url, method: config.method, data:config.data});
// GetDraft
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table({});
console.groupEnd();
console.groupEnd();
return [status, {}];
});
// CheckKey
mock.onPost(new RegExp(/^\/metadynamicmodels\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: CheckKey");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['configid'];
const matchArray:any = new RegExp(/^\/metadynamicmodels\/([a-zA-Z0-9\-\;]{1,35})\/checkkey$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.configid, tempValue.configid));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['configid'] == tempValue['configid'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// Init
mock.onPost(new RegExp(/^\/metadynamicmodels\/?([a-zA-Z0-9\-\;]{0,35})\/init$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: Init");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['configid'];
const matchArray:any = new RegExp(/^\/metadynamicmodels\/([a-zA-Z0-9\-\;]{1,35})\/init$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.configid, tempValue.configid));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['configid'] == tempValue['configid'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// Publish
mock.onPost(new RegExp(/^\/metadynamicmodels\/?([a-zA-Z0-9\-\;]{0,35})\/publish$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: Publish");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['configid'];
const matchArray:any = new RegExp(/^\/metadynamicmodels\/([a-zA-Z0-9\-\;]{1,35})\/publish$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.configid, tempValue.configid));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['configid'] == tempValue['configid'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// Save
mock.onPost(new RegExp(/^\/metadynamicmodels\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: Save");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['configid'];
const matchArray:any = new RegExp(/^\/metadynamicmodels\/([a-zA-Z0-9\-\;]{1,35})\/save$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.configid, tempValue.configid));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['configid'] == tempValue['configid'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// FetchDefault
mock.onGet(new RegExp(/^\/metadynamicmodels\/fetchdefault$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: FetchDefault");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(mockDatas);
console.groupEnd();
console.groupEnd();
return [status, mockDatas ? mockDatas : []];
});
// FetchDefault
mock.onGet(new RegExp(/^\/metadynamicmodels\/fetchdefault(\?[\w-./?%&=,]*)*$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: FetchDefault");
console.table({url:config.url, method: config.method, data:config.data});
if(config.url.includes('page')){
let url = config.url.split('?')[1];
let params = qs.parse(url);
Object.assign(config, params);
}
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
let total = mockDatas.length;
let records: Array<any> = [];
if(!config.page || !config.size){
records = mockDatas;
}else{
if((config.page-1)*config.size < total){
records = mockDatas.slice(config.page,config.size);
}
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(records ? records : []);
console.groupEnd();
console.groupEnd();
return [status, records ? records : []];
});
// FetchDynaInst
mock.onGet(new RegExp(/^\/metadynamicmodels\/fetchdynainst$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: FetchDynaInst");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(mockDatas);
console.groupEnd();
console.groupEnd();
return [status, mockDatas ? mockDatas : []];
});
// FetchDynaInst
mock.onGet(new RegExp(/^\/metadynamicmodels\/fetchdynainst(\?[\w-./?%&=,]*)*$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: FetchDynaInst");
console.table({url:config.url, method: config.method, data:config.data});
if(config.url.includes('page')){
let url = config.url.split('?')[1];
let params = qs.parse(url);
Object.assign(config, params);
}
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
let total = mockDatas.length;
let records: Array<any> = [];
if(!config.page || !config.size){
records = mockDatas;
}else{
if((config.page-1)*config.size < total){
records = mockDatas.slice(config.page,config.size);
}
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(records ? records : []);
console.groupEnd();
console.groupEnd();
return [status, records ? records : []];
});
// URI参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// Remove
mock.onDelete(new RegExp(/^\/metadynamicmodels\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: Remove");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['configid'];
const matchArray:any = new RegExp(/^\/metadynamicmodels\/([a-zA-Z0-9\-\;]{1,35})$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
let items = mockDatas ? mockDatas : [];
let _items = items.find((item: any) => Object.is(item.configid, tempValue.configid));
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(_items?_items:{});
console.groupEnd();
console.groupEnd();
return [status, _items?_items:{}];
});
// Get
mock.onGet(new RegExp(/^\/metadynamicmodels\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:metadynamicmodel 方法: Get");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['configid'];
const matchArray:any = new RegExp(/^\/metadynamicmodels\/([a-zA-Z0-9\-\;]{1,35})$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
let items = mockDatas ? mockDatas : [];
let _items = items.find((item: any) => Object.is(item.configid, tempValue.configid));
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(_items?_items:{});
console.groupEnd();
console.groupEnd();
return [status, _items?_items:{}];
});
......@@ -7,4 +7,5 @@ import './login/login';
import './upload/upload';
// 实体级接口对象
import './entity/meta-dynamic-models/meta-dynamic-models';
import './entity/sdfiles/sdfiles';
......@@ -23,6 +23,22 @@ mock.onGet('./assets/json/view-config.json').reply((config: any) => {
"viewname": "SDFileGridView",
"viewtag": "795a12a2bfb63a98ce5bb80310509360"
},
"metadynamicmodeldynainsteditview": {
"title": "动态模型编辑视图",
"caption": "动态模型",
"viewtype": "DEEDITVIEW",
"viewmodule": "lite",
"viewname": "MetaDynamicModelDynaInstEditView",
"viewtag": "92d51d41db51a671793ee8dc8876f9e9"
},
"metadynamicmodelgridview": {
"title": "动态模型",
"caption": "动态模型",
"viewtype": "DEGRIDVIEW",
"viewmodule": "lite",
"viewname": "MetaDynamicModelGridView",
"viewtag": "af9cfc34d957186380a012e322abff0c"
},
"sdindexview": {
"title": "ibizlab-disk",
"caption": "ibizlab-disk",
......@@ -30,6 +46,22 @@ mock.onGet('./assets/json/view-config.json').reply((config: any) => {
"viewmodule": "disk",
"viewname": "SDIndexView",
"viewtag": "c0a8e8c1058d9a5cdb5a6edbf9855886"
},
"metadynamicmodeldynainstgridview": {
"title": "动态模型表格视图",
"caption": "动态模型表格视图",
"viewtype": "DEGRIDVIEW",
"viewmodule": "lite",
"viewname": "MetaDynamicModelDynaInstGridView",
"viewtag": "cec3236f5a1f742f9b91f313506ccc6c"
},
"metadynamicmodeleditview": {
"title": "动态模型编辑视图",
"caption": "动态模型",
"viewtype": "DEEDITVIEW",
"viewmodule": "lite",
"viewname": "MetaDynamicModelEditView",
"viewtag": "e8892afaebe9a899e5d528d5b55d3cc5"
}
}];
});
......
export const PageComponents = {
install(Vue: any, opt: any) {
Vue.component('sdfile-edit-view', () => import('@pages/disk/sdfile-edit-view/sdfile-edit-view.vue'));
Vue.component('meta-dynamic-model-edit-view', () => import('@pages/lite/meta-dynamic-model-edit-view/meta-dynamic-model-edit-view.vue'));
Vue.component('sdfile-edit-view', () => import('@pages/disk/sdfile-edit-view/sdfile-edit-view.vue'));
Vue.component('meta-dynamic-model-grid-view', () => import('@pages/lite/meta-dynamic-model-grid-view/meta-dynamic-model-grid-view.vue'));
Vue.component('sdfile-grid-view', () => import('@pages/disk/sdfile-grid-view/sdfile-grid-view.vue'));
}
};
\ No newline at end of file
......@@ -35,6 +35,20 @@ const router = new Router({
},
component: () => import('@pages/disk/sdindex-view/sdindex-view.vue'),
children: [
{
path: 'metadynamicmodels/:metadynamicmodel?/editview/:editview?',
meta: {
caption: 'entities.metadynamicmodel.views.editview.caption',
info:'',
parameters: [
{ pathName: 'sdindexview', parameterName: 'sdindexview' },
{ pathName: 'metadynamicmodels', parameterName: 'metadynamicmodel' },
{ pathName: 'editview', parameterName: 'editview' },
],
requireAuth: true,
},
component: () => import('@pages/lite/meta-dynamic-model-edit-view/meta-dynamic-model-edit-view.vue'),
},
{
path: 'sdfiles/:sdfile?/editview/:editview?',
meta: {
......@@ -49,6 +63,20 @@ const router = new Router({
},
component: () => import('@pages/disk/sdfile-edit-view/sdfile-edit-view.vue'),
},
{
path: 'metadynamicmodels/:metadynamicmodel?/gridview/:gridview?',
meta: {
caption: 'entities.metadynamicmodel.views.gridview.caption',
info:'',
parameters: [
{ pathName: 'sdindexview', parameterName: 'sdindexview' },
{ pathName: 'metadynamicmodels', parameterName: 'metadynamicmodel' },
{ pathName: 'gridview', parameterName: 'gridview' },
],
requireAuth: true,
},
component: () => import('@pages/lite/meta-dynamic-model-grid-view/meta-dynamic-model-grid-view.vue'),
},
{
path: 'sdfiles/:sdfile?/gridview/:gridview?',
meta: {
......@@ -91,6 +119,32 @@ const router = new Router({
requireAuth: true,
},
component: () => import('@pages/disk/sdfile-grid-view/sdfile-grid-view.vue'),
},
{
path: '/metadynamicmodels/:metadynamicmodel?/gridview/:gridview?',
meta: {
caption: 'entities.metadynamicmodel.views.gridview.caption',
info:'',
parameters: [
{ pathName: 'metadynamicmodels', parameterName: 'metadynamicmodel' },
{ pathName: 'gridview', parameterName: 'gridview' },
],
requireAuth: true,
},
component: () => import('@pages/lite/meta-dynamic-model-grid-view/meta-dynamic-model-grid-view.vue'),
},
{
path: '/metadynamicmodels/:metadynamicmodel?/editview/:editview?',
meta: {
caption: 'entities.metadynamicmodel.views.editview.caption',
info:'',
parameters: [
{ pathName: 'metadynamicmodels', parameterName: 'metadynamicmodel' },
{ pathName: 'editview', parameterName: 'editview' },
],
requireAuth: true,
},
component: () => import('@pages/lite/meta-dynamic-model-edit-view/meta-dynamic-model-edit-view.vue'),
},
...globalRoutes,
{
......
<template>
<div class="view-container deeditview meta-dynamic-model-dyna-inst-edit-view">
<app-studioaction :viewTitle="$t(model.srfCaption)" viewName="metadynamicmodeldynainsteditview"></app-studioaction>
<card class='view-card ' :disHover="true" :bordered="false">
<div slot='title' class="header-container">
<span class='caption-info'>{{$t(model.srfCaption)}}</span>
<div class='toolbar-container'>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem3.visabled" :disabled="toolBarModels.tbitem3.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem3' }, $event)">
<i class='fa fa-save'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem3.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem3.tip')}}</div>
</tooltip>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem4.visabled" :disabled="toolBarModels.tbitem4.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem4' }, $event)">
<i class='sx-tb-saveandnew'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem4.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem4.tip')}}</div>
</tooltip>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem5.visabled" :disabled="toolBarModels.tbitem5.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem5' }, $event)">
<i class='sx-tb-saveandclose'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem5.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem5.tip')}}</div>
</tooltip>
<span class='seperator'>|</span>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem7.visabled" :disabled="toolBarModels.tbitem7.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem7' }, $event)">
<i class='fa fa-remove'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem7.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem7.tip')}}</div>
</tooltip>
<span class='seperator'>|</span>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem12.visabled" :disabled="toolBarModels.tbitem12.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem12' }, $event)">
<i class='fa fa-file-text-o'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem12.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem12.tip')}}</div>
</tooltip>
<span class='seperator'>|</span>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem14.visabled" :disabled="toolBarModels.tbitem14.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem14' }, $event)">
<i class='fa fa-copy'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem14.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem14.tip')}}</div>
</tooltip>
<span class='seperator'>|</span>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem23.visabled" :disabled="toolBarModels.tbitem23.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem23' }, $event)">
<i class='fa fa-fast-backward'></i>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem23.tip')}}</div>
</tooltip>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem24.visabled" :disabled="toolBarModels.tbitem24.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem24' }, $event)">
<i class='fa fa-step-backward'></i>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem24.tip')}}</div>
</tooltip>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem25.visabled" :disabled="toolBarModels.tbitem25.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem25' }, $event)">
<i class='fa fa-step-forward'></i>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem25.tip')}}</div>
</tooltip>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem26.visabled" :disabled="toolBarModels.tbitem26.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem26' }, $event)">
<i class='fa fa-fast-forward'></i>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem26.tip')}}</div>
</tooltip>
<span class='seperator'>|</span>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem22.visabled" :disabled="toolBarModels.tbitem22.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem22' }, $event)">
<i class='fa fa-question'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem22.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainsteditviewtoolbar_toolbar.tbitem22.tip')}}</div>
</tooltip>
</div>
</div>
<div class='view-top-messages'>
</div>
<div class="content-container">
<div class='view-body-messages'>
</div>
<view_form
:viewState="viewState"
:viewparams="viewparams"
:context="context"
:autosave="false"
:viewtag="viewtag"
:showBusyIndicator="true"
updateAction="Update"
removeAction="Remove"
loaddraftAction="GetDraft"
loadAction="Get"
createAction="Create"
WFSubmitAction=""
WFStartAction=""
style=''
name="form"
ref='form'
@save="form_save($event)"
@remove="form_remove($event)"
@load="form_load($event)"
@closeview="closeView($event)">
</view_form>
</div>
<div class='view-bottom-messages'>
</div>
</card>
</div>
</template>
<script lang='tsx'>
import { Vue, Component, Prop, Provide, Emit, Watch,Inject } from 'vue-property-decorator';
import { UIActionTool,Util } from '@/utils';
import NavDataService from '@/service/app/navdata-service';
import { Subject,Subscription } from 'rxjs';
import MetaDynamicModelService from '@/service/meta-dynamic-model/meta-dynamic-model-service';
import MetaDynamicModelAuthService from '@/authservice/meta-dynamic-model/meta-dynamic-model-auth-service';
import EditViewEngine from '@engine/view/edit-view-engine';
import MetaDynamicModelUIService from '@/uiservice/meta-dynamic-model/meta-dynamic-model-ui-service';
@Component({
components: {
},
})
export default class MetaDynamicModelDynaInstEditViewBase extends Vue {
/**
* 实体服务对象
*
* @type {MetaDynamicModelService}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public appEntityService: MetaDynamicModelService = new MetaDynamicModelService;
/**
* 实体UI服务对象
*
* @type MetaDynamicModelUIService
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public appUIService: MetaDynamicModelUIService = new MetaDynamicModelUIService(this.$store);
/**
* 数据变化
*
* @param {*} val
* @returns {*}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
@Emit()
public viewDatasChange(val: any):any {
return val;
}
/**
* 传入视图上下文
*
* @type {string}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
@Prop() public viewdata!: string;
/**
* 传入视图参数
*
* @type {string}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
@Prop() public viewparam!: string;
/**
* 视图默认使用
*
* @type {boolean}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
@Prop({ default: true }) public viewDefaultUsage!: boolean;
/**
* 视图默认使用
*
* @type {string}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
@Inject({from:'navModel',default: 'tab'})
public navModel!:string;
/**
* 视图标识
*
* @type {string}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public viewtag: string = '92d51d41db51a671793ee8dc8876f9e9';
/**
* 自定义视图导航上下文集合
*
* @type {*}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public customViewNavContexts:any ={
};
/**
* 自定义视图导航参数集合
*
* @type {*}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public customViewParams:any ={
};
/**
* 视图模型数据
*
* @type {*}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public model: any = {
srfCaption: 'entities.metadynamicmodel.views.dynainsteditview.caption',
srfTitle: 'entities.metadynamicmodel.views.dynainsteditview.title',
srfSubTitle: 'entities.metadynamicmodel.views.dynainsteditview.subtitle',
dataInfo: ''
}
/**
* 视图参数变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
@Watch('viewparam',{immediate: true, deep: true})
onParamData(newVal: any, oldVal: any) {
if(newVal){
this.viewparams = {};
if(typeof newVal == 'string') {
Object.assign(this.viewparams, JSON.parse(this.viewparam));
}else{
this.viewparams = Util.deepCopy(this.viewparam);
}
}
}
/**
* 处理应用上下文变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
@Watch('viewdata')
onViewData(newVal: any, oldVal: any) {
const _this: any = this;
if (!Object.is(newVal, oldVal) && _this.engine) {
this.$nextTick(()=>{
_this.parseViewParam();
_this.engine.load();
});
} else if(!Object.is(newVal, oldVal) && _this.refresh && _this.refresh instanceof Function) {
_this.refresh();
}
}
/**
* 容器模型
*
* @type {*}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public containerModel: any = {
view_toolbar: { name: 'toolbar', type: 'TOOLBAR' },
view_form: { name: 'form', type: 'FORM' },
};
/**
* 视图刷新
*
* @param {*} args
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public refresh(args?: any): void {
const refs: any = this.$refs;
if (refs && refs.form) {
refs.form.refresh();
}
}
/**
* 计数器刷新
*
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public counterRefresh(){
const _this:any =this;
if(_this.counterServiceArray && _this.counterServiceArray.length >0){
_this.counterServiceArray.forEach((item:any) =>{
if(item.refreshData && item.refreshData instanceof Function){
item.refreshData();
}
})
}
}
/**
* 视图状态订阅对象
*
* @public
* @type {Subject<{action: string, data: any}>}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public viewState: Subject<ViewState> = new Subject();
/**
* 工具栏模型
*
* @type {*}
* @memberof MetaDynamicModelDynaInstEditView
*/
public toolBarModels: any = {
tbitem3: { name: 'tbitem3', actiontarget: 'NONE', caption: '保存', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'Save', target: '' } },
tbitem4: { name: 'tbitem4', actiontarget: 'NONE', caption: '保存并新建', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'SaveAndNew', target: '' } },
tbitem5: { name: 'tbitem5', actiontarget: 'NONE', caption: '保存并关闭', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'SaveAndExit', target: '' } },
tbitem6: { name: 'tbitem6', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
tbitem7: { name: 'tbitem7', actiontarget: 'NONE', caption: '删除并关闭', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'RemoveAndExit', target: 'SINGLEKEY' } },
tbitem8: { name: 'tbitem8', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
tbitem12: { name: 'tbitem12', actiontarget: 'NONE', caption: '新建', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'New', target: '' } },
tbitem13: { name: 'tbitem13', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
tbitem14: { name: 'tbitem14', actiontarget: 'NONE', caption: '拷贝', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'Copy', target: 'SINGLEKEY' } },
tbitem16: { name: 'tbitem16', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
tbitem23: { name: 'tbitem23', actiontarget: 'NONE', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'FirstRecord', target: 'SINGLEKEY' } },
tbitem24: { name: 'tbitem24', actiontarget: 'NONE', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'PrevRecord', target: 'SINGLEKEY' } },
tbitem25: { name: 'tbitem25', actiontarget: 'NONE', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'NextRecord', target: 'SINGLEKEY' } },
tbitem26: { name: 'tbitem26', actiontarget: 'NONE', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'LastRecord', target: 'SINGLEKEY' } },
tbitem21: { name: 'tbitem21', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
tbitem22: { name: 'tbitem22', actiontarget: 'NONE', caption: '帮助', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'Help', target: '' } },
};
/**
* 视图引擎
*
* @public
* @type {Engine}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public engine: EditViewEngine = new EditViewEngine();
/**
* 引擎初始化
*
* @public
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public engineInit(): void {
this.engine.init({
view: this,
form: this.$refs.form,
p2k: '0',
keyPSDEField: 'metadynamicmodel',
majorPSDEField: 'configname',
isLoadDefault: true,
});
}
/**
* 应用导航服务
*
* @type {*}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public navDataService = NavDataService.getInstance(this.$store);
/**
* 导航服务事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public serviceStateEvent: Subscription | undefined;
/**
* 门户部件状态对象
*
* @type {*}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
@Prop() public portletState?: any;
/**
* 门户部件状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public portletStateEvent: Subscription | undefined;
/**
* 应用上下文
*
* @type {*}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public context:any = {};
/**
* 视图参数
*
* @type {*}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public viewparams:any = {};
/**
* 视图缓存数据
*
* @type {*}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public viewCacheData:any;
/**
* 计数器服务对象集合
*
* @type {Array<*>}
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public counterServiceArray:Array<any> = [];
/**
* 解析视图参数
*
* @public
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public parseViewParam(inputvalue:any = null): void {
for(let key in this.context){
delete this.context[key];
}
if(this.$store.getters.getAppData() && this.$store.getters.getAppData().context){
Object.assign(this.context,this.$store.getters.getAppData().context);
}
if (!this.viewDefaultUsage && this.viewdata && !Object.is(this.viewdata, '')) {
if(typeof this.viewdata == 'string') {
Object.assign(this.context, JSON.parse(this.viewdata));
}
if(this.context && this.context.srfparentdename){
Object.assign(this.viewparams,{srfparentdename:this.context.srfparentdename});
}
if(this.context && this.context.srfparentkey){
Object.assign(this.viewparams,{srfparentkey:this.context.srfparentkey});
}
this.handleCustomViewData();
return;
}
const path = (this.$route.matched[this.$route.matched.length - 1]).path;
const keys: Array<any> = [];
const curReg = this.$pathToRegExp.pathToRegexp(path, keys);
const matchArray = curReg.exec(this.$route.path);
let tempValue: Object = {};
keys.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item.name, {
enumerable: true,
value: matchArray[index + 1]
});
});
this.$viewTool.formatRouteParams(tempValue,this.$route,this.context,this.viewparams);
if(inputvalue){
Object.assign(this.context,{'metadynamicmodel':inputvalue});
}
//初始化视图唯一标识
Object.assign(this.context,{srfsessionid:this.$util.createUUID()});
this.handleCustomViewData();
//初始化导航数据
this.initNavDataWithRoute();
}
/**
* 处理自定义视图数据
*
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public handleCustomViewData(){
if(Object.keys(this.customViewNavContexts).length > 0){
Object.keys(this.customViewNavContexts).forEach((item:any) =>{
let tempContext:any = {};
let curNavContext:any = this.customViewNavContexts[item];
this.handleCustomDataLogic(curNavContext,tempContext,item);
Object.assign(this.context,tempContext);
})
}
if(Object.keys(this.customViewParams).length > 0){
Object.keys(this.customViewParams).forEach((item:any) =>{
let tempParam:any = {};
let curNavParam:any = this.customViewParams[item];
this.handleCustomDataLogic(curNavParam,tempParam,item);
Object.assign(this.viewparams,tempParam);
})
}
}
/**
* 处理自定义视图数据逻辑
*
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public handleCustomDataLogic(curNavData:any,tempData:any,item:string){
// 直接值直接赋值
if(curNavData.isRawValue){
if(Object.is(curNavData.value,"null") || Object.is(curNavData.value,"")){
Object.defineProperty(tempData, item.toLowerCase(), {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item.toLowerCase(), {
value: curNavData.value,
writable : true,
enumerable : true,
configurable : true
});
}
}else{
// 先从导航上下文取数,没有再从导航参数(URL)取数,如果导航上下文和导航参数都没有则为null
if(this.context[(curNavData.value).toLowerCase()] != null){
Object.defineProperty(tempData, item.toLowerCase(), {
value: this.context[(curNavData.value).toLowerCase()],
writable : true,
enumerable : true,
configurable : true
});
}else{
if(this.viewparams[(curNavData.value).toLowerCase()] != null){
Object.defineProperty(tempData, item.toLowerCase(), {
value: this.viewparams[(curNavData.value).toLowerCase()],
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item.toLowerCase(), {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}
}
}
}
/**
* 初始化导航数据(路由模式)
*
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public initNavDataWithRoute(data:any = null, isNew:boolean = false, isAlways:boolean = false){
if( isAlways || (this.viewDefaultUsage && Object.is(this.navModel,"route")) ){
this.navDataService.addNavData({id:'meta-dynamic-model-dyna-inst-edit-view',tag:this.viewtag,srfkey:isNew ? null : this.context.metadynamicmodel,title:this.$t(this.model.srfCaption),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath});
}
}
/**
* 初始化导航数据(分页模式)
*
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true, isAlways:boolean = false){
if( isAlways || (this.viewDefaultUsage && !Object.is(this.navModel,"route")) ){
this.navDataService.addNavDataByOnly({id:'meta-dynamic-model-dyna-inst-edit-view',tag:this.viewtag,srfkey:this.context.metadynamicmodel,title:this.$t(this.model.srfCaption),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath},isOnlyAdd);
}
}
/**
* Vue声明周期
*
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public created() {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public afterCreated(){
let _this:any = this;
const secondtag = _this.$util.createUUID();
_this.$store.commit('viewaction/createdView', { viewtag: _this.viewtag, secondtag: secondtag });
_this.viewtag = secondtag;
_this.parseViewParam();
_this.serviceStateEvent = _this.navDataService.serviceState.subscribe(({ action,name, data }:{ action:string,name:any,data:any }) => {
if(!Object.is(name,'meta-dynamic-model-dyna-inst-edit-view')){
return;
}
if (Object.is(action, 'viewrefresh')) {
_this.$nextTick(()=>{
_this.parseViewParam(data);
if(_this.engine){
_this.engine.load();
}
});
}
});
if(_this.portletState){
_this.portletStateEvent = _this.portletState.subscribe((res:any) =>{
if(!Object.is(res.name,'MetaDynamicModelDynaInstEditView')){
return;
}
if(Object.is(res.action,'refresh') && _this.refresh && _this.refresh instanceof Function){
_this.refresh();
}
})
}
}
/**
* 销毁之前
*
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public beforeDestroy() {
this.$store.commit('viewaction/removeView', this.viewtag);
}
/**
* Vue声明周期(组件初始化完毕)
*
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public mounted() {
this.afterMounted();
}
/**
* 执行mounted后的逻辑
*
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public afterMounted(){
const _this: any = this;
_this.engineInit();
if (_this.loadModel && _this.loadModel instanceof Function) {
_this.loadModel();
}
}
/**
* toolbar 部件 click 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public toolbar_click($event: any, $event2?: any) {
if (Object.is($event.tag, 'tbitem3')) {
this.toolbar_tbitem3_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem4')) {
this.toolbar_tbitem4_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem5')) {
this.toolbar_tbitem5_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem7')) {
this.toolbar_tbitem7_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem9')) {
this.toolbar_tbitem9_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem10')) {
this.toolbar_tbitem10_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem12')) {
this.toolbar_tbitem12_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem14')) {
this.toolbar_tbitem14_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem15')) {
this.toolbar_tbitem15_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem23')) {
this.toolbar_tbitem23_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem24')) {
this.toolbar_tbitem24_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem25')) {
this.toolbar_tbitem25_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem26')) {
this.toolbar_tbitem26_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem22')) {
this.toolbar_tbitem22_click(null, '', $event2);
}
}
/**
* form 部件 save 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public form_save($event: any, $event2?: any) {
this.engine.onCtrlEvent('form', 'save', $event);
}
/**
* form 部件 remove 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public form_remove($event: any, $event2?: any) {
this.engine.onCtrlEvent('form', 'remove', $event);
}
/**
* form 部件 load 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public form_load($event: any, $event2?: any) {
this.engine.onCtrlEvent('form', 'load', $event);
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem3_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Save(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem4_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.SaveAndNew(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem5_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.SaveAndExit(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem7_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.RemoveAndExit(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem9_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.SaveAndStart(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem10_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.ViewWFStep(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem12_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.New(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem14_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Copy(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem15_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Print(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem23_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.FirstRecord(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem24_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.PrevRecord(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem25_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.NextRecord(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem26_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.LastRecord(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem22_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Help(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 保存
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public Save(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
// 界面行为容器对象 _this
const _this: any = this;
if (xData && xData.save instanceof Function) {
xData.save().then((response: any) => {
if (!response || response.status !== 200) {
return;
}
_this.$emit('viewdataschange', [{ ...response.data }]);
});
} else if (_this.save && _this.save instanceof Function) {
_this.save();
}
}
/**
* 保存并新建
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public SaveAndNew(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (!xData || !(xData.saveAndNew instanceof Function)) {
return;
}
xData.saveAndNew().then((response: any) => {
if (!response || response.status !== 200) {
_this.$emit('viewdataschange', JSON.stringify({status:'error',action:'saveAndNew'}));
return;
}
_this.$emit('viewdataschange', JSON.stringify({status:'success',action:'saveAndNew',data:response.data}));
if (xData.autoLoad instanceof Function) {
xData.autoLoad();
}
});
}
/**
* 保存并关闭
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public SaveAndExit(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (xData && xData.saveAndExit instanceof Function) {
xData.saveAndExit().then((response: any) => {
if (!response || response.status !== 200) {
return;
}
if(window.parent){
window.parent.postMessage([{ ...response.data }],'*');
}
});
} else if (_this.saveAndExit && _this.saveAndExit instanceof Function) {
_this.saveAndExit().then((response: any) => {
if (!response || response.status !== 200) {
return;
}
if(window.parent){
window.parent.postMessage([{ ...response.data }],'*');
}
});
}
}
/**
* 删除并关闭
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public RemoveAndExit(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (xData && xData.removeAndExit instanceof Function) {
xData.removeAndExit().then((response: any) => {
if (!response || response.status !== 200) {
return;
}
if(window.parent){
window.parent.postMessage([{ ...response.data }],'*');
}
});
} else if (_this.removeAndExit && _this.removeAndExit instanceof Function) {
_this.removeAndExit().then((response: any) => {
if (!response || response.status !== 200) {
return;
}
if(window.parent){
window.parent.postMessage([{ ...response.data }],'*');
}
});
}
}
/**
* 开始流程
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public SaveAndStart(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (!xData || !(xData.wfstart instanceof Function)) {
return;
}
xData.wfstart(args).then((response: any) => {
if (!response || response.status !== 200) {
return;
}
const { data: _data } = response;
if(window.parent){
window.parent.postMessage({ ..._data },'*');
}
if (_this.viewdata) {
_this.$emit('viewdataschange', [{ ..._data }]);
_this.$emit('close');
}else if (this.$tabPageExp) {
this.$tabPageExp.onClose(this.$route.fullPath);
}
});
}
/**
* 当前流程步骤
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public ViewWFStep(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
let _this:any = this;
if (!xData || !(xData.wfsubmit instanceof Function)) {
return;
}
xData.wfsubmit(args).then((response: any) => {
if (!response || response.status !== 200) {
return;
}
const { data: _data } = response;
if (_this.viewdata) {
_this.$emit('viewdataschange', [{ ..._data }]);
_this.$emit('close');
} else if (_this.$tabPageExp) {
_this.$tabPageExp.onClose(_this.$route.fullPath);
}
});
}
/**
* 新建
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public New(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (_this.newdata && _this.newdata instanceof Function) {
const data: any = {};
_this.newdata([{ ...data }],[{ ...data }], params, $event, xData);
} else {
_this.$Notice.error({ title: '错误', desc: 'newdata 视图处理逻辑不存在,请添加!' });
}
}
/**
* 拷贝
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public Copy(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
if (args.length === 0) {
return;
}
const _this: any = this;
if (_this.opendata && _this.opendata instanceof Function) {
const data: any = { };
if (args.length > 0) {
Object.assign(data, { metadynamicmodel: args[0].metadynamicmodel });
}
if(!params) params = {};
Object.assign(args,{copymode:true});
_this.opendata([{ ...data }], args, params, $event, xData);
} else {
Object.assign(this.viewparams,{copymode:true});
}
}
/**
* 打印
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public Print(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
let _this:any = this;
if (!xData || !(xData.print instanceof Function) || !$event) {
return ;
}
xData.print();
}
/**
* 第一个记录
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public FirstRecord(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
let _this:any = this;
let navDataService:any = new NavDataService(this.$store);
let allNavData:any = Object.is(this.navModel,"route")?navDataService.getPreNavDataById('meta-dynamic-model-dyna-inst-edit-view'):navDataService.getPreNavDataByTag(_this.viewtag);
if(allNavData && allNavData.data && allNavData.data.length >0){
if(_this.parseViewParam && _this.engine){
_this.parseViewParam(allNavData.data[0].srfkey);
_this.engine.load();
}
}else{
this.$Notice.warning({ title: '警告', desc: '请确认操作路径是否正确' });
}
}
/**
* 上一个记录
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public PrevRecord(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
if(args.length === 0 || !args[0].srfkey){
return;
}
let _this:any = this;
let navDataService:any = new NavDataService(this.$store);
let allNavData:any = Object.is(this.navModel,"route")?navDataService.getPreNavDataById('meta-dynamic-model-dyna-inst-edit-view'):navDataService.getPreNavDataByTag(_this.viewtag);
if(allNavData && allNavData.data && allNavData.data.length >0){
let computedIndex:any;
for(let i=0;i<allNavData.data.length;i++){
if(allNavData.data[i].srfkey === args[0].srfkey){
computedIndex = i-1;
break;
}
}
if(computedIndex >= 0){
if(_this.parseViewParam && _this.engine){
_this.parseViewParam(allNavData.data[computedIndex].srfkey);
_this.engine.load();
}
}else{
this.$Notice.warning({ title: '警告', desc: '当前数据已经是第一条数据' });
}
}else{
this.$Notice.warning({ title: '警告', desc: '请确认操作路径是否正确' });
}
}
/**
* 下一个记录
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public NextRecord(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
if(args.length === 0 || !args[0].srfkey){
return;
}
let _this:any = this;
let navDataService:any = new NavDataService(this.$store);
let allNavData:any = Object.is(this.navModel,"route")?navDataService.getPreNavDataById('meta-dynamic-model-dyna-inst-edit-view'):navDataService.getPreNavDataByTag(_this.viewtag);
if(allNavData && allNavData.data && allNavData.data.length >0){
let computedIndex:any;
for(let i=0;i<allNavData.data.length;i++){
if(allNavData.data[i].srfkey === args[0].srfkey){
computedIndex = i+1;
break;
}
}
if(computedIndex < allNavData.data.length){
if(_this.parseViewParam && _this.engine){
_this.parseViewParam(allNavData.data[computedIndex].srfkey);
_this.engine.load();
}
}else{
this.$Notice.warning({ title: '警告', desc: '当前数据已经是最后一条数据' });
}
}else{
this.$Notice.warning({ title: '警告', desc: '请确认操作路径是否正确' });
}
}
/**
* 最后一个记录
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public LastRecord(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
let _this:any = this;
let navDataService:any = new NavDataService(this.$store);
let allNavData:any = Object.is(this.navModel,"route")?navDataService.getPreNavDataById('meta-dynamic-model-dyna-inst-edit-view'):navDataService.getPreNavDataByTag(_this.viewtag);
if(allNavData && allNavData.data && allNavData.data.length >0){
if(_this.parseViewParam && _this.engine){
_this.parseViewParam(allNavData.data[allNavData.data.length - 1].srfkey);
_this.engine.load();
}
}else{
this.$Notice.warning({ title: '警告', desc: '请确认操作路径是否正确' });
}
}
/**
* 帮助
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public Help(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
this.$Notice.error({ title: '错误', desc: '帮助未支持' });
}
/**
* 关闭视图
*
* @param {any[]} args
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public closeView(args: any[]): void {
let _view: any = this;
if (_view.viewdata) {
_view.$emit('viewdataschange', Array.isArray(args)?args:[args]);
_view.$emit('close', Array.isArray(args)?args:[args]);
} else if (_view.$tabPageExp) {
_view.$tabPageExp.onClose(_view.$route.fullPath);
}
}
/**
* 销毁视图回调
*
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public destroyed(){
this.afterDestroyed();
}
/**
* 执行destroyed后的逻辑
*
* @memberof MetaDynamicModelDynaInstEditViewBase
*/
public afterDestroyed(){
if(this.viewDefaultUsage){
let localStoreLength = Object.keys(localStorage);
if(localStoreLength.length > 0){
localStoreLength.forEach((item:string) =>{
if(item.startsWith(this.context.srfsessionid)){
localStorage.removeItem(item);
}
})
}
if(Object.is(this.navModel,"tab")){
this.navDataService.removeNavDataByTag(this.viewtag);
}
if (this.serviceStateEvent) {
this.serviceStateEvent.unsubscribe();
}
}
// 销毁计数器定时器
if(this.counterServiceArray && this.counterServiceArray.length >0){
this.counterServiceArray.forEach((item:any) =>{
if(item.destroyCounter && item.destroyCounter instanceof Function){
item.destroyCounter();
}
})
}
if(this.portletStateEvent){
this.portletStateEvent.unsubscribe();
}
}
}
</script>
<style lang='less'>
@import './meta-dynamic-model-dyna-inst-edit-view.less';
</style>
\ No newline at end of file
.view-card {
>.ivu-card-extra {
top: 5px;
right: 0px;
}
}
.meta-dynamic-model-dyna-inst-edit-view{
position: relative;
}
.toolbar-container {
button {
margin: 6px 0px 4px 4px;
.caption {
margin-left: 4px;
}
}
.seperator {
color: #dcdee2;
margin: 0 0px 0 4px;
}
}
// this is less
<script lang='tsx'>
import { Component } from 'vue-property-decorator';
import MetaDynamicModelDynaInstEditViewBase from './meta-dynamic-model-dyna-inst-edit-view-base.vue';
import view_form from '@widgets/meta-dynamic-model/dyna-inst-form/dyna-inst-form.vue';
@Component({
components: {
view_form,
},
beforeRouteEnter: (to: any, from: any, next: any) => {
next((vm: any) => {
if(!Object.is(vm.navModel,"route")){
vm.initNavDataWithTab(vm.viewCacheData);
}
vm.$store.commit('addCurPageViewtag', { fullPath: to.fullPath, viewtag: vm.viewtag });
});
},
})
export default class MetaDynamicModelDynaInstEditView extends MetaDynamicModelDynaInstEditViewBase {
}
</script>
\ No newline at end of file
<template>
<div class='view-container degridview meta-dynamic-model-dyna-inst-grid-view'>
<app-studioaction :viewTitle="$t(model.srfCaption)" viewName="metadynamicmodeldynainstgridview"></app-studioaction>
<card class='view-card ' :dis-hover="true" :bordered="false">
<div slot='title' class="header-container">
<span class='caption-info' :title="$t(model.srfCaption)">{{$t(model.srfCaption)}}</span>
</div>
<div class='view-top-messages'>
</div>
<div class='content-container'>
<div style='margin-bottom: 6px;'>
<i-input v-show="!isExpandSearchForm" v-model="query" search enter-button @on-search="onSearch($event)" class='quick-search-input' style='max-width: 400px;padding-left: 24px' placeholder="配置名称" />
<div class='pull-right'>
<div class='toolbar-container'>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem1_publish.visabled" :disabled="toolBarModels.tbitem1_publish.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem1_publish' }, $event)">
<i class=''></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem1_publish.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem1_publish.tip')}}</div>
</tooltip>
<span class='seperator'>|</span>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem3.visabled" :disabled="toolBarModels.tbitem3.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem3' }, $event)">
<i class='fa fa-file-text-o'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem3.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem3.tip')}}</div>
</tooltip>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem4.visabled" :disabled="toolBarModels.tbitem4.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem4' }, $event)">
<i class='fa fa-edit'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem4.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem4.tip')}}</div>
</tooltip>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem6.visabled" :disabled="toolBarModels.tbitem6.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem6' }, $event)">
<i class='fa fa-copy'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem6.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem6.tip')}}</div>
</tooltip>
<span class='seperator'>|</span>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem8.visabled" :disabled="toolBarModels.tbitem8.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem8' }, $event)">
<i class='fa fa-remove'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem8.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem8.tip')}}</div>
</tooltip>
<span class='seperator'>|</span>
<tooltip :transfer="true" :max-width="600">
<app-export-excel :item="toolBarModels.tbitem13" :caption="$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem13.caption')" @exportexcel="toolbar_click({ tag: 'tbitem13' }, $event)"></app-export-excel>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem13.tip')}}</div>
</tooltip>
<span class='seperator'>|</span>
<dropdown v-show="toolBarModels.tbitem16.visabled" trigger='click'>
<tooltip :transfer="true" :max-width="600">
<i-button class=''>
<i class=''></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem16.caption')}}</span>
<icon type="ios-arrow-down"></icon>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem16.tip')}}</div>
</tooltip>
<dropdown-menu slot='list'>
<dropdown-item>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem21.visabled" :disabled="toolBarModels.tbitem21.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem21' }, $event)">
<i class='fa fa-download'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem21.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem21.tip')}}</div>
</tooltip>
</dropdown-item>
<dropdown-item>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem23.visabled" :disabled="toolBarModels.tbitem23.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem23' }, $event)">
<i class='fa fa-upload'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem23.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem23.tip')}}</div>
</tooltip>
</dropdown-item>
</dropdown-menu>
</dropdown>
<span class='seperator'>|</span>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem19.visabled" :disabled="toolBarModels.tbitem19.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem19' }, $event)">
<i class='fa fa-filter'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem19.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem19.tip')}}</div>
</tooltip>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem18.visabled" :disabled="toolBarModels.tbitem18.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem18' }, $event)">
<i class='fa fa-question'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem18.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.dynainstgridviewtoolbar_toolbar.tbitem18.tip')}}</div>
</tooltip>
</div>
</div>
</div>
<view_searchform
:viewState="viewState"
:viewparams="viewparams"
:context="context"
:showBusyIndicator="true"
v-show="isExpandSearchForm"
loaddraftAction="FilterGetDraft"
loadAction="FilterGet"
name="searchform"
ref='searchform'
@save="searchform_save($event)"
@search="searchform_search($event)"
@load="searchform_load($event)"
@closeview="closeView($event)">
</view_searchform>
<div class='view-body-messages'>
</div>
<view_grid
:viewState="viewState"
:viewparams="viewparams"
:context="context"
:isSingleSelect="isSingleSelect"
:showBusyIndicator="true"
:isOpenEdit="false"
:gridRowActiveMode="gridRowActiveMode"
:isformDruipart="isformDruipart"
@save="onSave"
updateAction=""
removeAction="Remove"
loaddraftAction=""
loadAction=""
createAction=""
fetchAction="FetchDynaInst"
:newdata="newdata"
:opendata="opendata"
name="grid"
ref='grid'
@selectionchange="grid_selectionchange($event)"
@beforeload="grid_beforeload($event)"
@rowdblclick="grid_rowdblclick($event)"
@remove="grid_remove($event)"
@load="grid_load($event)"
@closeview="closeView($event)">
</view_grid>
</div>
<div class='view-bottom-messages'>
</div>
</card>
</div>
</template>
<script lang='tsx'>
import { Vue, Component, Prop, Provide, Emit, Watch,Inject } from 'vue-property-decorator';
import { UIActionTool,Util } from '@/utils';
import NavDataService from '@/service/app/navdata-service';
import { Subject,Subscription } from 'rxjs';
import MetaDynamicModelService from '@/service/meta-dynamic-model/meta-dynamic-model-service';
import MetaDynamicModelAuthService from '@/authservice/meta-dynamic-model/meta-dynamic-model-auth-service';
import GridViewEngine from '@engine/view/grid-view-engine';
import MetaDynamicModelUIService from '@/uiservice/meta-dynamic-model/meta-dynamic-model-ui-service';
import CodeListService from "@/codelist/codelist-service";
@Component({
components: {
},
})
export default class MetaDynamicModelDynaInstGridViewBase extends Vue {
/**
* 实体服务对象
*
* @type {MetaDynamicModelService}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public appEntityService: MetaDynamicModelService = new MetaDynamicModelService;
/**
* 实体UI服务对象
*
* @type MetaDynamicModelUIService
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public appUIService: MetaDynamicModelUIService = new MetaDynamicModelUIService(this.$store);
/**
* 数据变化
*
* @param {*} val
* @returns {*}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
@Emit()
public viewDatasChange(val: any):any {
return val;
}
/**
* 传入视图上下文
*
* @type {string}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
@Prop() public viewdata!: string;
/**
* 传入视图参数
*
* @type {string}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
@Prop() public viewparam!: string;
/**
* 视图默认使用
*
* @type {boolean}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
@Prop({ default: true }) public viewDefaultUsage!: boolean;
/**
* 视图默认使用
*
* @type {string}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
@Inject({from:'navModel',default: 'tab'})
public navModel!:string;
/**
* 视图标识
*
* @type {string}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public viewtag: string = 'cec3236f5a1f742f9b91f313506ccc6c';
/**
* 自定义视图导航上下文集合
*
* @type {*}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public customViewNavContexts:any ={
};
/**
* 自定义视图导航参数集合
*
* @type {*}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public customViewParams:any ={
};
/**
* 视图模型数据
*
* @type {*}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public model: any = {
srfCaption: 'entities.metadynamicmodel.views.dynainstgridview.caption',
srfTitle: 'entities.metadynamicmodel.views.dynainstgridview.title',
srfSubTitle: 'entities.metadynamicmodel.views.dynainstgridview.subtitle',
dataInfo: ''
}
/**
* 视图参数变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
@Watch('viewparam',{immediate: true, deep: true})
onParamData(newVal: any, oldVal: any) {
if(newVal){
this.viewparams = {};
if(typeof newVal == 'string') {
Object.assign(this.viewparams, JSON.parse(this.viewparam));
}else{
this.viewparams = Util.deepCopy(this.viewparam);
}
}
}
/**
* 处理应用上下文变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
@Watch('viewdata')
onViewData(newVal: any, oldVal: any) {
const _this: any = this;
if (!Object.is(newVal, oldVal) && _this.engine) {
this.$nextTick(()=>{
_this.parseViewParam();
_this.engine.load();
});
} else if(!Object.is(newVal, oldVal) && _this.refresh && _this.refresh instanceof Function) {
_this.refresh();
}
}
/**
* 容器模型
*
* @type {*}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public containerModel: any = {
view_toolbar: { name: 'toolbar', type: 'TOOLBAR' },
view_grid: { name: 'grid', type: 'GRID' },
view_searchform: { name: 'searchform', type: 'SEARCHFORM' },
};
/**
* 视图刷新
*
* @param {*} args
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public refresh(args?: any): void {
const refs: any = this.$refs;
if (refs && refs.grid) {
refs.grid.refresh();
}
}
/**
* 计数器刷新
*
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public counterRefresh(){
const _this:any =this;
if(_this.counterServiceArray && _this.counterServiceArray.length >0){
_this.counterServiceArray.forEach((item:any) =>{
if(item.refreshData && item.refreshData instanceof Function){
item.refreshData();
}
})
}
}
/**
* 视图状态订阅对象
*
* @public
* @type {Subject<{action: string, data: any}>}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public viewState: Subject<ViewState> = new Subject();
/**
* 工具栏模型
*
* @type {*}
* @memberof MetaDynamicModelDynaInstGridView
*/
public toolBarModels: any = {
tbitem1_publish: { name: 'tbitem1_publish', actiontarget: 'NONE', caption: '发布模型', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'publish', target: 'SINGLEKEY' } },
tbitem2: { name: 'tbitem2', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
tbitem3: { name: 'tbitem3', actiontarget: 'NONE', caption: '新建', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'New', target: '' } },
tbitem4: { name: 'tbitem4', actiontarget: 'NONE', caption: '编辑', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'Edit', target: 'SINGLEKEY' } },
tbitem6: { name: 'tbitem6', actiontarget: 'NONE', caption: '拷贝', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'Copy', target: 'SINGLEKEY' } },
tbitem7: { name: 'tbitem7', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
tbitem8: { name: 'tbitem8', actiontarget: 'NONE', caption: '删除', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'Remove', target: 'MULTIKEY' } },
tbitem9: { name: 'tbitem9', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
tbitem13: { name: 'tbitem13', actiontarget: 'NONE', caption: '导出', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'ExportExcel', target: '' }, MaxRowCount: 1000 },
tbitem10: { name: 'tbitem10', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
tbitem16: { name: 'tbitem16', caption: '其它', disabled: false, type: 'ITEMS', visabled: true, dataaccaction: '', uiaction: { } },
tbitem21: { name: 'tbitem21', actiontarget: 'NONE', caption: '导出数据模型', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'ExportModel', target: '' } },
tbitem23: { name: 'tbitem23', actiontarget: 'NONE', caption: '数据导入', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'Import', target: '' } },
tbitem17: { name: 'tbitem17', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
tbitem19: { name: 'tbitem19', actiontarget: 'NONE', caption: '过滤', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'ToggleFilter', target: '' } },
tbitem18: { name: 'tbitem18', actiontarget: 'NONE', caption: '帮助', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'Help', target: '' } },
};
/**
* 视图引擎
*
* @public
* @type {Engine}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public engine: GridViewEngine = new GridViewEngine();
/**
* 引擎初始化
*
* @public
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public engineInit(): void {
this.engine.init({
view: this,
opendata: (args: any[],fullargs?:any[],params?: any, $event?: any, xData?: any) => {
this.opendata(args,fullargs, params, $event, xData);
},
newdata: (args: any[],fullargs?:any[],params?: any, $event?: any, xData?: any) => {
this.newdata(args,fullargs, params, $event, xData);
},
grid: this.$refs.grid,
searchform: this.$refs.searchform,
keyPSDEField: 'metadynamicmodel',
majorPSDEField: 'configname',
isLoadDefault: true,
});
}
/**
* 应用导航服务
*
* @type {*}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public navDataService = NavDataService.getInstance(this.$store);
/**
* 导航服务事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public serviceStateEvent: Subscription | undefined;
/**
* 门户部件状态对象
*
* @type {*}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
@Prop() public portletState?: any;
/**
* 门户部件状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public portletStateEvent: Subscription | undefined;
/**
* 应用上下文
*
* @type {*}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public context:any = {};
/**
* 视图参数
*
* @type {*}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public viewparams:any = {};
/**
* 视图缓存数据
*
* @type {*}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public viewCacheData:any;
/**
* 计数器服务对象集合
*
* @type {Array<*>}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public counterServiceArray:Array<any> = [];
/**
* 解析视图参数
*
* @public
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public parseViewParam(inputvalue:any = null): void {
for(let key in this.context){
delete this.context[key];
}
if(this.$store.getters.getAppData() && this.$store.getters.getAppData().context){
Object.assign(this.context,this.$store.getters.getAppData().context);
}
if (!this.viewDefaultUsage && this.viewdata && !Object.is(this.viewdata, '')) {
if(typeof this.viewdata == 'string') {
Object.assign(this.context, JSON.parse(this.viewdata));
}
if(this.context && this.context.srfparentdename){
Object.assign(this.viewparams,{srfparentdename:this.context.srfparentdename});
}
if(this.context && this.context.srfparentkey){
Object.assign(this.viewparams,{srfparentkey:this.context.srfparentkey});
}
this.handleCustomViewData();
return;
}
const path = (this.$route.matched[this.$route.matched.length - 1]).path;
const keys: Array<any> = [];
const curReg = this.$pathToRegExp.pathToRegexp(path, keys);
const matchArray = curReg.exec(this.$route.path);
let tempValue: Object = {};
keys.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item.name, {
enumerable: true,
value: matchArray[index + 1]
});
});
this.$viewTool.formatRouteParams(tempValue,this.$route,this.context,this.viewparams);
if(inputvalue){
Object.assign(this.context,{'metadynamicmodel':inputvalue});
}
//初始化视图唯一标识
Object.assign(this.context,{srfsessionid:this.$util.createUUID()});
this.handleCustomViewData();
//初始化导航数据
this.initNavDataWithRoute();
}
/**
* 处理自定义视图数据
*
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public handleCustomViewData(){
if(Object.keys(this.customViewNavContexts).length > 0){
Object.keys(this.customViewNavContexts).forEach((item:any) =>{
let tempContext:any = {};
let curNavContext:any = this.customViewNavContexts[item];
this.handleCustomDataLogic(curNavContext,tempContext,item);
Object.assign(this.context,tempContext);
})
}
if(Object.keys(this.customViewParams).length > 0){
Object.keys(this.customViewParams).forEach((item:any) =>{
let tempParam:any = {};
let curNavParam:any = this.customViewParams[item];
this.handleCustomDataLogic(curNavParam,tempParam,item);
Object.assign(this.viewparams,tempParam);
})
}
}
/**
* 处理自定义视图数据逻辑
*
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public handleCustomDataLogic(curNavData:any,tempData:any,item:string){
// 直接值直接赋值
if(curNavData.isRawValue){
if(Object.is(curNavData.value,"null") || Object.is(curNavData.value,"")){
Object.defineProperty(tempData, item.toLowerCase(), {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item.toLowerCase(), {
value: curNavData.value,
writable : true,
enumerable : true,
configurable : true
});
}
}else{
// 先从导航上下文取数,没有再从导航参数(URL)取数,如果导航上下文和导航参数都没有则为null
if(this.context[(curNavData.value).toLowerCase()] != null){
Object.defineProperty(tempData, item.toLowerCase(), {
value: this.context[(curNavData.value).toLowerCase()],
writable : true,
enumerable : true,
configurable : true
});
}else{
if(this.viewparams[(curNavData.value).toLowerCase()] != null){
Object.defineProperty(tempData, item.toLowerCase(), {
value: this.viewparams[(curNavData.value).toLowerCase()],
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item.toLowerCase(), {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}
}
}
}
/**
* 初始化导航数据(路由模式)
*
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public initNavDataWithRoute(data:any = null, isNew:boolean = false, isAlways:boolean = false){
if( isAlways || (this.viewDefaultUsage && Object.is(this.navModel,"route")) ){
this.navDataService.addNavData({id:'meta-dynamic-model-dyna-inst-grid-view',tag:this.viewtag,srfkey:isNew ? null : this.context.metadynamicmodel,title:this.$t(this.model.srfCaption),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath});
}
}
/**
* 初始化导航数据(分页模式)
*
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true, isAlways:boolean = false){
if( isAlways || (this.viewDefaultUsage && !Object.is(this.navModel,"route")) ){
this.navDataService.addNavDataByOnly({id:'meta-dynamic-model-dyna-inst-grid-view',tag:this.viewtag,srfkey:this.context.metadynamicmodel,title:this.$t(this.model.srfCaption),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath},isOnlyAdd);
}
}
/**
* Vue声明周期
*
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public created() {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public afterCreated(){
let _this:any = this;
const secondtag = _this.$util.createUUID();
_this.$store.commit('viewaction/createdView', { viewtag: _this.viewtag, secondtag: secondtag });
_this.viewtag = secondtag;
_this.parseViewParam();
_this.serviceStateEvent = _this.navDataService.serviceState.subscribe(({ action,name, data }:{ action:string,name:any,data:any }) => {
if(!Object.is(name,'meta-dynamic-model-dyna-inst-grid-view')){
return;
}
if (Object.is(action, 'viewrefresh')) {
_this.$nextTick(()=>{
_this.parseViewParam(data);
if(_this.engine){
_this.engine.load();
}
});
}
});
if(_this.portletState){
_this.portletStateEvent = _this.portletState.subscribe((res:any) =>{
if(!Object.is(res.name,'MetaDynamicModelDynaInstGridView')){
return;
}
if(Object.is(res.action,'refresh') && _this.refresh && _this.refresh instanceof Function){
_this.refresh();
}
})
}
if(this.formDruipart){
this.formDruipart.subscribe((res:any) =>{
if(Object.is(res.action,'save')){
this.viewState.next({ tag:'grid', action: 'save', data: this.viewparams });
}
if(Object.is(res.action,'load')){
const _this: any = this;
_this.engine.load(res.data,true);
}
});
}
}
/**
* 销毁之前
*
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public beforeDestroy() {
this.$store.commit('viewaction/removeView', this.viewtag);
}
/**
* Vue声明周期(组件初始化完毕)
*
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public mounted() {
this.afterMounted();
}
/**
* 执行mounted后的逻辑
*
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public afterMounted(){
const _this: any = this;
_this.engineInit();
if (_this.loadModel && _this.loadModel instanceof Function) {
_this.loadModel();
}
}
/**
* toolbar 部件 click 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public toolbar_click($event: any, $event2?: any) {
if (Object.is($event.tag, 'tbitem1_publish')) {
this.toolbar_tbitem1_publish_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem3')) {
this.toolbar_tbitem3_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem4')) {
this.toolbar_tbitem4_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem5')) {
this.toolbar_tbitem5_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem6')) {
this.toolbar_tbitem6_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem24')) {
this.toolbar_tbitem24_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem25')) {
this.toolbar_tbitem25_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem8')) {
this.toolbar_tbitem8_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem13')) {
this.toolbar_tbitem13_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem11')) {
this.toolbar_tbitem11_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem21')) {
this.toolbar_tbitem21_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem23')) {
this.toolbar_tbitem23_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem19')) {
this.toolbar_tbitem19_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem18')) {
this.toolbar_tbitem18_click(null, '', $event2);
}
}
/**
* grid 部件 selectionchange 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public grid_selectionchange($event: any, $event2?: any) {
this.engine.onCtrlEvent('grid', 'selectionchange', $event);
}
/**
* grid 部件 beforeload 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public grid_beforeload($event: any, $event2?: any) {
this.engine.onCtrlEvent('grid', 'beforeload', $event);
}
/**
* grid 部件 rowdblclick 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public grid_rowdblclick($event: any, $event2?: any) {
this.engine.onCtrlEvent('grid', 'rowdblclick', $event);
}
/**
* grid 部件 remove 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public grid_remove($event: any, $event2?: any) {
this.engine.onCtrlEvent('grid', 'remove', $event);
}
/**
* grid 部件 load 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public grid_load($event: any, $event2?: any) {
this.engine.onCtrlEvent('grid', 'load', $event);
}
/**
* searchform 部件 save 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public searchform_save($event: any, $event2?: any) {
this.engine.onCtrlEvent('searchform', 'save', $event);
}
/**
* searchform 部件 search 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public searchform_search($event: any, $event2?: any) {
this.engine.onCtrlEvent('searchform', 'search', $event);
}
/**
* searchform 部件 load 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public searchform_load($event: any, $event2?: any) {
this.engine.onCtrlEvent('searchform', 'load', $event);
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem1_publish_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
const curUIService:MetaDynamicModelUIService = new MetaDynamicModelUIService();
curUIService.MetaDynamicModel_publish(datas,contextJO, paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem3_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.New(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem4_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Edit(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem5_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.View(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem6_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Copy(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem24_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.ToggleRowEdit(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem25_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.NewRow(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem8_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Remove(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem13_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.ExportExcel(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem11_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Print(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem21_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.ExportModel(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem23_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Import(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem19_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.ToggleFilter(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem18_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Help(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 打开新建数据视图
*
* @param {any[]} args
* @param {*} [params]
* @param {*} [fullargs]
* @param {*} [$event]
* @param {*} [xData]
* @memberof MetaDynamicModelDynaInstGridView
*/
public newdata(args: any[],fullargs?:any[], params?: any, $event?: any, xData?: any) {
let localContext:any = null;
let localViewParam:any =null;
const data: any = {};
if(args[0].srfsourcekey){
data.srfsourcekey = args[0].srfsourcekey;
}
let tempContext = JSON.parse(JSON.stringify(this.context));
delete tempContext.metadynamicmodel;
if(args.length >0){
Object.assign(tempContext,args[0]);
}
const deResParameters: any[] = [];
const parameters: any[] = [
{ pathName: 'metadynamicmodels', parameterName: 'metadynamicmodel' },
{ pathName: 'dynainsteditview', parameterName: 'dynainsteditview' },
];
const _this: any = this;
const openIndexViewTab = (data: any) => {
const _data: any = { w: (new Date().getTime()) };
Object.assign(_data, data);
const routePath = this.$viewTool.buildUpRoutePath(this.$route, tempContext, deResParameters, parameters, args, _data);
this.$router.push(routePath);
}
openIndexViewTab(data);
}
/**
* 打开编辑数据视图
*
* @param {any[]} args
* @param {*} [params]
* @param {*} [fullargs]
* @param {*} [$event]
* @param {*} [xData]
* @memberof MetaDynamicModelDynaInstGridView
*/
public opendata(args: any[],fullargs?:any,params?: any, $event?: any, xData?: any) {
if(!this.viewDefaultUsage){
if(Object.is(this.navModel,"route")){
this.initNavDataWithRoute(this.viewCacheData, false, true);
}else{
this.initNavDataWithTab(this.viewCacheData, false, true);
}
}
let localContext:any = null;
let localViewParam:any =null;
const data: any = {};
let tempContext = JSON.parse(JSON.stringify(this.context));
if(args.length >0){
Object.assign(tempContext,args[0]);
}
const deResParameters: any[] = [];
const parameters: any[] = [
{ pathName: 'metadynamicmodels', parameterName: 'metadynamicmodel' },
{ pathName: 'dynainsteditview', parameterName: 'dynainsteditview' },
];
const _this: any = this;
if(fullargs && fullargs.copymode){
Object.assign(data,{copymode:true});
}
const openIndexViewTab = (data: any) => {
const routePath = this.$viewTool.buildUpRoutePath(this.$route, tempContext, deResParameters, parameters, args, data);
this.$router.push(routePath);
}
openIndexViewTab(data);
}
/**
* 新建
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public New(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (_this.newdata && _this.newdata instanceof Function) {
const data: any = {};
_this.newdata([{ ...data }],[{ ...data }], params, $event, xData);
} else {
_this.$Notice.error({ title: '错误', desc: 'newdata 视图处理逻辑不存在,请添加!' });
}
}
/**
* 编辑
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public Edit(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
if (args.length === 0) {
return;
}
const _this: any = this;
if (_this.opendata && _this.opendata instanceof Function) {
const data: any = { };
if (args.length > 0) {
Object.assign(data, { metadynamicmodel: args[0].metadynamicmodel })
}
_this.opendata([{ ...data }], args, params, $event, xData);
} else {
_this.$Notice.error({ title: '错误', desc: 'opendata 视图处理逻辑不存在,请添加!' });
}
}
/**
* 查看
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public View(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
if (args.length === 0) {
return;
}
const _this: any = this;
if (_this.opendata && _this.opendata instanceof Function) {
const data: any = { };
if (args.length > 0) {
Object.assign(data, { metadynamicmodel: args[0].metadynamicmodel })
}
_this.opendata([{ ...data }], args, params, $event, xData);
} else {
_this.$Notice.error({ title: '错误', desc: 'opendata 视图处理逻辑不存在,请添加!' });
}
}
/**
* 拷贝
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public Copy(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
if (args.length === 0) {
return;
}
const _this: any = this;
if (_this.opendata && _this.opendata instanceof Function) {
const data: any = { };
if (args.length > 0) {
Object.assign(data, { metadynamicmodel: args[0].metadynamicmodel });
}
if(!params) params = {};
Object.assign(args,{copymode:true});
_this.opendata([{ ...data }], args, params, $event, xData);
} else {
Object.assign(this.viewparams,{copymode:true});
}
}
/**
* 行编辑
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public ToggleRowEdit(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
xData.actualIsOpenEdit = !xData.actualIsOpenEdit;
}
/**
* 新建行
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public NewRow(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
const data: any = {};
if (_this.hasOwnProperty('newRow') && _this.newRow instanceof Function) {
_this.newRow([{ ...data }], params, $event, xData);
} else if(xData.newRow && xData.newRow instanceof Function) {
xData.newRow([{ ...data }], params, $event, xData);
}else{
_this.$Notice.error({ title: '错误', desc: 'newRow 视图处理逻辑不存在,请添加!' });
}
}
/**
* 删除
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public Remove(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (!xData || !(xData.remove instanceof Function)) {
return ;
}
xData.remove(args);
}
/**
* 导出
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public ExportExcel(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (!xData || !(xData.exportExcel instanceof Function) || !$event) {
return ;
}
xData.exportExcel($event.exportparms);
}
/**
* 打印
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public Print(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
let _this:any = this;
if (!xData || !(xData.print instanceof Function) || !$event) {
return ;
}
xData.print();
}
/**
* 导出数据模型
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public ExportModel(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
this.$Notice.error({ title: '错误', desc: '导出数据模型未支持' });
}
/**
* 数据导入
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public Import(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (!xData || !(xData.importExcel instanceof Function) || !$event) {
return ;
}
xData.importExcel(params);
}
/**
* 过滤
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public ToggleFilter(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (_this.hasOwnProperty('isExpandSearchForm')) {
_this.isExpandSearchForm = !_this.isExpandSearchForm;
}
}
/**
* 帮助
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public Help(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
this.$Notice.error({ title: '错误', desc: '帮助未支持' });
}
/**
* 关闭视图
*
* @param {any[]} args
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public closeView(args: any[]): void {
let _view: any = this;
if (_view.viewdata) {
_view.$emit('viewdataschange', Array.isArray(args)?args:[args]);
_view.$emit('close', Array.isArray(args)?args:[args]);
} else if (_view.$tabPageExp) {
_view.$tabPageExp.onClose(_view.$route.fullPath);
}
}
/**
* 销毁视图回调
*
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public destroyed(){
this.afterDestroyed();
}
/**
* 执行destroyed后的逻辑
*
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public afterDestroyed(){
if(this.viewDefaultUsage){
let localStoreLength = Object.keys(localStorage);
if(localStoreLength.length > 0){
localStoreLength.forEach((item:string) =>{
if(item.startsWith(this.context.srfsessionid)){
localStorage.removeItem(item);
}
})
}
if(Object.is(this.navModel,"tab")){
this.navDataService.removeNavDataByTag(this.viewtag);
}
if (this.serviceStateEvent) {
this.serviceStateEvent.unsubscribe();
}
}
// 销毁计数器定时器
if(this.counterServiceArray && this.counterServiceArray.length >0){
this.counterServiceArray.forEach((item:any) =>{
if(item.destroyCounter && item.destroyCounter instanceof Function){
item.destroyCounter();
}
})
}
if(this.portletStateEvent){
this.portletStateEvent.unsubscribe();
}
}
/**
* 是否单选
*
* @type {boolean}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public isSingleSelect: boolean = false;
/**
* 是否嵌入关系界面
*
* @type {boolean}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
@Prop({default:false}) public isformDruipart?: boolean;
/**
* 界面关系通讯对象
*
* @type {Subject<ViewState>}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
@Prop() public formDruipart?: Subject<ViewState>;
/**
* 搜索值
*
* @type {string}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public query: string = '';
/**
* 是否展开搜索表单
*
* @type {boolean}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public isExpandSearchForm: boolean = false;
/**
* 表格行数据默认激活模式
* 0 不激活
* 1 单击激活
* 2 双击激活
*
* @type {(number | 0 | 1 | 2)}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public gridRowActiveMode: number | 0 | 1 | 2 = 2;
/**
* 快速搜索
*
* @param {*} $event
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
public onSearch($event: any): void {
const grid: any = this.$refs.grid;
if (grid) {
grid.load(this.context, true);
}
}
/**
* grid 部件 save 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof ENTITYTEST1Usr2GridViewBase
*/
public onSave($event: any) {
this.$emit('drdatasaved', $event);
}
/**
* 刷新数据
*
* @readonly
* @type {(number | null)}
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
get refreshdata(): number | null {
return this.$store.getters['viewaction/getRefreshData'](this.viewtag);
}
/**
* 监控数据变化
*
* @param {*} newVal
* @param {*} oldVal
* @returns
* @memberof MetaDynamicModelDynaInstGridViewBase
*/
@Watch('refreshdata')
onRefreshData(newVal: any, oldVal: any) {
if (newVal === null || newVal === undefined) {
return;
}
if (newVal === 0) {
return;
}
const grid: any = this.$refs.grid;
if (grid) {
grid.load({});
}
}
}
</script>
<style lang='less'>
@import './meta-dynamic-model-dyna-inst-grid-view.less';
</style>
\ No newline at end of file
.meta-dynamic-model-dyna-inst-grid-view{
position: relative;
}
.toolbar-container {
button {
margin: 6px 0px 4px 4px;
.caption {
margin-left: 4px;
}
}
.seperator {
color: #dcdee2;
margin: 0 0px 0 4px;
}
}
// this is less
<script lang='tsx'>
import { Component } from 'vue-property-decorator';
import MetaDynamicModelDynaInstGridViewBase from './meta-dynamic-model-dyna-inst-grid-view-base.vue';
import view_grid from '@widgets/meta-dynamic-model/main-grid/main-grid.vue';
import view_searchform from '@widgets/meta-dynamic-model/default-searchform/default-searchform.vue';
@Component({
components: {
view_grid,
view_searchform,
},
beforeRouteEnter: (to: any, from: any, next: any) => {
next((vm: any) => {
if(!Object.is(vm.navModel,"route")){
vm.initNavDataWithTab(vm.viewCacheData);
}
vm.$store.commit('addCurPageViewtag', { fullPath: to.fullPath, viewtag: vm.viewtag });
});
},
})
export default class MetaDynamicModelDynaInstGridView extends MetaDynamicModelDynaInstGridViewBase {
}
</script>
\ No newline at end of file
<template>
<div class="view-container deeditview meta-dynamic-model-edit-view">
<app-studioaction :viewTitle="$t(model.srfCaption)" viewName="metadynamicmodeleditview"></app-studioaction>
<card class='view-card ' :disHover="true" :bordered="false">
<div slot='title' class="header-container">
<span class='caption-info'>{{$t(model.srfCaption)}}</span>
<div class='toolbar-container'>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem1.visabled" :disabled="toolBarModels.tbitem1.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem1' }, $event)">
<i class='sx-tb-saveandclose'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.editviewtoolbar_toolbar.tbitem1.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.editviewtoolbar_toolbar.tbitem1.tip')}}</div>
</tooltip>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem2.visabled" :disabled="toolBarModels.tbitem2.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem2' }, $event)">
<i class='fa fa-sign-out'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.editviewtoolbar_toolbar.tbitem2.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.editviewtoolbar_toolbar.tbitem2.tip')}}</div>
</tooltip>
</div>
</div>
<div class='view-top-messages'>
</div>
<div class="content-container">
<div class='view-body-messages'>
</div>
<view_form
:viewState="viewState"
:viewparams="viewparams"
:context="context"
:autosave="false"
:viewtag="viewtag"
:showBusyIndicator="true"
updateAction="Update"
removeAction="Remove"
loaddraftAction="GetDraft"
loadAction="Get"
createAction="Create"
WFSubmitAction=""
WFStartAction=""
style=''
name="form"
ref='form'
@save="form_save($event)"
@remove="form_remove($event)"
@load="form_load($event)"
@closeview="closeView($event)">
</view_form>
</div>
<div class='view-bottom-messages'>
</div>
</card>
</div>
</template>
<script lang='tsx'>
import { Vue, Component, Prop, Provide, Emit, Watch,Inject } from 'vue-property-decorator';
import { UIActionTool,Util } from '@/utils';
import NavDataService from '@/service/app/navdata-service';
import { Subject,Subscription } from 'rxjs';
import MetaDynamicModelService from '@/service/meta-dynamic-model/meta-dynamic-model-service';
import MetaDynamicModelAuthService from '@/authservice/meta-dynamic-model/meta-dynamic-model-auth-service';
import EditViewEngine from '@engine/view/edit-view-engine';
import MetaDynamicModelUIService from '@/uiservice/meta-dynamic-model/meta-dynamic-model-ui-service';
@Component({
components: {
},
})
export default class MetaDynamicModelEditViewBase extends Vue {
/**
* 实体服务对象
*
* @type {MetaDynamicModelService}
* @memberof MetaDynamicModelEditViewBase
*/
public appEntityService: MetaDynamicModelService = new MetaDynamicModelService;
/**
* 实体UI服务对象
*
* @type MetaDynamicModelUIService
* @memberof MetaDynamicModelEditViewBase
*/
public appUIService: MetaDynamicModelUIService = new MetaDynamicModelUIService(this.$store);
/**
* 数据变化
*
* @param {*} val
* @returns {*}
* @memberof MetaDynamicModelEditViewBase
*/
@Emit()
public viewDatasChange(val: any):any {
return val;
}
/**
* 传入视图上下文
*
* @type {string}
* @memberof MetaDynamicModelEditViewBase
*/
@Prop() public viewdata!: string;
/**
* 传入视图参数
*
* @type {string}
* @memberof MetaDynamicModelEditViewBase
*/
@Prop() public viewparam!: string;
/**
* 视图默认使用
*
* @type {boolean}
* @memberof MetaDynamicModelEditViewBase
*/
@Prop({ default: true }) public viewDefaultUsage!: boolean;
/**
* 视图默认使用
*
* @type {string}
* @memberof MetaDynamicModelEditViewBase
*/
@Inject({from:'navModel',default: 'tab'})
public navModel!:string;
/**
* 视图标识
*
* @type {string}
* @memberof MetaDynamicModelEditViewBase
*/
public viewtag: string = 'e8892afaebe9a899e5d528d5b55d3cc5';
/**
* 自定义视图导航上下文集合
*
* @type {*}
* @memberof MetaDynamicModelEditViewBase
*/
public customViewNavContexts:any ={
};
/**
* 自定义视图导航参数集合
*
* @type {*}
* @memberof MetaDynamicModelEditViewBase
*/
public customViewParams:any ={
"pdynainstid":{"isRawValue":false,"value":"metadynamicmodel"}
};
/**
* 视图模型数据
*
* @type {*}
* @memberof MetaDynamicModelEditViewBase
*/
public model: any = {
srfCaption: 'entities.metadynamicmodel.views.editview.caption',
srfTitle: 'entities.metadynamicmodel.views.editview.title',
srfSubTitle: 'entities.metadynamicmodel.views.editview.subtitle',
dataInfo: ''
}
/**
* 视图参数变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MetaDynamicModelEditViewBase
*/
@Watch('viewparam',{immediate: true, deep: true})
onParamData(newVal: any, oldVal: any) {
if(newVal){
this.viewparams = {};
if(typeof newVal == 'string') {
Object.assign(this.viewparams, JSON.parse(this.viewparam));
}else{
this.viewparams = Util.deepCopy(this.viewparam);
}
}
}
/**
* 处理应用上下文变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MetaDynamicModelEditViewBase
*/
@Watch('viewdata')
onViewData(newVal: any, oldVal: any) {
const _this: any = this;
if (!Object.is(newVal, oldVal) && _this.engine) {
this.$nextTick(()=>{
_this.parseViewParam();
_this.engine.load();
});
} else if(!Object.is(newVal, oldVal) && _this.refresh && _this.refresh instanceof Function) {
_this.refresh();
}
}
/**
* 容器模型
*
* @type {*}
* @memberof MetaDynamicModelEditViewBase
*/
public containerModel: any = {
view_toolbar: { name: 'toolbar', type: 'TOOLBAR' },
view_form: { name: 'form', type: 'FORM' },
};
/**
* 视图刷新
*
* @param {*} args
* @memberof MetaDynamicModelEditViewBase
*/
public refresh(args?: any): void {
const refs: any = this.$refs;
if (refs && refs.form) {
refs.form.refresh();
}
}
/**
* 计数器刷新
*
* @memberof MetaDynamicModelEditViewBase
*/
public counterRefresh(){
const _this:any =this;
if(_this.counterServiceArray && _this.counterServiceArray.length >0){
_this.counterServiceArray.forEach((item:any) =>{
if(item.refreshData && item.refreshData instanceof Function){
item.refreshData();
}
})
}
}
/**
* 视图状态订阅对象
*
* @public
* @type {Subject<{action: string, data: any}>}
* @memberof MetaDynamicModelEditViewBase
*/
public viewState: Subject<ViewState> = new Subject();
/**
* 工具栏模型
*
* @type {*}
* @memberof MetaDynamicModelEditView
*/
public toolBarModels: any = {
tbitem1: { name: 'tbitem1', actiontarget: 'NONE', caption: '保存并关闭', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'SaveAndExit', target: '' } },
tbitem2: { name: 'tbitem2', actiontarget: 'NONE', caption: '关闭', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'Exit', target: '' } },
};
/**
* 视图引擎
*
* @public
* @type {Engine}
* @memberof MetaDynamicModelEditViewBase
*/
public engine: EditViewEngine = new EditViewEngine();
/**
* 引擎初始化
*
* @public
* @memberof MetaDynamicModelEditViewBase
*/
public engineInit(): void {
this.engine.init({
view: this,
form: this.$refs.form,
p2k: '0',
keyPSDEField: 'metadynamicmodel',
majorPSDEField: 'configname',
isLoadDefault: true,
});
}
/**
* 应用导航服务
*
* @type {*}
* @memberof MetaDynamicModelEditViewBase
*/
public navDataService = NavDataService.getInstance(this.$store);
/**
* 导航服务事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof MetaDynamicModelEditViewBase
*/
public serviceStateEvent: Subscription | undefined;
/**
* 门户部件状态对象
*
* @type {*}
* @memberof MetaDynamicModelEditViewBase
*/
@Prop() public portletState?: any;
/**
* 门户部件状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof MetaDynamicModelEditViewBase
*/
public portletStateEvent: Subscription | undefined;
/**
* 应用上下文
*
* @type {*}
* @memberof MetaDynamicModelEditViewBase
*/
public context:any = {};
/**
* 视图参数
*
* @type {*}
* @memberof MetaDynamicModelEditViewBase
*/
public viewparams:any = {};
/**
* 视图缓存数据
*
* @type {*}
* @memberof MetaDynamicModelEditViewBase
*/
public viewCacheData:any;
/**
* 计数器服务对象集合
*
* @type {Array<*>}
* @memberof MetaDynamicModelEditViewBase
*/
public counterServiceArray:Array<any> = [];
/**
* 解析视图参数
*
* @public
* @memberof MetaDynamicModelEditViewBase
*/
public parseViewParam(inputvalue:any = null): void {
for(let key in this.context){
delete this.context[key];
}
if(this.$store.getters.getAppData() && this.$store.getters.getAppData().context){
Object.assign(this.context,this.$store.getters.getAppData().context);
}
if (!this.viewDefaultUsage && this.viewdata && !Object.is(this.viewdata, '')) {
if(typeof this.viewdata == 'string') {
Object.assign(this.context, JSON.parse(this.viewdata));
}
if(this.context && this.context.srfparentdename){
Object.assign(this.viewparams,{srfparentdename:this.context.srfparentdename});
}
if(this.context && this.context.srfparentkey){
Object.assign(this.viewparams,{srfparentkey:this.context.srfparentkey});
}
this.handleCustomViewData();
return;
}
const path = (this.$route.matched[this.$route.matched.length - 1]).path;
const keys: Array<any> = [];
const curReg = this.$pathToRegExp.pathToRegexp(path, keys);
const matchArray = curReg.exec(this.$route.path);
let tempValue: Object = {};
keys.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item.name, {
enumerable: true,
value: matchArray[index + 1]
});
});
this.$viewTool.formatRouteParams(tempValue,this.$route,this.context,this.viewparams);
if(inputvalue){
Object.assign(this.context,{'metadynamicmodel':inputvalue});
}
//初始化视图唯一标识
Object.assign(this.context,{srfsessionid:this.$util.createUUID()});
this.handleCustomViewData();
//初始化导航数据
this.initNavDataWithRoute();
}
/**
* 处理自定义视图数据
*
* @memberof MetaDynamicModelEditViewBase
*/
public handleCustomViewData(){
if(Object.keys(this.customViewNavContexts).length > 0){
Object.keys(this.customViewNavContexts).forEach((item:any) =>{
let tempContext:any = {};
let curNavContext:any = this.customViewNavContexts[item];
this.handleCustomDataLogic(curNavContext,tempContext,item);
Object.assign(this.context,tempContext);
})
}
if(Object.keys(this.customViewParams).length > 0){
Object.keys(this.customViewParams).forEach((item:any) =>{
let tempParam:any = {};
let curNavParam:any = this.customViewParams[item];
this.handleCustomDataLogic(curNavParam,tempParam,item);
Object.assign(this.viewparams,tempParam);
})
}
}
/**
* 处理自定义视图数据逻辑
*
* @memberof MetaDynamicModelEditViewBase
*/
public handleCustomDataLogic(curNavData:any,tempData:any,item:string){
// 直接值直接赋值
if(curNavData.isRawValue){
if(Object.is(curNavData.value,"null") || Object.is(curNavData.value,"")){
Object.defineProperty(tempData, item.toLowerCase(), {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item.toLowerCase(), {
value: curNavData.value,
writable : true,
enumerable : true,
configurable : true
});
}
}else{
// 先从导航上下文取数,没有再从导航参数(URL)取数,如果导航上下文和导航参数都没有则为null
if(this.context[(curNavData.value).toLowerCase()] != null){
Object.defineProperty(tempData, item.toLowerCase(), {
value: this.context[(curNavData.value).toLowerCase()],
writable : true,
enumerable : true,
configurable : true
});
}else{
if(this.viewparams[(curNavData.value).toLowerCase()] != null){
Object.defineProperty(tempData, item.toLowerCase(), {
value: this.viewparams[(curNavData.value).toLowerCase()],
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item.toLowerCase(), {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}
}
}
}
/**
* 初始化导航数据(路由模式)
*
* @memberof MetaDynamicModelEditViewBase
*/
public initNavDataWithRoute(data:any = null, isNew:boolean = false, isAlways:boolean = false){
if( isAlways || (this.viewDefaultUsage && Object.is(this.navModel,"route")) ){
this.navDataService.addNavData({id:'meta-dynamic-model-edit-view',tag:this.viewtag,srfkey:isNew ? null : this.context.metadynamicmodel,title:this.$t(this.model.srfCaption),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath});
}
}
/**
* 初始化导航数据(分页模式)
*
* @memberof MetaDynamicModelEditViewBase
*/
public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true, isAlways:boolean = false){
if( isAlways || (this.viewDefaultUsage && !Object.is(this.navModel,"route")) ){
this.navDataService.addNavDataByOnly({id:'meta-dynamic-model-edit-view',tag:this.viewtag,srfkey:this.context.metadynamicmodel,title:this.$t(this.model.srfCaption),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath},isOnlyAdd);
}
}
/**
* Vue声明周期
*
* @memberof MetaDynamicModelEditViewBase
*/
public created() {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
* @memberof MetaDynamicModelEditViewBase
*/
public afterCreated(){
let _this:any = this;
const secondtag = _this.$util.createUUID();
_this.$store.commit('viewaction/createdView', { viewtag: _this.viewtag, secondtag: secondtag });
_this.viewtag = secondtag;
_this.parseViewParam();
_this.serviceStateEvent = _this.navDataService.serviceState.subscribe(({ action,name, data }:{ action:string,name:any,data:any }) => {
if(!Object.is(name,'meta-dynamic-model-edit-view')){
return;
}
if (Object.is(action, 'viewrefresh')) {
_this.$nextTick(()=>{
_this.parseViewParam(data);
if(_this.engine){
_this.engine.load();
}
});
}
});
if(_this.portletState){
_this.portletStateEvent = _this.portletState.subscribe((res:any) =>{
if(!Object.is(res.name,'MetaDynamicModelEditView')){
return;
}
if(Object.is(res.action,'refresh') && _this.refresh && _this.refresh instanceof Function){
_this.refresh();
}
})
}
}
/**
* 销毁之前
*
* @memberof MetaDynamicModelEditViewBase
*/
public beforeDestroy() {
this.$store.commit('viewaction/removeView', this.viewtag);
}
/**
* Vue声明周期(组件初始化完毕)
*
* @memberof MetaDynamicModelEditViewBase
*/
public mounted() {
this.afterMounted();
}
/**
* 执行mounted后的逻辑
*
* @memberof MetaDynamicModelEditViewBase
*/
public afterMounted(){
const _this: any = this;
_this.engineInit();
if (_this.loadModel && _this.loadModel instanceof Function) {
_this.loadModel();
}
}
/**
* toolbar 部件 click 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelEditViewBase
*/
public toolbar_click($event: any, $event2?: any) {
if (Object.is($event.tag, 'tbitem1')) {
this.toolbar_tbitem1_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem2')) {
this.toolbar_tbitem2_click(null, '', $event2);
}
}
/**
* form 部件 save 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelEditViewBase
*/
public form_save($event: any, $event2?: any) {
this.engine.onCtrlEvent('form', 'save', $event);
}
/**
* form 部件 remove 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelEditViewBase
*/
public form_remove($event: any, $event2?: any) {
this.engine.onCtrlEvent('form', 'remove', $event);
}
/**
* form 部件 load 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelEditViewBase
*/
public form_load($event: any, $event2?: any) {
this.engine.onCtrlEvent('form', 'load', $event);
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem1_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.SaveAndExit(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem2_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.form;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Exit(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 保存并关闭
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelEditViewBase
*/
public SaveAndExit(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (xData && xData.saveAndExit instanceof Function) {
xData.saveAndExit().then((response: any) => {
if (!response || response.status !== 200) {
return;
}
if(window.parent){
window.parent.postMessage([{ ...response.data }],'*');
}
});
} else if (_this.saveAndExit && _this.saveAndExit instanceof Function) {
_this.saveAndExit().then((response: any) => {
if (!response || response.status !== 200) {
return;
}
if(window.parent){
window.parent.postMessage([{ ...response.data }],'*');
}
});
}
}
/**
* 关闭
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelEditViewBase
*/
public Exit(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
this.closeView(args);
if(window.parent){
window.parent.postMessage([{ ...args }],'*');
}
}
/**
* 关闭视图
*
* @param {any[]} args
* @memberof MetaDynamicModelEditViewBase
*/
public closeView(args: any[]): void {
let _view: any = this;
if (_view.viewdata) {
_view.$emit('viewdataschange', Array.isArray(args)?args:[args]);
_view.$emit('close', Array.isArray(args)?args:[args]);
} else if (_view.$tabPageExp) {
_view.$tabPageExp.onClose(_view.$route.fullPath);
}
}
/**
* 销毁视图回调
*
* @memberof MetaDynamicModelEditViewBase
*/
public destroyed(){
this.afterDestroyed();
}
/**
* 执行destroyed后的逻辑
*
* @memberof MetaDynamicModelEditViewBase
*/
public afterDestroyed(){
if(this.viewDefaultUsage){
let localStoreLength = Object.keys(localStorage);
if(localStoreLength.length > 0){
localStoreLength.forEach((item:string) =>{
if(item.startsWith(this.context.srfsessionid)){
localStorage.removeItem(item);
}
})
}
if(Object.is(this.navModel,"tab")){
this.navDataService.removeNavDataByTag(this.viewtag);
}
if (this.serviceStateEvent) {
this.serviceStateEvent.unsubscribe();
}
}
// 销毁计数器定时器
if(this.counterServiceArray && this.counterServiceArray.length >0){
this.counterServiceArray.forEach((item:any) =>{
if(item.destroyCounter && item.destroyCounter instanceof Function){
item.destroyCounter();
}
})
}
if(this.portletStateEvent){
this.portletStateEvent.unsubscribe();
}
}
}
</script>
<style lang='less'>
@import './meta-dynamic-model-edit-view.less';
</style>
\ No newline at end of file
.view-card {
>.ivu-card-extra {
top: 5px;
right: 0px;
}
}
.meta-dynamic-model-edit-view{
position: relative;
}
.toolbar-container {
button {
margin: 6px 0px 4px 4px;
.caption {
margin-left: 4px;
}
}
.seperator {
color: #dcdee2;
margin: 0 0px 0 4px;
}
}
// this is less
<script lang='tsx'>
import { Component } from 'vue-property-decorator';
import MetaDynamicModelEditViewBase from './meta-dynamic-model-edit-view-base.vue';
import view_form from '@widgets/meta-dynamic-model/main-form/main-form.vue';
@Component({
components: {
view_form,
},
beforeRouteEnter: (to: any, from: any, next: any) => {
next((vm: any) => {
if(!Object.is(vm.navModel,"route")){
vm.initNavDataWithTab(vm.viewCacheData);
}
vm.$store.commit('addCurPageViewtag', { fullPath: to.fullPath, viewtag: vm.viewtag });
});
},
})
export default class MetaDynamicModelEditView extends MetaDynamicModelEditViewBase {
}
</script>
\ No newline at end of file
<template>
<div class='view-container degridview meta-dynamic-model-grid-view'>
<app-studioaction :viewTitle="$t(model.srfCaption)" viewName="metadynamicmodelgridview"></app-studioaction>
<card class='view-card ' :dis-hover="true" :bordered="false">
<div slot='title' class="header-container">
<span class='caption-info' :title="$t(model.srfCaption)">{{$t(model.srfCaption)}}</span>
</div>
<div class='view-top-messages'>
</div>
<div class='content-container'>
<div style='margin-bottom: 6px;'>
<i-input v-show="!isExpandSearchForm" v-model="query" search enter-button @on-search="onSearch($event)" class='quick-search-input' style='max-width: 400px;padding-left: 24px' placeholder="配置名称" />
<div class='pull-right'>
<div class='toolbar-container'>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem1_publish.visabled" :disabled="toolBarModels.tbitem1_publish.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem1_publish' }, $event)">
<i class=''></i>
<span class='caption'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem1_publish.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem1_publish.tip')}}</div>
</tooltip>
<span class='seperator'>|</span>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem3.visabled" :disabled="toolBarModels.tbitem3.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem3' }, $event)">
<i class='fa fa-file-text-o'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem3.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem3.tip')}}</div>
</tooltip>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem4.visabled" :disabled="toolBarModels.tbitem4.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem4' }, $event)">
<i class='fa fa-edit'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem4.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem4.tip')}}</div>
</tooltip>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem6.visabled" :disabled="toolBarModels.tbitem6.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem6' }, $event)">
<i class='fa fa-copy'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem6.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem6.tip')}}</div>
</tooltip>
<span class='seperator'>|</span>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem8.visabled" :disabled="toolBarModels.tbitem8.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem8' }, $event)">
<i class='fa fa-remove'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem8.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem8.tip')}}</div>
</tooltip>
<span class='seperator'>|</span>
<tooltip :transfer="true" :max-width="600">
<app-export-excel :item="toolBarModels.tbitem13" :caption="$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem13.caption')" @exportexcel="toolbar_click({ tag: 'tbitem13' }, $event)"></app-export-excel>
<div slot='content'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem13.tip')}}</div>
</tooltip>
<span class='seperator'>|</span>
<dropdown v-show="toolBarModels.tbitem16.visabled" trigger='click'>
<tooltip :transfer="true" :max-width="600">
<i-button class=''>
<i class=''></i>
<span class='caption'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem16.caption')}}</span>
<icon type="ios-arrow-down"></icon>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem16.tip')}}</div>
</tooltip>
<dropdown-menu slot='list'>
<dropdown-item>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem21.visabled" :disabled="toolBarModels.tbitem21.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem21' }, $event)">
<i class='fa fa-download'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem21.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem21.tip')}}</div>
</tooltip>
</dropdown-item>
<dropdown-item>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem23.visabled" :disabled="toolBarModels.tbitem23.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem23' }, $event)">
<i class='fa fa-upload'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem23.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem23.tip')}}</div>
</tooltip>
</dropdown-item>
</dropdown-menu>
</dropdown>
<span class='seperator'>|</span>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem19.visabled" :disabled="toolBarModels.tbitem19.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem19' }, $event)">
<i class='fa fa-filter'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem19.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem19.tip')}}</div>
</tooltip>
<tooltip :transfer="true" :max-width="600">
<i-button v-show="toolBarModels.tbitem18.visabled" :disabled="toolBarModels.tbitem18.disabled" class='' v-loading:i-button @click="toolbar_click({ tag: 'tbitem18' }, $event)">
<i class='fa fa-question'></i>
<span class='caption'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem18.caption')}}</span>
</i-button>
<div slot='content'>{{$t('entities.metadynamicmodel.gridviewtoolbar_toolbar.tbitem18.tip')}}</div>
</tooltip>
</div>
</div>
</div>
<view_searchform
:viewState="viewState"
:viewparams="viewparams"
:context="context"
:showBusyIndicator="true"
v-show="isExpandSearchForm"
loaddraftAction="FilterGetDraft"
loadAction="FilterGet"
name="searchform"
ref='searchform'
@save="searchform_save($event)"
@search="searchform_search($event)"
@load="searchform_load($event)"
@closeview="closeView($event)">
</view_searchform>
<div class='view-body-messages'>
</div>
<view_grid
:viewState="viewState"
:viewparams="viewparams"
:context="context"
:isSingleSelect="isSingleSelect"
:showBusyIndicator="true"
:isOpenEdit="false"
:gridRowActiveMode="gridRowActiveMode"
:isformDruipart="isformDruipart"
@save="onSave"
updateAction=""
removeAction="Remove"
loaddraftAction=""
loadAction=""
createAction=""
fetchAction="FetchDefault"
:newdata="newdata"
:opendata="opendata"
name="grid"
ref='grid'
@selectionchange="grid_selectionchange($event)"
@beforeload="grid_beforeload($event)"
@rowdblclick="grid_rowdblclick($event)"
@remove="grid_remove($event)"
@load="grid_load($event)"
@closeview="closeView($event)">
</view_grid>
</div>
<div class='view-bottom-messages'>
</div>
</card>
</div>
</template>
<script lang='tsx'>
import { Vue, Component, Prop, Provide, Emit, Watch,Inject } from 'vue-property-decorator';
import { UIActionTool,Util } from '@/utils';
import NavDataService from '@/service/app/navdata-service';
import { Subject,Subscription } from 'rxjs';
import MetaDynamicModelService from '@/service/meta-dynamic-model/meta-dynamic-model-service';
import MetaDynamicModelAuthService from '@/authservice/meta-dynamic-model/meta-dynamic-model-auth-service';
import GridViewEngine from '@engine/view/grid-view-engine';
import MetaDynamicModelUIService from '@/uiservice/meta-dynamic-model/meta-dynamic-model-ui-service';
import CodeListService from "@/codelist/codelist-service";
@Component({
components: {
},
})
export default class MetaDynamicModelGridViewBase extends Vue {
/**
* 实体服务对象
*
* @type {MetaDynamicModelService}
* @memberof MetaDynamicModelGridViewBase
*/
public appEntityService: MetaDynamicModelService = new MetaDynamicModelService;
/**
* 实体UI服务对象
*
* @type MetaDynamicModelUIService
* @memberof MetaDynamicModelGridViewBase
*/
public appUIService: MetaDynamicModelUIService = new MetaDynamicModelUIService(this.$store);
/**
* 数据变化
*
* @param {*} val
* @returns {*}
* @memberof MetaDynamicModelGridViewBase
*/
@Emit()
public viewDatasChange(val: any):any {
return val;
}
/**
* 传入视图上下文
*
* @type {string}
* @memberof MetaDynamicModelGridViewBase
*/
@Prop() public viewdata!: string;
/**
* 传入视图参数
*
* @type {string}
* @memberof MetaDynamicModelGridViewBase
*/
@Prop() public viewparam!: string;
/**
* 视图默认使用
*
* @type {boolean}
* @memberof MetaDynamicModelGridViewBase
*/
@Prop({ default: true }) public viewDefaultUsage!: boolean;
/**
* 视图默认使用
*
* @type {string}
* @memberof MetaDynamicModelGridViewBase
*/
@Inject({from:'navModel',default: 'tab'})
public navModel!:string;
/**
* 视图标识
*
* @type {string}
* @memberof MetaDynamicModelGridViewBase
*/
public viewtag: string = 'af9cfc34d957186380a012e322abff0c';
/**
* 自定义视图导航上下文集合
*
* @type {*}
* @memberof MetaDynamicModelGridViewBase
*/
public customViewNavContexts:any ={
};
/**
* 自定义视图导航参数集合
*
* @type {*}
* @memberof MetaDynamicModelGridViewBase
*/
public customViewParams:any ={
"n_pdynainstid_eq":{"isRawValue":false,"value":"metadynamicmodel"}
};
/**
* 视图模型数据
*
* @type {*}
* @memberof MetaDynamicModelGridViewBase
*/
public model: any = {
srfCaption: 'entities.metadynamicmodel.views.gridview.caption',
srfTitle: 'entities.metadynamicmodel.views.gridview.title',
srfSubTitle: 'entities.metadynamicmodel.views.gridview.subtitle',
dataInfo: ''
}
/**
* 视图参数变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MetaDynamicModelGridViewBase
*/
@Watch('viewparam',{immediate: true, deep: true})
onParamData(newVal: any, oldVal: any) {
if(newVal){
this.viewparams = {};
if(typeof newVal == 'string') {
Object.assign(this.viewparams, JSON.parse(this.viewparam));
}else{
this.viewparams = Util.deepCopy(this.viewparam);
}
}
}
/**
* 处理应用上下文变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MetaDynamicModelGridViewBase
*/
@Watch('viewdata')
onViewData(newVal: any, oldVal: any) {
const _this: any = this;
if (!Object.is(newVal, oldVal) && _this.engine) {
this.$nextTick(()=>{
_this.parseViewParam();
_this.engine.load();
});
} else if(!Object.is(newVal, oldVal) && _this.refresh && _this.refresh instanceof Function) {
_this.refresh();
}
}
/**
* 容器模型
*
* @type {*}
* @memberof MetaDynamicModelGridViewBase
*/
public containerModel: any = {
view_toolbar: { name: 'toolbar', type: 'TOOLBAR' },
view_grid: { name: 'grid', type: 'GRID' },
view_searchform: { name: 'searchform', type: 'SEARCHFORM' },
};
/**
* 视图刷新
*
* @param {*} args
* @memberof MetaDynamicModelGridViewBase
*/
public refresh(args?: any): void {
const refs: any = this.$refs;
if (refs && refs.grid) {
refs.grid.refresh();
}
}
/**
* 计数器刷新
*
* @memberof MetaDynamicModelGridViewBase
*/
public counterRefresh(){
const _this:any =this;
if(_this.counterServiceArray && _this.counterServiceArray.length >0){
_this.counterServiceArray.forEach((item:any) =>{
if(item.refreshData && item.refreshData instanceof Function){
item.refreshData();
}
})
}
}
/**
* 视图状态订阅对象
*
* @public
* @type {Subject<{action: string, data: any}>}
* @memberof MetaDynamicModelGridViewBase
*/
public viewState: Subject<ViewState> = new Subject();
/**
* 工具栏模型
*
* @type {*}
* @memberof MetaDynamicModelGridView
*/
public toolBarModels: any = {
tbitem1_publish: { name: 'tbitem1_publish', actiontarget: 'NONE', caption: '发布模型', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'publish', target: 'SINGLEKEY' } },
tbitem2: { name: 'tbitem2', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
tbitem3: { name: 'tbitem3', actiontarget: 'NONE', caption: '新建', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'New', target: '' } },
tbitem4: { name: 'tbitem4', actiontarget: 'NONE', caption: '编辑', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'Edit', target: 'SINGLEKEY' } },
tbitem6: { name: 'tbitem6', actiontarget: 'NONE', caption: '拷贝', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'Copy', target: 'SINGLEKEY' } },
tbitem7: { name: 'tbitem7', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
tbitem8: { name: 'tbitem8', actiontarget: 'NONE', caption: '删除', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'Remove', target: 'MULTIKEY' } },
tbitem9: { name: 'tbitem9', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
tbitem13: { name: 'tbitem13', actiontarget: 'NONE', caption: '导出', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'ExportExcel', target: '' }, MaxRowCount: 1000 },
tbitem10: { name: 'tbitem10', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
tbitem16: { name: 'tbitem16', caption: '其它', disabled: false, type: 'ITEMS', visabled: true, dataaccaction: '', uiaction: { } },
tbitem21: { name: 'tbitem21', actiontarget: 'NONE', caption: '导出数据模型', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'ExportModel', target: '' } },
tbitem23: { name: 'tbitem23', actiontarget: 'NONE', caption: '数据导入', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'Import', target: '' } },
tbitem17: { name: 'tbitem17', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
tbitem19: { name: 'tbitem19', actiontarget: 'NONE', caption: '过滤', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'ToggleFilter', target: '' } },
tbitem18: { name: 'tbitem18', actiontarget: 'NONE', caption: '帮助', disabled: false, type: 'DEUIACTION', visabled: true,noprivdisplaymode:2,dataaccaction: '', uiaction: { tag: 'Help', target: '' } },
};
/**
* 视图引擎
*
* @public
* @type {Engine}
* @memberof MetaDynamicModelGridViewBase
*/
public engine: GridViewEngine = new GridViewEngine();
/**
* 引擎初始化
*
* @public
* @memberof MetaDynamicModelGridViewBase
*/
public engineInit(): void {
this.engine.init({
view: this,
opendata: (args: any[],fullargs?:any[],params?: any, $event?: any, xData?: any) => {
this.opendata(args,fullargs, params, $event, xData);
},
newdata: (args: any[],fullargs?:any[],params?: any, $event?: any, xData?: any) => {
this.newdata(args,fullargs, params, $event, xData);
},
grid: this.$refs.grid,
searchform: this.$refs.searchform,
keyPSDEField: 'metadynamicmodel',
majorPSDEField: 'configname',
isLoadDefault: true,
});
}
/**
* 应用导航服务
*
* @type {*}
* @memberof MetaDynamicModelGridViewBase
*/
public navDataService = NavDataService.getInstance(this.$store);
/**
* 导航服务事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof MetaDynamicModelGridViewBase
*/
public serviceStateEvent: Subscription | undefined;
/**
* 门户部件状态对象
*
* @type {*}
* @memberof MetaDynamicModelGridViewBase
*/
@Prop() public portletState?: any;
/**
* 门户部件状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof MetaDynamicModelGridViewBase
*/
public portletStateEvent: Subscription | undefined;
/**
* 应用上下文
*
* @type {*}
* @memberof MetaDynamicModelGridViewBase
*/
public context:any = {};
/**
* 视图参数
*
* @type {*}
* @memberof MetaDynamicModelGridViewBase
*/
public viewparams:any = {};
/**
* 视图缓存数据
*
* @type {*}
* @memberof MetaDynamicModelGridViewBase
*/
public viewCacheData:any;
/**
* 计数器服务对象集合
*
* @type {Array<*>}
* @memberof MetaDynamicModelGridViewBase
*/
public counterServiceArray:Array<any> = [];
/**
* 解析视图参数
*
* @public
* @memberof MetaDynamicModelGridViewBase
*/
public parseViewParam(inputvalue:any = null): void {
for(let key in this.context){
delete this.context[key];
}
if(this.$store.getters.getAppData() && this.$store.getters.getAppData().context){
Object.assign(this.context,this.$store.getters.getAppData().context);
}
if (!this.viewDefaultUsage && this.viewdata && !Object.is(this.viewdata, '')) {
if(typeof this.viewdata == 'string') {
Object.assign(this.context, JSON.parse(this.viewdata));
}
if(this.context && this.context.srfparentdename){
Object.assign(this.viewparams,{srfparentdename:this.context.srfparentdename});
}
if(this.context && this.context.srfparentkey){
Object.assign(this.viewparams,{srfparentkey:this.context.srfparentkey});
}
this.handleCustomViewData();
return;
}
const path = (this.$route.matched[this.$route.matched.length - 1]).path;
const keys: Array<any> = [];
const curReg = this.$pathToRegExp.pathToRegexp(path, keys);
const matchArray = curReg.exec(this.$route.path);
let tempValue: Object = {};
keys.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item.name, {
enumerable: true,
value: matchArray[index + 1]
});
});
this.$viewTool.formatRouteParams(tempValue,this.$route,this.context,this.viewparams);
if(inputvalue){
Object.assign(this.context,{'metadynamicmodel':inputvalue});
}
//初始化视图唯一标识
Object.assign(this.context,{srfsessionid:this.$util.createUUID()});
this.handleCustomViewData();
//初始化导航数据
this.initNavDataWithRoute();
}
/**
* 处理自定义视图数据
*
* @memberof MetaDynamicModelGridViewBase
*/
public handleCustomViewData(){
if(Object.keys(this.customViewNavContexts).length > 0){
Object.keys(this.customViewNavContexts).forEach((item:any) =>{
let tempContext:any = {};
let curNavContext:any = this.customViewNavContexts[item];
this.handleCustomDataLogic(curNavContext,tempContext,item);
Object.assign(this.context,tempContext);
})
}
if(Object.keys(this.customViewParams).length > 0){
Object.keys(this.customViewParams).forEach((item:any) =>{
let tempParam:any = {};
let curNavParam:any = this.customViewParams[item];
this.handleCustomDataLogic(curNavParam,tempParam,item);
Object.assign(this.viewparams,tempParam);
})
}
}
/**
* 处理自定义视图数据逻辑
*
* @memberof MetaDynamicModelGridViewBase
*/
public handleCustomDataLogic(curNavData:any,tempData:any,item:string){
// 直接值直接赋值
if(curNavData.isRawValue){
if(Object.is(curNavData.value,"null") || Object.is(curNavData.value,"")){
Object.defineProperty(tempData, item.toLowerCase(), {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item.toLowerCase(), {
value: curNavData.value,
writable : true,
enumerable : true,
configurable : true
});
}
}else{
// 先从导航上下文取数,没有再从导航参数(URL)取数,如果导航上下文和导航参数都没有则为null
if(this.context[(curNavData.value).toLowerCase()] != null){
Object.defineProperty(tempData, item.toLowerCase(), {
value: this.context[(curNavData.value).toLowerCase()],
writable : true,
enumerable : true,
configurable : true
});
}else{
if(this.viewparams[(curNavData.value).toLowerCase()] != null){
Object.defineProperty(tempData, item.toLowerCase(), {
value: this.viewparams[(curNavData.value).toLowerCase()],
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item.toLowerCase(), {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}
}
}
}
/**
* 初始化导航数据(路由模式)
*
* @memberof MetaDynamicModelGridViewBase
*/
public initNavDataWithRoute(data:any = null, isNew:boolean = false, isAlways:boolean = false){
if( isAlways || (this.viewDefaultUsage && Object.is(this.navModel,"route")) ){
this.navDataService.addNavData({id:'meta-dynamic-model-grid-view',tag:this.viewtag,srfkey:isNew ? null : this.context.metadynamicmodel,title:this.$t(this.model.srfCaption),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath});
}
}
/**
* 初始化导航数据(分页模式)
*
* @memberof MetaDynamicModelGridViewBase
*/
public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true, isAlways:boolean = false){
if( isAlways || (this.viewDefaultUsage && !Object.is(this.navModel,"route")) ){
this.navDataService.addNavDataByOnly({id:'meta-dynamic-model-grid-view',tag:this.viewtag,srfkey:this.context.metadynamicmodel,title:this.$t(this.model.srfCaption),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath},isOnlyAdd);
}
}
/**
* Vue声明周期
*
* @memberof MetaDynamicModelGridViewBase
*/
public created() {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
* @memberof MetaDynamicModelGridViewBase
*/
public afterCreated(){
let _this:any = this;
const secondtag = _this.$util.createUUID();
_this.$store.commit('viewaction/createdView', { viewtag: _this.viewtag, secondtag: secondtag });
_this.viewtag = secondtag;
_this.parseViewParam();
_this.serviceStateEvent = _this.navDataService.serviceState.subscribe(({ action,name, data }:{ action:string,name:any,data:any }) => {
if(!Object.is(name,'meta-dynamic-model-grid-view')){
return;
}
if (Object.is(action, 'viewrefresh')) {
_this.$nextTick(()=>{
_this.parseViewParam(data);
if(_this.engine){
_this.engine.load();
}
});
}
});
if(_this.portletState){
_this.portletStateEvent = _this.portletState.subscribe((res:any) =>{
if(!Object.is(res.name,'MetaDynamicModelGridView')){
return;
}
if(Object.is(res.action,'refresh') && _this.refresh && _this.refresh instanceof Function){
_this.refresh();
}
})
}
if(this.formDruipart){
this.formDruipart.subscribe((res:any) =>{
if(Object.is(res.action,'save')){
this.viewState.next({ tag:'grid', action: 'save', data: this.viewparams });
}
if(Object.is(res.action,'load')){
const _this: any = this;
_this.engine.load(res.data,true);
}
});
}
}
/**
* 销毁之前
*
* @memberof MetaDynamicModelGridViewBase
*/
public beforeDestroy() {
this.$store.commit('viewaction/removeView', this.viewtag);
}
/**
* Vue声明周期(组件初始化完毕)
*
* @memberof MetaDynamicModelGridViewBase
*/
public mounted() {
this.afterMounted();
}
/**
* 执行mounted后的逻辑
*
* @memberof MetaDynamicModelGridViewBase
*/
public afterMounted(){
const _this: any = this;
_this.engineInit();
if (_this.loadModel && _this.loadModel instanceof Function) {
_this.loadModel();
}
}
/**
* toolbar 部件 click 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelGridViewBase
*/
public toolbar_click($event: any, $event2?: any) {
if (Object.is($event.tag, 'tbitem1_publish')) {
this.toolbar_tbitem1_publish_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem3')) {
this.toolbar_tbitem3_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem4')) {
this.toolbar_tbitem4_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem5')) {
this.toolbar_tbitem5_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem6')) {
this.toolbar_tbitem6_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem24')) {
this.toolbar_tbitem24_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem25')) {
this.toolbar_tbitem25_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem8')) {
this.toolbar_tbitem8_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem13')) {
this.toolbar_tbitem13_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem11')) {
this.toolbar_tbitem11_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem21')) {
this.toolbar_tbitem21_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem23')) {
this.toolbar_tbitem23_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem19')) {
this.toolbar_tbitem19_click(null, '', $event2);
}
if (Object.is($event.tag, 'tbitem18')) {
this.toolbar_tbitem18_click(null, '', $event2);
}
}
/**
* grid 部件 selectionchange 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelGridViewBase
*/
public grid_selectionchange($event: any, $event2?: any) {
this.engine.onCtrlEvent('grid', 'selectionchange', $event);
}
/**
* grid 部件 beforeload 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelGridViewBase
*/
public grid_beforeload($event: any, $event2?: any) {
this.engine.onCtrlEvent('grid', 'beforeload', $event);
}
/**
* grid 部件 rowdblclick 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelGridViewBase
*/
public grid_rowdblclick($event: any, $event2?: any) {
this.engine.onCtrlEvent('grid', 'rowdblclick', $event);
}
/**
* grid 部件 remove 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelGridViewBase
*/
public grid_remove($event: any, $event2?: any) {
this.engine.onCtrlEvent('grid', 'remove', $event);
}
/**
* grid 部件 load 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelGridViewBase
*/
public grid_load($event: any, $event2?: any) {
this.engine.onCtrlEvent('grid', 'load', $event);
}
/**
* searchform 部件 save 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelGridViewBase
*/
public searchform_save($event: any, $event2?: any) {
this.engine.onCtrlEvent('searchform', 'save', $event);
}
/**
* searchform 部件 search 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelGridViewBase
*/
public searchform_search($event: any, $event2?: any) {
this.engine.onCtrlEvent('searchform', 'search', $event);
}
/**
* searchform 部件 load 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof MetaDynamicModelGridViewBase
*/
public searchform_load($event: any, $event2?: any) {
this.engine.onCtrlEvent('searchform', 'load', $event);
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem1_publish_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
const curUIService:MetaDynamicModelUIService = new MetaDynamicModelUIService();
curUIService.MetaDynamicModel_publish(datas,contextJO, paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem3_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.New(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem4_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Edit(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem5_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.View(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem6_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Copy(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem24_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.ToggleRowEdit(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem25_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.NewRow(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem8_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Remove(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem13_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.ExportExcel(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem11_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Print(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem21_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.ExportModel(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem23_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Import(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem19_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.ToggleFilter(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 逻辑事件
*
* @param {*} [params={}]
* @param {*} [tag]
* @param {*} [$event]
* @memberof
*/
public toolbar_tbitem18_click(params: any = {}, tag?: any, $event?: any) {
// 参数
// 取数
let datas: any[] = [];
let xData: any = null;
// _this 指向容器对象
const _this: any = this;
let paramJO:any = {};
let contextJO:any = {};
xData = this.$refs.grid;
if (xData.getDatas && xData.getDatas instanceof Function) {
datas = [...xData.getDatas()];
}
if(params){
datas = [params];
}
// 界面行为
this.Help(datas, contextJO,paramJO, $event, xData,this,"MetaDynamicModel");
}
/**
* 打开新建数据视图
*
* @param {any[]} args
* @param {*} [params]
* @param {*} [fullargs]
* @param {*} [$event]
* @param {*} [xData]
* @memberof MetaDynamicModelGridView
*/
public newdata(args: any[],fullargs?:any[], params?: any, $event?: any, xData?: any) {
let localContext:any = null;
let localViewParam:any =null;
const data: any = {};
if(args[0].srfsourcekey){
data.srfsourcekey = args[0].srfsourcekey;
}
let tempContext = JSON.parse(JSON.stringify(this.context));
delete tempContext.metadynamicmodel;
if(args.length >0){
Object.assign(tempContext,args[0]);
}
const deResParameters: any[] = [];
const parameters: any[] = [
{ pathName: 'metadynamicmodels', parameterName: 'metadynamicmodel' },
];
const _this: any = this;
const openPopupModal = (view: any, data: any) => {
let container: Subject<any> = this.$appmodal.openModal(view, tempContext, data);
container.subscribe((result: any) => {
if (!result || !Object.is(result.ret, 'OK')) {
return;
}
if (!xData || !(xData.refresh instanceof Function)) {
return;
}
xData.refresh(result.datas);
});
}
const view: any = {
viewname: 'meta-dynamic-model-edit-view',
height: 0,
width: 0,
title: this.$t('entities.metadynamicmodel.views.editview.title'),
};
openPopupModal(view, data);
}
/**
* 打开编辑数据视图
*
* @param {any[]} args
* @param {*} [params]
* @param {*} [fullargs]
* @param {*} [$event]
* @param {*} [xData]
* @memberof MetaDynamicModelGridView
*/
public opendata(args: any[],fullargs?:any,params?: any, $event?: any, xData?: any) {
if(!this.viewDefaultUsage){
if(Object.is(this.navModel,"route")){
this.initNavDataWithRoute(this.viewCacheData, false, true);
}else{
this.initNavDataWithTab(this.viewCacheData, false, true);
}
}
let localContext:any = null;
let localViewParam:any =null;
const data: any = {};
let tempContext = JSON.parse(JSON.stringify(this.context));
if(args.length >0){
Object.assign(tempContext,args[0]);
}
const deResParameters: any[] = [];
const parameters: any[] = [
{ pathName: 'metadynamicmodels', parameterName: 'metadynamicmodel' },
{ pathName: 'editview', parameterName: 'editview' },
];
const _this: any = this;
if(fullargs && fullargs.copymode){
Object.assign(data,{copymode:true});
}
const openIndexViewTab = (data: any) => {
const routePath = this.$viewTool.buildUpRoutePath(this.$route, tempContext, deResParameters, parameters, args, data);
this.$router.push(routePath);
}
openIndexViewTab(data);
}
/**
* 新建
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelGridViewBase
*/
public New(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (_this.newdata && _this.newdata instanceof Function) {
const data: any = {};
_this.newdata([{ ...data }],[{ ...data }], params, $event, xData);
} else {
_this.$Notice.error({ title: '错误', desc: 'newdata 视图处理逻辑不存在,请添加!' });
}
}
/**
* 编辑
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelGridViewBase
*/
public Edit(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
if (args.length === 0) {
return;
}
const _this: any = this;
if (_this.opendata && _this.opendata instanceof Function) {
const data: any = { };
if (args.length > 0) {
Object.assign(data, { metadynamicmodel: args[0].metadynamicmodel })
}
_this.opendata([{ ...data }], args, params, $event, xData);
} else {
_this.$Notice.error({ title: '错误', desc: 'opendata 视图处理逻辑不存在,请添加!' });
}
}
/**
* 查看
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelGridViewBase
*/
public View(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
if (args.length === 0) {
return;
}
const _this: any = this;
if (_this.opendata && _this.opendata instanceof Function) {
const data: any = { };
if (args.length > 0) {
Object.assign(data, { metadynamicmodel: args[0].metadynamicmodel })
}
_this.opendata([{ ...data }], args, params, $event, xData);
} else {
_this.$Notice.error({ title: '错误', desc: 'opendata 视图处理逻辑不存在,请添加!' });
}
}
/**
* 拷贝
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelGridViewBase
*/
public Copy(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
if (args.length === 0) {
return;
}
const _this: any = this;
if (_this.opendata && _this.opendata instanceof Function) {
const data: any = { };
if (args.length > 0) {
Object.assign(data, { metadynamicmodel: args[0].metadynamicmodel });
}
if(!params) params = {};
Object.assign(args,{copymode:true});
_this.opendata([{ ...data }], args, params, $event, xData);
} else {
Object.assign(this.viewparams,{copymode:true});
}
}
/**
* 行编辑
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelGridViewBase
*/
public ToggleRowEdit(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
xData.actualIsOpenEdit = !xData.actualIsOpenEdit;
}
/**
* 新建行
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelGridViewBase
*/
public NewRow(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
const data: any = {};
if (_this.hasOwnProperty('newRow') && _this.newRow instanceof Function) {
_this.newRow([{ ...data }], params, $event, xData);
} else if(xData.newRow && xData.newRow instanceof Function) {
xData.newRow([{ ...data }], params, $event, xData);
}else{
_this.$Notice.error({ title: '错误', desc: 'newRow 视图处理逻辑不存在,请添加!' });
}
}
/**
* 删除
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelGridViewBase
*/
public Remove(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (!xData || !(xData.remove instanceof Function)) {
return ;
}
xData.remove(args);
}
/**
* 导出
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelGridViewBase
*/
public ExportExcel(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (!xData || !(xData.exportExcel instanceof Function) || !$event) {
return ;
}
xData.exportExcel($event.exportparms);
}
/**
* 打印
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelGridViewBase
*/
public Print(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
let _this:any = this;
if (!xData || !(xData.print instanceof Function) || !$event) {
return ;
}
xData.print();
}
/**
* 导出数据模型
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelGridViewBase
*/
public ExportModel(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
this.$Notice.error({ title: '错误', desc: '导出数据模型未支持' });
}
/**
* 数据导入
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelGridViewBase
*/
public Import(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (!xData || !(xData.importExcel instanceof Function) || !$event) {
return ;
}
xData.importExcel(params);
}
/**
* 过滤
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelGridViewBase
*/
public ToggleFilter(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
const _this: any = this;
if (_this.hasOwnProperty('isExpandSearchForm')) {
_this.isExpandSearchForm = !_this.isExpandSearchForm;
}
}
/**
* 帮助
*
* @param {any[]} args 当前数据
* @param {any} contextJO 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @memberof MetaDynamicModelGridViewBase
*/
public Help(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
this.$Notice.error({ title: '错误', desc: '帮助未支持' });
}
/**
* 关闭视图
*
* @param {any[]} args
* @memberof MetaDynamicModelGridViewBase
*/
public closeView(args: any[]): void {
let _view: any = this;
if (_view.viewdata) {
_view.$emit('viewdataschange', Array.isArray(args)?args:[args]);
_view.$emit('close', Array.isArray(args)?args:[args]);
} else if (_view.$tabPageExp) {
_view.$tabPageExp.onClose(_view.$route.fullPath);
}
}
/**
* 销毁视图回调
*
* @memberof MetaDynamicModelGridViewBase
*/
public destroyed(){
this.afterDestroyed();
}
/**
* 执行destroyed后的逻辑
*
* @memberof MetaDynamicModelGridViewBase
*/
public afterDestroyed(){
if(this.viewDefaultUsage){
let localStoreLength = Object.keys(localStorage);
if(localStoreLength.length > 0){
localStoreLength.forEach((item:string) =>{
if(item.startsWith(this.context.srfsessionid)){
localStorage.removeItem(item);
}
})
}
if(Object.is(this.navModel,"tab")){
this.navDataService.removeNavDataByTag(this.viewtag);
}
if (this.serviceStateEvent) {
this.serviceStateEvent.unsubscribe();
}
}
// 销毁计数器定时器
if(this.counterServiceArray && this.counterServiceArray.length >0){
this.counterServiceArray.forEach((item:any) =>{
if(item.destroyCounter && item.destroyCounter instanceof Function){
item.destroyCounter();
}
})
}
if(this.portletStateEvent){
this.portletStateEvent.unsubscribe();
}
}
/**
* 是否单选
*
* @type {boolean}
* @memberof MetaDynamicModelGridViewBase
*/
public isSingleSelect: boolean = false;
/**
* 是否嵌入关系界面
*
* @type {boolean}
* @memberof MetaDynamicModelGridViewBase
*/
@Prop({default:false}) public isformDruipart?: boolean;
/**
* 界面关系通讯对象
*
* @type {Subject<ViewState>}
* @memberof MetaDynamicModelGridViewBase
*/
@Prop() public formDruipart?: Subject<ViewState>;
/**
* 搜索值
*
* @type {string}
* @memberof MetaDynamicModelGridViewBase
*/
public query: string = '';
/**
* 是否展开搜索表单
*
* @type {boolean}
* @memberof MetaDynamicModelGridViewBase
*/
public isExpandSearchForm: boolean = false;
/**
* 表格行数据默认激活模式
* 0 不激活
* 1 单击激活
* 2 双击激活
*
* @type {(number | 0 | 1 | 2)}
* @memberof MetaDynamicModelGridViewBase
*/
public gridRowActiveMode: number | 0 | 1 | 2 = 2;
/**
* 快速搜索
*
* @param {*} $event
* @memberof MetaDynamicModelGridViewBase
*/
public onSearch($event: any): void {
const grid: any = this.$refs.grid;
if (grid) {
grid.load(this.context, true);
}
}
/**
* grid 部件 save 事件
*
* @param {*} [args={}]
* @param {*} $event
* @memberof ENTITYTEST1Usr2GridViewBase
*/
public onSave($event: any) {
this.$emit('drdatasaved', $event);
}
/**
* 刷新数据
*
* @readonly
* @type {(number | null)}
* @memberof MetaDynamicModelGridViewBase
*/
get refreshdata(): number | null {
return this.$store.getters['viewaction/getRefreshData'](this.viewtag);
}
/**
* 监控数据变化
*
* @param {*} newVal
* @param {*} oldVal
* @returns
* @memberof MetaDynamicModelGridViewBase
*/
@Watch('refreshdata')
onRefreshData(newVal: any, oldVal: any) {
if (newVal === null || newVal === undefined) {
return;
}
if (newVal === 0) {
return;
}
const grid: any = this.$refs.grid;
if (grid) {
grid.load({});
}
}
}
</script>
<style lang='less'>
@import './meta-dynamic-model-grid-view.less';
</style>
\ No newline at end of file
.meta-dynamic-model-grid-view{
position: relative;
}
.toolbar-container {
button {
margin: 6px 0px 4px 4px;
.caption {
margin-left: 4px;
}
}
.seperator {
color: #dcdee2;
margin: 0 0px 0 4px;
}
}
// this is less
<script lang='tsx'>
import { Component } from 'vue-property-decorator';
import MetaDynamicModelGridViewBase from './meta-dynamic-model-grid-view-base.vue';
import view_grid from '@widgets/meta-dynamic-model/main-grid/main-grid.vue';
import view_searchform from '@widgets/meta-dynamic-model/default-searchform/default-searchform.vue';
@Component({
components: {
view_grid,
view_searchform,
},
beforeRouteEnter: (to: any, from: any, next: any) => {
next((vm: any) => {
if(!Object.is(vm.navModel,"route")){
vm.initNavDataWithTab(vm.viewCacheData);
}
vm.$store.commit('addCurPageViewtag', { fullPath: to.fullPath, viewtag: vm.viewtag });
});
},
})
export default class MetaDynamicModelGridView extends MetaDynamicModelGridViewBase {
}
</script>
\ No newline at end of file
......@@ -39,7 +39,8 @@ export class EntityServiceRegister {
* @memberof EntityServiceRegister
*/
protected init(): void {
this.allEntityService.set('sdfile', () => import('@/service/sdfile/sdfile-service'));
this.allEntityService.set('metadynamicmodel', () => import('@/service/meta-dynamic-model/meta-dynamic-model-service'));
this.allEntityService.set('sdfile', () => import('@/service/sdfile/sdfile-service'));
}
/**
......
import { Http,Util } from '@/utils';
import EntityService from '../entity-service';
/**
* 动态模型服务对象基类
*
* @export
* @class MetaDynamicModelServiceBase
* @extends {EntityServie}
*/
export default class MetaDynamicModelServiceBase extends EntityService {
/**
* Creates an instance of MetaDynamicModelServiceBase.
*
* @param {*} [opts={}]
* @memberof MetaDynamicModelServiceBase
*/
constructor(opts: any = {}) {
super(opts);
}
/**
* 初始化基础数据
*
* @memberof MetaDynamicModelServiceBase
*/
public initBasicData(){
this.APPLYDEKEY ='metadynamicmodel';
this.APPDEKEY = 'configid';
this.APPDENAME = 'metadynamicmodels';
this.APPDETEXT = 'configname';
this.APPNAME = 'web';
this.SYSTEMNAME = 'ibzdisk';
}
// 实体接口
/**
* Select接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async Select(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = Http.getInstance().get(`/metadynamicmodels/${context.metadynamicmodel}/select`,isloading);
return res;
}
/**
* Create接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async Create(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let masterData:any = {};
Object.assign(data,masterData);
if(!data.srffrontuf || data.srffrontuf !== "1"){
data[this.APPDEKEY] = null;
}
if(data.srffrontuf){
delete data.srffrontuf;
}
let tempContext:any = JSON.parse(JSON.stringify(context));
let res:any = await Http.getInstance().post(`/metadynamicmodels`,data,isloading);
return res;
}
/**
* Update接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async Update(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let masterData:any = {};
Object.assign(data,masterData);
let res:any = await Http.getInstance().put(`/metadynamicmodels/${context.metadynamicmodel}`,data,isloading);
return res;
}
/**
* Remove接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async Remove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = Http.getInstance().delete(`/metadynamicmodels/${context.metadynamicmodel}`,isloading);
return res;
}
/**
* Get接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async Get(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().get(`/metadynamicmodels/${context.metadynamicmodel}`,isloading);
return res;
}
/**
* GetDraft接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async GetDraft(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().get(`/metadynamicmodels/getdraft`,isloading);
res.data.metadynamicmodel = data.metadynamicmodel;
return res;
}
/**
* CheckKey接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = Http.getInstance().post(`/metadynamicmodels/${context.metadynamicmodel}/checkkey`,data,isloading);
return res;
}
/**
* Init接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async Init(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = Http.getInstance().post(`/metadynamicmodels/${context.metadynamicmodel}/init`,data,isloading);
return res;
}
/**
* InitBatch接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async InitBatch(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let tempData:any = JSON.parse(JSON.stringify(data));
return await Http.getInstance().post(`/metadynamicmodels/initbatch`,tempData,isloading);
}
/**
* Publish接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async Publish(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = Http.getInstance().post(`/metadynamicmodels/${context.metadynamicmodel}/publish`,data,isloading);
return res;
}
/**
* PublishBatch接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async PublishBatch(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let tempData:any = JSON.parse(JSON.stringify(data));
return await Http.getInstance().post(`/metadynamicmodels/publishbatch`,tempData,isloading);
}
/**
* Save接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async Save(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let masterData:any = {};
Object.assign(data,masterData);
let res:any = await Http.getInstance().post(`/metadynamicmodels/${context.metadynamicmodel}/save`,data,isloading);
return res;
}
/**
* FetchDefault接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async FetchDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let tempData:any = JSON.parse(JSON.stringify(data));
let res:any = Http.getInstance().get(`/metadynamicmodels/fetchdefault`,tempData,isloading);
return res;
}
/**
* searchDefault接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async searchDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let tempData:any = JSON.parse(JSON.stringify(data));
return await Http.getInstance().post(`/metadynamicmodels/searchdefault`,tempData,isloading);
}
/**
* FetchDynaInst接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async FetchDynaInst(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let tempData:any = JSON.parse(JSON.stringify(data));
let res:any = Http.getInstance().get(`/metadynamicmodels/fetchdynainst`,tempData,isloading);
return res;
}
/**
* searchDynaInst接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaDynamicModelServiceBase
*/
public async searchDynaInst(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let tempData:any = JSON.parse(JSON.stringify(data));
return await Http.getInstance().post(`/metadynamicmodels/searchdynainst`,tempData,isloading);
}
}
\ No newline at end of file
import { Http,Util } from '@/utils';
import MetaDynamicModelServiceBase from './meta-dynamic-model-service-base';
/**
* 动态模型服务对象
*
* @export
* @class MetaDynamicModelService
* @extends {MetaDynamicModelServiceBase}
*/
export default class MetaDynamicModelService extends MetaDynamicModelServiceBase {
/**
* Creates an instance of MetaDynamicModelService.
*
* @param {*} [opts={}]
* @memberof MetaDynamicModelService
*/
constructor(opts: any = {}) {
super(opts);
}
}
\ No newline at end of file
......@@ -22,6 +22,26 @@ export const viewstate: any = {
'646581c57dbd5cf6c2570e4013f3adb8',
],
},
{
viewtag: '92d51d41db51a671793ee8dc8876f9e9',
viewmodule: 'lite',
viewname: 'MetaDynamicModelDynaInstEditView',
viewaction: '',
viewdatachange: false,
refviews: [
'af9cfc34d957186380a012e322abff0c',
],
},
{
viewtag: 'af9cfc34d957186380a012e322abff0c',
viewmodule: 'lite',
viewname: 'MetaDynamicModelGridView',
viewaction: '',
viewdatachange: false,
refviews: [
'e8892afaebe9a899e5d528d5b55d3cc5',
],
},
{
viewtag: 'c0a8e8c1058d9a5cdb5a6edbf9855886',
viewmodule: 'disk',
......@@ -29,9 +49,29 @@ export const viewstate: any = {
viewaction: '',
viewdatachange: false,
refviews: [
'af9cfc34d957186380a012e322abff0c',
'795a12a2bfb63a98ce5bb80310509360',
],
},
{
viewtag: 'cec3236f5a1f742f9b91f313506ccc6c',
viewmodule: 'lite',
viewname: 'MetaDynamicModelDynaInstGridView',
viewaction: '',
viewdatachange: false,
refviews: [
'92d51d41db51a671793ee8dc8876f9e9',
],
},
{
viewtag: 'e8892afaebe9a899e5d528d5b55d3cc5',
viewmodule: 'lite',
viewname: 'MetaDynamicModelEditView',
viewaction: '',
viewdatachange: false,
refviews: [
],
},
],
createdviews: [],
}
\ No newline at end of file
import { Environment } from '@/environments/environment';
import { UIActionTool,Util } from '@/utils';
import UIService from '../ui-service';
import { Subject } from 'rxjs';
import MetaDynamicModelService from '@/service/meta-dynamic-model/meta-dynamic-model-service';
import MetaDynamicModelAuthService from '@/authservice/meta-dynamic-model/meta-dynamic-model-auth-service';
/**
* 动态模型UI服务对象基类
*
* @export
* @class MetaDynamicModelUIServiceBase
*/
export default class MetaDynamicModelUIServiceBase extends UIService {
/**
* 是否支持工作流
*
* @memberof MetaDynamicModelUIServiceBase
*/
public isEnableWorkflow:boolean = false;
/**
* 是否支持实体主状态
*
* @memberof MetaDynamicModelUIServiceBase
*/
public isEnableDEMainState:boolean = false;
/**
* 当前UI服务对应的数据服务对象
*
* @memberof MetaDynamicModelUIServiceBase
*/
public dataService:MetaDynamicModelService = new MetaDynamicModelService();
/**
* 所有关联视图
*
* @memberof MetaDynamicModelUIServiceBase
*/
public allViewMap: Map<string, Object> = new Map();
/**
* 状态值
*
* @memberof MetaDynamicModelUIServiceBase
*/
public stateValue: number = 0;
/**
* 状态属性
*
* @memberof MetaDynamicModelUIServiceBase
*/
public stateField: string = "";
/**
* 主状态属性集合
*
* @memberof MetaDynamicModelUIServiceBase
*/
public mainStateFields:Array<any> = [];
/**
* 主状态集合Map
*
* @memberof MetaDynamicModelUIServiceBase
*/
public allDeMainStateMap:Map<string,string> = new Map();
/**
* 主状态操作标识Map
*
* @memberof MetaDynamicModelUIServiceBase
*/
public allDeMainStateOPPrivsMap:Map<string,any> = new Map();
/**
* Creates an instance of MetaDynamicModelUIServiceBase.
*
* @param {*} [opts={}]
* @memberof MetaDynamicModelUIServiceBase
*/
constructor(opts: any = {}) {
super(opts);
this.authService = new MetaDynamicModelAuthService(opts);
this.initViewMap();
this.initDeMainStateMap();
this.initDeMainStateOPPrivsMap();
}
/**
* 初始化视图Map
*
* @memberof MetaDynamicModelUIServiceBase
*/
public initViewMap(){
this.allViewMap.set(':',{viewname:'dynainsteditview',srfappde:'metadynamicmodels',component:'meta-dynamic-model-dyna-inst-edit-view'});
this.allViewMap.set('MDATAVIEW:',{viewname:'gridview',srfappde:'metadynamicmodels',component:'meta-dynamic-model-grid-view'});
this.allViewMap.set(':',{viewname:'dynainstgridview',srfappde:'metadynamicmodels',component:'meta-dynamic-model-dyna-inst-grid-view'});
this.allViewMap.set('EDITVIEW:',{viewname:'editview',srfappde:'metadynamicmodels',component:'meta-dynamic-model-edit-view'});
}
/**
* 初始化主状态集合
*
* @memberof MetaDynamicModelUIServiceBase
*/
public initDeMainStateMap(){
}
/**
* 初始化主状态操作标识
*
* @memberof MetaDynamicModelUIServiceBase
*/
public initDeMainStateOPPrivsMap(){
}
/**
* 发布模型
*
* @param {any[]} args 当前数据
* @param {any} context 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @param {*} [srfParentDeName] 父实体名称
* @returns {Promise<any>}
*/
public async MetaDynamicModel_publish(args: any[],context:any = {}, params:any = {}, $event?: any, xData?: any,actionContext?: any,srfParentDeName?:string){
let data: any = {};
let parentContext:any = {};
let parentViewParam:any = {};
const _this: any = actionContext;
const _args: any[] = Util.deepCopy(args);
const actionTarget: string | null = 'SINGLEKEY';
Object.assign(context, { metadynamicmodel: '%metadynamicmodel%' });
Object.assign(params, { configid: '%metadynamicmodel%' });
Object.assign(params, { configname: '%configname%' });
if(_this.context){
parentContext = _this.context;
}
if(_this.viewparams){
parentViewParam = _this.viewparams;
}
context = UIActionTool.handleContextParam(actionTarget,_args,parentContext,parentViewParam,context);
data = UIActionTool.handleActionParam(actionTarget,_args,parentContext,parentViewParam,params);
if(Object.is(actionTarget,"MULTIKEY")){
let tempDataArray:Array<any> = [];
if((_args.length >1) && (Object.keys(data).length >0)){
for(let i =0;i<_args.length;i++){
let tempObject:any = {};
Object.keys(data).forEach((key:string) =>{
Object.assign(tempObject,{[key]:data[key].split(',')[i]});
})
tempDataArray.push(tempObject);
}
}else{
tempDataArray.push(data);
}
data = tempDataArray;
}
context = Object.assign({},actionContext.context,context);
let parentObj:any = {srfparentdename:srfParentDeName?srfParentDeName:null,srfparentkey:srfParentDeName?context[srfParentDeName.toLowerCase()]:null};
if(!Object.is(actionTarget,"MULTIKEY")){
Object.assign(data,parentObj);
}
Object.assign(context,parentObj);
// 直接调实体服务需要转换的数据
if(context && context.srfsessionid){
context.srfsessionkey = context.srfsessionid;
delete context.srfsessionid;
}
const backend = () => {
const curService:MetaDynamicModelService = new MetaDynamicModelService();
curService.Publish(context,data, true).then((response: any) => {
if (!response || response.status !== 200) {
actionContext.$Notice.error({ title: '错误', desc: response.message });
return;
}
actionContext.$Notice.success({ title: '成功', desc: '发布模型成功!' });
const _this: any = actionContext;
if (xData && xData.refresh && xData.refresh instanceof Function) {
xData.refresh(args);
}
return response;
}).catch((response: any) => {
if (response && response.status && response.data) {
actionContext.$Notice.error({ title: (actionContext.$t('app.commonWords.wrong') as string), desc: response.data.message });
return;
}
if (!response || !response.status || !response.data) {
actionContext.$Notice.error({ title: (actionContext.$t('app.commonWords.wrong') as string), desc: (actionContext.$t('app.commonWords.sysException') as string) });
return;
}
return response;
});
};
backend();
}
/**
* 获取指定数据的重定向页面
*
* @param srfkey 数据主键
* @param isEnableWorkflow 重定向视图是否需要处理流程中的数据
* @memberof MetaDynamicModelUIServiceBase
*/
public async getRDAppView(srfkey:string,isEnableWorkflow:boolean){
this.isEnableWorkflow = isEnableWorkflow;
// 进行数据查询
let result:any = await this.dataService.Get({metadynamicmodel:srfkey});
const curData:any = result.data;
//判断当前数据模式,默认为true,todo
const iRealDEModel:boolean = true;
let bDataInWF:boolean = false;
let bWFMode:any = false;
// 计算数据模式
if (this.isEnableWorkflow) {
bDataInWF = await this.dataService.testDataInWF({stateValue:this.stateValue,stateField:this.stateField},curData);
if (bDataInWF) {
bDataInWF = true;
bWFMode = await this.dataService.testUserExistWorklist(null,curData);
}
}
let strPDTViewParam:string = await this.getDESDDEViewPDTParam(curData, bDataInWF, bWFMode);
//若不是当前数据模式,处理strPDTViewParam,todo
//查找视图
//返回视图
return this.allViewMap.get(strPDTViewParam);
}
/**
* 获取实际的数据类型
*
* @memberof MetaDynamicModelUIServiceBase
*/
public getRealDEType(entity:any){
}
/**
* 获取实体单数据实体视图预定义参数
*
* @param curData 当前数据
* @param bDataInWF 是否有数据在工作流中
* @param bWFMode 是否工作流模式
* @memberof MetaDynamicModelUIServiceBase
*/
public async getDESDDEViewPDTParam(curData:any, bDataInWF:boolean, bWFMode:boolean){
let strPDTParam:string = '';
if (bDataInWF) {
// 判断数据是否在流程中
}
//多表单,todo
const multiFormDEField:string|null =null;
if (multiFormDEField) {
const objFormValue:string = curData[multiFormDEField];
if(!Environment.isAppMode){
return 'MOBEDITVIEW:'+objFormValue;
}
return 'EDITVIEW:'+objFormValue;
}
if(!Environment.isAppMode){
if(this.getDEMainStateTag(curData)){
return `MOBEDITVIEW:MSTAG:${ this.getDEMainStateTag(curData)}`;
}
return 'MOBEDITVIEW:';
}
if(this.getDEMainStateTag(curData)){
return `EDITVIEW:MSTAG:${ this.getDEMainStateTag(curData)}`;
}
return 'EDITVIEW:';
}
/**
* 获取数据对象的主状态标识
*
* @param curData 当前数据
* @memberof MetaDynamicModelUIServiceBase
*/
public getDEMainStateTag(curData:any){
if(this.mainStateFields.length === 0) return null;
this.mainStateFields.forEach((singleMainField:any) =>{
if(!(singleMainField in curData)){
console.warn(`当前数据对象不包含属性「${singleMainField}」,根据「${singleMainField}」属性进行的主状态计算默认为空值`);
}
})
for (let i = 0; i <= 1; i++) {
let strTag:string = (curData[this.mainStateFields[0]] != null && curData[this.mainStateFields[0]] !== "")?(i == 0) ? `${curData[this.mainStateFields[0]]}` : "":"";
if (this.mainStateFields.length >= 2) {
for (let j = 0; j <= 1; j++) {
let strTag2:string = (curData[this.mainStateFields[1]] != null && curData[this.mainStateFields[1]] !== "")?`${strTag}__${(j == 0) ? `${curData[this.mainStateFields[1]]}` : ""}`:strTag;
if (this.mainStateFields.length >= 3) {
for (let k = 0; k <= 1; k++) {
let strTag3:string = (curData[this.mainStateFields[2]] != null && curData[this.mainStateFields[2]] !== "")?`${strTag2}__${(k == 0) ? `${curData[this.mainStateFields[2]]}` : ""}`:strTag2;
// 判断是否存在
return this.allDeMainStateMap.get(strTag3);
}
}else{
return this.allDeMainStateMap.get(strTag2);
}
}
}else{
return this.allDeMainStateMap.get(strTag);
}
}
return null;
}
/**
* 获取数据对象当前操作标识
*
* @param data 当前数据
* @memberof MetaDynamicModelUIServiceBase
*/
public getDEMainStateOPPrivs(data:any){
if(this.getDEMainStateTag(data)){
return this.allDeMainStateOPPrivsMap.get((this.getDEMainStateTag(data) as string));
}else{
return null;
}
}
/**
* 获取数据对象所有的操作标识
*
* @param data 当前数据
* @memberof MetaDynamicModelUIServiceBase
*/
public getAllOPPrivs(data:any){
return this.authService.getOPPrivs(this.getDEMainStateOPPrivs(data));
}
}
\ No newline at end of file
import MetaDynamicModelUIServiceBase from './meta-dynamic-model-ui-service-base';
/**
* 动态模型UI服务对象
*
* @export
* @class MetaDynamicModelUIService
*/
export default class MetaDynamicModelUIService extends MetaDynamicModelUIServiceBase {
/**
* Creates an instance of MetaDynamicModelUIService.
*
* @param {*} [opts={}]
* @memberof MetaDynamicModelUIService
*/
constructor(opts: any = {}) {
super(opts);
}
}
\ No newline at end of file
......@@ -39,7 +39,8 @@ export class UIServiceRegister {
* @memberof UIServiceRegister
*/
protected init(): void {
this.allUIService.set('sdfile', () => import('@/uiservice/sdfile/sdfile-ui-service'));
this.allUIService.set('metadynamicmodel', () => import('@/uiservice/meta-dynamic-model/meta-dynamic-model-ui-service'));
this.allUIService.set('sdfile', () => import('@/uiservice/sdfile/sdfile-ui-service'));
}
/**
......
......@@ -595,6 +595,9 @@ export default class SDIndexViewBase extends Vue implements ControlInterface {
navDataService.removeNavData(this.viewtag);
}
switch (item.appfunctag) {
case 'AppFunc':
this.clickAppFunc(item);
return;
case 'Auto1':
this.clickAuto1(item);
return;
......@@ -605,6 +608,29 @@ export default class SDIndexViewBase extends Vue implements ControlInterface {
}
/**
* 动态模型表格视图
*
* @param {*} [item={}]
* @memberof SDIndexView
*/
public clickAppFunc(item: any = {}) {
const viewparam: any = {};
Object.assign(viewparam, {});
const deResParameters: any[] = [];
const parameters: any[] = [
{ pathName: 'metadynamicmodels', parameterName: 'metadynamicmodel' },
{ pathName: 'gridview', parameterName: 'gridview' },
];
const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
if(Object.is(this.$route.fullPath,path)){
return;
}
this.$nextTick(function(){
this.$router.push(path);
})
}
/**
* 文件
*
......
......@@ -32,6 +32,25 @@ export default class SDIndexViewModel {
appfunctag: 'Auto1',
resourcetag: '',
authtag:'web-SDIndexView-menuitem1',
},
{
id: '4AD5C30C-D39B-42EC-9418-70615CA75A3C',
name: 'menuitem2',
text: '动态模型',
type: 'MENUITEM',
counterid: '',
tooltip: '动态模型',
expanded: false,
separator: false,
hidden: false,
hidesidebar: false,
opendefault: false,
iconcls: '',
icon: '',
textcls: '',
appfunctag: 'AppFunc',
resourcetag: '',
authtag:'web-SDIndexView-menuitem2',
},
];
......@@ -43,6 +62,18 @@ export default class SDIndexViewModel {
* @memberof SDIndexViewModel
*/
public funcs: any[] = [
{
appfunctag: 'AppFunc',
appfuncyype: 'APPVIEW',
openmode: '',
codename: 'metadynamicmodelgridview',
deResParameters: [],
routepath: '/sdindexview/:sdindexview?/metadynamicmodels/:metadynamicmodel?/gridview/:gridview?',
parameters: [
{ pathName: 'metadynamicmodels', parameterName: 'metadynamicmodel' },
{ pathName: 'gridview', parameterName: 'gridview' },
],
},
{
appfunctag: 'Auto1',
appfuncyype: 'APPVIEW',
......
<template>
<i-form :model="this.data" class='app-search-form' ref='searchform' style="">
<input style="display:none;"/>
<row>
<i-col span="20" class="form-content">
<row>
</row>
</i-col>
<i-col span="4" class="search-button">
<row v-show="Object.keys(data).length>0">
<i-button class='search_reset' size="default" type="primary" @click="onSearch">{{$t('app.searchButton.search')}}</i-button>
<i-button class='search_reset' size="default" @click="onReset">{{this.$t('app.searchButton.reset')}}</i-button>
</row>
</i-col>
</row>
</i-form>
</template>
<script lang='tsx'>
import { Vue, Component, Prop, Provide, Emit, Watch, Model,Inject } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util,ViewTool } from '@/utils';
import NavDataService from '@/service/app/navdata-service';
import AppCenterService from "@service/app/app-center-service";
import MetaDynamicModelEntityService from '@/service/meta-dynamic-model/meta-dynamic-model-service';
import DefaultService from './default-searchform-service';
import MetaDynamicModelUIService from '@/uiservice/meta-dynamic-model/meta-dynamic-model-ui-service';
import { FormButtonModel, FormPageModel, FormItemModel, FormDRUIPartModel, FormPartModel, FormGroupPanelModel, FormIFrameModel, FormRowItemModel, FormTabPageModel, FormTabPanelModel, FormUserControlModel } from '@/model/form-detail';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
@Component({
components: {
}
})
export default class DefaultBase extends Vue implements ControlInterface {
/**
* 名称
*
* @type {string}
* @memberof DefaultBase
*/
@Prop() public name?: string;
/**
* 视图通讯对象
*
* @type {Subject<ViewState>}
* @memberof DefaultBase
*/
@Prop() public viewState!: Subject<ViewState>;
/**
* 应用上下文
*
* @type {*}
* @memberof DefaultBase
*/
@Prop() public context!: any;
/**
* 视图参数
*
* @type {*}
* @memberof DefaultBase
*/
@Prop() public viewparams!: any;
/**
* 视图状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof DefaultBase
*/
public viewStateEvent: Subscription | undefined;
/**
* 获取部件类型
*
* @returns {string}
* @memberof DefaultBase
*/
public getControlType(): string {
return 'SEARCHFORM'
}
/**
* 计数器服务对象集合
*
* @type {Array<*>}
* @memberof DefaultBase
*/
public counterServiceArray:Array<any> = [];
/**
* 建构部件服务对象
*
* @type {DefaultService}
* @memberof DefaultBase
*/
public service: DefaultService = new DefaultService({ $store: this.$store });
/**
* 实体服务对象
*
* @type {MetaDynamicModelService}
* @memberof DefaultBase
*/
public appEntityService: MetaDynamicModelEntityService = new MetaDynamicModelEntityService({ $store: this.$store });
/**
* 转化数据
*
* @param {any} args
* @memberof DefaultBase
*/
public transformData(args: any) {
let _this: any = this;
if(_this.service && _this.service.handleRequestData instanceof Function && _this.service.handleRequestData('transform',_this.context,args)){
return _this.service.handleRequestData('transform',_this.context,args)['data'];
}
}
/**
* 关闭视图
*
* @param {any} args
* @memberof DefaultBase
*/
public closeView(args: any): void {
let _this: any = this;
_this.$emit('closeview', [args]);
}
/**
* 计数器刷新
*
* @memberof DefaultBase
*/
public counterRefresh(){
const _this:any =this;
if(_this.counterServiceArray && _this.counterServiceArray.length >0){
_this.counterServiceArray.forEach((item:any) =>{
if(item.refreshData && item.refreshData instanceof Function){
item.refreshData();
}
})
}
}
/**
* 获取多项数据
*
* @returns {any[]}
* @memberof DefaultBase
*/
public getDatas(): any[] {
return [this.data];
}
/**
* 获取单项树
*
* @returns {*}
* @memberof DefaultBase
*/
public getData(): any {
return this.data;
}
/**
* 显示处理提示
*
* @type {boolean}
* @memberof DefaultBase
*/
@Prop({ default: true }) public showBusyIndicator?: boolean;
/**
* 部件行为--loaddraft
*
* @type {string}
* @memberof DefaultBase
*/
@Prop() public loaddraftAction!: string;
/**
* 部件行为--load
*
* @type {string}
* @memberof DefaultBase
*/
@Prop() public loadAction!: string;
/**
* 视图标识
*
* @type {string}
* @memberof DefaultBase
*/
@Prop() public viewtag!: string;
/**
* 表单状态
*
* @type {Subject<any>}
* @memberof DefaultBase
*/
public formState: Subject<any> = new Subject();
/**
* 忽略表单项值变化
*
* @type {boolean}
* @memberof DefaultBase
*/
public ignorefieldvaluechange: boolean = false;
/**
* 数据变化
*
* @public
* @type {Subject<any>}
* @memberof DefaultBase
*/
public dataChang: Subject<any> = new Subject();
/**
* 视图状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof DefaultBase
*/
public dataChangEvent: Subscription | undefined;
/**
* 原始数据
*
* @public
* @type {*}
* @memberof DefaultBase
*/
public oldData: any = {};
/**
* 表单数据对象
*
* @type {*}
* @memberof DefaultBase
*/
public data: any = {
};
/**
* 详情模型集合
*
* @type {*}
* @memberof DefaultBase
*/
public detailsModel: any = {
formpage1: new FormPageModel({ caption: '常规条件', detailType: 'FORMPAGE', name: 'formpage1', visible: true, isShowCaption: true, form: this })
,
};
/**
* 属性值规则
*
* @type {*}
* @memberof DefaultBase
*/
public rules: any = {
}
/**
* 重置表单项值
*
* @public
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @memberof DefaultBase
*/
public resetFormData({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
}
/**
* 表单逻辑
*
* @public
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @memberof DefaultBase
*/
public formLogic({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
}
/**
* 表单值变化
*
* @public
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @returns {void}
* @memberof DefaultBase
*/
public formDataChange({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
if (this.ignorefieldvaluechange) {
return;
}
this.resetFormData({ name: name, newVal: newVal, oldVal: oldVal });
this.formLogic({ name: name, newVal: newVal, oldVal: oldVal });
this.dataChang.next(JSON.stringify(this.data));
}
/**
* 表单加载完成
*
* @public
* @param {*} [data={}]
* @param {string} [action]
* @memberof DefaultBase
*/
public onFormLoad(data: any = {},action:string): void {
this.setFormEnableCond(data);
this.fillForm(data,action);
this.formLogic({ name: '', newVal: null, oldVal: null });
}
/**
* 值填充
*
* @param {*} [_datas={}]
* @param {string} [action]
* @memberof DefaultBase
*/
public fillForm(_datas: any = {},action:string): void {
this.ignorefieldvaluechange = true;
Object.keys(_datas).forEach((name: string) => {
if (this.data.hasOwnProperty(name)) {
this.data[name] = _datas[name];
}
});
if(Object.is(action,'loadDraft')){
this.createDefault();
}
this.$nextTick(function () {
this.ignorefieldvaluechange = false;
})
}
/**
* 设置表单项是否启用
*
* @public
* @param {*} data
* @memberof DefaultBase
*/
public setFormEnableCond(data: any): void {
Object.values(this.detailsModel).forEach((detail: any) => {
if (!Object.is(detail.detailType, 'FORMITEM')) {
return;
}
const formItem: FormItemModel = detail;
formItem.setEnableCond(data.srfuf);
});
}
/**
* 新建默认值
* @memberof DefaultBase
*/
public createDefault(){
}
/**
* 重置草稿表单状态
*
* @public
* @memberof DefaultBase
*/
public resetDraftFormStates(): void {
const form: any = this.$refs.form;
if (form) {
form.resetFields();
}
}
/**
* 重置校验结果
*
* @memberof DefaultBase
*/
public resetValidates(): void {
Object.values(this.detailsModel).forEach((detail: any) => {
if (!Object.is(detail.detailType, 'FORMITEM')) {
return;
}
const formItem: FormItemModel = detail;
formItem.setError('');
});
}
/**
* 填充校验结果 (后台)
*
* @param {any[]} fieldErrors
* @memberof DefaultBase
*/
public fillValidates(fieldErrors: any[]): void {
fieldErrors.forEach((error: any) => {
const formItem: FormItemModel = this.detailsModel[error.field];
if (!formItem) {
return;
}
this.$nextTick(() => {
formItem.setError(error.message);
});
});
}
/**
* 表单校验状态
*
* @returns {boolean}
* @memberof DefaultBase
*/
public formValidateStatus(): boolean {
const form: any = this.$refs.searchform;
let validatestate: boolean = true;
form.validate((valid: boolean) => {
validatestate = valid ? true : false;
});
return validatestate
}
/**
* 获取全部值
*
* @returns {*}
* @memberof DefaultBase
*/
public getValues(): any {
return this.data;
}
/**
* 表单项值变更
*
* @param {{ name: string, value: any }} $event
* @returns {void}
* @memberof DefaultBase
*/
public onFormItemValueChange($event: { name: string, value: any }): void {
if (!$event) {
return;
}
if (!$event.name || Object.is($event.name, '') || !this.data.hasOwnProperty($event.name)) {
return;
}
this.data[$event.name] = $event.value;
}
/**
* 设置数据项值
*
* @param {string} name
* @param {*} value
* @returns {void}
* @memberof DefaultBase
*/
public setDataItemValue(name: string, value: any): void {
if (!name || Object.is(name, '') || !this.data.hasOwnProperty(name)) {
return;
}
if (Object.is(this.data[name], value)) {
return;
}
this.data[name] = value;
}
/**
* 分组界面行为事件
*
* @param {*} $event
* @memberof DefaultBase
*/
public groupUIActionClick($event: any): void {
if (!$event) {
return;
}
const item:any = $event.item;
}
/**
* Vue声明周期(处理组件的输入属性)
*
* @memberof DefaultBase
*/
public created(): void {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
* @memberof DefaultBase
*/
public afterCreated(){
if (this.viewState) {
this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
if (!Object.is(tag, this.name)) {
return;
}
if (Object.is('autoload', action)) {
this.autoLoad(data);
}
if (Object.is('load', action)) {
this.load(data);
}
if (Object.is('loaddraft', action)) {
this.loadDraft(data);
}
});
}
}
/**
* vue 生命周期
*
* @memberof DefaultBase
*/
public destroyed() {
this.afterDestroy();
}
/**
* 执行destroyed后的逻辑
*
* @memberof DefaultBase
*/
public afterDestroy() {
if (this.viewStateEvent) {
this.viewStateEvent.unsubscribe();
}
if (this.dataChangEvent) {
this.dataChangEvent.unsubscribe();
}
}
/**
* 自动加载
*
* @param {*} [arg={}]
* @returns {void}
* @memberof DefaultBase
*/
public autoLoad(arg: any = {}): void {
if (arg.srfkey && !Object.is(arg.srfkey, '')) {
Object.assign(arg, { srfkey: arg.srfkey });
this.load(arg);
return;
}
if (arg.srfkeys && !Object.is(arg.srfkeys, '')) {
Object.assign(arg, { srfkey: arg.srfkeys });
this.load(arg);
return;
}
this.loadDraft(arg);
}
/**
* 加载
*
* @public
* @param {*} [opt={}]
* @memberof DefaultBase
*/
public load(opt: any = {}): void {
if(!this.loadAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelDynaInstGridView' + (this.$t('app.searchForm.notConfig.loadAction') as string) });
return;
}
const arg: any = { ...opt };
Object.assign(arg,{viewparams:this.viewparams});
const get: Promise<any> = this.service.get(this.loadAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
get.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
this.$emit('load', data);
this.$nextTick(() => {
this.formState.next({ type: 'load', data: data });
});
}
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
return;
}
const { data: _data } = response;
this.$Notice.error({ title: _data.title, desc: _data.message });
});
}
/**
* 加载草稿
*
* @param {*} [opt={}]
* @memberof DefaultBase
*/
public loadDraft(opt: any = {},mode?:string): void {
if(!this.loaddraftAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelDynaInstGridView' + (this.$t('app.searchForm.notConfig.loaddraftAction') as string) });
return;
}
const arg: any = { ...opt } ;
Object.assign(arg,{viewparams:this.viewparams});
let post: Promise<any> = this.service.loadDraft(this.loaddraftAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.errorMessage) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.errorMessage });
}
return;
}
const data = response.data;
this.resetDraftFormStates();
this.onFormLoad(data,'loadDraft');
setTimeout(() => {
const form: any = this.$refs.form;
if (form) {
form.fields.forEach((field: any) => {
field.validateMessage = "";
field.validateState = "";
field.validateStatus = false;
});
}
});
if(Object.is(mode,'RESET')){
if (!this.formValidateStatus()) {
return;
}
}
this.$emit('load', data);
this.$nextTick(() => {
this.formState.next({ type: 'load', data: data });
});
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
return;
}
const { data: _data } = response;
this.$Notice.error({ title: _data.title, desc: _data.message });
});
}
/**
* 表单项更新
*
* @param {string} mode 界面行为名称
* @param {*} [data={}] 请求数据
* @param {string[]} updateDetails 更新项
* @param {boolean} [showloading] 是否显示加载状态
* @returns {void}
* @memberof DefaultBase
*/
public updateFormItems(mode: string, data: any = {}, updateDetails: string[], showloading?: boolean): void {
}
/**
* 回车事件
*
* @param {*} $event
* @memberof DefaultBase
*/
public onEnter($event: any): void {
if (!this.formValidateStatus()) {
return;
}
this.$emit('search', this.data);
}
/**
* 搜索
*
* @memberof DefaultBase
*/
public onSearch() {
if (!this.formValidateStatus()) {
return;
}
this.$emit('search', this.data);
}
/**
* 重置
*
* @memberof DefaultBase
*/
public onReset() {
this.loadDraft({},'RESET');
}
}
</script>
<style lang='less'>
@import './default-searchform.less';
</style>
\ No newline at end of file
/**
* Default 部件模型
*
* @export
* @class DefaultModel
*/
export default class DefaultModel {
/**
* 获取数据项集合
*
* @returns {any[]}
* @memberof DefaultModel
*/
public getDataItems(): any[] {
return [
{
name: 'srfwfmemo',
prop: 'srfwfmemo',
dataType: 'TEXT',
},
// 前端新增修改标识,新增为"0",修改为"1"或未设值
{
name: 'srffrontuf',
prop: 'srffrontuf',
dataType: 'TEXT',
},
]
}
}
\ No newline at end of file
import { Http,Util,Errorlog } from '@/utils';
import ControlService from '@/widgets/control-service';
import MetaDynamicModelService from '@/service/meta-dynamic-model/meta-dynamic-model-service';
import DefaultModel from './default-searchform-model';
/**
* Default 部件服务对象
*
* @export
* @class DefaultService
*/
export default class DefaultService extends ControlService {
/**
* 动态模型服务对象
*
* @type {MetaDynamicModelService}
* @memberof DefaultService
*/
public appEntityService: MetaDynamicModelService = new MetaDynamicModelService({ $store: this.getStore() });
/**
* 设置从数据模式
*
* @type {boolean}
* @memberof DefaultService
*/
public setTempMode(){
this.isTempMode = false;
}
/**
* Creates an instance of DefaultService.
*
* @param {*} [opts={}]
* @memberof DefaultService
*/
constructor(opts: any = {}) {
super(opts);
this.model = new DefaultModel();
}
/**
* 远端数据
*
* @type {*}
* @memberof DefaultService
*/
private remoteCopyData:any = {};
/**
* 处理数据
*
* @private
* @param {Promise<any>} promise
* @returns {Promise<any>}
* @memberof DefaultService
*/
private doItems(promise: Promise<any>, deKeyField: string, deName: string): Promise<any> {
return new Promise((resolve, reject) => {
promise.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
data.forEach((item:any,index:number) =>{
item[deName] = item[deKeyField];
data[index] = item;
});
resolve(data);
} else {
reject([])
}
}).catch((response: any) => {
reject([])
});
});
}
/**
* 获取跨实体数据集合
*
* @param {string} serviceName 服务名称
* @param {string} interfaceName 接口名称
* @param {*} data
* @param {boolean} [isloading]
* @returns {Promise<any[]>}
* @memberof DefaultService
*/
@Errorlog
public getItems(serviceName: string, interfaceName: string, context: any = {}, data: any, isloading?: boolean): Promise<any[]> {
data.page = data.page ? data.page : 0;
data.size = data.size ? data.size : 1000;
return Promise.reject([])
}
/**
* 启动工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @param {*} [localdata]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public wfstart(action: string,context: any = {},data: any = {}, isloading?: boolean,localdata?:any): Promise<any> {
data = this.handleWFData(data,true);
context = this.handleRequestData(action,context,data).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,data, isloading,localdata);
} else {
result = this.appEntityService.WFStart(context,data, isloading,localdata);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 提交工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @param {*} [localdata]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public wfsubmit(action: string,context: any = {}, data: any = {}, isloading?: boolean,localdata?:any): Promise<any> {
data = this.handleWFData(data,true);
context = this.handleRequestData(action,context,data,true).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,data, isloading,localdata);
} else {
result = this.appEntityService.WFSubmit(context,data, isloading,localdata);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 添加数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @param {boolean} [isWorkflow] 是否在工作流中添加数据
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public add(action: string, context: any = {},data: any = {}, isloading?: boolean,isWorkflow?:boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Create(Context,Data, isloading);
}
result.then((response) => {
if(isWorkflow){
resolve(response);
}else{
this.handleResponse(action, response);
resolve(response);
}
}).catch(response => {
reject(response);
});
});
}
/**
* 删除数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public delete(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Remove(Context,Data, isloading);
}
result.then((response) => {
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 修改数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @param {boolean} [isWorkflow] 是否在工作流中修改数据
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public update(action: string, context: any = {},data: any = {}, isloading?: boolean,isWorkflow?:boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Update(Context,Data, isloading);
}
result.then((response) => {
if(isWorkflow){
resolve(response);
}else{
this.handleResponse(action, response);
resolve(response);
}
}).catch(response => {
reject(response);
});
});
}
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public get(action: string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Get(Context,Data, isloading);
}
result.then((response) => {
this.setRemoteCopyData(response);
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 加载草稿
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public loadDraft(action: string,context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.GetDraft(Context,Data, isloading);
}
result.then((response) => {
this.setRemoteCopyData(response);
this.handleResponse(action, response, true);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 前台逻辑
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public frontLogic(action:string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any)=>{
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
return Promise.reject({ status: 500, data: { title: '失败', message: '系统异常' } });
}
result.then((response) => {
this.handleResponse(action, response,true);
resolve(response);
}).catch(response => {
reject(response);
});
})
}
/**
* 处理请求数据
*
* @param action 行为
* @param data 数据
* @memberof DefaultService
*/
public handleRequestData(action: string,context:any, data: any = {},isMerge:boolean = false){
let mode: any = this.getMode();
if (!mode && mode.getDataItems instanceof Function) {
return data;
}
let formItemItems: any[] = mode.getDataItems();
let requestData:any = {};
if(isMerge && (data && data.viewparams)){
Object.assign(requestData,data.viewparams);
}
formItemItems.forEach((item:any) =>{
if(item && item.dataType && Object.is(item.dataType,'FONTKEY')){
if(item && item.prop){
requestData[item.prop] = context[item.name];
}
}else{
if(item && item.prop){
requestData[item.prop] = data[item.name];
}else{
if(item.dataType && Object.is(item.dataType,"FORMPART")){
Object.assign(requestData,data[item.name]);
}
}
}
});
let tempContext:any = JSON.parse(JSON.stringify(context));
if(tempContext && tempContext.srfsessionid){
tempContext.srfsessionkey = tempContext.srfsessionid;
delete tempContext.srfsessionid;
}
return {context:tempContext,data:requestData};
}
/**
* 通过属性名称获取表单项名称
*
* @param name 实体属性名称
* @memberof DefaultService
*/
public getItemNameByDeName(name:string) :string{
let itemName = name;
let mode: any = this.getMode();
if (!mode && mode.getDataItems instanceof Function) {
return name;
}
let formItemItems: any[] = mode.getDataItems();
formItemItems.forEach((item:any)=>{
if(item.prop === name){
itemName = item.name;
}
});
return itemName.trim();
}
/**
* 重写处理返回数据
*
* @param {string} action
* @param {*} response
* @memberof DefaultService
*/
public handleResponseData(action: string, data: any = {},isCreate?:boolean,codelistArray?:any){
let model: any = this.getMode();
if (!model && model.getDataItems instanceof Function) {
return data;
}
let item: any = {};
let dataItems: any[] = model.getDataItems();
dataItems.forEach(dataitem => {
let val = data.hasOwnProperty(dataitem.prop) ? data[dataitem.prop] : null;
if (val === null) {
val = data.hasOwnProperty(dataitem.name) ? data[dataitem.name] : null;
}
if((isCreate === undefined || isCreate === null ) && Object.is(dataitem.dataType, 'GUID') && Object.is(dataitem.name, 'srfkey') && (val && !Object.is(val, ''))){
isCreate = true;
}
item[dataitem.name] = val;
// 转化代码表
if(codelistArray && dataitem.codelist){
if(codelistArray.get(dataitem.codelist.tag) && codelistArray.get(dataitem.codelist.tag).get(val)){
item[dataitem.name] = codelistArray.get(dataitem.codelist.tag).get(val);
}
}
});
item.srfuf = data.srfuf ? data.srfuf : (isCreate ? "0" : "1");
item = Object.assign(data,item);
return item;
}
/**
* 设置远端数据
*
* @param result 远端请求结果
* @memberof DefaultService
*/
public setRemoteCopyData(result:any){
if (result && result.status === 200) {
this.remoteCopyData = Util.deepCopy(result.data);
}
}
/**
* 获取远端数据
*
* @memberof DefaultService
*/
public getRemoteCopyData(){
return this.remoteCopyData;
}
}
\ No newline at end of file
.ivu-tabs-no-animation>.ivu-tabs-content{
padding: 0 16px;
}
.ivu-card-head{
padding: 14px 0;
}
.app-search-form {
padding: 8px 14px 0;
.ivu-form-item{
margin-bottom: 8px;
}
.search_reset {
margin-right: 12px;
margin-bottom: 8px;
}
.search-button{
text-align: right;
}
}
.app-search-form-flex {
height: 100%;
> .ivu-row {
height: 100%;
> .ivu-tabs {
height: 100%;
display: flex;
flex-direction: column;
> .ivu-tabs-content {
flex-grow: 1;
overflow: auto;
> .ivu-tabs-tabpane {
height: 100%;
}
}
}
}
}
.app-tabpanel-flex {
height: 100%;
> .ivu-tabs-content {
height: calc(100% - 52px);
> .ivu-tabs-tabpane {
height: 100%;
}
}
}
// this is less
<script lang='tsx'>
import { Component } from 'vue-property-decorator';
import DefaultBase from './default-searchform-base.vue';
@Component({
components: {
}
})
export default class Default extends DefaultBase {
}
</script>
\ No newline at end of file
<template>
<i-form :model="this.data" class='app-form' ref='form' id='metadynamicmodel_dynainst' style="" @on-validate="formItemValidate">
<input style="display:none;" />
<row >
<i-col v-show="detailsModel.group1.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<app-form-group :uiService="appUIService" :data="transformData(data)" :manageContainerStatus="detailsModel.group1.manageContainerStatus" :isManageContainer="detailsModel.group1.isManageContainer" @managecontainerclick="manageContainerClick('group1')" layoutType="TABLE_24COL" titleStyle="" class='' :uiActionGroup="detailsModel.group1.uiActionGroup" @groupuiactionclick="groupUIActionClick($event)" :caption="$t('entities.metadynamicmodel.dynainst_form.details.group1')" :isShowCaption="true" uiStyle="DEFAULT" :titleBarCloseMode="0" :isInfoGroupMode="false" >
<row>
<i-col v-show="detailsModel.configname.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<app-form-item name='configname' :itemRules="this.rules().configname" class='' :caption="$t('entities.metadynamicmodel.dynainst_form.details.configname')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.configname.error" :isEmptyCaption="false" labelPos="LEFT">
<input-box
v-model="data.configname"
@enter="onEnter($event)"
unit=""
:disabled="detailsModel.configname.disabled"
type='text'
style="">
</input-box>
</app-form-item>
</i-col>
<i-col v-show="detailsModel.formitem.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<app-form-item name='formitem' :itemRules="this.rules().formitem" class='' :caption="$t('entities.metadynamicmodel.dynainst_form.details.formitem')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.formitem.error" :isEmptyCaption="false" labelPos="LEFT">
<app-file-upload :formState="formState" :ignorefieldvaluechange="ignorefieldvaluechange" @formitemvaluechange="onFormItemValueChange" :data="JSON.stringify(this.data)" name='formitem' :value="data.formitem" :disabled="detailsModel.formitem.disabled" :uploadparams='{}' :exportparams='{}' style="overflow: auto;"></app-file-upload>
</app-form-item>
</i-col>
<i-col v-show="detailsModel.tabpanel1.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<tabs :animated="false" name='tabpanel1' v-show="detailsModel.tabpanel1.visible" class=''
:value="detailsModel.tabpanel1.activiedPage" @on-click="detailsModel.tabpanel1.clickPage($event)">
<tab-pane v-show="detailsModel.tabpage1.visible" name='tabpage1' :index="0" tab='tabpanel1' class=''
:label="(h) =>{
return h('span',{
class:'caption'
},[
$t('entities.metadynamicmodel.dynainst_form.details.tabpage1')
])
}">
<i-col v-show="detailsModel.druipart1.visible" :style="{'height': '500px !important',}" :lg="{ span: 24, offset: 0 }">
<app-form-druipart
:formState="formState"
:isForbidLoad="this.data.srfuf === '0'"
paramItem='metadynamicmodel'
:parentdata='{"srfparentdefname":"PDYNAINSTID","srfparentdename":"META_DYNAMICMODEL","SRFPARENTTYPE":"DER1N","srfparentmode":"DER1N_META_DYNAMICMODEL_META_DYNAMICMODEL_PDYNAINSTID","SRFDER1NID":"DER1N_META_DYNAMICMODEL_META_DYNAMICMODEL_PDYNAINSTID"}'
:parameters="[
]"
:context="context"
:viewparams="viewparams"
:localContext ='{PINSTID:"%metadynamicmodel%",SYSID:"%systemid%"}'
:localParam ='{}'
parameterName='metadynamicmodel'
parentName="MetaDynamicModel"
refviewtype='DEGRIDVIEW'
refreshitems=''
:ignorefieldvaluechange="ignorefieldvaluechange"
viewname='meta-dynamic-model-grid-view'
tempMode='0'
:data="JSON.stringify(this.data)"
@drdatasaved="drdatasaved($event)"
style="height:500px;overflow: auto;">
</app-form-druipart>
</i-col>
</tab-pane>
</tabs>
</i-col>
</row>
</app-form-group>
</i-col>
</row>
</i-form>
</template>
<script lang='tsx'>
import { Vue, Component, Prop, Provide, Emit, Watch, Model,Inject } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util,ViewTool } from '@/utils';
import NavDataService from '@/service/app/navdata-service';
import AppCenterService from "@service/app/app-center-service";
import MetaDynamicModelEntityService from '@/service/meta-dynamic-model/meta-dynamic-model-service';
import DynaInstService from './dyna-inst-form-service';
import MetaDynamicModelUIService from '@/uiservice/meta-dynamic-model/meta-dynamic-model-ui-service';
import { FormButtonModel, FormPageModel, FormItemModel, FormDRUIPartModel, FormPartModel, FormGroupPanelModel, FormIFrameModel, FormRowItemModel, FormTabPageModel, FormTabPanelModel, FormUserControlModel } from '@/model/form-detail';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import schema from 'async-validator';
import { Environment } from '@/environments/environment';
@Component({
components: {
}
})
export default class DynaInstBase extends Vue implements ControlInterface {
/**
* 名称
*
* @type {string}
* @memberof DynaInstBase
*/
@Prop() public name?: string;
/**
* 视图通讯对象
*
* @type {Subject<ViewState>}
* @memberof DynaInstBase
*/
@Prop() public viewState!: Subject<ViewState>;
/**
* 应用上下文
*
* @type {*}
* @memberof DynaInstBase
*/
@Prop() public context!: any;
/**
* 视图参数
*
* @type {*}
* @memberof DynaInstBase
*/
@Prop() public viewparams!: any;
/**
* 视图状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof DynaInstBase
*/
public viewStateEvent: Subscription | undefined;
/**
* 获取部件类型
*
* @returns {string}
* @memberof DynaInstBase
*/
public getControlType(): string {
return 'FORM'
}
/**
* 计数器服务对象集合
*
* @type {Array<*>}
* @memberof DynaInstBase
*/
public counterServiceArray:Array<any> = [];
/**
* 建构部件服务对象
*
* @type {DynaInstService}
* @memberof DynaInstBase
*/
public service: DynaInstService = new DynaInstService({ $store: this.$store });
/**
* 实体服务对象
*
* @type {MetaDynamicModelService}
* @memberof DynaInstBase
*/
public appEntityService: MetaDynamicModelEntityService = new MetaDynamicModelEntityService({ $store: this.$store });
/**
* 转化数据
*
* @param {any} args
* @memberof DynaInstBase
*/
public transformData(args: any) {
let _this: any = this;
if(_this.service && _this.service.handleRequestData instanceof Function && _this.service.handleRequestData('transform',_this.context,args)){
return _this.service.handleRequestData('transform',_this.context,args)['data'];
}
}
/**
* 关闭视图
*
* @param {any} args
* @memberof DynaInstBase
*/
public closeView(args: any): void {
let _this: any = this;
_this.$emit('closeview', [args]);
}
/**
* 计数器刷新
*
* @memberof DynaInstBase
*/
public counterRefresh(){
const _this:any =this;
if(_this.counterServiceArray && _this.counterServiceArray.length >0){
_this.counterServiceArray.forEach((item:any) =>{
if(item.refreshData && item.refreshData instanceof Function){
item.refreshData();
}
})
}
}
/**
* 视图默认使用
*
* @type {string}
* @memberof DynaInstBase
*/
@Inject({from:'navModel',default: 'tab'})
public navModel!:string;
/**
* 主键表单项名称
*
* @protected
* @type {string}
* @memberof DynaInstBase
*/
public formKeyItemName: string = '';
/**
* 是否自动加载
*
* @type {boolean}
* @memberof DynaInstBase
*/
@Prop({default:false}) public isautoload?:boolean;
/**
* 界面UI服务对象
*
* @type {MetaDynamicModelUIService}
* @memberof DynaInstBase
*/
public appUIService:MetaDynamicModelUIService = new MetaDynamicModelUIService(this.$store);
/**
* 工作流审批意见控件绑定值
*
* @memberof DynaInstBase
*/
public srfwfmemo:string = "";
/**
* 获取多项数据
*
* @returns {any[]}
* @memberof DynaInstBase
*/
public getDatas(): any[] {
return [this.data];
}
/**
* 获取单项树
*
* @returns {*}
* @memberof DynaInstBase
*/
public getData(): any {
return this.data;
}
/**
* 是否默认保存
*
* @type {boolean}
* @memberof DynaInstBase
*/
@Prop({ default: false }) public autosave?: boolean;
/**
* 显示处理提示
*
* @type {boolean}
* @memberof DynaInstBase
*/
@Prop({ default: true }) public showBusyIndicator?: boolean;
/**
* 部件行为--submit
*
* @type {string}
* @memberof DynaInstBase
*/
@Prop() public WFSubmitAction!: string;
/**
* 部件行为--start
*
* @type {string}
* @memberof DynaInstBase
*/
@Prop() public WFStartAction!: string;
/**
* 部件行为--update
*
* @type {string}
* @memberof DynaInstBase
*/
@Prop() public updateAction!: string;
/**
* 部件行为--remove
*
* @type {string}
* @memberof DynaInstBase
*/
@Prop() public removeAction!: string;
/**
* 部件行为--loaddraft
*
* @type {string}
* @memberof DynaInstBase
*/
@Prop() public loaddraftAction!: string;
/**
* 部件行为--load
*
* @type {string}
* @memberof DynaInstBase
*/
@Prop() public loadAction!: string;
/**
* 部件行为--create
*
* @type {string}
* @memberof DynaInstBase
*/
@Prop() public createAction!: string;
/**
* 部件行为--create
*
* @type {string}
* @memberof DynaInstBase
*/
@Prop() public searchAction!: string;
/**
* 视图标识
*
* @type {string}
* @memberof DynaInstBase
*/
@Prop() public viewtag!: string;
/**
* 表单状态
*
* @type {Subject<any>}
* @memberof DynaInstBase
*/
public formState: Subject<any> = new Subject();
/**
* 忽略表单项值变化
*
* @type {boolean}
* @memberof DynaInstBase
*/
public ignorefieldvaluechange: boolean = false;
/**
* 数据变化
*
* @public
* @type {Subject<any>}
* @memberof DynaInstBase
*/
public dataChang: Subject<any> = new Subject();
/**
* 视图状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof DynaInstBase
*/
public dataChangEvent: Subscription | undefined;
/**
* 原始数据
*
* @public
* @type {*}
* @memberof DynaInstBase
*/
public oldData: any = {};
/**
* 混入表单数据对象
*
* @type {*}
* @memberof DynaInstBase
*/
public mixinData:any = {};
/**
* 表单项校验错误提示信息
*
* @memberof DynaInstBase
*/
public errorMessages: Array<any> = [];
/**
* 应用状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof DynaInstBase
*/
public appStateEvent: Subscription | undefined;
/**
* 设置表单项错误提示信息
*
* @param {*} prop 表单项字段名
* @param {*} status 校验状态
* @param {*} error 错误信息
* @memberof DynaInstBase
*/
public formItemValidate(prop: string,status: boolean, error: string){
error = error ? error : '';
if(this.errorMessages && this.errorMessages.length > 0){
const index = this.errorMessages.findIndex((errorMessage:any) => Object.is(errorMessage.prop,prop));
if(index != -1){
this.errorMessages[index].error = error;
}else{
this.errorMessages.push({prop: prop,error: error});
}
}else{
this.errorMessages.push({prop: prop,error: error});
}
}
/**
* 表单数据对象
*
* @type {*}
* @memberof DynaInstBase
*/
public data: any = {
srforikey: null,
srfkey: null,
srfmajortext: null,
srftempmode: null,
srfuf: null,
srfdeid: null,
srfsourcekey: null,
configname: null,
formitem: null,
systemid: null,
configid: null,
metadynamicmodel:null,
};
/**
* 当前执行的行为逻辑
*
* @type {string}
* @memberof DynaInstBase
*/
public currentAction: string = "";
/**
* 关系界面计数器
*
* @type {number}
* @memberof DynaInstBase
*/
public drcounter: number = 0;
/**
* 需要等待关系界面保存时,第一次调用save参数的备份
*
* @type {number}
* @memberof DynaInstBase
*/
public drsaveopt: any = {};
/**
* 表单保存回调存储对象
*
* @type {any}
* @memberof DynaInstBase
*/
public saveState:any ;
/**
* 主信息属性映射表单项名称
*
* @type {string}
* @memberof DynaInstBase
*/
public majorMessageField: string = "configname";
/**
* 值规则
*
* @type {*}
* @memberof DynaInstBase
*/
public rules() :any {
return {
configname: [
{ required: this.detailsModel.configname.required, type: 'string', message: '配置名称 值不能为空', trigger: 'change' },
{ required: this.detailsModel.configname.required, type: 'string', message: '配置名称 值不能为空', trigger: 'blur' },
],
formitem: [
{ required: this.detailsModel.formitem.required, type: 'string', message: '文件 值不能为空', trigger: 'change' },
{ required: this.detailsModel.formitem.required, type: 'string', message: '文件 值不能为空', trigger: 'blur' },
],
}
}
/**
* 属性值规则
*
* @type {*}
* @memberof DynaInstBase
*/
public deRules(){
return {
}
}
/**
* 校验属性值规则
*
* @public
* @param {{ name: string }} { name }
* @memberof DynaInstBase
*/
public verifyDeRules(name:string,rule:any = this.deRules(),op:string = "AND") :{isPast:boolean,infoMessage:string}{
let falg:any = {infoMessage:""};
if(!rule[name]){
return falg;
}
let opValue = op == 'AND'? true :false;
let startOp = (val:boolean)=>{
if(falg.isPast){
if(opValue){
falg.isPast = falg.isPast && val;
}else{
falg.isPast = falg.isPast || val;
}
}else{
falg.isPast = val;
}
}
for(let i=0;i<rule[name].length;i++){
let item:any = rule[name][i];
let dataValue = item.deName?this.data[this.service.getItemNameByDeName(item.deName)]:"";
item.ruleInfo = item.ruleInfo ? item.ruleInfo : this.$t('app.formpage.valuecheckex');
if((dataValue === null || dataValue === undefined || dataValue === "") && (item.type != 'GROUP')){
startOp(true);
return falg;
}
try {
// 常规规则
if(item.type == 'SIMPLE'){
startOp(!this.$verify.checkFieldSimpleRule(dataValue,item.condOP,item.paramValue,item.ruleInfo,item.paramType,this.data,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
if(!falg.isPast) return falg;
}
// 数值范围
if(item.type == 'VALUERANGE2'){
startOp( !this.$verify.checkFieldValueRangeRule(dataValue,item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
if(!falg.isPast) return falg;
}
// 正则式
if (item.type == "REGEX") {
startOp(!this.$verify.checkFieldRegExRule(dataValue,item.regExCode,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
if(!falg.isPast) return falg;
}
// 长度
if (item.type == "STRINGLENGTH") {
startOp(!this.$verify.checkFieldStringLengthRule(dataValue,item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
if(!falg.isPast) return falg;
}
// 系统值规则
if(item.type == "SYSVALUERULE") {
startOp(!this.$verify.checkFieldSysValueRule(dataValue,item.sysRule.regExCode,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
if(!falg.isPast) return falg;
}
} catch(error) {
falg.infoMessage = item.ruleInfo;
startOp(false);
if(!falg.isPast) return falg;
}
// 分组
if(item.type == 'GROUP'){
falg = this.verifyDeRules('group',item,item.condOP?item.condOP:"AND");
if(item.isNotMode){
falg.isPast = !falg.isPast;
}
if(!falg.isPast) return falg;
}
}
if(!falg.hasOwnProperty("isPast")){
falg.isPast = true;
}
if(!this.data[name] && this.data[name] != 0){
falg.isPast = true;
}
return falg;
}
/**
* 详情模型集合
*
* @type {*}
* @memberof DynaInstBase
*/
public detailsModel: any = {
druipart1: new FormDRUIPartModel({ caption: '副本', detailType: 'DRUIPART', name: 'druipart1', visible: true, isShowCaption: true, form: this, isControlledContent: false })
,
tabpage1: new FormTabPageModel({ caption: '副本', detailType: 'TABPAGE', name: 'tabpage1', visible: true, isShowCaption: true, form: this, isControlledContent: false })
,
tabpanel1: new FormTabPanelModel({ caption: '', detailType: 'TABPANEL', name: 'tabpanel1', visible: true, isShowCaption: false, form: this, isControlledContent: false , tabPages: [{ name: 'tabpage1', index: 0, visible: true }] })
,
group1: new FormGroupPanelModel({ caption: '动态模型基本信息', detailType: 'GROUPPANEL', name: 'group1', visible: true, isShowCaption: true, form: this, isControlledContent: false , uiActionGroup: { caption: '', langbase: 'entities.metadynamicmodel.dynainst_form', extractMode: 'ITEM', details: [] }, isManageContainer: false, showMoreModeItems: [] })
,
formpage1: new FormPageModel({ caption: '基本信息', detailType: 'FORMPAGE', name: 'formpage1', visible: true, isShowCaption: true, form: this, isControlledContent: false })
,
srforikey: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srforikey', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
srfkey: new FormItemModel({ caption: '配置标识', detailType: 'FORMITEM', name: 'srfkey', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
srfmajortext: new FormItemModel({ caption: '配置名称', detailType: 'FORMITEM', name: 'srfmajortext', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
srftempmode: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srftempmode', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
srfuf: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfuf', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
srfdeid: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfdeid', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
srfsourcekey: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfsourcekey', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
configname: new FormItemModel({ caption: '配置名称', detailType: 'FORMITEM', name: 'configname', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
formitem: new FormItemModel({ caption: '文件', detailType: 'FORMITEM', name: 'formitem', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:true, disabled: false, enableCond: 3 })
,
systemid: new FormItemModel({ caption: '系统', detailType: 'FORMITEM', name: 'systemid', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
configid: new FormItemModel({ caption: '配置标识', detailType: 'FORMITEM', name: 'configid', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
};
/**
* 监控表单属性 srforikey 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof DynaInstBase
*/
@Watch('data.srforikey')
onSrforikeyChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srforikey', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srfkey 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof DynaInstBase
*/
@Watch('data.srfkey')
onSrfkeyChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfkey', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srfmajortext 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof DynaInstBase
*/
@Watch('data.srfmajortext')
onSrfmajortextChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfmajortext', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srftempmode 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof DynaInstBase
*/
@Watch('data.srftempmode')
onSrftempmodeChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srftempmode', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srfuf 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof DynaInstBase
*/
@Watch('data.srfuf')
onSrfufChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfuf', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srfdeid 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof DynaInstBase
*/
@Watch('data.srfdeid')
onSrfdeidChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfdeid', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srfsourcekey 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof DynaInstBase
*/
@Watch('data.srfsourcekey')
onSrfsourcekeyChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfsourcekey', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 configname 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof DynaInstBase
*/
@Watch('data.configname')
onConfignameChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'configname', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 formitem 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof DynaInstBase
*/
@Watch('data.formitem')
onFormitemChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'formitem', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 systemid 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof DynaInstBase
*/
@Watch('data.systemid')
onSystemidChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'systemid', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 configid 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof DynaInstBase
*/
@Watch('data.configid')
onConfigidChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'configid', newVal: newVal, oldVal: oldVal });
}
/**
* 显示更多模式切换操作
*
* @type {string}
* @memberof DynaInstBase
*/
public manageContainerClick(name: string){
let model = this.detailsModel[name];
if(model.isManageContainer){
model.setManageContainerStatus(!model.manageContainerStatus);
model.showMoreModeItems.forEach((item:any) => {
if(this.detailsModel[item].isControlledContent){
this.detailsModel[item].setVisible(model.manageContainerStatus? this.detailsModel[item].oldVisible : false);
}
});
}
}
/**
* 重置表单项值
*
* @public
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @memberof DynaInstBase
*/
public resetFormData({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
}
/**
* 置空对象
*
* @param {any[]} args
* @memberof DynaInstBase
*/
public ResetData(_datas:any){
if(Object.keys(_datas).length >0){
Object.keys(_datas).forEach((name: string) => {
if (this.data.hasOwnProperty(name)) {
this.data[name] = null;
}
});
}
}
/**
* 表单逻辑
*
* @public
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @memberof DynaInstBase
*/
public async formLogic({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }){
}
/**
* 表单项检查逻辑
*
* @public
* @param name 属性名
* @memberof DynaInstBase
*/
public checkItem(name:string):Promise<any> {
return new Promise((resolve, reject) => {
var validator = new schema({[name]:this.rules()[name]});
validator.validate({[name]:this.data[name]}).then(()=>{
resolve(true);
})
.catch(() => {
resolve(false);
});;
})
}
/**
* 表单值变化
*
* @public
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @returns {void}
* @memberof DynaInstBase
*/
public formDataChange({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
if (this.ignorefieldvaluechange) {
return;
}
this.resetFormData({ name: name, newVal: newVal, oldVal: oldVal });
this.formLogic({ name: name, newVal: newVal, oldVal: oldVal });
this.dataChang.next(JSON.stringify(this.data));
}
/**
* 表单加载完成
*
* @public
* @param {*} [data={}]
* @param {string} [action]
* @memberof DynaInstBase
*/
public onFormLoad(data: any = {},action:string): void {
if(Object.is(action,"save") || Object.is(action,"autoSave") || Object.is(action,"submit"))
// 更新context的实体主键
if(data.metadynamicmodel){
Object.assign(this.context,{metadynamicmodel:data.metadynamicmodel})
}
this.setFormEnableCond(data);
this.computeButtonState(data);
this.fillForm(data,action);
this.oldData = {};
Object.assign(this.oldData, JSON.parse(JSON.stringify(this.data)));
this.$store.commit('viewaction/setViewDataChange', { viewtag: this.viewtag, viewdatachange: false });
this.formLogic({ name: '', newVal: null, oldVal: null });
}
/**
* 值填充
*
* @param {*} [_datas={}]
* @param {string} [action]
* @memberof DynaInstBase
*/
public fillForm(_datas: any = {},action:string): void {
this.mixinData = _datas;
this.ignorefieldvaluechange = true;
Object.keys(_datas).forEach((name: string) => {
if (this.data.hasOwnProperty(name)) {
this.data[name] = _datas[name];
}
});
if(Object.is(action,'loadDraft')){
this.createDefault();
}
if(Object.is(action,'load')){
this.updateDefault();
}
this.$nextTick(function () {
this.ignorefieldvaluechange = false;
})
}
/**
* 设置表单项是否启用
*
* @public
* @param {*} data
* @memberof DynaInstBase
*/
public setFormEnableCond(data: any): void {
Object.values(this.detailsModel).forEach((detail: any) => {
if (!Object.is(detail.detailType, 'FORMITEM')) {
return;
}
const formItem: FormItemModel = detail;
formItem.setEnableCond(data.srfuf);
});
}
/**
* 重置草稿表单状态
*
* @public
* @memberof DynaInstBase
*/
public resetDraftFormStates(): void {
const form: any = this.$refs.form;
if (form) {
form.resetFields();
}
}
/**
* 重置校验结果
*
* @memberof DynaInstBase
*/
public resetValidates(): void {
Object.values(this.detailsModel).forEach((detail: any) => {
if (!Object.is(detail.detailType, 'FORMITEM')) {
return;
}
const formItem: FormItemModel = detail;
formItem.setError('');
});
}
/**
* 填充校验结果 (后台)
*
* @param {any[]} fieldErrors
* @memberof DynaInstBase
*/
public fillValidates(fieldErrors: any[]): void {
fieldErrors.forEach((error: any) => {
const formItem: FormItemModel = this.detailsModel[error.field];
if (!formItem) {
return;
}
this.$nextTick(() => {
formItem.setError(error.message);
});
});
}
/**
* 表单校验状态
*
* @returns {boolean}
* @memberof DynaInstBase
*/
public formValidateStatus(): boolean {
const form: any = this.$refs.form;
let validatestate: boolean = true;
form.validate((valid: boolean) => {
validatestate = valid ? true : false;
});
return validatestate
}
/**
* 获取全部值
*
* @returns {*}
* @memberof DynaInstBase
*/
public getValues(): any {
return this.data;
}
/**
* 表单项值变更
*
* @param {{ name: string, value: any }} $event
* @returns {void}
* @memberof DynaInstBase
*/
public onFormItemValueChange($event: { name: string, value: any }): void {
if (!$event) {
return;
}
if (!$event.name || Object.is($event.name, '') || !this.data.hasOwnProperty($event.name)) {
return;
}
this.data[$event.name] = $event.value;
}
/**
* 编辑器行为触发
*
* @param {*} arg
* @returns {void}
* @memberof DynaInstBase
*/
public onFormItemActionClick(arg:any){
if(arg && (arg instanceof Function)) arg();
}
/**
* 设置数据项值
*
* @param {string} name
* @param {*} value
* @returns {void}
* @memberof DynaInstBase
*/
public setDataItemValue(name: string, value: any): void {
if (!name || Object.is(name, '') || !this.data.hasOwnProperty(name)) {
return;
}
if (Object.is(this.data[name], value)) {
return;
}
this.data[name] = value;
}
/**
* 计算表单按钮权限状态
*
* @param {*} [data] 传入数据
* @memberof DynaInstBase
*/
public computeButtonState(data:any){
let targetData:any = this.transformData(data);
if(this.detailsModel && Object.keys(this.detailsModel).length >0){
Object.keys(this.detailsModel).forEach((name:any) =>{
if(this.detailsModel[name] && this.detailsModel[name].uiaction && this.detailsModel[name].uiaction.dataaccaction && Object.is(this.detailsModel[name].detailType,"BUTTON")){
this.detailsModel[name].isPower = true;
let tempUIAction:any = JSON.parse(JSON.stringify(this.detailsModel[name].uiaction));
let result: any[] = ViewTool.calcActionItemAuthState(targetData,[tempUIAction],this.appUIService);
this.detailsModel[name].visible = tempUIAction.visabled;
this.detailsModel[name].disabled = tempUIAction.disabled;
this.detailsModel[name].isPower = result[0] === 1 ? true : false;
}
})
}
}
/**
* 分组界面行为事件
*
* @param {*} $event
* @memberof DynaInstBase
*/
public groupUIActionClick($event: any): void {
if (!$event) {
return;
}
const item:any = $event.item;
}
/**
* Vue声明周期(处理组件的输入属性)
*
* @memberof DynaInstBase
*/
public created(): void {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
* @memberof DynaInstBase
*/
public afterCreated(){
if(this.isautoload){
this.autoLoad({srfkey:this.context.metadynamicmodel});
}
if (this.viewState) {
this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
if (!Object.is(tag, this.name)) {
return;
}
if (Object.is('autoload', action)) {
this.autoLoad(data);
}
if (Object.is('load', action)) {
this.load(data);
}
if (Object.is('loaddraft', action)) {
this.loadDraft(data);
}
if (Object.is('save', action)) {
this.save(data,data.showResultInfo);
}
if (Object.is('remove', action)) {
this.remove(data);
}
if (Object.is('saveandexit', action)) {
this.saveAndExit(data);
}
if (Object.is('saveandnew', action)) {
this.saveAndNew(data);
}
if (Object.is('removeandexit', action)) {
this.removeAndExit(data);
}
if (Object.is('refresh', action)) {
this.refresh(data);
}
if (Object.is('panelaction', action)) {
this.panelAction(data.action,data.emitAction,data.data);
}
});
}
this.dataChang
.pipe(
debounceTime(300),
distinctUntilChanged()
).subscribe((data: any) => {
if (this.autosave) {
this.autoSave();
}
const state = !Object.is(JSON.stringify(this.oldData), JSON.stringify(this.data)) ? true : false;
this.$store.commit('viewaction/setViewDataChange', { viewtag: this.viewtag, viewdatachange: state });
});
}
/**
* vue 生命周期
*
* @memberof DynaInstBase
*/
public destroyed() {
this.afterDestroy();
}
/**
* 执行destroyed后的逻辑
*
* @memberof DynaInstBase
*/
public afterDestroy() {
if (this.viewStateEvent) {
this.viewStateEvent.unsubscribe();
}
if (this.dataChangEvent) {
this.dataChangEvent.unsubscribe();
}
if(this.appStateEvent){
this.appStateEvent.unsubscribe();
}
}
/**
*打印
*@memberof @memberof DynaInstBase
*/
public print(){
let _this:any = this;
_this.$print({id:'metadynamicmodel_dynainst',popTitle:'主实例及副本实例关系表单'});
}
/**
* 部件刷新
*
* @param {any} args
* @memberof DynaInstBase
*/
public refresh(args?: any): void {
let arg: any = {};
Object.assign(arg,args?args[0]:{});
if (this.data.srfkey && !Object.is(this.data.srfkey, '')) {
Object.assign(arg, { srfkey: this.data.srfkey });
this.load(arg);
return;
}
if (this.data.srfkeys && !Object.is(this.data.srfkeys, '')) {
Object.assign(arg, { srfkey: this.data.srfkeys });
this.load(arg);
return;
}
}
/**
* 自动加载
*
* @param {*} [arg={}]
* @returns {void}
* @memberof DynaInstBase
*/
public autoLoad(arg: any = {}): void {
if (arg.srfkey && !Object.is(arg.srfkey, '')) {
Object.assign(arg, { srfkey: arg.srfkey });
this.load(arg);
return;
}
if (arg.srfkeys && !Object.is(arg.srfkeys, '')) {
Object.assign(arg, { srfkey: arg.srfkeys });
this.load(arg);
return;
}
this.loadDraft(arg);
}
/**
* 加载
*
* @public
* @param {*} [opt={}]
* @memberof DynaInstBase
*/
public load(opt: any = {}): void {
if(!this.loadAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelDynaInstEditView' + (this.$t('app.formpage.notconfig.loadaction') as string) });
return;
}
const arg: any = { ...opt };
let viewparamResult:any = Object.assign(arg,this.viewparams);
const get: Promise<any> = this.service.get(this.loadAction,JSON.parse(JSON.stringify(this.context)),{viewparams:viewparamResult}, this.showBusyIndicator);
get.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
this.onFormLoad(data,'load');
this.$emit('load', data);
this.$nextTick(() => {
this.formState.next({ type: 'load', data: data });
});
}
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
return;
}
});
}
/**
* 加载草稿
*
* @param {*} [opt={}]
* @memberof DynaInstBase
*/
public loadDraft(opt: any = {}): void {
if(!this.loaddraftAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelDynaInstEditView' + (this.$t('app.formpage.notconfig.loaddraftaction') as string) });
return;
}
const arg: any = { ...opt } ;
let viewparamResult:any = Object.assign(arg,this.viewparams);
let post: Promise<any> = this.service.loadDraft(this.loaddraftAction,JSON.parse(JSON.stringify(this.context)),{viewparams:viewparamResult}, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
return;
}
const data = response.data;
this.resetDraftFormStates();
this.onFormLoad(data,'loadDraft');
data.metadynamicmodel = null;
this.$emit('load', data);
this.$nextTick(() => {
this.formState.next({ type: 'load', data: data });
});
setTimeout(() => {
const form: any = this.$refs.form;
if (form) {
form.fields.forEach((field: any) => {
field.validateMessage = "";
field.validateState = "";
field.validateStatus = false;
});
}
});
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
return;
}
});
}
/**
* 自动保存
*
* @param {*} [opt={}]
* @memberof DynaInstBase
*/
public autoSave(opt: any = {}): void {
if (!this.formValidateStatus()) {
return;
}
const arg: any = { ...opt };
const data = this.getValues();
Object.assign(arg, data);
Object.assign(arg,{srfmajortext:data[this.majorMessageField]});
const action: any = Object.is(data.srfuf, '1') ? this.updateAction : this.createAction;
if(!action){
let actionName:any = Object.is(data.srfuf, '1')?"updateAction":"createAction";
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelDynaInstEditView' + (this.$t('app.formpage.notconfig.actionname') as string) });
return;
}
Object.assign(arg,{viewparams:this.viewparams});
const post: Promise<any> = this.service.add(action, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
return;
}
const data = response.data;
this.onFormLoad(data,'autoSave');
this.$emit('save', data);
AppCenterService.notifyMessage({name:"MetaDynamicModel",action:'appRefresh',data:data});
this.$nextTick(() => {
this.formState.next({ type: 'save', data: data });
});
}).catch((response: any) => {
if (response && response.status && response.data) {
if (response.data.errorKey) {
if(Object.is(response.data.errorKey, "versionCheck")) {
this.$Modal.confirm({
title: (this.$t('app.formpage.saveerror') as string),
content: (this.$t('app.formpage.savecontent') as string),
onOk: () => {
this.refresh([]);
},
onCancel: () => { }
});
} else if(Object.is(response.data.errorKey, 'DupCheck')) {
let errorProp: string = response.data.message.match(/\[[a-zA-Z]*\]/)[0];
let name: string = this.service.getNameByProp(errorProp.substr(1, errorProp.length-2));
if(name) {
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: this.detailsModel[name].caption + " : " + arg[name] + (this.$t('app.commonWords.isExist') as string) + '!',
});
} else {
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: response.data.message?response.data.message:(this.$t('app.commonWords.sysException') as string),
})
}
}else if(Object.is(response.data.errorKey, 'DuplicateKeyException')){
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: this.detailsModel[this.formKeyItemName].caption + " : " + arg[this.formKeyItemName] + (this.$t('app.commonWords.isExist') as string) + '!',
});
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message?response.data.message:(this.$t('app.commonWords.sysException') as string) });
}
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message?response.data.message:(this.$t('app.commonWords.sysException') as string) });
}
return;
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
}
});
}
/**
* 保存
*
* @param {*} [opt={}]
* @param {boolean} [showResultInfo]
* @param {boolean} [ifStateNext] formState是否下发通知
* @returns {Promise<any>}
* @memberof DynaInstBase
*/
public async save(opt: any = {}, showResultInfo?: boolean, ifStateNext: boolean = true): Promise<any> {
return new Promise((resolve: any, reject: any) => {
showResultInfo = showResultInfo === undefined ? true : false;
if (!this.formValidateStatus()) {
if(this.errorMessages && this.errorMessages.length > 0) {
let descMessage: string = '';
this.errorMessages.forEach((message: any) => {
descMessage = descMessage + '<p>' + message.error + '<p>';
})
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: descMessage });
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.formpage.valuecheckex') as string) });
}
return;
}
const arg: any = { ...opt };
const data = this.getValues();
Object.assign(arg, this.context);
Object.assign(arg, data);
Object.assign(arg,{srfmajortext:data[this.majorMessageField]});
if (ifStateNext) {
this.drcounter = 1;
if(this.drcounter !== 0){
this.drsaveopt = opt;
this.formState.next({ type: 'beforesave', data: arg });//先通知关系界面保存
this.saveState = resolve;
return;
}
}
if(this.viewparams && this.viewparams.copymode){
data.srfuf = '0';
}
const action: any = Object.is(data.srfuf, '1') ? this.updateAction : this.createAction;
if(!action){
let actionName:any = Object.is(data.srfuf, '1')?"updateAction":"createAction";
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelDynaInstEditView' + (this.$t('app.formpage.notconfig.actionname') as string) });
return;
}
Object.assign(arg,{viewparams:this.viewparams});
const post: Promise<any> = Object.is(data.srfuf, '1')?this.service.update(action, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator):this.service.add(action,JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
return;
}
this.viewparams.copymode = false;
const data = response.data;
this.onFormLoad(data,'save');
this.$emit('save', data);
AppCenterService.notifyMessage({name:"MetaDynamicModel",action:'appRefresh',data:data});
this.$nextTick(() => {
this.formState.next({ type: 'save', data: data });
});
if (showResultInfo) {
this.$Notice.success({ title: '', desc: (data.srfmajortext ? data.srfmajortext : '') + '&nbsp;'+ (this.$t('app.formpage.savesuccess') as string) });
}
resolve(response);
}).catch((response: any) => {
if (response && response.status && response.data) {
if (response.data.errorKey) {
if(Object.is(response.data.errorKey, "versionCheck")) {
this.$Modal.confirm({
title: (this.$t('app.formpage.saveerror') as string),
content: (this.$t('app.formpage.savecontent') as string),
onOk: () => {
this.refresh([]);
},
onCancel: () => { }
});
} else if(Object.is(response.data.errorKey, 'DupCheck')) {
let errorProp: string = response.data.message.match(/\[[a-zA-Z]*\]/)[0];
let name: string = this.service.getNameByProp(errorProp.substr(1, errorProp.length-2));
if(name) {
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: this.detailsModel[name].caption + " : " + arg[name] + (this.$t('app.commonWords.isExist') as string) + '!',
});
} else {
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: response.data.message,
})
}
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
reject(response);
}
return;
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
reject(response);
}
reject(response);
});
})
}
/**
* 删除
*
* @public
* @param {*} [opt={}]
* @memberof DynaInstBase
*/
public remove(opt:Array<any> = [],showResultInfo?: boolean): Promise<any> {
return new Promise((resolve: any, reject: any) => {
if(!this.removeAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelDynaInstEditView' + (this.$t('app.formpage.notconfig.removeaction') as string) });
return;
}
const arg: any = opt[0];
const _this: any = this;
Object.assign(arg,{viewparams:this.viewparams});
this.service.delete(_this.removeAction, JSON.parse(JSON.stringify(this.context)),arg, showResultInfo).then((response: any) => {
if (response) {
const data = response.data;
this.$emit('remove',data);
this.formState.next({ type: 'remove', data: data });
this.data.ismodify = false;
this.$Notice.success({ title: '', desc: (data.srfmajortext ? data.srfmajortext : '') + '&nbsp;' + (this.$t('app.formpage.deletesuccess') as string) });
AppCenterService.notifyMessage({name:"MetaDynamicModel",action:'appRefresh',data:data});
resolve(response);
}
}).catch((error: any) => {
const { data: _data } = error;
this.$Notice.error({ title: _data.title, desc: _data.message });
reject(error);
});
});
}
/**
* 工作流启动
*
* @param {*} [data={}]
* @param {*} [localdata={}]
* @returns {Promise<any>}
* @memberof DynaInstBase
*/
public async wfstart(data: any,localdata?:any): Promise<any> {
return new Promise((resolve: any, reject: any) => {
const _this: any = this;
const formData:any = this.getData();
const copyData:any = Util.deepCopy(formData);
const post: Promise<any> = Object.is(formData.srfuf, '1')?this.service.update(this.updateAction, JSON.parse(JSON.stringify(this.context)),formData, this.showBusyIndicator,true):this.service.add(this.createAction,JSON.parse(JSON.stringify(this.context)),formData, this.showBusyIndicator,true);
post.then((response:any) =>{
const responseData:any = response.data;
let tempResponseData:any = Util.deepCopy(response);
this.service.handleResponse('save', tempResponseData);
const arg:any = tempResponseData.data;
// 保存完成UI处理
this.onFormLoad(arg,'save');
this.$emit('save', arg);
AppCenterService.notifyMessage({name:"MetaDynamicModel",action:'appRefresh',data:data});
this.$nextTick(() => {
this.formState.next({ type: 'save', data: arg });
});
// 准备工作流数据,填充未存库数据
Object.assign(arg,copyData);
// 准备提交参数
if(this.viewparams){
let copyViewParams:any = Util.deepCopy(this.viewparams);
if(copyViewParams.w){
delete copyViewParams.w;
}
Object.assign(responseData,copyViewParams);
}
Object.assign(arg,{viewparams:responseData});
// 强制补充srfwfmemo
if(this.srfwfmemo){
Object.assign(arg,{srfwfmemo:this.srfwfmemo});
}
const result: Promise<any> = this.service.wfstart(_this.WFStartAction, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator,localdata);
result.then((response: any) => {
if (!response || response.status !== 200) {
if(response.data){
this.$Notice.error({ title: '', desc: (this.$t('app.formpage.workflow.starterror') as string) + ', ' + response.data.message });
}
return;
}
this.$Notice.info({ title: '', desc: (this.$t('app.formpage.workflow.startsuccess') as string) });
resolve(response);
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
reject(response);
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
reject(response);
return;
}
reject(response);
});
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
reject(response);
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
reject(response);
return;
}
reject(response);
})
});
}
/**
* 工作流提交
*
* @param {*} [data={}]
* @param {*} [localdata={}]
* @returns {Promise<any>}
* @memberof DynaInstBase
*/
public async wfsubmit(data: any,localdata?:any): Promise<any> {
return new Promise((resolve: any, reject: any) => {
const _this: any = this;
const arg: any = data[0];
const copyData:any = Util.deepCopy(arg);
Object.assign(arg,{viewparams:this.viewparams});
if (!arg.metadynamicmodel || Object.is(arg.metadynamicmodel, '')) {
return;
}
const post: Promise<any> = Object.is(arg.srfuf, '1')?this.service.update(this.updateAction, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator,true):this.service.add(this.createAction,JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator,true);
post.then((response:any) =>{
const responseData:any = response.data;
let tempResponseData:any = Util.deepCopy(response);
this.service.handleResponse('save', tempResponseData);
const arg:any = tempResponseData.data;
// 保存完成UI处理
this.onFormLoad(arg,'save');
this.$emit('save', arg);
AppCenterService.notifyMessage({name:"MetaDynamicModel",action:'appRefresh',data:data});
this.$nextTick(() => {
this.formState.next({ type: 'save', data: arg });
});
// 准备工作流数据,填充未存库数据
Object.assign(arg,copyData);
// 准备提交参数
if(this.viewparams){
Object.assign(responseData,this.viewparams);
}
Object.assign(arg,{viewparams:responseData});
// 强制补充srfwfmemo
if(this.srfwfmemo){
Object.assign(arg,{srfwfmemo:this.srfwfmemo});
}
const result: Promise<any> = this.service.wfsubmit(_this.WFSubmitAction, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator,localdata);
result.then((response: any) => {
if (!response || response.status !== 200) {
if(response.data){
this.$Notice.error({ title: '', desc: (this.$t('app.formpage.workflow.submiterror') as string) + ', ' + response.data.message });
}
return;
}
this.onFormLoad(arg,'submit');
this.$store.dispatch('viewaction/datasaved', { viewtag: this.viewtag });
this.$Notice.info({ title: '', desc: (this.$t('app.formpage.workflow.submitsuccess') as string) });
resolve(response);
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
reject(response);
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
reject(response);
return;
}
reject(response);
});
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
reject(response);
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
reject(response);
return;
}
reject(response);
})
})
}
/**
* 面板行为
*
* @param {string} [action] 调用的实体行为
* @param {string} [emitAction] 抛出行为
* @param {*} [data={}] 传入数据
* @param {boolean} [showloading] 是否显示加载状态
*
* @memberof DynaInstBase
*/
public panelAction(action:string,emitAction:string,data:any ={},showloading?:boolean):void{
if (!action || (action && Object.is(action, ''))) {
return;
}
const arg: any = { ...data };
const formdata = this.getValues();
Object.assign(arg, formdata);
Object.assign(arg,this.viewparams);
const post: Promise<any> = this.service.frontLogic(action,JSON.parse(JSON.stringify(this.context)),arg, showloading);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
return;
}
const data = response.data;
this.onFormLoad(data,emitAction);
this.$emit(emitAction, data);
this.$nextTick(() => {
this.formState.next({ type: emitAction, data: data });
});
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
return;
}
});
}
/**
* 表单项更新
*
* @param {string} mode 界面行为名称
* @param {*} [data={}] 请求数据
* @param {string[]} updateDetails 更新项
* @param {boolean} [showloading] 是否显示加载状态
* @returns {void}
* @memberof DynaInstBase
*/
public updateFormItems(mode: string, data: any = {}, updateDetails: string[], showloading?: boolean): void {
if (!mode || (mode && Object.is(mode, ''))) {
return;
}
const arg: any = { ...data };
Object.assign(arg,this.viewparams);
const post: Promise<any> = this.service.frontLogic(mode,JSON.parse(JSON.stringify(this.context)),arg, showloading);
post.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.formpage.updateerror') as string) });
return;
}
const data = response.data;
const _data: any = {};
updateDetails.forEach((name: string) => {
if (!data.hasOwnProperty(name)) {
return;
}
Object.assign(_data, { [name]: data[name] });
});
this.setFormEnableCond(_data);
this.fillForm(_data,'updateFormItem');
this.formLogic({ name: '', newVal: null, oldVal: null });
this.dataChang.next(JSON.stringify(this.data));
AppCenterService.notifyMessage({name:"MetaDynamicModel",action:'appRefresh',data:data});
this.$nextTick(() => {
this.formState.next({ type: 'updateformitem', ufimode: arg.srfufimode, data: _data });
});
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
return;
}
});
}
/**
* 回车事件
*
* @param {*} $event
* @memberof DynaInstBase
*/
public onEnter($event: any): void {
}
/**
* 保存并退出
*
* @param {any[]} args
* @memberof DynaInstBase
*/
public saveAndExit(data:any[]):Promise<any>{
let _this = this;
return new Promise((resolve: any, reject: any) =>{
let arg: any = {};
if(data && data.length > 0){
Object.assign(arg,data[0]);
}
_this.currentAction = "saveAndExit";
_this.save([arg]).then((res) =>{
if(res){
_this.closeView(res.data);
}
resolve(res);
}).catch((error) =>{
reject(error);
})
})
}
/**
* 保存并新建
*
* @param {any[]} args
* @memberof DynaInstBase
*/
public saveAndNew(data:any[]):Promise<any>{
let _this = this;
return new Promise((resolve: any, reject: any) =>{
let arg: any = {};
if(data && data.length > 0){
Object.assign(arg,data[0]);
}
_this.currentAction = "saveAndNew";
_this.save([arg]).then((res) =>{
_this.ResetData(res);
_this.loadDraft({});
}).catch((error) =>{
reject(error);
})
})
}
/**
* 删除并退出
*
* @param {any[]} args
* @memberof DynaInstBase
*/
public removeAndExit(data:any[]):Promise<any>{
let _this = this;
return new Promise((resolve: any, reject: any) =>{
let arg: any = {};
if(data && data.length > 0){
Object.assign(arg,data[0]);
}
_this.remove([arg]).then((res) =>{
if(res){
_this.closeView(res.data);
}
resolve(res);
}).catch((error) =>{
reject(error);
})
})
}
/**
* 关系界面数据保存完成
*
* @param {any} $event
* @memberof DynaInstBase
*/
public drdatasaved($event:any){
let _this = this;
this.drcounter--;
if(this.drcounter === 0){
this.save(this.drsaveopt, undefined, false).then((res) =>{
this.saveState(res);
this.drsaveopt = {};
if(Object.is(_this.currentAction, "saveAndNew")){
_this.ResetData(res);
_this.loadDraft({});
}else if(Object.is(_this.currentAction, "saveAndExit")){
if(res){
_this.closeView(res.data);
}
}
});
}
}
/**
* 新建默认值
* @memberof DynaInstBase
*/
public createDefault(){
}
/**
* 更新默认值
* @memberof DynaInstBase
*/
public updateDefault(){
}
/**
* 面板数据变化处理事件
* @param {any} item 当前列数据
* @param {any} $event 面板事件数据
*
* @memberof DynaInstBase
*/
public onPanelDataChange(item:any,$event:any) {
Object.assign(item, $event, {rowDataState:'update'});
}
}
</script>
<style lang='less'>
@import './dyna-inst-form.less';
</style>
\ No newline at end of file
/**
* DynaInst 部件模型
*
* @export
* @class DynaInstModel
*/
export default class DynaInstModel {
/**
* 获取数据项集合
*
* @returns {any[]}
* @memberof DynaInstModel
*/
public getDataItems(): any[] {
return [
{
name: 'srfwfmemo',
prop: 'srfwfmemo',
dataType: 'TEXT',
},
// 前端新增修改标识,新增为"0",修改为"1"或未设值
{
name: 'srffrontuf',
prop: 'srffrontuf',
dataType: 'TEXT',
},
{
name: 'srforikey',
},
{
name: 'srfkey',
prop: 'configid',
dataType: 'TEXT',
},
{
name: 'srfmajortext',
prop: 'configname',
dataType: 'TEXT',
},
{
name: 'srftempmode',
},
{
name: 'srfuf',
},
{
name: 'srfdeid',
},
{
name: 'srfsourcekey',
},
{
name: 'configname',
prop: 'configname',
dataType: 'TEXT',
},
{
name: 'formitem',
prop: 'modelfile',
dataType: 'TEXT',
},
{
name: 'systemid',
prop: 'system_id',
dataType: 'TEXT',
},
{
name: 'configid',
prop: 'configid',
dataType: 'TEXT',
},
{
name: 'metadynamicmodel',
prop: 'configid',
dataType: 'FONTKEY',
},
]
}
}
\ No newline at end of file
import { Http,Util,Errorlog } from '@/utils';
import ControlService from '@/widgets/control-service';
import MetaDynamicModelService from '@/service/meta-dynamic-model/meta-dynamic-model-service';
import DynaInstModel from './dyna-inst-form-model';
/**
* DynaInst 部件服务对象
*
* @export
* @class DynaInstService
*/
export default class DynaInstService extends ControlService {
/**
* 动态模型服务对象
*
* @type {MetaDynamicModelService}
* @memberof DynaInstService
*/
public appEntityService: MetaDynamicModelService = new MetaDynamicModelService({ $store: this.getStore() });
/**
* 设置从数据模式
*
* @type {boolean}
* @memberof DynaInstService
*/
public setTempMode(){
this.isTempMode = false;
}
/**
* Creates an instance of DynaInstService.
*
* @param {*} [opts={}]
* @memberof DynaInstService
*/
constructor(opts: any = {}) {
super(opts);
this.model = new DynaInstModel();
}
/**
* 远端数据
*
* @type {*}
* @memberof DynaInstService
*/
private remoteCopyData:any = {};
/**
* 处理数据
*
* @private
* @param {Promise<any>} promise
* @returns {Promise<any>}
* @memberof DynaInstService
*/
private doItems(promise: Promise<any>, deKeyField: string, deName: string): Promise<any> {
return new Promise((resolve, reject) => {
promise.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
data.forEach((item:any,index:number) =>{
item[deName] = item[deKeyField];
data[index] = item;
});
resolve(data);
} else {
reject([])
}
}).catch((response: any) => {
reject([])
});
});
}
/**
* 获取跨实体数据集合
*
* @param {string} serviceName 服务名称
* @param {string} interfaceName 接口名称
* @param {*} data
* @param {boolean} [isloading]
* @returns {Promise<any[]>}
* @memberof DynaInstService
*/
@Errorlog
public getItems(serviceName: string, interfaceName: string, context: any = {}, data: any, isloading?: boolean): Promise<any[]> {
data.page = data.page ? data.page : 0;
data.size = data.size ? data.size : 1000;
return Promise.reject([])
}
/**
* 启动工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @param {*} [localdata]
* @returns {Promise<any>}
* @memberof DynaInstService
*/
@Errorlog
public wfstart(action: string,context: any = {},data: any = {}, isloading?: boolean,localdata?:any): Promise<any> {
data = this.handleWFData(data,true);
context = this.handleRequestData(action,context,data).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,data, isloading,localdata);
} else {
result = this.appEntityService.WFStart(context,data, isloading,localdata);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 提交工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @param {*} [localdata]
* @returns {Promise<any>}
* @memberof DynaInstService
*/
@Errorlog
public wfsubmit(action: string,context: any = {}, data: any = {}, isloading?: boolean,localdata?:any): Promise<any> {
data = this.handleWFData(data,true);
context = this.handleRequestData(action,context,data,true).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,data, isloading,localdata);
} else {
result = this.appEntityService.WFSubmit(context,data, isloading,localdata);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 添加数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @param {boolean} [isWorkflow] 是否在工作流中添加数据
* @returns {Promise<any>}
* @memberof DynaInstService
*/
@Errorlog
public add(action: string, context: any = {},data: any = {}, isloading?: boolean,isWorkflow?:boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Create(Context,Data, isloading);
}
result.then((response) => {
if(isWorkflow){
resolve(response);
}else{
this.handleResponse(action, response);
resolve(response);
}
}).catch(response => {
reject(response);
});
});
}
/**
* 删除数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DynaInstService
*/
@Errorlog
public delete(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Remove(Context,Data, isloading);
}
result.then((response) => {
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 修改数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @param {boolean} [isWorkflow] 是否在工作流中修改数据
* @returns {Promise<any>}
* @memberof DynaInstService
*/
@Errorlog
public update(action: string, context: any = {},data: any = {}, isloading?: boolean,isWorkflow?:boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Update(Context,Data, isloading);
}
result.then((response) => {
if(isWorkflow){
resolve(response);
}else{
this.handleResponse(action, response);
resolve(response);
}
}).catch(response => {
reject(response);
});
});
}
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DynaInstService
*/
@Errorlog
public get(action: string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Get(Context,Data, isloading);
}
result.then((response) => {
this.setRemoteCopyData(response);
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 加载草稿
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DynaInstService
*/
@Errorlog
public loadDraft(action: string,context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
//仿真主键数据
const PrimaryKey = Util.createUUID();
Data.configid = PrimaryKey;
Data.metadynamicmodel = PrimaryKey;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.GetDraft(Context,Data, isloading);
}
result.then((response) => {
this.setRemoteCopyData(response);
response.data.configid = PrimaryKey;
this.handleResponse(action, response, true);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 前台逻辑
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DynaInstService
*/
@Errorlog
public frontLogic(action:string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any)=>{
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
return Promise.reject({ status: 500, data: { title: '失败', message: '系统异常' } });
}
result.then((response) => {
this.handleResponse(action, response,true);
resolve(response);
}).catch(response => {
reject(response);
});
})
}
/**
* 处理请求数据
*
* @param action 行为
* @param data 数据
* @memberof DynaInstService
*/
public handleRequestData(action: string,context:any, data: any = {},isMerge:boolean = false){
let mode: any = this.getMode();
if (!mode && mode.getDataItems instanceof Function) {
return data;
}
let formItemItems: any[] = mode.getDataItems();
let requestData:any = {};
if(isMerge && (data && data.viewparams)){
Object.assign(requestData,data.viewparams);
}
formItemItems.forEach((item:any) =>{
if(item && item.dataType && Object.is(item.dataType,'FONTKEY')){
if(item && item.prop){
requestData[item.prop] = context[item.name];
}
}else{
if(item && item.prop){
requestData[item.prop] = data[item.name];
}else{
if(item.dataType && Object.is(item.dataType,"FORMPART")){
Object.assign(requestData,data[item.name]);
}
}
}
});
let tempContext:any = JSON.parse(JSON.stringify(context));
if(tempContext && tempContext.srfsessionid){
tempContext.srfsessionkey = tempContext.srfsessionid;
delete tempContext.srfsessionid;
}
return {context:tempContext,data:requestData};
}
/**
* 通过属性名称获取表单项名称
*
* @param name 实体属性名称
* @memberof DynaInstService
*/
public getItemNameByDeName(name:string) :string{
let itemName = name;
let mode: any = this.getMode();
if (!mode && mode.getDataItems instanceof Function) {
return name;
}
let formItemItems: any[] = mode.getDataItems();
formItemItems.forEach((item:any)=>{
if(item.prop === name){
itemName = item.name;
}
});
return itemName.trim();
}
/**
* 重写处理返回数据
*
* @param {string} action
* @param {*} response
* @memberof DynaInstService
*/
public handleResponseData(action: string, data: any = {},isCreate?:boolean,codelistArray?:any){
let model: any = this.getMode();
if (!model && model.getDataItems instanceof Function) {
return data;
}
let item: any = {};
let dataItems: any[] = model.getDataItems();
dataItems.forEach(dataitem => {
let val = data.hasOwnProperty(dataitem.prop) ? data[dataitem.prop] : null;
if (val === null) {
val = data.hasOwnProperty(dataitem.name) ? data[dataitem.name] : null;
}
if((isCreate === undefined || isCreate === null ) && Object.is(dataitem.dataType, 'GUID') && Object.is(dataitem.name, 'srfkey') && (val && !Object.is(val, ''))){
isCreate = true;
}
item[dataitem.name] = val;
// 转化代码表
if(codelistArray && dataitem.codelist){
if(codelistArray.get(dataitem.codelist.tag) && codelistArray.get(dataitem.codelist.tag).get(val)){
item[dataitem.name] = codelistArray.get(dataitem.codelist.tag).get(val);
}
}
});
item.srfuf = data.srfuf ? data.srfuf : (isCreate ? "0" : "1");
item = Object.assign(data,item);
return item;
}
/**
* 设置远端数据
*
* @param result 远端请求结果
* @memberof DynaInstService
*/
public setRemoteCopyData(result:any){
if (result && result.status === 200) {
this.remoteCopyData = Util.deepCopy(result.data);
}
}
/**
* 获取远端数据
*
* @memberof DynaInstService
*/
public getRemoteCopyData(){
return this.remoteCopyData;
}
}
\ No newline at end of file
.ivu-tabs-no-animation>.ivu-tabs-content{
padding: 0 16px;
}
.ivu-card-head{
padding: 14px 0;
}
.app-form {
overflow: auto;
padding: 6px;
> .ivu-row {
> .ivu-tabs {
height: 100%;
display: flex;
flex-direction: column;
> .ivu-tabs-content {
flex-grow: 1;
overflow: auto;
> .ivu-tabs-tabpane {
height: 100%;
}
}
}
}
}
.app-tabpanel-flex {
height: 100%;
> .ivu-tabs-content {
height: calc(100% - 52px);
> .ivu-tabs-tabpane {
height: 100%;
}
}
}
.app-form {
>.ivu-row:nth-child(2) {
>.ivu-col:nth-child(1) {
>.ivu-row.app-form-group.app-group-hiddden-caption:nth-child(1) {
margin-top: 12px;
}
}
}
}
.app-form{
// 表单行间距
.app-form-item{
margin-bottom: 20px;
}
// 表单按钮margin
.app-form-button{
margin:0 6px;
}
}
// this is less
<script lang='tsx'>
import { Component } from 'vue-property-decorator';
import DynaInstBase from './dyna-inst-form-base.vue';
@Component({
components: {
}
})
export default class DynaInst extends DynaInstBase {
}
</script>
\ No newline at end of file
<template>
<i-form :model="this.data" class='app-form' ref='form' id='metadynamicmodel_main' style="" @on-validate="formItemValidate">
<input style="display:none;" />
<row >
<i-col v-show="detailsModel.group1.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<app-form-group :uiService="appUIService" :data="transformData(data)" :manageContainerStatus="detailsModel.group1.manageContainerStatus" :isManageContainer="detailsModel.group1.isManageContainer" @managecontainerclick="manageContainerClick('group1')" layoutType="TABLE_24COL" titleStyle="" class='' :uiActionGroup="detailsModel.group1.uiActionGroup" @groupuiactionclick="groupUIActionClick($event)" :caption="$t('entities.metadynamicmodel.main_form.details.group1')" :isShowCaption="true" uiStyle="DEFAULT" :titleBarCloseMode="0" :isInfoGroupMode="false" >
<row>
<i-col v-show="detailsModel.configname.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<app-form-item name='configname' :itemRules="this.rules().configname" class='' :caption="$t('entities.metadynamicmodel.main_form.details.configname')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.configname.error" :isEmptyCaption="false" labelPos="LEFT">
<input-box
v-model="data.configname"
@enter="onEnter($event)"
unit=""
:disabled="detailsModel.configname.disabled"
type='text'
style="">
</input-box>
</app-form-item>
</i-col>
<i-col v-show="detailsModel.formitem.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<app-form-item name='formitem' :itemRules="this.rules().formitem" class='' :caption="$t('entities.metadynamicmodel.main_form.details.formitem')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.formitem.error" :isEmptyCaption="false" labelPos="LEFT">
<app-file-upload :formState="formState" :ignorefieldvaluechange="ignorefieldvaluechange" @formitemvaluechange="onFormItemValueChange" :data="JSON.stringify(this.data)" name='formitem' :value="data.formitem" :disabled="detailsModel.formitem.disabled" :uploadparams='{}' :exportparams='{}' style="overflow: auto;"></app-file-upload>
</app-form-item>
</i-col>
</row>
</app-form-group>
</i-col>
</row>
</i-form>
</template>
<script lang='tsx'>
import { Vue, Component, Prop, Provide, Emit, Watch, Model,Inject } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util,ViewTool } from '@/utils';
import NavDataService from '@/service/app/navdata-service';
import AppCenterService from "@service/app/app-center-service";
import MetaDynamicModelEntityService from '@/service/meta-dynamic-model/meta-dynamic-model-service';
import MainService from './main-form-service';
import MetaDynamicModelUIService from '@/uiservice/meta-dynamic-model/meta-dynamic-model-ui-service';
import { FormButtonModel, FormPageModel, FormItemModel, FormDRUIPartModel, FormPartModel, FormGroupPanelModel, FormIFrameModel, FormRowItemModel, FormTabPageModel, FormTabPanelModel, FormUserControlModel } from '@/model/form-detail';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import schema from 'async-validator';
import { Environment } from '@/environments/environment';
@Component({
components: {
}
})
export default class MainBase extends Vue implements ControlInterface {
/**
* 名称
*
* @type {string}
* @memberof MainBase
*/
@Prop() public name?: string;
/**
* 视图通讯对象
*
* @type {Subject<ViewState>}
* @memberof MainBase
*/
@Prop() public viewState!: Subject<ViewState>;
/**
* 应用上下文
*
* @type {*}
* @memberof MainBase
*/
@Prop() public context!: any;
/**
* 视图参数
*
* @type {*}
* @memberof MainBase
*/
@Prop() public viewparams!: any;
/**
* 视图状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof MainBase
*/
public viewStateEvent: Subscription | undefined;
/**
* 获取部件类型
*
* @returns {string}
* @memberof MainBase
*/
public getControlType(): string {
return 'FORM'
}
/**
* 计数器服务对象集合
*
* @type {Array<*>}
* @memberof MainBase
*/
public counterServiceArray:Array<any> = [];
/**
* 建构部件服务对象
*
* @type {MainService}
* @memberof MainBase
*/
public service: MainService = new MainService({ $store: this.$store });
/**
* 实体服务对象
*
* @type {MetaDynamicModelService}
* @memberof MainBase
*/
public appEntityService: MetaDynamicModelEntityService = new MetaDynamicModelEntityService({ $store: this.$store });
/**
* 转化数据
*
* @param {any} args
* @memberof MainBase
*/
public transformData(args: any) {
let _this: any = this;
if(_this.service && _this.service.handleRequestData instanceof Function && _this.service.handleRequestData('transform',_this.context,args)){
return _this.service.handleRequestData('transform',_this.context,args)['data'];
}
}
/**
* 关闭视图
*
* @param {any} args
* @memberof MainBase
*/
public closeView(args: any): void {
let _this: any = this;
_this.$emit('closeview', [args]);
}
/**
* 计数器刷新
*
* @memberof MainBase
*/
public counterRefresh(){
const _this:any =this;
if(_this.counterServiceArray && _this.counterServiceArray.length >0){
_this.counterServiceArray.forEach((item:any) =>{
if(item.refreshData && item.refreshData instanceof Function){
item.refreshData();
}
})
}
}
/**
* 视图默认使用
*
* @type {string}
* @memberof MainBase
*/
@Inject({from:'navModel',default: 'tab'})
public navModel!:string;
/**
* 主键表单项名称
*
* @protected
* @type {string}
* @memberof MainBase
*/
public formKeyItemName: string = '';
/**
* 是否自动加载
*
* @type {boolean}
* @memberof MainBase
*/
@Prop({default:false}) public isautoload?:boolean;
/**
* 界面UI服务对象
*
* @type {MetaDynamicModelUIService}
* @memberof MainBase
*/
public appUIService:MetaDynamicModelUIService = new MetaDynamicModelUIService(this.$store);
/**
* 工作流审批意见控件绑定值
*
* @memberof MainBase
*/
public srfwfmemo:string = "";
/**
* 获取多项数据
*
* @returns {any[]}
* @memberof MainBase
*/
public getDatas(): any[] {
return [this.data];
}
/**
* 获取单项树
*
* @returns {*}
* @memberof MainBase
*/
public getData(): any {
return this.data;
}
/**
* 是否默认保存
*
* @type {boolean}
* @memberof MainBase
*/
@Prop({ default: false }) public autosave?: boolean;
/**
* 显示处理提示
*
* @type {boolean}
* @memberof MainBase
*/
@Prop({ default: true }) public showBusyIndicator?: boolean;
/**
* 部件行为--submit
*
* @type {string}
* @memberof MainBase
*/
@Prop() public WFSubmitAction!: string;
/**
* 部件行为--start
*
* @type {string}
* @memberof MainBase
*/
@Prop() public WFStartAction!: string;
/**
* 部件行为--update
*
* @type {string}
* @memberof MainBase
*/
@Prop() public updateAction!: string;
/**
* 部件行为--remove
*
* @type {string}
* @memberof MainBase
*/
@Prop() public removeAction!: string;
/**
* 部件行为--loaddraft
*
* @type {string}
* @memberof MainBase
*/
@Prop() public loaddraftAction!: string;
/**
* 部件行为--load
*
* @type {string}
* @memberof MainBase
*/
@Prop() public loadAction!: string;
/**
* 部件行为--create
*
* @type {string}
* @memberof MainBase
*/
@Prop() public createAction!: string;
/**
* 部件行为--create
*
* @type {string}
* @memberof MainBase
*/
@Prop() public searchAction!: string;
/**
* 视图标识
*
* @type {string}
* @memberof MainBase
*/
@Prop() public viewtag!: string;
/**
* 表单状态
*
* @type {Subject<any>}
* @memberof MainBase
*/
public formState: Subject<any> = new Subject();
/**
* 忽略表单项值变化
*
* @type {boolean}
* @memberof MainBase
*/
public ignorefieldvaluechange: boolean = false;
/**
* 数据变化
*
* @public
* @type {Subject<any>}
* @memberof MainBase
*/
public dataChang: Subject<any> = new Subject();
/**
* 视图状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof MainBase
*/
public dataChangEvent: Subscription | undefined;
/**
* 原始数据
*
* @public
* @type {*}
* @memberof MainBase
*/
public oldData: any = {};
/**
* 混入表单数据对象
*
* @type {*}
* @memberof MainBase
*/
public mixinData:any = {};
/**
* 表单项校验错误提示信息
*
* @memberof MainBase
*/
public errorMessages: Array<any> = [];
/**
* 应用状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof MainBase
*/
public appStateEvent: Subscription | undefined;
/**
* 设置表单项错误提示信息
*
* @param {*} prop 表单项字段名
* @param {*} status 校验状态
* @param {*} error 错误信息
* @memberof MainBase
*/
public formItemValidate(prop: string,status: boolean, error: string){
error = error ? error : '';
if(this.errorMessages && this.errorMessages.length > 0){
const index = this.errorMessages.findIndex((errorMessage:any) => Object.is(errorMessage.prop,prop));
if(index != -1){
this.errorMessages[index].error = error;
}else{
this.errorMessages.push({prop: prop,error: error});
}
}else{
this.errorMessages.push({prop: prop,error: error});
}
}
/**
* 表单数据对象
*
* @type {*}
* @memberof MainBase
*/
public data: any = {
srforikey: null,
srfkey: null,
srfmajortext: null,
srftempmode: null,
srfuf: null,
srfdeid: null,
srfsourcekey: null,
configname: null,
formitem: null,
systemid: null,
pdynainstid: null,
configid: null,
metadynamicmodel:null,
};
/**
* 当前执行的行为逻辑
*
* @type {string}
* @memberof MainBase
*/
public currentAction: string = "";
/**
* 关系界面计数器
*
* @type {number}
* @memberof MainBase
*/
public drcounter: number = 0;
/**
* 需要等待关系界面保存时,第一次调用save参数的备份
*
* @type {number}
* @memberof MainBase
*/
public drsaveopt: any = {};
/**
* 表单保存回调存储对象
*
* @type {any}
* @memberof MainBase
*/
public saveState:any ;
/**
* 主信息属性映射表单项名称
*
* @type {string}
* @memberof MainBase
*/
public majorMessageField: string = "configname";
/**
* 值规则
*
* @type {*}
* @memberof MainBase
*/
public rules() :any {
return {
configname: [
{ required: this.detailsModel.configname.required, type: 'string', message: '配置名称 值不能为空', trigger: 'change' },
{ required: this.detailsModel.configname.required, type: 'string', message: '配置名称 值不能为空', trigger: 'blur' },
],
formitem: [
{ required: this.detailsModel.formitem.required, type: 'string', message: '文件 值不能为空', trigger: 'change' },
{ required: this.detailsModel.formitem.required, type: 'string', message: '文件 值不能为空', trigger: 'blur' },
],
}
}
/**
* 属性值规则
*
* @type {*}
* @memberof MainBase
*/
public deRules(){
return {
}
}
/**
* 校验属性值规则
*
* @public
* @param {{ name: string }} { name }
* @memberof MainBase
*/
public verifyDeRules(name:string,rule:any = this.deRules(),op:string = "AND") :{isPast:boolean,infoMessage:string}{
let falg:any = {infoMessage:""};
if(!rule[name]){
return falg;
}
let opValue = op == 'AND'? true :false;
let startOp = (val:boolean)=>{
if(falg.isPast){
if(opValue){
falg.isPast = falg.isPast && val;
}else{
falg.isPast = falg.isPast || val;
}
}else{
falg.isPast = val;
}
}
for(let i=0;i<rule[name].length;i++){
let item:any = rule[name][i];
let dataValue = item.deName?this.data[this.service.getItemNameByDeName(item.deName)]:"";
item.ruleInfo = item.ruleInfo ? item.ruleInfo : this.$t('app.formpage.valuecheckex');
if((dataValue === null || dataValue === undefined || dataValue === "") && (item.type != 'GROUP')){
startOp(true);
return falg;
}
try {
// 常规规则
if(item.type == 'SIMPLE'){
startOp(!this.$verify.checkFieldSimpleRule(dataValue,item.condOP,item.paramValue,item.ruleInfo,item.paramType,this.data,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
if(!falg.isPast) return falg;
}
// 数值范围
if(item.type == 'VALUERANGE2'){
startOp( !this.$verify.checkFieldValueRangeRule(dataValue,item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
if(!falg.isPast) return falg;
}
// 正则式
if (item.type == "REGEX") {
startOp(!this.$verify.checkFieldRegExRule(dataValue,item.regExCode,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
if(!falg.isPast) return falg;
}
// 长度
if (item.type == "STRINGLENGTH") {
startOp(!this.$verify.checkFieldStringLengthRule(dataValue,item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
if(!falg.isPast) return falg;
}
// 系统值规则
if(item.type == "SYSVALUERULE") {
startOp(!this.$verify.checkFieldSysValueRule(dataValue,item.sysRule.regExCode,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
if(!falg.isPast) return falg;
}
} catch(error) {
falg.infoMessage = item.ruleInfo;
startOp(false);
if(!falg.isPast) return falg;
}
// 分组
if(item.type == 'GROUP'){
falg = this.verifyDeRules('group',item,item.condOP?item.condOP:"AND");
if(item.isNotMode){
falg.isPast = !falg.isPast;
}
if(!falg.isPast) return falg;
}
}
if(!falg.hasOwnProperty("isPast")){
falg.isPast = true;
}
if(!this.data[name] && this.data[name] != 0){
falg.isPast = true;
}
return falg;
}
/**
* 详情模型集合
*
* @type {*}
* @memberof MainBase
*/
public detailsModel: any = {
group1: new FormGroupPanelModel({ caption: '动态模型基本信息', detailType: 'GROUPPANEL', name: 'group1', visible: true, isShowCaption: true, form: this, isControlledContent: false , uiActionGroup: { caption: '', langbase: 'entities.metadynamicmodel.main_form', extractMode: 'ITEM', details: [] }, isManageContainer: false, showMoreModeItems: [] })
,
formpage1: new FormPageModel({ caption: '基本信息', detailType: 'FORMPAGE', name: 'formpage1', visible: true, isShowCaption: true, form: this, isControlledContent: false })
,
srforikey: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srforikey', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
srfkey: new FormItemModel({ caption: '配置标识', detailType: 'FORMITEM', name: 'srfkey', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
srfmajortext: new FormItemModel({ caption: '配置名称', detailType: 'FORMITEM', name: 'srfmajortext', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
srftempmode: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srftempmode', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
srfuf: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfuf', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
srfdeid: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfdeid', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
srfsourcekey: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfsourcekey', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
configname: new FormItemModel({ caption: '配置名称', detailType: 'FORMITEM', name: 'configname', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
formitem: new FormItemModel({ caption: '文件', detailType: 'FORMITEM', name: 'formitem', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:true, disabled: false, enableCond: 3 })
,
systemid: new FormItemModel({ caption: '系统', detailType: 'FORMITEM', name: 'systemid', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
pdynainstid: new FormItemModel({ caption: '父实例', detailType: 'FORMITEM', name: 'pdynainstid', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
configid: new FormItemModel({ caption: '配置标识', detailType: 'FORMITEM', name: 'configid', visible: true, isShowCaption: true, form: this, isControlledContent: false , required:false, disabled: false, enableCond: 3 })
,
};
/**
* 监控表单属性 srforikey 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MainBase
*/
@Watch('data.srforikey')
onSrforikeyChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srforikey', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srfkey 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MainBase
*/
@Watch('data.srfkey')
onSrfkeyChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfkey', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srfmajortext 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MainBase
*/
@Watch('data.srfmajortext')
onSrfmajortextChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfmajortext', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srftempmode 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MainBase
*/
@Watch('data.srftempmode')
onSrftempmodeChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srftempmode', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srfuf 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MainBase
*/
@Watch('data.srfuf')
onSrfufChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfuf', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srfdeid 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MainBase
*/
@Watch('data.srfdeid')
onSrfdeidChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfdeid', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srfsourcekey 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MainBase
*/
@Watch('data.srfsourcekey')
onSrfsourcekeyChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfsourcekey', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 configname 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MainBase
*/
@Watch('data.configname')
onConfignameChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'configname', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 formitem 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MainBase
*/
@Watch('data.formitem')
onFormitemChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'formitem', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 systemid 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MainBase
*/
@Watch('data.systemid')
onSystemidChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'systemid', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 pdynainstid 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MainBase
*/
@Watch('data.pdynainstid')
onPdynainstidChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'pdynainstid', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 configid 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MainBase
*/
@Watch('data.configid')
onConfigidChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'configid', newVal: newVal, oldVal: oldVal });
}
/**
* 显示更多模式切换操作
*
* @type {string}
* @memberof MainBase
*/
public manageContainerClick(name: string){
let model = this.detailsModel[name];
if(model.isManageContainer){
model.setManageContainerStatus(!model.manageContainerStatus);
model.showMoreModeItems.forEach((item:any) => {
if(this.detailsModel[item].isControlledContent){
this.detailsModel[item].setVisible(model.manageContainerStatus? this.detailsModel[item].oldVisible : false);
}
});
}
}
/**
* 重置表单项值
*
* @public
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @memberof MainBase
*/
public resetFormData({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
}
/**
* 置空对象
*
* @param {any[]} args
* @memberof MainBase
*/
public ResetData(_datas:any){
if(Object.keys(_datas).length >0){
Object.keys(_datas).forEach((name: string) => {
if (this.data.hasOwnProperty(name)) {
this.data[name] = null;
}
});
}
}
/**
* 表单逻辑
*
* @public
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @memberof MainBase
*/
public async formLogic({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }){
}
/**
* 表单项检查逻辑
*
* @public
* @param name 属性名
* @memberof MainBase
*/
public checkItem(name:string):Promise<any> {
return new Promise((resolve, reject) => {
var validator = new schema({[name]:this.rules()[name]});
validator.validate({[name]:this.data[name]}).then(()=>{
resolve(true);
})
.catch(() => {
resolve(false);
});;
})
}
/**
* 表单值变化
*
* @public
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @returns {void}
* @memberof MainBase
*/
public formDataChange({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
if (this.ignorefieldvaluechange) {
return;
}
this.resetFormData({ name: name, newVal: newVal, oldVal: oldVal });
this.formLogic({ name: name, newVal: newVal, oldVal: oldVal });
this.dataChang.next(JSON.stringify(this.data));
}
/**
* 表单加载完成
*
* @public
* @param {*} [data={}]
* @param {string} [action]
* @memberof MainBase
*/
public onFormLoad(data: any = {},action:string): void {
if(Object.is(action,"save") || Object.is(action,"autoSave") || Object.is(action,"submit"))
// 更新context的实体主键
if(data.metadynamicmodel){
Object.assign(this.context,{metadynamicmodel:data.metadynamicmodel})
}
this.setFormEnableCond(data);
this.computeButtonState(data);
this.fillForm(data,action);
this.oldData = {};
Object.assign(this.oldData, JSON.parse(JSON.stringify(this.data)));
this.$store.commit('viewaction/setViewDataChange', { viewtag: this.viewtag, viewdatachange: false });
this.formLogic({ name: '', newVal: null, oldVal: null });
}
/**
* 值填充
*
* @param {*} [_datas={}]
* @param {string} [action]
* @memberof MainBase
*/
public fillForm(_datas: any = {},action:string): void {
this.mixinData = _datas;
this.ignorefieldvaluechange = true;
Object.keys(_datas).forEach((name: string) => {
if (this.data.hasOwnProperty(name)) {
this.data[name] = _datas[name];
}
});
if(Object.is(action,'loadDraft')){
this.createDefault();
}
if(Object.is(action,'load')){
this.updateDefault();
}
this.$nextTick(function () {
this.ignorefieldvaluechange = false;
})
}
/**
* 设置表单项是否启用
*
* @public
* @param {*} data
* @memberof MainBase
*/
public setFormEnableCond(data: any): void {
Object.values(this.detailsModel).forEach((detail: any) => {
if (!Object.is(detail.detailType, 'FORMITEM')) {
return;
}
const formItem: FormItemModel = detail;
formItem.setEnableCond(data.srfuf);
});
}
/**
* 重置草稿表单状态
*
* @public
* @memberof MainBase
*/
public resetDraftFormStates(): void {
const form: any = this.$refs.form;
if (form) {
form.resetFields();
}
}
/**
* 重置校验结果
*
* @memberof MainBase
*/
public resetValidates(): void {
Object.values(this.detailsModel).forEach((detail: any) => {
if (!Object.is(detail.detailType, 'FORMITEM')) {
return;
}
const formItem: FormItemModel = detail;
formItem.setError('');
});
}
/**
* 填充校验结果 (后台)
*
* @param {any[]} fieldErrors
* @memberof MainBase
*/
public fillValidates(fieldErrors: any[]): void {
fieldErrors.forEach((error: any) => {
const formItem: FormItemModel = this.detailsModel[error.field];
if (!formItem) {
return;
}
this.$nextTick(() => {
formItem.setError(error.message);
});
});
}
/**
* 表单校验状态
*
* @returns {boolean}
* @memberof MainBase
*/
public formValidateStatus(): boolean {
const form: any = this.$refs.form;
let validatestate: boolean = true;
form.validate((valid: boolean) => {
validatestate = valid ? true : false;
});
return validatestate
}
/**
* 获取全部值
*
* @returns {*}
* @memberof MainBase
*/
public getValues(): any {
return this.data;
}
/**
* 表单项值变更
*
* @param {{ name: string, value: any }} $event
* @returns {void}
* @memberof MainBase
*/
public onFormItemValueChange($event: { name: string, value: any }): void {
if (!$event) {
return;
}
if (!$event.name || Object.is($event.name, '') || !this.data.hasOwnProperty($event.name)) {
return;
}
this.data[$event.name] = $event.value;
}
/**
* 编辑器行为触发
*
* @param {*} arg
* @returns {void}
* @memberof MainBase
*/
public onFormItemActionClick(arg:any){
if(arg && (arg instanceof Function)) arg();
}
/**
* 设置数据项值
*
* @param {string} name
* @param {*} value
* @returns {void}
* @memberof MainBase
*/
public setDataItemValue(name: string, value: any): void {
if (!name || Object.is(name, '') || !this.data.hasOwnProperty(name)) {
return;
}
if (Object.is(this.data[name], value)) {
return;
}
this.data[name] = value;
}
/**
* 计算表单按钮权限状态
*
* @param {*} [data] 传入数据
* @memberof MainBase
*/
public computeButtonState(data:any){
let targetData:any = this.transformData(data);
if(this.detailsModel && Object.keys(this.detailsModel).length >0){
Object.keys(this.detailsModel).forEach((name:any) =>{
if(this.detailsModel[name] && this.detailsModel[name].uiaction && this.detailsModel[name].uiaction.dataaccaction && Object.is(this.detailsModel[name].detailType,"BUTTON")){
this.detailsModel[name].isPower = true;
let tempUIAction:any = JSON.parse(JSON.stringify(this.detailsModel[name].uiaction));
let result: any[] = ViewTool.calcActionItemAuthState(targetData,[tempUIAction],this.appUIService);
this.detailsModel[name].visible = tempUIAction.visabled;
this.detailsModel[name].disabled = tempUIAction.disabled;
this.detailsModel[name].isPower = result[0] === 1 ? true : false;
}
})
}
}
/**
* 分组界面行为事件
*
* @param {*} $event
* @memberof MainBase
*/
public groupUIActionClick($event: any): void {
if (!$event) {
return;
}
const item:any = $event.item;
}
/**
* Vue声明周期(处理组件的输入属性)
*
* @memberof MainBase
*/
public created(): void {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
* @memberof MainBase
*/
public afterCreated(){
if(this.isautoload){
this.autoLoad({srfkey:this.context.metadynamicmodel});
}
if (this.viewState) {
this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
if (!Object.is(tag, this.name)) {
return;
}
if (Object.is('autoload', action)) {
this.autoLoad(data);
}
if (Object.is('load', action)) {
this.load(data);
}
if (Object.is('loaddraft', action)) {
this.loadDraft(data);
}
if (Object.is('save', action)) {
this.save(data,data.showResultInfo);
}
if (Object.is('remove', action)) {
this.remove(data);
}
if (Object.is('saveandexit', action)) {
this.saveAndExit(data);
}
if (Object.is('saveandnew', action)) {
this.saveAndNew(data);
}
if (Object.is('removeandexit', action)) {
this.removeAndExit(data);
}
if (Object.is('refresh', action)) {
this.refresh(data);
}
if (Object.is('panelaction', action)) {
this.panelAction(data.action,data.emitAction,data.data);
}
});
}
this.dataChang
.pipe(
debounceTime(300),
distinctUntilChanged()
).subscribe((data: any) => {
if (this.autosave) {
this.autoSave();
}
const state = !Object.is(JSON.stringify(this.oldData), JSON.stringify(this.data)) ? true : false;
this.$store.commit('viewaction/setViewDataChange', { viewtag: this.viewtag, viewdatachange: state });
});
}
/**
* vue 生命周期
*
* @memberof MainBase
*/
public destroyed() {
this.afterDestroy();
}
/**
* 执行destroyed后的逻辑
*
* @memberof MainBase
*/
public afterDestroy() {
if (this.viewStateEvent) {
this.viewStateEvent.unsubscribe();
}
if (this.dataChangEvent) {
this.dataChangEvent.unsubscribe();
}
if(this.appStateEvent){
this.appStateEvent.unsubscribe();
}
}
/**
*打印
*@memberof @memberof MainBase
*/
public print(){
let _this:any = this;
_this.$print({id:'metadynamicmodel_main',popTitle:'主编辑表单'});
}
/**
* 部件刷新
*
* @param {any} args
* @memberof MainBase
*/
public refresh(args?: any): void {
let arg: any = {};
Object.assign(arg,args?args[0]:{});
if (this.data.srfkey && !Object.is(this.data.srfkey, '')) {
Object.assign(arg, { srfkey: this.data.srfkey });
this.load(arg);
return;
}
if (this.data.srfkeys && !Object.is(this.data.srfkeys, '')) {
Object.assign(arg, { srfkey: this.data.srfkeys });
this.load(arg);
return;
}
}
/**
* 自动加载
*
* @param {*} [arg={}]
* @returns {void}
* @memberof MainBase
*/
public autoLoad(arg: any = {}): void {
if (arg.srfkey && !Object.is(arg.srfkey, '')) {
Object.assign(arg, { srfkey: arg.srfkey });
this.load(arg);
return;
}
if (arg.srfkeys && !Object.is(arg.srfkeys, '')) {
Object.assign(arg, { srfkey: arg.srfkeys });
this.load(arg);
return;
}
this.loadDraft(arg);
}
/**
* 加载
*
* @public
* @param {*} [opt={}]
* @memberof MainBase
*/
public load(opt: any = {}): void {
if(!this.loadAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelEditView' + (this.$t('app.formpage.notconfig.loadaction') as string) });
return;
}
const arg: any = { ...opt };
let viewparamResult:any = Object.assign(arg,this.viewparams);
const get: Promise<any> = this.service.get(this.loadAction,JSON.parse(JSON.stringify(this.context)),{viewparams:viewparamResult}, this.showBusyIndicator);
get.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
this.onFormLoad(data,'load');
this.$emit('load', data);
this.$nextTick(() => {
this.formState.next({ type: 'load', data: data });
});
}
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
return;
}
});
}
/**
* 加载草稿
*
* @param {*} [opt={}]
* @memberof MainBase
*/
public loadDraft(opt: any = {}): void {
if(!this.loaddraftAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelEditView' + (this.$t('app.formpage.notconfig.loaddraftaction') as string) });
return;
}
const arg: any = { ...opt } ;
let viewparamResult:any = Object.assign(arg,this.viewparams);
let post: Promise<any> = this.service.loadDraft(this.loaddraftAction,JSON.parse(JSON.stringify(this.context)),{viewparams:viewparamResult}, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
return;
}
const data = response.data;
this.resetDraftFormStates();
this.onFormLoad(data,'loadDraft');
data.metadynamicmodel = null;
this.$emit('load', data);
this.$nextTick(() => {
this.formState.next({ type: 'load', data: data });
});
setTimeout(() => {
const form: any = this.$refs.form;
if (form) {
form.fields.forEach((field: any) => {
field.validateMessage = "";
field.validateState = "";
field.validateStatus = false;
});
}
});
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
return;
}
});
}
/**
* 自动保存
*
* @param {*} [opt={}]
* @memberof MainBase
*/
public autoSave(opt: any = {}): void {
if (!this.formValidateStatus()) {
return;
}
const arg: any = { ...opt };
const data = this.getValues();
Object.assign(arg, data);
Object.assign(arg,{srfmajortext:data[this.majorMessageField]});
const action: any = Object.is(data.srfuf, '1') ? this.updateAction : this.createAction;
if(!action){
let actionName:any = Object.is(data.srfuf, '1')?"updateAction":"createAction";
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelEditView' + (this.$t('app.formpage.notconfig.actionname') as string) });
return;
}
Object.assign(arg,{viewparams:this.viewparams});
const post: Promise<any> = this.service.add(action, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
return;
}
const data = response.data;
this.onFormLoad(data,'autoSave');
this.$emit('save', data);
AppCenterService.notifyMessage({name:"MetaDynamicModel",action:'appRefresh',data:data});
this.$nextTick(() => {
this.formState.next({ type: 'save', data: data });
});
}).catch((response: any) => {
if (response && response.status && response.data) {
if (response.data.errorKey) {
if(Object.is(response.data.errorKey, "versionCheck")) {
this.$Modal.confirm({
title: (this.$t('app.formpage.saveerror') as string),
content: (this.$t('app.formpage.savecontent') as string),
onOk: () => {
this.refresh([]);
},
onCancel: () => { }
});
} else if(Object.is(response.data.errorKey, 'DupCheck')) {
let errorProp: string = response.data.message.match(/\[[a-zA-Z]*\]/)[0];
let name: string = this.service.getNameByProp(errorProp.substr(1, errorProp.length-2));
if(name) {
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: this.detailsModel[name].caption + " : " + arg[name] + (this.$t('app.commonWords.isExist') as string) + '!',
});
} else {
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: response.data.message?response.data.message:(this.$t('app.commonWords.sysException') as string),
})
}
}else if(Object.is(response.data.errorKey, 'DuplicateKeyException')){
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: this.detailsModel[this.formKeyItemName].caption + " : " + arg[this.formKeyItemName] + (this.$t('app.commonWords.isExist') as string) + '!',
});
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message?response.data.message:(this.$t('app.commonWords.sysException') as string) });
}
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message?response.data.message:(this.$t('app.commonWords.sysException') as string) });
}
return;
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
}
});
}
/**
* 保存
*
* @param {*} [opt={}]
* @param {boolean} [showResultInfo]
* @param {boolean} [ifStateNext] formState是否下发通知
* @returns {Promise<any>}
* @memberof MainBase
*/
public async save(opt: any = {}, showResultInfo?: boolean, ifStateNext: boolean = true): Promise<any> {
return new Promise((resolve: any, reject: any) => {
showResultInfo = showResultInfo === undefined ? true : false;
if (!this.formValidateStatus()) {
if(this.errorMessages && this.errorMessages.length > 0) {
let descMessage: string = '';
this.errorMessages.forEach((message: any) => {
descMessage = descMessage + '<p>' + message.error + '<p>';
})
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: descMessage });
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.formpage.valuecheckex') as string) });
}
return;
}
const arg: any = { ...opt };
const data = this.getValues();
Object.assign(arg, this.context);
Object.assign(arg, data);
Object.assign(arg,{srfmajortext:data[this.majorMessageField]});
if (ifStateNext) {
this.drcounter = 0;
if(this.drcounter !== 0){
this.drsaveopt = opt;
this.formState.next({ type: 'beforesave', data: arg });//先通知关系界面保存
this.saveState = resolve;
return;
}
}
if(this.viewparams && this.viewparams.copymode){
data.srfuf = '0';
}
const action: any = Object.is(data.srfuf, '1') ? this.updateAction : this.createAction;
if(!action){
let actionName:any = Object.is(data.srfuf, '1')?"updateAction":"createAction";
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelEditView' + (this.$t('app.formpage.notconfig.actionname') as string) });
return;
}
Object.assign(arg,{viewparams:this.viewparams});
const post: Promise<any> = Object.is(data.srfuf, '1')?this.service.update(action, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator):this.service.add(action,JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
return;
}
this.viewparams.copymode = false;
const data = response.data;
this.onFormLoad(data,'save');
this.$emit('save', data);
AppCenterService.notifyMessage({name:"MetaDynamicModel",action:'appRefresh',data:data});
this.$nextTick(() => {
this.formState.next({ type: 'save', data: data });
});
if (showResultInfo) {
this.$Notice.success({ title: '', desc: (data.srfmajortext ? data.srfmajortext : '') + '&nbsp;'+ (this.$t('app.formpage.savesuccess') as string) });
}
resolve(response);
}).catch((response: any) => {
if (response && response.status && response.data) {
if (response.data.errorKey) {
if(Object.is(response.data.errorKey, "versionCheck")) {
this.$Modal.confirm({
title: (this.$t('app.formpage.saveerror') as string),
content: (this.$t('app.formpage.savecontent') as string),
onOk: () => {
this.refresh([]);
},
onCancel: () => { }
});
} else if(Object.is(response.data.errorKey, 'DupCheck')) {
let errorProp: string = response.data.message.match(/\[[a-zA-Z]*\]/)[0];
let name: string = this.service.getNameByProp(errorProp.substr(1, errorProp.length-2));
if(name) {
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: this.detailsModel[name].caption + " : " + arg[name] + (this.$t('app.commonWords.isExist') as string) + '!',
});
} else {
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: response.data.message,
})
}
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
reject(response);
}
return;
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
reject(response);
}
reject(response);
});
})
}
/**
* 删除
*
* @public
* @param {*} [opt={}]
* @memberof MainBase
*/
public remove(opt:Array<any> = [],showResultInfo?: boolean): Promise<any> {
return new Promise((resolve: any, reject: any) => {
if(!this.removeAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelEditView' + (this.$t('app.formpage.notconfig.removeaction') as string) });
return;
}
const arg: any = opt[0];
const _this: any = this;
Object.assign(arg,{viewparams:this.viewparams});
this.service.delete(_this.removeAction, JSON.parse(JSON.stringify(this.context)),arg, showResultInfo).then((response: any) => {
if (response) {
const data = response.data;
this.$emit('remove',data);
this.formState.next({ type: 'remove', data: data });
this.data.ismodify = false;
this.$Notice.success({ title: '', desc: (data.srfmajortext ? data.srfmajortext : '') + '&nbsp;' + (this.$t('app.formpage.deletesuccess') as string) });
AppCenterService.notifyMessage({name:"MetaDynamicModel",action:'appRefresh',data:data});
resolve(response);
}
}).catch((error: any) => {
const { data: _data } = error;
this.$Notice.error({ title: _data.title, desc: _data.message });
reject(error);
});
});
}
/**
* 工作流启动
*
* @param {*} [data={}]
* @param {*} [localdata={}]
* @returns {Promise<any>}
* @memberof MainBase
*/
public async wfstart(data: any,localdata?:any): Promise<any> {
return new Promise((resolve: any, reject: any) => {
const _this: any = this;
const formData:any = this.getData();
const copyData:any = Util.deepCopy(formData);
const post: Promise<any> = Object.is(formData.srfuf, '1')?this.service.update(this.updateAction, JSON.parse(JSON.stringify(this.context)),formData, this.showBusyIndicator,true):this.service.add(this.createAction,JSON.parse(JSON.stringify(this.context)),formData, this.showBusyIndicator,true);
post.then((response:any) =>{
const responseData:any = response.data;
let tempResponseData:any = Util.deepCopy(response);
this.service.handleResponse('save', tempResponseData);
const arg:any = tempResponseData.data;
// 保存完成UI处理
this.onFormLoad(arg,'save');
this.$emit('save', arg);
AppCenterService.notifyMessage({name:"MetaDynamicModel",action:'appRefresh',data:data});
this.$nextTick(() => {
this.formState.next({ type: 'save', data: arg });
});
// 准备工作流数据,填充未存库数据
Object.assign(arg,copyData);
// 准备提交参数
if(this.viewparams){
let copyViewParams:any = Util.deepCopy(this.viewparams);
if(copyViewParams.w){
delete copyViewParams.w;
}
Object.assign(responseData,copyViewParams);
}
Object.assign(arg,{viewparams:responseData});
// 强制补充srfwfmemo
if(this.srfwfmemo){
Object.assign(arg,{srfwfmemo:this.srfwfmemo});
}
const result: Promise<any> = this.service.wfstart(_this.WFStartAction, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator,localdata);
result.then((response: any) => {
if (!response || response.status !== 200) {
if(response.data){
this.$Notice.error({ title: '', desc: (this.$t('app.formpage.workflow.starterror') as string) + ', ' + response.data.message });
}
return;
}
this.$Notice.info({ title: '', desc: (this.$t('app.formpage.workflow.startsuccess') as string) });
resolve(response);
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
reject(response);
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
reject(response);
return;
}
reject(response);
});
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
reject(response);
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
reject(response);
return;
}
reject(response);
})
});
}
/**
* 工作流提交
*
* @param {*} [data={}]
* @param {*} [localdata={}]
* @returns {Promise<any>}
* @memberof MainBase
*/
public async wfsubmit(data: any,localdata?:any): Promise<any> {
return new Promise((resolve: any, reject: any) => {
const _this: any = this;
const arg: any = data[0];
const copyData:any = Util.deepCopy(arg);
Object.assign(arg,{viewparams:this.viewparams});
if (!arg.metadynamicmodel || Object.is(arg.metadynamicmodel, '')) {
return;
}
const post: Promise<any> = Object.is(arg.srfuf, '1')?this.service.update(this.updateAction, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator,true):this.service.add(this.createAction,JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator,true);
post.then((response:any) =>{
const responseData:any = response.data;
let tempResponseData:any = Util.deepCopy(response);
this.service.handleResponse('save', tempResponseData);
const arg:any = tempResponseData.data;
// 保存完成UI处理
this.onFormLoad(arg,'save');
this.$emit('save', arg);
AppCenterService.notifyMessage({name:"MetaDynamicModel",action:'appRefresh',data:data});
this.$nextTick(() => {
this.formState.next({ type: 'save', data: arg });
});
// 准备工作流数据,填充未存库数据
Object.assign(arg,copyData);
// 准备提交参数
if(this.viewparams){
Object.assign(responseData,this.viewparams);
}
Object.assign(arg,{viewparams:responseData});
// 强制补充srfwfmemo
if(this.srfwfmemo){
Object.assign(arg,{srfwfmemo:this.srfwfmemo});
}
const result: Promise<any> = this.service.wfsubmit(_this.WFSubmitAction, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator,localdata);
result.then((response: any) => {
if (!response || response.status !== 200) {
if(response.data){
this.$Notice.error({ title: '', desc: (this.$t('app.formpage.workflow.submiterror') as string) + ', ' + response.data.message });
}
return;
}
this.onFormLoad(arg,'submit');
this.$store.dispatch('viewaction/datasaved', { viewtag: this.viewtag });
this.$Notice.info({ title: '', desc: (this.$t('app.formpage.workflow.submitsuccess') as string) });
resolve(response);
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
reject(response);
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
reject(response);
return;
}
reject(response);
});
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
reject(response);
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
reject(response);
return;
}
reject(response);
})
})
}
/**
* 面板行为
*
* @param {string} [action] 调用的实体行为
* @param {string} [emitAction] 抛出行为
* @param {*} [data={}] 传入数据
* @param {boolean} [showloading] 是否显示加载状态
*
* @memberof MainBase
*/
public panelAction(action:string,emitAction:string,data:any ={},showloading?:boolean):void{
if (!action || (action && Object.is(action, ''))) {
return;
}
const arg: any = { ...data };
const formdata = this.getValues();
Object.assign(arg, formdata);
Object.assign(arg,this.viewparams);
const post: Promise<any> = this.service.frontLogic(action,JSON.parse(JSON.stringify(this.context)),arg, showloading);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
}
return;
}
const data = response.data;
this.onFormLoad(data,emitAction);
this.$emit(emitAction, data);
this.$nextTick(() => {
this.formState.next({ type: emitAction, data: data });
});
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
return;
}
});
}
/**
* 表单项更新
*
* @param {string} mode 界面行为名称
* @param {*} [data={}] 请求数据
* @param {string[]} updateDetails 更新项
* @param {boolean} [showloading] 是否显示加载状态
* @returns {void}
* @memberof MainBase
*/
public updateFormItems(mode: string, data: any = {}, updateDetails: string[], showloading?: boolean): void {
if (!mode || (mode && Object.is(mode, ''))) {
return;
}
const arg: any = { ...data };
Object.assign(arg,this.viewparams);
const post: Promise<any> = this.service.frontLogic(mode,JSON.parse(JSON.stringify(this.context)),arg, showloading);
post.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.formpage.updateerror') as string) });
return;
}
const data = response.data;
const _data: any = {};
updateDetails.forEach((name: string) => {
if (!data.hasOwnProperty(name)) {
return;
}
Object.assign(_data, { [name]: data[name] });
});
this.setFormEnableCond(_data);
this.fillForm(_data,'updateFormItem');
this.formLogic({ name: '', newVal: null, oldVal: null });
this.dataChang.next(JSON.stringify(this.data));
AppCenterService.notifyMessage({name:"MetaDynamicModel",action:'appRefresh',data:data});
this.$nextTick(() => {
this.formState.next({ type: 'updateformitem', ufimode: arg.srfufimode, data: _data });
});
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
return;
}
});
}
/**
* 回车事件
*
* @param {*} $event
* @memberof MainBase
*/
public onEnter($event: any): void {
}
/**
* 保存并退出
*
* @param {any[]} args
* @memberof MainBase
*/
public saveAndExit(data:any[]):Promise<any>{
let _this = this;
return new Promise((resolve: any, reject: any) =>{
let arg: any = {};
if(data && data.length > 0){
Object.assign(arg,data[0]);
}
_this.currentAction = "saveAndExit";
_this.save([arg]).then((res) =>{
if(res){
_this.closeView(res.data);
}
resolve(res);
}).catch((error) =>{
reject(error);
})
})
}
/**
* 保存并新建
*
* @param {any[]} args
* @memberof MainBase
*/
public saveAndNew(data:any[]):Promise<any>{
let _this = this;
return new Promise((resolve: any, reject: any) =>{
let arg: any = {};
if(data && data.length > 0){
Object.assign(arg,data[0]);
}
_this.currentAction = "saveAndNew";
_this.save([arg]).then((res) =>{
_this.ResetData(res);
_this.loadDraft({});
}).catch((error) =>{
reject(error);
})
})
}
/**
* 删除并退出
*
* @param {any[]} args
* @memberof MainBase
*/
public removeAndExit(data:any[]):Promise<any>{
let _this = this;
return new Promise((resolve: any, reject: any) =>{
let arg: any = {};
if(data && data.length > 0){
Object.assign(arg,data[0]);
}
_this.remove([arg]).then((res) =>{
if(res){
_this.closeView(res.data);
}
resolve(res);
}).catch((error) =>{
reject(error);
})
})
}
/**
* 关系界面数据保存完成
*
* @param {any} $event
* @memberof MainBase
*/
public drdatasaved($event:any){
let _this = this;
this.drcounter--;
if(this.drcounter === 0){
this.save(this.drsaveopt, undefined, false).then((res) =>{
this.saveState(res);
this.drsaveopt = {};
if(Object.is(_this.currentAction, "saveAndNew")){
_this.ResetData(res);
_this.loadDraft({});
}else if(Object.is(_this.currentAction, "saveAndExit")){
if(res){
_this.closeView(res.data);
}
}
});
}
}
/**
* 新建默认值
* @memberof MainBase
*/
public createDefault(){
if (this.data.hasOwnProperty('systemid')) {
this.data['systemid'] = this.context['sysid'];
}
if (this.data.hasOwnProperty('pdynainstid')) {
this.data['pdynainstid'] = this.context['pinstid'];
}
}
/**
* 更新默认值
* @memberof MainBase
*/
public updateDefault(){
}
/**
* 面板数据变化处理事件
* @param {any} item 当前列数据
* @param {any} $event 面板事件数据
*
* @memberof MainBase
*/
public onPanelDataChange(item:any,$event:any) {
Object.assign(item, $event, {rowDataState:'update'});
}
}
</script>
<style lang='less'>
@import './main-form.less';
</style>
\ No newline at end of file
/**
* Main 部件模型
*
* @export
* @class MainModel
*/
export default class MainModel {
/**
* 获取数据项集合
*
* @returns {any[]}
* @memberof MainModel
*/
public getDataItems(): any[] {
return [
{
name: 'srfwfmemo',
prop: 'srfwfmemo',
dataType: 'TEXT',
},
// 前端新增修改标识,新增为"0",修改为"1"或未设值
{
name: 'srffrontuf',
prop: 'srffrontuf',
dataType: 'TEXT',
},
{
name: 'srforikey',
},
{
name: 'srfkey',
prop: 'configid',
dataType: 'TEXT',
},
{
name: 'srfmajortext',
prop: 'configname',
dataType: 'TEXT',
},
{
name: 'srftempmode',
},
{
name: 'srfuf',
},
{
name: 'srfdeid',
},
{
name: 'srfsourcekey',
},
{
name: 'configname',
prop: 'configname',
dataType: 'TEXT',
},
{
name: 'formitem',
prop: 'modelfile',
dataType: 'TEXT',
},
{
name: 'systemid',
prop: 'system_id',
dataType: 'TEXT',
},
{
name: 'pdynainstid',
prop: 'pdynainstid',
dataType: 'PICKUP',
},
{
name: 'configid',
prop: 'configid',
dataType: 'TEXT',
},
{
name: 'metadynamicmodel',
prop: 'configid',
dataType: 'FONTKEY',
},
]
}
}
\ No newline at end of file
import { Http,Util,Errorlog } from '@/utils';
import ControlService from '@/widgets/control-service';
import MetaDynamicModelService from '@/service/meta-dynamic-model/meta-dynamic-model-service';
import MainModel from './main-form-model';
/**
* Main 部件服务对象
*
* @export
* @class MainService
*/
export default class MainService extends ControlService {
/**
* 动态模型服务对象
*
* @type {MetaDynamicModelService}
* @memberof MainService
*/
public appEntityService: MetaDynamicModelService = new MetaDynamicModelService({ $store: this.getStore() });
/**
* 设置从数据模式
*
* @type {boolean}
* @memberof MainService
*/
public setTempMode(){
this.isTempMode = false;
}
/**
* Creates an instance of MainService.
*
* @param {*} [opts={}]
* @memberof MainService
*/
constructor(opts: any = {}) {
super(opts);
this.model = new MainModel();
}
/**
* 远端数据
*
* @type {*}
* @memberof MainService
*/
private remoteCopyData:any = {};
/**
* 处理数据
*
* @private
* @param {Promise<any>} promise
* @returns {Promise<any>}
* @memberof MainService
*/
private doItems(promise: Promise<any>, deKeyField: string, deName: string): Promise<any> {
return new Promise((resolve, reject) => {
promise.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
data.forEach((item:any,index:number) =>{
item[deName] = item[deKeyField];
data[index] = item;
});
resolve(data);
} else {
reject([])
}
}).catch((response: any) => {
reject([])
});
});
}
/**
* 获取跨实体数据集合
*
* @param {string} serviceName 服务名称
* @param {string} interfaceName 接口名称
* @param {*} data
* @param {boolean} [isloading]
* @returns {Promise<any[]>}
* @memberof MainService
*/
@Errorlog
public getItems(serviceName: string, interfaceName: string, context: any = {}, data: any, isloading?: boolean): Promise<any[]> {
data.page = data.page ? data.page : 0;
data.size = data.size ? data.size : 1000;
return Promise.reject([])
}
/**
* 启动工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @param {*} [localdata]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public wfstart(action: string,context: any = {},data: any = {}, isloading?: boolean,localdata?:any): Promise<any> {
data = this.handleWFData(data,true);
context = this.handleRequestData(action,context,data).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,data, isloading,localdata);
} else {
result = this.appEntityService.WFStart(context,data, isloading,localdata);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 提交工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @param {*} [localdata]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public wfsubmit(action: string,context: any = {}, data: any = {}, isloading?: boolean,localdata?:any): Promise<any> {
data = this.handleWFData(data,true);
context = this.handleRequestData(action,context,data,true).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,data, isloading,localdata);
} else {
result = this.appEntityService.WFSubmit(context,data, isloading,localdata);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 添加数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @param {boolean} [isWorkflow] 是否在工作流中添加数据
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public add(action: string, context: any = {},data: any = {}, isloading?: boolean,isWorkflow?:boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Create(Context,Data, isloading);
}
result.then((response) => {
if(isWorkflow){
resolve(response);
}else{
this.handleResponse(action, response);
resolve(response);
}
}).catch(response => {
reject(response);
});
});
}
/**
* 删除数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public delete(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Remove(Context,Data, isloading);
}
result.then((response) => {
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 修改数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @param {boolean} [isWorkflow] 是否在工作流中修改数据
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public update(action: string, context: any = {},data: any = {}, isloading?: boolean,isWorkflow?:boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Update(Context,Data, isloading);
}
result.then((response) => {
if(isWorkflow){
resolve(response);
}else{
this.handleResponse(action, response);
resolve(response);
}
}).catch(response => {
reject(response);
});
});
}
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public get(action: string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Get(Context,Data, isloading);
}
result.then((response) => {
this.setRemoteCopyData(response);
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 加载草稿
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public loadDraft(action: string,context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
//仿真主键数据
const PrimaryKey = Util.createUUID();
Data.configid = PrimaryKey;
Data.metadynamicmodel = PrimaryKey;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.GetDraft(Context,Data, isloading);
}
result.then((response) => {
this.setRemoteCopyData(response);
response.data.configid = PrimaryKey;
this.handleResponse(action, response, true);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 前台逻辑
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public frontLogic(action:string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any)=>{
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
return Promise.reject({ status: 500, data: { title: '失败', message: '系统异常' } });
}
result.then((response) => {
this.handleResponse(action, response,true);
resolve(response);
}).catch(response => {
reject(response);
});
})
}
/**
* 处理请求数据
*
* @param action 行为
* @param data 数据
* @memberof MainService
*/
public handleRequestData(action: string,context:any, data: any = {},isMerge:boolean = false){
let mode: any = this.getMode();
if (!mode && mode.getDataItems instanceof Function) {
return data;
}
let formItemItems: any[] = mode.getDataItems();
let requestData:any = {};
if(isMerge && (data && data.viewparams)){
Object.assign(requestData,data.viewparams);
}
formItemItems.forEach((item:any) =>{
if(item && item.dataType && Object.is(item.dataType,'FONTKEY')){
if(item && item.prop){
requestData[item.prop] = context[item.name];
}
}else{
if(item && item.prop){
requestData[item.prop] = data[item.name];
}else{
if(item.dataType && Object.is(item.dataType,"FORMPART")){
Object.assign(requestData,data[item.name]);
}
}
}
});
let tempContext:any = JSON.parse(JSON.stringify(context));
if(tempContext && tempContext.srfsessionid){
tempContext.srfsessionkey = tempContext.srfsessionid;
delete tempContext.srfsessionid;
}
return {context:tempContext,data:requestData};
}
/**
* 通过属性名称获取表单项名称
*
* @param name 实体属性名称
* @memberof MainService
*/
public getItemNameByDeName(name:string) :string{
let itemName = name;
let mode: any = this.getMode();
if (!mode && mode.getDataItems instanceof Function) {
return name;
}
let formItemItems: any[] = mode.getDataItems();
formItemItems.forEach((item:any)=>{
if(item.prop === name){
itemName = item.name;
}
});
return itemName.trim();
}
/**
* 重写处理返回数据
*
* @param {string} action
* @param {*} response
* @memberof MainService
*/
public handleResponseData(action: string, data: any = {},isCreate?:boolean,codelistArray?:any){
let model: any = this.getMode();
if (!model && model.getDataItems instanceof Function) {
return data;
}
let item: any = {};
let dataItems: any[] = model.getDataItems();
dataItems.forEach(dataitem => {
let val = data.hasOwnProperty(dataitem.prop) ? data[dataitem.prop] : null;
if (val === null) {
val = data.hasOwnProperty(dataitem.name) ? data[dataitem.name] : null;
}
if((isCreate === undefined || isCreate === null ) && Object.is(dataitem.dataType, 'GUID') && Object.is(dataitem.name, 'srfkey') && (val && !Object.is(val, ''))){
isCreate = true;
}
item[dataitem.name] = val;
// 转化代码表
if(codelistArray && dataitem.codelist){
if(codelistArray.get(dataitem.codelist.tag) && codelistArray.get(dataitem.codelist.tag).get(val)){
item[dataitem.name] = codelistArray.get(dataitem.codelist.tag).get(val);
}
}
});
item.srfuf = data.srfuf ? data.srfuf : (isCreate ? "0" : "1");
item = Object.assign(data,item);
return item;
}
/**
* 设置远端数据
*
* @param result 远端请求结果
* @memberof MainService
*/
public setRemoteCopyData(result:any){
if (result && result.status === 200) {
this.remoteCopyData = Util.deepCopy(result.data);
}
}
/**
* 获取远端数据
*
* @memberof MainService
*/
public getRemoteCopyData(){
return this.remoteCopyData;
}
}
\ No newline at end of file
.ivu-tabs-no-animation>.ivu-tabs-content{
padding: 0 16px;
}
.ivu-card-head{
padding: 14px 0;
}
.app-form {
overflow: auto;
padding: 6px;
> .ivu-row {
> .ivu-tabs {
height: 100%;
display: flex;
flex-direction: column;
> .ivu-tabs-content {
flex-grow: 1;
overflow: auto;
> .ivu-tabs-tabpane {
height: 100%;
}
}
}
}
}
.app-tabpanel-flex {
height: 100%;
> .ivu-tabs-content {
height: calc(100% - 52px);
> .ivu-tabs-tabpane {
height: 100%;
}
}
}
.app-form {
>.ivu-row:nth-child(2) {
>.ivu-col:nth-child(1) {
>.ivu-row.app-form-group.app-group-hiddden-caption:nth-child(1) {
margin-top: 12px;
}
}
}
}
.app-form{
// 表单行间距
.app-form-item{
margin-bottom: 20px;
}
// 表单按钮margin
.app-form-button{
margin:0 6px;
}
}
// this is less
<script lang='tsx'>
import { Component } from 'vue-property-decorator';
import MainBase from './main-form-base.vue';
@Component({
components: {
}
})
export default class Main extends MainBase {
}
</script>
\ No newline at end of file
<template>
<div class='grid' style="height:100%">
<i-form style="height:100%;display:flex;flex-direction: column;justify-content: space-between">
<el-table v-if="isDisplay === true"
:default-sort="{ prop: minorSortPSDEF, order: Object.is(minorSortDir, 'ASC') ? 'ascending' : Object.is(minorSortDir, 'DESC') ? 'descending' : '' }"
@sort-change="onSortChange($event)"
:border="isDragendCol"
:highlight-current-row ="isSingleSelect"
:row-class-name="getRowClassName"
:cell-class-name="getCellClassName"
max-height="items.length > 0 ? 'calc(100%-50px)' : '100%'"
@row-click="rowClick($event)"
@cell-click="cellClick"
@select-all="selectAll($event)"
@select="select"
@row-class-name="onRowClassName($event)"
@row-dblclick="rowDBLClick($event)"
ref='multipleTable' :data="items" :show-header="!isHideHeader">
<template slot="empty">
{{$t('entities.metadynamicmodel.main_grid.nodata')}}
</template>
<template v-if="!isSingleSelect">
<el-table-column align="center" type='selection' :width="checkboxColWidth"></el-table-column>
</template>
<template v-if="getColumnState('configname')">
<el-table-column show-overflow-tooltip :prop="'configname'" :label="$t('entities.metadynamicmodel.main_grid.columns.configname')" :width="200" :align="'left'" :sortable="'custom'">
<template v-slot:header="{column}">
<span class="column-header ">
{{$t('entities.metadynamicmodel.main_grid.columns.configname')}}
</span>
</template>
<template v-slot="{row,column,$index}">
<span>{{row.configname}}</span>
</template>
</el-table-column>
</template>
<template v-if="getColumnState('systemid')">
<el-table-column show-overflow-tooltip :prop="'systemid'" :label="$t('entities.metadynamicmodel.main_grid.columns.systemid')" :width="200" :align="'left'" :sortable="'custom'">
<template v-slot:header="{column}">
<span class="column-header ">
{{$t('entities.metadynamicmodel.main_grid.columns.systemid')}}
</span>
</template>
<template v-slot="{row,column,$index}">
<span>{{row.systemid}}</span>
</template>
</el-table-column>
</template>
<template v-if="getColumnState('dynainstid')">
<el-table-column show-overflow-tooltip :prop="'dynainstid'" :label="$t('entities.metadynamicmodel.main_grid.columns.dynainstid')" :width="350" :align="'left'" :sortable="'custom'">
<template v-slot:header="{column}">
<span class="column-header ">
{{$t('entities.metadynamicmodel.main_grid.columns.dynainstid')}}
</span>
</template>
<template v-slot="{row,column,$index}">
<span>{{row.dynainstid}}</span>
</template>
</el-table-column>
</template>
<template v-if="getColumnState('status')">
<el-table-column show-overflow-tooltip :prop="'status'" :label="$t('entities.metadynamicmodel.main_grid.columns.status')" :width="200" :align="'left'" :sortable="'custom'">
<template v-slot:header="{column}">
<span class="column-header ">
{{$t('entities.metadynamicmodel.main_grid.columns.status')}}
</span>
</template>
<template v-slot="{row,column,$index}">
<template >
<codelist :value="row.status" tag='DynamicModelStatus' codelistType='STATIC' ></codelist>
</template>
</template>
</el-table-column>
</template>
<template v-if="adaptiveState">
<el-table-column></el-table-column>
</template>
</el-table>
<row class='grid-pagination' v-show="items.length > 0">
<page class='pull-right' @on-change="pageOnChange($event)"
@on-page-size-change="onPageSizeChange($event)"
:transfer="true" :total="totalrow"
show-sizer :current="curPage" :page-size="limit"
:page-size-opts="[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]" show-elevator show-total>
<span>
<span class="page-column">
<poptip transfer placement="top-start">
<i-button icon="md-menu">{{$t('app.gridpage.choicecolumns')}}</i-button>
<div slot="content">
<template v-for="col in allColumns">
<div :key="col.name"><el-checkbox v-model="col.show" @change="onColChange()">{{$t(col.langtag)}}</el-checkbox></div>
</template>
</div>
</poptip>
</span>
<span class="page-button"><i-button icon="md-refresh" :title="$t('app.gridpage.refresh')" @click="pageRefresh()"></i-button></span>&nbsp;
<span>
{{$t('app.gridpage.show')}}&nbsp;
<span>
<template v-if="items.length === 1">
1
</template>
<template v-else>
<span>{{(curPage - 1) * limit + 1}}&nbsp;-&nbsp;{{totalrow > curPage * limit ? curPage * limit : totalrow}}</span>
</template>
</span>&nbsp;
{{$t('app.gridpage.records')}},{{$t('app.gridpage.totle')}}&nbsp;{{totalrow}}&nbsp;{{$t('app.gridpage.records')}}
</span>
</span>
</page>
</row>
</i-form>
</div>
</template>
<script lang='tsx'>
import { Vue, Component, Prop, Provide, Emit, Watch, Model,Inject } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util,ViewTool } from '@/utils';
import NavDataService from '@/service/app/navdata-service';
import AppCenterService from "@service/app/app-center-service";
import MetaDynamicModelEntityService from '@/service/meta-dynamic-model/meta-dynamic-model-service';
import MainService from './main-grid-service';
import MetaDynamicModelUIService from '@/uiservice/meta-dynamic-model/meta-dynamic-model-ui-service';
import CodeListService from "@/codelist/codelist-service";
import { FormItemModel } from '@/model/form-detail';
import { Environment } from '@/environments/environment';
@Component({
components: {
}
})
export default class MainBase extends Vue implements ControlInterface {
/**
* 名称
*
* @type {string}
* @memberof MainBase
*/
@Prop() public name?: string;
/**
* 视图通讯对象
*
* @type {Subject<ViewState>}
* @memberof MainBase
*/
@Prop() public viewState!: Subject<ViewState>;
/**
* 应用上下文
*
* @type {*}
* @memberof MainBase
*/
@Prop() public context!: any;
/**
* 视图参数
*
* @type {*}
* @memberof MainBase
*/
@Prop() public viewparams!: any;
/**
* 视图状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof MainBase
*/
public viewStateEvent: Subscription | undefined;
/**
* 获取部件类型
*
* @returns {string}
* @memberof MainBase
*/
public getControlType(): string {
return 'GRID'
}
/**
* 计数器服务对象集合
*
* @type {Array<*>}
* @memberof MainBase
*/
public counterServiceArray:Array<any> = [];
/**
* 建构部件服务对象
*
* @type {MainService}
* @memberof MainBase
*/
public service: MainService = new MainService({ $store: this.$store });
/**
* 实体服务对象
*
* @type {MetaDynamicModelService}
* @memberof MainBase
*/
public appEntityService: MetaDynamicModelEntityService = new MetaDynamicModelEntityService({ $store: this.$store });
/**
* 转化数据
*
* @param {any} args
* @memberof MainBase
*/
public transformData(args: any) {
let _this: any = this;
if(_this.service && _this.service.handleRequestData instanceof Function && _this.service.handleRequestData('transform',_this.context,args)){
return _this.service.handleRequestData('transform',_this.context,args)['data'];
}
}
/**
* 关闭视图
*
* @param {any} args
* @memberof MainBase
*/
public closeView(args: any): void {
let _this: any = this;
_this.$emit('closeview', [args]);
}
/**
* 计数器刷新
*
* @memberof MainBase
*/
public counterRefresh(){
const _this:any =this;
if(_this.counterServiceArray && _this.counterServiceArray.length >0){
_this.counterServiceArray.forEach((item:any) =>{
if(item.refreshData && item.refreshData instanceof Function){
item.refreshData();
}
})
}
}
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof MainBase
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
/**
* 主信息表格列
*
* @type {string}
* @memberof MainBase
*/
public majorInfoColName:string = "configname";
/**
* 界面UI服务对象
*
* @type {MetaDynamicModelUIService}
* @memberof MainBase
*/
public appUIService:MetaDynamicModelUIService = new MetaDynamicModelUIService(this.$store);
/**
* 界面行为模型
*
* @type {*}
* @memberof MainBase
*/
public actionModel:any ={
};
/**
* 应用状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof MainBase
*/
public appStateEvent: Subscription | undefined;
/**
* 获取多项数据
*
* @returns {any[]}
* @memberof MainBase
*/
public getDatas(): any[] {
return this.selections;
}
/**
* 获取单项树
*
* @returns {*}
* @memberof MainBase
*/
public getData(): any {
return this.selections[0];
}
/**
* 打开新建数据视图
*
* @type {any}
* @memberof MainBase
*/
@Prop() public newdata: any;
/**
* 打开编辑数据视图
*
* @type {any}
* @memberof MainBase
*/
@Prop() public opendata: any;
/**
* 是否嵌入关系界面
*
* @type {boolean}
* @memberof MainBase
*/
@Prop({default:false}) public isformDruipart?: boolean;
/**
* 显示处理提示
*
* @type {boolean}
* @memberof MainBase
*/
@Prop({ default: true }) public showBusyIndicator?: boolean;
/**
* 部件行为--update
*
* @type {string}
* @memberof MainBase
*/
@Prop() public updateAction!: string;
/**
* 部件行为--fetch
*
* @type {string}
* @memberof MainBase
*/
@Prop() public fetchAction!: string;
/**
* 部件行为--remove
*
* @type {string}
* @memberof MainBase
*/
@Prop() public removeAction!: string;
/**
* 部件行为--load
*
* @type {string}
* @memberof MainBase
*/
@Prop() public loadAction!: string;
/**
* 部件行为--loaddraft
*
* @type {string}
* @memberof MainBase
*/
@Prop() public loaddraftAction!: string;
/**
* 部件行为--create
*
* @type {string}
* @memberof MainBase
*/
@Prop() public createAction!: string;
/**
* 当前页
*
* @type {number}
* @memberof MainBase
*/
public curPage: number = 1;
/**
* 数据
*
* @type {any[]}
* @memberof MainBase
*/
public items: any[] = [];
/**
* 是否支持分页
*
* @type {boolean}
* @memberof MainBase
*/
public isEnablePagingBar: boolean = true;
/**
* 是否禁用排序
*
* @type {boolean}
* @memberof MainBase
*/
public isNoSort: boolean = false;
/**
* 排序方向
*
* @type {string}
* @memberof MainBase
*/
public minorSortDir: string = '';
/**
* 排序字段
*
* @type {string}
* @memberof MainBase
*/
public minorSortPSDEF: string = '';
/**
* 分页条数
*
* @type {number}
* @memberof MainBase
*/
public limit: number = 20;
/**
* 是否显示标题
*
* @type {boolean}
* @memberof MainBase
*/
public isHideHeader: boolean = false;
/**
* 是否默认选中第一条数据
*
* @type {boolean}
* @memberof MainBase
*/
@Prop({ default: false }) public isSelectFirstDefault!: boolean;
/**
* 是否单选
*
* @type {boolean}
* @memberof MainBase
*/
@Prop() public isSingleSelect?: boolean;
/**
* 选中数据字符串
*
* @type {string}
* @memberof MainBase
*/
@Prop() public selectedData?: string;
/**
* 选中值变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MainBase
*/
@Watch('selectedData')
public onValueChange(newVal: any, oldVal: any) {
this.selections = [];
if(this.selectedData){
const refs: any = this.$refs;
if (refs.multipleTable) {
refs.multipleTable.clearSelection();
JSON.parse(this.selectedData).forEach((selection:any)=>{
let selectedItem = this.items.find((item:any)=>{
return Object.is(item.srfkey, selection.srfkey);
});
if(selectedItem){
this.rowClick(selectedItem);
}
});
}
}
}
/**
* 表格行数据默认激活模式
* 0 不激活
* 1 单击激活
* 2 双击激活
*
* @type {(number | 0 | 1 | 2)}
* @memberof MainBase
*/
@Prop({default: 2}) public gridRowActiveMode!: number;
/**
* 是否开启行编辑
*
* @type {boolean}
* @memberof MainBase
*/
@Prop({default: false}) public isOpenEdit!: boolean;
/**
* 实际是否开启行编辑
*
* @type {boolean}
* @memberof MainBase
*/
public actualIsOpenEdit: boolean = this.isOpenEdit;
/**
* 总条数
*
* @type {number}
* @memberof MainBase
*/
public totalrow: number = 0;
/**
* 表格更新默认值项
*
* @memberof MainBase
*/
public defaultUpdateItems:Array<any> =[];
/**
* 选中行数据
*
* @type {any[]}
* @memberof MainBase
*/
public selections: any[] = [];
/**
* 拦截行选中
*
* @type {boolean}
* @memberof MainBase
*/
public stopRowClick: boolean = false;
/**
* 当前编辑行数据
*
* @type {boolean}
* @memberof MainBase
*/
public curEditRowData:any;
/**
* 表格是否显示
*
* @type {boolean}
* @memberof MainBase
*/
public isDisplay:boolean = true;
/**
* 表格行编辑项校验错误提示信息
*
* @type {boolean}
* @memberof MainBase
*/
public errorMessages: Array<any> = [];
/**
* 部件刷新
*
* @param {any} args
* @memberof MainBase
*/
public refresh(args?: any): void {
this.load();
}
/**
* 选项框列宽
*
* @type {number}
* @memberof AppIndex
*/
public checkboxColWidth: number = 50;
/**
* 是否允许拖动列宽
*
* @type {boolean}
* @memberof AppEmbedPicker
*/
public isDragendCol: boolean = true;
/**
* 所有列成员
*
* @type {any[]}
* @memberof MainBase
*/
public allColumns: any[] = [
{
name: 'configname',
label: '配置名称',
langtag: 'entities.metadynamicmodel.main_grid.columns.configname',
show: true,
unit: 'PX',
isEnableRowEdit: false,
enableCond: 3 ,
},
{
name: 'systemid',
label: '系统',
langtag: 'entities.metadynamicmodel.main_grid.columns.systemid',
show: true,
unit: 'PX',
isEnableRowEdit: false,
enableCond: 3 ,
},
{
name: 'dynainstid',
label: '动态实例',
langtag: 'entities.metadynamicmodel.main_grid.columns.dynainstid',
show: true,
unit: 'PX',
isEnableRowEdit: false,
enableCond: 3 ,
},
{
name: 'status',
label: '状态',
langtag: 'entities.metadynamicmodel.main_grid.columns.status',
show: true,
unit: 'PX',
isEnableRowEdit: false,
enableCond: 3 ,
},
]
/**
* 表格模型集合
*
* @type {*}
* @memberof MainBase
*/
public gridItemsModel: any[] = [];
/**
* 是否启用分组
*
* @type {boolean}
* @memberof MainBase
*/
public isEnableGroup:boolean = false;
/**
* 分组属性
*
* @type {string}
* @memberof MainBase
*/
public groupAppField:string ="";
/**
* 分组属性代码表标识
*
* @type {string}
* @memberof MainBase
*/
public groupAppFieldCodelistTag:string ="";
/**
* 分组属性代码表类型
*
* @type {string}
* @memberof MainBase
*/
public groupAppFieldCodelistType: string = "";
/**
* 分组模式
*
* @type {string}
* @memberof MainBase
*/
public groupMode:string ="NONE";
/**
* 分组代码表标识
*
* @type {string}
* @memberof MainBase
*/
public codelistTag: string = "";
/**
* 分组代码表类型
*
* @type {string}
* @memberof MainBase
*/
public codelistType: string = "";
/**
* 获取界面行为权限状态
*
* @memberof MainBase
*/
public getActionState(data:any){
let tempActionModel:any = JSON.parse(JSON.stringify(this.actionModel));
let targetData:any = this.transformData(data);
ViewTool.calcActionItemAuthState(targetData,tempActionModel,this.appUIService);
return tempActionModel;
}
/**
* 获取表格行模型
*
* @type {*}
* @memberof MainBase
*/
public getGridRowModel(){
return {
srfkey: new FormItemModel(),
}
}
/**
* 属性值规则
*
* @type {*}
* @memberof MainBase
*/
public deRules(){
return {
};
}
/**
* 值规则集合
*
* @type {*}
* @memberof MainBase
*/
public rules(){
return {
srfkey: [
{ required: false, validator: (rule:any, value:any, callback:any) => { return (rule.required && (value === null || value === undefined || value === "")) ? false : true;}, message: `${this.$t('entities.metadynamicmodel.main_grid.columns.srfkey')}${this.$t('app.commonWords.valueNotEmpty')}`, trigger: 'change' },
{ required: false, validator: (rule:any, value:any, callback:any) => { return (rule.required && (value === null || value === undefined || value === "")) ? false : true;}, message: `${this.$t('entities.metadynamicmodel.main_grid.columns.srfkey')}${this.$t('app.commonWords.valueNotEmpty')}`, trigger: 'blur' },
],
}
}
/**
* 表格行编辑项校验
*
* @param {string} property 属性名
* @param {*} data 行数据
* @param {number} rowIndex 行索引
* @returns Promise<any>
*
* @memberof MainBase
*/
public validate(property:string, data:any, rowIndex:number):Promise<any>{
return new Promise((resolve, reject) => {
this.$util.validateItem(property,data,this.rules()).then(()=>{
this.gridItemsModel[rowIndex][property].setError(null);
resolve(true);
}).catch(({ errors, fields }) => {
this.gridItemsModel[rowIndex][property].setError(errors[0].message);
resolve(false);
});
});
}
/**
* 校验所有修改过的编辑项
*
* @returns Promise<any>
* @memberof MainBase
*/
public async validateAll(){
this.errorMessages = [];
let validateState = true;
let index = -1;
for (let item of this.items) {
let tempMessage: string = '';
index++;
if (item.rowDataState === "create" || item.rowDataState === "update") {
for (let property of Object.keys(this.rules())) {
if (!await this.validate(property, item, index)) {
validateState = false;
tempMessage = tempMessage + '<p>' + this.gridItemsModel[index][property].error + '<p>';
}
}
}
this.errorMessages.push(tempMessage);
}
return validateState;
}
/**
* 表格数据加载
*
* @param {*} [arg={}]
* @memberof MainBase
*/
public load(opt: any = {}, pageReset: boolean = false): void {
if(!this.fetchAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelDynaInstGridView'+(this.$t('app.gridpage.notConfig.fetchAction') as string) });
return;
}
if(pageReset){
this.curPage = 1;
}
const arg: any = {...opt};
const page: any = {};
if (this.isEnablePagingBar) {
Object.assign(page, { page: this.curPage-1, size: this.limit });
}
// 设置排序
if (!this.isNoSort && !Object.is(this.minorSortDir, '') && !Object.is(this.minorSortPSDEF, '')) {
const sort: string = this.minorSortPSDEF+","+this.minorSortDir;
Object.assign(page, { sort: sort });
}
//清空selections
if(this.selections && this.selections.length > 0) {
this.selections = [];
this.$emit('selectionchange', this.selections);
}
Object.assign(arg, page);
const parentdata: any = {};
this.$emit('beforeload', parentdata);
Object.assign(arg, parentdata);
let tempViewParams:any = parentdata.viewparams?parentdata.viewparams:{};
Object.assign(tempViewParams,JSON.parse(JSON.stringify(this.viewparams)));
Object.assign(arg,{viewparams:tempViewParams});
const post: Promise<any> = this.service.search(this.fetchAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.errorMessage) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.errorMessage });
}
return;
}
const data: any = response.data;
this.totalrow = response.total;
this.items = JSON.parse(JSON.stringify(data));
// 清空selections,gridItemsModel
// this.selections = [];
this.gridItemsModel = [];
this.items.forEach(()=>{this.gridItemsModel.push(this.getGridRowModel())});
this.items.forEach((item:any)=>{
Object.assign(item,this.getActionState(item));
});
this.$emit('load', this.items);
// 设置默认选中
let _this = this;
setTimeout(() => {
//在导航视图中,如已有选中数据,则右侧展开已选中数据的视图,如无选中数据则默认选中第一条
if(_this.isSelectFirstDefault){
if(_this.selections && _this.selections.length > 0){
_this.selections.forEach((select: any)=>{
const index = _this.items.findIndex((item:any) => Object.is(item.srfkey,select.srfkey));
if(index != -1){
_this.rowClick(_this.items[index]);
}
})
}else{
_this.rowClick(this.items[0]);
}
}
if(_this.selectedData){
const refs: any = _this.$refs;
if (refs.multipleTable) {
refs.multipleTable.clearSelection();
JSON.parse(_this.selectedData).forEach((selection:any)=>{
let selectedItem = _this.items.find((item:any)=>{
return Object.is(item.srfkey, selection.srfkey);
});
if(selectedItem){
_this.rowClick(selectedItem);
}
});
}
}
}, 300);
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.errorMessage });
});
}
/**
* 删除
*
* @param {any[]} datas
* @returns {Promise<any>}
* @memberof MainBase
*/
public async remove(datas: any[]): Promise<any> {
if(!this.removeAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelDynaInstGridView'+(this.$t('app.gridpage.notConfig.removeAction') as string) });
return;
}
let _datas:any[] = [];
datas.forEach((record: any, index: number) => {
if (Object.is(record.srfuf,"0")) {
this.items.some((val: any, num: number) =>{
if(JSON.stringify(val) == JSON.stringify(record)){
this.items.splice(num,1);
this.gridItemsModel.splice(num,1);
return true;
}
});
}else{
_datas.push(datas[index]);
}
});
if (_datas.length === 0) {
return;
}
let dataInfo = '';
_datas.forEach((record: any, index: number) => {
let srfmajortext = record.configname;
if (index < 5) {
if (!Object.is(dataInfo, '')) {
dataInfo += '、';
}
dataInfo += srfmajortext;
} else {
return false;
}
});
if (_datas.length < 5) {
dataInfo = dataInfo + ' ' + (this.$t('app.gridpage.totle') as string) + _datas.length + (this.$t('app.gridpage.records') as string) + (this.$t('app.gridpage.data') as string);
} else {
dataInfo = ' ... ' + (this.$t('app.gridpage.totle') as string) + _datas.length + (this.$t('app.gridpage.records') as string) + (this.$t('app.gridpage.data') as string);
}
const removeData = () => {
let keys: any[] = [];
_datas.forEach((data: any) => {
keys.push(data.srfkey);
});
let _removeAction = keys.length > 1 ? 'removeBatch' : this.removeAction ;
let _keys = keys.length > 1 ? keys : keys[0] ;
const context:any = JSON.parse(JSON.stringify(this.context));
const post: Promise<any> = this.service.delete(_removeAction,Object.assign(context,{ metadynamicmodel: _keys }),Object.assign({ metadynamicmodel: _keys },{viewparams:this.viewparams}), this.showBusyIndicator);
return new Promise((resolve: any, reject: any) => {
post.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: '', desc: (this.$t('app.gridpage.delDataFail') as string)+',' + response.info });
return;
} else {
this.$Notice.success({ title: '', desc: (this.$t('app.gridpage.delSuccess') as string) });
}
//删除items中已删除的项
_datas.forEach((data: any) => {
this.items.some((item:any,index:number)=>{
if(Object.is(item.srfkey,data.srfkey)){
this.items.splice(index,1);
this.gridItemsModel.splice(index,1);
return true;
}
});
});
this.totalrow -= _datas.length;
this.$emit('remove', null);
this.selections = [];
resolve(response);
}).catch((response: any) => {
if (response && response.status != 200) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.message});
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
reject(response);
return;
}
reject(response);
});
});
}
dataInfo = dataInfo.replace(/[null]/g, '').replace(/[undefined]/g, '');
this.$Modal.confirm({
title: (this.$t('app.commonWords.warning') as string),
content: (this.$t('app.gridpage.confirmDel') as string)+' ' + dataInfo + ','+(this.$t('app.gridpage.notRecoverable') as string),
onOk: () => {
removeData();
},
onCancel: () => { }
});
return removeData;
}
/**
* 批量添加
*
* @param {*} [arg={}]
* @memberof MainBase
*/
public addBatch(arg: any = {}): void {
if(!this.fetchAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelDynaInstGridView'+(this.$t('app.gridpage.notConfig.fetchAction') as string) });
return;
}
if(!arg){
arg = {};
}
console.error((this.$t('app.gridpage.notBatch') as string));
}
/**
* 数据导入
*
* @param {*} data
* @memberof MainBase
*/
public importExcel(data:any ={}):void{
//导入excel
const importDataModel:any ={
}
if(Object.keys(importDataModel).length == 0){
this.$Notice.warning({ 'title': (this.$t("app.utilview.warning") as string), 'desc': (this.$t("app.utilview.info") as string) });
return;
}
const view:any ={
viewname: 'app-data-upload',
title: this.$t("app.utilview.importview"),
width: 900,
height: 700
}
let container: Subject<any> = this.$appmodal.openModal(view, JSON.parse(JSON.stringify(this.context)), importDataModel);
container.subscribe((result: any) => {
if(Object.is(result.ret,'OK')){
this.refresh(result.datas);
}
});
}
/**
* 数据导出
*
* @param {*} data
* @memberof MainBase
*/
public exportExcel(data: any = {}): void {
// 导出Excel
const doExport = async (_data:any) => {
const tHeader: Array<any> = [];
const filterVal: Array<any> = [];
this.allColumns.forEach((item: any) => {
item.show && item.label ? tHeader.push(this.$t(item.langtag)) : "";
item.show && item.name ? filterVal.push(item.name) : "";
});
const data = await this.formatExcelData(filterVal, _data);
this.$export.exportExcel().then((excel:any)=>{
excel.export_json_to_excel({
header: tHeader, //表头 必填
data, //具体数据 必填
filename: "动态模型"+(this.$t('app.gridpage.grid') as string), //非必填
autoWidth: true, //非必填
bookType: "xlsx" //非必填
});
});
};
const page: any = {};
// 设置page,size
if (Object.is(data.type, 'maxRowCount')) {
Object.assign(page, { page: 0, size: data.maxRowCount });
} else if (Object.is(data.type, 'activatedPage')) {
try {
doExport(JSON.parse(JSON.stringify(this.items)));
} catch (error) {
console.error(error);
}
return;
}
// 设置排序
if (!this.isNoSort && !Object.is(this.minorSortDir, '') && !Object.is(this.minorSortPSDEF, '')) {
const sort: string = this.minorSortPSDEF+","+this.minorSortDir;
Object.assign(page, { sort: sort });
}
const arg: any = {};
Object.assign(arg, page);
// 获取query,搜索表单,viewparams等父数据
const parentdata: any = {};
this.$emit('beforeload', parentdata);
Object.assign(arg, parentdata);
const post: Promise<any> = this.service.search(this.fetchAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: '', desc: (this.$t('app.gridpage.exportFail') as string)+',' + response.info });
return;
}
try {
doExport(JSON.parse(JSON.stringify(response.data)));
} catch (error) {
console.error(error);
}
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
this.$Notice.error({ title: '', desc: (this.$t('app.gridpage.exportFail') as string) });
});
}
/**
* 导出数据格式化
*
* @param {*} filterVal
* @param {*} jsonData
* @returns {[]}
* @memberof MainBase
*/
public async formatExcelData(filterVal:any, jsonData:any) {
let codelistColumns:Array<any> = [
{
name: 'status',
srfkey: 'DynamicModelStatus',
codelistType : 'STATIC',
renderMode: 'other',
textSeparator: '、',
valueSeparator: ',',
},
];
let _this = this;
for (const codelist of codelistColumns) {
// 动态代码表处理
if (Object.is(codelist.codelistType, "DYNAMIC")) {
let items = await _this.codeListService.getItems(codelist.srfkey);
jsonData.forEach((row:any)=>{
row[codelist.name] = _this.getCodelistValue(items, row[codelist.name], codelist);
});
// 静态处理
} else if(Object.is(codelist.codelistType, "STATIC")){
let items = await _this.$store.getters.getCodeListItems(codelist.srfkey);
jsonData.forEach((row:any)=>{
row[codelist.name] = _this.getCodelistValue(items, row[codelist.name], codelist);
});
}
}
return jsonData.map((v:any) => filterVal.map((j:any) => v[j]))
}
/**
* 解析代码表和vlaue,设置items
*
* @public
* @param {any[]} items 代码表数据
* @param {*} value
* @returns {*}
* @memberof MainBase
*/
public getCodelistValue(items: any[], value: any, codelist: any,){
if(!value && value !== 0 && value !== false){
return this.$t('codelist.'+codelist.srfkey+'.empty');
}
if (items) {
let result:any = [];
if(Object.is(codelist.renderMode,"number")){
items.map((_item: any, index: number)=>{
const nValue = parseInt((value as any), 10);
const codevalue = _item.value;
if((parseInt(codevalue, 10) & nValue) > 0){
result.push(_item);
}
});
} else if(Object.is(codelist.renderMode,"string")){
const arrayValue: Array<any> = (value as any).split(codelist.valueSeparator);
arrayValue.map((value: any, index: number) => {
result.push([]);
let values: any[] = Object.is(this.$util.typeOf(value), 'number') ? [value] : [...(value as any).split(codelist.valueSeparator)];
values.map((val:any ,num: number)=>{
const item = this.getItem(items, val, codelist);
if(item){
result[index].push(item);
}
});
});
} else {
let values: any[] = Object.is(this.$util.typeOf(value), 'number') ? [value] : [...(value as any).split(codelist.valueSeparator)];
values.map((value:any ,index: number)=>{
const item = this.getItem(items, value, codelist);
if(item){
result.push(item);
}
});
}
// 设置items
if(result.length != 0){
return result.join(codelist.valueSeparator);
}else{
return value;
}
}
}
/**
* 获取代码项
*
* @public
* @param {any[]} items
* @param {*} value
* @returns {*}
* @memberof MainBase
*/
public getItem(items: any[], value: any, codelist: any): any {
const arr: Array<any> = items.filter(item => {return item.value == value});
if (arr.length !== 1) {
return undefined;
}
if(Object.is(codelist.codelistType,'STATIC')){
return this.$t('codelist.'+codelist.srfkey+'.'+arr[0].value);
}else{
return arr[0].text;
}
}
/**
* 生命周期
*
* @memberof MainBase
*/
public created(): void {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
* @memberof MainBase
*/
public afterCreated(){
this.setColState();
if (this.viewState) {
this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
if (!Object.is(tag, this.name)) {
return;
}
if (Object.is('load', action)) {
this.load(data,true);
}
if (Object.is('remove', action)) {
this.remove(data);
}
if (Object.is('save', action)) {
this.save(data);
}
});
}
if(AppCenterService && AppCenterService.getMessageCenter()){
this.appStateEvent = AppCenterService.getMessageCenter().subscribe(({ name, action, data }) =>{
if(!Object.is(name,"MetaDynamicModel")){
return;
}
if(Object.is(action,'appRefresh')){
this.refresh([data]);
}
})
}
}
/**
* vue 生命周期
*
* @memberof MainBase
*/
public destroyed() {
this.afterDestroy();
}
/**
* 执行destroyed后的逻辑
*
* @memberof MainBase
*/
public afterDestroy() {
if (this.viewStateEvent) {
this.viewStateEvent.unsubscribe();
}
if(this.appStateEvent){
this.appStateEvent.unsubscribe();
}
}
/**
* 获取选中行胡数据
*
* @returns {any[]}
* @memberof MainBase
*/
public getSelection(): any[] {
return this.selections;
}
/**
* 行双击事件
*
* @param {*} $event
* @returns {void}
* @memberof MainBase
*/
public rowDBLClick($event: any): void {
// 分组行跳过
if($event && $event.children){
return;
}
if (!$event || this.actualIsOpenEdit || Object.is(this.gridRowActiveMode,0)) {
return;
}
this.selections = [];
this.selections.push(JSON.parse(JSON.stringify($event)));
const refs: any = this.$refs;
if (refs.multipleTable) {
refs.multipleTable.clearSelection();
refs.multipleTable.toggleRowSelection($event);
}
this.$emit('rowdblclick', this.selections);
this.$emit('selectionchange', this.selections);
}
/**
* 合并分组行
*
* @memberof MainBase
*/
public arraySpanMethod({row, column, rowIndex, columnIndex} : any) {
let allColumns:Array<any> = ['configname','systemid','dynainstid','status'];
if(row && row.children) {
if(columnIndex == (this.isSingleSelect ? 0:1)) {
return [1, allColumns.length+1];
} else if(columnIndex > (this.isSingleSelect ? 0:1)) {
return [0,0];
}
}
}
/**
* 分组方法
*
* @memberof MainBase
*/
public group(){
if(Object.is(this.groupMode,"AUTO")){
this.drawGroup();
}else if(Object.is(this.groupMode,"CODELIST")){
this.drawCodelistGroup();
}
}
/**
* 获取表格分组相关代码表
*
* @param {string} codelistType 代码表类型
* @param {string} codelistTag 代码表标识
* @memberof MainBase
*/
public getGroupCodelist(codelistType: string,codelistTag:string){
let codelist: Array<any> = [];
// 动态代码表
if (Object.is(codelistType, "DYNAMIC")) {
this.codeListService.getItems(codelistTag).then((res: any)=>{
codelist = res;
}).catch((error: any) => {
});
// 静态代码表
} else if(Object.is(codelistType, "STATIC")){
codelist = this.$store.getters.getCodeListItems(codelistTag);
}
return codelist;
}
/**
* 根据分组代码表绘制分组列表
*
* @memberof MainBase
*/
public drawCodelistGroup(){
if(!this.isEnableGroup) return;
// 分组
let allGroup: Array<any> = [];
let allGroupField: Array<any> =[];
let groupTree:Array<any> = [];
allGroup = this.getGroupCodelist(this.codelistType,this.codelistTag);
allGroupField = this.getGroupCodelist(this.groupAppFieldCodelistType,this.groupAppFieldCodelistTag);
if(allGroup.length == 0){
console.warn("分组数据无效");
}
allGroup.forEach((group: any,i: number)=>{
let children:Array<any> = [];
this.items.forEach((item: any,j: number)=>{
if(allGroupField && allGroupField.length > 0){
if(Object.is(group.label,item[this.groupAppField])){
item.groupById = Number((i+1) * 100 + (j+1) * 1);
item.group = '';
children.push(item);
}
}else if(Object.is(group.value,item[this.groupAppField])){
item.groupById = Number((i+1) * 100 + (j+1) * 1);
item.group = '';
children.push(item);
}
});
const tree: any ={
groupById: Number((i+1)*100),
group: group.label,
configname:'',
systemid:'',
dynainstid:'',
status:'',
children: children
}
groupTree.push(tree);
});
let child:Array<any> = [];
this.items.forEach((item: any,index: number)=>{
let i: number = 0;
if(allGroupField && allGroupField.length > 0){
i = allGroup.findIndex((group: any)=>Object.is(group.label,item[this.groupAppField]));
}else{
i = allGroup.findIndex((group: any)=>Object.is(group.value,item[this.groupAppField]));
}
if(i < 0){
item.groupById = Number((allGroup.length+1) * 100 + (index+1) * 1);
item.group = '';
child.push(item);
}
if(i < 0){
item.groupById = Number((allGroup.length+1) * 100 + (index+1) * 1);
item.group = '';
child.push(item);
}
})
const Tree: any = {
groupById: Number((allGroup.length+1)*100),
group: this.$t('app.gridpage.other'),
configname:'',
systemid:'',
dynainstid:'',
status:'',
children: child
}
if(child && child.length > 0){
groupTree.push(Tree);
}
this.items = groupTree;
if(this.actualIsOpenEdit) {
for(let i = 0; i < this.items.length; i++) {
this.gridItemsModel.push(this.getGridRowModel());
}
}
}
/**
* 绘制分组
*
* @memberof MainBase
*/
public drawGroup(){
if(!this.isEnableGroup) return;
// 分组
let allGroup: Array<any> = [];
this.items.forEach((item: any)=>{
if(item.hasOwnProperty(this.groupAppField)){
allGroup.push(item[this.groupAppField]);
}
});
let groupTree:Array<any> = [];
allGroup = [...new Set(allGroup)];
if(allGroup.length == 0){
console.warn("分组数据无效");
}
// 组装数据
allGroup.forEach((group: any, groupIndex: number)=>{
let children:Array<any> = [];
this.items.forEach((item: any,itemIndex: number)=>{
if(Object.is(group,item[this.groupAppField])){
item.groupById = Number((groupIndex+1) * 100 + (itemIndex+1) * 1);
item.group = '';
children.push(item);
}
});
group = group ? group : this.$t('app.gridpage.other');
const tree: any ={
groupById: Number((groupIndex+1)*100),
group: group,
configname:'',
systemid:'',
dynainstid:'',
status:'',
children: children,
}
groupTree.push(tree);
});
this.items = groupTree;
if(this.actualIsOpenEdit) {
for(let i = 0; i < this.items.length; i++) {
this.gridItemsModel.push(this.getGridRowModel());
}
}
}
/**
* 单个复选框选中
*
* @param {*} selection 所有选中行数据
* @param {*} row 当前选中行数据
* @memberof MainBase
*/
public select(selection: any, row: any): void {
if(this.groupAppField) {
let isContain:boolean = selection.some((item:any) =>{
return item == row;
})
// 是否选中当前行,选中为true,否则为false
if(isContain) {
// 当前行为分组行
if(row.children && row.children.length > 0) {
this.toggleSelection(row.children, true);
row.children.forEach((children: any) => {
this.selections.push(children);
});
} else {
this.selections.push(row);
}
} else {
if(row.children && row.children.length > 0) {
this.toggleSelection(row.children, false);
this.selections = this.computeCheckedData(this.selections, row.children);
} else {
this.selections = this.computeCheckedData(this.selections, row);
}
}
this.selections = [...new Set(this.selections)]
} else {
if(!selection) {
return;
}
this.selections = [...JSON.parse(JSON.stringify(selection))];
}
this.$emit('selectionchange', this.selections);
}
/**
* 计算当前选中数据
*
* @param {*} selectionArray 所有选中行数据
* @param {*} cancelData 被取消选中行数据,分组行为数组,非分组行为对象
* @memberof MainBase
*/
public computeCheckedData(selectionArray: any[], cancelData: Array<any> | any) {
let targetArray: Array<any> = [];
// 分组行
if(Array.isArray(cancelData)) {
if(selectionArray && selectionArray.length > 0) {
selectionArray.forEach((selection:any) =>{
let tempFlag:boolean = true;
cancelData.forEach((child:any) =>{
if(selection.groupById===child.groupById){
tempFlag = false;
}
})
if(tempFlag) targetArray.push(selection);
})
}
} else {
// 非分组行
if(selectionArray && selectionArray.length > 0) {
selectionArray.forEach((selection:any) =>{
let tempFlag:boolean = true;
if(selection.groupById===cancelData.groupById){
tempFlag = false;
}
if(tempFlag) targetArray.push(selection);
})
}
}
return targetArray;
}
/**
* 设置非分组行checkbox选中状态
*
* @param {*} rows 选中数据数组
* @param {boolean} flag 是否选中
* @memberof MainBase
*/
public toggleSelection(rows?: any, flag?: boolean) {
if(rows) {
rows.forEach((row:any) => {
(this.$refs.multipleTable as any).toggleRowSelection(row, flag);
});
} else {
(this.$refs.multipleTable as any).clearSelection();
}
}
/**
* 复选框数据全部选中
*
* @param {*} $event
* @memberof MainBase
*/
public selectAll(selection: any): void {
this.selections = [];
if(this.groupAppField) {
let flag: boolean = true;
if(selection && selection.length === this.items.length) {
selection.forEach((element: any) => {
if(element.children) {
this.toggleSelection(element.children, flag);
element.children.forEach((children: any) => {
this.selections.push(children);
});
} else {
flag = false;
}
});
} else {
flag = false;
}
if(!flag) {
this.toggleSelection();
}
} else {
if(!selection) {
return;
}
this.selections = [...JSON.parse(JSON.stringify(selection))];
}
this.$emit('selectionchange', this.selections);
}
/**
* 单元格单击隐藏提示框
*
* @memberof MainBase
*/
public cellClick() {
let el: any = document.getElementsByClassName('el-tooltip__popper')[0];
if (el) {
el.style.display = 'none';
}
}
/**
* 行单击选中
*
* @param {*} $event
* @returns {void}
* @memberof MainBase
*/
public rowClick($event: any, ifAlways: boolean = false): void {
// 分组行跳过
if($event && $event.children){
return;
}
if (!ifAlways && (!$event || this.actualIsOpenEdit)) {
return;
}
if(this.stopRowClick) {
this.stopRowClick = false;
return;
}
if(this.isSingleSelect){
this.selections = [];
}
// 已选中则删除,没选中则添加
let selectIndex = this.selections.findIndex((item:any)=>{
return Object.is(item.metadynamicmodel,$event.metadynamicmodel);
});
if (Object.is(selectIndex,-1)){
this.selections.push(JSON.parse(JSON.stringify($event)));
} else {
this.selections.splice(selectIndex,1);
}
const refs: any = this.$refs;
if (refs.multipleTable) {
if(this.isSingleSelect){
refs.multipleTable.clearSelection();
refs.multipleTable.setCurrentRow($event);
}else{
refs.multipleTable.toggleRowSelection($event);
}
}
this.$emit('selectionchange', this.selections);
}
/**
* 页面变化
*
* @param {*} $event
* @returns {void}
* @memberof MainBase
*/
public pageOnChange($event: any): void {
if (!$event) {
return;
}
if ($event === this.curPage) {
return;
}
this.curPage = $event;
this.load({});
}
/**
* 分页条数变化
*
* @param {*} $event
* @returns {void}
* @memberof MainBase
*/
public onPageSizeChange($event: any): void {
if (!$event) {
return;
}
if ($event === this.limit) {
return;
}
this.limit = $event;
if (this.curPage === 1) {
this.load({});
}
}
/**
* 分页刷新
*
* @memberof MainBase
*/
public pageRefresh(): void {
this.load({});
}
/**
* 排序变化
*
* @param {{ column: any, prop: any, order: any }} { column, prop, order }
* @memberof MainBase
*/
public onSortChange({ column, prop, order }: { column: any, prop: any, order: any }): void {
const dir = Object.is(order, 'ascending') ? 'asc' : Object.is(order, 'descending') ? 'desc' : '';
if (Object.is(dir, this.minorSortDir) && Object.is(this.minorSortPSDEF, prop)) {
return;
}
this.minorSortDir = dir;
this.minorSortPSDEF = prop ? prop : '';
this.load({});
}
/**
* 表格行选中样式
*
* @param {{ row: any, rowIndex: any }} { row, rowIndex }
* @returns {string}
* @memberof MainBase
*/
public onRowClassName({ row, rowIndex }: { row: any, rowIndex: any }): string {
const index = this.selections.findIndex((select: any) => Object.is(select.srfkey, row.srfkey));
return index !== -1 ? 'grid-row-select' : '';
}
/**
* 界面行为
*
* @param {*} row
* @param {*} tag
* @param {*} $event
* @memberof MainBase
*/
public uiAction(row: any, tag: any, $event: any) {
// this.rowClick(row, true);
this.cellClick();
$event.stopPropagation();
}
/**
* 设置列状态
*
* @memberof MainBase
*/
public setColState() {
const _data: any = localStorage.getItem('meta_dynamicmodel_main_grid');
if (_data) {
let columns = JSON.parse(_data);
columns.forEach((col: any) => {
let column = this.allColumns.find((item) => Object.is(col.name, item.name));
if (column) {
Object.assign(column, col);
}
});
}
}
/**
* 列变化
*
* @memberof MainBase
*/
public onColChange() {
localStorage.setItem('meta_dynamicmodel_main_grid', JSON.stringify(this.allColumns));
}
/**
* 获取列状态
*
* @param {string} name
* @returns {boolean}
* @memberof MainBase
*/
public getColumnState(name: string): boolean {
let column = this.allColumns.find((col: any) =>
Object.is(name, col.name)
);
return column.show ? true : false;
}
/**
* 表格列是否自适应布局
*
* @readonly
* @type {boolean}
* @memberof MainBase
*/
get adaptiveState(): boolean {
return !this.allColumns.find((column: any) => column.show && Object.is(column.unit, 'STAR'));
}
/**
* 保存
*
* @param {*} $event
* @returns {Promise<any>}
* @memberof MainBase
*/
public async save(args: any[], params?: any, $event?: any, xData?: any){
let _this = this;
// 拷贝模式
if(_this.viewparams && _this.viewparams.copymode && Object.is(_this.viewparams.copymode,'true') && _this.items && _this.items.length >0){
for (const item of _this.items) {
item.rowDataState = 'create';
}
}
if(_this.items && _this.items.length >0){
for (const item of _this.items) {
if(Object.is(item.rowDataState, 'update')){
_this.updateDefault(item);
}
}
}
if (!await this.validateAll()) {
if(this.errorMessages && this.errorMessages.length > 0) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: this.errorMessages[0] });
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.rulesException') as string) });
}
return [];
}
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: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelDynaInstGridView'+(this.$t('app.gridpage.notConfig.createAction') as string) });
}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: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelDynaInstGridView'+(this.$t('app.gridpage.notConfig.updateAction') as string) });
}else{
Object.assign(item,{viewparams:this.viewparams});
if(item.metadynamicmodel){
Object.assign(this.context,{metadynamicmodel:item.metadynamicmodel});
}
let response = await this.service.update(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 && successItems.length > 0){
this.$Notice.success({ title: '', desc: (this.$t('app.commonWords.saveSuccess') as string) });
}else{
errorItems.forEach((item: any, index: number) => {
if(errorMessage[index] && errorMessage[index].data) {
if(Object.is(errorMessage[index].data.errorKey, 'DupCheck')) {
let errorProp: string = errorMessage[index].data.message.match(/\[[a-zA-Z]*\]/)[0];
let name: string = errorProp ? this.service.getNameByProp(errorProp.substr(1, errorProp.length-2)) : '';
if(name) {
let desc: any = this.allColumns.find((column: any) =>{
return Object.is(column.name, name);
});
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: (desc ? desc.label : '') + " : " + item[name] + (this.$t('app.commonWords.isExist') as string) + '!',
});
} else {
this.$Notice.error({
title: (this.$t('app.commonWords.createFailed') as string),
desc: errorMessage[index].data.message?errorMessage[index].data.message:(this.$t('app.commonWords.sysException') as string),
});
}
} else if(Object.is(errorMessage[index].data.errorKey, 'DuplicateKeyException')){
this.$Notice.error({
title: (this.$t('app.commonWords.saveFailed') as string),
desc: errorMessage[index].data.message?errorMessage[index].data.message:(this.$t('app.commonWords.sysException') as string),
});
}else {
this.$Notice.error({
title: (this.$t('app.commonWords.saveFailed') as string),
desc: errorMessage[index].data.message?errorMessage[index].data.message:(this.$t('app.commonWords.sysException') as string),
});
}
} else {
this.$Notice.error({ title: (this.$t('app.commonWords.saveFailed') as string), desc: (item[this.majorInfoColName]?item[this.majorInfoColName]:"") + (this.$t('app.commonWords.saveFailed') as string) + '!' });
}
});
}
return successItems;
}
/**
* 新建行
*
* @param {*} $event
* @returns {void}
* @memberof MainBase
*/
public newRow(args: any[], params?: any, $event?: any, xData?: any): void {
if(!this.loaddraftAction){
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'MetaDynamicModelDynaInstGridView'+(this.$t('app.gridpage.notConfig.loaddraftAction') as string) });
return;
}
let _this = this;
Object.assign(args[0],{viewparams:this.viewparams});
let post: Promise<any> = this.service.loadDraft(this.loaddraftAction, JSON.parse(JSON.stringify(this.context)), args[0], this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.errorMessage) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.errorMessage });
}
return;
}
const data = response.data;
this.createDefault(data);
data.rowDataState = "create";
this.items.splice(0,0,data);
_this.gridItemsModel.push(_this.getGridRowModel());
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
return;
}
});
}
/**
* 表格编辑项值变更
*
* @param row 行数据
* @param {{ name: string, value: any }} $event
* @returns {void}
* @memberof MainBase
*/
public onGridItemValueChange(row: any,$event: { name: string, value: any },rowIndex: number): void {
if (!$event) {
return;
}
if (!$event.name || Object.is($event.name, '') || !row.hasOwnProperty($event.name)) {
return;
}
row[$event.name] = $event.value;
this.gridEditItemChange(row, $event.name, $event.value, rowIndex);
}
/**
* 表格编辑项值变化
*
* @public
* @param row 行数据
* @param property 列编辑项名
* @param row 列编辑项值
* @returns {void}
* @memberof MainBase
*/
public gridEditItemChange(row: any, property: string, value: any, rowIndex: number){
row.rowDataState = row.rowDataState ? row.rowDataState : "update" ;
if(Object.is(row.rowDataState,"update")){
if(this.defaultUpdateItems.includes(property)){
row.hasUpdated = true;
}
}
this.curEditRowData = row;
this.resetGridData(row, property, rowIndex);
this.validate(property,row,rowIndex);
}
/**
* 表格编辑项更新
*
* @param {string} mode 界面行为名称
* @param {*} [data={}] 请求数据
* @param {string[]} updateDetails 更新项
* @param {boolean} [showloading] 是否显示加载状态
* @returns {void}
* @memberof MainBase
*/
public updateGridEditItem(mode: string, data: any = {}, updateDetails: string[], showloading?: boolean): void {
if (!mode || (mode && Object.is(mode, ''))) {
return;
}
let tempContext: any = this.$util.deepCopy(this.context);
const arg: any = JSON.parse(JSON.stringify(data));
Object.assign(arg,{viewparams:this.viewparams});
const post: Promise<any> = this.service.frontLogic(mode,JSON.parse(JSON.stringify(tempContext)),arg, showloading);
post.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.gridpage.formitemFailed') as string) });
return;
}
const _data: any = response.data;
if(!_data){
return;
}
updateDetails.forEach((name: string) => {
if (!_data.hasOwnProperty(name)) {
return;
}
data[name] = _data[name];
});
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
return;
}
});
}
/**
* 获取对应行class
*
* @param {*} $args row 行数据,rowIndex 行索引
* @returns {void}
* @memberof MainBase
*/
public getRowClassName(args:{row: any,rowIndex: number}){
let isSelected = this.selections.some((item:any)=>{
return Object.is(item.metadynamicmodel,args.row.metadynamicmodel);
});
return isSelected ? "grid-selected-row" : "";
}
/**
* 获取对应单元格class
*
* @param {*} $args row 行数据,column 列数据,rowIndex 行索引,columnIndex 列索引
* @returns {void}
* @memberof MainBase
*/
public getCellClassName(args:{row: any, column: any, rowIndex: number, columnIndex:number}){
let className: string = '';
if(args.column.property){
let col = this.allColumns.find((item:any)=>{
return Object.is(args.column.property,item.name);
})
if(col !== undefined){
if(col.isEnableRowEdit && this.actualIsOpenEdit ){
className += 'edit-cell ';
}
} else {
className += 'info-cell';
}
}
if(this.groupAppField && args.columnIndex === 0 && !this.isSingleSelect) {
if(args.row.children && args.row.children.length > 0) {
className += this.computeGroupRow(args.row.children, args.row);
}
}
return className;
}
/**
* 计算分组行checkbox选中样式
*
* @param {*} rows 当前分组行下的所有数据
* @returns {*} currentRow 当前分组行
* @memberof MainBase
*/
public computeGroupRow(rows: any[], currentRow: any) {
let count: number = 0;
this.selections.forEach((select: any) => {
rows.forEach((row: any) => {
if(row.groupById === select.groupById) {
count++;
}
})
})
if(count === rows.length) {
(this.$refs.multipleTable as any).toggleRowSelection(currentRow, true);
return 'cell-select-all ';
} else if(count !== 0 && count < rows.length) {
return 'cell-indeterminate '
} else if(count === 0) {
(this.$refs.multipleTable as any).toggleRowSelection(currentRow, false);
return '';
}
}
/**
* 新建默认值
* @param {*} row 行数据
* @memberof MainBase
*/
public createDefault(row: any){
}
/**
* 更新默认值
* @param {*} row 行数据
* @memberof MainBase
*/
public updateDefault(row: any){
}
/**
* 计算数据对象类型的默认值
* @param {string} action 行为
* @param {string} param 默认值参数
* @param {*} data 当前行数据
* @memberof MainBase
*/
public computeDefaultValueWithParam(action:string,param:string,data:any){
if(Object.is(action,"UPDATE")){
const nativeData:any = this.service.getCopynativeData();
if(nativeData && (nativeData instanceof Array) && nativeData.length >0){
let targetData:any = nativeData.find((item:any) =>{
return item.configid === data.srfkey;
})
if(targetData){
return targetData[param]?targetData[param]:null;
}else{
return null;
}
}else{
return null;
}
}else{
return this.service.getRemoteCopyData()[param]?this.service.getRemoteCopyData()[param]:null;
}
}
/**
* 校验属性值规则
*
* @public
* @param {{ name: string }} { name }
* @memberof MainBase
*/
public verifyDeRules(name:string,rule:any = this.deRules(),op:string = "AND",value:any) :{isPast:boolean}{
let falg:any = {};
if(!rule || !rule[name]){
return falg;
}
let opValue = op == 'AND'? true :false;
let startOp = (val:boolean)=>{
if(falg.isPast){
if(opValue){
falg.isPast = falg.isPast && val;
}else{
falg.isPast = falg.isPast || val;
}
}else{
falg.isPast = val;
}
}
for(let i=0; i < rule[name].length; i++) {
let item: any = rule[name][i];
if((value === null || value === undefined || value === "") && (item.type != 'GROUP')){
startOp(true);
return falg;
}
try {
// 常规规则
if(item.type == 'SIMPLE'){
startOp(!this.$verify.checkFieldSimpleRule(value,item.condOP,item.paramValue,item.ruleInfo,item.paramType,this.curEditRowData,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
if(!falg.isPast) return falg;
}
// 数值范围
if(item.type == 'VALUERANGE2'){
startOp( !this.$verify.checkFieldValueRangeRule(value,item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
if(!falg.isPast) return falg;
}
// 正则式
if (item.type == "REGEX") {
startOp(!this.$verify.checkFieldRegExRule(value,item.regExCode,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
if(!falg.isPast) return falg;
}
// 长度
if (item.type == "STRINGLENGTH") {
startOp(!this.$verify.checkFieldStringLengthRule(value,item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
if(!falg.isPast) return falg;
}
// 系统值规则
if(item.type == "SYSVALUERULE") {
startOp(!this.$verify.checkFieldSysValueRule(value,item.sysRule.regExCode,item.ruleInfo,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
if(!falg.isPast) return falg;
}
} catch(error) {
falg.infoMessage = item.ruleInfo;
startOp(false);
if(!falg.isPast) return falg;
}
// 分组
if(item.type == 'GROUP'){
falg = this.verifyDeRules('group',item,item.condOP?item.condOP:"AND",value)
if(item.isNotMode){
falg.isPast = !falg.isPast;
}
}
};
if(!falg.hasOwnProperty("isPast")){
falg.isPast = true;
}
if(!value && value != 0){
falg.isPast = true;
}
return falg;
}
/**
* 工作流提交
*
* @param {*} [data={}]
* @param {*} [localdata={}]
* @returns {Promise<any>}
* @memberof MainBase
*/
public async submitbatch(data: any,localdata:any): Promise<any> {
return new Promise((resolve: any, reject: any) => {
const _this: any = this;
const arg: any = data;
const result: Promise<any> = this.service.submitbatch(_this.WFSubmitAction, JSON.parse(JSON.stringify(this.context)),arg,localdata,this.showBusyIndicator);
result.then((response: any) => {
if (!response || response.status !== 200) {
if(response.data){
this.$Notice.error({ title: '', desc: (this.$t('app.formpage.workflow.submiterror') as string) + ', ' + response.data.message });
}
return;
}
this.$Notice.info({ title: '', desc: (this.$t('app.formpage.workflow.submitsuccess') as string) });
resolve(response);
}).catch((response: any) => {
if (response && response.status && response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
reject(response);
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
reject(response);
return;
}
reject(response);
});
})
}
/**
* 获取表格列禁用状态
*
* @memberof MainBase
*/
public getColumnDisabled(data:any,name:string){
if(this.allColumns || Array.isArray(this.allColumns)){
const curColumn:any = this.allColumns.find((item:any) =>{
return item.name === name;
})
if(curColumn.hasOwnProperty('enableCond')){
return data.srfuf == 1 ? (curColumn.enableCond & 2) !== 2 : (curColumn.enableCond & 1) !== 1
}else{
return false;
}
}
}
/**
* 重置表格项值
*
* @param {*} row 当前行
* @param {string} property 属性名
* @param {number} rowIndex 行下标
* @memberof MainBase
*/
public resetGridData(row: any, property: string, rowIndex: number) {
if(this.actualIsOpenEdit) {
}
}
}
</script>
<style lang='less'>
@import './main-grid.less';
</style>
\ No newline at end of file
/**
* Main 部件模型
*
* @export
* @class MainModel
*/
export default class MainModel {
/**
* 是否是实体数据导出
*
* @returns {any[]}
* @memberof MainGridMode
*/
public isDEExport: boolean = false;
/**
* 获取数据项集合
*
* @returns {any[]}
* @memberof MainGridMode
*/
public getDataItems(): any[] {
if(this.isDEExport){
return [
]
}else{
return [
{
name: 'dynainstid',
prop: 'dynainstid',
dataType: 'TEXT',
},
{
name: 'systemid',
prop: 'system_id',
dataType: 'TEXT',
},
{
name: 'status',
prop: 'status',
dataType: 'SSCODELIST',
},
{
name: 'configname',
prop: 'configname',
dataType: 'TEXT',
},
{
name: 'pdynainstid',
prop: 'pdynainstid',
dataType: 'PICKUP',
},
{
name: 'srfmajortext',
prop: 'configname',
dataType: 'TEXT',
},
{
name: 'srfdataaccaction',
prop: 'configid',
dataType: 'TEXT',
},
{
name: 'srfkey',
prop: 'configid',
dataType: 'TEXT',
isEditable:true
},
{
name: 'metadynamicmodel',
prop: 'configid',
},
{
name:'size',
prop:'size',
dataType: 'QUERYPARAM'
},
{
name:'query',
prop:'query',
dataType: 'QUERYPARAM'
},
{
name:'filter',
prop:'filter',
dataType: 'QUERYPARAM'
},
{
name:'page',
prop:'page',
dataType: 'QUERYPARAM'
},
{
name:'sort',
prop:'sort',
dataType: 'QUERYPARAM'
},
{
name:'srfparentdata',
prop:'srfparentdata',
dataType: 'QUERYPARAM'
},
// 前端新增修改标识,新增为"0",修改为"1"或未设值
{
name: 'srffrontuf',
prop: 'srffrontuf',
dataType: 'TEXT',
},
]
}
}
}
\ No newline at end of file
import { Http,Util,Errorlog } from '@/utils';
import ControlService from '@/widgets/control-service';
import MetaDynamicModelService from '@/service/meta-dynamic-model/meta-dynamic-model-service';
import MainModel from './main-grid-model';
/**
* Main 部件服务对象
*
* @export
* @class MainService
*/
export default class MainService extends ControlService {
/**
* 动态模型服务对象
*
* @type {MetaDynamicModelService}
* @memberof MainService
*/
public appEntityService: MetaDynamicModelService = new MetaDynamicModelService({ $store: this.getStore() });
/**
* 设置从数据模式
*
* @type {boolean}
* @memberof MainService
*/
public setTempMode(){
this.isTempMode = false;
}
/**
* Creates an instance of MainService.
*
* @param {*} [opts={}]
* @memberof MainService
*/
constructor(opts: any = {}) {
super(opts);
this.model = new MainModel();
}
/**
* 备份原生数据
*
* @type {*}
* @memberof MainService
*/
private copynativeData:any;
/**
* 远端数据
*
* @type {*}
* @memberof MainService
*/
private remoteCopyData:any = {};
/**
* 处理数据
*
* @public
* @param {Promise<any>} promise
* @returns {Promise<any>}
* @memberof MainService
*/
public doItems(promise: Promise<any>, deKeyField: string, deName: string): Promise<any> {
return new Promise((resolve, reject) => {
promise.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
data.forEach((item:any,index:number) =>{
item[deName] = item[deKeyField];
data[index] = item;
});
resolve(data);
} else {
reject([])
}
}).catch((response: any) => {
reject([])
});
});
}
/**
* 获取跨实体数据集合
*
* @param {string} serviceName 服务名称
* @param {string} interfaceName 接口名称
* @param {*} data
* @param {boolean} [isloading]
* @returns {Promise<any[]>}
* @memberof MainService
*/
@Errorlog
public getItems(serviceName: string, interfaceName: string, context: any = {}, data: any, isloading?: boolean): Promise<any[]> {
data.page = data.page ? data.page : 0;
data.size = data.size ? data.size : 1000;
return Promise.reject([])
}
/**
* 添加数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public add(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestDataWithUpdate(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
const _appEntityService: any = this.appEntityService;
let result: Promise<any>;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
}else{
result =_appEntityService.Create(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 删除数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public delete(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
const _appEntityService: any = this.appEntityService;
let result: Promise<any>;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
}else{
result =_appEntityService.Remove(Context,Data, isloading);
}
result.then((response) => {
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 修改数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public update(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestDataWithUpdate(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
const _appEntityService: any = this.appEntityService;
let result: Promise<any>;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data,isloading);
}else{
result =_appEntityService.Update(Context,Data,isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 获取数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public get(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Get(Context,Data, isloading);
}
result.then((response) => {
//处理返回数据,补充判断标识
if(response.data){
Object.assign(response.data,{srfuf:'0'});
}
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public search(action: string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
const _appEntityService: any = this.appEntityService;
let result: Promise<any>;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
}else{
result =_appEntityService.FetchDefault(Context,Data, isloading);
}
result.then((response) => {
this.setCopynativeData(response.data);
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 加载草稿
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public loadDraft(action: string, context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.GetDraft(Context,Data, isloading);
}
result.then((response) => {
//处理返回数据,补充判断标识
if(response.data){
Object.assign(response.data,{srfuf:'0'});
//仿真主键数据
response.data.configid = Util.createUUID();
}
this.setRemoteCopyData(response);
this.handleResponse(action, response, true);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 前台逻辑
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public frontLogic(action:string,context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any)=>{
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
return Promise.reject({ status: 500, data: { title: '失败', message: '系统异常' } });
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
})
}
/**
* 处理请求数据(修改或增加数据)
*
* @param action 行为
* @param data 数据
* @memberof MainService
*/
public handleRequestDataWithUpdate(action: string,context:any ={},data: any = {},isMerge:boolean = false){
let model: any = this.getMode();
if (!model && model.getDataItems instanceof Function) {
return data;
}
let dataItems: any[] = model.getDataItems();
let requestData:any = {};
if(isMerge && (data && data.viewparams)){
Object.assign(requestData,data.viewparams);
}
dataItems.forEach((item:any) =>{
if(item && item.dataType && Object.is(item.dataType,'FONTKEY')){
if(item && item.prop && item.name ){
requestData[item.prop] = context[item.name];
}
}else{
if(item && item.isEditable && item.prop && item.name && data.hasOwnProperty(item.name)){
requestData[item.prop] = data[item.name];
}
}
});
let tempContext:any = JSON.parse(JSON.stringify(context));
if(tempContext && tempContext.srfsessionid){
tempContext.srfsessionkey = tempContext.srfsessionid;
delete tempContext.srfsessionid;
}
return {context:tempContext,data:requestData};
}
/**
* 处理工作流数据
*
* @param data 传入数据
* @memberof MainService
*/
public handleWFData(data:any, isMerge:boolean = false){
let model: any = this.getMode();
if (!model && model.getDataItems instanceof Function) {
return data;
}
let dataItems: any[] = model.getDataItems();
let requestData:any = {};
dataItems.forEach((item:any) =>{
if(item && item.prop){
if(item.dataType){
if(!Object.is(item.dataType,'QUERYPARAM')){
requestData[item.prop] = data[item.name];
}
}else{
requestData[item.prop] = data[item.name];
}
}
});
if(isMerge && (data.viewparams && Object.keys(data.viewparams).length > 0)){
Object.assign(requestData,data.viewparams);
}
// 删除前端srffrontuf标识
if(requestData.hasOwnProperty('srffrontuf')){
delete requestData.srffrontuf;
}
//补充工作流所需主键
requestData.srfkey = data.metadynamicmodel;
//补充全量数据
requestData = this.fillNativeData(requestData);
return requestData;
}
/**
* 补充全量数据
*
* @param {*} [data]
* @memberof MainService
*/
public fillNativeData(data:any){
if(this.copynativeData && this.copynativeData.length >0){
let targetData:any = this.copynativeData.find((item:any) =>{
return item.configid === data.srfkey;
})
data = Object.assign(targetData,data);
return data;
}
}
/**
* 提交工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @param {*} [localdata]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public submitbatch(action: string,context: any = {}, data: any,localdata:any,isloading?: boolean): Promise<any> {
let tempData:any = [];
if(data && data.length > 0){
data.forEach((item:any) => {
let data:any = this.handleWFData(item,true);
tempData.push(data);
});
}
context = this.handleRequestData(action,context,data,true).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,tempData, localdata,isloading);
} else {
result = this.appEntityService.wfSubmitBatch(context,tempData,localdata,isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 设置远端数据
*
* @param result 远端请求结果
* @memberof MainService
*/
public setRemoteCopyData(result:any){
if (result && result.status === 200) {
this.remoteCopyData = Util.deepCopy(result.data);
}
}
/**
* 获取远端数据
*
* @memberof MainService
*/
public getRemoteCopyData(){
return this.remoteCopyData;
}
/**
* 设置备份原生数据
*
* @param data 远端请求结果
* @memberof MainService
*/
public setCopynativeData(data:any){
this.copynativeData = Util.deepCopy(data);
}
/**
* 获取备份原生数据
*
* @memberof MainService
*/
public getCopynativeData(){
return this.copynativeData;
}
}
\ No newline at end of file
.grid {
flex-grow: 1;
height: 100%;
overflow: auto;
.el-table__body-wrapper::-webkit-scrollbar {
/*滚动条整体样式*/
width : 10px !important; /*高宽分别对应横竖滚动条的尺寸*/
height: 10px !important;
}
.el-table__body-wrapper::-webkit-scrollbar-thumb {
/*滚动条颜色*/
border-radius : 10px !important;
background-color: #cecece !important;
}
.el-table__body-wrapper::-webkit-scrollbar-track {
/*滚动条里面轨道*/
box-shadow : inset 0 0 5px rgba(0, 0, 0, 0.2) !important;
background : #ededed !important;
border-radius: 10px !important;
}
/*表格文字过长省略*/
.el-table th>.cell, .el-table td>.cell{
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
word-break: break-all;
}
.el-table-column--selection .cell {
padding-left: 0px;
padding-right: 0px;
}
.app-column-link, .app-format-data{
display: inline;
}
.el-table {
height: 100%;
display:flex;
flex-direction: column;
justify-content: flex-start;
.el-table__row{
.grid-uiaction-divider {
padding:0 10px 0 10px;
border-left: 1px #b3b3b3 solid;
}
.grid-first-uiaction {
padding:0 10px 0 10px;
}
}
.quick-toolbar{
display: inline-block;
button{
background: #ebf3fb;
color: #2575ca;
border: 0;
}
}
.el-tooltip{
.ivu-form-item{
margin-bottom: unset !important;
}
}
.el-table__body .edit-cell{
padding:0;
.app-form-item{
margin-top: 20px;
margin-bottom: 20px;
}
}
.el-table__header-wrapper{
min-height: 45px;
max-height: 100px;
height: auto;
}
.el-table__footer-wrapper{
min-height: 45px;
max-height: 100px;
height: auto;
}
}
.grid-pagination {
height: 50px;
padding: 6px 0px;
.page-button {
button {
padding: 0;
font-size: 16px;
min-width: 32px;
height: 32px;
margin-right: 4px;
}
}
.page-column {
position: absolute;
left: 0;
}
.batch-toolbar{
position: absolute;
left: 105px;
>.toolbar-container{
button {
font-size: 16px;
min-width: 32px;
height: 32px;
margin-right: 4px;
margin-top: 0;
margin-bottom: 0;
}
}
}
}
}
.ivu-modal-content{
.footer{
.ivu-row{
text-align: right;
}
}
}
.cell-indeterminate {
>div>label {
>span {
.el-checkbox__inner {
background-color: #409eff;
border-color: #409eff;
}
.el-checkbox__inner:before {
content: "";
position: absolute;
display: block;
background-color: #fff;
height: 2px;
transform: scale(.5);
left: 0;
right: 0;
top: 5px;
}
}
>span.is-checked {
.el-checkbox__inner {
background-color: #409eff;
border-color: #409eff;
}
.el-checkbox__inner:after {
border: 0px;
}
}
}
}
.cell-select-all {
>div>label {
>span {
.el-checkbox__inner {
background-color: #409eff;
border-color: #409eff;
}
.el-checkbox__inner:after {
box-sizing: content-box;
content: "";
border: 1px solid #fff;
border-left: 0;
border-top: 0;
height: 7px;
left: 4px;
position: absolute;
top: 1px;
transform: rotate(45deg) scaleY(1);
width: 3px;
transition: transform .15s ease-in .05s;
transform-origin: center;
}
}
}
}
// this is less
<script lang='tsx'>
import { Component } from 'vue-property-decorator';
import MainBase from './main-grid-base.vue';
@Component({
components: {
}
})
export default class Main extends MainBase {
}
</script>
\ No newline at end of file
......@@ -7,6 +7,10 @@ logging:
#zuul网关路由设置
zuul:
routes:
meta_dynamicmodel:
path: /metadynamicmodels/**
serviceId: ${ibiz.ref.service.ibzdisk-api:ibzdisk-api}
stripPrefix: false
sd_file:
path: /sdfiles/**
serviceId: ${ibiz.ref.service.ibzdisk-api:ibzdisk-api}
......
......@@ -4,7 +4,7 @@
<!--输出实体[META_DYNAMICMODEL]数据结构 -->
<changeSet author="root" id="tab-meta_dynamicmodel-1-1">
<changeSet author="root" id="tab-meta_dynamicmodel-5-1">
<createTable tableName="IBZDYNAMICMODEL">
<column name="DYNAINSTID" remarks="" type="VARCHAR(100)">
</column>
......@@ -27,7 +27,7 @@
<!--输出实体[META_DYNAMICMODEL]外键关系 -->
<changeSet author="root" id="fk-meta_dynamicmodel-1-2">
<changeSet author="root" id="fk-meta_dynamicmodel-5-2">
<addForeignKeyConstraint baseColumnNames="PDYNAINSTID" baseTableName="IBZDYNAMICMODEL" constraintName="DER1N_META_DYNAMICMODEL_META_D" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="CONFIGID" referencedTableName="IBZDYNAMICMODEL" validate="true"/>
</changeSet>
......
......@@ -4,6 +4,14 @@
],
"entities":[
{
"dename":"MetaDynamicModel",
"delogicname":"动态模型",
"sysmoudle":{"id":"DISK","name":"disk"},
"dedataset":[{"id":"Default" , "name":"数据集"},{"id":"DynaInst" , "name":"主实例数据查询"}],
"deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"Init" , "name":"初始化副本实例" , "type":"USERCUSTOM" },{"id":"Publish" , "name":"发布模型" , "type":"USERCUSTOM" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" }],
"datascope":[{"id":"all","name":"全部数据"}]
}
, {
"dename":"SDFile",
"delogicname":"文件",
"sysmoudle":{"id":"DISK","name":"disk"},
......@@ -17,7 +25,7 @@
{
"appid":"web",
"appname":"存储",
"appmenu":[{"menuid":"SDIndexView", "menuname":"SDIndexView", "menuitem":[{ "id":"menuitem1" , "name":"文件" }] }]
"appmenu":[{"menuid":"SDIndexView", "menuname":"SDIndexView", "menuitem":[{ "id":"menuitem1" , "name":"文件" },{ "id":"menuitem2" , "name":"动态模型" }] }]
}
]
}
package cn.ibizlab.api.dto;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.math.BigInteger;
import java.util.Map;
import java.util.HashMap;
import java.io.Serializable;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.alibaba.fastjson.annotation.JSONField;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import cn.ibizlab.util.domain.DTOBase;
import cn.ibizlab.util.domain.DTOClient;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* 服务DTO对象[MetaDynamicModelDTO]
*/
@Data
@ApiModel("动态模型")
public class MetaDynamicModelDTO extends DTOBase implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 属性 [DYNAINSTID]
*
*/
@JSONField(name = "dynainstid")
@JsonProperty("dynainstid")
@Size(min = 0, max = 100, message = "内容长度必须小于等于[100]")
@ApiModelProperty("动态实例")
private String dynainstid;
/**
* 属性 [SYSTEMID]
*
*/
@JSONField(name = "system_id")
@JsonProperty("system_id")
@Size(min = 0, max = 100, message = "内容长度必须小于等于[100]")
@ApiModelProperty("系统")
private String systemId;
/**
* 属性 [CONFIGID]
*
*/
@JSONField(name = "configid")
@JsonProperty("configid")
@Size(min = 0, max = 100, message = "内容长度必须小于等于[100]")
@ApiModelProperty("配置标识")
private String configid;
/**
* 属性 [CONFIGNAME]
*
*/
@JSONField(name = "configname")
@JsonProperty("configname")
@Size(min = 0, max = 100, message = "内容长度必须小于等于[100]")
@ApiModelProperty("配置名称")
private String configname;
/**
* 属性 [PDYNAINSTID]
*
*/
@JSONField(name = "pdynainstid")
@JsonProperty("pdynainstid")
@Size(min = 0, max = 100, message = "内容长度必须小于等于[100]")
@ApiModelProperty("父实例")
private String pdynainstid;
/**
* 属性 [MODELFILE]
*
*/
@JSONField(name = "modelfile")
@JsonProperty("modelfile")
@Size(min = 0, max = 1000, message = "内容长度必须小于等于[1000]")
@ApiModelProperty("文件")
private String modelfile;
/**
* 属性 [STATUS]
*
*/
@JSONField(name = "status")
@JsonProperty("status")
@Size(min = 0, max = 60, message = "内容长度必须小于等于[60]")
@ApiModelProperty("状态")
private String status;
/**
* 设置 [DYNAINSTID]
*/
public void setDynainstid(String dynainstid){
this.dynainstid = dynainstid ;
this.modify("dynainstid",dynainstid);
}
/**
* 设置 [SYSTEMID]
*/
public void setSystemId(String systemId){
this.systemId = systemId ;
this.modify("systemid",systemId);
}
/**
* 设置 [CONFIGNAME]
*/
public void setConfigname(String configname){
this.configname = configname ;
this.modify("configname",configname);
}
/**
* 设置 [PDYNAINSTID]
*/
public void setPdynainstid(String pdynainstid){
this.pdynainstid = pdynainstid ;
this.modify("pdynainstid",pdynainstid);
}
/**
* 设置 [MODELFILE]
*/
public void setModelfile(String modelfile){
this.modelfile = modelfile ;
this.modify("modelfile",modelfile);
}
/**
* 设置 [STATUS]
*/
public void setStatus(String status){
this.status = status ;
this.modify("status",status);
}
}
package cn.ibizlab.api.mapping;
import org.mapstruct.*;
import cn.ibizlab.core.disk.domain.MetaDynamicModel;
import cn.ibizlab.api.dto.MetaDynamicModelDTO;
import cn.ibizlab.util.domain.MappingBase;
@Mapper(componentModel = "spring", uses = {}, implementationName = "apiMetaDynamicModelMapping",
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface MetaDynamicModelMapping extends MappingBase<MetaDynamicModelDTO, MetaDynamicModel> {
}
package cn.ibizlab.api.rest;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.math.BigInteger;
import java.util.HashMap;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.ServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.HttpStatus;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import cn.ibizlab.api.dto.*;
import cn.ibizlab.api.mapping.*;
import cn.ibizlab.core.disk.domain.MetaDynamicModel;
import cn.ibizlab.core.disk.service.IMetaDynamicModelService;
import cn.ibizlab.core.disk.filter.MetaDynamicModelSearchContext;
import cn.ibizlab.util.annotation.VersionCheck;
@Slf4j
@Api(tags = {"动态模型" })
@RestController("api-metadynamicmodel")
@RequestMapping("")
public class MetaDynamicModelResource {
@Autowired
public IMetaDynamicModelService metadynamicmodelService;
@Autowired
@Lazy
public MetaDynamicModelMapping metadynamicmodelMapping;
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-Create-all')")
@ApiOperation(value = "新建动态模型", tags = {"动态模型" }, notes = "新建动态模型")
@RequestMapping(method = RequestMethod.POST, value = "/metadynamicmodels")
public ResponseEntity<MetaDynamicModelDTO> create(@Validated @RequestBody MetaDynamicModelDTO metadynamicmodeldto) {
MetaDynamicModel domain = metadynamicmodelMapping.toDomain(metadynamicmodeldto);
metadynamicmodelService.create(domain);
MetaDynamicModelDTO dto = metadynamicmodelMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-Create-all')")
@ApiOperation(value = "批量新建动态模型", tags = {"动态模型" }, notes = "批量新建动态模型")
@RequestMapping(method = RequestMethod.POST, value = "/metadynamicmodels/batch")
public ResponseEntity<Boolean> createBatch(@RequestBody List<MetaDynamicModelDTO> metadynamicmodeldtos) {
metadynamicmodelService.createBatch(metadynamicmodelMapping.toDomain(metadynamicmodeldtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-Update-all')")
@ApiOperation(value = "更新动态模型", tags = {"动态模型" }, notes = "更新动态模型")
@RequestMapping(method = RequestMethod.PUT, value = "/metadynamicmodels/{metadynamicmodel_id}")
public ResponseEntity<MetaDynamicModelDTO> update(@PathVariable("metadynamicmodel_id") String metadynamicmodel_id, @RequestBody MetaDynamicModelDTO metadynamicmodeldto) {
MetaDynamicModel domain = metadynamicmodelMapping.toDomain(metadynamicmodeldto);
domain .setConfigid(metadynamicmodel_id);
metadynamicmodelService.update(domain );
MetaDynamicModelDTO dto = metadynamicmodelMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-Update-all')")
@ApiOperation(value = "批量更新动态模型", tags = {"动态模型" }, notes = "批量更新动态模型")
@RequestMapping(method = RequestMethod.PUT, value = "/metadynamicmodels/batch")
public ResponseEntity<Boolean> updateBatch(@RequestBody List<MetaDynamicModelDTO> metadynamicmodeldtos) {
metadynamicmodelService.updateBatch(metadynamicmodelMapping.toDomain(metadynamicmodeldtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-Remove-all')")
@ApiOperation(value = "删除动态模型", tags = {"动态模型" }, notes = "删除动态模型")
@RequestMapping(method = RequestMethod.DELETE, value = "/metadynamicmodels/{metadynamicmodel_id}")
public ResponseEntity<Boolean> remove(@PathVariable("metadynamicmodel_id") String metadynamicmodel_id) {
return ResponseEntity.status(HttpStatus.OK).body(metadynamicmodelService.remove(metadynamicmodel_id));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-Remove-all')")
@ApiOperation(value = "批量删除动态模型", tags = {"动态模型" }, notes = "批量删除动态模型")
@RequestMapping(method = RequestMethod.DELETE, value = "/metadynamicmodels/batch")
public ResponseEntity<Boolean> removeBatch(@RequestBody List<String> ids) {
metadynamicmodelService.removeBatch(ids);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-Get-all')")
@ApiOperation(value = "获取动态模型", tags = {"动态模型" }, notes = "获取动态模型")
@RequestMapping(method = RequestMethod.GET, value = "/metadynamicmodels/{metadynamicmodel_id}")
public ResponseEntity<MetaDynamicModelDTO> get(@PathVariable("metadynamicmodel_id") String metadynamicmodel_id) {
MetaDynamicModel domain = metadynamicmodelService.get(metadynamicmodel_id);
MetaDynamicModelDTO dto = metadynamicmodelMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@ApiOperation(value = "获取动态模型草稿", tags = {"动态模型" }, notes = "获取动态模型草稿")
@RequestMapping(method = RequestMethod.GET, value = "/metadynamicmodels/getdraft")
public ResponseEntity<MetaDynamicModelDTO> getDraft(MetaDynamicModelDTO dto) {
MetaDynamicModel domain = metadynamicmodelMapping.toDomain(dto);
return ResponseEntity.status(HttpStatus.OK).body(metadynamicmodelMapping.toDto(metadynamicmodelService.getDraft(domain)));
}
@ApiOperation(value = "检查动态模型", tags = {"动态模型" }, notes = "检查动态模型")
@RequestMapping(method = RequestMethod.POST, value = "/metadynamicmodels/checkkey")
public ResponseEntity<Boolean> checkKey(@RequestBody MetaDynamicModelDTO metadynamicmodeldto) {
return ResponseEntity.status(HttpStatus.OK).body(metadynamicmodelService.checkKey(metadynamicmodelMapping.toDomain(metadynamicmodeldto)));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-Init-all')")
@ApiOperation(value = "初始化副本实例", tags = {"动态模型" }, notes = "初始化副本实例")
@RequestMapping(method = RequestMethod.POST, value = "/metadynamicmodels/{metadynamicmodel_id}/init")
public ResponseEntity<MetaDynamicModelDTO> init(@PathVariable("metadynamicmodel_id") String metadynamicmodel_id, @RequestBody MetaDynamicModelDTO metadynamicmodeldto) {
MetaDynamicModel domain = metadynamicmodelMapping.toDomain(metadynamicmodeldto);
domain.setConfigid(metadynamicmodel_id);
domain = metadynamicmodelService.init(domain);
metadynamicmodeldto = metadynamicmodelMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(metadynamicmodeldto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-Init-all')")
@ApiOperation(value = "批量处理[初始化副本实例]", tags = {"动态模型" }, notes = "批量处理[初始化副本实例]")
@RequestMapping(method = RequestMethod.POST, value = "/metadynamicmodels/initbatch")
public ResponseEntity<Boolean> initBatch(@RequestBody List<MetaDynamicModelDTO> metadynamicmodeldtos) {
List<MetaDynamicModel> domains = metadynamicmodelMapping.toDomain(metadynamicmodeldtos);
boolean result = metadynamicmodelService.initBatch(domains);
return ResponseEntity.status(HttpStatus.OK).body(result);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-Publish-all')")
@ApiOperation(value = "发布模型", tags = {"动态模型" }, notes = "发布模型")
@RequestMapping(method = RequestMethod.POST, value = "/metadynamicmodels/{metadynamicmodel_id}/publish")
public ResponseEntity<MetaDynamicModelDTO> publish(@PathVariable("metadynamicmodel_id") String metadynamicmodel_id, @RequestBody MetaDynamicModelDTO metadynamicmodeldto) {
MetaDynamicModel domain = metadynamicmodelMapping.toDomain(metadynamicmodeldto);
domain.setConfigid(metadynamicmodel_id);
domain = metadynamicmodelService.publish(domain);
metadynamicmodeldto = metadynamicmodelMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(metadynamicmodeldto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-Publish-all')")
@ApiOperation(value = "批量处理[发布模型]", tags = {"动态模型" }, notes = "批量处理[发布模型]")
@RequestMapping(method = RequestMethod.POST, value = "/metadynamicmodels/publishbatch")
public ResponseEntity<Boolean> publishBatch(@RequestBody List<MetaDynamicModelDTO> metadynamicmodeldtos) {
List<MetaDynamicModel> domains = metadynamicmodelMapping.toDomain(metadynamicmodeldtos);
boolean result = metadynamicmodelService.publishBatch(domains);
return ResponseEntity.status(HttpStatus.OK).body(result);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-Save-all')")
@ApiOperation(value = "保存动态模型", tags = {"动态模型" }, notes = "保存动态模型")
@RequestMapping(method = RequestMethod.POST, value = "/metadynamicmodels/save")
public ResponseEntity<MetaDynamicModelDTO> save(@RequestBody MetaDynamicModelDTO metadynamicmodeldto) {
MetaDynamicModel domain = metadynamicmodelMapping.toDomain(metadynamicmodeldto);
metadynamicmodelService.save(domain);
return ResponseEntity.status(HttpStatus.OK).body(metadynamicmodelMapping.toDto(domain));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-Save-all')")
@ApiOperation(value = "批量保存动态模型", tags = {"动态模型" }, notes = "批量保存动态模型")
@RequestMapping(method = RequestMethod.POST, value = "/metadynamicmodels/savebatch")
public ResponseEntity<Boolean> saveBatch(@RequestBody List<MetaDynamicModelDTO> metadynamicmodeldtos) {
metadynamicmodelService.saveBatch(metadynamicmodelMapping.toDomain(metadynamicmodeldtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-searchDefault-all')")
@ApiOperation(value = "获取数据集", tags = {"动态模型" } ,notes = "获取数据集")
@RequestMapping(method= RequestMethod.GET , value="/metadynamicmodels/fetchdefault")
public ResponseEntity<List<MetaDynamicModelDTO>> fetchDefault(MetaDynamicModelSearchContext context) {
Page<MetaDynamicModel> domains = metadynamicmodelService.searchDefault(context) ;
List<MetaDynamicModelDTO> list = metadynamicmodelMapping.toDto(domains.getContent());
return ResponseEntity.status(HttpStatus.OK)
.header("x-page", String.valueOf(context.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
.header("x-total", String.valueOf(domains.getTotalElements()))
.body(list);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-searchDefault-all')")
@ApiOperation(value = "查询数据集", tags = {"动态模型" } ,notes = "查询数据集")
@RequestMapping(method= RequestMethod.POST , value="/metadynamicmodels/searchdefault")
public ResponseEntity<Page<MetaDynamicModelDTO>> searchDefault(@RequestBody MetaDynamicModelSearchContext context) {
Page<MetaDynamicModel> domains = metadynamicmodelService.searchDefault(context) ;
return ResponseEntity.status(HttpStatus.OK)
.body(new PageImpl(metadynamicmodelMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-searchDynaInst-all')")
@ApiOperation(value = "获取主实例数据查询", tags = {"动态模型" } ,notes = "获取主实例数据查询")
@RequestMapping(method= RequestMethod.GET , value="/metadynamicmodels/fetchdynainst")
public ResponseEntity<List<MetaDynamicModelDTO>> fetchDynaInst(MetaDynamicModelSearchContext context) {
Page<MetaDynamicModel> domains = metadynamicmodelService.searchDynaInst(context) ;
List<MetaDynamicModelDTO> list = metadynamicmodelMapping.toDto(domains.getContent());
return ResponseEntity.status(HttpStatus.OK)
.header("x-page", String.valueOf(context.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
.header("x-total", String.valueOf(domains.getTotalElements()))
.body(list);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdisk-MetaDynamicModel-searchDynaInst-all')")
@ApiOperation(value = "查询主实例数据查询", tags = {"动态模型" } ,notes = "查询主实例数据查询")
@RequestMapping(method= RequestMethod.POST , value="/metadynamicmodels/searchdynainst")
public ResponseEntity<Page<MetaDynamicModelDTO>> searchDynaInst(@RequestBody MetaDynamicModelSearchContext context) {
Page<MetaDynamicModel> domains = metadynamicmodelService.searchDynaInst(context) ;
return ResponseEntity.status(HttpStatus.OK)
.body(new PageImpl(metadynamicmodelMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册