Commit 780254b888fb5560f4285301ab2227fda45e47d6
1 parent
e6d4b04c
feat: add AuthIcon component replace ant-design icon
Showing
4 changed files
with
66 additions
and
33 deletions
| 1 | +<script lang="ts" setup> | |
| 2 | + import { Icon } from '/@/components/Icon'; | |
| 3 | + import { computed, ExtractPropTypes, unref } from 'vue'; | |
| 4 | + import { usePermission } from '/@/hooks/web/usePermission'; | |
| 5 | + | |
| 6 | + interface AuthIconProps extends ExtractPropTypes<typeof Icon> { | |
| 7 | + auth?: string; | |
| 8 | + } | |
| 9 | + | |
| 10 | + const props = defineProps<AuthIconProps>(); | |
| 11 | + | |
| 12 | + const emit = defineEmits(['click']); | |
| 13 | + | |
| 14 | + const { hasPermission } = usePermission(); | |
| 15 | + | |
| 16 | + const getHasPermission = computed(() => { | |
| 17 | + const { auth } = props; | |
| 18 | + return auth ? hasPermission(auth) : true; | |
| 19 | + }); | |
| 20 | + | |
| 21 | + const getBindProps = computed(() => { | |
| 22 | + return { | |
| 23 | + ...props, | |
| 24 | + ...(unref(getHasPermission) ? { onClick: (event: Event) => emit('click', event) } : {}), | |
| 25 | + }; | |
| 26 | + }); | |
| 27 | +</script> | |
| 28 | + | |
| 29 | +<template> | |
| 30 | + <Icon | |
| 31 | + v-bind="getBindProps" | |
| 32 | + class="justify-center items-center" | |
| 33 | + :class="getHasPermission ? '' : '!cursor-not-allowed !text-gray-200'" | |
| 34 | + /> | |
| 35 | +</template> | ... | ... |
| 1 | 1 | <script setup lang="ts"> |
| 2 | 2 | import { List, Card, Button, PaginationProps, Popover, Slider, Tooltip } from 'ant-design-vue'; |
| 3 | - import { | |
| 4 | - ReloadOutlined, | |
| 5 | - AppstoreOutlined, | |
| 6 | - EyeOutlined, | |
| 7 | - EditOutlined, | |
| 8 | - EllipsisOutlined, | |
| 9 | - } from '@ant-design/icons-vue'; | |
| 3 | + import { ReloadOutlined, AppstoreOutlined, EllipsisOutlined } from '@ant-design/icons-vue'; | |
| 10 | 4 | import { computed, onMounted, reactive, ref, unref } from 'vue'; |
| 11 | 5 | import { OrganizationIdTree, useResetOrganizationTree } from '../../common/organizationIdTree'; |
| 12 | 6 | import { |
| ... | ... | @@ -29,6 +23,7 @@ |
| 29 | 23 | import { cloneDeep } from 'lodash'; |
| 30 | 24 | import { usePermission } from '/@/hooks/web/usePermission'; |
| 31 | 25 | import { useGlobSetting } from '/@/hooks/setting'; |
| 26 | + import { AuthIcon } from '/@/components/Widget'; | |
| 32 | 27 | |
| 33 | 28 | const listColumn = ref(5); |
| 34 | 29 | |
| ... | ... | @@ -227,16 +222,18 @@ |
| 227 | 222 | </template> |
| 228 | 223 | <template class="ant-card-actions" #actions> |
| 229 | 224 | <Tooltip title="预览"> |
| 230 | - <EyeOutlined | |
| 231 | - :class="getPreviewFlag ? '' : '!cursor-not-allowed !text-gray-200'" | |
| 232 | - key="setting" | |
| 225 | + <AuthIcon | |
| 226 | + :auth="ConfigurationPermission.PREVIEW" | |
| 227 | + class="!text-lg" | |
| 228 | + icon="ant-design:eye-outlined" | |
| 233 | 229 | @click="handlePreview(item)" |
| 234 | 230 | /> |
| 235 | 231 | </Tooltip> |
| 236 | 232 | <Tooltip title="设计"> |
| 237 | - <EditOutlined | |
| 238 | - :class="getDesignFlag ? '' : '!cursor-not-allowed !text-gray-200'" | |
| 239 | - key="edit" | |
| 233 | + <AuthIcon | |
| 234 | + :auth="ConfigurationPermission.DESIGN" | |
| 235 | + class="!text-lg" | |
| 236 | + icon="ant-design:edit-outlined" | |
| 240 | 237 | @click="handleDesign(item)" |
| 241 | 238 | /> |
| 242 | 239 | </Tooltip> | ... | ... |
| ... | ... | @@ -2,9 +2,14 @@ |
| 2 | 2 | import { PageWrapper } from '/@/components/Page'; |
| 3 | 3 | import { BasicForm, useForm } from '/@/components/Form'; |
| 4 | 4 | import { List, Button, Tooltip, Card, PaginationProps, Image } from 'ant-design-vue'; |
| 5 | - import { ReloadOutlined, EyeOutlined, FormOutlined, MoreOutlined } from '@ant-design/icons-vue'; | |
| 5 | + import { ReloadOutlined, MoreOutlined } from '@ant-design/icons-vue'; | |
| 6 | 6 | import { computed, onMounted, reactive, ref, unref } from 'vue'; |
| 7 | - import { CardLayoutButton, EnumTableCardMode, ModeSwitchButton } from '/@/components/Widget'; | |
| 7 | + import { | |
| 8 | + AuthIcon, | |
| 9 | + CardLayoutButton, | |
| 10 | + EnumTableCardMode, | |
| 11 | + ModeSwitchButton, | |
| 12 | + } from '/@/components/Widget'; | |
| 8 | 13 | import { Authority } from '/@/components/Authority'; |
| 9 | 14 | import { |
| 10 | 15 | deviceConfigDelete, |
| ... | ... | @@ -111,14 +116,6 @@ |
| 111 | 116 | return hasPermission(ProductPermission.DELETE); |
| 112 | 117 | }); |
| 113 | 118 | |
| 114 | - const getHasDetailFlag = computed(() => { | |
| 115 | - return hasPermission(ProductPermission.DETAIL); | |
| 116 | - }); | |
| 117 | - | |
| 118 | - const getHasUpdateFlag = computed(() => { | |
| 119 | - return hasPermission(ProductPermission.UPDATE); | |
| 120 | - }); | |
| 121 | - | |
| 122 | 119 | const getDropDownList = (record: ProfileRecord) => { |
| 123 | 120 | const list = [ |
| 124 | 121 | { |
| ... | ... | @@ -163,12 +160,10 @@ |
| 163 | 160 | }; |
| 164 | 161 | |
| 165 | 162 | const handleShowDetail = (record: ProfileRecord) => { |
| 166 | - if (!unref(getHasDetailFlag)) return; | |
| 167 | 163 | openDrawer(true, { record }); |
| 168 | 164 | }; |
| 169 | 165 | |
| 170 | 166 | const handleUpdate = (record: ProfileRecord) => { |
| 171 | - if (!unref(getHasUpdateFlag)) return; | |
| 172 | 167 | openModal(true, { |
| 173 | 168 | record, |
| 174 | 169 | isUpdate: true, |
| ... | ... | @@ -268,16 +263,18 @@ |
| 268 | 263 | </template> |
| 269 | 264 | <template class="ant-card-actions" #actions> |
| 270 | 265 | <Tooltip title="详情"> |
| 271 | - <EyeOutlined | |
| 272 | - :class="getHasDetailFlag ? '' : '!cursor-not-allowed !text-gray-200'" | |
| 273 | - key="setting" | |
| 266 | + <AuthIcon | |
| 267 | + :auth="ProductPermission.DETAIL" | |
| 268 | + class="!text-lg" | |
| 269 | + icon="ant-design:eye-outlined" | |
| 274 | 270 | @click.stop="handleShowDetail(item)" |
| 275 | 271 | /> |
| 276 | 272 | </Tooltip> |
| 277 | 273 | <Tooltip title="编辑"> |
| 278 | - <FormOutlined | |
| 279 | - :class="getHasUpdateFlag ? '' : '!cursor-not-allowed !text-gray-200'" | |
| 280 | - key="edit" | |
| 274 | + <AuthIcon | |
| 275 | + :auth="ProductPermission.UPDATE" | |
| 276 | + class="!text-lg" | |
| 277 | + icon="ant-design:form-outlined" | |
| 281 | 278 | @click.stop="handleUpdate(item)" |
| 282 | 279 | /> |
| 283 | 280 | </Tooltip> |
| ... | ... | @@ -308,7 +305,10 @@ |
| 308 | 305 | |
| 309 | 306 | <style lang="less" scoped> |
| 310 | 307 | .profile-list:deep(.ant-image-img) { |
| 311 | - width: 100% !important; | |
| 312 | - height: 100% !important; | |
| 308 | + @apply !w-full !h-full; | |
| 309 | + } | |
| 310 | + | |
| 311 | + .profile-list:deep(.ant-card-body) { | |
| 312 | + @apply !p-4; | |
| 313 | 313 | } |
| 314 | 314 | </style> | ... | ... |