feat: xbutton
parent
d79b23c8a2
commit
bca13b1961
|
@ -0,0 +1,3 @@
|
||||||
|
import XButton from './src/XButton.vue'
|
||||||
|
|
||||||
|
export { XButton }
|
|
@ -0,0 +1,41 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { propTypes } from '@/utils/propTypes'
|
||||||
|
import { computed, useAttrs, PropType } from 'vue'
|
||||||
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
|
|
||||||
|
const { t } = useI18n() // 国际化
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: propTypes.bool.def(false),
|
||||||
|
loading: propTypes.bool.def(false),
|
||||||
|
preIcon: propTypes.string.def(''),
|
||||||
|
postIcon: propTypes.string.def(''),
|
||||||
|
iTitle: propTypes.string.def(''),
|
||||||
|
title: propTypes.string.def('按钮'),
|
||||||
|
type: propTypes.oneOf(['primary', 'success', 'warning', 'danger', 'info']).def('primary'),
|
||||||
|
link: propTypes.bool.def(false),
|
||||||
|
circle: propTypes.bool.def(false),
|
||||||
|
round: propTypes.bool.def(false),
|
||||||
|
plain: propTypes.bool.def(false),
|
||||||
|
onClick: { type: Function as PropType<(...args) => any>, default: null }
|
||||||
|
})
|
||||||
|
const getBindValue = computed(() => {
|
||||||
|
const delArr: string[] = ['title', 'preIcon', 'postIcon', 'onClick']
|
||||||
|
const attrs = useAttrs()
|
||||||
|
const obj = { ...attrs, ...props }
|
||||||
|
for (const key in obj) {
|
||||||
|
if (delArr.indexOf(key) !== -1) {
|
||||||
|
delete obj[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<el-button v-bind="getBindValue" @click="onClick">
|
||||||
|
<Icon :icon="preIcon" v-if="preIcon" class="mr-1px" />
|
||||||
|
{{ iTitle ? t(iTitle) : title }}
|
||||||
|
<Icon :icon="postIcon" v-if="postIcon" class="mr-1px" />
|
||||||
|
</el-button>
|
||||||
|
</template>
|
|
@ -18,34 +18,14 @@ const props = defineProps({
|
||||||
})
|
})
|
||||||
|
|
||||||
const getBindValue = computed(() => {
|
const getBindValue = computed(() => {
|
||||||
const delArr: string[] = ['title']
|
|
||||||
const attrs = useAttrs()
|
const attrs = useAttrs()
|
||||||
const obj = { ...attrs, ...props }
|
const obj = { ...attrs, ...props }
|
||||||
for (const key in obj) {
|
|
||||||
if (delArr.indexOf(key) !== -1) {
|
|
||||||
delete obj[key]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return obj
|
return obj
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<vxe-modal
|
<vxe-modal v-bind="getBindValue" destroy-on-close show-zoom resize transfer>
|
||||||
v-bind="getBindValue"
|
|
||||||
:width="width"
|
|
||||||
:height="height"
|
|
||||||
:title="title"
|
|
||||||
min-width="460"
|
|
||||||
min-height="320"
|
|
||||||
:loading="loading"
|
|
||||||
:fullscreen="fullscreen"
|
|
||||||
destroy-on-close
|
|
||||||
show-zoom
|
|
||||||
resize
|
|
||||||
transfer
|
|
||||||
:show-footer="showFooter"
|
|
||||||
>
|
|
||||||
<template v-if="slots.header" #header>
|
<template v-if="slots.header" #header>
|
||||||
<slot name="header"></slot>
|
<slot name="header"></slot>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { Table } from '@/components/Table'
|
||||||
import { Search } from '@/components/Search'
|
import { Search } from '@/components/Search'
|
||||||
import { Dialog } from '@/components/Dialog'
|
import { Dialog } from '@/components/Dialog'
|
||||||
import { XModal } from '@/components/XModal'
|
import { XModal } from '@/components/XModal'
|
||||||
|
import { XButton } from '@/components/XButton'
|
||||||
import { DictTag } from '@/components/DictTag'
|
import { DictTag } from '@/components/DictTag'
|
||||||
import { ContentWrap } from '@/components/ContentWrap'
|
import { ContentWrap } from '@/components/ContentWrap'
|
||||||
import { Descriptions } from '@/components/Descriptions'
|
import { Descriptions } from '@/components/Descriptions'
|
||||||
|
@ -16,6 +17,7 @@ export const setupGlobCom = (app: App<Element>): void => {
|
||||||
app.component('Search', Search)
|
app.component('Search', Search)
|
||||||
app.component('Dialog', Dialog)
|
app.component('Dialog', Dialog)
|
||||||
app.component('XModal', XModal)
|
app.component('XModal', XModal)
|
||||||
|
app.component('XButton', XButton)
|
||||||
app.component('DictTag', DictTag)
|
app.component('DictTag', DictTag)
|
||||||
app.component('ContentWrap', ContentWrap)
|
app.component('ContentWrap', ContentWrap)
|
||||||
app.component('Descriptions', Descriptions)
|
app.component('Descriptions', Descriptions)
|
||||||
|
|
|
@ -189,6 +189,7 @@ const filterFormSchema = (crudSchema: VxeCrudSchema[]): VxeFormItemProps[] => {
|
||||||
// 默认为 input
|
// 默认为 input
|
||||||
itemRender: itemRender,
|
itemRender: itemRender,
|
||||||
...schemaItem.form,
|
...schemaItem.form,
|
||||||
|
span: schemaItem.form?.span || 12,
|
||||||
field: schemaItem.field,
|
field: schemaItem.field,
|
||||||
title: schemaItem.form?.title || schemaItem.title
|
title: schemaItem.form?.title || schemaItem.title
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,38 +2,38 @@
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
|
<vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
|
||||||
<template #toolbar_buttons>
|
<template #toolbar_buttons>
|
||||||
<el-button type="primary" v-hasPermi="['system:post:create']" @click="handleCreate">
|
<XButton
|
||||||
<Icon icon="ep:zoom-in" class="mr-5px" /> {{ t('action.add') }}
|
preIcon="ep:zoom-in"
|
||||||
</el-button>
|
iTitle="action.add"
|
||||||
|
v-hasPermi="['system:post:create']"
|
||||||
|
@click="handleCreate()"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #status_default="{ row }">
|
<template #status_default="{ row }">
|
||||||
<DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
|
<DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
|
||||||
</template>
|
</template>
|
||||||
<template #action_default="{ row }">
|
<template #action_default="{ row }">
|
||||||
<el-button
|
<XButton
|
||||||
link
|
link
|
||||||
type="primary"
|
preIcon="ep:edit"
|
||||||
|
iTitle="action.edit"
|
||||||
v-hasPermi="['system:post:update']"
|
v-hasPermi="['system:post:update']"
|
||||||
@click="handleUpdate(row.id)"
|
@click="handleUpdate(row.id)"
|
||||||
>
|
/>
|
||||||
<Icon icon="ep:edit" class="mr-1px" /> {{ t('action.edit') }}
|
<XButton
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
link
|
link
|
||||||
type="primary"
|
preIcon="ep:view"
|
||||||
|
iTitle="action.detail"
|
||||||
v-hasPermi="['system:post:update']"
|
v-hasPermi="['system:post:update']"
|
||||||
@click="handleDetail(row)"
|
@click="handleDetail(row)"
|
||||||
>
|
/>
|
||||||
<Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }}
|
<XButton
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
link
|
link
|
||||||
type="primary"
|
preIcon="ep:delete"
|
||||||
|
iTitle="action.del"
|
||||||
v-hasPermi="['system:post:delete']"
|
v-hasPermi="['system:post:delete']"
|
||||||
@click="handleDelete(row.id)"
|
@click="handleDelete(row.id)"
|
||||||
>
|
/>
|
||||||
<Icon icon="ep:delete" class="mr-1px" /> {{ t('action.del') }}
|
|
||||||
</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</vxe-grid>
|
</vxe-grid>
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
|
@ -61,13 +61,18 @@
|
||||||
</Descriptions>
|
</Descriptions>
|
||||||
</template>
|
</template>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<vxe-button
|
<XButton
|
||||||
v-if="['create', 'update'].includes(actionType)"
|
v-if="['create', 'update'].includes(actionType)"
|
||||||
status="primary"
|
:loading="actionLoading"
|
||||||
|
iTitle="action.save"
|
||||||
@click="submitForm"
|
@click="submitForm"
|
||||||
:content="t('action.save')"
|
|
||||||
/>
|
/>
|
||||||
<vxe-button @click="dialogVisible = false" :content="t('dialog.close')" />
|
<XButton
|
||||||
|
v-if="['create', 'update'].includes(actionType)"
|
||||||
|
:loading="actionLoading"
|
||||||
|
iTitle="dialog.close"
|
||||||
|
@click="dialogVisible = false"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</XModal>
|
</XModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue