wangrong
2026-08-30 4c949c0dc9bcae785c281c9d8125295f09810b15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<script lang="ts" setup>
import { Icon } from '@/components/icon-custom'
import icon_more_outlined from '@/assets/svg/icon_more_outlined.svg'
import { propTypes } from '@/utils/propTypes'
import type { Placement } from 'element-plus-secondary'
import { ref, PropType, computed } from 'vue'
import ShareHandler from '@/views/share/share/ShareHandler.vue'
import { useShareStoreWithOut } from '@/store/modules/share'
import { isDesktop } from '@/utils/ModelUtil'
import { useI18n } from '@/hooks/web/useI18n'
const shareStore = useShareStoreWithOut()
const { t } = useI18n()
 
export interface Menu {
  svgName?: string
  label?: string
  command: string
  divided?: boolean
  disabled?: boolean
  hidden?: boolean
}
 
const props = defineProps({
  menuList: {
    type: Array as PropType<Menu[]>
  },
  placement: {
    type: String as () => Placement,
    default: 'bottom-end'
  },
  iconName: propTypes.string.def(''),
  inTable: propTypes.bool.def(false),
  resourceType: propTypes.string.def('dashboard'),
  node: {
    type: Object,
    default() {
      return {}
    }
  },
  anyManage: propTypes.bool.def(false)
})
 
const shareDisable = computed(() => {
  return shareStore.getShareDisable || isDesktop()
})
 
const shareComponent = ref(null)
const menus = ref([
  ...props.menuList.map(item => {
    if (!props.anyManage && (item.command === 'copy' || item.command === 'move')) {
      item.hidden = true
    }
    return item
  })
])
const handleCommand = (command: string | number | object) => {
  if (command === 'share') {
    // shareComponent.value.invokeMethod({ methodName: 'execute' })
    shareComponent.value.execute()
    return
  }
  emit('handleCommand', command)
}
const callBack = param => {
  if (shareDisable.value) {
    return
  }
  if (props.node.leaf && props.node?.weight >= 7) {
    menus.value.splice(0, 0, param)
  }
}
const emit = defineEmits(['handleCommand'])
 
const menuDisabledCheck = ele => {
  // do return
  return ele.disabled || (props.node.extraFlag1 === 0 && ['share', 'copy'].includes(ele.command))
}
</script>
 
<template>
  <el-dropdown
    popper-class="menu-more-dv_popper"
    :placement="placement"
    trigger="click"
    @command="handleCommand"
  >
    <el-icon class="hover-icon" :class="inTable && 'hover-icon-in-table'" @click.stop>
      <Icon><component class="svg-icon" :is="iconName || icon_more_outlined"></component></Icon>
    </el-icon>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item
          :divided="ele.divided"
          :command="ele.command"
          v-for="ele in menus"
          :key="ele.label"
          :disabled="menuDisabledCheck(ele)"
          :class="{
            'de-hidden-drop-item':
              ele.hidden || (ele.command === 'cancelPublish' && node.extraFlag1 === 0)
          }"
        >
          <el-icon class="handle-icon" color="#646a73" size="16" v-if="ele.svgName">
            <Icon
              ><component
                class="svg-icon"
                :class="{ 'custom-disable': menuDisabledCheck(ele) }"
                :is="ele.svgName"
              ></component
            ></Icon>
          </el-icon>
          <el-tooltip
            class="box-item"
            effect="dark"
            :content="t('visualization.publish_tips2', [ele.label])"
            :disabled="!menuDisabledCheck(ele)"
            placement="top-start"
          >
            {{ ele.label }}
          </el-tooltip>
        </el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
  <ShareHandler
    v-if="!shareDisable"
    ref="shareComponent"
    :resource-id="props.node.id"
    :resource-type="props.resourceType"
    :weight="node.weight"
    @loaded="callBack"
  />
</template>
 
<style lang="less">
.custom-disable {
  color: var(--ed-text-color-disabled) !important;
}
.de-hidden-drop-item {
  display: none !important;
}
.menu-more-dv_popper {
  min-width: 120px;
  margin-top: -2px !important;
}
 
.handle-icon {
  font-size: 16px;
  color: #646a73;
}
</style>