提交 3031388a 编写于 作者: WodahsOrez's avatar WodahsOrez

update: 统一事件规范

上级 ed79749d
...@@ -41,12 +41,12 @@ public declare state: GridViewState; ...@@ -41,12 +41,12 @@ public declare state: GridViewState;
* @param {IActionParam} actionParam * @param {IActionParam} actionParam
* @memberof MDView * @memberof MDView
*/ */
public handleCtrlEvent(actionParam: IActionParam) { public onCtrlEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam; const { tag, action, data } = actionParam;
if (Object.is(tag, 'grid')) { if (Object.is(tag, 'grid')) {
this.MDCtrlEvent(action, data); this.MDCtrlEvent(action, data);
} }
super.handleCtrlEvent(actionParam); super.onCtrlEvent(actionParam);
} }
/** /**
......
...@@ -66,7 +66,7 @@ export class MDView extends MainView { ...@@ -66,7 +66,7 @@ export class MDView extends MainView {
* @param {IActionParam} actionParam * @param {IActionParam} actionParam
* @memberof MDView * @memberof MDView
*/ */
public handleCtrlEvent(actionParam: IActionParam) { public onCtrlEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam; const { tag, action, data } = actionParam;
if (Object.is(tag, 'searchform')) { if (Object.is(tag, 'searchform')) {
this.handleSearchFormEvent(action, data); this.handleSearchFormEvent(action, data);
......
...@@ -38,7 +38,7 @@ export class PickupGridView extends PickupView { ...@@ -38,7 +38,7 @@ export class PickupGridView extends PickupView {
* @param {IActionParam} actionParam * @param {IActionParam} actionParam
* @memberof PickupGridView * @memberof PickupGridView
*/ */
public handleCtrlEvent(actionParam: IActionParam) { public onCtrlEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam; const { tag, action, data } = actionParam;
if (tag !== 'grid') { if (tag !== 'grid') {
return; return;
......
...@@ -49,7 +49,7 @@ export class PickupView extends MainView { ...@@ -49,7 +49,7 @@ export class PickupView extends MainView {
this.emit('viewEvent', { data: this.selectData, tag: '', action: 'close' }) this.emit('viewEvent', { data: this.selectData, tag: '', action: 'close' })
} }
public handleCtrlEvent(actionParam: IActionParam) { public onCtrlEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam; const { tag, action, data } = actionParam;
// TODO // TODO
......
...@@ -21,7 +21,7 @@ export class ExpBarControl extends MainControl { ...@@ -21,7 +21,7 @@ export class ExpBarControl extends MainControl {
* @param {IActionParam} actionParam * @param {IActionParam} actionParam
* @memberof ExpBarControl * @memberof ExpBarControl
*/ */
public handleCtrlEvent(actionParam: IActionParam) { public onCtrlEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam; const { tag, action, data } = actionParam;
const { selection } = this.state; const { selection } = this.state;
switch (action) { switch (action) {
...@@ -73,7 +73,7 @@ export class ExpBarControl extends MainControl { ...@@ -73,7 +73,7 @@ export class ExpBarControl extends MainControl {
const superParams = super.moduleInstall(); const superParams = super.moduleInstall();
return { return {
...superParams, ...superParams,
handleCtrlEvent: this.handleCtrlEvent.bind(this) onCtrlEvent: this.onCtrlEvent.bind(this)
}; };
} }
} }
\ No newline at end of file
...@@ -55,16 +55,16 @@ export class GridControl extends MDControl { ...@@ -55,16 +55,16 @@ export class GridControl extends MDControl {
if (!rowEditState) { if (!rowEditState) {
selectedRowKeys.value = [record.srfkey]; selectedRowKeys.value = [record.srfkey];
if (!record.children) { if (!record.children) {
this.emit("onCtrlEvent", { tag: controlName, action: "selectionChange", data: [deepCopy(record)] }) this.emit("ctrlEvent", { tag: this.props.name, action: "selectionChange", data: [deepCopy(record)] })
if (Object.is(rowActiveMode, 1)) { if (Object.is(rowActiveMode, 1)) {
this.emit("onCtrlEvent", { tag: controlName, action: "rowClick", data: [deepCopy(record)] }) this.emit("ctrlEvent", { tag: this.props.name, action: "rowClick", data: [deepCopy(record)] })
} }
} }
} }
}, },
onDblclick: () => { onDblclick: () => {
if (!record.children && Object.is(rowActiveMode, 2)) { if (!record.children && Object.is(rowActiveMode, 2)) {
this.emit("onCtrlEvent", { tag: controlName, action: "rowDbClick", data: [deepCopy(record)] }) this.emit("ctrlEvent", { tag: this.props.name, action: "rowDbClick", data: [deepCopy(record)] })
} }
} }
}; };
...@@ -86,7 +86,7 @@ export class GridControl extends MDControl { ...@@ -86,7 +86,7 @@ export class GridControl extends MDControl {
selection.push(select); selection.push(select);
} }
}) })
this.emit("onCtrlEvent", { tag: controlName, action: "selectionChange", data: selection }) this.emit("ctrlEvent", { tag: this.props.name, action: "selectionChange", data: selection })
}, },
}; };
}); });
...@@ -189,8 +189,8 @@ export class GridControl extends MDControl { ...@@ -189,8 +189,8 @@ export class GridControl extends MDControl {
selectedRowKeys.value = _selectedRowKeys; selectedRowKeys.value = _selectedRowKeys;
} else if (isSelectDefault) { } else if (isSelectDefault) {
if (items && items.length > 0) { if (items && items.length > 0) {
this.emit("onCtrlEvent", { this.emit("ctrlEvent", {
tag: controlName, tag: this.props.name,
action: "selectionChange", action: "selectionChange",
data: [deepCopy(items[0])], data: [deepCopy(items[0])],
}); });
......
...@@ -67,14 +67,14 @@ export class MDControl extends MainControl { ...@@ -67,14 +67,14 @@ export class MDControl extends MainControl {
Object.assign(arg, tempViewParams); Object.assign(arg, tempViewParams);
// 组装视图其他查询参数 // 组装视图其他查询参数
this.emit('ctrlevent', { tag: controlName.toLowerCase(), action: 'beforeload', data: arg }); this.emit("ctrlEvent", { tag: this.props.name, action: 'beforeload', data: arg });
const response = await controlService.search(tempContext, arg, { const response = await controlService.search(tempContext, arg, {
action: controlAction.fetchAction, action: controlAction.fetchAction,
isLoading: showBusyIndicator, isLoading: showBusyIndicator,
}); });
if (response.status || response.status == 200) { if (response.status || response.status == 200) {
this.state.items = response.data; this.state.items = response.data;
this.emit('ctrlevent', { tag: controlName.toLowerCase(), action: 'load', data: response.data }); this.emit("ctrlEvent", { tag: this.props.name, action: 'load', data: response.data });
if (enablePagingBar) { if (enablePagingBar) {
this.state.mdCtrlPaging.pagination['total'] = response.total; this.state.mdCtrlPaging.pagination['total'] = response.total;
} }
......
...@@ -49,7 +49,7 @@ export class PickupViewPanelControl extends MainControl { ...@@ -49,7 +49,7 @@ export class PickupViewPanelControl extends MainControl {
const { tag, action, data } = actionParam; const { tag, action, data } = actionParam;
const { controlName } = this.state; const { controlName } = this.state;
if (Object.is("selectionChange", action)) { if (Object.is("selectionChange", action)) {
this.emit('ctrlEvent', { tag: controlName, action: action, data: data }); this.emit("ctrlEvent", { tag: this.props.name, action: action, data: data });
} }
} }
......
...@@ -21,8 +21,8 @@ export class QuickSearchFormControl extends FormControl { ...@@ -21,8 +21,8 @@ export class QuickSearchFormControl extends FormControl {
*/ */
public onEditorEvent(actionParam: IActionParam) { public onEditorEvent(actionParam: IActionParam) {
super.onEditorEvent(actionParam); super.onEditorEvent(actionParam);
this.emit("onCtrlEvent", { this.emit("ctrlEvent", {
tag: this.state.controlName, tag: this.props.name,
action: "selectionChange", action: "selectionChange",
data: this.state.data, data: this.state.data,
}); });
......
...@@ -19,9 +19,8 @@ export class SearchFormControl extends FormControl { ...@@ -19,9 +19,8 @@ export class SearchFormControl extends FormControl {
* @memberof SearchFormControl * @memberof SearchFormControl
*/ */
public onSearch() { public onSearch() {
const { controlName } = this.state; this.emit("ctrlEvent", {
this.emit("onCtrlEvent", { tag: this.props.name,
tag: controlName,
action: "selectionChange", action: "selectionChange",
data: this.state.data, data: this.state.data,
}); });
......
...@@ -45,7 +45,7 @@ export class TreeControl extends MainControl { ...@@ -45,7 +45,7 @@ export class TreeControl extends MainControl {
currentselectedNode.value = e.node; currentselectedNode.value = e.node;
if (!multiple) { if (!multiple) {
selectedNodes.push(currentselectedNode.value); selectedNodes.push(currentselectedNode.value);
this.emit("ctrlEvent", { tag: controlName, action: 'selectionchange', data: deepCopy(selectedNodes) }); this.emit("ctrlEvent", { tag: this.props.name, action: 'selectionchange', data: deepCopy(selectedNodes) });
} }
} }
} }
...@@ -125,7 +125,7 @@ export class TreeControl extends MainControl { ...@@ -125,7 +125,7 @@ export class TreeControl extends MainControl {
const isSelectedAll = node.checked; const isSelectedAll = node.checked;
// TODO 默认选中 // TODO 默认选中
// this.setDefaultSelection(items, isRoot, isSelectedAll); // this.setDefaultSelection(items, isRoot, isSelectedAll);
this.emit("ctrlEvent", { tag: controlName, action: "load", data: items }); this.emit("ctrlEvent", { tag: this.props.name, action: "load", data: items });
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
......
...@@ -75,7 +75,7 @@ const { state, grid, onCtrlEvent, onToolbarEvent, onQuickGroupEvent } = new Grid ...@@ -75,7 +75,7 @@ const { state, grid, onCtrlEvent, onToolbarEvent, onQuickGroupEvent } = new Grid
:viewParams="state.viewParams" :viewParams="state.viewParams"
:controlAction="state.{{camelCase name}}.action" :controlAction="state.{{camelCase name}}.action"
:viewSubject="state.viewSubject" :viewSubject="state.viewSubject"
@onCtrlEvent="onCtrlEvent" @ctrlEvent="onCtrlEvent"
></{{codeName}}SearchForm> ></{{codeName}}SearchForm>
</template> </template>
<a-button><filter-outlined /></a-button> <a-button><filter-outlined /></a-button>
...@@ -89,7 +89,7 @@ const { state, grid, onCtrlEvent, onToolbarEvent, onQuickGroupEvent } = new Grid ...@@ -89,7 +89,7 @@ const { state, grid, onCtrlEvent, onToolbarEvent, onQuickGroupEvent } = new Grid
:viewParams="state.viewParams" :viewParams="state.viewParams"
:controlAction="state.{{camelCase name}}.action" :controlAction="state.{{camelCase name}}.action"
:viewSubject="state.viewSubject" :viewSubject="state.viewSubject"
@onCtrlEvent="onCtrlEvent" @ctrlEvent="onCtrlEvent"
></{{codeName}}SearchForm> ></{{codeName}}SearchForm>
</template> </template>
{{/if}} {{/if}}
...@@ -101,7 +101,7 @@ const { state, grid, onCtrlEvent, onToolbarEvent, onQuickGroupEvent } = new Grid ...@@ -101,7 +101,7 @@ const { state, grid, onCtrlEvent, onToolbarEvent, onQuickGroupEvent } = new Grid
:viewParams="state.viewParams" :viewParams="state.viewParams"
:controlAction="state.{{camelCase name}}.action" :controlAction="state.{{camelCase name}}.action"
:viewSubject="state.viewSubject" :viewSubject="state.viewSubject"
@onCtrlEvent="onCtrlEvent" @ctrlEvent="onCtrlEvent"
></{{codeName}}QuickSearchForm> ></{{codeName}}QuickSearchForm>
</template> </template>
{{/if}} {{/if}}
...@@ -122,7 +122,7 @@ const { state, grid, onCtrlEvent, onToolbarEvent, onQuickGroupEvent } = new Grid ...@@ -122,7 +122,7 @@ const { state, grid, onCtrlEvent, onToolbarEvent, onQuickGroupEvent } = new Grid
:viewParams="state.viewParams" :viewParams="state.viewParams"
:controlAction="state.{{name}}.action" :controlAction="state.{{name}}.action"
:viewSubject="state.viewSubject" :viewSubject="state.viewSubject"
@onCtrlEvent="onCtrlEvent" @ctrlEvent="onCtrlEvent"
></{{codeName}}Grid> ></{{codeName}}Grid>
{{/eq}} {{/eq}}
{{/page.ctrls}} {{/page.ctrls}}
......
...@@ -32,7 +32,7 @@ interface ViewEmit { ...@@ -32,7 +32,7 @@ interface ViewEmit {
const emit = defineEmits<ViewEmit>(); const emit = defineEmits<ViewEmit>();
// 安装功能模块,提供状态和能力方法 // 安装功能模块,提供状态和能力方法
const { state, confirm, handleCtrlEvent } = new PickupGridView(viewState, props, emit).moduleInstall(); const { state, confirm, onCtrlEvent } = new PickupGridView(viewState, props, emit).moduleInstall();
</script> </script>
<template> <template>
...@@ -62,7 +62,7 @@ const { state, confirm, handleCtrlEvent } = new PickupGridView(viewState, props, ...@@ -62,7 +62,7 @@ const { state, confirm, handleCtrlEvent } = new PickupGridView(viewState, props,
:viewParams="state.viewParams" :viewParams="state.viewParams"
:controlAction="state.controlsAction.grid" :controlAction="state.controlsAction.grid"
:viewSubject="state.viewSubject" :viewSubject="state.viewSubject"
@ctrlEvent="handleCtrlEvent" @ctrlEvent="onCtrlEvent"
></MainGrid> ></MainGrid>
</AppPickerUpGridViewLayout> </AppPickerUpGridViewLayout>
</template> </template>
...@@ -28,7 +28,7 @@ interface ViewEmit { ...@@ -28,7 +28,7 @@ interface ViewEmit {
const emit = defineEmits<ViewEmit>(); const emit = defineEmits<ViewEmit>();
// 安装功能模块,提供状态和能力方法 // 安装功能模块,提供状态和能力方法
const { state, cancel, confirm,handleCtrlEvent } = new PickupView(viewState, props, emit).moduleInstall(); const { state, cancel, confirm,onCtrlEvent } = new PickupView(viewState, props, emit).moduleInstall();
</script> </script>
<template> <template>
...@@ -56,7 +56,7 @@ const { state, cancel, confirm,handleCtrlEvent } = new PickupView(viewState, pro ...@@ -56,7 +56,7 @@ const { state, cancel, confirm,handleCtrlEvent } = new PickupView(viewState, pro
:viewParams="state.viewParams" :viewParams="state.viewParams"
:controlAction="state.controlsAction.{{name}}" :controlAction="state.controlsAction.{{name}}"
:viewSubject="state.viewSubject" :viewSubject="state.viewSubject"
@ctrlEvent="handleCtrlEvent" @ctrlEvent="onCtrlEvent"
></{{codeName}}PickUpViewPanel> ></{{codeName}}PickUpViewPanel>
{{/eq}} {{/eq}}
{{/page.ctrls}} {{/page.ctrls}}
......
...@@ -25,7 +25,7 @@ interface ViewEmit { ...@@ -25,7 +25,7 @@ interface ViewEmit {
const emit = defineEmits<ViewEmit>(); const emit = defineEmits<ViewEmit>();
// 安装功能模块 // 安装功能模块
const { state, handleCtrlEvent, onToolbarEvent } = new TreeExpView(viewState, props, emit).moduleInstall(); const { state, onCtrlEvent, onToolbarEvent } = new TreeExpView(viewState, props, emit).moduleInstall();
</script> </script>
<template> <template>
...@@ -49,7 +49,7 @@ const { state, handleCtrlEvent, onToolbarEvent } = new TreeExpView(viewState, pr ...@@ -49,7 +49,7 @@ const { state, handleCtrlEvent, onToolbarEvent } = new TreeExpView(viewState, pr
:showBusyIndicator="true" :showBusyIndicator="true"
:viewParams="state.viewParams" :viewParams="state.viewParams"
:viewSubject="state.viewSubject" :viewSubject="state.viewSubject"
@ctrlEvent="handleCtrlEvent" @ctrlEvent="onCtrlEvent"
></{{codeName}}TreeExpBar> ></{{codeName}}TreeExpBar>
{{/eq}} {{/eq}}
{{/page.ctrls}} {{/page.ctrls}}
......
...@@ -18,7 +18,7 @@ const props = withDefaults(defineProps < Props > (), { ...@@ -18,7 +18,7 @@ const props = withDefaults(defineProps < Props > (), {
interface CtrlEmit { interface CtrlEmit {
(name: "ctrlEvent", value: IActionParam): void; (name: "ctrlEvent", value: IActionParam): void;
} }
const emit = defineEmits < CtrlEmit > (); const emit = defineEmits <CtrlEmit> ();
const { state, menuSelect } = new MenuControl(ctrlState, props, emit).moduleInstall(); const { state, menuSelect } = new MenuControl(ctrlState, props, emit).moduleInstall();
......
...@@ -19,10 +19,10 @@ const props = withDefaults(defineProps < Props > (), { ...@@ -19,10 +19,10 @@ const props = withDefaults(defineProps < Props > (), {
// emit声明 // emit声明
interface CtrlEmit { interface CtrlEmit {
(name: "onCtrlEvent", value: IActionParam): void; (name: "ctrlEvent", value: IActionParam): void;
} }
const emit = defineEmits < CtrlEmit > (); const emit = defineEmits <CtrlEmit> ();
// 安装功能模块,提供状态和能力方法 // 安装功能模块,提供状态和能力方法
const { state, onEditorEvent, onComponentEvent } = new FormControl(ctrlState, props, emit).moduleInstall(); const { state, onEditorEvent, onComponentEvent } = new FormControl(ctrlState, props, emit).moduleInstall();
......
...@@ -27,7 +27,12 @@ const props = withDefaults(defineProps < Props > (), { ...@@ -27,7 +27,12 @@ const props = withDefaults(defineProps < Props > (), {
}) })
// emit声明 // emit声明
const emit = defineEmits<{(event: 'onCtrlEvent', value: IActionParam): void;}>(); interface CtrlEmit {
(name: "ctrlEvent", value: IActionParam): void;
}
// emit声明
const emit = defineEmits<CtrlEmit>();
// 安装功能模块,提供状态和能力 // 安装功能模块,提供状态和能力
const { state, useCustom, onEditorEvent, onToolbarEvent } = new GridControl(ctrlState, props, emit).moduleInstall(); const { state, useCustom, onEditorEvent, onToolbarEvent } = new GridControl(ctrlState, props, emit).moduleInstall();
......
...@@ -28,7 +28,7 @@ interface CtrlEmit { ...@@ -28,7 +28,7 @@ interface CtrlEmit {
(name: "ctrlEvent", value: IActionParam): void; (name: "ctrlEvent", value: IActionParam): void;
} }
const emit = defineEmits < CtrlEmit > (); const emit = defineEmits <CtrlEmit> ();
// 安装功能模块,提供状态和能力方法 // 安装功能模块,提供状态和能力方法
const { state, inited, viewdata, viewparam } = new PickupViewPanelControl(ctrlState, props, emit).moduleInstall(); const { state, inited, viewdata, viewparam } = new PickupViewPanelControl(ctrlState, props, emit).moduleInstall();
......
...@@ -20,7 +20,7 @@ const props = withDefaults(defineProps<Props>(), { ...@@ -20,7 +20,7 @@ const props = withDefaults(defineProps<Props>(), {
// emit声明 // emit声明
interface CtrlEmit { interface CtrlEmit {
(name: "onCtrlEvent", value: IActionParam): void; (name: "ctrlEvent", value: IActionParam): void;
} }
const emit = defineEmits<CtrlEmit>(); const emit = defineEmits<CtrlEmit>();
......
...@@ -20,7 +20,7 @@ const props = withDefaults(defineProps<Props>(), { ...@@ -20,7 +20,7 @@ const props = withDefaults(defineProps<Props>(), {
// emit声明 // emit声明
interface CtrlEmit { interface CtrlEmit {
(name: "onCtrlEvent", value: IActionParam): void; (name: "ctrlEvent", value: IActionParam): void;
} }
const emit = defineEmits<CtrlEmit>(); const emit = defineEmits<CtrlEmit>();
......
...@@ -32,10 +32,10 @@ interface CtrlEmit { ...@@ -32,10 +32,10 @@ interface CtrlEmit {
(name: "ctrlEvent", value: IActionParam): void; (name: "ctrlEvent", value: IActionParam): void;
} }
const emit = defineEmits < CtrlEmit > (); const emit = defineEmits <CtrlEmit> ();
// 安装功能模块,提供状态和能力方法 // 安装功能模块,提供状态和能力方法
const { state, handleCtrlEvent } = new TreeExpBarControl(ctrlState, props, emit).moduleInstall(); const { state, onCtrlEvent } = new TreeExpBarControl(ctrlState, props, emit).moduleInstall();
// 暴露内部状态及能力 // 暴露内部状态及能力
defineExpose({ state, name: '{{ctrl.name}}' }); defineExpose({ state, name: '{{ctrl.name}}' });
...@@ -53,7 +53,7 @@ defineExpose({ state, name: '{{ctrl.name}}' }); ...@@ -53,7 +53,7 @@ defineExpose({ state, name: '{{ctrl.name}}' });
:viewParams="state.viewParams" :viewParams="state.viewParams"
:viewSubject="state.viewSubject" :viewSubject="state.viewSubject"
:isBranchAvailable="true" :isBranchAvailable="true"
@ctrlEvent="handleCtrlEvent" @ctrlEvent="onCtrlEvent"
></{{codeName}}Tree> ></{{codeName}}Tree>
{{/eq}} {{/eq}}
{{/ctrl.ctrls}} {{/ctrl.ctrls}}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册