@oinone/kunlun-vue-admin-base 6.2.11 → 6.2.13

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 (30) hide show
  1. package/dist/oinone-kunlun-vue-admin-base.css +1 -1
  2. package/dist/oinone-kunlun-vue-admin-base.esm.js +1149 -1086
  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/permission/permission/field/ActionPermissionWidget.d.ts +1 -1
  9. package/dist/types/src/spi/LayoutManager.d.ts +20 -17
  10. package/dist/types/src/spi/MaskManager.d.ts +33 -5
  11. package/dist/types/src/tags/context/runtime-context-helper.d.ts +1 -0
  12. package/dist/types/src/typing/tree.d.ts +5 -0
  13. package/dist/types/src/view/tree/AbstractTreeElementWidget.d.ts +2 -0
  14. package/dist/types/src/view/tree/DefaultTree.vue.d.ts +15 -3
  15. package/package.json +8 -8
  16. package/src/basic/element/BaseElementViewWidget.ts +11 -2
  17. package/src/basic/form-item/DefaultFormItem.vue +1 -1
  18. package/src/container/collapse/DefaultCollapse.vue +7 -3
  19. package/src/container/collapse/DefaultCollapseWidget.ts +19 -1
  20. package/src/main-view/DefaultMetadataMainViewWidget.ts +7 -24
  21. package/src/permission/permission/field/ActionPermissionWidget.ts +3 -1
  22. package/src/spi/LayoutManager.ts +20 -17
  23. package/src/spi/MaskManager.ts +36 -6
  24. package/src/tags/context/runtime-context-helper.ts +11 -9
  25. package/src/typing/tree.ts +6 -0
  26. package/src/util/tree-utils.ts +24 -17
  27. package/src/view/tree/AbstractTreeElementWidget.ts +15 -1
  28. package/src/view/tree/DefaultTree.vue +19 -18
  29. package/src/view/tree/TreeWidget.ts +9 -2
  30. package/src/view/tree/style/index.scss +0 -2
@@ -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 {