| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- <template>
- <vxe-grid class="wrapper" v-bind="props.gridOptions" ref="gridRef" v-fullscreen>
- <template #form>
- <Search
- v-if="props?.searchConfig && props.searchConfig.enable && props.searchConfig?.fields && props.searchConfig?.data"
- :fields="props.searchConfig?.fields"
- :data="props.searchConfig?.data"
- v-bind="props.searchConfig"
- @reset="handleReset"
- @search="handleSearch"
- >
- <template #searchRight>
- <slot name="searchRight"></slot>
- </template>
- </Search>
- <!-- <IndexData />-->
- </template>
- <template #top>
- <div class="top-main">
- <div class="top-top" v-if="$slots.toolbarTop">
- <a-space v-if="props?.toolbarTopConfig && props?.toolbarTopConfig.enable" style="margin-right: 8px">
- <a-button v-for="(btn, idx) in props?.toolbarTopConfig.buttons" :key="btn.code" size="middle" v-bind="btn.props">{{ btn.title }}</a-button>
- </a-space>
- <slot name="toolbarTop"></slot>
- </div>
- <div class="top-bottom">
- <div class="top-left" v-if="props?.toolbarConfig && props?.toolbarConfig.enable">
- <Toolbar :toolbarConfig="props.toolbarConfig">
- <slot name="toolbarLeft"></slot>
- </Toolbar>
- </div>
- <div class="top-right" v-if="props?.toolbarConfig && props?.toolbarConfig.enable">
- <a-tooltip placement="top">
- <template #title>
- <span>刷新</span>
- </template>
- <a-button type="text" size="small" @click="handleRefresh">
- <ReloadOutlined />
- </a-button>
- </a-tooltip>
- <a-tooltip placement="top" v-if="isZoom">
- <template #title>
- <span>还原</span>
- </template>
- <a-button type="text" size="small" @click="toggleFullscreen">
- <FullscreenExitOutlined />
- </a-button>
- </a-tooltip>
- <a-tooltip placement="top" v-if="!isZoom">
- <template #title>
- <span>全屏</span>
- </template>
- <a-button type="text" size="small" @click="toggleFullscreen">
- <FullscreenOutlined />
- </a-button>
- </a-tooltip>
- </div>
- </div>
- </div>
- </template>
- <template #pager>
- <div class="pager" v-if="props?.pagerConfig && props.pagerConfig.enable">
- <Pagination :pagerConfig="props.pagerConfig" />
- </div>
- </template>
- <template #bottom>
- <slot name="bottom" />
- </template>
- <template #empty>
- <div class="empty">
- <bs-empty />
- </div>
- </template>
- <!-- 自定义列插槽 -->
- <template v-for="(name, idx) in slotCols" #[name]="scope" :key="idx">
- <slot :name="name" v-bind="scope || {}" />
- </template>
- </vxe-grid>
- </template>
- <script setup>
- import { nextTick, onMounted, ref, useSlots } from 'vue';
- import Search from './component/search/index.vue';
- import Pagination from './component/pagination/index.vue';
- import Toolbar from './component/toolbar/index.vue';
- import IndexData from './component/indexData/index.vue';
- import { mapValues, has, isString } from 'lodash';
- const props = defineProps(['gridOptions', 'searchConfig', 'pagerConfig', 'toolbarConfig', 'getGridRef', 'mounted', 'toolbarTopConfig']);
- const $slots = useSlots();
- const gridRef = ref(null);
- const isZoom = ref(false);
- const slotCols = ref([]);
- const setSlotsCols = () => {
- slotCols.value = [];
- props.gridOptions.columns.forEach((v) => {
- if (has(v, 'slots')) {
- mapValues(v.slots, (value, key) => {
- if (isString(value)) {
- slotCols.value.push(value);
- }
- });
- }
- });
- };
- const handleReset = () => {};
- const handleSearch = () => {};
- // 刷新回调
- const handleRefresh = () => {
- props.toolbarConfig.onRefresh && props.toolbarConfig.onRefresh();
- };
- onMounted(() => {
- setSlotsCols();
- nextTick(() => {
- props.getGridRef && props.getGridRef(gridRef.value);
- props.mounted && props.mounted(gridRef.value);
- });
- });
- const toggleFullscreen = () => {
- gridRef.value.zoom().then((zoom) => {
- isZoom.value = zoom;
- });
- };
- defineExpose({ gridRef });
- </script>
- <style lang="scss" scoped>
- .wrapper {
- width: 100%;
- height: 100%;
- .top-main {
- width: 100%;
- background: #fff;
- .top-top {
- padding: 10px 20px;
- }
- .top-bottom {
- padding: 0 20px 10px 20px;
- background: white;
- display: flex;
- align-items: center;
- .top-left {
- flex: 1;
- }
- .top-right {
- display: flex;
- justify-content: flex-end;
- align-items: center;
- }
- }
- }
- .pager {
- width: 100%;
- display: flex;
- flex-direction: row;
- justify-content: flex-end;
- align-items: center;
- padding: 0 10px 10px 10px;
- background: white;
- border-radius: 0 0 10px 10px;
- :deep(.ant-select-in-form-item) {
- width: auto !important;
- }
- }
- :deep(.vxe-grid--table-container) {
- background: white;
- //border-radius: 0 0 10px 10px;
- padding: 0 20px 20px 20px;
- }
- .empty {
- padding: 20px;
- }
- }
- </style>
|