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

Merge remote-tracking branch 'origin/master'

package cn.ibizlab.codegen.model;
import cn.ibizlab.codegen.utils.Inflector;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
......@@ -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{
return (IPSApplication)opt;
}
private Map<String,AppEntityModel> appEntitiesMap=new LinkedHashMap<>();;
private Map<String,AppEntityModel> appEntitiesMap=new LinkedHashMap<>();
private Map<String,PageModel> pagesMap=new LinkedHashMap<>();
......@@ -77,4 +104,19 @@ public class AppModel extends BaseModel{
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 @@
{{#*inline "FILEUPLOADER_ONE"}}{{>@macro/editor/upload.hbs}}{{/inline}}
{{#*inline "PICTURE"}}{{>@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_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 @@
<a-col :span="24">
<IbizFormItem name="{{item.codeName}}" label="{{item.caption}}">
{{#if item.psEditor}}
{{>(lookup . 'item.psEditor.editorType') item=item}}
{{>(lookup . 'item.psEditor.editorType') item=item controlType="form"}}
{{/if}}
</IbizFormItem>
</a-col>
......
{{#*inline "FORMPAGE"}}{{>@macro/form-detail/form-page.hbs}}{{/inline}}
{{#*inline "GROUPPANEL"}}{{>@macro/form-detail/form-group.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 @@
title: "{{item.caption}}",
columnType: "{{item.columnType}}",
{{#if item.align}}
align: "{{item.align}}",
align: "{{lowerCase item.align}}",
{{/if}}
{{#neq lastColumn true}}
{{#if item.widthUnit 'PX'}}
width: {{item.width}},
{{else}}
minWidth: {{item.width}},
{{/if}}
resizable: true,
{{/neq}}
{{#eq item.columnType 'GROUPGRIDCOLUMN'}}
children: [
{{#each item.psDEGridColumns as | column |}}
......@@ -19,7 +17,10 @@
{{/each}}
],
{{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,
enableSort: {{item.enableSort}},
{{#if item.aggMode}}
......
{{#neq item.columnType 'GROUPGRIDCOLUMN'}}
<div v-if="column.dataIndex === '{{item.codeName}}'" class="table-cell">
{{#eq item.columnType 'DEFGRIDCOLUMN'}}
{{#if item.enableRowEdit}}
{{#if (neq item.columnType 'GROUPGRIDCOLUMN')}}
<div v-if="Object.is(column.dataIndex, '{{item.codeName}}')" class="table-cell">
{{#if (eq item.columnType 'DEFGRIDCOLUMN')}}
{{#if item.enableRowEdit}}
<div v-if="state.rowEditState" class="editor-cell">
{{#each ctrl.psDEGridEditItems as | editColumn | }}
{{#eq editColumn.codeName (item.codeName)}}
{{#if item.psEditor}}
{{>(lookup . 'item.psEditor.editorType') item=item}}
{{>(lookup . 'item.psEditor.editorType') item=item ctrlType="grid"}}
{{/if}}
{{/eq}}
{{/each}}
......@@ -20,13 +20,13 @@
<span class="text">\{{text}}</span>
</div>
{{/if}}
{{/eq}}
{{#eq item.columnType 'UAGRIDCOLUMN'}}
{{/if}}
{{#if (eq item.columnType 'UAGRIDCOLUMN')}}
{{!-- <ibizToolbar
:toolbarModel="state.actionModel"
@toolbarEvent="handleToolbarEvent"
:toolbarModel="record.{{lowerCase item.codeName}}"
:context="state.context"
:viewParams="state.viewParams"/> --}}
{{/eq}}
:viewParams="state.viewParams"
@toolbarEvent="($event: ) => handleToolbarEvent()"/> --}}
{{/if}}
</div>
{{/neq}}
{{/if}}
......@@ -87,3 +87,36 @@ export function useContextParams(props: Record<any, any>) {
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 {
//todo
}
public handleCtrlEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam;
// TODO
console.log(tag, action, data);
}
/**
* 安装部件所有功能模块的方法
* @param props 传入的Props
......@@ -58,7 +64,8 @@ export class MainView extends ViewBase {
return {
...superParams,
state: this.viewState,
handleToolbarEvent: this.handleToolbarEvent,
handleToolbarEvent: this.handleToolbarEvent.bind(this),
handleCtrlEvent: this.handleCtrlEvent.bind(this),
};
}
}
......@@ -29,6 +29,13 @@ export class ControlBase {
*/
public route: RouteLocationNormalizedLoaded = useRoute();
/**
* @description 事件
* @type {*}
* @memberof ControlBase
*/
public emit: any;
/**
* Creates an instance of ControlBase.
* @param {*} options 配置参数
......@@ -75,6 +82,7 @@ export class ControlBase {
* @memberof ControlBase
*/
public moduleInstall(props: ControlPropsBase, emit?: Function) {
this.emit = emit?.bind(this);
this.setState(props);
this.useControlContextParams(props);
return {
......
......@@ -28,12 +28,31 @@ export class FormControl extends MainControl {
*/
public formDataChange(name: string, value: any) {
this.controlState.data[name] = value;
// TODO 重置项逻辑
this.resetFormData(name);
// TODO 表单项更新
// TODO 动态控制逻辑
// 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.
......@@ -301,17 +320,12 @@ export class FormControl extends MainControl {
const { load } = this.useLoad(props);
const { save } = this.useSave(props);
const handleEditorEvent = this.handleEditorEvent.bind(this);
this.handleEditorEvent = (actionParam: IActionParam) => {
handleEditorEvent(actionParam);
};
return {
...superParams,
state: this.controlState,
load,
save,
handleEditorEvent: this.handleEditorEvent,
handleEditorEvent: this.handleEditorEvent.bind(this),
};
}
}
......@@ -64,6 +64,13 @@ export interface GridControlState extends MainControlState {
*/
selectedData: IParam[];
/**
* @description 选中行keys
* @type {string[]}
* @memberof GridControlState
*/
selectedRowKeys: string[];
/**
* @description 是否默认选中第一条数据
* @type {boolean}
......@@ -71,6 +78,13 @@ export interface GridControlState extends MainControlState {
*/
selectFirstDefault: boolean;
/**
* @description 当前页
* @type {number}
* @memberof GridControlState
*/
current: number;
/**
* @description 分页大小
* @type {number}
......
import {{page.codeName}} from "./{{spinalCase page.codeName}}.vue";
export { {{page.codeName}} };
export default {{page.codeName}};
import {{page.codeName}} from "./{{spinalCase page.codeName}}.vue";
export { {{page.codeName}} };
export default {{page.codeName}};
export const ViewConfig = {
viewCodeName: '{{page.codeName}}',
viewName: '{{page.name}}',
viewCaption: '{{page.caption}}',
{{> @macro/front-end/view/common/viewBaseConfig.hbs}}
{{#page.ctrls}}
{{#eq controlType "TOOLBAR"}}
{{lowerCase codeName}}:{
......
......@@ -34,9 +34,15 @@ const { state, handleToolbarEvent } = new EditView(ViewConfig).moduleInstall(pro
</script>
<template>
<IbizDefaultViewLayout class="ibiz-edit-view">
<IbizDefaultViewLayout :class="['ibiz-edit-view', state.viewSysCss]">
<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>
{{#page.ctrls}}
{{#eq controlType "TOOLBAR"}}
......
import {{page.codeName}} from "./{{spinalCase page.codeName}}.vue";
export { {{page.codeName}} };
export default {{page.codeName}};
......@@ -29,7 +29,7 @@ interface ViewEmit {
const emit = defineEmits<ViewEmit>();
// 安装功能模块,提供状态和能力方法
const { state } = new GridView(ViewConfig).moduleInstall(props);
const { state, handleCtrlEvent } = new GridView(ViewConfig).moduleInstall(props);
</script>
......@@ -45,13 +45,13 @@ const { state } = new GridView(ViewConfig).moduleInstall(props);
{{#eq controlType "GRID"}}
<{{codeName}}Grid
:context="state.context"
:multiple="false"
:rowEditState="state.rowEditState"
:rowActiveMode="state.gridRowActiveMode"
:showBusyIndicator="true"
:viewParams="state.viewParams"
:controlAction="state.controlsAction"
:viewSubject="state.viewSubject"
@ctrlEvent="handleCtrlEvent"
></{{codeName}}Grid>
{{/eq}}
{{/page.ctrls}}
......
......@@ -2,7 +2,7 @@ import { createRouter, createWebHashHistory } from 'vue-router';
const routes = [
{
path: "/{{lowerCase app.defaultPSAppIndexView.codeName}}/:{{lowerCase app.defaultPSAppIndexView.codeName}}?",
path: "/apps/:app?",
{{!-- beforeEnter: (to: any, from: any, next: any) => {
next();
}, --}}
......@@ -10,100 +10,50 @@ const routes = [
captionTag: "{{#if app.defaultPSAppIndexView.capPSLanguageRes}}{{app.defaultPSAppIndexView.capPSLanguageRes.lanResTag}}{{/if}}",
caption: "{{app.defaultPSAppIndexView.caption}}",
viewType: "{{app.defaultPSAppIndexView.viewType}}",
dynaModelFilePath: "{{app.defaultPSAppIndexView.dynaModelFilePath}}",
{{#if app.defaultPSAppIndexView.psSysImage}}
imgPath: "{{app.defaultPSAppIndexView.psSysImage.imagePath}}",
iconCls: "{{app.defaultPSAppIndexView.psSysImage.cssClass}}",
{{/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}},
},
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: [
{{#each app.allPSAppViews as | appView |}}
{{!-- 实体视图 --}}
{{#if appView.psAppDataEntity}}
{{!-- 多重路径 --}}
{{#if appView.psAppDataEntity.psAppDERSPathCount}}
{{#each app.appEntityResources as |appEntityResource|}}
{{#if appEntityResource.appDataEntity.allPSAppViews}}
{{#each appEntityResource.appDataEntity.allPSAppViews as |appView|}}
{{#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: {
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}}
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 appView.capPSLanguageRes}}
captionTag: "{{appView.capPSLanguageRes.lanResTag}}",
{{/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}}",
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 appView.psAppDataEntity.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}}
{{#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}}",
{ pathName: "apps", parameterName: "app" },
{{#if appEntityResource.majorCodeName}}
{ pathName: "{{pluralize appEntityResource.majorCodeName}}", parameterName: "{{appEntityResource.majorCodeName}}" },
{{/if}}
parameters: [
{ pathName: "{{lowerCase app.defaultPSAppIndexView.codeName}}", parameterName: "{{lowerCase app.defaultPSAppIndexView.codeName}}" },
{ pathName: "{{lowerCase appView.codeName}}", parameterName: "{{lowerCase appView.codeName}}" },
{ pathName: "{{pluralize appEntityResource.curCodeName}}", parameterName: "{{appEntityResource.curCodeName}}" }
],
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}}
{{/each}}
]
},
{
path: "/",
redirect: "/{{lowerCase app.defaultPSAppIndexView.codeName}}"
redirect: "/apps/{{lowerCase app.codeName}}"
},
]
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';
export const CtrlConfig = {
......@@ -6,6 +7,33 @@ export const CtrlConfig = {
controlName: '{{ctrl.name}}',
controlService: new ControlService(),
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 = {
controlName: "{{ctrl.name}}",
items: [],
dataAgg: [],
selectedRowKeys: [],
aggMode: "{{ctrl.aggMode}}",
{{#if (eq ctrl.aggMode 'ALL')}}
aggEntity: "{{ctrl.aggPSAppDataEntity.codeName}}",
......@@ -29,6 +30,7 @@ export const CtrlConfig = {
{{/if}}
{{#if ctrl.enablePagingBar}}
enablePagingBar: true,
current: 1,
pageSize: {{#if ctrl.pagingSize}}{{ctrl.pagingSize}}{{else}}20{{/if}},
pagination: {
position: ['bottomRight'],
......@@ -46,6 +48,7 @@ export const CtrlConfig = {
{{#if ctrl.groupPSAppDEField}}
{
title: "分组",
align: "left",
columnType: "GROUP",
width: 100,
resizable: true,
......
......@@ -2,7 +2,7 @@
<script setup lang="ts">
import { Subject } from 'rxjs';
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 {
context: IParam;
......@@ -32,25 +32,62 @@ interface 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(() => {
return {
scrollToFirstRowOnChange: true,
x: '100%',
x: '110%',
y: '690px',
}
});
// 表格行key
const rowKey = (record: IParam) => {
return record.srfkey;
}
// 表格行样式(斑马纹)
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(() => {
if (props.rowEditState || props.selectFirstDefault) {
return false;
}
return {
columnWidth: {{#neq ctrl.aggMode 'NONE'}}90{{else}}50{{/neq}},
selectedRowKeys: state.selectedRowKeys,
checkStrictly: props.multiple ? false : true,
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) => {
// 处理表格变化(分页,过滤,排序)
const handleChange = (pagination: IParam, filters: IParam, sorter: IParam, data: IParam) => {
const { current, pageSize } = pagination;
const { currentDataSource } = data;
console.log(pagination, filters, sorter, currentDataSource);
state.current = current;
state.pageSize = pageSize;
load();
}
</script>
<template>
<a-table
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}}"
:scroll="gridScrollOption"
:sortDirections="['ascend', 'descend']"
......@@ -76,6 +116,7 @@ const handleChange = (pagination: IParam, filters: IParam, sorter: IParam, data:
:row-selection="rowSelectionOption"
:columns="state.columnsModel"
:pagination="state.pagination"
:customRow="customRow"
:rowClassName="rowClassName"
@change="handleChange"
@resizeColumn="handleResizeColumn">
......@@ -91,7 +132,7 @@ const handleChange = (pagination: IParam, filters: IParam, sorter: IParam, data:
{{!-- 快速工具栏 --}}
</div>
</template>
<template #bodyCell="{ column, text, record }">
<template #bodyCell="{ column, text, record, index }">
{{#each ctrl.psDEGridColumns as | column |}}
{{>(lookup 'COLUMN') item=column ctrl=ctrl}}
{{/each}}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册