| | |
| | | Button, |
| | | Dropdown, |
| | | Menu, |
| | | Modal, |
| | | Popconfirm, |
| | | Space, |
| | | Tooltip, |
| | |
| | | /** 处理菜单点击 */ |
| | | function handleMenuClick(e: any) { |
| | | const action = getDropdownList.value[e.key]; |
| | | if (action && action.onClick && isFunction(action.onClick)) { |
| | | if (!action) { |
| | | return; |
| | | } |
| | | const popConfirm = action.popConfirm; |
| | | if (popConfirm) { |
| | | // 下拉菜单项会被 Dropdown 自动关闭销毁,嵌套 Popconfirm 无法弹出, |
| | | // 故改用命令式 Modal.confirm 完成确认 |
| | | Modal.confirm({ |
| | | title: popConfirm.title, |
| | | okText: popConfirm.okText, |
| | | cancelText: popConfirm.cancelText, |
| | | onOk: popConfirm.confirm ? () => popConfirm.confirm!() : undefined, |
| | | onCancel: popConfirm.cancel ? () => popConfirm.cancel!() : undefined, |
| | | }); |
| | | return; |
| | | } |
| | | if (action.onClick && isFunction(action.onClick)) { |
| | | action.onClick(); |
| | | } |
| | | } |
| | |
| | | v-for="(action, index) in getDropdownList" |
| | | :key="index" |
| | | :disabled="action.disabled" |
| | | @click="!action.popConfirm && handleMenuClick({ key: index })" |
| | | @click="handleMenuClick({ key: index })" |
| | | > |
| | | <template v-if="action.popConfirm"> |
| | | <Popconfirm v-bind="getPopConfirmProps(action.popConfirm)"> |
| | | <template v-if="action.popConfirm.icon" #icon> |
| | | <IconifyIcon :icon="action.popConfirm.icon" /> |
| | | </template> |
| | | <div |
| | | :class=" |
| | | action.disabled === true |
| | | ? 'cursor-not-allowed text-gray-300' |
| | | : '' |
| | | " |
| | | > |
| | | <IconifyIcon v-if="action.icon" :icon="action.icon" /> |
| | | <span :class="action.icon ? 'ml-1' : ''"> |
| | | {{ action.label }} |
| | | </span> |
| | | </div> |
| | | </Popconfirm> |
| | | </template> |
| | | <template v-else> |
| | | <div |
| | | :class=" |
| | | action.disabled === true |
| | | ? 'cursor-not-allowed text-gray-300' |
| | | : '' |
| | | " |
| | | > |
| | | <IconifyIcon v-if="action.icon" :icon="action.icon" /> |
| | | <div |
| | | :class=" |
| | | action.disabled === true |
| | | ? 'cursor-not-allowed text-gray-300' |
| | | : '' |
| | | " |
| | | > |
| | | <IconifyIcon v-if="action.icon" :icon="action.icon" /> |
| | | <span :class="action.icon ? 'ml-1' : ''"> |
| | | {{ action.label }} |
| | | </div> |
| | | </template> |
| | | </span> |
| | | </div> |
| | | </Menu.Item> |
| | | </Menu> |
| | | </template> |