@oinone/kunlun-vue-admin-base 6.2.11 → 6.3.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.
Files changed (34) hide show
  1. package/dist/oinone-kunlun-vue-admin-base.css +1 -1
  2. package/dist/oinone-kunlun-vue-admin-base.esm.js +1163 -1090
  3. package/dist/oinone-kunlun-vue-admin-base.scss +1 -1
  4. package/dist/types/src/basic/form-item/DefaultFormItem.vue.d.ts +7 -6
  5. package/dist/types/src/container/collapse/DefaultCollapse.vue.d.ts +6 -0
  6. package/dist/types/src/container/collapse/DefaultCollapseWidget.d.ts +5 -1
  7. package/dist/types/src/field/form/float/Plat.vue.d.ts +2 -2
  8. package/dist/types/src/field/form/html/expressionRichtext/ExpressionRichText.vue.d.ts +7 -0
  9. package/dist/types/src/permission/permission/field/ActionPermissionWidget.d.ts +1 -1
  10. package/dist/types/src/spi/LayoutManager.d.ts +20 -17
  11. package/dist/types/src/spi/MaskManager.d.ts +33 -5
  12. package/dist/types/src/tags/context/runtime-context-helper.d.ts +1 -0
  13. package/dist/types/src/typing/tree.d.ts +5 -0
  14. package/dist/types/src/view/tree/AbstractTreeElementWidget.d.ts +2 -0
  15. package/dist/types/src/view/tree/DefaultTree.vue.d.ts +15 -3
  16. package/package.json +22 -22
  17. package/src/basic/element/BaseElementViewWidget.ts +11 -2
  18. package/src/basic/form-item/DefaultFormItem.vue +1 -1
  19. package/src/basic/table/BaseTableWidget.ts +5 -2
  20. package/src/container/collapse/DefaultCollapse.vue +7 -3
  21. package/src/container/collapse/DefaultCollapseWidget.ts +19 -1
  22. package/src/field/eip/form/work-scope/service.ts +4 -2
  23. package/src/field/form/html/expressionRichtext/ExpressionRichText.vue +17 -7
  24. package/src/main-view/DefaultMetadataMainViewWidget.ts +7 -24
  25. package/src/permission/permission/field/ActionPermissionWidget.ts +3 -1
  26. package/src/spi/LayoutManager.ts +20 -17
  27. package/src/spi/MaskManager.ts +36 -6
  28. package/src/tags/context/runtime-context-helper.ts +11 -9
  29. package/src/typing/tree.ts +6 -0
  30. package/src/util/tree-utils.ts +24 -17
  31. package/src/view/tree/AbstractTreeElementWidget.ts +15 -1
  32. package/src/view/tree/DefaultTree.vue +19 -18
  33. package/src/view/tree/TreeWidget.ts +9 -2
  34. package/src/view/tree/style/index.scss +0 -2
@@ -1,4 +1,4 @@
1
- import { DslDefinition, XMLParse } from '@oinone/kunlun-dsl';
1
+ import { DslDefinition } from '@oinone/kunlun-dsl';
2
2
  import {
3
3
  $systemMajorConfig,
4
4
  CurrentLanguage,
@@ -22,21 +22,20 @@ import {
22
22
  import { ViewActionTarget } from '@oinone/kunlun-meta';
23
23
  import { isNotPermission, setSessionPath, useSessionPath } from '@oinone/kunlun-request';
24
24
  import { useMatched } from '@oinone/kunlun-router';
25
- import { CallChaining, debugConsole } from '@oinone/kunlun-shared';
25
+ import { CallChaining } from '@oinone/kunlun-shared';
26
26
  import { distinctUntilChanged, Subscription } from '@oinone/kunlun-state';
27
27
  import { DEFAULT_PREFIX } from '@oinone/kunlun-theme';
28
28
 
29
29
  import {
30
30
  emptyHomepageModelName,
31
- getDefaultMaskTemplate,
32
31
  getUnauthorizedAction,
33
- maskTemplateEdit,
34
32
  MenuService,
35
33
  ModuleService,
36
34
  replaceStanderMainView,
37
35
  RuntimeMenu,
38
36
  TopBarService,
39
- unauthorizedActionName, urlHomepageModelName
37
+ unauthorizedActionName,
38
+ urlHomepageModelName
40
39
  } from '@oinone/kunlun-vue-admin-layout';
41
40
  import { OioNotification } from '@oinone/kunlun-vue-ui-antd';
42
41
  import { ZH_CN_CODE } from '@oinone/kunlun-vue-ui-common';
@@ -44,7 +43,7 @@ import { Widget } from '@oinone/kunlun-vue-widget';
44
43
  import { nextTick, VNode } from 'vue';
45
44
  import { MetadataViewWidget } from '../basic';
46
45
  import { TeleportWidget } from '../components/teleport';
47
- import { MaskManager } from '../spi';
46
+ import { seekViewMask } from '../tags';
48
47
  import { TranslateBox } from '../view/translate';
49
48
  import DefaultMetadataMainView from './DefaultMetadataMainView.vue';
50
49
  import { MetadataMainViewLifecycle } from './lifecycle';
@@ -355,24 +354,8 @@ export class DefaultMetadataMainViewWidget extends MetadataViewWidget {
355
354
  newPage: ViewActionQueryParameter
356
355
  ): Promise<void> {
357
356
  const { module: moduleName, model, action } = newPage;
358
- let maskTemplate: string = MaskManager.selector({
359
- module: viewAction.moduleDefinition?.module || viewAction.resModuleDefinition?.module,
360
- moduleName: viewAction.moduleDefinition?.name || viewAction.resModuleDefinition?.name || moduleName,
361
- model,
362
- actionName: action
363
- })!;
364
- if (!maskTemplate) {
365
- maskTemplate = viewAction.resMaskDefinition?.template as string;
366
- if (maskTemplate) {
367
- debugConsole.log('使用后端mask', maskTemplate);
368
- }
369
- }
370
- let finalMaskTemplate: DslDefinition;
371
- if (maskTemplate) {
372
- finalMaskTemplate = maskTemplateEdit({ isDefault: false }, XMLParse.INSTANCE.parse(maskTemplate));
373
- } else {
374
- finalMaskTemplate = getDefaultMaskTemplate();
375
- }
357
+
358
+ let finalMaskTemplate: DslDefinition = seekViewMask(viewAction, moduleName);
376
359
 
377
360
  /**
378
361
  * 当前用户没有该视图没有权限
@@ -57,7 +57,9 @@ let counter = 0;
57
57
  @SPI.ClassFactory(FormFieldWidget.Token({ widget: 'action-permission' }))
58
58
  export class ActionPermissionWidget extends FormFieldWidget<unknown, RuntimeO2MField> {
59
59
  @Widget.Reactive()
60
- private class = 'oio-tree';
60
+ public get class() {
61
+ return 'oio-tree';
62
+ }
61
63
 
62
64
  public initialize(props) {
63
65
  super.initialize(props);
@@ -11,31 +11,31 @@ export interface LayoutRegisterOptions extends SPIOptions {
11
11
  /**
12
12
  * 视图类型
13
13
  */
14
- viewType: ViewType;
14
+ viewType: ViewType | ViewType[];
15
15
  /**
16
- * 视图模型所在模块编码,一般是驼峰风格的英文 designerCommon
16
+ * 视图模型所在模块编码,一般是下划线风格的英文 designer_common
17
17
  */
18
- module?: string;
18
+ module?: string | string[];
19
19
  /**
20
- * 视图模型所在模块名称,一般是下划线风格的英文 designer_common
20
+ * 视图模型所在模块名称,一般是驼峰风格的英文 designerCommon
21
21
  */
22
- moduleName?: string;
22
+ moduleName?: string | string[];
23
23
  /**
24
- * 布局名称,对应viewActionQuery.load.resView.baseLayoutName
24
+ * 布局名称,对应 viewActionQuery.load.resView.baseLayoutName
25
25
  */
26
- layoutName?: string;
26
+ layoutName?: string | string[];
27
27
  /**
28
28
  * 视图的模型编码
29
29
  */
30
- model?: string;
30
+ model?: string | string[];
31
31
  /**
32
32
  * 视图的模型名称
33
33
  */
34
- modelName?: string;
34
+ modelName?: string | string[];
35
35
  /**
36
36
  * 视图的名称
37
37
  */
38
- viewName?: string;
38
+ viewName?: string | string[];
39
39
  /**
40
40
  * 是否为内嵌视图(子视图特有),表单页内有个o2m的子表格,该表格的inline为true
41
41
  */
@@ -48,15 +48,15 @@ export interface LayoutRegisterOptions extends SPIOptions {
48
48
  /**
49
49
  * 模型字段类型(子视图特有)
50
50
  */
51
- ttype?: ModelFieldType;
51
+ ttype?: ModelFieldType | ModelFieldType[];
52
52
  /**
53
53
  * 关联模型字段类型(子视图特有)
54
54
  */
55
- relatedTtype?: ModelFieldType;
55
+ relatedTtype?: ModelFieldType | ModelFieldType[];
56
56
  /**
57
57
  * 字段(子视图特有)
58
58
  */
59
- field?: string;
59
+ field?: string | string[];
60
60
 
61
61
  // endregion
62
62
 
@@ -65,11 +65,11 @@ export interface LayoutRegisterOptions extends SPIOptions {
65
65
  /**
66
66
  * 动作名称
67
67
  */
68
- actionName?: string;
68
+ actionName?: string | string[];
69
69
  /**
70
70
  * 动作使用的组件名称
71
71
  */
72
- actionWidget?: string;
72
+ actionWidget?: string | string[];
73
73
 
74
74
  // endregion
75
75
  }
@@ -115,9 +115,12 @@ export class LayoutManager {
115
115
  }
116
116
  }
117
117
 
118
+ /**
119
+ * @deprecated please use {@link LayoutRegisterOptions}
120
+ */
118
121
  export type ILayoutOption = LayoutRegisterOptions;
119
122
 
120
- export function registerLayout(layoutTpl: string, layoutOption: ILayoutOption): boolean {
123
+ export function registerLayout(layoutTpl: string, layoutOption: LayoutRegisterOptions): boolean {
121
124
  if (!layoutOption.viewType) {
122
125
  console.warn('viewType is blank');
123
126
  return false;
@@ -129,6 +132,6 @@ export function registerLayout(layoutTpl: string, layoutOption: ILayoutOption):
129
132
  return LayoutManager.register(layoutOption, layoutTpl);
130
133
  }
131
134
 
132
- export function generatorLayout(layoutOption: ILayoutOption): DslDefinition | undefined {
135
+ export function generatorLayout(layoutOption: LayoutRegisterOptions): DslDefinition | undefined {
133
136
  return LayoutManager.selector(layoutOption);
134
137
  }
@@ -1,13 +1,40 @@
1
+ import { ViewType } from '@oinone/kunlun-meta';
1
2
  import { SPIFactory, SPIOperator, SPIOptions, SPISingleSelector, SPITokenFactory } from '@oinone/kunlun-spi';
2
3
 
3
4
  export interface MaskRegisterOptions extends SPIOptions {
4
- module?: string;
5
- moduleName?: string;
6
- model?: string;
5
+ /**
6
+ * 视图类型
7
+ */
8
+ viewType?: ViewType | ViewType[];
9
+ /**
10
+ * 模块编码
11
+ */
12
+ module?: string | string[];
13
+ /**
14
+ * 模块名称
15
+ */
16
+ moduleName?: string | string[];
17
+ /**
18
+ * 模型编码
19
+ */
20
+ model?: string | string[];
21
+ /**
22
+ * 模型名称
23
+ */
24
+ modelName?: string | string[];
25
+ /**
26
+ * 视图名称
27
+ */
28
+ viewName?: string | string[];
29
+ /**
30
+ * 动作名称
31
+ */
7
32
  actionName?: string | string[];
8
33
  }
9
34
 
10
- @SPIFactory.Storage(['module', 'moduleName', 'model', 'actionName'], { key: Symbol('MaskTpl') })
35
+ @SPIFactory.Storage(['viewType', 'module', 'moduleName', 'model', 'modelName', 'viewName', 'actionName'], {
36
+ key: Symbol('MaskTpl')
37
+ })
11
38
  export class MaskManager {
12
39
  private static Token: SPITokenFactory<MaskRegisterOptions>;
13
40
 
@@ -26,9 +53,12 @@ export class MaskManager {
26
53
  }
27
54
  }
28
55
 
56
+ /**
57
+ * @deprecated please use {@link MaskRegisterOptions}
58
+ */
29
59
  export type IMaskOption = MaskRegisterOptions;
30
60
 
31
- export function registerMask(maskTpl: string, maskOption?: IMaskOption) {
61
+ export function registerMask(maskTpl: string, maskOption?: MaskRegisterOptions) {
32
62
  if (!maskTpl) {
33
63
  console.warn('maskTpl is blank');
34
64
  return false;
@@ -36,6 +66,6 @@ export function registerMask(maskTpl: string, maskOption?: IMaskOption) {
36
66
  return MaskManager.register(maskOption || {}, maskTpl);
37
67
  }
38
68
 
39
- export function generatorMask(maskOption?: IMaskOption): string | undefined {
69
+ export function generatorMask(maskOption?: MaskRegisterOptions): string | undefined {
40
70
  return MaskManager.selector(maskOption || {});
41
71
  }
@@ -19,17 +19,19 @@ import { SPI } from '@oinone/kunlun-spi';
19
19
  import { getDefaultMaskTemplate, maskTemplateEdit } from '@oinone/kunlun-vue-admin-layout';
20
20
  import { isNil, isPlainObject, isString } from 'lodash-es';
21
21
  import { LayoutManager, LayoutRegisterOptions, MaskManager } from '../../spi';
22
- import { useInjectMetaContext } from './context';
23
22
  import { ActiveLayoutEffectOpt } from './active';
23
+ import { useInjectMetaContext } from './context';
24
24
 
25
- function seekViewMask(viewAction: RuntimeViewAction, moduleName?: string): DslDefinition {
26
- let maskTemplate: string =
27
- MaskManager.selector({
28
- module: viewAction.moduleDefinition?.module || viewAction.resModuleDefinition?.module,
29
- moduleName: viewAction.moduleDefinition?.name || viewAction.resModuleDefinition?.name || moduleName,
30
- model: viewAction.model,
31
- actionName: viewAction.name
32
- })!;
25
+ export function seekViewMask(viewAction: RuntimeViewAction, moduleName?: string): DslDefinition {
26
+ let maskTemplate: string | undefined = MaskManager.selector({
27
+ viewType: viewAction.resViewType || viewAction.viewType,
28
+ module: viewAction.moduleDefinition?.module || viewAction.resModuleDefinition?.module,
29
+ moduleName: viewAction.moduleDefinition?.name || viewAction.resModuleDefinition?.name || moduleName,
30
+ model: viewAction.modelDefinition?.model || viewAction.model,
31
+ modelName: viewAction.modelDefinition?.name || viewAction.modelName,
32
+ viewName: viewAction.resViewName || viewAction.viewName,
33
+ actionName: viewAction.name
34
+ });
33
35
  if (!maskTemplate) {
34
36
  maskTemplate = viewAction.resMaskDefinition?.template as string;
35
37
  if (maskTemplate) {
@@ -1,3 +1,4 @@
1
+ import { DslDefinition } from '@oinone/kunlun-dsl';
1
2
  import { ActiveRecord, Pagination, RefreshCallChainingParameters } from '@oinone/kunlun-engine';
2
3
  import { TreeNode } from '@oinone/kunlun-shared';
3
4
  import { Slot } from 'vue';
@@ -64,6 +65,11 @@ export interface TreeNodeMetadata {
64
65
  */
65
66
  rowActionsSlot?: Slot;
66
67
 
68
+ /**
69
+ * 当配置了 nodes 节点时,根元数据节点具有该属性
70
+ */
71
+ nodes?: DslDefinition;
72
+
67
73
  /**
68
74
  * 图标 iconfont/https
69
75
  */
@@ -44,6 +44,7 @@ export class TreeUtils {
44
44
  }
45
45
  let root: TreeNodeMetadata | undefined;
46
46
  let parent: TreeNodeMetadata | undefined;
47
+ let nodes: DslDefinition | undefined;
47
48
  const appendChild = (widget: DslDefinition) => {
48
49
  const { model, title, label, labelFields, searchFields, references, selfReferences, filter, search, icon } =
49
50
  widget;
@@ -80,28 +81,34 @@ export class TreeUtils {
80
81
  }
81
82
  parent = metadata;
82
83
  };
83
- for (const widget of widgets) {
84
- const appendWidget = (targetWidget: DslDefinition) => {
85
- if (targetWidget.dslNodeType === TreeUtils.DSL_NODES_TYPE) {
86
- const nodesWidgets = targetWidget.widgets;
87
- if (nodesWidgets) {
88
- for (const nodeWidget of nodesWidgets) {
89
- appendChild(nodeWidget);
90
- }
84
+ const appendWidget = (targetWidget: DslDefinition) => {
85
+ if (targetWidget.dslNodeType === TreeUtils.DSL_NODES_TYPE) {
86
+ const nodesWidgets = targetWidget.widgets;
87
+ if (nodesWidgets) {
88
+ if (!nodes) {
89
+ nodes = targetWidget;
91
90
  }
92
- } else if (targetWidget.dslNodeType === TreeUtils.DSL_NODE_TYPE) {
93
- appendChild(targetWidget);
94
- } else if (DslDefinitionHelper.isTemplate(targetWidget) && targetWidget.slot === DEFAULT_SLOT_NAME) {
95
- const nodesWidgets = targetWidget.widgets;
96
- if (nodesWidgets) {
97
- for (const nodeWidget of nodesWidgets) {
98
- appendWidget(nodeWidget);
99
- }
91
+ for (const nodeWidget of nodesWidgets) {
92
+ appendChild(nodeWidget);
100
93
  }
101
94
  }
102
- };
95
+ } else if (targetWidget.dslNodeType === TreeUtils.DSL_NODE_TYPE) {
96
+ appendChild(targetWidget);
97
+ } else if (DslDefinitionHelper.isTemplate(targetWidget) && targetWidget.slot === DEFAULT_SLOT_NAME) {
98
+ const nodesWidgets = targetWidget.widgets;
99
+ if (nodesWidgets) {
100
+ for (const nodeWidget of nodesWidgets) {
101
+ appendWidget(nodeWidget);
102
+ }
103
+ }
104
+ }
105
+ };
106
+ for (const widget of widgets) {
103
107
  appendWidget(widget);
104
108
  }
109
+ if (root) {
110
+ root.nodes = nodes;
111
+ }
105
112
  return root;
106
113
  }
107
114
 
@@ -2,7 +2,7 @@ import { DEFAULT_SLOT_NAME } from '@oinone/kunlun-dsl';
2
2
  import { ExpressionRunParam } from '@oinone/kunlun-expression';
3
3
  import { ViewType } from '@oinone/kunlun-meta';
4
4
  import { BooleanHelper, ReturnPromise, uniqueKeyGenerator } from '@oinone/kunlun-shared';
5
- import { OioTreeNode } from '@oinone/kunlun-vue-ui-common';
5
+ import { OioTreeNode, StyleHelper } from '@oinone/kunlun-vue-ui-common';
6
6
  import { Widget } from '@oinone/kunlun-vue-widget';
7
7
  import { TreeNodeResponseBody, TreeService } from '../../service';
8
8
  import { TreeData, TreeNodeMetadata } from '../../typing';
@@ -83,6 +83,20 @@ export abstract class AbstractTreeElementWidget<V extends TreeData = TreeData> e
83
83
  return this.getDsl().searchRemote ?? true;
84
84
  }
85
85
 
86
+ @Widget.Reactive()
87
+ public get viewModel(): string | undefined {
88
+ return this.model.model;
89
+ }
90
+
91
+ @Widget.Reactive()
92
+ public get width(): string | undefined {
93
+ let { width } = this.getDsl();
94
+ if (width == null) {
95
+ width = this.treeDefinition?.nodes?.width;
96
+ }
97
+ return StyleHelper.px(width);
98
+ }
99
+
86
100
  public initialize(props) {
87
101
  if (!props.slotNames) {
88
102
  props.slotNames = [DEFAULT_SLOT_NAME, CONTENT_SLOT_NAME, 'rowActions'];
@@ -44,9 +44,15 @@ export default defineComponent({
44
44
  viewType: {
45
45
  type: String as PropType<ViewType>
46
46
  },
47
+ viewModel: {
48
+ type: String
49
+ },
47
50
  template: {
48
51
  type: Object as PropType<DslDefinition>
49
52
  },
53
+ width: {
54
+ type: String
55
+ },
50
56
  autoExpandParent: {
51
57
  type: Boolean
52
58
  },
@@ -82,23 +88,11 @@ export default defineComponent({
82
88
  return treeNodeList;
83
89
  });
84
90
 
85
- const isSameModel = computed(() => {
86
- let model: string | undefined;
87
- let metadata = props.rootNode?.value?.metadata;
88
- while (metadata) {
89
- const nodeModel = metadata.model;
90
- if (nodeModel) {
91
- if (model) {
92
- if (model !== nodeModel) {
93
- return false;
94
- }
95
- } else {
96
- model = nodeModel;
97
- }
98
- }
99
- metadata = metadata.child;
91
+ const width = computed(() => {
92
+ if (props.width == null) {
93
+ return '234px';
100
94
  }
101
- return !!model;
95
+ return props.width;
102
96
  });
103
97
 
104
98
  const internalExpandedKeys = ref<string[]>([]);
@@ -182,7 +176,7 @@ export default defineComponent({
182
176
 
183
177
  return {
184
178
  treeData,
185
- isSameModel,
179
+ width,
186
180
 
187
181
  internalExpandedKeys,
188
182
  selectedKeys,
@@ -196,6 +190,7 @@ export default defineComponent({
196
190
  };
197
191
  },
198
192
  render() {
193
+ const { viewModel } = this;
199
194
  const treeComponent = createVNode(
200
195
  OioTree,
201
196
  {
@@ -241,7 +236,7 @@ export default defineComponent({
241
236
  ];
242
237
  }
243
238
  let rowActionsSlot = dataRef.value?.metadata?.rowActionsSlot;
244
- if (!rowActionsSlot && this.isSameModel) {
239
+ if (!rowActionsSlot && dataRef.value?.metadata?.model === viewModel) {
245
240
  rowActionsSlot = this.$slots.rowActions;
246
241
  }
247
242
  if (rowActionsSlot) {
@@ -331,3 +326,9 @@ export default defineComponent({
331
326
  }
332
327
  });
333
328
  </script>
329
+ <style lang="scss">
330
+ .default-tree.default-tree-content-wrapper .oio-tree-wrapper {
331
+ width: v-bind('width');
332
+ flex-basis: v-bind('width');
333
+ }
334
+ </style>
@@ -1,4 +1,4 @@
1
- import { ActiveRecord } from '@oinone/kunlun-engine';
1
+ import { ActiveRecord, ExperimentalConfigManager } from '@oinone/kunlun-engine';
2
2
  import { ViewType } from '@oinone/kunlun-meta';
3
3
  import { SPI } from '@oinone/kunlun-spi';
4
4
  import { OioTreeNode } from '@oinone/kunlun-vue-ui-common';
@@ -18,7 +18,14 @@ export class TreeWidget extends AbstractTreeElementWidget {
18
18
  protected showContent = true;
19
19
 
20
20
  protected async onNodeSelected(node: OioTreeNode<TreeData>) {
21
- await this.onSelectedForQuery(node);
21
+ if (ExperimentalConfigManager.treeWidgetNext()) {
22
+ const nodeModel = node.value.metadata?.model;
23
+ if (nodeModel === this.model.model) {
24
+ await this.onSelectedForQuery(node);
25
+ }
26
+ } else {
27
+ await this.onSelectedForQuery(node);
28
+ }
22
29
  }
23
30
 
24
31
  protected async onNodeUnselected(node: OioTreeNode<TreeData>) {
@@ -92,8 +92,6 @@
92
92
 
93
93
  .oio-tree-wrapper {
94
94
  position: relative;
95
- width: 234px;
96
- flex-basis: 234px;
97
95
  }
98
96
 
99
97
  .default-tree-content {