perf: vxe

This commit is contained in:
xingyu4j 2022-11-12 17:33:48 +08:00
parent 16b3e910e4
commit 199d3ebb69
6 changed files with 22 additions and 25 deletions

View File

@ -1,4 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import dayjs from 'dayjs'
import { ElCollapseTransition, ElDescriptions, ElDescriptionsItem, ElTooltip } from 'element-plus' import { ElCollapseTransition, ElDescriptions, ElDescriptionsItem, ElTooltip } from 'element-plus'
import { useDesign } from '@/hooks/web/useDesign' import { useDesign } from '@/hooks/web/useDesign'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
@ -111,7 +112,13 @@ const toggleClick = () => {
</template> </template>
<template #default> <template #default>
<slot :name="item.field" :row="data">{{ data[item.field] }}</slot> <slot v-if="item.dateFormat">
{{ dayjs(data[item.field]).format(item.dateFormat) }}
</slot>
<slot v-else-if="item.dictType">
<DictTag :type="item.dictType" :value="data[item.field]" />
</slot>
<slot v-else :name="item.field" :row="data">{{ data[item.field] }}</slot>
</template> </template>
</ElDescriptionsItem> </ElDescriptionsItem>
</ElDescriptions> </ElDescriptions>

View File

@ -165,6 +165,7 @@ const filterTableSchema = (crudSchema: VxeCrudSchema): VxeGridPropTypes.Columns
field: schemaItem.field, field: schemaItem.field,
title: schemaItem.table?.title || schemaItem.title title: schemaItem.table?.title || schemaItem.title
} }
tableSchemaItem.showOverflow = 'tooltip'
if (schemaItem?.formatter) { if (schemaItem?.formatter) {
tableSchemaItem.formatter = schemaItem.formatter tableSchemaItem.formatter = schemaItem.formatter
} }
@ -240,6 +241,15 @@ const filterDescriptionsSchema = (crudSchema: VxeCrudSchema): DescriptionsSchema
field: schemaItem.field, field: schemaItem.field,
label: schemaItem.detail?.label || schemaItem.title label: schemaItem.detail?.label || schemaItem.title
} }
if (schemaItem.dictType) {
descriptionsSchemaItem.dictType = schemaItem.dictType
}
if (schemaItem.detail?.dateFormat || schemaItem.formatter == 'formatDate') {
// descriptionsSchemaItem.dateFormat = schemaItem.detail.dateFormat
// ? schemaItem?.detail?.dateFormat
// : 'YYYY-MM-DD HH:mm:ss'
descriptionsSchemaItem.dateFormat = 'YYYY-MM-DD HH:mm:ss'
}
descriptionsSchema.push(descriptionsSchemaItem) descriptionsSchema.push(descriptionsSchemaItem)
} }

View File

@ -43,10 +43,6 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
isCurrent: true, // 当鼠标点击行时,是否要高亮当前行 isCurrent: true, // 当鼠标点击行时,是否要高亮当前行
isHover: true // 当鼠标移到行时,是否要高亮当前行 isHover: true // 当鼠标移到行时,是否要高亮当前行
}, },
showOverflow: 'tooltip', // 当内容溢出时显示为省略号
tooltipConfig: {
showAll: true // 开启全表工具提示
},
toolbarConfig: { toolbarConfig: {
custom: true, custom: true,
slots: { buttons: 'toolbar_buttons' } slots: { buttons: 'toolbar_buttons' }

View File

@ -8,4 +8,6 @@ export interface DescriptionsSchema {
labelAlign?: 'left' | 'center' | 'right' labelAlign?: 'left' | 'center' | 'right'
className?: string className?: string
labelClassName?: string labelClassName?: string
dateFormat?: string
dictType?: string
} }

View File

@ -46,14 +46,7 @@
v-if="actionType === 'detail'" v-if="actionType === 'detail'"
:schema="allSchemas.detailSchema" :schema="allSchemas.detailSchema"
:data="detailRef" :data="detailRef"
> />
<template #type="{ row }">
<DictTag :type="DICT_TYPE.SYSTEM_ERROR_CODE_TYPE" :value="row.type" />
</template>
<template #createTime="{ row }">
<span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
</template>
</Descriptions>
</template> </template>
<!-- 操作按钮 --> <!-- 操作按钮 -->
<template #footer> <template #footer>
@ -71,8 +64,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, unref } from 'vue' import { ref, unref } from 'vue'
import dayjs from 'dayjs'
import { DICT_TYPE } from '@/utils/dict'
import type { ErrorCodeVO } from '@/api/system/errorCode/types' import type { ErrorCodeVO } from '@/api/system/errorCode/types'
import { rules, allSchemas } from './errorCode.data' import { rules, allSchemas } from './errorCode.data'
import * as ErrorCodeApi from '@/api/system/errorCode' import * as ErrorCodeApi from '@/api/system/errorCode'

View File

@ -45,14 +45,7 @@
v-if="actionType === 'detail'" v-if="actionType === 'detail'"
:schema="allSchemas.detailSchema" :schema="allSchemas.detailSchema"
:data="detailRef" :data="detailRef"
> />
<template #status="{ row }">
<DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
</template>
<template #createTime="{ row }">
<span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
</template>
</Descriptions>
</template> </template>
<template #footer> <template #footer>
<XButton <XButton
@ -68,8 +61,6 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, unref } from 'vue' import { ref, unref } from 'vue'
import dayjs from 'dayjs'
import { DICT_TYPE } from '@/utils/dict'
import * as PostApi from '@/api/system/post' import * as PostApi from '@/api/system/post'
import { PostVO } from '@/api/system/post/types' import { PostVO } from '@/api/system/post/types'
import { rules, allSchemas } from './post.data' import { rules, allSchemas } from './post.data'