sh-view 2.0.8 → 2.2.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 (129) hide show
  1. package/package.json +9 -13
  2. package/packages/components/global-components/sh-alert/index.vue +175 -173
  3. package/packages/components/global-components/sh-badge/index.vue +57 -43
  4. package/packages/components/global-components/sh-card/index.vue +24 -16
  5. package/packages/components/global-components/sh-code-editor/index.vue +250 -260
  6. package/packages/components/global-components/sh-col/index.vue +44 -36
  7. package/packages/components/global-components/sh-corner/index.vue +230 -228
  8. package/packages/components/global-components/sh-count-to/index.vue +60 -51
  9. package/packages/components/global-components/sh-drawer/index.vue +216 -183
  10. package/packages/components/global-components/sh-drawer/scrollbar.js +44 -42
  11. package/packages/components/global-components/sh-empty/index.vue +0 -1
  12. package/packages/components/global-components/sh-form/form.vue +110 -0
  13. package/packages/components/global-components/sh-form/js/props.js +76 -63
  14. package/packages/components/global-components/sh-form/js/useForm.js +236 -0
  15. package/packages/components/global-components/sh-form/query.vue +70 -0
  16. package/packages/components/global-components/sh-header/index.vue +35 -50
  17. package/packages/components/global-components/sh-icon/css/index.scss +44 -0
  18. package/packages/components/global-components/sh-icon/index.vue +24 -11
  19. package/packages/components/global-components/sh-image/index.vue +47 -38
  20. package/packages/components/global-components/sh-list/index.vue +42 -37
  21. package/packages/components/global-components/sh-loading/index.vue +12 -8
  22. package/packages/components/global-components/sh-modal/index.vue +49 -40
  23. package/packages/components/global-components/sh-noticebar/index.vue +68 -54
  24. package/packages/components/global-components/sh-poptip/index.vue +247 -130
  25. package/packages/components/global-components/sh-progress/index.vue +71 -69
  26. package/packages/components/global-components/sh-pull-refresh/index.vue +156 -157
  27. package/packages/components/global-components/sh-result/index.vue +37 -28
  28. package/packages/components/global-components/sh-row/index.vue +21 -18
  29. package/packages/components/global-components/sh-split/index.vue +115 -109
  30. package/packages/components/global-components/sh-table/components/importModal.vue +95 -86
  31. package/packages/components/global-components/sh-table/components/sh-column.vue +54 -0
  32. package/packages/components/global-components/sh-table/{index.vue → grid.vue} +34 -145
  33. package/packages/components/global-components/sh-table/js/tableMethods.js +175 -0
  34. package/packages/components/global-components/sh-table/js/useTable.js +592 -0
  35. package/packages/components/global-components/sh-table/table.vue +269 -0
  36. package/packages/components/global-components/sh-tabs/index.vue +118 -93
  37. package/packages/components/global-components/sh-tag/index.vue +52 -51
  38. package/packages/components/global-components/sh-toolbar/index.vue +53 -47
  39. package/packages/components/global-components/sh-tree/components/table-tree.vue +152 -139
  40. package/packages/components/global-components/sh-tree/index.vue +218 -195
  41. package/packages/components/global-components/sh-tree/mixin/treeProps.js +118 -120
  42. package/packages/components/global-components/sh-upload/index.vue +308 -51
  43. package/packages/components/global-components/sh-water-fall/index.vue +4 -11
  44. package/packages/components/index.js +5 -3
  45. package/packages/components/other-components/sh-cron-modal/components/cron-content.vue +294 -287
  46. package/packages/components/other-components/sh-cron-modal/css/index.scss +0 -5
  47. package/packages/components/other-components/sh-cron-modal/index.vue +81 -67
  48. package/packages/components/other-components/sh-cron-modal/mixin/cron-emits.js +1 -0
  49. package/packages/components/other-components/sh-cron-modal/mixin/cron-hooks.js +179 -0
  50. package/packages/components/other-components/sh-cron-modal/mixin/cron-props.js +9 -0
  51. package/packages/components/other-components/sh-cron-modal/tabs/cron-day-box.vue +101 -92
  52. package/packages/components/other-components/sh-cron-modal/tabs/cron-hour-box.vue +68 -56
  53. package/packages/components/other-components/sh-cron-modal/tabs/cron-minute-box.vue +68 -56
  54. package/packages/components/other-components/sh-cron-modal/tabs/cron-month-box.vue +68 -56
  55. package/packages/components/other-components/sh-cron-modal/tabs/cron-second-box.vue +68 -56
  56. package/packages/components/other-components/sh-cron-modal/tabs/cron-week-box.vue +126 -115
  57. package/packages/components/other-components/sh-cron-modal/tabs/cron-year-box.vue +59 -46
  58. package/packages/components/other-components/sh-menu/index.vue +75 -60
  59. package/packages/components/other-components/sh-menu/menu-group-content.vue +71 -59
  60. package/packages/components/other-components/sh-menu/menu-item-content.vue +71 -61
  61. package/packages/components/other-components/sh-menu-card/index.vue +81 -59
  62. package/packages/components/other-components/sh-menu-card/menu-box.vue +87 -68
  63. package/packages/components/other-components/sh-preview/components/sh-excel.vue +182 -0
  64. package/packages/components/other-components/sh-preview/components/sh-word.vue +73 -0
  65. package/packages/components/other-components/sh-preview/index.vue +86 -85
  66. package/packages/components/other-components/sh-preview/js/data-hook.js +37 -0
  67. package/packages/components/other-components/sh-preview/js/data-props.js +11 -0
  68. package/packages/components/other-components/sh-system-tip/index.vue +115 -113
  69. package/packages/css/index.js +4 -4
  70. package/packages/{assets/css → css}/main.scss +2 -50
  71. package/packages/{assets/css → css}/theme.scss +35 -16
  72. package/packages/directive/module/prevent-click.js +1 -1
  73. package/packages/directive/module/resize.js +11 -154
  74. package/packages/index.js +39 -39
  75. package/packages/mixin/index.js +86 -87
  76. package/packages/vxeTable/css/index.scss +3 -0
  77. package/packages/vxeTable/render/cell/vxe-render-checkbox.vue +14 -5
  78. package/packages/vxeTable/render/cell/vxe-render-checkgroup.vue +43 -36
  79. package/packages/vxeTable/render/cell/vxe-render-code.vue +14 -5
  80. package/packages/vxeTable/render/cell/vxe-render-goption.vue +34 -24
  81. package/packages/vxeTable/render/cell/vxe-render-href.vue +21 -11
  82. package/packages/vxeTable/render/cell/vxe-render-img.vue +16 -10
  83. package/packages/vxeTable/render/cell/vxe-render-input.vue +83 -67
  84. package/packages/vxeTable/render/cell/vxe-render-money.vue +14 -6
  85. package/packages/vxeTable/render/cell/vxe-render-progress.vue +28 -19
  86. package/packages/vxeTable/render/cell/vxe-render-radio.vue +14 -5
  87. package/packages/vxeTable/render/cell/vxe-render-radiogroup.vue +43 -36
  88. package/packages/vxeTable/render/cell/vxe-render-select.vue +44 -36
  89. package/packages/vxeTable/render/cell/vxe-render-switch.vue +14 -5
  90. package/packages/vxeTable/render/cell/vxe-render-table.vue +51 -78
  91. package/packages/vxeTable/render/cell/vxe-render-textarea.vue +14 -5
  92. package/packages/vxeTable/render/cell/vxe-render-time.vue +23 -13
  93. package/packages/vxeTable/render/cell/vxe-render-tree.vue +23 -27
  94. package/packages/vxeTable/render/cell/vxe-render-upload.vue +11 -7
  95. package/packages/vxeTable/render/filters/vxe-filter-input.vue +25 -43
  96. package/packages/vxeTable/render/footer/vxe-footer-input.vue +23 -13
  97. package/packages/vxeTable/render/footer/vxe-footer-money.vue +30 -20
  98. package/packages/vxeTable/render/globalRenders.jsx +1 -1
  99. package/packages/vxeTable/render/header/vxe-header-money.vue +31 -21
  100. package/packages/vxeTable/render/mixin/cell-hooks.js +162 -0
  101. package/packages/vxeTable/render/mixin/cell-props.js +23 -0
  102. package/packages/vxeTable/render/mixin/filter-hooks.js +28 -0
  103. package/packages/components/global-components/sh-form/components/form-item.vue +0 -25
  104. package/packages/components/global-components/sh-form/css/index.scss +0 -55
  105. package/packages/components/global-components/sh-form/index.vue +0 -114
  106. package/packages/components/global-components/sh-form/js/methods.js +0 -146
  107. package/packages/components/global-components/sh-form/mixin/defaultData.js +0 -32
  108. package/packages/components/global-components/sh-icon/css/default/index.scss +0 -27
  109. package/packages/components/global-components/sh-icon/css/font/index.scss +0 -16
  110. package/packages/components/global-components/sh-icon/icon-default.vue +0 -32
  111. package/packages/components/global-components/sh-icon/icon-font.vue +0 -32
  112. package/packages/components/global-components/sh-poptip/popper.js +0 -115
  113. package/packages/components/global-components/sh-query/index.vue +0 -317
  114. package/packages/components/global-components/sh-table/js/methods.js +0 -549
  115. package/packages/components/global-components/sh-table/mixin/defaultData.js +0 -94
  116. package/packages/components/global-components/sh-upload/js/mixin.js +0 -257
  117. package/packages/components/other-components/sh-cron-modal/mixin/cron-box.js +0 -169
  118. package/packages/vxeTable/render/mixin/cell-mixin.js +0 -206
  119. /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.svg → ionicons.svg} +0 -0
  120. /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.ttf → ionicons.ttf} +0 -0
  121. /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.woff → ionicons.woff} +0 -0
  122. /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.woff2 → ionicons.woff2} +0 -0
  123. /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.js → iconfont.js} +0 -0
  124. /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.json → iconfont.json} +0 -0
  125. /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.ttf → iconfont.ttf} +0 -0
  126. /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.woff → iconfont.woff} +0 -0
  127. /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.woff2 → iconfont.woff2} +0 -0
  128. /package/packages/{assets/css → css}/animated.scss +0 -0
  129. /package/packages/{assets/css → css}/loader.scss +0 -0
@@ -1,46 +1,59 @@
1
- <template>
2
- <div class="sh-cron-config-list">
3
- <vxe-radio-group v-model="type">
4
- <div class="item">
5
- <vxe-radio :label="TypeEnum.every" v-bind="beforeRadioAttrs">每年</vxe-radio>
6
- </div>
7
- <div class="item">
8
- <vxe-radio :label="TypeEnum.range" v-bind="beforeRadioAttrs">区间</vxe-radio>
9
- <span> 从 </span>
10
- <vxe-input v-model="valueRange.start" v-bind="typeRangeAttrs" />
11
- <span> 年 至 </span>
12
- <vxe-input v-model="valueRange.end" v-bind="typeRangeAttrs" />
13
- <span> 年 </span>
14
- </div>
15
- <div class="item">
16
- <vxe-radio :label="TypeEnum.loop" v-bind="beforeRadioAttrs">循环</vxe-radio>
17
- <span> 年 </span>
18
- <vxe-input v-model="valueLoop.start" v-bind="typeLoopAttrs" />
19
- <span> 分开始,间隔 </span>
20
- <vxe-input v-model="valueLoop.interval" v-bind="typeLoopAttrs" />
21
- <span> 年 </span>
22
- </div>
23
- </vxe-radio-group>
24
- </div>
25
- </template>
26
-
27
- <script>
28
- import cronMixin from '../mixin/cron-box'
29
-
30
- const nowYear = new Date().getFullYear()
31
- export default {
32
- name: 'CronYearBox',
33
- mixins: [cronMixin],
34
- data() {
35
- return {
36
- defaultValue: '*',
37
- minValue: 0,
38
- valueRange: { start: nowYear, end: nowYear + 100 },
39
- valueLoop: { start: nowYear, interval: 1 }
40
- }
41
- },
42
- methods: {}
43
- }
44
- </script>
45
-
46
- <style scoped></style>
1
+ <template>
2
+ <div class="sh-cron-config-list">
3
+ <vxe-radio-group v-model="type">
4
+ <div class="item">
5
+ <vxe-radio :label="TypeEnum.every" v-bind="beforeRadioAttrs">每年</vxe-radio>
6
+ </div>
7
+ <div class="item">
8
+ <vxe-radio :label="TypeEnum.range" v-bind="beforeRadioAttrs">区间</vxe-radio>
9
+ <span> 从 </span>
10
+ <vxe-input v-model="valueRange.start" v-bind="typeRangeAttrs" />
11
+ <span> 年 至 </span>
12
+ <vxe-input v-model="valueRange.end" v-bind="typeRangeAttrs" />
13
+ <span> 年 </span>
14
+ </div>
15
+ <div class="item">
16
+ <vxe-radio :label="TypeEnum.loop" v-bind="beforeRadioAttrs">循环</vxe-radio>
17
+ <span> 年 </span>
18
+ <vxe-input v-model="valueLoop.start" v-bind="typeLoopAttrs" />
19
+ <span> 分开始,间隔 </span>
20
+ <vxe-input v-model="valueLoop.interval" v-bind="typeLoopAttrs" />
21
+ <span> 年 </span>
22
+ </div>
23
+ </vxe-radio-group>
24
+ </div>
25
+ </template>
26
+
27
+ <script>
28
+ import { defineComponent, computed, getCurrentInstance, watch } from 'vue'
29
+ import cronProps from '../mixin/cron-props'
30
+ import cronHooks from '../mixin/cron-hooks'
31
+ import cronEmits from '../mixin/cron-emits'
32
+ export default defineComponent({
33
+ name: 'CronYearBox',
34
+ props: {
35
+ ...cronProps
36
+ },
37
+ emits: cronEmits,
38
+ setup(props, context) {
39
+ const { proxy } = getCurrentInstance()
40
+ const { $vUtils } = proxy
41
+ const { emit, slots } = context
42
+
43
+ const nowYear = new Date().getFullYear()
44
+
45
+ const useCron = cronHooks(props, context, proxy, {
46
+ defaultValue: '*',
47
+ minValue: 0,
48
+ valueRange: { start: nowYear, end: nowYear + 100 },
49
+ valueLoop: { start: nowYear, interval: 1 }
50
+ })
51
+
52
+ return {
53
+ ...useCron
54
+ }
55
+ }
56
+ })
57
+ </script>
58
+
59
+ <style scoped></style>
@@ -9,17 +9,13 @@
9
9
  </template>
10
10
 
11
11
  <script>
12
+ import { defineComponent, computed, provide, ref, getCurrentInstance, watch, onMounted } from 'vue'
12
13
  import menuGroupContent from './menu-group-content.vue'
13
- export default {
14
+ export default defineComponent({
14
15
  name: 'ShMenu',
15
16
  components: {
16
17
  menuGroupContent
17
18
  },
18
- provide() {
19
- return {
20
- MenuInstance: this
21
- }
22
- },
23
19
  props: {
24
20
  modelValue: {
25
21
  type: String
@@ -60,72 +56,89 @@ export default {
60
56
  }
61
57
  },
62
58
  emits: ['update:modelValue', 'change', 'expand'],
63
- data() {
64
- return {
65
- activeName: this.modelValue,
66
- activeNames: [],
67
- openedNames: []
68
- }
69
- },
70
- computed: {
71
- classes() {
59
+ setup(props, context) {
60
+ const { proxy } = getCurrentInstance()
61
+ const { $vUtils } = proxy
62
+ const { emit, slots } = context
63
+
64
+ const activeName = ref(props.modelValue)
65
+ const activeNames = ref([])
66
+ const openedNames = ref([])
67
+
68
+ const classes = computed(() => {
72
69
  return {
73
- theme: this.theme,
74
- fix: this.fix,
75
- collapsed: this.collapsed,
76
- [`${this.mode}`]: this.mode
70
+ theme: props.theme,
71
+ fix: props.fix,
72
+ collapsed: props.collapsed,
73
+ [`${props.mode}`]: props.mode
77
74
  }
78
- }
79
- },
80
- watch: {
81
- modelValue(to, from) {
82
- this.resetMenu()
83
- }
84
- },
85
- mounted() {
86
- this.resetMenu()
87
- },
88
- methods: {
75
+ })
76
+
89
77
  // 重新渲染菜单
90
- resetMenu() {
91
- this.activeName = this.modelValue
92
- this.resetExpand(this.activeName, true)
93
- },
94
- resetExpand(menuName, mount) {
95
- let activeNames = []
96
- let parentTree = this.$vUtils.searchTree(this.options, item => item.name === menuName)
97
- this.$vUtils.eachTree(parentTree, item => {
98
- activeNames.push(item.name)
78
+ const resetMenu = () => {
79
+ activeName.value = props.modelValue
80
+ resetExpand(activeName.value, true)
81
+ }
82
+ const resetExpand = (menuName, mount) => {
83
+ let setActiveNames = []
84
+ let parentTree = $vUtils.searchTree(props.options, item => item.name === menuName)
85
+ $vUtils.eachTree(parentTree, item => {
86
+ setActiveNames.push(item.name)
99
87
  })
100
88
  if (mount) {
101
- this.activeNames = activeNames
102
- if (this.collapsed || this.mode !== 'vertical') return
89
+ activeNames.value = setActiveNames
90
+ if (props.collapsed || props.mode !== 'vertical') return
103
91
  }
104
92
  // 过滤掉所有子节点
105
- let menuIndex = activeNames.findIndex(item => item === menuName)
106
- let parentNames = activeNames.filter((item, itemIndex) => menuIndex >= itemIndex)
107
- if (!this.accordion) parentNames = Array.from(new Set(this.openedNames.concat(parentNames)))
108
- this.openedNames = parentNames
109
- },
110
- onMenuSelect(menu) {
111
- this.$emit('update:modelValue', menu.name)
112
- this.$emit('change', menu)
113
- this.handleOut()
114
- },
115
- onMenuExpand(expand, menu) {
116
- this.$emit('expand', expand, menu)
93
+ let menuIndex = setActiveNames.findIndex(item => item === menuName)
94
+ let parentNames = setActiveNames.filter((item, itemIndex) => menuIndex >= itemIndex)
95
+ if (!props.accordion) parentNames = Array.from(new Set(openedNames.value.concat(parentNames)))
96
+ openedNames.value = parentNames
97
+ }
98
+ const onMenuSelect = menu => {
99
+ emit('update:modelValue', menu.name)
100
+ emit('change', menu)
101
+ handleOut()
102
+ }
103
+ const onMenuExpand = (expand, menu) => {
104
+ emit('expand', expand, menu)
117
105
  if (!expand) {
118
- this.openedNames = this.openedNames.filter(name => name !== menu.name)
106
+ openedNames.value = openedNames.value.filter(name => name !== menu.name)
119
107
  return
120
108
  }
121
- this.resetExpand(menu.name)
122
- },
123
- handleOut() {
124
- if (!this.collapsed && this.mode === 'vertical') return
125
- this.openedNames = []
109
+ resetExpand(menu.name)
110
+ }
111
+ const handleOut = () => {
112
+ if (!props.collapsed && props.mode === 'vertical') return
113
+ openedNames.value = []
114
+ }
115
+
116
+ provide('MenuInstance', {
117
+ ...props,
118
+ activeName,
119
+ activeNames,
120
+ openedNames,
121
+ onMenuSelect,
122
+ onMenuExpand
123
+ })
124
+
125
+ watch(
126
+ () => props.modelValue,
127
+ () => {
128
+ resetMenu()
129
+ }
130
+ )
131
+
132
+ onMounted(() => {
133
+ resetMenu()
134
+ })
135
+
136
+ return {
137
+ classes,
138
+ handleOut
126
139
  }
127
140
  }
128
- }
141
+ })
129
142
  </script>
130
143
 
131
144
  <style lang="scss">
@@ -295,6 +308,8 @@ $expandDkBgColor: var(--vxe-primary-darken-color);
295
308
  .sh-menu-item-title {
296
309
  flex: 1;
297
310
  white-space: nowrap;
311
+ overflow: hidden;
312
+ text-overflow: ellipsis;
298
313
  }
299
314
  .sh-menu-item-arrow {
300
315
  margin-left: 5px;
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div v-if="showChildren(menuItem)" class="sh-menu-group" :class="groupClass">
3
- <menuItemContent ref="groupItem" :menu-item="menuItem" :menu-level="menuLevel" :arrow="isArrow" @click="onMenuExpand(!expand)" />
3
+ <menuItemContent ref="groupItemRef" :menu-item="menuItem" :menu-level="menuLevel" :arrow="isArrow" @click="onMenuExpand(!expand)" />
4
4
  <div v-show="expand" ref="groupList" class="sh-menu-group-list" :class="groupListClass" :style="groupListStyle">
5
5
  <template v-for="(item, index) in menuItem.children" :key="`sh-menu-${menuLevel}-${index}`">
6
6
  <menuGroupContent :menu-item="item" :menu-level="menuNextLevel" />
@@ -13,17 +13,13 @@
13
13
  </template>
14
14
 
15
15
  <script>
16
+ import { defineComponent, computed, getCurrentInstance, ref, watch, onMounted, inject } from 'vue'
16
17
  import menuItemContent from './menu-item-content.vue'
17
- export default {
18
+ export default defineComponent({
18
19
  name: 'MenuGroupContent',
19
20
  components: {
20
21
  menuItemContent
21
22
  },
22
- inject: {
23
- MenuInstance: {
24
- default: null
25
- }
26
- },
27
23
  props: {
28
24
  menuLevel: {
29
25
  type: Number,
@@ -36,51 +32,43 @@ export default {
36
32
  }
37
33
  }
38
34
  },
39
- data() {
40
- return {
41
- expand: false,
42
- groupListStyle: {}
43
- }
44
- },
45
- computed: {
46
- menuNextLevel() {
47
- return this.menuLevel + 1
48
- },
49
- isArrow() {
50
- return this.MenuInstance.collapsed ? !!this.menuLevel : true
51
- },
52
- groupClass() {
35
+ setup(props, context) {
36
+ const { proxy } = getCurrentInstance()
37
+ const { $vUtils } = proxy
38
+ const { emit, slots } = context
39
+ const MenuInstance = inject('MenuInstance')
40
+
41
+ const groupItemRef = ref()
42
+ const expand = ref(false)
43
+ const groupListStyle = ref({})
44
+
45
+ const menuNextLevel = computed(() => props.menuLevel + 1)
46
+ const isArrow = computed(() => {
47
+ return MenuInstance.collapsed ? !!props.menuLevel : true
48
+ })
49
+ const groupClass = computed(() => {
53
50
  return {
54
- is__level: !this.menuLevel,
55
- is__active: this.MenuInstance.activeNames.includes(this.menuItem.name),
56
- is__expand: this.expand
51
+ is__level: !props.menuLevel,
52
+ is__active: MenuInstance.activeNames.value.includes(props.menuItem.name),
53
+ is__expand: expand.value
57
54
  }
58
- },
59
- groupListClass() {
60
- const { mode, collapsed } = this.MenuInstance
55
+ })
56
+ const groupListClass = computed(() => {
57
+ const { mode, collapsed } = MenuInstance
61
58
  return {
62
59
  'sh-menu-group-dropdown': mode === 'horizontal',
63
60
  'sh-menu-group-dropright': mode === 'vertical' && collapsed
64
61
  }
65
- }
66
- },
67
- watch: {
68
- 'MenuInstance.openedNames'(names) {
69
- this.setMenuExpand()
70
- }
71
- },
72
- mounted() {
73
- this.setMenuExpand()
74
- },
75
- methods: {
76
- setMenuExpand() {
77
- let names = this.MenuInstance.openedNames
78
- this.expand = names.includes(this.menuItem.name)
79
- const { mode, collapsed } = this.MenuInstance
80
- if (this.expand && this.$refs.groupItem && ((mode === 'vertical' && collapsed) || mode === 'horizontal')) {
81
- this.$nextTick(() => {
82
- const { left, right, top, bottom } = this.$refs.groupItem.$refs?.shMenuItem.getBoundingClientRect()
83
- const { offsetHeight, offsetWidth } = this.$refs.groupList
62
+ })
63
+
64
+ const setMenuExpand = () => {
65
+ const { mode, collapsed, openedNames } = MenuInstance
66
+ let names = openedNames.value
67
+ expand.value = names.includes(props.menuItem.name)
68
+ if (expand.value && groupItemRef.value && ((mode === 'vertical' && collapsed) || mode === 'horizontal')) {
69
+ nextTick(() => {
70
+ const { offsetHeight, offsetWidth, itemRef } = groupItemRef.value
71
+ const { left, right, top, bottom } = itemRef.value.getBoundingClientRect()
84
72
  const winWidth = window.innerWidth
85
73
  const winHeight = window.innerHeight
86
74
  if (mode === 'vertical') {
@@ -93,30 +81,54 @@ export default {
93
81
  } else {
94
82
  groupStyle.top = `${top}px`
95
83
  }
96
- this.groupListStyle = groupStyle
84
+ groupListStyle.value = groupStyle
97
85
  } else {
98
- let groupStyle = { top: `${this.menuLevel ? top : bottom}px` }
86
+ let groupStyle = { top: `${props.menuLevel ? top : bottom}px` }
99
87
  if (right + offsetWidth >= winWidth) {
100
88
  groupStyle.right = '10px'
101
89
  } else {
102
- groupStyle.left = `${this.menuLevel ? right : left}px`
90
+ groupStyle.left = `${props.menuLevel ? right : left}px`
103
91
  }
104
- this.groupListStyle = groupStyle
92
+ groupListStyle.value = groupStyle
105
93
  }
106
94
  })
107
95
  }
108
- },
109
- showChildren(item) {
96
+ }
97
+ const showChildren = item => {
110
98
  return item.children && item.children.length > 0
111
- },
112
- onMenuClick() {
113
- this.MenuInstance.onMenuSelect(this.menuItem)
114
- },
115
- onMenuExpand(value) {
116
- this.MenuInstance.onMenuExpand(value, this.menuItem)
99
+ }
100
+ const onMenuClick = () => {
101
+ MenuInstance.onMenuSelect(props.menuItem)
102
+ }
103
+ const onMenuExpand = value => {
104
+ MenuInstance.onMenuExpand(value, props.menuItem)
105
+ }
106
+
107
+ watch(
108
+ () => MenuInstance.openedNames.value,
109
+ () => {
110
+ setMenuExpand()
111
+ }
112
+ )
113
+
114
+ onMounted(() => {
115
+ setMenuExpand()
116
+ })
117
+
118
+ return {
119
+ groupItemRef,
120
+ groupClass,
121
+ groupListClass,
122
+ groupListStyle,
123
+ isArrow,
124
+ expand,
125
+ menuNextLevel,
126
+ showChildren,
127
+ onMenuExpand,
128
+ onMenuClick
117
129
  }
118
130
  }
119
- }
131
+ })
120
132
  </script>
121
133
 
122
134
  <style scoped></style>
@@ -1,61 +1,71 @@
1
- <template>
2
- <div ref="shMenuItem" class="sh-menu-item" :class="itemClass" :style="itemStyle">
3
- <sh-icon v-if="iconType" class="sh-menu-item-icon" :type="iconType"></sh-icon>
4
- <span class="sh-menu-item-title">{{ formatTitle(menuItem) }}</span>
5
- <sh-icon v-if="arrow" class="sh-menu-item-arrow" type="ios-arrow-forward"></sh-icon>
6
- </div>
7
- </template>
8
-
9
- <script>
10
- export default {
11
- name: 'MenuItemBox',
12
- inject: {
13
- MenuInstance: {
14
- default: null
15
- }
16
- },
17
- props: {
18
- arrow: Boolean,
19
- menuLevel: {
20
- type: Number
21
- },
22
- menuItem: {
23
- type: Object,
24
- default() {
25
- return {}
26
- }
27
- }
28
- },
29
- computed: {
30
- defaultIcon() {
31
- if (!this.menuLevel || this.menuLevel < 2) return 'md-folder'
32
- else if (this.menuLevel === 2) return 'md-bookmark'
33
- else return ''
34
- },
35
- iconType() {
36
- return this.menuItem.meta?.icon || this.menuItem.icon || this.defaultIcon
37
- },
38
- itemClass() {
39
- return {
40
- 'sh-menu-item-level': !this.menuLevel,
41
- 'sh-menu-item-active': this.MenuInstance.activeName === this.menuItem.name
42
- }
43
- },
44
- itemStyle() {
45
- let result = {}
46
- const { mode, collapsed, indent } = this.MenuInstance
47
- if (mode === 'vertical' && !collapsed && this.menuLevel) {
48
- result.paddingLeft = `${indent * this.menuLevel}px`
49
- }
50
- return result
51
- },
52
- itemTitle() {
53
- const { labelField, labelFormat } = this.MenuInstance
54
- return labelFormat ? labelFormat(this.menuItem) : this.$vUtils.get(this.menuItem, labelField)
55
- }
56
- },
57
- methods: {}
58
- }
59
- </script>
60
-
61
- <style scoped></style>
1
+ <template>
2
+ <div ref="itemRef" class="sh-menu-item" :class="itemClass" :style="itemStyle">
3
+ <sh-icon v-if="iconType" class="sh-menu-item-icon" :type="iconType"></sh-icon>
4
+ <span class="sh-menu-item-title">{{ itemTitle }}</span>
5
+ <sh-icon v-if="arrow" class="sh-menu-item-arrow" type="ios-arrow-forward"></sh-icon>
6
+ </div>
7
+ </template>
8
+
9
+ <script>
10
+ import { defineComponent, computed, getCurrentInstance, ref, inject } from 'vue'
11
+ export default defineComponent({
12
+ name: 'MenuItemBox',
13
+ props: {
14
+ arrow: Boolean,
15
+ menuLevel: {
16
+ type: Number
17
+ },
18
+ menuItem: {
19
+ type: Object,
20
+ default() {
21
+ return {}
22
+ }
23
+ }
24
+ },
25
+ setup(props, context) {
26
+ const { proxy } = getCurrentInstance()
27
+ const { $vUtils } = proxy
28
+ const { emit, slots } = context
29
+ const MenuInstance = inject('MenuInstance')
30
+
31
+ const itemRef = ref()
32
+
33
+ const defaultIcon = computed(() => {
34
+ if (!props.menuLevel || props.menuLevel < 1) return 'md-folder'
35
+ else if (props.menuLevel === 1) return 'md-bookmark'
36
+ else return ''
37
+ })
38
+ const iconType = computed(() => {
39
+ return props.menuItem.meta?.icon || props.menuItem.icon || defaultIcon.value
40
+ })
41
+ const itemClass = computed(() => {
42
+ return {
43
+ 'sh-menu-item-level': !props.menuLevel,
44
+ 'sh-menu-item-active': MenuInstance.activeName.value === props.menuItem.name
45
+ }
46
+ })
47
+ const itemStyle = computed(() => {
48
+ let result = {}
49
+ const { mode, collapsed, indent } = MenuInstance
50
+ if (mode === 'vertical' && !collapsed && props.menuLevel) {
51
+ result.paddingLeft = `${indent * props.menuLevel}px`
52
+ }
53
+ return result
54
+ })
55
+ const itemTitle = computed(() => {
56
+ const { labelField, labelFormat } = MenuInstance
57
+ return labelFormat ? labelFormat(props.menuItem) : $vUtils.get(props.menuItem, labelField)
58
+ })
59
+
60
+ return {
61
+ itemRef,
62
+ itemClass,
63
+ itemStyle,
64
+ itemTitle,
65
+ iconType
66
+ }
67
+ }
68
+ })
69
+ </script>
70
+
71
+ <style scoped></style>