提交 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 { createUUID } from 'qx-util';
import { calcActionItemAuthState, deepCopy, GridControlProps, GridControlState, IActionParam, IParam, MainControl } from '@ibiz-core';
/**
......@@ -22,11 +23,11 @@ export class GridControl extends MainControl {
*/
public setState(props: GridControlProps) {
super.setState(props);
this.controlState.multiple = toRef(props, 'multiple') as any;
this.controlState.rowEditState = toRef(props, 'rowEditState') as any;
this.controlState.rowActiveMode = toRef(props, 'rowActiveMode') as any;
this.controlState.selectedData = toRef(props, 'selectedData') as any;
this.controlState.selectFirstDefault = toRef(props, 'selectFirstDefault') as any;
this.controlState.multiple = toRef(props, "multiple") as any;
this.controlState.rowEditState = toRef(props, "rowEditState") as any;
this.controlState.rowActiveMode = toRef(props, "rowActiveMode") as any;
this.controlState.selectedData = toRef(props, "selectedData") as any;
this.controlState.selectFirstDefault = toRef(props, "selectFirstDefault") as any;
}
/**
......@@ -37,7 +38,12 @@ export class GridControl extends MainControl {
* @memberof GridControl
*/
public gridDataChange(rowIndex: number, name: string, value: any){
if (this.controlState.items[rowIndex][name] !== value) {
this.controlState.items[rowIndex][name] = value;
if (!this.controlState.items[rowIndex]["rowDataState"]) {
this.controlState.items[rowIndex]["rowDataState"] = "update";
}
}
}
/**
......@@ -61,14 +67,14 @@ export class GridControl extends MainControl {
* @memberof GridControl
*/
public getGridColumn(columns: IParam[], columnType: string): any {
columns.forEach((column: IParam) => {
for (const column of columns) {
if (Object.is(column.columnType, columnType)) {
return column;
return deepCopy(column);
}
if (column.children?.length > 0) {
return this.getGridColumn(column.children, columnType);
}
})
}
}
/**
......@@ -77,7 +83,7 @@ export class GridControl extends MainControl {
*/
public autoGroup() {
const { groupField } = this.controlState;
const dataRef = toRef(this.controlState, 'items');
const dataRef = toRef(this.controlState, "items");
let autoGroup: string[] = [];
dataRef.value.forEach((item: IParam) => {
if (item.hasOwnProperty(groupField)) {
......@@ -86,10 +92,10 @@ export class GridControl extends MainControl {
})
autoGroup = [...new Set(autoGroup)];
if (autoGroup.length > 0) {
const columnsModelRef = toRef(this.controlState, 'columnsModel');
const groupColumn = this.getGridColumn(columnsModelRef.value, 'GROUP');
const columnsModelRef = toRef(this.controlState, "columnsModel");
const groupColumn = this.getGridColumn(columnsModelRef.value, "GROUP");
const gridData: IParam[] = [];
autoGroup.forEach((group: string) => {
autoGroup.forEach((group: string, index: number) => {
const children: IParam[] = [];
dataRef.value.forEach((item: IParam) => {
if (Object.is(group, item[groupField])) {
......@@ -97,6 +103,7 @@ export class GridControl extends MainControl {
}
})
gridData.push({
srfkey: createUUID(),
[groupColumn.dataIndex]: group,
children: deepCopy(children),
})
......@@ -111,12 +118,12 @@ export class GridControl extends MainControl {
*/
public async codeListGroup() {
const { groupField } = this.controlState;
const dataRef = toRef(this.controlState, 'items');
const dataRef = toRef(this.controlState, "items");
// TODO 代码表数据
let codeListGroup: IParam[] = [];
if (codeListGroup.length > 0) {
const columnsModelRef = toRef(this.controlState, 'columnsModel');
const groupColumn = this.getGridColumn(columnsModelRef.value, 'GROUP');
const columnsModelRef = toRef(this.controlState, "columnsModel");
const groupColumn = this.getGridColumn(columnsModelRef.value, "GROUP");
const gridData: IParam[] = [];
const otherGroup: IParam[] = [];
codeListGroup.forEach((group: IParam) => {
......@@ -127,6 +134,7 @@ export class GridControl extends MainControl {
}
});
gridData.push({
srfkey: createUUID(),
[groupColumn.dataIndex]: group.text,
children: deepCopy(children),
})
......@@ -139,6 +147,7 @@ export class GridControl extends MainControl {
});
if (otherGroup.length > 0) {
gridData.push({
srfkey: createUUID(),
[groupColumn.dataIndex]: "其它",
children: deepCopy(otherGroup),
})
......@@ -152,9 +161,9 @@ export class GridControl extends MainControl {
* @memberof GridControl
*/
public calcGridAuthState() {
const dataRef = toRef(this.controlState, 'items');
const columnsModelRef = toRef(this.controlState, 'columnsModel');
let columnModel = this.getGridColumn(columnsModelRef.value, 'UAGRIDCOLUMN');
const dataRef = toRef(this.controlState, "items");
const columnsModelRef = toRef(this.controlState, "columnsModel");
let columnModel = this.getGridColumn(columnsModelRef.value, "UAGRIDCOLUMN");
if (columnModel) {
dataRef.value.forEach((item: IParam) => {
Object.assign(item, {
......@@ -164,18 +173,49 @@ export class GridControl extends MainControl {
}
}
/**
* @description 设置表格合并列
* @memberof GridControl
*/
public setGridColSpan() {
const columnsModelRef = toRef(this.controlState, "columnsModel");
columnsModelRef.value.forEach((columnModel: IParam) => {
const customRender = ({text, record, index, column}: IParam) => {
const option = {
props: {} as IParam,
};
if (record.children) {
if (Object.is(column.columnType, "GROUP")) {
Object.assign(option.props,{
colSpan: columnsModelRef.value.length,
});
} else {
Object.assign(option.props,{
colSpan: 0
});
}
}
return option;
}
Object.assign(columnModel,{
customRender: customRender,
})
});
}
/**
* @description 处理表格分组
* @memberof GridControl
*/
public handleGridGroup() {
const { groupMode, groupField } = this.controlState;
if (groupField) {
if (groupField && !Object.is(groupMode, "NONE")) {
if (Object.is(groupMode, "AUTO")) {
this.autoGroup();
} else if (Object.is(groupMode, "CODELIST")) {
this.codeListGroup();
}
this.setGridColSpan();
}
}
......@@ -198,21 +238,21 @@ export class GridControl extends MainControl {
*/
public getAggValue(aggData: IParam[], column: IParam): string {
switch (column.aggMode) {
case 'NONE':
return '';
case 'SUM':
case "NONE":
return "";
case "SUM":
let sum: number = 0;
aggData.forEach((item: IParam) => {
sum += Number(item[column.dataIndex] ? item[column.dataIndex] : 0);
})
return 'SUM:' + sum;
case 'AVG':
return "SUM:" + sum;
case "AVG":
let sum2: number = 0;
aggData.forEach((item: IParam) => {
sum2 += Number(item[column.dataIndex] ? item[column.dataIndex] : 0);
})
return 'AVG:' + Number(sum2 / (aggData.length)).toFixed(3);
case 'MAX':
return "AVG:" + Number(sum2 / (aggData.length)).toFixed(3);
case "MAX":
let max: number = 0;
aggData.forEach((item: IParam) => {
const value: number = Number(item[column.dataIndex] ? item[column.dataIndex] : 0);
......@@ -220,8 +260,8 @@ export class GridControl extends MainControl {
max = value;
}
})
return 'MAX:' + max;
case 'MIN':
return "MAX:" + max;
case "MIN":
let min: number = 0;
aggData.forEach((item: IParam) => {
const value: number = Number(item[column.dataIndex] ? item[column.dataIndex] : 0);
......@@ -229,9 +269,9 @@ export class GridControl extends MainControl {
min = value;
}
})
return 'MIN:' + min;
return "MIN:" + min;
default:
return '';
return "";
}
}
......@@ -240,20 +280,27 @@ export class GridControl extends MainControl {
* @memberof GridControl
*/
public async handleDataAgg() {
const { aggMode } = this.controlState;
if (!Object.is(aggMode, 'NONE')) {
const dataAggRef = toRef(this.controlState, 'dataAgg');
let aggData: IParam[];
if (Object.is(aggMode, 'PAGE')) {
const dataRef = toRef(this.controlState, 'items');
const { aggMode, enablePagingBar } = this.controlState;
if (!Object.is(aggMode, "NONE")) {
const dataAggRef = toRef(this.controlState, "dataAgg");
const currentRef = toRef(this.controlState, "current");
const pageSizeRef = toRef(this.controlState, "pageSize");
let aggData: IParam[] = [];
if (Object.is(aggMode, "PAGE")) {
const dataRef = toRef(this.controlState, "items");
aggData = [...dataRef.value];
} else if (Object.is(aggMode, 'ALL')) {
} else if (Object.is(aggMode, "ALL")) {
aggData = await this.remoteAgg();
}
const columnsModelRef = toRef(this.controlState, 'columnsModel');
if (enablePagingBar) {
const start: number = (currentRef.value - 1) * pageSizeRef.value > 0 ? (currentRef.value - 1) * pageSizeRef.value - 1 : 0;
const end: number = currentRef.value * pageSizeRef.value;
aggData = aggData.slice(start, end);
}
const columnsModelRef = toRef(this.controlState, "columnsModel");
const columnsModel: IParam[] = [];
columnsModelRef.value.forEach((column: IParam) => {
if (!Object.is(column.columnType, 'GROUPGRIDCOLUMN')) {
if (!Object.is(column.columnType, "GROUPGRIDCOLUMN")) {
columnsModel.push(column);
}
});
......@@ -265,6 +312,33 @@ export class GridControl extends MainControl {
}
}
/**
* @description 处理默认选中
* @memberof GridControl
*/
public handleDefaultSelect() {
const { selectedData, selectFirstDefault, controlName } = this.controlState;
if (selectedData?.length > 0) {
const selectedRowKeys: string[] = [];
const selectedRowKeysRef = toRef(this.controlState, "selectedRowKeys");
selectedData.forEach((selected: IParam) => {
if (selected.srfkey) {
selectedRowKeys.push(selected.srfkey);
}
});
selectedRowKeysRef.value = selectedRowKeys;
} else if (selectFirstDefault) {
const dataRef = toRef(this.controlState, "items");
if (dataRef.value[0]) {
this.emit("ctrlEvent", {
tag: controlName,
action: "selectionChange",
data: [deepCopy(dataRef.value[0])],
});
}
}
}
/**
* @description 使用加载功能模块
* @param {GridControlProps} props 传入的props
......@@ -278,38 +352,52 @@ export class GridControl extends MainControl {
const loadAction = this.controlState.controlAction.loadAction;
const {
controlService, context, viewParams, showBusyIndicator, noSort, minorSortDir, minorSortPSDEF,
enablePagingBar, pageSize
enablePagingBar
} = this.controlState;
const dataRef = toRef(this.controlState, 'items');
const paginationRef = toRef(this.controlState, 'pagination');
if(!loadAction){
return;
}
let _context = deepCopy(context);
let _viewParams = deepCopy(viewParams);
const dataRef = toRef(this.controlState, "items");
const paginationRef = toRef(this.controlState, "pagination");
// if(!loadAction){
// return;
// }
let _context = deepCopy(context ? context : {});
let _viewParams = deepCopy(viewParams ? context : {});
if (noSort && minorSortDir && minorSortPSDEF) {
Object.assign(_viewParams, { sort: `${minorSortPSDEF},${minorSortDir}`});
}
if (enablePagingBar) {
if (opt.current && opt.pageSize) {
Object.assign(_viewParams, { page: opt.current - 1, size: opt.pageSize});
} else {
Object.assign(_viewParams, { page: 0, size: pageSize});
}
}
const response = await controlService.get(loadAction, _context, {viewParams: _viewParams}, showBusyIndicator );
if (!response.status || response.status !== 200) {
return
const currentRef = toRef(this.controlState, "current");
const pageSizeRef = toRef(this.controlState, "pageSize");
Object.assign(_viewParams, { page: currentRef.value - 1, size: pageSizeRef.value});
}
// const response = await controlService.get(loadAction, _context, {viewParams: _viewParams}, showBusyIndicator );
// if (!response.status || response.status !== 200) {
// return
// }
const data = [];
for (let i = 0; i < 100; i++) {
data.push({
group: i % 2 === 1 ? "分组1": "分组2",
srfkey: i,
tefsubjecttypename: `Edrward ${i}`,
nian: i,
testdata: i,
updatedate: 32,
description: `London Park no. ${i}`,
});
}
dataRef.value = response.data;
dataRef.value = data;
// dataRef.value = response.data;
if (enablePagingBar) {
paginationRef.value['total'] = response.total;
// paginationRef.value['total'] = response.total;
paginationRef.value["total"] = 100;
}
this.calcGridAuthState();
this.handleDefaultSelect();
this.handleGridGroup();
this.handleDataAgg();
} catch (error) {
// todo 错误异常处理
console.error(error)
}
}
......@@ -358,16 +446,11 @@ export class GridControl extends MainControl {
const superParams = super.moduleInstall(props, emit);
const { load } = this.useLoad(props);
const handleEditorEvent = this.handleEditorEvent.bind(this);
this.handleEditorEvent = (rowIndex: number,actionParam: IActionParam) => {
handleEditorEvent(rowIndex, actionParam)
}
return {
...superParams,
state: this.controlState,
load,
handleEditorEvent: this.handleEditorEvent,
handleEditorEvent: this.handleEditorEvent.bind(this),
};
}
}
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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册