修改setProps,重新赋值的时候保留旧值,如果有新的值则覆盖,去掉option.height使用动态计算

pull/120/head
puhui999 2023-04-13 16:47:08 +08:00
parent 6fb5f6f59e
commit 7be96dea0b
1 changed files with 7 additions and 8 deletions

View File

@ -1,11 +1,11 @@
<template> <template>
<VxeGrid v-bind="getProps" ref="xGrid" :class="`${prefixCls}`" class="xtable-scrollbar"> <VxeGrid ref="xGrid" :class="`${prefixCls}`" class="xtable-scrollbar" v-bind="getProps">
<template #[item]="data" v-for="item in Object.keys($slots)" :key="item"> <template v-for="item in Object.keys($slots)" :key="item" #[item]="data">
<slot :name="item" v-bind="data || {}"></slot> <slot :name="item" v-bind="data || {}"></slot>
</template> </template>
</VxeGrid> </VxeGrid>
</template> </template>
<script setup lang="ts" name="XTable"> <script lang="ts" name="XTable" setup>
import { PropType } from 'vue' import { PropType } from 'vue'
import { SizeType, VxeGridInstance } from 'vxe-table' import { SizeType, VxeGridInstance } from 'vxe-table'
import { useAppStore } from '@/store/modules/app' import { useAppStore } from '@/store/modules/app'
@ -37,7 +37,6 @@ const removeStyles = () => {
allsuspects[i].getAttribute(targetattr) != null && allsuspects[i].getAttribute(targetattr) != null &&
allsuspects[i].getAttribute(targetattr)?.indexOf(filename) != -1 allsuspects[i].getAttribute(targetattr)?.indexOf(filename) != -1
) { ) {
console.log(allsuspects[i], 'node')
allsuspects[i].parentNode?.removeChild(allsuspects[i]) allsuspects[i].parentNode?.removeChild(allsuspects[i])
} }
} }
@ -90,7 +89,6 @@ const innerProps = ref<Partial<XTableProps>>()
const getProps = computed(() => { const getProps = computed(() => {
const options = innerProps.value || props.options const options = innerProps.value || props.options
options.size = currentSize as any options.size = currentSize as any
options.height = 700
getOptionInitConfig(options) getOptionInitConfig(options)
getColumnsConfig(options) getColumnsConfig(options)
getProxyConfig(options) getProxyConfig(options)
@ -254,7 +252,7 @@ const getPageConfig = (options: XTableProps) => {
background: false, // background: false, //
perfect: false, // perfect: false, //
pageSize: 10, // pageSize: 10, //
pagerCount: 7, // pagerCount: 5, //
autoHidden: false, // autoHidden: false, //
pageSizes: [5, 10, 20, 30, 50, 100], // pageSizes: [5, 10, 20, 30, 50, 100], //
layouts: [ layouts: [
@ -272,7 +270,7 @@ const getPageConfig = (options: XTableProps) => {
} }
} }
// tool bar // toolbar
const getToolBarConfig = (options: XTableProps) => { const getToolBarConfig = (options: XTableProps) => {
const { toolBar, toolbarConfig, topActionSlots } = options const { toolBar, toolbarConfig, topActionSlots } = options
if (toolbarConfig) return if (toolbarConfig) return
@ -421,7 +419,8 @@ const getCheckboxRecords = () => {
return g.getCheckboxRecords(false) return g.getCheckboxRecords(false)
} }
const setProps = (prop: Partial<XTableProps>) => { const setProps = (prop: Partial<XTableProps>) => {
innerProps.value = { ...unref(innerProps), ...prop } //
innerProps.value = { ...innerProps.value, ...prop, ...props.options }
} }
defineExpose({ reload, Ref: xGrid, getSearchData, deleteData, exportList }) defineExpose({ reload, Ref: xGrid, getSearchData, deleteData, exportList })