提交 5a7024f6 编写于 作者: tony001's avatar tony001

update:新增工具栏状态控制逻辑

上级 5d89de7e
......@@ -102,6 +102,7 @@ public class PageModel extends BaseModel{
appUIAction.put("uIActionMode",UIAction.getUIActionMode());
appUIAction.put("uIActionTag",UIAction.getUIActionTag());
appUIAction.put("uIActionType",UIAction.getUIActionType());
appUIAction.put("actionTarget",UIAction.getActionTarget());
toolbarItem.put("uIAction",appUIAction);
}
}
......
......@@ -57,13 +57,13 @@
{{/if}}
{{/each}}
},
toolbar: [
{{#page.viewToolBarItems}}
toolbar: [
{{#items}}
{ id:'{{id}}',name:'{{name}}',caption:'{{caption}}',groupExtractMode:'{{groupExtractMode}}',itemType:'{{itemType}}',noPrivDisplayMode:'{{noPrivDisplayMode}}',showIcon:{{showIcon}},showCaption:{{showCaption}},tooltip:'{{tooltip}}',disabled: false, visible: true, imgPath: '{{imgPath}}',iconClass: '{{iconClass}}',xDataControlName:'{{xDataControlName}}',{{#if uIAction}}uIAction:{codeName:'{{uIAction.codeName}}',fullCodeName:'{{uIAction.fullCodeName}}',uIActionMode:'{{uIAction.uIActionMode}}',uIActionTag:'{{uIAction.uIActionTag}}',uIActionType:'{{uIAction.uIActionType}}'}{{/if}} },
{ id:'{{id}}',name:'{{name}}',caption:'{{caption}}',groupExtractMode:'{{groupExtractMode}}',itemType:'{{itemType}}',noPrivDisplayMode:'{{noPrivDisplayMode}}',showIcon:{{showIcon}},showCaption:{{showCaption}},tooltip:'{{tooltip}}',disabled: false, visible: true, imgPath: '{{imgPath}}',iconClass: '{{iconClass}}',xDataControlName:'{{xDataControlName}}',{{#if uIAction}}uIAction:{codeName:'{{uIAction.codeName}}',fullCodeName:'{{uIAction.fullCodeName}}',uIActionMode:'{{uIAction.uIActionMode}}',actionTarget:'{{uIAction.actionTarget}}',uIActionTag:'{{uIAction.uIActionTag}}',uIActionType:'{{uIAction.uIActionType}}'}{{/if}} },
{{/items}}
],
{{/page.viewToolBarItems}}
],
{{#each page.ctrls as | ctrl |}}
{{#if (neq ctrl.controlType "TOOLBAR")}}
{{>(lookup . 'ctrl.controlType') ctrl=ctrl}}{{#unless @last}},{{/unless}}
......
......@@ -29,8 +29,6 @@ let slotStyle = computed(() => {
}
let result = '';
result += isObject(attrs.style) ? styleObj2Str(attrs.style) : attrs.style;
console.log(attrs.style)
console.log(result)
if (layout?.value?.colStyle) {
result += layout.value.colStyle;
}
......
import { EditViewState, IParam, MainView } from '@core';
import { EditViewState, IActionParam, IParam, MainView } from '@core';
/**
* @description 编辑视图
......@@ -54,11 +54,75 @@ export class EditView extends MainView {
})
}
/**
* 处理部件事件
*
* @param {IActionParam} actionParam
* @memberof EditView
*/
public onCtrlEvent(actionParam: IActionParam) {
super.onCtrlEvent(actionParam);
const { tag, action, data } = actionParam;
if (Object.is(tag, 'form')) {
this.formEvent(action, data);
}
}
/**
* 表单事件
*
* @param {string} action
* @param {*} data
* @memberof EditView
*/
public formEvent(action: string, data: IParam): void {
if (Object.is(action, 'load')) {
this.onFormLoad(data);
}
if (Object.is(action, 'save')) {
this.onFormSave(data);
}
if (Object.is(action, 'remove')) {
this.onFormRemove(data);
}
}
/**
* 表单加载完成
*
* @param {*} data
* @memberof EditView
*/
public onFormLoad(data: IParam): void {
// 设置工具栏状态
const state: boolean = !Object.is(data.srfuf, '1');
this.setToolbarItemState(state);
}
/**
* 表单保存完成
*
* @param {*} data
* @memberof EditView
*/
public onFormSave(data: IParam): void {
}
/**
* 表单删除完成
*
* @param {*} data
* @memberof EditView
*/
public onFormRemove(data: IParam): void {
}
/**
* 获取表单部件
*
* @return {*} {*}
* @memberof IndexView
* @memberof EditView
*/
public getForm(): any {
return unref(this.form);
......
......@@ -42,11 +42,11 @@ public declare state: GridViewState;
* @memberof MDView
*/
public onCtrlEvent(actionParam: IActionParam) {
super.onCtrlEvent(actionParam);
const { tag, action, data } = actionParam;
if (Object.is(tag, 'grid')) {
this.MDCtrlEvent(action, data);
}
super.onCtrlEvent(actionParam);
}
/**
......
......@@ -15,6 +15,32 @@ export class MainView extends ViewBase {
*/
public declare state: MainViewState;
/**
* 设置工具栏项状态
*
* @param {boolean} state 初始化状态
* @return {*}
* @memberof MainView
*/
public setToolbarItemState(state: boolean) {
if (!this.state.toolbar) {
return;
}
for (const key in this.state.toolbar) {
if (!this.state.toolbar.hasOwnProperty(key)) {
return;
}
const item = this.state.toolbar[key];
if (item.uIAction && (Object.is(item.uIAction.actionTarget, 'SINGLEKEY') || Object.is(item.uIAction.actionTarget, 'MULTIKEY'))) {
item.disabled = state;
}
item.visible = true;
if (item.noPrivDisplayMode && Object.is(item.noPrivDisplayMode, '6')) {
item.visible = false;
}
}
}
/**
* @description 处理工具栏事件
*
......
......@@ -66,6 +66,7 @@ export class MDView extends MainView {
* @memberof MDView
*/
public onCtrlEvent(actionParam: IActionParam) {
super.onCtrlEvent(actionParam);
const { tag, action, data } = actionParam;
if (Object.is(tag, 'searchform')) {
this.handleSearchFormEvent(action, data);
......@@ -205,7 +206,8 @@ export class MDView extends MainView {
* @memberof MDView
*/
public MDCtrlLoaded(args: any) {
console.log('数据加载完成', args);
// 设置工具栏状态
this.setToolbarItemState(true);
}
/**
......
......@@ -447,7 +447,6 @@ export class FormControl extends MainControl {
const load = async (opt: any = {}) => {
try {
const { controlService, context, viewParams, showBusyIndicator, controlAction } = this.state;
const { data } = toRefs(this.state);
if (!controlAction.loadAction) {
return;
}
......@@ -462,7 +461,8 @@ export class FormControl extends MainControl {
{ action: controlAction.loadAction, isLoading: showBusyIndicator },
);
if (response.status && response.status == 200) {
data.value = response.data;
this.state.data = response.data;
this.emit('ctrlEvent', { tag: this.props.name, action: 'load', data: response.data });
this.afterFormAction('load');
}
} catch (error) {
......
......@@ -29,7 +29,7 @@ interface ViewEmit {
const emit = defineEmits<ViewEmit>();
// 安装功能模块,提供状态和能力方法
const { state, form, onToolbarEvent } = new EditView(viewState, props, emit).moduleInstall();
const { state, form, onToolbarEvent, onCtrlEvent } = new EditView(viewState, props, emit).moduleInstall();
</script>
......@@ -63,6 +63,7 @@ const { state, form, onToolbarEvent } = new EditView(viewState, props, emit).mod
:viewParams="state.viewParams"
:controlAction="state.{{name}}.action"
:viewSubject="state.viewSubject"
@ctrlEvent="onCtrlEvent"
></{{codeName}}Form>
{{/eq}}
{{/page.ctrls}}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册