mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 15:51:52 +08:00
perf: vxe demo
This commit is contained in:
parent
a95694ae6b
commit
8917dcf6bf
@ -103,6 +103,9 @@ VXETable.setup({
|
|||||||
input: {
|
input: {
|
||||||
clearable: true
|
clearable: true
|
||||||
},
|
},
|
||||||
|
form: {
|
||||||
|
titleColon: true // 是否显示标题冒号
|
||||||
|
},
|
||||||
modal: {
|
modal: {
|
||||||
width: 600, // 窗口的宽度
|
width: 600, // 窗口的宽度
|
||||||
height: 400, // 窗口的高度
|
height: 400, // 窗口的高度
|
||||||
@ -124,6 +127,14 @@ VXETable.setup({
|
|||||||
: XEUtils.toFormatString(XEUtils.get(enUS, key), args)
|
: XEUtils.toFormatString(XEUtils.get(enUS, key), args)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// 格式金额,默认2位数
|
||||||
|
VXETable.formats.add('formatAmount', ({ cellValue }, digits = 2) => {
|
||||||
|
return XEUtils.commafy(XEUtils.toNumber(cellValue), { digits })
|
||||||
|
})
|
||||||
|
// 格式日期,默认 yyyy-MM-dd HH:mm:ss
|
||||||
|
VXETable.formats.add('formatDate', ({ cellValue }, format = 'yyyy-MM-dd HH:mm:ss') => {
|
||||||
|
return XEUtils.toDateString(cellValue, format)
|
||||||
|
})
|
||||||
export const setupVxeTable = (app: App<Element>) => {
|
export const setupVxeTable = (app: App<Element>) => {
|
||||||
// 表格功能
|
// 表格功能
|
||||||
app.use(Filter).use(Edit).use(Menu).use(Export).use(Keyboard).use(Validator)
|
app.use(Filter).use(Edit).use(Menu).use(Export).use(Keyboard).use(Validator)
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, ref } from 'vue'
|
import { reactive, ref } from 'vue'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import XEUtils from 'xe-utils'
|
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { VxeFormEvents, VxeFormItemProps, VxeGrid, VxeGridInstance, VxeGridProps } from 'vxe-table'
|
import {
|
||||||
|
VxeFormEvents,
|
||||||
|
VxeFormInstance,
|
||||||
|
VxeFormItemProps,
|
||||||
|
VxeGrid,
|
||||||
|
VxeGridInstance,
|
||||||
|
VxeGridProps
|
||||||
|
} from 'vxe-table'
|
||||||
import * as PostApi from '@/api/system/post'
|
import * as PostApi from '@/api/system/post'
|
||||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||||
import { ContentWrap } from '@/components/ContentWrap'
|
import { ContentWrap } from '@/components/ContentWrap'
|
||||||
@ -14,6 +20,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
|||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
|
|
||||||
const xGrid = ref<VxeGridInstance>()
|
const xGrid = ref<VxeGridInstance>()
|
||||||
|
const xForm = ref<VxeFormInstance>()
|
||||||
const dialogVisible = ref(false) // 是否显示弹出层
|
const dialogVisible = ref(false) // 是否显示弹出层
|
||||||
const dialogTitle = ref('edit') // 弹出层标题
|
const dialogTitle = ref('edit') // 弹出层标题
|
||||||
const actionType = ref('') // 操作按钮的类型
|
const actionType = ref('') // 操作按钮的类型
|
||||||
@ -93,9 +100,7 @@ const gridOptions = reactive<VxeGridProps>({
|
|||||||
title: t('common.createTime'),
|
title: t('common.createTime'),
|
||||||
width: 160,
|
width: 160,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
formatter({ cellValue }) {
|
formatter: 'formatDate'
|
||||||
return XEUtils.toDateString(cellValue, 'yyyy-MM-dd HH:ss:mm')
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'action',
|
field: 'action',
|
||||||
@ -203,6 +208,8 @@ const handleDetail = (row: PostVO) => {
|
|||||||
}
|
}
|
||||||
// 新增操作
|
// 新增操作
|
||||||
const handleCreate = () => {
|
const handleCreate = () => {
|
||||||
|
const $form = xForm.value
|
||||||
|
$form?.reset()
|
||||||
setDialogTile('create')
|
setDialogTile('create')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,11 +315,11 @@ const submitForm: VxeFormEvents.Submit = async () => {
|
|||||||
<template #default>
|
<template #default>
|
||||||
<!-- 对话框(添加 / 修改) -->
|
<!-- 对话框(添加 / 修改) -->
|
||||||
<vxe-form
|
<vxe-form
|
||||||
|
ref="xForm"
|
||||||
v-if="['create', 'update'].includes(actionType)"
|
v-if="['create', 'update'].includes(actionType)"
|
||||||
:data="formData"
|
:data="formData"
|
||||||
:items="formItems"
|
:items="formItems"
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
titleColon
|
|
||||||
@submit="submitForm"
|
@submit="submitForm"
|
||||||
/>
|
/>
|
||||||
<Descriptions
|
<Descriptions
|
||||||
|
Loading…
Reference in New Issue
Block a user