提交 8bcb839d 编写于 作者: tony001's avatar tony001

update:更新模板

上级 7a0761eb
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
width: '{{page.width}}', width: '{{page.width}}',
appEntityName: '{{page.appEntity.codeName}}', appEntityName: '{{page.appEntity.codeName}}',
isLoadDefault: true, isLoadDefault: true,
keyPSDEField: '{{lowerCase page.appEntity.codeName}}',
{{!-- viewMsgGroup: '{{page.psAppViewMsgGroup}}', --}} {{!-- viewMsgGroup: '{{page.psAppViewMsgGroup}}', --}}
{{!-- viewUIActions: '{{page.psAppViewUIActions}}', --}} {{!-- viewUIActions: '{{page.psAppViewUIActions}}', --}}
viewSysCss: '{{page.psSysCss}}', viewSysCss: '{{page.psSysCss}}',
......
...@@ -33,8 +33,22 @@ export class EditView extends MainView { ...@@ -33,8 +33,22 @@ export class EditView extends MainView {
// 初始化表单引用 // 初始化表单引用
this.form = ref(null); this.form = ref(null);
onMounted(() => { onMounted(() => {
const { viewSubject } = this.state; const { isLoadDefault, context, viewparams, keyPSDEField } = this.state;
viewSubject.next({ tag: this.getForm().name, action: "load", data: {} }) if (this.getForm() && isLoadDefault) {
const tag = this.getForm().name;
let action: string = '';
if (
keyPSDEField &&
context[keyPSDEField] &&
!Object.is(context[keyPSDEField], '')
) {
action = 'load';
} else {
action = 'loadDraft';
}
this.next({ tag: tag, action: action, data: viewparams });
}
this.state.isLoadDefault = true;
}) })
} }
...@@ -45,11 +59,7 @@ export class EditView extends MainView { ...@@ -45,11 +59,7 @@ export class EditView extends MainView {
* @memberof IndexView * @memberof IndexView
*/ */
public getForm(): any { public getForm(): any {
if (this.form.value) { return unref(this.form);
return this.form.value;
} else {
return null;
}
} }
/** /**
......
...@@ -56,11 +56,7 @@ public declare state: GridViewState; ...@@ -56,11 +56,7 @@ public declare state: GridViewState;
* @memberof GridView * @memberof GridView
*/ */
public getMDCtrl(): any { public getMDCtrl(): any {
if (this.grid.value) { return unref(this.grid);
return this.grid.value;
} else {
return null;
}
} }
/** /**
......
...@@ -227,11 +227,7 @@ export class MDView extends MainView { ...@@ -227,11 +227,7 @@ export class MDView extends MainView {
* @memberof MDView * @memberof MDView
*/ */
public getSearchForm(): any { public getSearchForm(): any {
if (this.searchForm.value) { return unref(this.searchForm);
return this.searchForm.value;
} else {
return null;
}
} }
/** /**
...@@ -241,11 +237,7 @@ export class MDView extends MainView { ...@@ -241,11 +237,7 @@ export class MDView extends MainView {
* @memberof MDView * @memberof MDView
*/ */
public getSearchBar() { public getSearchBar() {
if (this.searchBar.value) { return unref(this.searchBar);
return this.searchBar.value;
} else {
return null;
}
} }
/** /**
......
...@@ -341,13 +341,7 @@ export class FormControl extends MainControl { ...@@ -341,13 +341,7 @@ export class FormControl extends MainControl {
*/ */
public useLoadDraft() { public useLoadDraft() {
const { viewSubject, controlName } = this.state; const { viewSubject, controlName } = this.state;
// 加载草稿
/**
* 加载行为
*
* @param [opt={}]
* @return {*}
*/
const loadDraft = async (opt: any = {}) => { const loadDraft = async (opt: any = {}) => {
try { try {
const { controlService, context, viewParams, showBusyIndicator, controlAction, appDeKeyFieldName } = this.state; const { controlService, context, viewParams, showBusyIndicator, controlAction, appDeKeyFieldName } = this.state;
...@@ -377,7 +371,6 @@ export class FormControl extends MainControl { ...@@ -377,7 +371,6 @@ export class FormControl extends MainControl {
console.log(error); console.log(error);
} }
}; };
// 订阅viewSubject,监听load行为 // 订阅viewSubject,监听load行为
if (viewSubject) { if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => { let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
...@@ -385,16 +378,12 @@ export class FormControl extends MainControl { ...@@ -385,16 +378,12 @@ export class FormControl extends MainControl {
loadDraft(data); loadDraft(data);
} }
}); });
// 部件卸载时退订viewSubject // 部件卸载时退订viewSubject
onUnmounted(() => { onUnmounted(() => {
subscription.unsubscribe(); subscription.unsubscribe();
}); });
} }
return { loadDraft };
return {
loadDraft: loadDraft,
};
} }
/** /**
...@@ -660,14 +649,11 @@ export class FormControl extends MainControl { ...@@ -660,14 +649,11 @@ export class FormControl extends MainControl {
*/ */
public moduleInstall() { public moduleInstall() {
const superParams = super.moduleInstall(); const superParams = super.moduleInstall();
// 表单行为能力启用
const { load } = this.useLoad();
const { save } = this.useSave();
return { return {
...superParams, ...superParams,
load, load: this.useLoad(),
save, loadDraft: this.useLoadDraft(),
save: this.useSave(),
handleEditorEvent: this.handleEditorEvent.bind(this), handleEditorEvent: this.handleEditorEvent.bind(this),
handleComponentEvent: this.handleComponentEvent.bind(this), handleComponentEvent: this.handleComponentEvent.bind(this),
}; };
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册