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 | export { default as ModeSwitchButton } from './ModeSwitchButton.vue'; | 1 | export { default as ModeSwitchButton } from './ModeSwitchButton.vue'; | 
| 2 | export { default as CardLayoutButton } from './CardLayoutButton.vue'; | 2 | export { default as CardLayoutButton } from './CardLayoutButton.vue'; | 
| 3 | +export { default as AuthIcon } from './AuthIcon.vue'; | ||
| 3 | export { | 4 | export { | 
| 4 | EnumTableCardMode, | 5 | EnumTableCardMode, | 
| 5 | EnumTableChartMode, | 6 | EnumTableChartMode, | 
| 1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> | 
| 2 | import { List, Card, Button, PaginationProps, Popover, Slider, Tooltip } from 'ant-design-vue'; | 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 | import { computed, onMounted, reactive, ref, unref } from 'vue'; | 4 | import { computed, onMounted, reactive, ref, unref } from 'vue'; | 
| 11 | import { OrganizationIdTree, useResetOrganizationTree } from '../../common/organizationIdTree'; | 5 | import { OrganizationIdTree, useResetOrganizationTree } from '../../common/organizationIdTree'; | 
| 12 | import { | 6 | import { | 
| @@ -29,6 +23,7 @@ | @@ -29,6 +23,7 @@ | ||
| 29 | import { cloneDeep } from 'lodash'; | 23 | import { cloneDeep } from 'lodash'; | 
| 30 | import { usePermission } from '/@/hooks/web/usePermission'; | 24 | import { usePermission } from '/@/hooks/web/usePermission'; | 
| 31 | import { useGlobSetting } from '/@/hooks/setting'; | 25 | import { useGlobSetting } from '/@/hooks/setting'; | 
| 26 | + import { AuthIcon } from '/@/components/Widget'; | ||
| 32 | 27 | ||
| 33 | const listColumn = ref(5); | 28 | const listColumn = ref(5); | 
| 34 | 29 | ||
| @@ -227,16 +222,18 @@ | @@ -227,16 +222,18 @@ | ||
| 227 | </template> | 222 | </template> | 
| 228 | <template class="ant-card-actions" #actions> | 223 | <template class="ant-card-actions" #actions> | 
| 229 | <Tooltip title="预览"> | 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 | @click="handlePreview(item)" | 229 | @click="handlePreview(item)" | 
| 234 | /> | 230 | /> | 
| 235 | </Tooltip> | 231 | </Tooltip> | 
| 236 | <Tooltip title="设计"> | 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 | @click="handleDesign(item)" | 237 | @click="handleDesign(item)" | 
| 241 | /> | 238 | /> | 
| 242 | </Tooltip> | 239 | </Tooltip> | 
| @@ -2,9 +2,14 @@ | @@ -2,9 +2,14 @@ | ||
| 2 | import { PageWrapper } from '/@/components/Page'; | 2 | import { PageWrapper } from '/@/components/Page'; | 
| 3 | import { BasicForm, useForm } from '/@/components/Form'; | 3 | import { BasicForm, useForm } from '/@/components/Form'; | 
| 4 | import { List, Button, Tooltip, Card, PaginationProps, Image } from 'ant-design-vue'; | 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 | import { computed, onMounted, reactive, ref, unref } from 'vue'; | 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 | import { Authority } from '/@/components/Authority'; | 13 | import { Authority } from '/@/components/Authority'; | 
| 9 | import { | 14 | import { | 
| 10 | deviceConfigDelete, | 15 | deviceConfigDelete, | 
| @@ -111,14 +116,6 @@ | @@ -111,14 +116,6 @@ | ||
| 111 | return hasPermission(ProductPermission.DELETE); | 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 | const getDropDownList = (record: ProfileRecord) => { | 119 | const getDropDownList = (record: ProfileRecord) => { | 
| 123 | const list = [ | 120 | const list = [ | 
| 124 | { | 121 | { | 
| @@ -163,12 +160,10 @@ | @@ -163,12 +160,10 @@ | ||
| 163 | }; | 160 | }; | 
| 164 | 161 | ||
| 165 | const handleShowDetail = (record: ProfileRecord) => { | 162 | const handleShowDetail = (record: ProfileRecord) => { | 
| 166 | - if (!unref(getHasDetailFlag)) return; | ||
| 167 | openDrawer(true, { record }); | 163 | openDrawer(true, { record }); | 
| 168 | }; | 164 | }; | 
| 169 | 165 | ||
| 170 | const handleUpdate = (record: ProfileRecord) => { | 166 | const handleUpdate = (record: ProfileRecord) => { | 
| 171 | - if (!unref(getHasUpdateFlag)) return; | ||
| 172 | openModal(true, { | 167 | openModal(true, { | 
| 173 | record, | 168 | record, | 
| 174 | isUpdate: true, | 169 | isUpdate: true, | 
| @@ -268,16 +263,18 @@ | @@ -268,16 +263,18 @@ | ||
| 268 | </template> | 263 | </template> | 
| 269 | <template class="ant-card-actions" #actions> | 264 | <template class="ant-card-actions" #actions> | 
| 270 | <Tooltip title="详情"> | 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 | @click.stop="handleShowDetail(item)" | 270 | @click.stop="handleShowDetail(item)" | 
| 275 | /> | 271 | /> | 
| 276 | </Tooltip> | 272 | </Tooltip> | 
| 277 | <Tooltip title="编辑"> | 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 | @click.stop="handleUpdate(item)" | 278 | @click.stop="handleUpdate(item)" | 
| 282 | /> | 279 | /> | 
| 283 | </Tooltip> | 280 | </Tooltip> | 
| @@ -308,7 +305,10 @@ | @@ -308,7 +305,10 @@ | ||
| 308 | 305 | ||
| 309 | <style lang="less" scoped> | 306 | <style lang="less" scoped> | 
| 310 | .profile-list:deep(.ant-image-img) { | 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 | </style> | 314 | </style> |