提交 7dce5820 编写于 作者: sq3536's avatar sq3536

Merge remote-tracking branch 'origin/master'

package cn.ibizlab.codegen.model; package cn.ibizlab.codegen.model;
import cn.ibizlab.codegen.utils.Inflector;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
...@@ -32,6 +34,31 @@ public class AppModel extends BaseModel{ ...@@ -32,6 +34,31 @@ public class AppModel extends BaseModel{
}); });
} }
// 初始化应用实体资源数据Map
if(getApplication().getAllPSAppDataEntities()!=null)
{
getApplication().getAllPSAppDataEntities().forEach(appDataEntity ->{
if(appDataEntity.getMinorPSAppDERSs() != null){
appDataEntity.getMinorPSAppDERSs().forEach(appDERS ->{
JSONObject tempObj = new JSONObject();
String majorCodeName = appDERS.getMajorPSAppDataEntity().getCodeName();
String minorCodeName = appDERS.getMinorPSAppDataEntity().getCodeName();
String path = String.format("%1$s/:%2$s?/%3$s/:%4$s?",Inflector.getInstance().pluralize(majorCodeName),majorCodeName,Inflector.getInstance().pluralize(minorCodeName),minorCodeName).toLowerCase();
tempObj.put("majorCodeName",majorCodeName.toLowerCase());
tempObj.put("curCodeName",minorCodeName.toLowerCase());
tempObj.put("path",path);
tempObj.put("appDataEntity",appDataEntity);
appEntityResourceMap.put(String.format("%1$s:%2$s",majorCodeName,minorCodeName),tempObj);
});
}else{
JSONObject tempObj = new JSONObject();
tempObj.put("curCodeName",appDataEntity.getCodeName().toLowerCase());
tempObj.put("path",String.format("%1$s/:%2$s?",Inflector.getInstance().pluralize(appDataEntity.getCodeName()),appDataEntity.getCodeName()).toLowerCase());
tempObj.put("appDataEntity",appDataEntity);
appEntityResourceMap.put(appDataEntity.getCodeName(),tempObj);
}
});
}
} }
...@@ -42,7 +69,7 @@ public class AppModel extends BaseModel{ ...@@ -42,7 +69,7 @@ public class AppModel extends BaseModel{
return (IPSApplication)opt; return (IPSApplication)opt;
} }
private Map<String,AppEntityModel> appEntitiesMap=new LinkedHashMap<>();; private Map<String,AppEntityModel> appEntitiesMap=new LinkedHashMap<>();
private Map<String,PageModel> pagesMap=new LinkedHashMap<>(); private Map<String,PageModel> pagesMap=new LinkedHashMap<>();
...@@ -77,4 +104,19 @@ public class AppModel extends BaseModel{ ...@@ -77,4 +104,19 @@ public class AppModel extends BaseModel{
return null; return null;
} }
/**
* 应用实体资源数据Map
*/
private Map<String, JSONObject> appEntityResourceMap =new LinkedHashMap<>();
/**
* 获取应用实体资源数据
* @return
*/
public Collection<JSONObject> getAppEntityResources(){
if(appEntityResourceMap!=null)
return appEntityResourceMap.values();
return new ArrayList<>();
}
} }
...@@ -46,5 +46,6 @@ ...@@ -46,5 +46,6 @@
{{#*inline "FILEUPLOADER_ONE"}}{{>@macro/editor/upload.hbs}}{{/inline}} {{#*inline "FILEUPLOADER_ONE"}}{{>@macro/editor/upload.hbs}}{{/inline}}
{{#*inline "PICTURE"}}{{>@macro/editor/upload.hbs}}{{/inline}} {{#*inline "PICTURE"}}{{>@macro/editor/upload.hbs}}{{/inline}}
{{#*inline "PICTURE_ONE"}}{{>@macro/editor/upload.hbs}}{{/inline}} {{#*inline "PICTURE_ONE"}}{{>@macro/editor/upload.hbs}}{{/inline}}
{{#*inline "PICKUPVIEW"}}{{>@macro/editor/data-picker-view.hbs}}{{/inline}}
{{#*inline "PICKEREX_DROPDOWNVIEW"}}{{>@macro/editor/data-picker-view.hbs}}{{/inline}} {{#*inline "PICKEREX_DROPDOWNVIEW"}}{{>@macro/editor/data-picker-view.hbs}}{{/inline}}
{{#*inline "PICKEREX_DROPDOWNVIEW_LINK"}}{{>@macro/editor/data-picker-view.hbs}}{{/inline}} {{#*inline "PICKEREX_DROPDOWNVIEW_LINK"}}{{>@macro/editor/data-picker-view.hbs}}{{/inline}}
\ No newline at end of file
{{#each items as | formDetail |}}
{
caption: '{{formDetail.caption}}',
codeName: '{{formDetail.codeName}}',
name: '{{formDetail.name}}',
{{#if (eq formDetail.detailType "FORMITEM")}}
dataType: '{{formDetail.dataType}}',
detailStyle: '{{formDetail.detailStyle}}',
resetItemName: '{{formDetail.resetItemName}}',
valueItemName: '{{formDetail.valueItemName}}',
{{/if}}
},
{{#if formDetail.psDEFormDetails}}
{{>(lookup 'FORMDETAILSMODEL') items=formDetail.psDEFormDetails}}
{{/if}}
{{/each}}
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<a-col :span="24"> <a-col :span="24">
<IbizFormItem name="{{item.codeName}}" label="{{item.caption}}"> <IbizFormItem name="{{item.codeName}}" label="{{item.caption}}">
{{#if item.psEditor}} {{#if item.psEditor}}
{{>(lookup . 'item.psEditor.editorType') item=item}} {{>(lookup . 'item.psEditor.editorType') item=item controlType="form"}}
{{/if}} {{/if}}
</IbizFormItem> </IbizFormItem>
</a-col> </a-col>
......
{{#*inline "FORMPAGE"}}{{>@macro/form-detail/form-page.hbs}}{{/inline}} {{#*inline "FORMPAGE"}}{{>@macro/form-detail/form-page.hbs}}{{/inline}}
{{#*inline "GROUPPANEL"}}{{>@macro/form-detail/form-group.hbs}}{{/inline}} {{#*inline "GROUPPANEL"}}{{>@macro/form-detail/form-group.hbs}}{{/inline}}
{{#*inline "FORMITEM"}}{{>@macro/form-detail/form-item.hbs}}{{/inline}} {{#*inline "FORMITEM"}}{{>@macro/form-detail/form-item.hbs}}{{/inline}}
{{#*inline "FORMDETAILSMODEL"}}{{>@macro/form-detail/form-details-model.hbs}}{{/inline}}
\ No newline at end of file
viewCodeName: '{{page.codeName}}',
viewName: '{{page.name}}',
viewCaption: '{{page.caption}}',
height: '{{page.height}}',
width: '{{page.width}}',
viewMsgGroup: '{{page.psAppViewMsgGroup}}',
viewUIActions: '{{page.psAppViewUIActions}}',
viewSysCss: '{{page.psSysCss}}',
viewSysImage: '{{page.psSysImage}}',
subCaption: '{{page.subCaption}}',
viewType: '{{page.viewType}}',
viewStyle: '{{page.viewStyle}}',
showCaptionBar: '{{page.viewStyle}}',
\ No newline at end of file
...@@ -2,16 +2,14 @@ ...@@ -2,16 +2,14 @@
title: "{{item.caption}}", title: "{{item.caption}}",
columnType: "{{item.columnType}}", columnType: "{{item.columnType}}",
{{#if item.align}} {{#if item.align}}
align: "{{item.align}}", align: "{{lowerCase item.align}}",
{{/if}} {{/if}}
{{#neq lastColumn true}}
{{#if item.widthUnit 'PX'}} {{#if item.widthUnit 'PX'}}
width: {{item.width}}, width: {{item.width}},
{{else}} {{else}}
minWidth: {{item.width}}, minWidth: {{item.width}},
{{/if}} {{/if}}
resizable: true, resizable: true,
{{/neq}}
{{#eq item.columnType 'GROUPGRIDCOLUMN'}} {{#eq item.columnType 'GROUPGRIDCOLUMN'}}
children: [ children: [
{{#each item.psDEGridColumns as | column |}} {{#each item.psDEGridColumns as | column |}}
...@@ -19,7 +17,10 @@ ...@@ -19,7 +17,10 @@
{{/each}} {{/each}}
], ],
{{else}} {{else}}
dataIndex: "{{lowerCase item.codeName}}", {{#eq item.columnType 'UAGRIDCOLUMN'}}
fixed: "right",
{{/eq}}
dataIndex: "{{#if item.dataItemName}}{{lowerCase item.dataItemName}}{{else}}{{lowerCase item.codeName}}{{/if}}",
ellipsis: true, ellipsis: true,
enableSort: {{item.enableSort}}, enableSort: {{item.enableSort}},
{{#if item.aggMode}} {{#if item.aggMode}}
......
{{#neq item.columnType 'GROUPGRIDCOLUMN'}} {{#if (neq item.columnType 'GROUPGRIDCOLUMN')}}
<div v-if="column.dataIndex === '{{item.codeName}}'" class="table-cell"> <div v-if="Object.is(column.dataIndex, '{{item.codeName}}')" class="table-cell">
{{#eq item.columnType 'DEFGRIDCOLUMN'}} {{#if (eq item.columnType 'DEFGRIDCOLUMN')}}
{{#if item.enableRowEdit}} {{#if item.enableRowEdit}}
<div v-if="state.rowEditState" class="editor-cell"> <div v-if="state.rowEditState" class="editor-cell">
{{#each ctrl.psDEGridEditItems as | editColumn | }} {{#each ctrl.psDEGridEditItems as | editColumn | }}
{{#eq editColumn.codeName (item.codeName)}} {{#eq editColumn.codeName (item.codeName)}}
{{#if item.psEditor}} {{#if item.psEditor}}
{{>(lookup . 'item.psEditor.editorType') item=item}} {{>(lookup . 'item.psEditor.editorType') item=item ctrlType="grid"}}
{{/if}} {{/if}}
{{/eq}} {{/eq}}
{{/each}} {{/each}}
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
<span class="text">\{{text}}</span> <span class="text">\{{text}}</span>
</div> </div>
{{/if}} {{/if}}
{{/eq}} {{/if}}
{{#eq item.columnType 'UAGRIDCOLUMN'}} {{#if (eq item.columnType 'UAGRIDCOLUMN')}}
{{!-- <ibizToolbar {{!-- <ibizToolbar
:toolbarModel="state.actionModel" :toolbarModel="record.{{lowerCase item.codeName}}"
@toolbarEvent="handleToolbarEvent"
:context="state.context" :context="state.context"
:viewParams="state.viewParams"/> --}} :viewParams="state.viewParams"
{{/eq}} @toolbarEvent="($event: ) => handleToolbarEvent()"/> --}}
{{/if}}
</div> </div>
{{/neq}} {{/if}}
...@@ -87,3 +87,36 @@ export function useContextParams(props: Record<any, any>) { ...@@ -87,3 +87,36 @@ export function useContextParams(props: Record<any, any>) {
return { context, viewParams }; return { context, viewParams };
} }
/**
* @description 值规则校验
* @export
* @param {Record<any, any>} props
*/
export async function verifyRules(_rule: any, value: any, condition: any) {
//常规规则
if (Object.is(condition.Type, 'SIMPLE')) {
//todo
// 数值范围
} else if (Object.is(condition.Type, 'VALUERANGE2')) {
if (!value) {
return;
}
if (!Number.isInteger(value)) {
return Promise.reject('请输入数值!');
} else {
if (condition.includeMinValue && Object.is(value,condition.minValue)) {
return Promise.resolve();
} else if (condition.includeMaxValue && Object.is(value,condition.maxValue)) {
return Promise.resolve();
} else if (value > condition.minValue && value < condition.maxValue) {
return Promise.resolve();
}
}
// 正则式
} else if (Object.is(condition.Type, 'REGEX')) {
// 长度
} else if (Object.is(condition.Type, 'STRINGLENGTH')) {
// 系统值规则
} else if (Object.is(condition.Type, 'SYSVALUERULE')) {
}
}
\ No newline at end of file
...@@ -44,6 +44,12 @@ export class MainView extends ViewBase { ...@@ -44,6 +44,12 @@ export class MainView extends ViewBase {
//todo //todo
} }
public handleCtrlEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam;
// TODO
console.log(tag, action, data);
}
/** /**
* 安装部件所有功能模块的方法 * 安装部件所有功能模块的方法
* @param props 传入的Props * @param props 传入的Props
...@@ -58,7 +64,8 @@ export class MainView extends ViewBase { ...@@ -58,7 +64,8 @@ export class MainView extends ViewBase {
return { return {
...superParams, ...superParams,
state: this.viewState, state: this.viewState,
handleToolbarEvent: this.handleToolbarEvent, handleToolbarEvent: this.handleToolbarEvent.bind(this),
handleCtrlEvent: this.handleCtrlEvent.bind(this),
}; };
} }
} }
...@@ -29,6 +29,13 @@ export class ControlBase { ...@@ -29,6 +29,13 @@ export class ControlBase {
*/ */
public route: RouteLocationNormalizedLoaded = useRoute(); public route: RouteLocationNormalizedLoaded = useRoute();
/**
* @description 事件
* @type {*}
* @memberof ControlBase
*/
public emit: any;
/** /**
* Creates an instance of ControlBase. * Creates an instance of ControlBase.
* @param {*} options 配置参数 * @param {*} options 配置参数
...@@ -75,6 +82,7 @@ export class ControlBase { ...@@ -75,6 +82,7 @@ export class ControlBase {
* @memberof ControlBase * @memberof ControlBase
*/ */
public moduleInstall(props: ControlPropsBase, emit?: Function) { public moduleInstall(props: ControlPropsBase, emit?: Function) {
this.emit = emit?.bind(this);
this.setState(props); this.setState(props);
this.useControlContextParams(props); this.useControlContextParams(props);
return { return {
......
...@@ -28,12 +28,31 @@ export class FormControl extends MainControl { ...@@ -28,12 +28,31 @@ export class FormControl extends MainControl {
*/ */
public formDataChange(name: string, value: any) { public formDataChange(name: string, value: any) {
this.controlState.data[name] = value; this.controlState.data[name] = value;
// TODO 重置项逻辑 this.resetFormData(name);
// TODO 表单项更新 // TODO 表单项更新
// TODO 动态控制逻辑 // TODO 动态控制逻辑
// TODO 自动保存(可以单独做一个逻辑块,监听data的变化) // TODO 自动保存(可以单独做一个逻辑块,监听data的变化)
} }
/**
* @description 表单项重置
* @param {string} name
* @memberof FormControl
*/
public resetFormData(name: string) {
const formItems: any[] = this.controlState.itemsModel;
if (formItems && formItems.length > 0) {
for (const item of formItems) {
if (item.resetItemName && item.resetItemName == name) {
this.formDataChange( item.name, null);
if (item.valueItemName) {
this.formDataChange(item.valueItemName, null);
}
}
}
}
}
/** /**
* 在表单执行某些行为能力后,表单整体数据发生改变后被调用。会依次执行以下逻辑: * 在表单执行某些行为能力后,表单整体数据发生改变后被调用。会依次执行以下逻辑:
* 1. * 1.
...@@ -301,17 +320,12 @@ export class FormControl extends MainControl { ...@@ -301,17 +320,12 @@ export class FormControl extends MainControl {
const { load } = this.useLoad(props); const { load } = this.useLoad(props);
const { save } = this.useSave(props); const { save } = this.useSave(props);
const handleEditorEvent = this.handleEditorEvent.bind(this);
this.handleEditorEvent = (actionParam: IActionParam) => {
handleEditorEvent(actionParam);
};
return { return {
...superParams, ...superParams,
state: this.controlState, state: this.controlState,
load, load,
save, save,
handleEditorEvent: this.handleEditorEvent, handleEditorEvent: this.handleEditorEvent.bind(this),
}; };
} }
} }
...@@ -64,6 +64,13 @@ export interface GridControlState extends MainControlState { ...@@ -64,6 +64,13 @@ export interface GridControlState extends MainControlState {
*/ */
selectedData: IParam[]; selectedData: IParam[];
/**
* @description 选中行keys
* @type {string[]}
* @memberof GridControlState
*/
selectedRowKeys: string[];
/** /**
* @description 是否默认选中第一条数据 * @description 是否默认选中第一条数据
* @type {boolean} * @type {boolean}
...@@ -71,6 +78,13 @@ export interface GridControlState extends MainControlState { ...@@ -71,6 +78,13 @@ export interface GridControlState extends MainControlState {
*/ */
selectFirstDefault: boolean; selectFirstDefault: boolean;
/**
* @description 当前页
* @type {number}
* @memberof GridControlState
*/
current: number;
/** /**
* @description 分页大小 * @description 分页大小
* @type {number} * @type {number}
......
import {{page.codeName}} from "./{{spinalCase page.codeName}}.vue"; import {{page.codeName}} from "./{{spinalCase page.codeName}}.vue";
export { {{page.codeName}} }; export default {{page.codeName}};
import {{page.codeName}} from "./{{spinalCase page.codeName}}.vue"; import {{page.codeName}} from "./{{spinalCase page.codeName}}.vue";
export { {{page.codeName}} }; export default {{page.codeName}};
export const ViewConfig = { export const ViewConfig = {
viewCodeName: '{{page.codeName}}', {{> @macro/front-end/view/common/viewBaseConfig.hbs}}
viewName: '{{page.name}}',
viewCaption: '{{page.caption}}',
{{#page.ctrls}} {{#page.ctrls}}
{{#eq controlType "TOOLBAR"}} {{#eq controlType "TOOLBAR"}}
{{lowerCase codeName}}:{ {{lowerCase codeName}}:{
......
...@@ -34,9 +34,15 @@ const { state, handleToolbarEvent } = new EditView(ViewConfig).moduleInstall(pro ...@@ -34,9 +34,15 @@ const { state, handleToolbarEvent } = new EditView(ViewConfig).moduleInstall(pro
</script> </script>
<template> <template>
<IbizDefaultViewLayout class="ibiz-edit-view"> <IbizDefaultViewLayout :class="['ibiz-edit-view', state.viewSysCss]">
<template v-slot:header-left> <template v-slot:header-left>
<IbizIconText class="ibiz-view__caption" size="large" :text="state.viewCaption" /> <IbizIconText
class="ibiz-view__caption"
size="large"
:subCaption="state.subCaption"
:showCaptionBar="state.showCaptionBar"
:text="state.viewCaption"
/>
</template> </template>
{{#page.ctrls}} {{#page.ctrls}}
{{#eq controlType "TOOLBAR"}} {{#eq controlType "TOOLBAR"}}
......
import {{page.codeName}} from "./{{spinalCase page.codeName}}.vue"; import {{page.codeName}} from "./{{spinalCase page.codeName}}.vue";
export { {{page.codeName}} }; export default {{page.codeName}};
...@@ -29,7 +29,7 @@ interface ViewEmit { ...@@ -29,7 +29,7 @@ interface ViewEmit {
const emit = defineEmits<ViewEmit>(); const emit = defineEmits<ViewEmit>();
// 安装功能模块,提供状态和能力方法 // 安装功能模块,提供状态和能力方法
const { state } = new GridView(ViewConfig).moduleInstall(props); const { state, handleCtrlEvent } = new GridView(ViewConfig).moduleInstall(props);
</script> </script>
...@@ -45,13 +45,13 @@ const { state } = new GridView(ViewConfig).moduleInstall(props); ...@@ -45,13 +45,13 @@ const { state } = new GridView(ViewConfig).moduleInstall(props);
{{#eq controlType "GRID"}} {{#eq controlType "GRID"}}
<{{codeName}}Grid <{{codeName}}Grid
:context="state.context" :context="state.context"
:multiple="false"
:rowEditState="state.rowEditState" :rowEditState="state.rowEditState"
:rowActiveMode="state.gridRowActiveMode" :rowActiveMode="state.gridRowActiveMode"
:showBusyIndicator="true" :showBusyIndicator="true"
:viewParams="state.viewParams" :viewParams="state.viewParams"
:controlAction="state.controlsAction" :controlAction="state.controlsAction"
:viewSubject="state.viewSubject" :viewSubject="state.viewSubject"
@ctrlEvent="handleCtrlEvent"
></{{codeName}}Grid> ></{{codeName}}Grid>
{{/eq}} {{/eq}}
{{/page.ctrls}} {{/page.ctrls}}
......
...@@ -2,7 +2,7 @@ import { createRouter, createWebHashHistory } from 'vue-router'; ...@@ -2,7 +2,7 @@ import { createRouter, createWebHashHistory } from 'vue-router';
const routes = [ const routes = [
{ {
path: "/{{lowerCase app.defaultPSAppIndexView.codeName}}/:{{lowerCase app.defaultPSAppIndexView.codeName}}?", path: "/apps/:app?",
{{!-- beforeEnter: (to: any, from: any, next: any) => { {{!-- beforeEnter: (to: any, from: any, next: any) => {
next(); next();
}, --}} }, --}}
...@@ -10,100 +10,50 @@ const routes = [ ...@@ -10,100 +10,50 @@ const routes = [
captionTag: "{{#if app.defaultPSAppIndexView.capPSLanguageRes}}{{app.defaultPSAppIndexView.capPSLanguageRes.lanResTag}}{{/if}}", captionTag: "{{#if app.defaultPSAppIndexView.capPSLanguageRes}}{{app.defaultPSAppIndexView.capPSLanguageRes.lanResTag}}{{/if}}",
caption: "{{app.defaultPSAppIndexView.caption}}", caption: "{{app.defaultPSAppIndexView.caption}}",
viewType: "{{app.defaultPSAppIndexView.viewType}}", viewType: "{{app.defaultPSAppIndexView.viewType}}",
dynaModelFilePath: "{{app.defaultPSAppIndexView.dynaModelFilePath}}",
{{#if app.defaultPSAppIndexView.psSysImage}} {{#if app.defaultPSAppIndexView.psSysImage}}
imgPath: "{{app.defaultPSAppIndexView.psSysImage.imagePath}}", imgPath: "{{app.defaultPSAppIndexView.psSysImage.imagePath}}",
iconCls: "{{app.defaultPSAppIndexView.psSysImage.cssClass}}", iconCls: "{{app.defaultPSAppIndexView.psSysImage.cssClass}}",
{{/if}} {{/if}}
parameters: [
{ pathName: "views", parameterName: "{{lowerCase app.defaultPSAppIndexView.codeName}}" },
],
requireAuth: {{#eq app.defaultPSAppIndexView.accUserMode 0}}false{{else}}{{#eq app.defaultPSAppIndexView.accUserMode 3}}false{{else}}true{{/eq}}{{/eq}}, requireAuth: {{#eq app.defaultPSAppIndexView.accUserMode 0}}false{{else}}{{#eq app.defaultPSAppIndexView.accUserMode 3}}false{{else}}true{{/eq}}{{/eq}},
}, },
component: () => import("@page/{{#if app.defaultPSAppIndexView.psAppDataEntity}}{{spinalCase app.defaultPSAppIndexView.psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase app.defaultPSAppIndexView.codeName}}/{{spinalCase app.defaultPSAppIndexView.codeName}}.vue"), component: () => import("@page/default/{{spinalCase app.defaultPSAppIndexView.codeName}}"),
children: [ children: [
{{#each app.allPSAppViews as | appView |}} {{#each app.appEntityResources as |appEntityResource|}}
{{!-- 实体视图 --}} {{#if appEntityResource.appDataEntity.allPSAppViews}}
{{#if appView.psAppDataEntity}} {{#each appEntityResource.appDataEntity.allPSAppViews as |appView|}}
{{!-- 多重路径 --}}
{{#if appView.psAppDataEntity.psAppDERSPathCount}}
{{#if (or (eq appView.viewType 'DEEDITVIEW') (eq appView.viewType 'DEGRIDVIEW'))}} {{#if (or (eq appView.viewType 'DEEDITVIEW') (eq appView.viewType 'DEGRIDVIEW'))}}
{ {
path: "{{lowerCase (pluralize appView.psAppDataEntity.codeName)}}/:{{lowerCase appView.psAppDataEntity.codeName}}?/{{lowerCase appView.codeName}}/:{{lowerCase appView.codeName}}?", path: "{{appEntityResource.path}}/views/{{lowerCase appView.codeName}}",
meta: { meta: {
captionTag: "{{#if appView.capPSLanguageRes}}{{appView.capPSLanguageRes.lanResTag}}{{/if}}", {{#if appView.capPSLanguageRes}}
caption: "{{appView.caption}}", captionTag: "{{appView.capPSLanguageRes.lanResTag}}",
viewType: "{{appView.viewType}}",
info:'',
{{#if appView.psSysImage}}
imgPath: "{{appView.psSysImage.imagePath}}",
iconCls: "{{appView.psSysImage.cssClass}}",
{{/if}}
parameters: [
{ pathName: "{{lowerCase app.defaultPSAppIndexView.codeName}}", parameterName: "{{lowerCase app.defaultPSAppIndexView.codeName}}" },
{ pathName: "{{lowerCase (pluralize appView.psAppDataEntity.codeName)}}", parameterName: "{{lowerCase codeName}}" },
{ pathName: "{{lowerCase appView.codeName}}", parameterName: "{{lowerCase appView.codeName}}" },
],
resource: "{{lowerCase entity.codeName}}",
requireAuth: false,
},
component: () => import("@page/{{#if appView.psAppDataEntity}}{{spinalCase appView.psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase appView.codeName}}/{{spinalCase appView.codeName}}.vue"),
},
{{/if}} {{/if}}
{{else}}
{{#if (or (eq appView.viewType 'DEEDITVIEW') (eq appView.viewType 'DEGRIDVIEW'))}}
{
path: "{{lowerCase (pluralize appView.psAppDataEntity.codeName)}}/:{{lowerCase appView.psAppDataEntity.codeName}}?/{{lowerCase appView.codeName}}/:{{lowerCase appView.codeName}}?",
meta: {
captionTag: "{{#if appView.capPSLanguageRes}}{{appView.capPSLanguageRes.lanResTag}}{{/if}}",
caption: "{{appView.caption}}", caption: "{{appView.caption}}",
viewType: "{{appView.viewType}}", viewType: "{{appView.viewType}}",
info:'',
{{#if appView.psSysImage}} {{#if appView.psSysImage}}
imgPath: "{{appView.psSysImage.imagePath}}", imgPath: "{{appView.psSysImage.imagePath}}",
iconCls: "{{appView.psSysImage.cssClass}}", iconCls: "{{appView.psSysImage.cssClass}}",
{{/if}} {{/if}}
parameters: [ parameters: [
{ pathName: "{{lowerCase app.defaultPSAppIndexView.codeName}}", parameterName: "{{lowerCase app.defaultPSAppIndexView.codeName}}" }, { pathName: "apps", parameterName: "app" },
{ pathName: "{{lowerCase (pluralize appView.psAppDataEntity.codeName)}}", parameterName: "{{lowerCase appView.psAppDataEntity.codeName}}" }, {{#if appEntityResource.majorCodeName}}
{ pathName: "{{lowerCase appView.codeName}}", parameterName: "{{lowerCase appView.codeName}}" }, { pathName: "{{pluralize appEntityResource.majorCodeName}}", parameterName: "{{appEntityResource.majorCodeName}}" },
],
resource: "{{lowerCase entity.codeName}}",
requireAuth: false,
},
component: () => import("@page/{{#if appView.psAppDataEntity}}{{spinalCase appView.psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase appView.codeName}}/{{spinalCase appView.codeName}}.vue"),
},
{{/if}}
{{/if}}
{{else}}
{{#neq app.defaultPSAppIndexView.codeName (appView.codeName)}}
{
path: "{{lowerCase appView.codeName}}/:{{lowerCase appView.codeName}}?",
meta: {
captionTag: "{{#if appView.capPSLanguageRes}}{{appView.capPSLanguageRes.lanResTag}}{{/if}}",
caption: "{{appView.caption}}",
viewType: "{{appView.viewType}}",
info:'',
{{#if appView.psSysImage}}
imgPath: "{{appView.psSysImage.imagePath}}",
iconCls: "{{appView.psSysImage.cssClass}}",
{{/if}} {{/if}}
parameters: [ { pathName: "{{pluralize appEntityResource.curCodeName}}", parameterName: "{{appEntityResource.curCodeName}}" }
{ pathName: "{{lowerCase app.defaultPSAppIndexView.codeName}}", parameterName: "{{lowerCase app.defaultPSAppIndexView.codeName}}" },
{ pathName: "{{lowerCase appView.codeName}}", parameterName: "{{lowerCase appView.codeName}}" },
], ],
requireAuth: false, requireAuth: false,
}, },
component: () => import("@page/{{#if appView.psAppDataEntity}}{{spinalCase appView.psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase appView.codeName}}/{{spinalCase appView.codeName}}.vue"), component: () => import("@page/{{#if psAppDataEntity}}{{spinalCase psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase appView.codeName}}"),
}, },
{{/neq}} {{/if}}
{{/each}}
{{/if}} {{/if}}
{{/each}} {{/each}}
] ]
}, },
{ {
path: "/", path: "/",
redirect: "/{{lowerCase app.defaultPSAppIndexView.codeName}}" redirect: "/apps/{{lowerCase app.codeName}}"
}, },
] ]
const router = createRouter({ const router = createRouter({
......
import { ControlVOBase } from '@ibiz-core'; {{>@macro/form-detail/include-form.hbs}}
import { ControlVOBase, verifyRules } from '@ibiz-core';
import { ControlService } from './{{spinalCase ctrl.codeName}}-form-service'; import { ControlService } from './{{spinalCase ctrl.codeName}}-form-service';
export const CtrlConfig = { export const CtrlConfig = {
...@@ -6,6 +7,33 @@ export const CtrlConfig = { ...@@ -6,6 +7,33 @@ export const CtrlConfig = {
controlName: '{{ctrl.name}}', controlName: '{{ctrl.name}}',
controlService: new ControlService(), controlService: new ControlService(),
data: {}, data: {},
itemsModel: [
{{#each ctrl.psDEFormPages as | FormPage | }}
{{>(lookup 'FORMDETAILSMODEL') items=FormPage.psDEFormDetails}}
{{/each}}
],
rules: {
{{#each ctrl.psDEFormEditItemVRs as | ruleItem |}}
{{#neq ruleItem 2}}
{{#if ruleItem.valueRuleType 'DEFVALUERULE'}}
{{psDEFormEditItemName}}: [
{{#each ruleItem.psDEFVRGroupCondition as | condition |}}
{trigger: ['change', 'blur'],
validator: (_rule: RuleObject, value: string) => verifyRules(_rule,value,{
{{#condition.condType}}type: {{condition.condType}},{{/condition.condType}}
{{#condition.name}}name: {{condition.name}},{{/condition.name}}
{{#condition.maxValue}}maxValue: {{condition.maxValue}},{{/condition.maxValue}}
{{#condition.minValue}}minValue: {{condition.minValue}},{{/condition.minValue}}
{{#condition.ruleInfo}}ruleInfo: {{condition.ruleInfo}},{{/condition.ruleInfo}}
{{#condition.includeMaxValue}}includeMaxValue: {{condition.includeMaxValue}},{{/condition.includeMaxValue}}
{{#condition.includeMinValue}}includeMinValue: {{condition.includeMinValue}},{{/condition.includeMinValue}}
}) }
{{/each}}
]
{{/if}}
{{/neq}}
{{/each}}
},
}; };
/** /**
......
...@@ -5,6 +5,7 @@ export const CtrlConfig = { ...@@ -5,6 +5,7 @@ export const CtrlConfig = {
controlName: "{{ctrl.name}}", controlName: "{{ctrl.name}}",
items: [], items: [],
dataAgg: [], dataAgg: [],
selectedRowKeys: [],
aggMode: "{{ctrl.aggMode}}", aggMode: "{{ctrl.aggMode}}",
{{#if (eq ctrl.aggMode 'ALL')}} {{#if (eq ctrl.aggMode 'ALL')}}
aggEntity: "{{ctrl.aggPSAppDataEntity.codeName}}", aggEntity: "{{ctrl.aggPSAppDataEntity.codeName}}",
...@@ -29,6 +30,7 @@ export const CtrlConfig = { ...@@ -29,6 +30,7 @@ export const CtrlConfig = {
{{/if}} {{/if}}
{{#if ctrl.enablePagingBar}} {{#if ctrl.enablePagingBar}}
enablePagingBar: true, enablePagingBar: true,
current: 1,
pageSize: {{#if ctrl.pagingSize}}{{ctrl.pagingSize}}{{else}}20{{/if}}, pageSize: {{#if ctrl.pagingSize}}{{ctrl.pagingSize}}{{else}}20{{/if}},
pagination: { pagination: {
position: ['bottomRight'], position: ['bottomRight'],
...@@ -46,6 +48,7 @@ export const CtrlConfig = { ...@@ -46,6 +48,7 @@ export const CtrlConfig = {
{{#if ctrl.groupPSAppDEField}} {{#if ctrl.groupPSAppDEField}}
{ {
title: "分组", title: "分组",
align: "left",
columnType: "GROUP", columnType: "GROUP",
width: 100, width: 100,
resizable: true, resizable: true,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { CtrlConfig } from './{{spinalCase ctrl.codeName}}-grid-config'; import { CtrlConfig } from './{{spinalCase ctrl.codeName}}-grid-config';
import { GridControl, IActionParam, IParam, ControlAction } from '@ibiz-core'; import { GridControl, IActionParam, IParam, ControlAction, deepCopy } from '@ibiz-core';
interface Props { interface Props {
context: IParam; context: IParam;
...@@ -32,25 +32,62 @@ interface CtrlEmit { ...@@ -32,25 +32,62 @@ interface CtrlEmit {
} }
const emit = defineEmits<CtrlEmit>(); const emit = defineEmits<CtrlEmit>();
// 安装功能模块,提供状态和能力方法 // 安装功能模块,提供状态和能力方法
const { state, handleEditorEvent } = new GridControl(CtrlConfig).moduleInstall(props); const { state, load, handleEditorEvent } = new GridControl(CtrlConfig).moduleInstall(props);
// 表格滚动条配置 // 表格滚动条配置
const gridScrollOption = computed(() => { const gridScrollOption = computed(() => {
return { return {
scrollToFirstRowOnChange: true, scrollToFirstRowOnChange: true,
x: '100%', x: '110%',
y: '690px', y: '690px',
} }
}); });
// 表格行key
const rowKey = (record: IParam) => {
return record.srfkey;
}
// 表格行样式(斑马纹) // 表格行样式(斑马纹)
const rowClassName = (record: IParam, index: number) => { const rowClassName = (record: IParam, index: number) => {
return index % 2 === 1 ? 'table-striped' : null; return index % 2 === 1 ? "table-striped" : null;
}
// 表格行选中
const customRow = (record: IParam, index: number) => {
return {
onClick: () => {
if (!props.rowEditState) {
state.selectedRowKeys = [record.srfkey];
if (!record.children) {
emit("ctrlEvent",{ tag: state.controlName, action: "selectionChange", data: [deepCopy(record)] })
if (Object.is(props.rowActiveMode, 1)) {
emit("ctrlEvent",{ tag: state.controlName, action: "rowClick", data: [deepCopy(record)] })
}
}
}
},
onDblclick: () => {
if (!record.children && Object.is(props.rowActiveMode, 2)) {
emit("ctrlEvent",{ tag: state.controlName, action: "rowDbClick", data: [deepCopy(record)] })
}
}
};
} }
// 表格选择功能配置 // 表格选择功能配置
const rowSelectionOption = computed(() => { const rowSelectionOption = computed(() => {
if (props.rowEditState || props.selectFirstDefault) {
return false;
}
return { return {
columnWidth: {{#neq ctrl.aggMode 'NONE'}}90{{else}}50{{/neq}}, columnWidth: {{#neq ctrl.aggMode 'NONE'}}90{{else}}50{{/neq}},
selectedRowKeys: state.selectedRowKeys,
checkStrictly: props.multiple ? false : true,
onChange: (selectedRowKeys: string[], selectedRows: IParam[]) => { onChange: (selectedRowKeys: string[], selectedRows: IParam[]) => {
console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows); state.selectedRowKeys = selectedRowKeys;
const selection: IParam[] = [];
selectedRows.forEach((select: IParam) => {
if (!select.children) {
selection.push(select);
}
})
emit("ctrlEvent",{ tag: state.controlName, action: "selectionChange", data: selection })
}, },
}; };
}); });
...@@ -61,14 +98,17 @@ const handleResizeColumn = (width: number, column: IParam) => { ...@@ -61,14 +98,17 @@ const handleResizeColumn = (width: number, column: IParam) => {
// 处理表格变化(分页,过滤,排序) // 处理表格变化(分页,过滤,排序)
const handleChange = (pagination: IParam, filters: IParam, sorter: IParam, data: IParam) => { const handleChange = (pagination: IParam, filters: IParam, sorter: IParam, data: IParam) => {
const { current, pageSize } = pagination; const { current, pageSize } = pagination;
const { currentDataSource } = data; state.current = current;
console.log(pagination, filters, sorter, currentDataSource); state.pageSize = pageSize;
load();
} }
</script> </script>
<template> <template>
<a-table <a-table
bordered bordered
class="ibiz-grid" sticky
class="ibiz-grid{{#if ctrl.psSysCss}} {{ctrl.psSysCss.cssName}}{{/if}}"
:rowKey="rowKey"
:showHeader="{{#if ctrl.hideHeader}}false{{else}}true{{/if}}" :showHeader="{{#if ctrl.hideHeader}}false{{else}}true{{/if}}"
:scroll="gridScrollOption" :scroll="gridScrollOption"
:sortDirections="['ascend', 'descend']" :sortDirections="['ascend', 'descend']"
...@@ -76,6 +116,7 @@ const handleChange = (pagination: IParam, filters: IParam, sorter: IParam, data: ...@@ -76,6 +116,7 @@ const handleChange = (pagination: IParam, filters: IParam, sorter: IParam, data:
:row-selection="rowSelectionOption" :row-selection="rowSelectionOption"
:columns="state.columnsModel" :columns="state.columnsModel"
:pagination="state.pagination" :pagination="state.pagination"
:customRow="customRow"
:rowClassName="rowClassName" :rowClassName="rowClassName"
@change="handleChange" @change="handleChange"
@resizeColumn="handleResizeColumn"> @resizeColumn="handleResizeColumn">
...@@ -91,7 +132,7 @@ const handleChange = (pagination: IParam, filters: IParam, sorter: IParam, data: ...@@ -91,7 +132,7 @@ const handleChange = (pagination: IParam, filters: IParam, sorter: IParam, data:
{{!-- 快速工具栏 --}} {{!-- 快速工具栏 --}}
</div> </div>
</template> </template>
<template #bodyCell="{ column, text, record }"> <template #bodyCell="{ column, text, record, index }">
{{#each ctrl.psDEGridColumns as | column |}} {{#each ctrl.psDEGridColumns as | column |}}
{{>(lookup 'COLUMN') item=column ctrl=ctrl}} {{>(lookup 'COLUMN') item=column ctrl=ctrl}}
{{/each}} {{/each}}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册