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

update:修复写法错误

上级 84a53d55
...@@ -18,16 +18,16 @@ ...@@ -18,16 +18,16 @@
}, },
{{/if}} {{/if}}
appEntityName: '{{page.appEntity.codeName}}', appEntityName: '{{page.appEntity.codeName}}',
isLoadDefault: true, isLoadDefault: {{#if (or page.loadDefault (eq page.loadDefault false))}}{{page.loadDefault}}{{else}}true{{/if}},
keyPSDEField: '{{lowerCase page.appEntity.codeName}}', keyPSDEField: '{{lowerCase page.appEntity.codeName}}',
{{!-- viewMsgGroup: '{{page.psAppViewMsgGroup}}', --}} {{!-- viewMsgGroup: '{{page.psAppViewMsgGroup}}', --}}
{{!-- viewUIActions: '{{page.psAppViewUIActions}}', --}} {{!-- viewUIActions: '{{page.psAppViewUIActions}}', --}}
viewSysCss: '{{page.psSysCss}}', viewSysCss: '{{page.psSysCss.cssName}}',
{{!-- viewSysImage: '{{page.psSysImage}}', --}} {{!-- viewSysImage: '{{page.psSysImage}}', --}}
subCaption: '{{page.subCaption}}', subCaption: '{{page.subCaption}}',
viewType: '{{page.viewType}}', viewType: '{{page.viewType}}',
viewStyle: '{{page.viewStyle}}', viewStyle: '{{page.viewStyle}}',
showCaptionBar: '{{page.viewStyle}}', showCaptionBar: {{page.showCaptionBar}},
xDataControlName:'{{page.xDataControlName}}', xDataControlName:'{{page.xDataControlName}}',
openDataViewName: 'ExampleEditorEditView', openDataViewName: 'ExampleEditorEditView',
appViewNavContexts:{{> @macro/front-end/common/navparam.hbs appNavParams=page.psAppViewNavContexts}}, appViewNavContexts:{{> @macro/front-end/common/navparam.hbs appNavParams=page.psAppViewNavContexts}},
......
...@@ -16,6 +16,12 @@ export const AppViewConfig:IParam = { ...@@ -16,6 +16,12 @@ export const AppViewConfig:IParam = {
"parameters": [ "parameters": [
{ "pathName": "views", "parameterName": "{{lowerCase appView.codeName}}" } { "pathName": "views", "parameterName": "{{lowerCase appView.codeName}}" }
], ],
{{#if (gt appView.height 0)}}
"height": {{appView.height}},
{{/if}}
{{#if (gt appView.width 0)}}
"width": {{appView.width}},
{{/if}}
{{#if appView.capPSLanguageRes}} {{#if appView.capPSLanguageRes}}
"captionTag": "{{appView.capPSLanguageRes.lanResTag}}", "captionTag": "{{appView.capPSLanguageRes.lanResTag}}",
{{/if}} {{/if}}
......
import { DataTypes, dateFormat, deepCopy, FormControlProps, FormControlState, IActionParam, IParam, MainControl, UIUtil, verifyValue } from '@core'; import {
DataTypes,
dateFormat,
deepCopy,
FormControlProps,
FormControlState,
IActionParam,
IParam,
MainControl,
UIUtil,
verifyValue,
} from '@core';
/** /**
* @description 表单部件 * @description 表单部件
...@@ -19,7 +30,7 @@ export class FormControl extends MainControl { ...@@ -19,7 +30,7 @@ export class FormControl extends MainControl {
* @description 检验表单动态逻辑 * @description 检验表单动态逻辑
* @param {IParam} data 表单数据 * @param {IParam} data 表单数据
* @param {IParam} logic 动态逻辑 * @param {IParam} logic 动态逻辑
* @return {*} * @return {*}
* @memberof FormControl * @memberof FormControl
*/ */
public verifyGroupLogic(data: IParam, logic: IParam) { public verifyGroupLogic(data: IParam, logic: IParam) {
...@@ -28,12 +39,12 @@ export class FormControl extends MainControl { ...@@ -28,12 +39,12 @@ export class FormControl extends MainControl {
if (logic.groupOP == 'AND') { if (logic.groupOP == 'AND') {
const falseItem = logic.logics.find((childLogic: IParam) => { const falseItem = logic.logics.find((childLogic: IParam) => {
return !this.verifyGroupLogic(data, childLogic); return !this.verifyGroupLogic(data, childLogic);
}) });
result = falseItem ? false : true; result = falseItem ? false : true;
} else if (logic.groupOP == 'OR') { } else if (logic.groupOP == 'OR') {
const trueItem = logic.logics.find((childLogic: IParam) => { const trueItem = logic.logics.find((childLogic: IParam) => {
return this.verifyGroupLogic(data, childLogic); return this.verifyGroupLogic(data, childLogic);
}) });
result = trueItem ? true : false; result = trueItem ? true : false;
} }
// 是否取反 // 是否取反
...@@ -62,7 +73,7 @@ export class FormControl extends MainControl { ...@@ -62,7 +73,7 @@ export class FormControl extends MainControl {
this.formItemUpdate(name); this.formItemUpdate(name);
this.formDynamicLogic(name); this.formDynamicLogic(name);
if (enableAutoSave) { if (enableAutoSave) {
this.useSave().save(); this.save();
} }
} }
...@@ -80,7 +91,7 @@ export class FormControl extends MainControl { ...@@ -80,7 +91,7 @@ export class FormControl extends MainControl {
this.handleFormDataChange(item.valueItemName, null); this.handleFormDataChange(item.valueItemName, null);
} }
} }
}) });
} }
/** /**
...@@ -110,7 +121,7 @@ export class FormControl extends MainControl { ...@@ -110,7 +121,7 @@ export class FormControl extends MainControl {
if (data.value.hasOwnProperty(detailsName)) { if (data.value.hasOwnProperty(detailsName)) {
data.value[detailsName] = response.data[detailsName]; data.value[detailsName] = response.data[detailsName];
} }
}) });
this.afterFormAction('formItemUpdate'); this.afterFormAction('formItemUpdate');
} }
} }
...@@ -188,11 +199,11 @@ export class FormControl extends MainControl { ...@@ -188,11 +199,11 @@ export class FormControl extends MainControl {
if (Object.is(item.detailType, 'FORMITEM')) { if (Object.is(item.detailType, 'FORMITEM')) {
switch (item.enableCond) { switch (item.enableCond) {
case 0: case 0:
// 不启用 // 不启用
item.disabled = false; item.disabled = false;
break; break;
case 1: case 1:
// 新建 // 新建
item.disabled = data.srfuf != 0; item.disabled = data.srfuf != 0;
break; break;
case 2: case 2:
...@@ -284,12 +295,14 @@ export class FormControl extends MainControl { ...@@ -284,12 +295,14 @@ export class FormControl extends MainControl {
data.value[detail.codeName] = controlService.getRemoteCopyData()?.[detail.codeName] || null; data.value[detail.codeName] = controlService.getRemoteCopyData()?.[detail.codeName] || null;
break; break;
default: default:
data.value[detail.codeName] = DataTypes.isNumber(detail.dataType) ? Number(detail?.createDV) : detail?.createDV; data.value[detail.codeName] = DataTypes.isNumber(detail.dataType)
? Number(detail?.createDV)
: detail?.createDV;
break; break;
} }
} }
} }
}) });
} }
/** /**
...@@ -325,18 +338,28 @@ export class FormControl extends MainControl { ...@@ -325,18 +338,28 @@ export class FormControl extends MainControl {
data.value[detail.codeName] = controlService.getRemoteCopyData()?.[detail.codeName] || null; data.value[detail.codeName] = controlService.getRemoteCopyData()?.[detail.codeName] || null;
break; break;
default: default:
data.value[detail.codeName] = DataTypes.isNumber(detail.dataType) ? Number(detail.updateDV) : detail.updateDV; data.value[detail.codeName] = DataTypes.isNumber(detail.dataType)
? Number(detail.updateDV)
: detail.updateDV;
break; break;
} }
} }
} }
}) });
} }
/**
* 加载草稿行为
*
* @protected
* @param [opt={}]
*/
protected async loadDraft(opt: any = {}) {}
/** /**
* @description 使用加载草稿功能模块 * @description 使用加载草稿功能模块
* @param {FormControlProps} props 传入的props * @param {FormControlProps} props 传入的props
* @return {*} * @return {*}
* @memberof FormControl * @memberof FormControl
*/ */
public useLoadDraft() { public useLoadDraft() {
...@@ -371,6 +394,10 @@ export class FormControl extends MainControl { ...@@ -371,6 +394,10 @@ export class FormControl extends MainControl {
console.log(error); console.log(error);
} }
}; };
// 在类里绑定能力方法
this.loadDraft = loadDraft;
// 订阅viewSubject,监听load行为 // 订阅viewSubject,监听load行为
if (viewSubject) { if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => { let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
...@@ -378,14 +405,23 @@ export class FormControl extends MainControl { ...@@ -378,14 +405,23 @@ export class FormControl extends MainControl {
loadDraft(data); loadDraft(data);
} }
}); });
// 部件卸载时退订viewSubject // 部件卸载时退订viewSubject
onUnmounted(() => { onUnmounted(() => {
subscription.unsubscribe(); subscription.unsubscribe();
}); });
} }
return { loadDraft }; return loadDraft;
} }
/**
* 加载行为
*
* @protected
* @param [opt={}]
*/
protected async load(opt: any = {}) {}
/** /**
* @description 使用加载功能模块 * @description 使用加载功能模块
* @return {*} * @return {*}
...@@ -427,6 +463,9 @@ export class FormControl extends MainControl { ...@@ -427,6 +463,9 @@ export class FormControl extends MainControl {
} }
}; };
// 在类里绑定能力方法
this.load = load;
// 订阅viewSubject,监听load行为 // 订阅viewSubject,监听load行为
if (viewSubject) { if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => { let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
...@@ -441,11 +480,17 @@ export class FormControl extends MainControl { ...@@ -441,11 +480,17 @@ export class FormControl extends MainControl {
}); });
} }
return { return load;
load: load,
};
} }
/**
* 保存行为
*
* @protected
* @param [opt={}]
*/
protected async save(opt: any = {}) {}
/** /**
* @description 使用加载功能模块 * @description 使用加载功能模块
* @return {*} * @return {*}
...@@ -482,19 +527,14 @@ export class FormControl extends MainControl { ...@@ -482,19 +527,14 @@ export class FormControl extends MainControl {
Object.assign(arg, data.getDo()); Object.assign(arg, data.getDo());
Object.assign(arg, { viewParams: _viewParams }); Object.assign(arg, { viewParams: _viewParams });
// TODO 关系界面保存通知处理,做成异步。 // TODO 关系界面保存通知处理,做成异步。
// TODO 拷贝相关。 // TODO 拷贝相关。
// 发起请求处理与解析请求 // 发起请求处理与解析请求
const response = await controlService[saveFunName]( const response = await controlService[saveFunName](_context, arg, {
_context, action: saveAction,
arg, isLoading: showBusyIndicator,
{ });
action: saveAction,
isLoading: showBusyIndicator,
},
);
if (!response.status || response.status !== 200) { if (!response.status || response.status !== 200) {
// TODO 统一Error格式 // TODO 统一Error格式
return; return;
...@@ -510,6 +550,9 @@ export class FormControl extends MainControl { ...@@ -510,6 +550,9 @@ export class FormControl extends MainControl {
} }
}; };
// 在类里绑定能力方法
this.save = save;
// 订阅viewSubject,监听load行为 // 订阅viewSubject,监听load行为
if (viewSubject) { if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => { let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
...@@ -523,11 +566,17 @@ export class FormControl extends MainControl { ...@@ -523,11 +566,17 @@ export class FormControl extends MainControl {
}); });
} }
return { return save;
save: save,
};
} }
/**
* 删除行为
*
* @protected
* @param [opt={}]
*/
protected async remove(opt: any = {}) {}
/** /**
* @description 使用加载功能模块 * @description 使用加载功能模块
* @param {FormControlProps} props 传入的props * @param {FormControlProps} props 传入的props
...@@ -558,17 +607,13 @@ export class FormControl extends MainControl { ...@@ -558,17 +607,13 @@ export class FormControl extends MainControl {
let _context = deepCopy(context); let _context = deepCopy(context);
let _viewParams = deepCopy(viewParams); let _viewParams = deepCopy(viewParams);
const arg: any = opt[0]; const arg: any = opt[0];
Object.assign(arg, { viewParams: _viewParams },); Object.assign(arg, { viewParams: _viewParams });
// 发起请求处理与解析请求 // 发起请求处理与解析请求
const response = await controlService.remove( const response = await controlService.remove(_context, arg, {
_context, action: removeAction,
arg, isLoading: showBusyIndicator,
{ });
action: removeAction,
isLoading: showBusyIndicator
},
);
if (!response.status || response.status !== 200) { if (!response.status || response.status !== 200) {
return; return;
} }
...@@ -581,6 +626,9 @@ export class FormControl extends MainControl { ...@@ -581,6 +626,9 @@ export class FormControl extends MainControl {
} }
}; };
// 在类里绑定能力方法
this.remove = remove;
// 订阅viewSubject,监听load行为 // 订阅viewSubject,监听load行为
if (viewSubject) { if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => { let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
...@@ -595,9 +643,7 @@ export class FormControl extends MainControl { ...@@ -595,9 +643,7 @@ export class FormControl extends MainControl {
}); });
} }
return { return remove;
remove: remove,
};
} }
/** /**
...@@ -639,7 +685,7 @@ export class FormControl extends MainControl { ...@@ -639,7 +685,7 @@ export class FormControl extends MainControl {
* @memberof FormControl * @memberof FormControl
*/ */
public handleFormGroupAction(tag: string, data: any) { public handleFormGroupAction(tag: string, data: any) {
console.log(tag, data) console.log(tag, data);
} }
/** /**
......
...@@ -97,7 +97,7 @@ export class GridControl extends MDControl { ...@@ -97,7 +97,7 @@ export class GridControl extends MDControl {
// 处理表格变化(分页,过滤,排序) // 处理表格变化(分页,过滤,排序)
const onGridChange = (pagination: IParam, filters: IParam, sorter: IParam, data: IParam) => { const onGridChange = (pagination: IParam, filters: IParam, sorter: IParam, data: IParam) => {
if (pagination) { if (pagination) {
this.useLoad().load(); this.load();
} }
} }
return { return {
......
...@@ -7,323 +7,367 @@ import { MDControlState, MainControl, deepCopy, IActionParam, IParam } from '@co ...@@ -7,323 +7,367 @@ import { MDControlState, MainControl, deepCopy, IActionParam, IParam } from '@co
* @extends {MainControl} * @extends {MainControl}
*/ */
export class MDControl extends MainControl { export class MDControl extends MainControl {
/**
* @description 多数据部件状态
* @type {MDControlState}
* @memberof MDControl
*/
public declare state: MDControlState;
/** /**
* @description 多数据部件状态 * @description
* @type {MDControlState} * @memberof MDControl
* @memberof MDControl */
*/ public setState() {
public declare state: MDControlState; super.setState();
// 交联输入Props
this.state.isMultiple = toRef(this.props, 'isMultiple') as any;
this.state.rowEditState = toRef(this.props, 'rowEditState') as any;
this.state.rowActiveMode = toRef(this.props, 'rowActiveMode') as any;
this.state.selectedData = toRef(this.props, 'selectedData') as any;
this.state.isSelectDefault = toRef(this.props, 'isSelectDefault') as any;
}
/** /**
* @description * 加载行为
* @memberof MDControl *
*/ * @protected
public setState() { * @param [opt={}]
super.setState(); */
// 交联输入Props protected async load(opt: any = {}) {}
this.state.isMultiple = toRef(this.props, "isMultiple") as any;
this.state.rowEditState = toRef(this.props, "rowEditState") as any; /**
this.state.rowActiveMode = toRef(this.props, "rowActiveMode") as any; * @description 使用加载功能模块
this.state.selectedData = toRef(this.props, "selectedData") as any; * @return {*}
this.state.isSelectDefault = toRef(this.props, "isSelectDefault") as any; * @memberof MDControl
} */
public useLoad() {
const { viewSubject, controlName } = this.state;
/** const load = async (opt: any = {}) => {
* @description 使用加载功能模块 try {
* @return {*} let { controlService, context, viewParams, showBusyIndicator, controlAction, mdCtrlSort, mdCtrlPaging } =
* @memberof MDControl this.state;
*/ if (!controlAction.fetchAction) {
public useLoad() { return;
const { viewSubject, controlName } = this.state;
const load = async (opt: any = {}) => {
try {
let {
controlService, context, viewParams, showBusyIndicator, controlAction, mdCtrlSort, mdCtrlPaging
} = this.state;
if (!controlAction.fetchAction) {
return;
}
// 组装查询参数
const arg: any = { ...opt };
let tempContext = deepCopy(context ? context : {});
let tempViewParams = deepCopy(viewParams ? viewParams : {});
const { noSort, minorSortDir, minorSortPSDEF } = mdCtrlSort;
let { enablePagingBar, current, pageSize } = mdCtrlPaging;
if (noSort && minorSortDir && minorSortPSDEF) {
Object.assign(tempViewParams, { sort: `${minorSortPSDEF},${minorSortDir}` });
}
if (enablePagingBar) {
Object.assign(tempViewParams, { page: current - 1, size: pageSize });
}
Object.assign(arg, tempViewParams);
// 组装视图其他查询参数
this.emit('ctrlevent', { tag: controlName.toLowerCase(), action: 'beforeload', data: arg });
const response = await controlService.search(
tempContext,
arg,
{ action: controlAction.fetchAction, isLoading: showBusyIndicator }
);
if (response.status || response.status == 200) {
this.state.items = response.data;
this.emit('ctrlevent', { tag: controlName.toLowerCase(), action: 'load', data: response.data });
if (enablePagingBar) {
this.state.mdCtrlPaging.pagination['total'] = response.total;
}
this.handleStateChange();
}
} catch (error) {
// todo 错误异常处理
console.log(error);
}
} }
// 订阅viewSubject,监听load行为
if (viewSubject) { // 组装查询参数
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => { const arg: any = { ...opt };
if (Object.is(controlName, tag) && Object.is("load", action)) { let tempContext = deepCopy(context ? context : {});
load(data); let tempViewParams = deepCopy(viewParams ? viewParams : {});
} const { noSort, minorSortDir, minorSortPSDEF } = mdCtrlSort;
}) let { enablePagingBar, current, pageSize } = mdCtrlPaging;
// 部件卸载时退订viewSubject if (!noSort && minorSortDir && minorSortPSDEF) {
onUnmounted(() => { Object.assign(tempViewParams, { sort: `${minorSortPSDEF},${minorSortDir}` });
subscription.unsubscribe();
})
} }
return { load }; if (enablePagingBar) {
} Object.assign(tempViewParams, { page: current - 1, size: pageSize });
}
Object.assign(arg, tempViewParams);
/** // 组装视图其他查询参数
* @description 使用保存功能模块 this.emit('ctrlevent', { tag: controlName.toLowerCase(), action: 'beforeload', data: arg });
* @return {*} const response = await controlService.search(tempContext, arg, {
* @memberof MDControl action: controlAction.fetchAction,
*/ isLoading: showBusyIndicator,
public useSave() { });
const { viewSubject, controlName } = this.state; if (response.status || response.status == 200) {
const save = async (opt: any = {}) => { this.state.items = response.data;
try { this.emit('ctrlevent', { tag: controlName.toLowerCase(), action: 'load', data: response.data });
const { controlService, context, viewParams, showBusyIndicator, items, controlAction } = this.state; if (enablePagingBar) {
// TODO 值规则校验处理 this.state.mdCtrlPaging.pagination['total'] = response.total;
for (const item of items) { }
const { updateAction, createAction } = controlAction; this.handleStateChange();
const saveAction: any = item.rowDataState == "update" ? updateAction : item.rowDataState == "create" ? createAction : ""; }
if (!saveAction) { } catch (error) {
return; // todo 错误异常处理
} console.log(error);
const arg: any = { ...opt }; }
let _context = deepCopy(context); };
let _viewParams = deepCopy(viewParams);
Object.assign(arg, item.getDo());
Object.assign(arg, { viewParams: _viewParams });
const response = await controlService[saveAction](
_context,
arg,
{ action: saveAction, isLoading: showBusyIndicator },
);
if (response.status || response.status == 200) {
} // 在类里绑定能力方法
} this.load = load;
} catch (error) {
// TODO 错误异常处理 // 订阅viewSubject,监听load行为
console.log(error); if (viewSubject) {
} let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
}; if (Object.is(controlName, tag) && Object.is('load', action)) {
// 订阅viewSubject,监听load行为 load(data);
if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
if (Object.is(controlName, tag) && Object.is("save", action)) {
save(data);
}
});
// 部件卸载时退订viewSubject
onUnmounted(() => {
subscription.unsubscribe();
});
} }
return { save }; });
// 部件卸载时退订viewSubject
onUnmounted(() => {
subscription.unsubscribe();
});
} }
return load;
}
/** /**
* @description 使用删除功能模块 * 保存行为
* @return {*} *
* @memberof MDControl * @protected
*/ * @param [opt={}]
public useRemove() { */
const { viewSubject, controlName } = this.state; protected async save(opt: any = {}) {}
const remove = async (opt: IParam[] = []) => {
try {
const { controlService, context, viewParams, showBusyIndicator, controlAction, appDeCodeName } = this.state;
const { items } = toRefs(this.state);
if (!controlAction.removeAction) {
return;
}
const _data: IParam[] = [];
opt.forEach((item: IParam, index: number) => {
if (Object.is(item.srfuf, "0")) {
items.value.some((val: any, num: number) => {
if (JSON.stringify(val) == JSON.stringify(item)) {
items.value.splice(num, 1);
return true;
}
});
} else {
_data.push(opt[index]);
}
});
if (_data.length > 0) {
const keys: string[] = [];
_data.forEach((item: IParam) => {
keys.push(item.srfkey);
});
const _removeAction = keys.length > 1 ? "removeBatch" : controlAction.removeAction;
let _context = deepCopy(context);
Object.assign(_context, { [appDeCodeName]: keys });
let _viewParams = deepCopy(viewParams);
const arg: IParam = {
[appDeCodeName]: keys,
};
Object.assign(arg, { viewParams: _viewParams });
const response = await controlService.remove(
_context,
arg,
{ action: _removeAction, isLoading: showBusyIndicator },
);
if (response.status || response.status == 200) {
} /**
} * @description 使用保存功能模块
} catch (error) { * @return {*}
// TODO 错误异常处理 * @memberof MDControl
console.log(error); */
} public useSave() {
}; const { viewSubject, controlName } = this.state;
// 订阅viewSubject,监听load行为 const save = async (opt: any = {}) => {
if (viewSubject) { try {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => { const { controlService, context, viewParams, showBusyIndicator, items, controlAction } = this.state;
if (Object.is(controlName, tag) && Object.is("remove", action)) { // TODO 值规则校验处理
remove(data); for (const item of items) {
} const { updateAction, createAction } = controlAction;
}); const saveAction: any =
// 部件卸载时退订viewSubject item.rowDataState == 'update' ? updateAction : item.rowDataState == 'create' ? createAction : '';
onUnmounted(() => { if (!saveAction) {
subscription.unsubscribe(); return;
}); }
const arg: any = { ...opt };
let _context = deepCopy(context);
let _viewParams = deepCopy(viewParams);
Object.assign(arg, item.getDo());
Object.assign(arg, { viewParams: _viewParams });
const response = await controlService[saveAction](_context, arg, {
action: saveAction,
isLoading: showBusyIndicator,
});
if (response.status || response.status == 200) {
}
}
} catch (error) {
// TODO 错误异常处理
console.log(error);
}
};
// 在类里绑定能力方法
this.save = save;
// 订阅viewSubject,监听load行为
if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
if (Object.is(controlName, tag) && Object.is('save', action)) {
save(data);
} }
return { remove }; });
// 部件卸载时退订viewSubject
onUnmounted(() => {
subscription.unsubscribe();
});
} }
return save;
}
/** /**
* @description 使用新建功能模块 * 删除行为
* @return {*} *
* @memberof MDControl * @protected
*/ * @param [opt={}]
public useNewRow() { */
const { viewSubject, controlName } = this.state; protected async remove(opt: any = {}) {}
const newRow = async (opt: any = {}) => {
try {
const { controlService, context, viewParams, showBusyIndicator, controlAction } = this.state;
const { items } = toRefs(this.state);
if (!controlAction.loadDraftAction) {
return;
}
let _context = deepCopy(context);
let _viewParams = deepCopy(viewParams);
const arg: any = { ...opt };
Object.assign(arg, { viewParams: _viewParams });
const response = await controlService.loadDraft(
_context,
arg,
{ action: controlAction.loadDraftAction, isLoading: showBusyIndicator },
);
if (response.status || response.status == 200) {
items.value = [...items.value, [response.data]];
}
} catch (error) {
// TODO 错误异常处理
console.log(error);
}
};
// 订阅viewSubject,监听load行为 /**
if (viewSubject) { * @description 使用删除功能模块
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => { * @return {*}
if (Object.is(controlName, tag) && Object.is("newRow", action)) { * @memberof MDControl
newRow(data); */
} public useRemove() {
}); const { viewSubject, controlName } = this.state;
// 部件卸载时退订viewSubject const remove = async (opt: IParam[] = []) => {
onUnmounted(() => { try {
subscription.unsubscribe(); const { controlService, context, viewParams, showBusyIndicator, controlAction, appDeCodeName } = this.state;
const { items } = toRefs(this.state);
if (!controlAction.removeAction) {
return;
}
const _data: IParam[] = [];
opt.forEach((item: IParam, index: number) => {
if (Object.is(item.srfuf, '0')) {
items.value.some((val: any, num: number) => {
if (JSON.stringify(val) == JSON.stringify(item)) {
items.value.splice(num, 1);
return true;
}
}); });
} else {
_data.push(opt[index]);
}
});
if (_data.length > 0) {
const keys: string[] = [];
_data.forEach((item: IParam) => {
keys.push(item.srfkey);
});
const _removeAction = keys.length > 1 ? 'removeBatch' : controlAction.removeAction;
let _context = deepCopy(context);
Object.assign(_context, { [appDeCodeName]: keys });
let _viewParams = deepCopy(viewParams);
const arg: IParam = {
[appDeCodeName]: keys,
};
Object.assign(arg, { viewParams: _viewParams });
const response = await controlService.remove(_context, arg, {
action: _removeAction,
isLoading: showBusyIndicator,
});
if (response.status || response.status == 200) {
}
} }
} catch (error) {
// TODO 错误异常处理
console.log(error);
}
};
// 在类里绑定能力方法
this.remove = remove;
return { // 订阅viewSubject,监听load行为
newRow, if (viewSubject) {
}; let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
if (Object.is(controlName, tag) && Object.is('remove', action)) {
remove(data);
}
});
// 部件卸载时退订viewSubject
onUnmounted(() => {
subscription.unsubscribe();
});
} }
return remove;
}
/**
* 新建行行为(新增一条数据)
*
* @protected
* @param [opt={}]
*/
protected async newRow(opt: any = {}) {}
/** /**
* 处理数据状态变化(逻辑数据+UI) * @description 使用新建功能模块
* * @return {*}
* @memberof MDControl * @memberof MDControl
*/ */
public handleStateChange() { } public useNewRow() {
const { viewSubject, controlName } = this.state;
const newRow = async (opt: any = {}) => {
try {
const { controlService, context, viewParams, showBusyIndicator, controlAction } = this.state;
const { items } = toRefs(this.state);
if (!controlAction.loadDraftAction) {
return;
}
let _context = deepCopy(context);
let _viewParams = deepCopy(viewParams);
const arg: any = { ...opt };
Object.assign(arg, { viewParams: _viewParams });
const response = await controlService.loadDraft(_context, arg, {
action: controlAction.loadDraftAction,
isLoading: showBusyIndicator,
});
if (response.status || response.status == 200) {
items.value = [...items.value, [response.data]];
}
} catch (error) {
// TODO 错误异常处理
console.log(error);
}
};
/** // 在类里绑定能力方法
* 处理数据分组 this.newRow = newRow;
*
* @memberof MDControl // 订阅viewSubject,监听load行为
*/ if (viewSubject) {
public handleDataGroup() { let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
const { enableGroup, groupField, groupMode } = this.state.mdCtrlGroup; if (Object.is(controlName, tag) && Object.is('newRow', action)) {
if (enableGroup && groupField && !Object.is(groupMode, "NONE")) { newRow(data);
if (Object.is(groupMode, "AUTO")) {
this.autoGroupData();
} else if (Object.is(groupMode, "CODELIST")) {
this.codeListGroupData();
}
} }
});
// 部件卸载时退订viewSubject
onUnmounted(() => {
subscription.unsubscribe();
});
} }
/** return newRow;
* 自动分组 }
*
* @protected
* @memberof MDControl
*/
protected autoGroupData() { }
/** /**
* 代码表分组 * 处理数据状态变化(逻辑数据+UI)
* *
* @protected * @memberof MDControl
* @memberof MDControl */
*/ public handleStateChange() {}
protected codeListGroupData() { }
/** /**
* 获取当前激活数据 * 处理数据分组
* *
* @memberof MDControl * @memberof MDControl
*/ */
public getData(): IParam[] { public handleDataGroup() {
const { selectedData } = this.state; const { enableGroup, groupField, groupMode } = this.state.mdCtrlGroup;
return selectedData; if (enableGroup && groupField && !Object.is(groupMode, 'NONE')) {
if (Object.is(groupMode, 'AUTO')) {
this.autoGroupData();
} else if (Object.is(groupMode, 'CODELIST')) {
this.codeListGroupData();
}
} }
}
/** /**
* @description 安装部件所有功能模块的方法 * 自动分组
* @return {*} *
* @memberof MDControl * @protected
*/ * @memberof MDControl
public moduleInstall() { */
const superParams = super.moduleInstall(); protected autoGroupData() {}
return {
...superParams, /**
load: this.useLoad(), * 代码表分组
save: this.useSave(), *
romove: this.useRemove(), * @protected
new: this.useNewRow() * @memberof MDControl
}; */
} protected codeListGroupData() {}
/**
* 获取当前激活数据
*
* @memberof MDControl
*/
public getData(): IParam[] {
const { selectedData } = this.state;
return selectedData;
}
/**
* @description 安装部件所有功能模块的方法
* @return {*}
* @memberof MDControl
*/
public moduleInstall() {
const superParams = super.moduleInstall();
return {
...superParams,
load: this.useLoad(),
save: this.useSave(),
remove: this.useRemove(),
newRow: this.useNewRow(),
};
}
} }
...@@ -75,7 +75,6 @@ export class SearchFormControl extends FormControl { ...@@ -75,7 +75,6 @@ export class SearchFormControl extends FormControl {
public moduleInstall() { public moduleInstall() {
const superParams = super.moduleInstall(); const superParams = super.moduleInstall();
// 表单行为能力启用 // 表单行为能力启用
const { loadDraft } = this.useLoadDraft();
return { return {
...superParams, ...superParams,
onSearch: this.onSearch.bind(this), onSearch: this.onSearch.bind(this),
......
import { toRef } from "vue";
import { deepCopy, deepObjectMerge, IActionParam, MainControl } from "@core"; import { deepCopy, deepObjectMerge, IActionParam, MainControl } from "@core";
import { TreeControlProps } from "./tree-control-prop"; import { TreeControlProps } from "./tree-control-prop";
import { TreeControlState } from "./tree-control-state"; import { TreeControlState } from "./tree-control-state";
...@@ -143,9 +142,7 @@ export class TreeControl extends MainControl { ...@@ -143,9 +142,7 @@ export class TreeControl extends MainControl {
subscription.unsubscribe(); subscription.unsubscribe();
}) })
} }
return { return load;
load
};
} }
/** /**
...@@ -155,11 +152,10 @@ export class TreeControl extends MainControl { ...@@ -155,11 +152,10 @@ export class TreeControl extends MainControl {
*/ */
public moduleInstall() { public moduleInstall() {
const superParams = super.moduleInstall(); const superParams = super.moduleInstall();
const { load } = this.useLoad();
return { return {
...superParams, ...superParams,
treeNodeSelect: this.treeNodeSelect.bind(this), treeNodeSelect: this.treeNodeSelect.bind(this),
load load: this.useLoad(),
}; };
} }
} }
\ No newline at end of file
...@@ -196,14 +196,13 @@ const handleShowState = ($event: any) => { ...@@ -196,14 +196,13 @@ const handleShowState = ($event: any) => {
:maskClosable="true" :maskClosable="true"
:destroyOnClose="true" :destroyOnClose="true"
:width="width" :width="width"
:height="height"
:bodyStyle="style" :bodyStyle="style"
@cancel="onVisibleChange($event)" @cancel="onVisibleChange($event)"
> >
<component <component
:is="viewName" :is="viewName"
class="app-modal-view-component" class="app-modal-view-component"
:width="width"
:height="height"
:context="context" :context="context"
:viewParams="viewParams" :viewParams="viewParams"
:viewDefaultUsage="false" :viewDefaultUsage="false"
......
...@@ -39,7 +39,7 @@ const collapsedChange = () => { ...@@ -39,7 +39,7 @@ const collapsedChange = () => {
</script> </script>
<template> <template>
<AppDefaultIndexViewLayout class="app-index-view" :menuAlign="state.menuAlign" :collapsed="collapsed"> <AppDefaultIndexViewLayout :class="['app-index-view', state.viewSysCss]" :menuAlign="state.menuAlign" :collapsed="collapsed">
<template #caption> <template #caption>
<div class="index-view-header"> <div class="index-view-header">
\{{state.viewCaption}} \{{state.viewCaption}}
......
...@@ -44,7 +44,7 @@ const { state, grid, onCtrlEvent, onToolbarEvent, onQuickGroupEvent } = new Grid ...@@ -44,7 +44,7 @@ const { state, grid, onCtrlEvent, onToolbarEvent, onQuickGroupEvent } = new Grid
</script> </script>
<template> <template>
<AppGridViewLayout class="app-grid-view"> <AppGridViewLayout :class="['app-grid-view', state.viewSysCss]">
<template v-slot:caption> <template v-slot:caption>
<AppIconText class="app-view__caption" size="large" :text="state.viewCaption" /> <AppIconText class="app-view__caption" size="large" :text="state.viewCaption" />
</template> </template>
......
...@@ -36,7 +36,7 @@ const { state, confirm, handleCtrlEvent } = new PickupGridView(viewState, props, ...@@ -36,7 +36,7 @@ const { state, confirm, handleCtrlEvent } = new PickupGridView(viewState, props,
</script> </script>
<template> <template>
<AppPickerUpGridViewLayout class="app-pickup-grid-view"> <AppPickerUpGridViewLayout :class="['app-pickup-grid-view', state.viewSysCss]">
<template v-slot:header-left> <template v-slot:header-left>
<AppIconText class="app-view__caption" size="large" :text="state.viewCaption" /> <AppIconText class="app-view__caption" size="large" :text="state.viewCaption" />
</template> </template>
......
...@@ -32,7 +32,7 @@ const { state, cancel, confirm,handleCtrlEvent } = new PickupView(viewState, pro ...@@ -32,7 +32,7 @@ const { state, cancel, confirm,handleCtrlEvent } = new PickupView(viewState, pro
</script> </script>
<template> <template>
<AppPickerUpViewLayout class="app-pickup-view"> <AppPickerUpViewLayout :class="['app-pickup-view', state.viewSysCss]">
<template v-slot:header-left> <template v-slot:header-left>
<AppIconText class="app-view__caption" size="large" :text="state.viewCaption" /> <AppIconText class="app-view__caption" size="large" :text="state.viewCaption" />
</template> </template>
......
...@@ -29,7 +29,7 @@ const { state, handleCtrlEvent, onToolbarEvent } = new TreeExpView(viewState, pr ...@@ -29,7 +29,7 @@ const { state, handleCtrlEvent, onToolbarEvent } = new TreeExpView(viewState, pr
</script> </script>
<template> <template>
<AppTreeExpViewLayout class="app-tree-exp-view"> <AppTreeExpViewLayout :class="['app-tree-exp-view', state.viewSysCss]">
<template v-slot:caption> <template v-slot:caption>
<AppIconText class="app-view__caption" size="large" :text="state.viewCaption" /> <AppIconText class="app-view__caption" size="large" :text="state.viewCaption" />
</template> </template>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册