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

Merge remote-tracking branch 'origin/master'

/**
* {{singleAppMethod.codeName}}
*
* @param {IContext} [context={}]
* @param {IParam} [data = {}]
* @returns {Promise<any>}
* @memberof {{pascalCase appEntity.codeName}}ServiceBase
*/
public async {{singleAppMethod.codeName}}(context: IContext = {}, data: IParam = {}): Promise<any> {
try {
// data = await this.executeAppDELogic('{{singleAppMethod.psDEAction.psDELogic.codeName}}', context, data);
const res = {
ok: true,
status: 200,
data: data
};
return res;
} catch (error: any) {
const res = {
ok: false,
status: 500,
message: error?.message
}
return res;
}
}
/**
/**
* {{singleAppMethod.codeName}}
*
* @param {IContext} [context={}]
......@@ -6,7 +6,7 @@
* @returns {Promise<any>}
* @memberof {{pascalCase appEntity.codeName}}ServiceBase
*/
public async {{singleAppMethod.codeName}}(context: IContext = {}, data: IParam = {}): Promise<any> {
public async {{singleAppMethod.codeName}}(context: IContext = {}, data: IParam = {}): Promise<any> {
{{! 方法路径是否带资源主键 }}
const deResPath = this.buildDeResPath(context, {{singleAppMethod.psDEServiceAPIMethod.needResourceKey}});
{{#if (eq singleAppMethod.methodType "SELECT")}}
......@@ -45,4 +45,4 @@
this.afterExecuteAction(context,data,'{{singleAppMethod.codeName}}');
{{/if}}
return res;
}
\ No newline at end of file
}
/**
* {{singleAppMethod.codeName}}
*
* @param {IContext} [context={}]
* @param {IParam} [data = {}]
* @returns {Promise<any>}
* @memberof {{pascalCase appEntity.codeName}}ServiceBase
*/
public async {{singleAppMethod.codeName}}(context: IContext = {}, data: IParam = {}): Promise<any> {
{{#if singleAppMethod.psDEAction.scriptCode}}
eval(`{{singleAppMethod.psDEAction.scriptCode}}`);
{{/if}}
const res = {
ok: true,
status: 200,
data: data
}
return res;
}
......@@ -32,5 +32,33 @@
aggMode: "{{item.aggMode}}",
{{/if}}
{{/eq}}
{{#if item.enableRowEdit}}
{{#each ctrl.psDEGridEditItems as | editColumn | }}
{{#if (eq editColumn.codeName item.codeName)}}
{{#if editColumn.resetItemName}}
resetItemName: "{{editColumn.resetItemName}}",
{{/if}}
{{#if editColumn.valueItemName}}
valueItemName: "{{editColumn.valueItemName}}",
{{/if}}
{{#each ctrl.psDEGridEditItemUpdates as | updateItem | }}
{{#if (eq updateItem.codeName editColumn.codeName)}}
updateItem: {
name: "{{updateItem.name}}",
codeName: "{{updateItem.codeName}}",
{{#if updateItem.customCode}}
customCode: {{updateItem.customCode}},
scriptCode: `{{updateItem.scriptCode}}`,
{{else}}
showBusyIndicator: {{updateItem.showBusyIndicator}},
appDEMethod: "{{updateItem.psAppDEMethod.id}}",
updateDetails: [{{#each updateItem.psDEGEIUpdateDetails as | updateDetails | }}"{{updateDetails.name}}",{{/each}}],
{{/if}}
},
{{/if}}
{{/each}}
{{/if}}
{{/each}}
{{/if}}
},
{{/unless}}
......@@ -43,13 +43,25 @@ export class {{pascalCase appEntity.codeName}}ServiceBase extends EntityService
}
{{#each appEntity.allPSAppDEMethods as |singleAppMethod| }}
{{! 非内置行为才输出 }}
{{#if (eq isBuiltinMethod false)}}
{{! 存在接口方法才输出 }}
{{#if singleAppMethod.psDEServiceAPIMethod}}
{{! 远端接口 }}
{{! 非内置行为和非临时数据方法才输出 }}
{{#if (and (eq builtinMethod false) (eq tempDataMode 0))}}
{{#if (eq appEntity.psDEServiceAPI.nested true)}}
{{!-- todo嵌套行为补充 --}}
{{else}}
{{!-- todo 插件 --}}
{{#if (and (eq methodType 'DEACTION') psDEAction (eq psDEAction.actionType 'DELOGIC'))}}
{{!-- 实体处理逻辑 --}}
{{> @macro/front-end/entity/service-delogic-method.hbs singleAppMethod=singleAppMethod}}
{{else if (and (eq methodType 'DEACTION') psDEAction (eq psDEAction.actionType 'SCRIPT'))}}
{{!-- 脚本代码 --}}
{{> @macro/front-end/entity/service-script-method.hbs singleAppMethod=singleAppMethod}}
{{else if (and singleAppMethod.psDEServiceAPIMethod appEntity.major)}}
{{!-- 远程接口 --}}
{{> @macro/front-end/entity/service-remote-method.hbs singleAppMethod=singleAppMethod}}
{{/if}}
{{/if}}
{{/if}}
{{/each}}
......
......@@ -56,7 +56,7 @@ interface DropdownListProps {
/**
* @description 代码表标识
*/
codeListTag?: string;
codeListTag: string;
/**
* @description 代码表类型
......@@ -81,10 +81,7 @@ const props = withDefaults(defineProps<DropdownListProps>(), {
const emit = defineEmits<EditorEmit>()
const { handleEditorNavParams, loadCodeListData } = new EditorBase();
const { navContext, navViewParam } = handleEditorNavParams(props);
let curValue: Ref<any> = ref(
props.multiple ?
props.value?.split(props.valueSeparator) : props.value
);
let curValue : Ref<any> = computed(() => props.multiple ? props.value?.split(props.valueSeparator) : props.value);
let items: Ref<IParam[]> = ref([]);
const onChange = (select: any, option: any) => {
const value = typeOf(select) == 'array' ? select.join(props.valueSeparator) : select;
......
......@@ -204,7 +204,7 @@ export class AppSysAction {
public static newRow(params: IUIActionParams) {
const { actionEnvironment } = params;
// 视图里获取多数据部件
if (hasFunction(actionEnvironment.xDataControl, "newRow")) {
if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "newRow")) {
actionEnvironment.xDataControl.newRow();
} else if (isExist(actionEnvironment.newRow)) {
actionEnvironment.newRow();
......@@ -220,7 +220,7 @@ export class AppSysAction {
public static save(params: IUIActionParams) {
const { actionEnvironment } = params;
// 视图里获取多数据部件
if (hasFunction(actionEnvironment.xDataControl, "save")) {
if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "save")) {
actionEnvironment.xDataControl.save();
} else if (isExist(actionEnvironment.save)) {
actionEnvironment.save();
......@@ -236,7 +236,7 @@ export class AppSysAction {
public static saveRow(params: IUIActionParams) {
const { actionEnvironment } = params;
// 视图里获取多数据部件
if (hasFunction(actionEnvironment.xDataControl, "save")) {
if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "save")) {
actionEnvironment.xDataControl.save();
} else if (isExist(actionEnvironment.save)) {
actionEnvironment.save();
......@@ -252,10 +252,10 @@ export class AppSysAction {
public static remove(params: IUIActionParams) {
const { actionEnvironment, data } = params;
// 视图里获取多数据部件
if (hasFunction(actionEnvironment.xDataControl, "remove")) {
if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "remove")) {
actionEnvironment.xDataControl.remove(data);
} else if (isExist(actionEnvironment.remove)) {
actionEnvironment.remove();
actionEnvironment.remove(data);
}
}
......@@ -268,7 +268,7 @@ export class AppSysAction {
public static refresh(params: IUIActionParams) {
const { actionEnvironment } = params;
// 视图里获取多数据部件
if (hasFunction(actionEnvironment.xDataControl, "refresh")) {
if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "refresh")) {
actionEnvironment.xDataControl.refresh();
} else if (isExist(actionEnvironment.refresh)) {
actionEnvironment.refresh();
......@@ -296,7 +296,7 @@ export class AppSysAction {
*/
public static async saveAndExit(params: IUIActionParams) {
const { actionEnvironment } = params;
if (hasFunction(actionEnvironment.xDataControl, "save")) {
if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "save")) {
await actionEnvironment.xDataControl.save();
} else if (isExist(actionEnvironment.save)) {
await actionEnvironment.save();
......@@ -314,7 +314,7 @@ export class AppSysAction {
*/
public static async saveAndNew(params: IUIActionParams) {
const { actionEnvironment } = params;
if (hasFunction(actionEnvironment.xDataControl, "save")) {
if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "save")) {
await actionEnvironment.xDataControl.save();
} else if (isExist(actionEnvironment.save)) {
await actionEnvironment.save();
......@@ -338,7 +338,7 @@ export class AppSysAction {
public static async removeAndExit(params: IUIActionParams) {
const { actionEnvironment } = params;
// 视图里获取多数据部件
if (hasFunction(actionEnvironment.xDataControl, "remove")) {
if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "remove")) {
await actionEnvironment.xDataControl.remove();
} else if (isExist(actionEnvironment.remove)) {
await actionEnvironment.remove();
......
......@@ -133,6 +133,9 @@ export class GridControl extends MDControl {
if (pagination) {
this.load();
}
if (sorter) {
this.load({ sort: `${sorter.field},${sorter.order == 'descend' ? 'desc' : 'asc'}` });
}
}
return {
useScrollOption,
......@@ -154,18 +157,51 @@ export class GridControl extends MDControl {
const { tag, action, data } = actionParam;
switch (action) {
case "valueChange":
this.handleGridItemValueChange(rowIndex, tag, data);
break;
default:
break;
}
}
/**
* @description 表格项值改变
* @param {*} data
* @param {number} rowIndex
* @param {string} tag
* @memberof GridControl
*/
public handleGridItemValueChange(rowIndex: number, tag: string, data: any) {
const { items } = toRefs(this.state);
if (items.value[rowIndex][tag] !== data) {
items.value[rowIndex][tag] = data;
items.value[rowIndex]["rowDataState"] = "update";
this.resetGridData(tag, data, rowIndex);
this.validateField(tag, data, rowIndex);
}
break;
default:
break;
this.updateGridEditItem(tag, data, rowIndex);
}
}
/**
* @description 重置表格数据
* @param {string} name
* @param {*} data
* @param {number} rowIndex
* @memberof GridControl
*/
public resetGridData(name: string, data: any, rowIndex: number) {
const { columnsModel } = this.state;
if (columnsModel && columnsModel.length > 0) {
columnsModel.forEach((column: any) => {
if (column.resetItemName && Object.is(name, column.resetItemName)) {
this.handleGridItemValueChange(rowIndex, column.dataIndex, null);
if (column.valueItemName) {
this.handleGridItemValueChange(rowIndex, column.valueItemName, null);
}
}
})
}
}
/**
*
......@@ -192,6 +228,44 @@ export class GridControl extends MDControl {
})
}
/**
* @description 更新表格编辑项
* @param {string} name
* @param {*} data
* @param {number} rowIndex
* @memberof GridControl
*/
public async updateGridEditItem(name: string, data: any, rowIndex: number) {
const { items, columnsModel, context, viewParams, controlService, appDeCodeName, appDeKeyFieldName } = this.state;
if (columnsModel && columnsModel.length > 0) {
columnsModel.forEach(async (column: any) => {
if (column.updateItem) {
const updateItem: any = column.updateItem;
if (updateItem.customCode) {
if (updateItem.scriptCode) {
eval(updateItem.scriptCode);
}
} else {
const arg = Object.assign(deepCopy(viewParams), items[rowIndex]);
const tempContext = Object.assign(deepCopy(context), { [appDeCodeName?.toLowerCase()]: items[rowIndex][appDeKeyFieldName] || items[rowIndex].srfkey });
const response = await controlService.frontLogic(
tempContext,
{ viewParams: arg },
{ action: updateItem.appDEMethod, isLoading: updateItem.showBusyIndicator },
);
if (response.status && response.status == 200) {
updateItem.updateDetails?.forEach((detailName: string) => {
if (detailName && items[rowIndex].hasOwnProperty(detailName)) {
items[rowIndex][detailName] = response.data[detailName];
}
});
}
}
}
})
}
}
/**
* @description 操作列事件触发
* @param {IActionParam} actionParam
......
......@@ -98,4 +98,24 @@ export class GridService<T extends ControlVOBase> extends ControlServiceBase<T>
response.data = this.newControlVO(response.data);
return this.handleResponse(response, opts);
}
/**
* 前台逻辑
*
* @param [context={}] 上下文参数
* @param [data={}] 视图参数
* @param opts
* @return {*}
*/
public async frontLogic(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise<any> {
let _entityService: any = this.entityService;
const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
if (hasFunction(_entityService, opts.action)) {
const response = await _entityService[opts.action](Context, Data, opts.isLoading);
response.data = this.newControlVO(response.data);
return this.handleResponse(response, opts);
} else {
return null;
}
}
}
.app-grid-batchtoolbar-container {
display: flex;
height: 100%;
}
.app-grid-batchtoolbar {
position: absolute;
left: 0;
.toolbar-buttons {
height: 100%;
}
}
.app-grid-batchtoolbar.toolbar .toolbar-buttons .ant-space-item {
padding: 0 6px;
height: 100%;
&:first-child {
padding-left: 0;
}
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
}
.ant-card-body {
text-align: left;
padding: 16px;
}
}
\ No newline at end of file
......@@ -5,3 +5,4 @@
@use './app-tab-exp-panel.scss';
@use './app-tab-view-panel.scss';
@use './app-portlet.scss';
@use './app-grid.scss';
\ No newline at end of file
{{>@macro/front-end/widgets/grid-detail/include-grid.hbs}}
<script setup lang="ts">
import { Subject } from 'rxjs';
import { ctrlState } from './{{spinalCase ctrl.codeName}}-grid-state';
import { GridControl, IActionParam, IParam, IContext, ControlAction, deepCopy } from '@core';
{{#if ctrl.batchToolBarItems}}
import AppToolbar from '@components/common/app-toolbar.vue';
{{/if}}
interface Props {
name:string,
......@@ -39,6 +41,22 @@ const emit = defineEmits<CtrlEmit>();
// 安装功能模块,提供状态和能力
const { name, state, useCustom, onEditorEvent, onToolbarEvent, onActionColEvent, newRow, remove, save, load, refresh, getData } = new GridControl(ctrlState, props, emit).moduleInstall();
const { useScrollOption, useRowKey, useRowClassName, useCustomRow, useRowSelectionOption, onResizeColumn, onGridChange } = useCustom;
{{#if ctrl.batchToolBarItems}}
const renderBatchToolbar = (total: number, range: IParam[]) => {
return (
h('div', { class: 'app-grid-batchtoolbar-container' }, [
h(AppToolbar, {
mode: 'button',
class: 'app-grid-batchtoolbar',
name: '{{ctrl.batchToolBarName}}',
actionModel: state.batchToolbar,
onOnToolbarEvent: (event: any) => onToolbarEvent(event)
}),
`显示 ${range[0]} - ${range[1]} 条数据,共 ${total} 条数据`
])
)
}
{{/if}}
// 暴露内部状态及能力
defineExpose({ name, state, newRow, remove, save, load, refresh, getData });
......@@ -56,7 +74,15 @@ defineExpose({ name, state, newRow, remove, save, load, refresh, getData });
:data-source="state.items"
:row-selection="useRowSelectionOption"
:columns="state.columnsModel"
{{#if ctrl.batchToolBarItems}}
:pagination="Object.assign(state.mdCtrlPaging.pagination, {
showTotal: (total, range) => {
return renderBatchToolbar(total, range);
}
})"
{{else}}
:pagination="state.mdCtrlPaging.pagination"
{{/if}}
:customRow="useCustomRow"
:rowClassName="useRowClassName"
@change="onGridChange"
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册