Commit bca13b1961dedbbf6d37fc3aeda6fb4d1e3e010b
1 parent
d79b23c8
feat: xbutton
Showing
6 changed files
with
75 additions
and
43 deletions
yudao-ui-admin-vue3/src/components/XButton/index.ts
0 → 100644
yudao-ui-admin-vue3/src/components/XButton/src/XButton.vue
0 → 100644
| 1 | +<script setup lang="ts"> | ||
| 2 | +import { propTypes } from '@/utils/propTypes' | ||
| 3 | +import { computed, useAttrs, PropType } from 'vue' | ||
| 4 | +import { useI18n } from '@/hooks/web/useI18n' | ||
| 5 | + | ||
| 6 | +const { t } = useI18n() // 国际化 | ||
| 7 | + | ||
| 8 | +const props = defineProps({ | ||
| 9 | + modelValue: propTypes.bool.def(false), | ||
| 10 | + loading: propTypes.bool.def(false), | ||
| 11 | + preIcon: propTypes.string.def(''), | ||
| 12 | + postIcon: propTypes.string.def(''), | ||
| 13 | + iTitle: propTypes.string.def(''), | ||
| 14 | + title: propTypes.string.def('按钮'), | ||
| 15 | + type: propTypes.oneOf(['primary', 'success', 'warning', 'danger', 'info']).def('primary'), | ||
| 16 | + link: propTypes.bool.def(false), | ||
| 17 | + circle: propTypes.bool.def(false), | ||
| 18 | + round: propTypes.bool.def(false), | ||
| 19 | + plain: propTypes.bool.def(false), | ||
| 20 | + onClick: { type: Function as PropType<(...args) => any>, default: null } | ||
| 21 | +}) | ||
| 22 | +const getBindValue = computed(() => { | ||
| 23 | + const delArr: string[] = ['title', 'preIcon', 'postIcon', 'onClick'] | ||
| 24 | + const attrs = useAttrs() | ||
| 25 | + const obj = { ...attrs, ...props } | ||
| 26 | + for (const key in obj) { | ||
| 27 | + if (delArr.indexOf(key) !== -1) { | ||
| 28 | + delete obj[key] | ||
| 29 | + } | ||
| 30 | + } | ||
| 31 | + return obj | ||
| 32 | +}) | ||
| 33 | +</script> | ||
| 34 | + | ||
| 35 | +<template> | ||
| 36 | + <el-button v-bind="getBindValue" @click="onClick"> | ||
| 37 | + <Icon :icon="preIcon" v-if="preIcon" class="mr-1px" /> | ||
| 38 | + {{ iTitle ? t(iTitle) : title }} | ||
| 39 | + <Icon :icon="postIcon" v-if="postIcon" class="mr-1px" /> | ||
| 40 | + </el-button> | ||
| 41 | +</template> |
yudao-ui-admin-vue3/src/components/XModal/src/XModal.vue
| @@ -18,34 +18,14 @@ const props = defineProps({ | @@ -18,34 +18,14 @@ const props = defineProps({ | ||
| 18 | }) | 18 | }) |
| 19 | 19 | ||
| 20 | const getBindValue = computed(() => { | 20 | const getBindValue = computed(() => { |
| 21 | - const delArr: string[] = ['title'] | ||
| 22 | const attrs = useAttrs() | 21 | const attrs = useAttrs() |
| 23 | const obj = { ...attrs, ...props } | 22 | const obj = { ...attrs, ...props } |
| 24 | - for (const key in obj) { | ||
| 25 | - if (delArr.indexOf(key) !== -1) { | ||
| 26 | - delete obj[key] | ||
| 27 | - } | ||
| 28 | - } | ||
| 29 | return obj | 23 | return obj |
| 30 | }) | 24 | }) |
| 31 | </script> | 25 | </script> |
| 32 | 26 | ||
| 33 | <template> | 27 | <template> |
| 34 | - <vxe-modal | ||
| 35 | - v-bind="getBindValue" | ||
| 36 | - :width="width" | ||
| 37 | - :height="height" | ||
| 38 | - :title="title" | ||
| 39 | - min-width="460" | ||
| 40 | - min-height="320" | ||
| 41 | - :loading="loading" | ||
| 42 | - :fullscreen="fullscreen" | ||
| 43 | - destroy-on-close | ||
| 44 | - show-zoom | ||
| 45 | - resize | ||
| 46 | - transfer | ||
| 47 | - :show-footer="showFooter" | ||
| 48 | - > | 28 | + <vxe-modal v-bind="getBindValue" destroy-on-close show-zoom resize transfer> |
| 49 | <template v-if="slots.header" #header> | 29 | <template v-if="slots.header" #header> |
| 50 | <slot name="header"></slot> | 30 | <slot name="header"></slot> |
| 51 | </template> | 31 | </template> |
yudao-ui-admin-vue3/src/components/index.ts
| @@ -5,6 +5,7 @@ import { Table } from '@/components/Table' | @@ -5,6 +5,7 @@ import { Table } from '@/components/Table' | ||
| 5 | import { Search } from '@/components/Search' | 5 | import { Search } from '@/components/Search' |
| 6 | import { Dialog } from '@/components/Dialog' | 6 | import { Dialog } from '@/components/Dialog' |
| 7 | import { XModal } from '@/components/XModal' | 7 | import { XModal } from '@/components/XModal' |
| 8 | +import { XButton } from '@/components/XButton' | ||
| 8 | import { DictTag } from '@/components/DictTag' | 9 | import { DictTag } from '@/components/DictTag' |
| 9 | import { ContentWrap } from '@/components/ContentWrap' | 10 | import { ContentWrap } from '@/components/ContentWrap' |
| 10 | import { Descriptions } from '@/components/Descriptions' | 11 | import { Descriptions } from '@/components/Descriptions' |
| @@ -16,6 +17,7 @@ export const setupGlobCom = (app: App<Element>): void => { | @@ -16,6 +17,7 @@ export const setupGlobCom = (app: App<Element>): void => { | ||
| 16 | app.component('Search', Search) | 17 | app.component('Search', Search) |
| 17 | app.component('Dialog', Dialog) | 18 | app.component('Dialog', Dialog) |
| 18 | app.component('XModal', XModal) | 19 | app.component('XModal', XModal) |
| 20 | + app.component('XButton', XButton) | ||
| 19 | app.component('DictTag', DictTag) | 21 | app.component('DictTag', DictTag) |
| 20 | app.component('ContentWrap', ContentWrap) | 22 | app.component('ContentWrap', ContentWrap) |
| 21 | app.component('Descriptions', Descriptions) | 23 | app.component('Descriptions', Descriptions) |
yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts
| @@ -189,6 +189,7 @@ const filterFormSchema = (crudSchema: VxeCrudSchema[]): VxeFormItemProps[] => { | @@ -189,6 +189,7 @@ const filterFormSchema = (crudSchema: VxeCrudSchema[]): VxeFormItemProps[] => { | ||
| 189 | // 默认为 input | 189 | // 默认为 input |
| 190 | itemRender: itemRender, | 190 | itemRender: itemRender, |
| 191 | ...schemaItem.form, | 191 | ...schemaItem.form, |
| 192 | + span: schemaItem.form?.span || 12, | ||
| 192 | field: schemaItem.field, | 193 | field: schemaItem.field, |
| 193 | title: schemaItem.form?.title || schemaItem.title | 194 | title: schemaItem.form?.title || schemaItem.title |
| 194 | } | 195 | } |
yudao-ui-admin-vue3/src/views/system/post/index.vue
| @@ -2,38 +2,38 @@ | @@ -2,38 +2,38 @@ | ||
| 2 | <ContentWrap> | 2 | <ContentWrap> |
| 3 | <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar"> | 3 | <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar"> |
| 4 | <template #toolbar_buttons> | 4 | <template #toolbar_buttons> |
| 5 | - <el-button type="primary" v-hasPermi="['system:post:create']" @click="handleCreate"> | ||
| 6 | - <Icon icon="ep:zoom-in" class="mr-5px" /> {{ t('action.add') }} | ||
| 7 | - </el-button> | 5 | + <XButton |
| 6 | + preIcon="ep:zoom-in" | ||
| 7 | + iTitle="action.add" | ||
| 8 | + v-hasPermi="['system:post:create']" | ||
| 9 | + @click="handleCreate()" | ||
| 10 | + /> | ||
| 8 | </template> | 11 | </template> |
| 9 | <template #status_default="{ row }"> | 12 | <template #status_default="{ row }"> |
| 10 | <DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" /> | 13 | <DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" /> |
| 11 | </template> | 14 | </template> |
| 12 | <template #action_default="{ row }"> | 15 | <template #action_default="{ row }"> |
| 13 | - <el-button | 16 | + <XButton |
| 14 | link | 17 | link |
| 15 | - type="primary" | 18 | + preIcon="ep:edit" |
| 19 | + iTitle="action.edit" | ||
| 16 | v-hasPermi="['system:post:update']" | 20 | v-hasPermi="['system:post:update']" |
| 17 | @click="handleUpdate(row.id)" | 21 | @click="handleUpdate(row.id)" |
| 18 | - > | ||
| 19 | - <Icon icon="ep:edit" class="mr-1px" /> {{ t('action.edit') }} | ||
| 20 | - </el-button> | ||
| 21 | - <el-button | 22 | + /> |
| 23 | + <XButton | ||
| 22 | link | 24 | link |
| 23 | - type="primary" | 25 | + preIcon="ep:view" |
| 26 | + iTitle="action.detail" | ||
| 24 | v-hasPermi="['system:post:update']" | 27 | v-hasPermi="['system:post:update']" |
| 25 | @click="handleDetail(row)" | 28 | @click="handleDetail(row)" |
| 26 | - > | ||
| 27 | - <Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }} | ||
| 28 | - </el-button> | ||
| 29 | - <el-button | 29 | + /> |
| 30 | + <XButton | ||
| 30 | link | 31 | link |
| 31 | - type="primary" | 32 | + preIcon="ep:delete" |
| 33 | + iTitle="action.del" | ||
| 32 | v-hasPermi="['system:post:delete']" | 34 | v-hasPermi="['system:post:delete']" |
| 33 | @click="handleDelete(row.id)" | 35 | @click="handleDelete(row.id)" |
| 34 | - > | ||
| 35 | - <Icon icon="ep:delete" class="mr-1px" /> {{ t('action.del') }} | ||
| 36 | - </el-button> | 36 | + /> |
| 37 | </template> | 37 | </template> |
| 38 | </vxe-grid> | 38 | </vxe-grid> |
| 39 | </ContentWrap> | 39 | </ContentWrap> |
| @@ -61,13 +61,18 @@ | @@ -61,13 +61,18 @@ | ||
| 61 | </Descriptions> | 61 | </Descriptions> |
| 62 | </template> | 62 | </template> |
| 63 | <template #footer> | 63 | <template #footer> |
| 64 | - <vxe-button | 64 | + <XButton |
| 65 | v-if="['create', 'update'].includes(actionType)" | 65 | v-if="['create', 'update'].includes(actionType)" |
| 66 | - status="primary" | 66 | + :loading="actionLoading" |
| 67 | + iTitle="action.save" | ||
| 67 | @click="submitForm" | 68 | @click="submitForm" |
| 68 | - :content="t('action.save')" | ||
| 69 | /> | 69 | /> |
| 70 | - <vxe-button @click="dialogVisible = false" :content="t('dialog.close')" /> | 70 | + <XButton |
| 71 | + v-if="['create', 'update'].includes(actionType)" | ||
| 72 | + :loading="actionLoading" | ||
| 73 | + iTitle="dialog.close" | ||
| 74 | + @click="dialogVisible = false" | ||
| 75 | + /> | ||
| 71 | </template> | 76 | </template> |
| 72 | </XModal> | 77 | </XModal> |
| 73 | </template> | 78 | </template> |