提交 a3955eaa 编写于 作者: Mosher's avatar Mosher

update:更新

上级 dcb1a0f5
{ {{#appNavParams}}'{{lowerCase key}}':{{#if (eq rawValue true)}}'{{lowerCase value}}'{{else}}'%{{lowerCase value}}%'{{/if}}{{#unless @last}},{{/unless}}{{/appNavParams}} }
\ No newline at end of file
{ {{#appNavParams}}'{{lowerCase key}}':{{#if (eq rawValue true)}}'{{value}}'{{else}}'%{{lowerCase value}}%'{{/if}}{{#unless @last}},{{/unless}}{{/appNavParams}} }
\ 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.psDEDataSet}}
{{#if singleAppMethod.psDEDataSet.psDEDataQueries}}
{{#singleAppMethod.psDEDataSet.psDEDataQueries}}
// const cond: any = this.get{{codeName}}Cond();
{{/singleAppMethod.psDEDataSet.psDEDataQueries}}
// return this.searchAppLocal(cond, new SearchFilter(context, data));
// return this.searchAppLocal(null, new SearchFilter(context, data));
// 从数据模式暂未支持。等待后续补充
const res = { ok: true, data: [], status: 200 };
return res;
{{else}}
// return this.searchAppLocal(null, new SearchFilter(context, data));
// 从数据模式暂未支持。等待后续补充
const res = { ok: true, data: [], status: 200 };
return res;
{{/if}}
{{else}}
const res: any = { ok: false, message: '未设置数据集', status: 500 };
return res;
{{/if}}
}
......@@ -46,6 +46,10 @@ export class {{pascalCase appEntity.codeName}}ServiceBase extends EntityService
{{! 非内置行为和非临时数据方法才输出 }}
{{#if (and (eq builtinMethod false) (eq tempDataMode 0))}}
{{#if (eq appEntity.psDEServiceAPI.nested true)}}
{{#or (eq methodType 'FETCH') (eq methodType 'SELECT')}}
{{> @macro/front-end/entity/service-nested-fetch-method.hbs singleAppMethod=singleAppMethod}}
{{/or}}
{{!-- todo嵌套行为补充 --}}
{{else}}
{{!-- todo 插件 --}}
......
import { ExpView, isExist } from '@core';
import { deepCopy, hasFunction } from '@core/utils';
import { TabExpViewProps } from './tab-exp-view-prop';
import { TabExpViewState } from './tab-exp-view-state';
......@@ -17,12 +18,53 @@ export class TabExpView extends ExpView {
public declare state: TabExpViewState;
/**
*【内置功能】提供通过viewparams里的srfDefaultPanel指定默认打开的分页的功能
* 视图输入参数
*
* @type {TabExpViewProps}
* @memberof TabExpView
*/
public declare props: TabExpViewProps;
/**
*【内置功能】提供通过viewparams里的srfdefaultpanel指定默认打开的分页的功能
*/
public useDefaultPanel() {
const { srfDefaultPanel } = this.state.viewParams;
if (isExist(srfDefaultPanel)) {
this.state.defaultActivePanel = srfDefaultPanel;
const { srfdefaultpanel } = this.state.viewParams;
if (isExist(srfdefaultpanel)) {
this.state.defaultActivePanel = srfdefaultpanel;
}
}
/**
* 使用加载模型模块
*
* @private
* @memberof TabExpView
*/
private useLoadModel() {
const { context, appEntityCodeName, appDeMajorFieldName } = this.state;
if (context && context[appEntityCodeName.toLowerCase()]) {
const tempContext = deepCopy(context);
// 从数据模式标识
if (tempContext.srfsessionid) {
tempContext.srfsessionkey = tempContext.srfsessionid;
delete tempContext.srfsessionid;
}
App.getDataService(appEntityCodeName.toLowerCase(), tempContext).then((service: any) => {
if (service && hasFunction(service, 'getDataInfo')) {
service.getDataInfo(tempContext, {}, false).then((response: any) => {
if (response && response.status === 200) {
this.state.viewCtx['viewGlobal'] = response.data;
// TODO 计算工具栏权限
if (appDeMajorFieldName && response.data[appDeMajorFieldName]) {
this.state.viewCaption += ` - ${response.data[appDeMajorFieldName]}`;
}
}
});
}
}).catch((error: any) => {
console.warn('获取实体服务异常');
});
}
}
......@@ -33,7 +75,8 @@ export class TabExpView extends ExpView {
*/
public moduleInstall() {
const superParams = super.moduleInstall();
this.useDefaultPanel()
this.useDefaultPanel();
this.useLoadModel();
return {
...superParams,
};
......
......@@ -97,6 +97,24 @@ export class ViewBase {
}
}
/**
* 初始化视图操作参数
*
* @private
* @memberof ViewBase
*/
private initViewCtx() {
const { context, viewParams } = this.state;
const viewCtx = {
viewContext: context,
viewNavParams: viewParams,
view: this,
viewGlobal: {}
};
this.state.viewCtx = viewCtx;
}
/**
* @description 处理视图导航参数
*
......@@ -148,6 +166,7 @@ export class ViewBase {
const pageCustomViewParams = UIUtil.computedNavData(null, context.value, viewParams.value, appViewNavParams);
Object.assign(viewParams.value, pageCustomViewParams);
}
this.initViewCtx();
}
/**
......
......@@ -43,6 +43,13 @@ export interface ViewStateBase {
*/
viewSubject: Subject<IActionParam>;
/**
* @description 视图操作参数
* @type {IParam}
* @memberof ViewStateBase
*/
viewCtx: IParam;
/**
* @description 是否显示标题栏
* @type {boolean}
......
......@@ -28,4 +28,11 @@ export interface ControlPropsBase {
* @memberof ControlPropsBase
*/
viewSubject: Subject<IActionParam>;
/**
* @description 父部件(该部件上一层组件)
* @type {*}
* @memberof ControlPropsBase
*/
parent: any;
}
\ No newline at end of file
......@@ -7,5 +7,11 @@ import { MainControlProps } from "@core";
* @extends {MainControlProps}
*/
export interface TabViewPanelControlProps extends MainControlProps {
/**
* 父视图,即分页导航视图
*
* @type {*}
* @memberof TabViewPanelControlProps
*/
parentView: any;
}
\ No newline at end of file
......@@ -10,16 +10,41 @@ export interface TabViewPanelControlState extends MainControlState {
/**
* 导航过滤项
*
* @type {string}
* @memberof TabViewPanelControlState
*/
navFilter?:string;
/**
* 导航关系
*
* @type {IParam}
* @memberof TabViewPanelControlState
*/
navPSDer?: IParam;
/**
* 导航上下文集合
*
* @type {IParam}
* @memberof TabViewPanelControlState
*/
navContexts?:IParam;
/**
* 导航参数集合
*
* @type {IParam}
* @memberof TabViewPanelControlState
*/
navParams?:IParam;
/**
* 父视图,即分页导航视图
*
* @type {*}
* @memberof TabViewPanelControlState
*/
parentView: any;
}
\ No newline at end of file
import { IActionParam, MainControl, UIUtil } from '@core';
import { IActionParam, MainControl, UIUtil, IParam, isExistAndNotEmpty } from '@core';
import { TabViewPanelControlProps } from './tab-view-panel-control-prop';
import { TabViewPanelControlState } from './tab-view-panel-control-state';
......@@ -16,6 +16,62 @@ export class TabViewPanelControl extends MainControl {
*/
public declare state: TabViewPanelControlState;
/**
* 部件输入参数
*
* @type {TabViewPanelControlProps}
* @memberof TabViewPanelControl
*/
public declare props: TabViewPanelControlProps;
/**
* 设置部件状态
*
* @memberof TabViewPanelControl
*/
public setState() {
super.setState();
this.state.parentView = this.props.parentView;
}
/**
* 处理导航数据
*
* @private
* @return {*}
* @memberof TabViewPanelControl
*/
private handleNavData() {
const { navPSDer, parentView } = this.state;
const { context, viewParams } = toRefs(this.state);
if (!parentView || !parentView.state || !navPSDer) {
return;
}
const data: IParam = parentView.state.viewCtx?.viewGlobal || {};
const getValue = (key: string) => {
if (isExistAndNotEmpty(data[key])) {
return data[key];
} else if (isExistAndNotEmpty(context.value[key])) {
return context.value[key];
} else if (isExistAndNotEmpty(viewParams.value[key])) {
return viewParams.value[key];
}
return null;
}
if (navPSDer.major && navPSDer.majorKey) {
const value = getValue(navPSDer.majorKey);
if (navPSDer.isMajor) {
if (value) {
Object.assign(context.value, { [navPSDer.major]: value });
}
} else {
if (value) {
Object.assign(viewParams.value, { [`n_${navPSDer.majorKey}_eq`]: value });
}
}
}
}
/**
* 支持导航参数的处理
* 监听props里的context和viewParams,
......@@ -24,31 +80,27 @@ export class TabViewPanelControl extends MainControl {
*/
public useNavParams() {
const { navContexts, navParams, navFilter, appDeCodeName } = this.state;
// 处理导航数据
this.handleNavData();
const { context, viewParams } = toRefs(this.state);
watch(
[context, viewParams],
(newValues: any[], prevValues: any[]) => {
// 处理导航过滤项
if(navFilter && appDeCodeName && this.state.context[appDeCodeName.toLowerCase()]){
this.state.context[navFilter] = this.state.context[appDeCodeName.toLowerCase()];
if(navFilter && appDeCodeName && context.value[appDeCodeName.toLowerCase()]){
context.value[navFilter] = context.value[appDeCodeName.toLowerCase()];
}
// 处理导航上下文
if (navContexts && Object.keys(navContexts).length > 0) {
const _context = UIUtil.computedNavData({}, this.state.context, this.state.viewParams, navContexts);
Object.assign(this.state.context, _context);
const _context = UIUtil.computedNavData({}, context.value, viewParams.value, navContexts);
Object.assign(context.value, _context);
}
// 处理导航视图参数
if (navParams && Object.keys(navParams).length > 0) {
const _param = UIUtil.computedNavData({}, this.state.context, this.state.viewParams, navParams);
Object.assign(this.state.viewParams, _param);
const _param = UIUtil.computedNavData({}, context.value, viewParams.value, navParams);
Object.assign(viewParams.value, _param);
}
},
{
immediate: true,
},
);
console.log(1111, this.state.context, this.state.viewParams);
}
/**
......
......@@ -39,7 +39,7 @@ export class GridService<T extends ControlVOBase> extends ControlServiceBase<T>
public async search(context: IParam, data: IParam, opts: { action: string; isLoading?: boolean }): Promise<any> {
let _entityService: any = this.entityService;
const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const action = hasFunction(_entityService, opts.action) ? opts.action : 'GET';
const action = hasFunction(_entityService, opts.action) ? opts.action : 'FetchDefault';
const response = await _entityService[action](Context, Data, opts.isLoading);
let resData:any[] = response.data;
for (let index = 0; index < resData.length; index++) {
......
......@@ -38,7 +38,7 @@ export class ListService<T extends ControlVOBase> extends ControlServiceBase<T>
public async search(context: IParam, data: IParam, opts: { action: string; isLoading?: boolean }): Promise<any> {
let _entityService: any = this.entityService;
const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const action = hasFunction(_entityService, opts.action) ? opts.action : 'GET';
const action = hasFunction(_entityService, opts.action) ? opts.action : 'FetchDefault';
const response = await _entityService[action](Context, Data, opts.isLoading);
let resData: any[] = response.data;
for (let index = 0; index < resData.length; index++) {
......
......@@ -153,4 +153,30 @@ export class EntityService {
}
/**
* 获取数据(实体类重写该方法实现)
*
* @protected
* @param {IContext} context 应用上下文
* @param {IParam} [data={}] 参数
* @return {*} {Promise<any>}
* @memberof EntityService
*/
protected Get(context: IContext, data: IParam = {}): Promise<any> {
return Promise.resolve({ ok: true, status: 200, data: data });
}
/**
* 获取数据信息
*
* @protected
* @param {IContext} context 应用上下文
* @param {IParam} data 参数
* @return {*} {Promise<any>}
* @memberof EntityService
*/
protected getDataInfo(context: IContext, data: IParam): Promise<any> {
return this.Get(context, data);
}
}
\ No newline at end of file
......@@ -151,6 +151,9 @@ export class RouteUtil {
curMatch++;
curRoutPath += `/${deResNode.pathName}/${notEmpty(value) ? value : 'undefined'}`;
}
} else {
curMatch++;
curRoutPath += `/${deResNode.pathName}/${notEmpty(value) ? value : 'undefined'}`;
}
});
......@@ -160,12 +163,6 @@ export class RouteUtil {
routePath = curRoutPath;
}
});
// 如果一个匹配的没有,即没有任何主键匹配上,关系路径为实体自身的/pathName/undefined
if(routePath == ''){
routePath = "/"+deResPaths[deResPaths.length -1][0].pathName+"/undefined";
}
return routePath;
}
......
......@@ -36,7 +36,8 @@ interface CtrlEmit {
const emit = defineEmits <CtrlEmit> ();
// 安装功能模块,提供状态和能力方法
const { name, state, onCtrlEvent } = new TabExpPanelControl(ctrlState, props, emit).moduleInstall();
const tabExpPanelControl = new TabExpPanelControl(ctrlState, props, emit).moduleInstall();
const { name, state, onCtrlEvent } = tabExpPanelControl;
// 暴露内部状态及能力
defineExpose({ name, state });
......@@ -57,7 +58,8 @@ defineExpose({ name, state });
:context="state.context"
:viewParams="state.viewParams"
:viewSubject="state.viewSubject"
:parent="parent"
:parent="tabExpPanelControl"
:parentView="parent"
@onCtrlEvent="onCtrlEvent"
/>
</a-tab-pane>
......
......@@ -3,6 +3,20 @@ export const ctrlState = {
controlName: '{{ctrl.name}}',
appDeCodeName: '{{ctrl.psAppDataEntity.codeName}}',
navFilter: "{{ctrl.navFilter}}",
{{#if ctrl.navPSDER}}
navPSDer: {
{{#if ctrl.navPSDER.minorCodeName}}
isMajor: false,
minorCodeName: '{{lowerCase ctrl.navPSDER.minorCodeName}}',
{{else}}
isMajor: true,
{{/if}}
{{#if ctrl.navPSDER.majorPSDataEntity}}
major: '{{lowerCase ctrl.navPSDER.majorPSDataEntity.codeName}}',
majorKey: '{{lowerCase ctrl.navPSDER.majorPSDataEntity.keyPSDEField.codeName}}'
{{/if}}
}
{{/if}}
{{#if ctrl.psNavigateContexts}}
navContexts:{{> @macro/front-end/common/navparam.hbs appNavParams=ctrl.psNavigateContexts}},
{{/if}}
......
......@@ -11,6 +11,10 @@ interface Props {
viewParams?: IParam;
showBusyIndicator?: boolean;
viewSubject: Subject<IActionParam>;
// 父部件,即分页导航面板
parent: any;
// 父视图,此处指向分页导航视图
parentView: any;
}
const props = withDefaults(defineProps < Props > (), {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册