@ibiz-template/vue3-util 0.3.5 → 0.4.0
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/dist/index.system.min.js.map +1 -1
- package/es/control/index.d.ts +2 -0
- package/es/control/index.d.ts.map +1 -0
- package/es/control/index.mjs +5 -0
- package/es/control/panel/index.d.ts +3 -0
- package/es/control/panel/index.d.ts.map +1 -0
- package/es/control/panel/index.mjs +4 -0
- package/es/control/panel/panel/index.d.ts +57 -0
- package/es/control/panel/panel/index.d.ts.map +1 -0
- package/es/control/panel/panel/index.mjs +13 -0
- package/es/control/panel/panel/panel.css +1 -0
- package/es/control/panel/panel/panel.d.ts +63 -0
- package/es/control/panel/panel/panel.d.ts.map +1 -0
- package/es/control/panel/panel/panel.mjs +135 -0
- package/es/control/panel/panel/panel.provider.d.ts +14 -0
- package/es/control/panel/panel/panel.provider.d.ts.map +1 -0
- package/es/control/panel/panel/panel.provider.mjs +8 -0
- package/es/control/panel/view-layout-panel/index.d.ts +58 -0
- package/es/control/panel/view-layout-panel/index.d.ts.map +1 -0
- package/es/control/panel/view-layout-panel/index.mjs +19 -0
- package/es/control/panel/view-layout-panel/view-layout-panel.css +1 -0
- package/es/control/panel/view-layout-panel/view-layout-panel.d.ts +62 -0
- package/es/control/panel/view-layout-panel/view-layout-panel.d.ts.map +1 -0
- package/es/control/panel/view-layout-panel/view-layout-panel.mjs +137 -0
- package/es/control/panel/view-layout-panel/view-layout-panel.provider.d.ts +14 -0
- package/es/control/panel/view-layout-panel/view-layout-panel.provider.d.ts.map +1 -0
- package/es/control/panel/view-layout-panel/view-layout-panel.provider.mjs +8 -0
- package/es/index.d.ts +1 -0
- package/es/index.d.ts.map +1 -1
- package/es/index.mjs +3 -0
- package/es/use/control/use-control-controller/use-control-controller.d.ts +10 -1
- package/es/use/control/use-control-controller/use-control-controller.d.ts.map +1 -1
- package/es/use/control/use-control-controller/use-control-controller.mjs +4 -4
- package/lib/index.cjs +10 -5
- package/package.json +7 -7
- package/src/control/index.ts +1 -0
- package/src/control/panel/index.ts +2 -0
- package/src/control/panel/panel/index.ts +12 -0
- package/src/control/panel/panel/panel.provider.ts +14 -0
- package/src/control/panel/panel/panel.scss +9 -0
- package/src/control/panel/panel/panel.tsx +160 -0
- package/src/control/panel/view-layout-panel/index.ts +18 -0
- package/src/control/panel/view-layout-panel/view-layout-panel.provider.ts +14 -0
- package/src/control/panel/view-layout-panel/view-layout-panel.scss +9 -0
- package/src/control/panel/view-layout-panel/view-layout-panel.tsx +172 -0
- package/src/index.ts +1 -0
- package/src/use/control/use-control-controller/use-control-controller.ts +18 -3
package/es/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AAExB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,YAAY,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;KAC7B;CACF"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AAExB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,YAAY,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;KAC7B;CACF"}
|
package/es/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import './common/index.mjs';
|
|
2
2
|
import './panel-component/index.mjs';
|
|
3
3
|
import './view/index.mjs';
|
|
4
|
+
import './control/index.mjs';
|
|
4
5
|
import './interface/index.mjs';
|
|
5
6
|
import './plugin/index.mjs';
|
|
6
7
|
import './use/index.mjs';
|
|
@@ -46,6 +47,8 @@ export { AppRedirectView } from './view/app-redirect-view/app-redirect-view.mjs'
|
|
|
46
47
|
export { IBizView } from './view/common/index.mjs';
|
|
47
48
|
export { TodoRedirect } from './view/todo-redirect/todo-redirect.mjs';
|
|
48
49
|
export { IBizPortalView } from './view/portal-view/index.mjs';
|
|
50
|
+
export { IBizViewLayoutPanelControl } from './control/panel/view-layout-panel/index.mjs';
|
|
51
|
+
export { IBizPanelControl } from './control/panel/panel/index.mjs';
|
|
49
52
|
export { PluginFactory } from './plugin/plugin-factory/plugin-factory.mjs';
|
|
50
53
|
export { useClickOutside } from './use/click-outside/click-outside.mjs';
|
|
51
54
|
export { useControlController } from './use/control/use-control-controller/use-control-controller.mjs';
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { ControlController, IControlController } from '@ibiz-template/runtime';
|
|
2
|
+
export interface extraOptions {
|
|
3
|
+
/**
|
|
4
|
+
* 排除监听的props里的key
|
|
5
|
+
* @author lxm
|
|
6
|
+
* @date 2023-11-22 06:11:45
|
|
7
|
+
* @type {string[]}
|
|
8
|
+
*/
|
|
9
|
+
excludePropsKeys: string[];
|
|
10
|
+
}
|
|
2
11
|
/**
|
|
3
12
|
* 初始化部件控制器
|
|
4
13
|
*
|
|
@@ -9,5 +18,5 @@ import { ControlController, IControlController } from '@ibiz-template/runtime';
|
|
|
9
18
|
* @param {() => T} fn
|
|
10
19
|
* @return {*} {T}
|
|
11
20
|
*/
|
|
12
|
-
export declare function useControlController<T extends IControlController>(fn: (...args: ConstructorParameters<typeof ControlController>) => T): T;
|
|
21
|
+
export declare function useControlController<T extends IControlController>(fn: (...args: ConstructorParameters<typeof ControlController>) => T, opts?: Partial<extraOptions>): T;
|
|
13
22
|
//# sourceMappingURL=use-control-controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-control-controller.d.ts","sourceRoot":"","sources":["../../../../src/use/control/use-control-controller/use-control-controller.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAEnB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-control-controller.d.ts","sourceRoot":"","sources":["../../../../src/use/control/use-control-controller/use-control-controller.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAEnB,MAAM,wBAAwB,CAAC;AAqEhC,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,kBAAkB,EAC/D,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,iBAAiB,CAAC,KAAK,CAAC,EACnE,IAAI,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAC3B,CAAC,CA4CH"}
|
|
@@ -12,8 +12,8 @@ function watchAndUpdateContextParams(props, control) {
|
|
|
12
12
|
}
|
|
13
13
|
);
|
|
14
14
|
}
|
|
15
|
-
function watchAndUpdateState(props, control) {
|
|
16
|
-
const excludeKeys = ["context", "params", "modelData"];
|
|
15
|
+
function watchAndUpdateState(props, control, excludeFields = []) {
|
|
16
|
+
const excludeKeys = ["context", "params", "modelData", ...excludeFields];
|
|
17
17
|
watch(
|
|
18
18
|
() => {
|
|
19
19
|
const watchProps = {};
|
|
@@ -41,7 +41,7 @@ function watchAndUpdateState(props, control) {
|
|
|
41
41
|
{ immediate: true }
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
|
-
function useControlController(fn) {
|
|
44
|
+
function useControlController(fn, opts) {
|
|
45
45
|
const ctx = useCtx();
|
|
46
46
|
const props = useProps();
|
|
47
47
|
ctx.evt.emit("onForecast", props.modelData.name);
|
|
@@ -58,7 +58,7 @@ function useControlController(fn) {
|
|
|
58
58
|
c = fn(props.modelData, props.context, props.params, ctx);
|
|
59
59
|
}
|
|
60
60
|
watchAndUpdateContextParams(props, c);
|
|
61
|
-
watchAndUpdateState(props, c);
|
|
61
|
+
watchAndUpdateState(props, c, opts == null ? void 0 : opts.excludePropsKeys);
|
|
62
62
|
c.state = reactive(c.state);
|
|
63
63
|
c.force = useForce();
|
|
64
64
|
const vue = getCurrentInstance().proxy;
|
package/lib/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require('./common/index.cjs');
|
|
4
4
|
require('./panel-component/index.cjs');
|
|
5
5
|
require('./view/index.cjs');
|
|
6
|
+
require('./control/index.cjs');
|
|
6
7
|
require('./interface/index.cjs');
|
|
7
8
|
require('./plugin/index.cjs');
|
|
8
9
|
require('./use/index.cjs');
|
|
@@ -48,6 +49,8 @@ var appRedirectView = require('./view/app-redirect-view/app-redirect-view.cjs');
|
|
|
48
49
|
var index$a = require('./view/common/index.cjs');
|
|
49
50
|
var todoRedirect = require('./view/todo-redirect/todo-redirect.cjs');
|
|
50
51
|
var index$b = require('./view/portal-view/index.cjs');
|
|
52
|
+
var index$c = require('./control/panel/view-layout-panel/index.cjs');
|
|
53
|
+
var index$d = require('./control/panel/panel/index.cjs');
|
|
51
54
|
var pluginFactory = require('./plugin/plugin-factory/plugin-factory.cjs');
|
|
52
55
|
var clickOutside = require('./use/click-outside/click-outside.cjs');
|
|
53
56
|
var useControlController = require('./use/control/use-control-controller/use-control-controller.cjs');
|
|
@@ -55,7 +58,7 @@ var event = require('./use/event/event.cjs');
|
|
|
55
58
|
var focusBlur = require('./use/focus-blur/focus-blur.cjs');
|
|
56
59
|
var namespace = require('./use/namespace/namespace.cjs');
|
|
57
60
|
var route = require('./use/route/route.cjs');
|
|
58
|
-
var index$
|
|
61
|
+
var index$e = require('./use/util/index.cjs');
|
|
59
62
|
var useViewController = require('./use/view/use-view-controller/use-view-controller.cjs');
|
|
60
63
|
var vue = require('./use/vue/vue.cjs');
|
|
61
64
|
var overlayContainer = require('./util/overlay-container/overlay-container.cjs');
|
|
@@ -69,7 +72,7 @@ var render = require('./util/render/render.cjs');
|
|
|
69
72
|
var overlayViewUtil = require('./util/overlay-view-util/overlay-view-util.cjs');
|
|
70
73
|
var appStore = require('./util/store/app-store/app-store.cjs');
|
|
71
74
|
var uiStore = require('./util/store/ui-store/ui-store.cjs');
|
|
72
|
-
var index$
|
|
75
|
+
var index$f = require('./util/store/index.cjs');
|
|
73
76
|
var common = require('./props/common.cjs');
|
|
74
77
|
var textBox = require('./props/editor/text-box.cjs');
|
|
75
78
|
var span = require('./props/editor/span.cjs');
|
|
@@ -139,6 +142,8 @@ exports.AppRedirectView = appRedirectView.AppRedirectView;
|
|
|
139
142
|
exports.IBizView = index$a.IBizView;
|
|
140
143
|
exports.TodoRedirect = todoRedirect.TodoRedirect;
|
|
141
144
|
exports.IBizPortalView = index$b.IBizPortalView;
|
|
145
|
+
exports.IBizViewLayoutPanelControl = index$c.IBizViewLayoutPanelControl;
|
|
146
|
+
exports.IBizPanelControl = index$d.IBizPanelControl;
|
|
142
147
|
exports.PluginFactory = pluginFactory.PluginFactory;
|
|
143
148
|
exports.useClickOutside = clickOutside.useClickOutside;
|
|
144
149
|
exports.useControlController = useControlController.useControlController;
|
|
@@ -147,8 +152,8 @@ exports.useFocusAndBlur = focusBlur.useFocusAndBlur;
|
|
|
147
152
|
exports.useNamespace = namespace.useNamespace;
|
|
148
153
|
exports.useRouteKey = route.useRouteKey;
|
|
149
154
|
exports.useRouterQuery = route.useRouterQuery;
|
|
150
|
-
exports.useCtx = index$
|
|
151
|
-
exports.useMobCtx = index$
|
|
155
|
+
exports.useCtx = index$e.useCtx;
|
|
156
|
+
exports.useMobCtx = index$e.useMobCtx;
|
|
152
157
|
exports.useViewController = useViewController.useViewController;
|
|
153
158
|
exports.EmptyVNode = vue.EmptyVNode;
|
|
154
159
|
exports.getOrigin = vue.getOrigin;
|
|
@@ -182,7 +187,7 @@ exports.openViewModal = overlayViewUtil.openViewModal;
|
|
|
182
187
|
exports.openViewPopover = overlayViewUtil.openViewPopover;
|
|
183
188
|
exports.useAppStore = appStore.useAppStore;
|
|
184
189
|
exports.useUIStore = uiStore.useUIStore;
|
|
185
|
-
exports.piniaInstance = index$
|
|
190
|
+
exports.piniaInstance = index$f.piniaInstance;
|
|
186
191
|
exports.RequiredProp = common.RequiredProp;
|
|
187
192
|
exports.getGridInputIpProps = textBox.getGridInputIpProps;
|
|
188
193
|
exports.getGridInputNumberProps = textBox.getGridInputNumberProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibiz-template/vue3-util",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "vue3 工具包",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@ibiz-template/cli": "0.3.2",
|
|
34
|
-
"@ibiz-template/core": "^0.
|
|
35
|
-
"@ibiz-template/runtime": "^0.
|
|
36
|
-
"@ibiz-template/theme": "^0.
|
|
37
|
-
"@ibiz/model-core": "^0.0.
|
|
34
|
+
"@ibiz-template/core": "^0.4.0",
|
|
35
|
+
"@ibiz-template/runtime": "^0.4.0",
|
|
36
|
+
"@ibiz-template/theme": "^0.4.0",
|
|
37
|
+
"@ibiz/model-core": "^0.0.21",
|
|
38
38
|
"@types/path-browserify": "^1.0.2",
|
|
39
39
|
"@types/qs": "^6.9.10",
|
|
40
40
|
"@types/systemjs": "^6.13.5",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@ibiz-template/core": "^0.3.0",
|
|
53
53
|
"@ibiz-template/runtime": "^0.3.1",
|
|
54
|
-
"@ibiz/model-core": "^0.0.
|
|
54
|
+
"@ibiz/model-core": "^0.0.21",
|
|
55
55
|
"dayjs": "^1.11.10",
|
|
56
56
|
"path-browserify": "^1.0.1",
|
|
57
57
|
"pinia": "^2.1.7",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"vue": "^3.3.4",
|
|
62
62
|
"vue-router": "^4.2.4"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "800965b3012bcaea89a53e2becbd74d5151d43f1"
|
|
65
65
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './panel';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { registerControlProvider, ControlType } from '@ibiz-template/runtime';
|
|
2
|
+
import { App } from 'vue';
|
|
3
|
+
import { PanelControl } from './panel';
|
|
4
|
+
import { PanelProvider } from './panel.provider';
|
|
5
|
+
import { withInstall } from '../../../util';
|
|
6
|
+
|
|
7
|
+
export const IBizPanelControl = withInstall(PanelControl, function (v: App) {
|
|
8
|
+
v.component(PanelControl.name, PanelControl);
|
|
9
|
+
registerControlProvider(ControlType.PANEL, () => new PanelProvider());
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export default IBizPanelControl;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IControlProvider } from '@ibiz-template/runtime';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 面板部件适配器
|
|
5
|
+
*
|
|
6
|
+
* @author lxm
|
|
7
|
+
* @date 2022-10-25 18:10:57
|
|
8
|
+
* @export
|
|
9
|
+
* @class ViewLayoutPanelProvider
|
|
10
|
+
* @implements {IControlProvider}
|
|
11
|
+
*/
|
|
12
|
+
export class PanelProvider implements IControlProvider {
|
|
13
|
+
component: string = 'IBizPanelControl';
|
|
14
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
PropType,
|
|
4
|
+
resolveComponent,
|
|
5
|
+
h,
|
|
6
|
+
VNode,
|
|
7
|
+
reactive,
|
|
8
|
+
ComponentPublicInstance,
|
|
9
|
+
watch,
|
|
10
|
+
} from 'vue';
|
|
11
|
+
import {
|
|
12
|
+
IPanel,
|
|
13
|
+
IPanelContainer,
|
|
14
|
+
IPanelField,
|
|
15
|
+
IPanelItem,
|
|
16
|
+
IPanelTabPanel,
|
|
17
|
+
} from '@ibiz/model-core';
|
|
18
|
+
import './panel.scss';
|
|
19
|
+
import {
|
|
20
|
+
IControlProvider,
|
|
21
|
+
IController,
|
|
22
|
+
PanelController,
|
|
23
|
+
} from '@ibiz-template/runtime';
|
|
24
|
+
import { useControlController, useNamespace } from '../../../use';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 绘制面板成员
|
|
28
|
+
*
|
|
29
|
+
* @author lxm
|
|
30
|
+
* @date 2023-02-07 05:58:43
|
|
31
|
+
* @param {IPanelItem} panelItem
|
|
32
|
+
* @param {PanelController} c
|
|
33
|
+
* @returns {*} {(VNode | undefined)}
|
|
34
|
+
*/
|
|
35
|
+
function renderPanelItem(
|
|
36
|
+
panelItem: IPanelItem,
|
|
37
|
+
c: PanelController,
|
|
38
|
+
ins: ComponentPublicInstance,
|
|
39
|
+
): VNode | undefined {
|
|
40
|
+
if ((panelItem as IPanelField).hidden) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const { providers, panelItems } = c;
|
|
44
|
+
const provider = providers[panelItem.id!];
|
|
45
|
+
if (!provider) {
|
|
46
|
+
return (
|
|
47
|
+
<div>
|
|
48
|
+
暂未支持的面板项: {panelItem.id} - {panelItem.itemType}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
const component = resolveComponent(provider.component);
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
let children: any;
|
|
55
|
+
// 占位类型成员填充外部对应的插槽。
|
|
56
|
+
if (panelItem.itemType === 'CTRLPOS' && ins.$slots[panelItem.id!]) {
|
|
57
|
+
children = (): VNode[] => {
|
|
58
|
+
return ins.$slots[panelItem.id!]!();
|
|
59
|
+
};
|
|
60
|
+
} else if (
|
|
61
|
+
panelItem.itemType === 'TABPANEL' &&
|
|
62
|
+
(panelItem as IPanelTabPanel).panelTabPages?.length
|
|
63
|
+
) {
|
|
64
|
+
children = (): (VNode | undefined)[] => {
|
|
65
|
+
return (panelItem as IPanelTabPanel).panelTabPages!.map(child => {
|
|
66
|
+
return renderPanelItem(child, c, ins);
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
} else if ((panelItem as IPanelContainer).panelItems?.length) {
|
|
70
|
+
children = (): (VNode | undefined)[] => {
|
|
71
|
+
return (panelItem as IPanelContainer).panelItems!.map(child => {
|
|
72
|
+
return renderPanelItem(child, c, ins);
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return h(
|
|
78
|
+
component,
|
|
79
|
+
{
|
|
80
|
+
modelData: panelItem,
|
|
81
|
+
controller: panelItems[panelItem.id!],
|
|
82
|
+
key: panelItem.id,
|
|
83
|
+
},
|
|
84
|
+
children,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 视图布局面板组件
|
|
90
|
+
*/
|
|
91
|
+
export const PanelControl = defineComponent({
|
|
92
|
+
name: 'IBizPanelControl',
|
|
93
|
+
props: {
|
|
94
|
+
modelData: {
|
|
95
|
+
type: Object as PropType<IPanel>,
|
|
96
|
+
required: true,
|
|
97
|
+
},
|
|
98
|
+
context: { type: Object as PropType<IContext>, required: true },
|
|
99
|
+
params: { type: Object as PropType<IParams>, default: () => ({}) },
|
|
100
|
+
provider: { type: Object as PropType<IControlProvider> },
|
|
101
|
+
container: { type: Object as PropType<IController> },
|
|
102
|
+
data: Object as PropType<IData>,
|
|
103
|
+
loadDefault: { type: Boolean, default: true },
|
|
104
|
+
},
|
|
105
|
+
setup(props) {
|
|
106
|
+
const c = useControlController<PanelController>(
|
|
107
|
+
(...args) => new PanelController(...args, props.container),
|
|
108
|
+
);
|
|
109
|
+
const ns = useNamespace(`control-${c.model.controlType!.toLowerCase()}`);
|
|
110
|
+
|
|
111
|
+
watch(
|
|
112
|
+
() => props.data,
|
|
113
|
+
newVal => {
|
|
114
|
+
if (newVal) {
|
|
115
|
+
c.setInputData(newVal);
|
|
116
|
+
c.load();
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
immediate: true,
|
|
121
|
+
},
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
c.evt.on('onCreated', () => {
|
|
125
|
+
// 面板成员state响应式
|
|
126
|
+
const keys = Object.keys(c.panelItems);
|
|
127
|
+
keys.forEach(key => {
|
|
128
|
+
const panelItem = c.panelItems[key];
|
|
129
|
+
panelItem.state = reactive(panelItem.state);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
return { c, ns };
|
|
134
|
+
},
|
|
135
|
+
render() {
|
|
136
|
+
const { state, model } = this.c;
|
|
137
|
+
return (
|
|
138
|
+
<iBizControlBase controller={this.c}>
|
|
139
|
+
<iBizRow class={this.ns.b('content')} layout={{ layout: 'FLEX' }}>
|
|
140
|
+
{state.isCreated &&
|
|
141
|
+
(this.$slots.default
|
|
142
|
+
? this.$slots.default({
|
|
143
|
+
panelItems: this.c.panelItems,
|
|
144
|
+
})
|
|
145
|
+
: model.rootPanelItems?.map(panelItem => {
|
|
146
|
+
const subC = this.c.panelItems[panelItem.id!];
|
|
147
|
+
// 视图布局面板的子默认布局改成flex
|
|
148
|
+
// eslint-disable-next-line no-param-reassign
|
|
149
|
+
panelItem.layoutPos!.layout = 'FLEX';
|
|
150
|
+
return (
|
|
151
|
+
<iBizCol layoutPos={panelItem.layoutPos} state={subC.state}>
|
|
152
|
+
{renderPanelItem(panelItem, this.c, this)}
|
|
153
|
+
</iBizCol>
|
|
154
|
+
);
|
|
155
|
+
}))}
|
|
156
|
+
</iBizRow>
|
|
157
|
+
</iBizControlBase>
|
|
158
|
+
);
|
|
159
|
+
},
|
|
160
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { registerControlProvider, ControlType } from '@ibiz-template/runtime';
|
|
2
|
+
import { App } from 'vue';
|
|
3
|
+
import { ViewLayoutPanelControl } from './view-layout-panel';
|
|
4
|
+
import { ViewLayoutPanelProvider } from './view-layout-panel.provider';
|
|
5
|
+
import { withInstall } from '../../../util';
|
|
6
|
+
|
|
7
|
+
export const IBizViewLayoutPanelControl = withInstall(
|
|
8
|
+
ViewLayoutPanelControl,
|
|
9
|
+
function (v: App) {
|
|
10
|
+
v.component(ViewLayoutPanelControl.name, ViewLayoutPanelControl);
|
|
11
|
+
registerControlProvider(
|
|
12
|
+
ControlType.VIEW_LAYOUT_PANEL,
|
|
13
|
+
() => new ViewLayoutPanelProvider(),
|
|
14
|
+
);
|
|
15
|
+
},
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export default IBizViewLayoutPanelControl;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IControlProvider } from '@ibiz-template/runtime';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 视图布局面板部件适配器
|
|
5
|
+
*
|
|
6
|
+
* @author lxm
|
|
7
|
+
* @date 2022-10-25 18:10:57
|
|
8
|
+
* @export
|
|
9
|
+
* @class ViewLayoutPanelProvider
|
|
10
|
+
* @implements {IControlProvider}
|
|
11
|
+
*/
|
|
12
|
+
export class ViewLayoutPanelProvider implements IControlProvider {
|
|
13
|
+
component: string = 'IBizViewLayoutPanelControl';
|
|
14
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
PropType,
|
|
4
|
+
resolveComponent,
|
|
5
|
+
h,
|
|
6
|
+
VNode,
|
|
7
|
+
reactive,
|
|
8
|
+
watch,
|
|
9
|
+
provide,
|
|
10
|
+
} from 'vue';
|
|
11
|
+
import {
|
|
12
|
+
IPanelContainer,
|
|
13
|
+
IPanelField,
|
|
14
|
+
IPanelItem,
|
|
15
|
+
IPanelTabPanel,
|
|
16
|
+
IViewLayoutPanel,
|
|
17
|
+
} from '@ibiz/model-core';
|
|
18
|
+
import './view-layout-panel.scss';
|
|
19
|
+
import {
|
|
20
|
+
IController,
|
|
21
|
+
IControlProvider,
|
|
22
|
+
IPanelItemController,
|
|
23
|
+
IPanelItemProvider,
|
|
24
|
+
isDataContainer,
|
|
25
|
+
ViewLayoutPanelController,
|
|
26
|
+
} from '@ibiz-template/runtime';
|
|
27
|
+
import { useControlController, useNamespace } from '../../../use';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 视图布局面板组件
|
|
31
|
+
*/
|
|
32
|
+
export const ViewLayoutPanelControl = defineComponent({
|
|
33
|
+
name: 'IBizViewLayoutPanelControl',
|
|
34
|
+
props: {
|
|
35
|
+
modelData: {
|
|
36
|
+
type: Object as PropType<IViewLayoutPanel>,
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
context: { type: Object as PropType<IContext>, required: true },
|
|
40
|
+
params: { type: Object as PropType<IParams>, default: () => ({}) },
|
|
41
|
+
provider: { type: Object as PropType<IControlProvider> },
|
|
42
|
+
container: { type: Object as PropType<IController> },
|
|
43
|
+
data: Object as PropType<IData>,
|
|
44
|
+
},
|
|
45
|
+
setup(props, { slots }) {
|
|
46
|
+
const c = useControlController(
|
|
47
|
+
(...args) => new ViewLayoutPanelController(...args, props.container),
|
|
48
|
+
);
|
|
49
|
+
const ns = useNamespace(`control-${c.model.controlType!.toLowerCase()}`);
|
|
50
|
+
|
|
51
|
+
watch(
|
|
52
|
+
() => props.data,
|
|
53
|
+
newVal => {
|
|
54
|
+
if (newVal) {
|
|
55
|
+
c.setInputData(newVal);
|
|
56
|
+
c.load();
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
immediate: true,
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
c.evt.on('onCreated', () => {
|
|
65
|
+
// 面板成员state响应式
|
|
66
|
+
const keys = Object.keys(c.panelItems);
|
|
67
|
+
keys.forEach(key => {
|
|
68
|
+
const panelItem = c.panelItems[key];
|
|
69
|
+
panelItem.state = reactive(panelItem.state);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 绘制面板成员
|
|
75
|
+
* @author lxm
|
|
76
|
+
* @date 2023-08-25 04:09:07
|
|
77
|
+
* @param {IPanelItem} panelItem
|
|
78
|
+
* @return {*} {(VNode | null)}
|
|
79
|
+
*/
|
|
80
|
+
const renderPanelItem = (
|
|
81
|
+
panelItem: IPanelItem,
|
|
82
|
+
options?: {
|
|
83
|
+
providers: {
|
|
84
|
+
[key: string]: IPanelItemProvider;
|
|
85
|
+
};
|
|
86
|
+
panelItems: {
|
|
87
|
+
[key: string]: IPanelItemController;
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
): VNode | null => {
|
|
91
|
+
if ((panelItem as IPanelField).hidden) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
const { providers, panelItems } = options || c;
|
|
95
|
+
const provider = providers[panelItem.id!];
|
|
96
|
+
if (!provider) {
|
|
97
|
+
return (
|
|
98
|
+
<div>
|
|
99
|
+
暂未支持的面板项: {panelItem.id} - {panelItem.itemType}
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const component = resolveComponent(provider.component);
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
|
+
let children: any;
|
|
106
|
+
// 占位类型成员填充外部对应的插槽。
|
|
107
|
+
if (panelItem.itemType === 'CTRLPOS' && slots[panelItem.id!]) {
|
|
108
|
+
children = () => {
|
|
109
|
+
return slots[panelItem.id!]!();
|
|
110
|
+
};
|
|
111
|
+
} else if (
|
|
112
|
+
panelItem.itemType === 'TABPANEL' &&
|
|
113
|
+
(panelItem as IPanelTabPanel).panelTabPages?.length
|
|
114
|
+
) {
|
|
115
|
+
children = () => {
|
|
116
|
+
return (panelItem as IPanelTabPanel).panelTabPages!.map(child => {
|
|
117
|
+
return renderPanelItem(child, options);
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
} else if (isDataContainer(panelItem)) {
|
|
121
|
+
// 单项数据容器,多项数据容器不给子
|
|
122
|
+
children = undefined;
|
|
123
|
+
} else if ((panelItem as IPanelContainer).panelItems?.length) {
|
|
124
|
+
children = () => {
|
|
125
|
+
return (panelItem as IPanelContainer).panelItems!.map(child => {
|
|
126
|
+
return renderPanelItem(child, options);
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return h(
|
|
132
|
+
component,
|
|
133
|
+
{
|
|
134
|
+
modelData: panelItem,
|
|
135
|
+
controller: panelItems[panelItem.id!],
|
|
136
|
+
key: panelItem.id,
|
|
137
|
+
},
|
|
138
|
+
children,
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
provide('renderPanelItem', renderPanelItem);
|
|
143
|
+
|
|
144
|
+
return { c, ns, renderPanelItem };
|
|
145
|
+
},
|
|
146
|
+
render() {
|
|
147
|
+
const { state, model } = this.c;
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<iBizControlBase controller={this.c}>
|
|
151
|
+
<iBizRow class={this.ns.b('content')} layout={{ layout: 'FLEX' }}>
|
|
152
|
+
{state.isCreated &&
|
|
153
|
+
(this.$slots.default
|
|
154
|
+
? this.$slots.default({
|
|
155
|
+
panelItems: this.c.panelItems,
|
|
156
|
+
})
|
|
157
|
+
: model.rootPanelItems?.map(panelItem => {
|
|
158
|
+
const subC = this.c.panelItems[panelItem.id!];
|
|
159
|
+
// 视图布局面板的子默认布局改成flex
|
|
160
|
+
// eslint-disable-next-line no-param-reassign
|
|
161
|
+
panelItem.layoutPos!.layout = 'FLEX';
|
|
162
|
+
return (
|
|
163
|
+
<iBizCol layoutPos={panelItem.layoutPos} state={subC.state}>
|
|
164
|
+
{this.renderPanelItem(panelItem)}
|
|
165
|
+
</iBizCol>
|
|
166
|
+
);
|
|
167
|
+
}))}
|
|
168
|
+
</iBizRow>
|
|
169
|
+
</iBizControlBase>
|
|
170
|
+
);
|
|
171
|
+
},
|
|
172
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -38,8 +38,12 @@ function watchAndUpdateContextParams(
|
|
|
38
38
|
* @param {IData} props
|
|
39
39
|
* @param {IControlController} control
|
|
40
40
|
*/
|
|
41
|
-
function watchAndUpdateState(
|
|
42
|
-
|
|
41
|
+
function watchAndUpdateState(
|
|
42
|
+
props: IData,
|
|
43
|
+
control: IControlController,
|
|
44
|
+
excludeFields: string[] = [],
|
|
45
|
+
): void {
|
|
46
|
+
const excludeKeys = ['context', 'params', 'modelData', ...excludeFields];
|
|
43
47
|
watch(
|
|
44
48
|
() => {
|
|
45
49
|
const watchProps: IData = {};
|
|
@@ -68,6 +72,16 @@ function watchAndUpdateState(props: IData, control: IControlController): void {
|
|
|
68
72
|
);
|
|
69
73
|
}
|
|
70
74
|
|
|
75
|
+
export interface extraOptions {
|
|
76
|
+
/**
|
|
77
|
+
* 排除监听的props里的key
|
|
78
|
+
* @author lxm
|
|
79
|
+
* @date 2023-11-22 06:11:45
|
|
80
|
+
* @type {string[]}
|
|
81
|
+
*/
|
|
82
|
+
excludePropsKeys: string[];
|
|
83
|
+
}
|
|
84
|
+
|
|
71
85
|
/**
|
|
72
86
|
* 初始化部件控制器
|
|
73
87
|
*
|
|
@@ -80,6 +94,7 @@ function watchAndUpdateState(props: IData, control: IControlController): void {
|
|
|
80
94
|
*/
|
|
81
95
|
export function useControlController<T extends IControlController>(
|
|
82
96
|
fn: (...args: ConstructorParameters<typeof ControlController>) => T,
|
|
97
|
+
opts?: Partial<extraOptions>,
|
|
83
98
|
): T {
|
|
84
99
|
// 获取上层组件的ctx
|
|
85
100
|
const ctx = useCtx();
|
|
@@ -104,7 +119,7 @@ export function useControlController<T extends IControlController>(
|
|
|
104
119
|
}
|
|
105
120
|
|
|
106
121
|
watchAndUpdateContextParams(props, c);
|
|
107
|
-
watchAndUpdateState(props, c);
|
|
122
|
+
watchAndUpdateState(props, c, opts?.excludePropsKeys);
|
|
108
123
|
|
|
109
124
|
c.state = reactive(c.state);
|
|
110
125
|
|