@ibiz-template/vue3-util 0.5.7-alpha.0 → 0.5.7-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.css +1 -1
- package/dist/index.system.min.js +1 -1
- package/es/common/code-list/code-list.d.ts +2 -2
- package/es/common/view-shell/view-shell.d.ts.map +1 -1
- package/es/common/view-shell/view-shell.mjs +9 -25
- package/es/control/panel/panel/panel.d.ts.map +1 -1
- package/es/control/panel/panel/panel.mjs +6 -1
- package/es/control/panel/view-layout-panel/view-layout-panel.d.ts.map +1 -1
- package/es/control/panel/view-layout-panel/view-layout-panel.mjs +6 -1
- package/es/panel-component/grid-container/grid-container.d.ts +2 -0
- package/es/panel-component/grid-container/grid-container.d.ts.map +1 -1
- package/es/panel-component/grid-container/index.d.ts +2 -0
- package/es/panel-component/grid-container/index.d.ts.map +1 -1
- package/es/panel-component/panel-rawitem/index.d.ts +1 -0
- package/es/panel-component/panel-rawitem/index.d.ts.map +1 -1
- package/es/panel-component/panel-rawitem/panel-rawitem.d.ts +1 -0
- package/es/panel-component/panel-rawitem/panel-rawitem.d.ts.map +1 -1
- package/es/panel-component/panel-rawitem/panel-rawitem.mjs +11 -2
- package/es/props/editor/autocomplete.d.ts +2 -2
- package/es/props/editor/check-box-list.d.ts +2 -2
- package/es/props/editor/check-box.d.ts +2 -2
- package/es/props/editor/data-picker.d.ts +2 -2
- package/es/props/editor/date-picker.d.ts +2 -2
- package/es/props/editor/date-range.d.ts +2 -2
- package/es/props/editor/dropdown-list.d.ts +2 -2
- package/es/props/editor/list-box.d.ts +2 -2
- package/es/props/editor/number-range.d.ts +2 -2
- package/es/props/editor/radio-button-list.d.ts +2 -2
- package/es/props/editor/rate.d.ts +2 -2
- package/es/props/editor/raw.d.ts +2 -2
- package/es/props/editor/slider.d.ts +2 -2
- package/es/props/editor/span.d.ts +2 -2
- package/es/props/editor/stepper.d.ts +2 -2
- package/es/props/editor/switch.d.ts +2 -2
- package/es/props/editor/text-box.d.ts +2 -2
- package/es/util/route/route.d.ts +4 -3
- package/es/util/route/route.d.ts.map +1 -1
- package/es/util/route/route.mjs +19 -5
- package/es/util/store/app-store/app-store.d.ts +3 -82
- package/es/util/store/app-store/app-store.d.ts.map +1 -1
- package/es/util/store/app-store/app-store.mjs +1 -8
- package/es/view/common/index.d.ts +0 -1
- package/es/view/common/index.d.ts.map +1 -1
- package/es/view/common/view.d.ts +0 -1
- package/es/view/common/view.d.ts.map +1 -1
- package/es/view/common/view.mjs +1 -17
- package/package.json +6 -6
- package/src/common/view-shell/view-shell.tsx +11 -35
- package/src/control/panel/panel/panel.tsx +6 -0
- package/src/control/panel/view-layout-panel/view-layout-panel.tsx +6 -0
- package/src/panel-component/panel-rawitem/panel-rawitem.tsx +11 -1
- package/src/util/route/route.ts +30 -5
- package/src/util/store/app-store/app-store.ts +3 -14
- package/src/view/common/view.tsx +0 -24
- package/es/util/store/async-action/async-action.d.ts +0 -56
- package/es/util/store/async-action/async-action.d.ts.map +0 -1
- package/es/util/store/async-action/async-action.mjs +0 -80
- package/src/util/store/async-action/async-action.ts +0 -122
package/es/view/common/view.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { defineComponent, computed,
|
|
1
|
+
import { defineComponent, computed, createVNode, resolveComponent, h, createTextVNode, withDirectives, resolveDirective } from 'vue';
|
|
2
2
|
import { ViewController, getControlsByView } from '@ibiz-template/runtime';
|
|
3
|
-
import { createUUID } from 'qx-util';
|
|
4
3
|
import './view.css';
|
|
5
4
|
import '../../use/index.mjs';
|
|
6
5
|
import { useNamespace } from '../../use/namespace/namespace.mjs';
|
|
@@ -44,19 +43,6 @@ const View = /* @__PURE__ */ defineComponent({
|
|
|
44
43
|
const onLayoutPanelCreated = (controller) => {
|
|
45
44
|
c.setLayoutPanel(controller);
|
|
46
45
|
};
|
|
47
|
-
const container = ref(null);
|
|
48
|
-
const key = createUUID();
|
|
49
|
-
const devtool = window.devtool;
|
|
50
|
-
onMounted(() => {
|
|
51
|
-
if (devtool) {
|
|
52
|
-
devtool.registerView(key, c, container);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
onUnmounted(() => {
|
|
56
|
-
if (devtool) {
|
|
57
|
-
devtool.unRegisterView(key);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
46
|
const renderViewMessage = (position) => {
|
|
61
47
|
if (c.state.isCreated) {
|
|
62
48
|
const viewMessages = c.state.viewMessages[position];
|
|
@@ -73,7 +59,6 @@ const View = /* @__PURE__ */ defineComponent({
|
|
|
73
59
|
c,
|
|
74
60
|
controls,
|
|
75
61
|
viewClassNames,
|
|
76
|
-
container,
|
|
77
62
|
onLayoutPanelCreated,
|
|
78
63
|
renderViewMessage
|
|
79
64
|
};
|
|
@@ -133,7 +118,6 @@ const View = /* @__PURE__ */ defineComponent({
|
|
|
133
118
|
}
|
|
134
119
|
}
|
|
135
120
|
return withDirectives(createVNode("div", {
|
|
136
|
-
"ref": "container",
|
|
137
121
|
"class": this.viewClassNames,
|
|
138
122
|
"id": this.c.id
|
|
139
123
|
}, [this.renderViewMessage("TOP"), layoutPanel, this.renderViewMessage("BOTTOM")]), [[resolveDirective("loading"), this.c.state.isLoading]]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibiz-template/vue3-util",
|
|
3
|
-
"version": "0.5.7-alpha.
|
|
3
|
+
"version": "0.5.7-alpha.10",
|
|
4
4
|
"description": "vue3 工具包",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@ibiz-template/cli": "^0.3.10",
|
|
35
|
-
"@ibiz-template/core": "^0.5.7-alpha.
|
|
36
|
-
"@ibiz-template/runtime": "^0.5.7-alpha.
|
|
35
|
+
"@ibiz-template/core": "^0.5.7-alpha.10",
|
|
36
|
+
"@ibiz-template/runtime": "^0.5.7-alpha.10",
|
|
37
37
|
"@ibiz-template/theme": "^0.5.7-alpha.0",
|
|
38
|
-
"@ibiz/model-core": "^0.1.
|
|
38
|
+
"@ibiz/model-core": "^0.1.9",
|
|
39
39
|
"@types/path-browserify": "^1.0.2",
|
|
40
40
|
"@types/qs": "^6.9.11",
|
|
41
41
|
"@types/systemjs": "^6.13.5",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@ibiz-template/core": "^0.5.0-beta.0",
|
|
54
54
|
"@ibiz-template/runtime": "^0.5.0-beta.0",
|
|
55
|
-
"@ibiz/model-core": "^0.1.
|
|
55
|
+
"@ibiz/model-core": "^0.1.9",
|
|
56
56
|
"dayjs": "^1.11.10",
|
|
57
57
|
"path-browserify": "^1.0.1",
|
|
58
58
|
"pinia": "^2.1.7",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"vue": "^3.3.4",
|
|
63
63
|
"vue-router": "^4.2.4"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "9ccf60215bd9d4c64c9102032c492a85ddbc591e"
|
|
66
66
|
}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import {
|
|
4
4
|
getViewProvider,
|
|
5
5
|
IViewProvider,
|
|
6
|
-
|
|
6
|
+
calcDynaSysParams,
|
|
7
7
|
} from '@ibiz-template/runtime';
|
|
8
8
|
import { defineComponent, h, PropType, ref, resolveComponent } from 'vue';
|
|
9
|
-
import {
|
|
9
|
+
import { IAppView } from '@ibiz/model-core';
|
|
10
10
|
import { RuntimeError } from '@ibiz-template/core';
|
|
11
11
|
import { createUUID } from 'qx-util';
|
|
12
12
|
import { isEmpty, isNil } from 'ramda';
|
|
@@ -42,13 +42,7 @@ export const IBizViewShell = defineComponent({
|
|
|
42
42
|
if (viewModel.dynaSysMode === 1) {
|
|
43
43
|
//* 计算实体资源路径上下文参数
|
|
44
44
|
const appDataEntityId = viewModel.appDataEntityId;
|
|
45
|
-
|
|
46
|
-
if (appDataEntityId) {
|
|
47
|
-
appDe = await ibiz.hub.getAppDataEntity(
|
|
48
|
-
appDataEntityId,
|
|
49
|
-
viewModel.appId,
|
|
50
|
-
);
|
|
51
|
-
} else {
|
|
45
|
+
if (!appDataEntityId) {
|
|
52
46
|
throw new RuntimeError(
|
|
53
47
|
`${viewModel.codeName}无实体,暂不支持加载动态模型`,
|
|
54
48
|
);
|
|
@@ -57,38 +51,20 @@ export const IBizViewShell = defineComponent({
|
|
|
57
51
|
const params = props.params || {};
|
|
58
52
|
|
|
59
53
|
/** 加载动态模型的请求参数 */
|
|
60
|
-
const loadModelParams: IParams =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
// 主键
|
|
66
|
-
const srfkey = props.context[appDe.codeName!.toLowerCase()];
|
|
67
|
-
if (srfkey) {
|
|
68
|
-
loadModelParams.srfkey = srfkey;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
54
|
+
const loadModelParams: IParams = await calcDynaSysParams(
|
|
55
|
+
appDataEntityId,
|
|
56
|
+
props.context,
|
|
57
|
+
{ viewParams: params, appId: viewModel.appId },
|
|
58
|
+
);
|
|
71
59
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
loadModelParams.srfparentkey = params.srfparentkey;
|
|
75
|
-
loadModelParams.srfparentdeanme = params.srfparentdeanme;
|
|
76
|
-
} else {
|
|
77
|
-
// 上层资源路径主实体名称和主键
|
|
78
|
-
const match = getMatchResPath(props.context, appDe);
|
|
79
|
-
if (match && match.keys.length > 1) {
|
|
80
|
-
const parentDeKey = match.keys[match.keys.length - 2];
|
|
81
|
-
loadModelParams.srfparentkey =
|
|
82
|
-
params.srfparentkey || props.context[parentDeKey];
|
|
83
|
-
loadModelParams.srfparentdeanme =
|
|
84
|
-
params.srfparentdeanme || parentDeKey;
|
|
85
|
-
}
|
|
60
|
+
if (params.srfdatatype) {
|
|
61
|
+
loadModelParams.srfdatatype = params.srfdatatype;
|
|
86
62
|
}
|
|
87
63
|
|
|
88
64
|
// 如果视图参数中存在 srfwftag 则直接使用视图参数
|
|
89
65
|
if (params.srfwftag) {
|
|
90
66
|
loadModelParams.srfwftag = params.srfwftag;
|
|
91
|
-
} else if (
|
|
67
|
+
} else if (appDataEntityId && viewModel.enableWF) {
|
|
92
68
|
// 处理数据请求的上下文
|
|
93
69
|
const context: IContext = { ...props.context };
|
|
94
70
|
// 存在主键则加载数据计算对应的参数
|
|
@@ -74,12 +74,18 @@ function renderPanelItem(
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
// 直接样式
|
|
78
|
+
let tempStyle = '';
|
|
79
|
+
if (panelItem.cssStyle) {
|
|
80
|
+
tempStyle = panelItem.cssStyle;
|
|
81
|
+
}
|
|
77
82
|
return h(
|
|
78
83
|
component,
|
|
79
84
|
{
|
|
80
85
|
modelData: panelItem,
|
|
81
86
|
controller: panelItems[panelItem.id!],
|
|
82
87
|
key: panelItem.id,
|
|
88
|
+
style: tempStyle,
|
|
83
89
|
},
|
|
84
90
|
children,
|
|
85
91
|
);
|
|
@@ -128,12 +128,18 @@ export const ViewLayoutPanelControl = defineComponent({
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
// 直接样式
|
|
132
|
+
let tempStyle = '';
|
|
133
|
+
if (panelItem.cssStyle) {
|
|
134
|
+
tempStyle = panelItem.cssStyle;
|
|
135
|
+
}
|
|
131
136
|
return h(
|
|
132
137
|
component,
|
|
133
138
|
{
|
|
134
139
|
modelData: panelItem,
|
|
135
140
|
controller: panelItems[panelItem.id!],
|
|
136
141
|
key: panelItem.id,
|
|
142
|
+
style: tempStyle,
|
|
137
143
|
},
|
|
138
144
|
children,
|
|
139
145
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IPanelRawItem } from '@ibiz/model-core';
|
|
2
|
-
import { computed, defineComponent, PropType } from 'vue';
|
|
2
|
+
import { computed, defineComponent, PropType, ref } from 'vue';
|
|
3
3
|
import { useNamespace } from '../../use';
|
|
4
4
|
import { PanelRawItemController } from './panel-rawitem.controller';
|
|
5
5
|
import './panel-rawitem.scss';
|
|
@@ -19,6 +19,14 @@ export const PanelRawItem = defineComponent({
|
|
|
19
19
|
setup(props) {
|
|
20
20
|
const ns = useNamespace('panel-rawitem');
|
|
21
21
|
|
|
22
|
+
const tempStyle = ref('');
|
|
23
|
+
|
|
24
|
+
const { rawItem } = props.modelData;
|
|
25
|
+
|
|
26
|
+
if (rawItem && rawItem.cssStyle) {
|
|
27
|
+
tempStyle.value = rawItem.cssStyle;
|
|
28
|
+
}
|
|
29
|
+
|
|
22
30
|
// 类名控制
|
|
23
31
|
const classArr = computed(() => {
|
|
24
32
|
const { id } = props.modelData;
|
|
@@ -30,6 +38,7 @@ export const PanelRawItem = defineComponent({
|
|
|
30
38
|
return {
|
|
31
39
|
ns,
|
|
32
40
|
classArr,
|
|
41
|
+
tempStyle,
|
|
33
42
|
};
|
|
34
43
|
},
|
|
35
44
|
render() {
|
|
@@ -40,6 +49,7 @@ export const PanelRawItem = defineComponent({
|
|
|
40
49
|
return (
|
|
41
50
|
<div
|
|
42
51
|
class={this.classArr}
|
|
52
|
+
style={this.tempStyle}
|
|
43
53
|
onClick={() => {
|
|
44
54
|
this.controller.onClick();
|
|
45
55
|
}}
|
package/src/util/route/route.ts
CHANGED
|
@@ -19,16 +19,26 @@ import { IRoutePath, IRoutePathNode, IRouteViewData } from '../../interface';
|
|
|
19
19
|
* @date 2022-08-18 11:08:08
|
|
20
20
|
* @export
|
|
21
21
|
* @param {string} pathStr 以/开头的路径,即router的path
|
|
22
|
+
* @param {boolean} [isRouteModal=false]
|
|
22
23
|
* @returns {*} {IRoutePath}
|
|
23
24
|
*/
|
|
24
|
-
export function route2routePath(
|
|
25
|
+
export function route2routePath(
|
|
26
|
+
route: Route,
|
|
27
|
+
isRouteModal: boolean = false,
|
|
28
|
+
): IRoutePath {
|
|
25
29
|
// 一共匹配了几级路由
|
|
26
30
|
const depth = route.matched.length;
|
|
27
31
|
|
|
32
|
+
let path = route.path;
|
|
33
|
+
if (isRouteModal) {
|
|
34
|
+
path = path.replace(new RegExp(`/${RouteConst.ROUTE_MODAL_TAG}`, 'g'), '');
|
|
35
|
+
}
|
|
36
|
+
const items = path.split('/');
|
|
37
|
+
|
|
28
38
|
// 解析路径节点
|
|
29
39
|
const pathNodes: IRoutePathNode[] = [];
|
|
30
40
|
for (let index = 1; index <= depth; index++) {
|
|
31
|
-
const viewName =
|
|
41
|
+
const viewName = items[index * 2];
|
|
32
42
|
const paramsStr = route.params[`params${index}`] as string;
|
|
33
43
|
|
|
34
44
|
/** 路由参数,默认是视图参数 */
|
|
@@ -341,6 +351,15 @@ export async function generateRoutePathByModal(
|
|
|
341
351
|
): Promise<{ path: string }> {
|
|
342
352
|
const routePath = route2routePath(route);
|
|
343
353
|
|
|
354
|
+
// 特殊处理 RouteConst.ROUTE_MODAL_TAG,因为只能有一级避免多次或重复点击,导致路由计算错误。再次点击时把之前的modal路由删除
|
|
355
|
+
const findIndex = routePath.pathNodes.findIndex(
|
|
356
|
+
item => item.viewName === RouteConst.ROUTE_MODAL_TAG,
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
if (findIndex !== -1) {
|
|
360
|
+
routePath.pathNodes = routePath.pathNodes.slice(0, findIndex);
|
|
361
|
+
}
|
|
362
|
+
|
|
344
363
|
// 导航视图的导航参数,加在目标层级之前的一个层级的视图参数里
|
|
345
364
|
if (context.currentSrfNav) {
|
|
346
365
|
const currentNode = routePath.pathNodes[routePath.pathNodes.length - 1];
|
|
@@ -352,7 +371,9 @@ export async function generateRoutePathByModal(
|
|
|
352
371
|
|
|
353
372
|
// 计算目标视图path路径
|
|
354
373
|
routePath.pathNodes.push({
|
|
355
|
-
viewName: `${
|
|
374
|
+
viewName: `${
|
|
375
|
+
RouteConst.ROUTE_MODAL_TAG
|
|
376
|
+
}/${appView.codeName!.toLowerCase()}`,
|
|
356
377
|
context: getOwnRouteContext(context),
|
|
357
378
|
params,
|
|
358
379
|
});
|
|
@@ -366,23 +387,27 @@ export async function generateRoutePathByModal(
|
|
|
366
387
|
* @author lxm
|
|
367
388
|
* @date 2022-08-17 22:08:51
|
|
368
389
|
* @export
|
|
369
|
-
* @param {IApplication} appModel 视图模型
|
|
370
390
|
* @param {Route} route 路由对象
|
|
371
391
|
* @param {number} depth 层级
|
|
392
|
+
* @param {boolean} [isRouteModal=false]
|
|
372
393
|
* @returns {*} {IRouteViewData}
|
|
373
394
|
*/
|
|
374
395
|
export async function parseRouteViewData(
|
|
375
396
|
route: Route,
|
|
376
397
|
depth: number,
|
|
398
|
+
isRouteModal: boolean = false,
|
|
377
399
|
): Promise<IRouteViewData> {
|
|
378
400
|
// 解析路由的视图参数
|
|
379
|
-
const routePath = route2routePath(route);
|
|
401
|
+
const routePath = route2routePath(route, isRouteModal);
|
|
380
402
|
|
|
381
403
|
// 获取对应层级的视图名称参数
|
|
382
404
|
let viewCodeName = routePath.pathNodes[depth - 1].viewName;
|
|
383
405
|
if (!viewCodeName) {
|
|
384
406
|
throw new RuntimeError(`第${depth}级路由不存在视图标识`);
|
|
385
407
|
}
|
|
408
|
+
if (viewCodeName === RouteConst.ROUTE_MODAL_TAG) {
|
|
409
|
+
viewCodeName = routePath.pathNodes[depth].viewName;
|
|
410
|
+
}
|
|
386
411
|
if (viewCodeName === 'index') {
|
|
387
412
|
viewCodeName = ibiz.hub.defaultAppIndexViewName;
|
|
388
413
|
}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
import { IPortalAsyncAction } from '@ibiz-template/core';
|
|
2
1
|
import { defineStore } from 'pinia';
|
|
3
|
-
import { reactive
|
|
4
|
-
import { useAsyncAction } from '../async-action/async-action';
|
|
2
|
+
import { reactive } from 'vue';
|
|
5
3
|
|
|
6
|
-
export interface IAppStore {
|
|
7
|
-
allAsyncActions: Ref<IPortalAsyncAction[]>;
|
|
8
|
-
recentAsyncActions: IPortalAsyncAction[];
|
|
9
|
-
}
|
|
4
|
+
export interface IAppStore {}
|
|
10
5
|
|
|
11
6
|
export const useAppStore = defineStore('appStore', () => {
|
|
12
|
-
const
|
|
13
|
-
const appStore = reactive<IAppStore>({
|
|
14
|
-
allAsyncActions,
|
|
15
|
-
get recentAsyncActions() {
|
|
16
|
-
return recentAsyncActions.value;
|
|
17
|
-
},
|
|
18
|
-
});
|
|
7
|
+
const appStore = reactive<IAppStore>({});
|
|
19
8
|
|
|
20
9
|
return { appStore };
|
|
21
10
|
});
|
package/src/view/common/view.tsx
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
IViewProvider,
|
|
6
6
|
ViewController,
|
|
7
7
|
} from '@ibiz-template/runtime';
|
|
8
|
-
import { createUUID } from 'qx-util';
|
|
9
8
|
import { IAppView } from '@ibiz/model-core';
|
|
10
9
|
import {
|
|
11
10
|
defineComponent,
|
|
@@ -13,10 +12,7 @@ import {
|
|
|
13
12
|
PropType,
|
|
14
13
|
resolveComponent,
|
|
15
14
|
VNode,
|
|
16
|
-
ref,
|
|
17
15
|
computed,
|
|
18
|
-
onMounted,
|
|
19
|
-
onUnmounted,
|
|
20
16
|
} from 'vue';
|
|
21
17
|
import './view.scss';
|
|
22
18
|
import { useNamespace, useViewController } from '../../use';
|
|
@@ -54,24 +50,6 @@ export const View = defineComponent({
|
|
|
54
50
|
c.setLayoutPanel(controller as IViewLayoutPanelController);
|
|
55
51
|
};
|
|
56
52
|
|
|
57
|
-
const container = ref<HTMLElement | null>(null);
|
|
58
|
-
// todo devtool抽全局
|
|
59
|
-
const key = createUUID();
|
|
60
|
-
|
|
61
|
-
// 临时实现从window上取
|
|
62
|
-
const devtool = (window as IData).devtool;
|
|
63
|
-
onMounted(() => {
|
|
64
|
-
if (devtool) {
|
|
65
|
-
devtool.registerView(key, c, container);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
onUnmounted(() => {
|
|
70
|
-
if (devtool) {
|
|
71
|
-
devtool.unRegisterView(key);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
53
|
const renderViewMessage = (position: 'TOP' | 'BOTTOM' | 'BODY') => {
|
|
76
54
|
if (c.state.isCreated) {
|
|
77
55
|
const viewMessages = c.state.viewMessages[position];
|
|
@@ -91,7 +69,6 @@ export const View = defineComponent({
|
|
|
91
69
|
c,
|
|
92
70
|
controls,
|
|
93
71
|
viewClassNames,
|
|
94
|
-
container,
|
|
95
72
|
onLayoutPanelCreated,
|
|
96
73
|
renderViewMessage,
|
|
97
74
|
};
|
|
@@ -162,7 +139,6 @@ export const View = defineComponent({
|
|
|
162
139
|
|
|
163
140
|
return (
|
|
164
141
|
<div
|
|
165
|
-
ref='container'
|
|
166
142
|
class={this.viewClassNames}
|
|
167
143
|
id={this.c.id}
|
|
168
144
|
v-loading={this.c.state.isLoading}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 使用异步操作消息
|
|
3
|
-
* @author lxm
|
|
4
|
-
* @date 2023-11-14 03:17:28
|
|
5
|
-
* @export
|
|
6
|
-
* @return {*}
|
|
7
|
-
*/
|
|
8
|
-
export declare function useAsyncAction(): {
|
|
9
|
-
allAsyncActions: import("vue").Ref<{
|
|
10
|
-
asyncacitonid: string;
|
|
11
|
-
asyncacitonname: string;
|
|
12
|
-
fulltopictag: string;
|
|
13
|
-
srfdcid: string;
|
|
14
|
-
dcsystemid: string;
|
|
15
|
-
actiontype: string;
|
|
16
|
-
actionstate: 10 | 20 | 30 | 40;
|
|
17
|
-
actionresult?: unknown;
|
|
18
|
-
stepinfo?: string | undefined;
|
|
19
|
-
completionrate?: number | undefined;
|
|
20
|
-
asyncresultdownloadurl?: string | undefined;
|
|
21
|
-
actionparam?: unknown;
|
|
22
|
-
actionparam2?: unknown;
|
|
23
|
-
actionparam3?: unknown;
|
|
24
|
-
actionparam4?: unknown;
|
|
25
|
-
begintime: string;
|
|
26
|
-
endtime: string;
|
|
27
|
-
createman: string;
|
|
28
|
-
createdate: string;
|
|
29
|
-
updateman: string;
|
|
30
|
-
updatedate: string;
|
|
31
|
-
}[]>;
|
|
32
|
-
recentAsyncActions: import("vue").ComputedRef<{
|
|
33
|
-
asyncacitonid: string;
|
|
34
|
-
asyncacitonname: string;
|
|
35
|
-
fulltopictag: string;
|
|
36
|
-
srfdcid: string;
|
|
37
|
-
dcsystemid: string;
|
|
38
|
-
actiontype: string;
|
|
39
|
-
actionstate: 10 | 20 | 30 | 40;
|
|
40
|
-
actionresult?: unknown;
|
|
41
|
-
stepinfo?: string | undefined;
|
|
42
|
-
completionrate?: number | undefined;
|
|
43
|
-
asyncresultdownloadurl?: string | undefined;
|
|
44
|
-
actionparam?: unknown;
|
|
45
|
-
actionparam2?: unknown;
|
|
46
|
-
actionparam3?: unknown;
|
|
47
|
-
actionparam4?: unknown;
|
|
48
|
-
begintime: string;
|
|
49
|
-
endtime: string;
|
|
50
|
-
createman: string;
|
|
51
|
-
createdate: string;
|
|
52
|
-
updateman: string;
|
|
53
|
-
updatedate: string;
|
|
54
|
-
}[]>;
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=async-action.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-action.d.ts","sourceRoot":"","sources":["../../../../src/util/store/async-action/async-action.ts"],"names":[],"mappings":"AAiDA;;;;;;GAMG;AACH,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiE7B"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
import { isNumber, isNil } from 'lodash-es';
|
|
3
|
-
import { ref, computed, onUnmounted } from 'vue';
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
function formatAsyncAction(data) {
|
|
7
|
-
const dateFields = [
|
|
8
|
-
"begintime",
|
|
9
|
-
"endtime",
|
|
10
|
-
"createdate",
|
|
11
|
-
"updatedate"
|
|
12
|
-
];
|
|
13
|
-
dateFields.forEach((key) => {
|
|
14
|
-
if (isNumber(data[key])) {
|
|
15
|
-
data[key] = dayjs(data[key]).format("YYYY-MM-DD HH:mm:ss");
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
if (!isNil(data.actionresult)) {
|
|
19
|
-
try {
|
|
20
|
-
const json = JSON.parse(data.actionresult);
|
|
21
|
-
data.actionresult = json;
|
|
22
|
-
} catch (error) {
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (!isNil(data.completionrate)) {
|
|
26
|
-
const num = Number(data.completionrate);
|
|
27
|
-
if (Number.isNaN(num)) {
|
|
28
|
-
data.completionrate = void 0;
|
|
29
|
-
} else {
|
|
30
|
-
data.completionrate = num;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return data;
|
|
34
|
-
}
|
|
35
|
-
function useAsyncAction() {
|
|
36
|
-
const allAsyncActions = ref([]);
|
|
37
|
-
const showLength = ref(0);
|
|
38
|
-
const recentAsyncActions = computed(() => {
|
|
39
|
-
return allAsyncActions.value.filter(
|
|
40
|
-
(_item, index) => index < showLength.value
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
const load = async () => {
|
|
44
|
-
const res = await ibiz.asyncAction.fetch();
|
|
45
|
-
res.data.forEach(formatAsyncAction);
|
|
46
|
-
allAsyncActions.value = res.data;
|
|
47
|
-
};
|
|
48
|
-
const asyncActionCallBack = (msg) => {
|
|
49
|
-
if (!msg.data || msg.subtype !== "ASYNCACTION") {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
console.log("\u539F\u59CB\u6570\u636E", msg);
|
|
53
|
-
const asyncAction = formatAsyncAction(msg.data);
|
|
54
|
-
console.log("\u683C\u5F0F\u5316\u540E\u6570\u636E", asyncAction);
|
|
55
|
-
const findIndex = allAsyncActions.value.findIndex(
|
|
56
|
-
(item) => item.asyncacitonid === asyncAction.asyncacitonid
|
|
57
|
-
);
|
|
58
|
-
if (findIndex === -1) {
|
|
59
|
-
allAsyncActions.value.unshift(asyncAction);
|
|
60
|
-
showLength.value += 1;
|
|
61
|
-
} else {
|
|
62
|
-
const isShow = findIndex >= showLength.value;
|
|
63
|
-
if (isShow) {
|
|
64
|
-
allAsyncActions.value.splice(findIndex, 1);
|
|
65
|
-
allAsyncActions.value.unshift(asyncAction);
|
|
66
|
-
showLength.value += 1;
|
|
67
|
-
} else {
|
|
68
|
-
allAsyncActions.value.splice(findIndex, 1, asyncAction);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
load();
|
|
73
|
-
ibiz.mc.command.asyncAction.on(asyncActionCallBack);
|
|
74
|
-
onUnmounted(() => {
|
|
75
|
-
ibiz.mc.command.asyncAction.off(asyncActionCallBack);
|
|
76
|
-
});
|
|
77
|
-
return { allAsyncActions, recentAsyncActions };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export { useAsyncAction };
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
2
|
-
|
|
3
|
-
import { IPortalAsyncAction, IPortalMessage } from '@ibiz-template/core';
|
|
4
|
-
import dayjs from 'dayjs';
|
|
5
|
-
import { isNil, isNumber } from 'lodash-es';
|
|
6
|
-
import { computed, onUnmounted, ref } from 'vue';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 格式化数据
|
|
10
|
-
* @author lxm
|
|
11
|
-
* @date 2023-11-14 09:02:49
|
|
12
|
-
* @param {IPortalAsyncAction} data
|
|
13
|
-
* @return {*} {IPortalAsyncAction}
|
|
14
|
-
*/
|
|
15
|
-
function formatAsyncAction(data: IPortalAsyncAction): IPortalAsyncAction {
|
|
16
|
-
// 处理时间日期为毫秒值时,转换成字符串。
|
|
17
|
-
const dateFields = [
|
|
18
|
-
'begintime',
|
|
19
|
-
'endtime',
|
|
20
|
-
'createdate',
|
|
21
|
-
'updatedate',
|
|
22
|
-
] as const;
|
|
23
|
-
dateFields.forEach(key => {
|
|
24
|
-
if (isNumber(data[key])) {
|
|
25
|
-
data[key] = dayjs(data[key]).format('YYYY-MM-DD HH:mm:ss');
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
if (!isNil(data.actionresult)) {
|
|
30
|
-
try {
|
|
31
|
-
const json = JSON.parse(data.actionresult as string);
|
|
32
|
-
data.actionresult = json;
|
|
33
|
-
} catch (error) {
|
|
34
|
-
// 不是对象类型就是字符串。
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (!isNil(data.completionrate)) {
|
|
39
|
-
const num = Number(data.completionrate);
|
|
40
|
-
if (Number.isNaN(num)) {
|
|
41
|
-
data.completionrate = undefined;
|
|
42
|
-
} else {
|
|
43
|
-
data.completionrate = num;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 使用异步操作消息
|
|
52
|
-
* @author lxm
|
|
53
|
-
* @date 2023-11-14 03:17:28
|
|
54
|
-
* @export
|
|
55
|
-
* @return {*}
|
|
56
|
-
*/
|
|
57
|
-
export function useAsyncAction() {
|
|
58
|
-
/** 所有消息数据 */
|
|
59
|
-
const allAsyncActions = ref<IPortalAsyncAction[]>([]);
|
|
60
|
-
/** 显示的长度 */
|
|
61
|
-
const showLength = ref(0);
|
|
62
|
-
|
|
63
|
-
/** 显示的消息数据 */
|
|
64
|
-
const recentAsyncActions = computed(() => {
|
|
65
|
-
return allAsyncActions.value.filter(
|
|
66
|
-
(_item, index) => index < showLength.value,
|
|
67
|
-
);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const load = async () => {
|
|
71
|
-
const res = await ibiz.asyncAction.fetch();
|
|
72
|
-
res.data.forEach(formatAsyncAction);
|
|
73
|
-
allAsyncActions.value = res.data;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* 异步消息变更回调处理
|
|
78
|
-
* @author lxm
|
|
79
|
-
* @date 2023-11-14 03:53:08
|
|
80
|
-
*/
|
|
81
|
-
const asyncActionCallBack = (msg: IPortalMessage) => {
|
|
82
|
-
if (!msg.data || msg.subtype !== 'ASYNCACTION') {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
console.log('原始数据', msg);
|
|
86
|
-
|
|
87
|
-
const asyncAction = formatAsyncAction(msg.data as IPortalAsyncAction);
|
|
88
|
-
|
|
89
|
-
console.log('格式化后数据', asyncAction);
|
|
90
|
-
|
|
91
|
-
const findIndex = allAsyncActions.value.findIndex(
|
|
92
|
-
item => item.asyncacitonid === asyncAction.asyncacitonid,
|
|
93
|
-
);
|
|
94
|
-
if (findIndex === -1) {
|
|
95
|
-
// 不存在的数据补充到最开始,并显示长度加一
|
|
96
|
-
allAsyncActions.value.unshift(asyncAction);
|
|
97
|
-
showLength.value += 1;
|
|
98
|
-
} else {
|
|
99
|
-
const isShow = findIndex >= showLength.value;
|
|
100
|
-
// 找的到但是不在显示列表里,移到开头,并增加长度
|
|
101
|
-
if (isShow) {
|
|
102
|
-
allAsyncActions.value.splice(findIndex, 1);
|
|
103
|
-
allAsyncActions.value.unshift(asyncAction);
|
|
104
|
-
showLength.value += 1;
|
|
105
|
-
} else {
|
|
106
|
-
allAsyncActions.value.splice(findIndex, 1, asyncAction);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// *初始化操作
|
|
112
|
-
load();
|
|
113
|
-
|
|
114
|
-
// 监听异步操作消息变更
|
|
115
|
-
ibiz.mc.command.asyncAction.on(asyncActionCallBack);
|
|
116
|
-
// 销毁时删除监听
|
|
117
|
-
onUnmounted(() => {
|
|
118
|
-
ibiz.mc.command.asyncAction.off(asyncActionCallBack);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
return { allAsyncActions, recentAsyncActions };
|
|
122
|
-
}
|