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 | 18 | }) |
| 19 | 19 | |
| 20 | 20 | const getBindValue = computed(() => { |
| 21 | - const delArr: string[] = ['title'] | |
| 22 | 21 | const attrs = useAttrs() |
| 23 | 22 | const obj = { ...attrs, ...props } |
| 24 | - for (const key in obj) { | |
| 25 | - if (delArr.indexOf(key) !== -1) { | |
| 26 | - delete obj[key] | |
| 27 | - } | |
| 28 | - } | |
| 29 | 23 | return obj |
| 30 | 24 | }) |
| 31 | 25 | </script> |
| 32 | 26 | |
| 33 | 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 | 29 | <template v-if="slots.header" #header> |
| 50 | 30 | <slot name="header"></slot> |
| 51 | 31 | </template> | ... | ... |
yudao-ui-admin-vue3/src/components/index.ts
| ... | ... | @@ -5,6 +5,7 @@ import { Table } from '@/components/Table' |
| 5 | 5 | import { Search } from '@/components/Search' |
| 6 | 6 | import { Dialog } from '@/components/Dialog' |
| 7 | 7 | import { XModal } from '@/components/XModal' |
| 8 | +import { XButton } from '@/components/XButton' | |
| 8 | 9 | import { DictTag } from '@/components/DictTag' |
| 9 | 10 | import { ContentWrap } from '@/components/ContentWrap' |
| 10 | 11 | import { Descriptions } from '@/components/Descriptions' |
| ... | ... | @@ -16,6 +17,7 @@ export const setupGlobCom = (app: App<Element>): void => { |
| 16 | 17 | app.component('Search', Search) |
| 17 | 18 | app.component('Dialog', Dialog) |
| 18 | 19 | app.component('XModal', XModal) |
| 20 | + app.component('XButton', XButton) | |
| 19 | 21 | app.component('DictTag', DictTag) |
| 20 | 22 | app.component('ContentWrap', ContentWrap) |
| 21 | 23 | app.component('Descriptions', Descriptions) | ... | ... |
yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts
| ... | ... | @@ -189,6 +189,7 @@ const filterFormSchema = (crudSchema: VxeCrudSchema[]): VxeFormItemProps[] => { |
| 189 | 189 | // 默认为 input |
| 190 | 190 | itemRender: itemRender, |
| 191 | 191 | ...schemaItem.form, |
| 192 | + span: schemaItem.form?.span || 12, | |
| 192 | 193 | field: schemaItem.field, |
| 193 | 194 | title: schemaItem.form?.title || schemaItem.title |
| 194 | 195 | } | ... | ... |
yudao-ui-admin-vue3/src/views/system/post/index.vue
| ... | ... | @@ -2,38 +2,38 @@ |
| 2 | 2 | <ContentWrap> |
| 3 | 3 | <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar"> |
| 4 | 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 | 11 | </template> |
| 9 | 12 | <template #status_default="{ row }"> |
| 10 | 13 | <DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" /> |
| 11 | 14 | </template> |
| 12 | 15 | <template #action_default="{ row }"> |
| 13 | - <el-button | |
| 16 | + <XButton | |
| 14 | 17 | link |
| 15 | - type="primary" | |
| 18 | + preIcon="ep:edit" | |
| 19 | + iTitle="action.edit" | |
| 16 | 20 | v-hasPermi="['system:post:update']" |
| 17 | 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 | 24 | link |
| 23 | - type="primary" | |
| 25 | + preIcon="ep:view" | |
| 26 | + iTitle="action.detail" | |
| 24 | 27 | v-hasPermi="['system:post:update']" |
| 25 | 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 | 31 | link |
| 31 | - type="primary" | |
| 32 | + preIcon="ep:delete" | |
| 33 | + iTitle="action.del" | |
| 32 | 34 | v-hasPermi="['system:post:delete']" |
| 33 | 35 | @click="handleDelete(row.id)" |
| 34 | - > | |
| 35 | - <Icon icon="ep:delete" class="mr-1px" /> {{ t('action.del') }} | |
| 36 | - </el-button> | |
| 36 | + /> | |
| 37 | 37 | </template> |
| 38 | 38 | </vxe-grid> |
| 39 | 39 | </ContentWrap> |
| ... | ... | @@ -61,13 +61,18 @@ |
| 61 | 61 | </Descriptions> |
| 62 | 62 | </template> |
| 63 | 63 | <template #footer> |
| 64 | - <vxe-button | |
| 64 | + <XButton | |
| 65 | 65 | v-if="['create', 'update'].includes(actionType)" |
| 66 | - status="primary" | |
| 66 | + :loading="actionLoading" | |
| 67 | + iTitle="action.save" | |
| 67 | 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 | 76 | </template> |
| 72 | 77 | </XModal> |
| 73 | 78 | </template> | ... | ... |