2023-06-28 21:35:03 +08:00
|
|
|
|
<template>
|
2023-12-12 23:31:53 +08:00
|
|
|
|
<div>
|
2023-12-13 14:01:13 +08:00
|
|
|
|
<transition name="el-zoom-in-top">
|
|
|
|
|
|
<!-- 查询表单 -->
|
2023-12-29 16:48:15 +08:00
|
|
|
|
<SearchForm v-if="isShowSearch" :items="tableSearchItems" v-model="queryForm" :search="search" :reset="reset" :search-col="searchCol">
|
2023-12-13 14:01:13 +08:00
|
|
|
|
<!-- 遍历父组件传入的 solts 透传给子组件 -->
|
|
|
|
|
|
<template v-for="(_, key) in useSlots()" v-slot:[key]>
|
|
|
|
|
|
<slot :name="key"></slot>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</SearchForm>
|
|
|
|
|
|
</transition>
|
2023-06-28 21:35:03 +08:00
|
|
|
|
|
2023-12-14 13:05:21 +08:00
|
|
|
|
<div class="card">
|
2023-12-12 23:31:53 +08:00
|
|
|
|
<div class="table-main">
|
|
|
|
|
|
<!-- 表格头部 操作按钮 -->
|
|
|
|
|
|
<div class="table-header">
|
|
|
|
|
|
<div class="header-button-lf">
|
|
|
|
|
|
<slot name="tableHeader" />
|
2023-06-28 21:35:03 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2023-12-12 23:31:53 +08:00
|
|
|
|
<div v-if="toolButton" class="header-button-ri">
|
|
|
|
|
|
<slot name="toolButton">
|
2023-12-16 17:41:15 +08:00
|
|
|
|
<div class="tool-button">
|
|
|
|
|
|
<!-- 简易单个搜索项 -->
|
|
|
|
|
|
<div v-if="nowSearchItem" class="simple-search-form">
|
|
|
|
|
|
<el-dropdown v-if="searchItems?.length > 1">
|
2023-12-19 19:23:33 +08:00
|
|
|
|
<SvgIcon :size="16" name="CaretBottom" class="mr4 mt6 simple-search-form-btn" />
|
2023-12-16 17:41:15 +08:00
|
|
|
|
<template #dropdown>
|
|
|
|
|
|
<el-dropdown-menu>
|
|
|
|
|
|
<el-dropdown-item
|
|
|
|
|
|
v-for="searchItem in searchItems"
|
|
|
|
|
|
:key="searchItem.prop"
|
|
|
|
|
|
@click="changeSimpleFormItem(searchItem)"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ searchItem.label }}
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="simple-search-form-label mt5">
|
|
|
|
|
|
<el-text truncated tag="b">{{ `${nowSearchItem?.label} : ` }}</el-text>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item style="width: 200px" :key="nowSearchItem.prop">
|
2023-12-20 23:01:51 +08:00
|
|
|
|
<SearchFormItem
|
|
|
|
|
|
@keyup.enter.native="searchFormItemKeyUpEnter"
|
|
|
|
|
|
v-if="!nowSearchItem.slot"
|
|
|
|
|
|
:item="nowSearchItem"
|
2023-12-29 16:48:15 +08:00
|
|
|
|
v-model="queryForm[nowSearchItem.prop]"
|
2023-12-20 23:01:51 +08:00
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<slot @keyup.enter.native="searchFormItemKeyUpEnter" v-else :name="nowSearchItem.slot"></slot>
|
2023-12-16 17:41:15 +08:00
|
|
|
|
</el-form-item>
|
2023-12-12 23:31:53 +08:00
|
|
|
|
</div>
|
2023-12-16 17:41:15 +08:00
|
|
|
|
|
|
|
|
|
|
<div>
|
2023-12-17 14:38:53 +08:00
|
|
|
|
<el-button v-if="showToolButton('search') && searchItems?.length" icon="Search" circle @click="search" />
|
2023-12-16 17:41:15 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- <el-button v-if="showToolButton('refresh')" icon="Refresh" circle @click="execQuery()" /> -->
|
|
|
|
|
|
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
v-if="showToolButton('search') && searchItems?.length > 1"
|
|
|
|
|
|
:icon="isShowSearch ? 'ArrowDown' : 'ArrowUp'"
|
|
|
|
|
|
circle
|
|
|
|
|
|
@click="isShowSearch = !isShowSearch"
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<el-popover
|
|
|
|
|
|
placement="bottom"
|
|
|
|
|
|
title="表格配置"
|
|
|
|
|
|
popper-style="max-height: 550px; overflow: auto; max-width: 450px"
|
|
|
|
|
|
width="auto"
|
|
|
|
|
|
trigger="click"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div v-for="(item, index) in tableColumns" :key="index">
|
2024-03-02 19:08:19 +08:00
|
|
|
|
<el-checkbox v-model="item.show" :label="item.label" :true-value="true" :false-value="false" />
|
2023-12-16 17:41:15 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<template #reference>
|
|
|
|
|
|
<el-button icon="Operation" circle :size="props.size"></el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2023-12-12 23:31:53 +08:00
|
|
|
|
</slot>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2023-07-20 22:41:13 +08:00
|
|
|
|
|
2023-12-12 23:31:53 +08:00
|
|
|
|
<el-table
|
2023-12-17 14:38:53 +08:00
|
|
|
|
ref="tableRef"
|
2023-12-12 23:31:53 +08:00
|
|
|
|
v-bind="$attrs"
|
|
|
|
|
|
:max-height="tableMaxHeight"
|
|
|
|
|
|
@selection-change="handleSelectionChange"
|
2023-12-17 14:38:53 +08:00
|
|
|
|
:data="tableData"
|
2023-12-12 23:31:53 +08:00
|
|
|
|
highlight-current-row
|
2023-12-17 14:38:53 +08:00
|
|
|
|
v-loading="loading"
|
|
|
|
|
|
:size="props.size as any"
|
2023-12-12 23:31:53 +08:00
|
|
|
|
:border="border"
|
|
|
|
|
|
>
|
2023-12-17 14:38:53 +08:00
|
|
|
|
<el-table-column v-if="props.showSelection" :selectable="selectable" type="selection" width="40" />
|
2023-12-12 23:31:53 +08:00
|
|
|
|
|
|
|
|
|
|
<template v-for="(item, index) in tableColumns">
|
|
|
|
|
|
<el-table-column
|
|
|
|
|
|
:key="index"
|
|
|
|
|
|
v-if="item.show"
|
|
|
|
|
|
:prop="item.prop"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
:fixed="item.fixed"
|
|
|
|
|
|
:align="item.align"
|
|
|
|
|
|
:show-overflow-tooltip="item.showOverflowTooltip"
|
|
|
|
|
|
:min-width="item.minWidth"
|
|
|
|
|
|
:sortable="item.sortable || false"
|
|
|
|
|
|
:type="item.type"
|
|
|
|
|
|
:width="item.width"
|
|
|
|
|
|
>
|
|
|
|
|
|
<!-- 插槽:预留功能 -->
|
|
|
|
|
|
<template #default="scope" v-if="item.slot">
|
2024-02-29 22:12:50 +08:00
|
|
|
|
<slot :name="item.slotName ? item.slotName : item.prop" :data="scope.row"></slot>
|
2023-12-12 23:31:53 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 枚举类型使用tab展示 -->
|
|
|
|
|
|
<template #default="scope" v-else-if="item.type == 'tag'">
|
2024-02-29 22:12:50 +08:00
|
|
|
|
<enum-tag :size="props.size" :enums="item.typeParam" :value="item.getValueByData(scope.row)"></enum-tag>
|
2023-12-12 23:31:53 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<template #default="scope" v-else>
|
|
|
|
|
|
<!-- 配置了美化文本按钮以及文本内容大于指定长度,则显示美化按钮 -->
|
|
|
|
|
|
<el-popover
|
2024-02-29 22:12:50 +08:00
|
|
|
|
v-if="item.isBeautify && item.getValueByData(scope.row)?.length > 35"
|
2023-12-12 23:31:53 +08:00
|
|
|
|
effect="light"
|
|
|
|
|
|
trigger="click"
|
|
|
|
|
|
placement="top"
|
|
|
|
|
|
width="600px"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template #default>
|
|
|
|
|
|
<el-input :autosize="{ minRows: 3, maxRows: 15 }" disabled v-model="formatVal" type="textarea" />
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #reference>
|
|
|
|
|
|
<el-link
|
2024-02-29 22:12:50 +08:00
|
|
|
|
@click="formatText(item.getValueByData(scope.row))"
|
2023-12-12 23:31:53 +08:00
|
|
|
|
:underline="false"
|
|
|
|
|
|
type="success"
|
|
|
|
|
|
icon="MagicStick"
|
|
|
|
|
|
class="mr5"
|
|
|
|
|
|
></el-link>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-popover>
|
2023-06-28 21:35:03 +08:00
|
|
|
|
|
2023-12-12 23:31:53 +08:00
|
|
|
|
<span>{{ item.getValueByData(scope.row) }}</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2023-12-18 22:39:32 +08:00
|
|
|
|
<el-row v-if="props.pageable" class="mt20" type="flex" justify="end">
|
2023-07-06 20:59:22 +08:00
|
|
|
|
<el-pagination
|
|
|
|
|
|
:small="props.size == 'small'"
|
2024-10-20 03:52:23 +00:00
|
|
|
|
@current-change="pageNumChange"
|
|
|
|
|
|
@size-change="pageSizeChange"
|
2023-07-06 20:59:22 +08:00
|
|
|
|
style="text-align: right"
|
2024-04-28 23:45:57 +08:00
|
|
|
|
layout="prev, pager, next, total, sizes"
|
2023-12-17 14:38:53 +08:00
|
|
|
|
:total="total"
|
2023-12-29 16:48:15 +08:00
|
|
|
|
v-model:current-page="queryForm.pageNum"
|
|
|
|
|
|
v-model:page-size="queryForm.pageSize"
|
2023-07-06 20:59:22 +08:00
|
|
|
|
:page-sizes="pageSizes"
|
|
|
|
|
|
/>
|
2023-06-28 21:35:03 +08:00
|
|
|
|
</el-row>
|
2023-12-14 13:05:21 +08:00
|
|
|
|
</div>
|
2023-06-28 21:35:03 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
2023-07-06 20:59:22 +08:00
|
|
|
|
<script lang="ts" setup>
|
2023-12-18 22:39:32 +08:00
|
|
|
|
import { toRefs, watch, reactive, onMounted, Ref, ref, useSlots, toValue } from 'vue';
|
2023-12-12 23:31:53 +08:00
|
|
|
|
import { TableColumn } from './index';
|
2023-07-06 20:59:22 +08:00
|
|
|
|
import EnumTag from '@/components/enumtag/EnumTag.vue';
|
2023-11-29 17:34:54 +08:00
|
|
|
|
import { useThemeConfig } from '@/store/themeConfig';
|
|
|
|
|
|
import { storeToRefs } from 'pinia';
|
2023-12-29 16:48:15 +08:00
|
|
|
|
import { useEventListener } from '@vueuse/core';
|
2023-12-11 01:00:09 +08:00
|
|
|
|
import Api from '@/common/Api';
|
2023-12-12 23:31:53 +08:00
|
|
|
|
import SearchForm from '@/components/SearchForm/index.vue';
|
|
|
|
|
|
import { SearchItem } from '../SearchForm/index';
|
2023-12-16 17:41:15 +08:00
|
|
|
|
import SearchFormItem from '../SearchForm/components/SearchFormItem.vue';
|
|
|
|
|
|
import SvgIcon from '@/components/svgIcon/index.vue';
|
2024-01-09 17:31:21 +08:00
|
|
|
|
import { usePageTable } from '@/hooks/usePageTable';
|
2023-12-17 14:38:53 +08:00
|
|
|
|
import { ElTable } from 'element-plus';
|
2023-12-12 23:31:53 +08:00
|
|
|
|
|
2024-10-20 03:52:23 +00:00
|
|
|
|
const emit = defineEmits(['update:selectionData', 'pageSizeChange', 'pageNumChange']);
|
2023-12-12 23:31:53 +08:00
|
|
|
|
|
|
|
|
|
|
export interface PageTableProps {
|
|
|
|
|
|
size?: string;
|
2024-02-06 07:32:03 +00:00
|
|
|
|
pageApi?: Api; // 请求表格数据的 api
|
2023-12-17 14:38:53 +08:00
|
|
|
|
columns: TableColumn[]; // 列配置项 ==> 必传
|
2023-12-12 23:31:53 +08:00
|
|
|
|
showSelection?: boolean;
|
2023-12-17 14:38:53 +08:00
|
|
|
|
selectable?: (row: any) => boolean; // 是否可选
|
2023-12-18 22:39:32 +08:00
|
|
|
|
pageable?: boolean;
|
2023-12-12 23:31:53 +08:00
|
|
|
|
showSearch?: boolean; // 是否显示搜索表单
|
|
|
|
|
|
data?: any[]; // 静态 table data 数据,若存在则不会使用 requestApi 返回的 data ==> 非必传
|
|
|
|
|
|
lazy?: boolean; // 是否自动执行请求 api ==> 非必传(默认为false)
|
|
|
|
|
|
beforeQueryFn?: (params: any) => any; // 执行查询时对查询参数进行处理,调整等
|
|
|
|
|
|
dataHandlerFn?: (data: any) => any; // 数据处理回调函数,用于将请求回来的数据二次加工处理等
|
|
|
|
|
|
searchItems?: SearchItem[];
|
|
|
|
|
|
border?: boolean; // 是否带有纵向边框 ==> 非必传(默认为false)
|
2023-12-16 17:41:15 +08:00
|
|
|
|
toolButton?: ('setting' | 'search')[] | boolean; // 是否显示表格功能按钮 ==> 非必传(默认为true)
|
2023-12-18 22:39:32 +08:00
|
|
|
|
searchCol?: any; // 表格搜索项 每列占比配置 ==> 非必传 { xs: 1, sm: 2, md: 2, lg: 3, xl: 4 } | number 如 3
|
2023-12-12 23:31:53 +08:00
|
|
|
|
}
|
2023-06-28 21:35:03 +08:00
|
|
|
|
|
2023-12-12 23:31:53 +08:00
|
|
|
|
// 接受父组件参数,配置默认值
|
|
|
|
|
|
const props = withDefaults(defineProps<PageTableProps>(), {
|
|
|
|
|
|
columns: () => [],
|
2023-12-18 22:39:32 +08:00
|
|
|
|
pageable: true,
|
2023-12-12 23:31:53 +08:00
|
|
|
|
showSelection: false,
|
|
|
|
|
|
lazy: false,
|
|
|
|
|
|
border: false,
|
|
|
|
|
|
toolButton: true,
|
|
|
|
|
|
showSearch: false,
|
|
|
|
|
|
searchItems: () => [],
|
2023-12-15 17:33:22 +08:00
|
|
|
|
searchCol: () => ({ xs: 1, sm: 3, md: 3, lg: 4, xl: 5 }),
|
2023-11-29 17:34:54 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2023-12-29 16:48:15 +08:00
|
|
|
|
// 查询表单参数 ==> 非必传(默认为{pageNum:1, pageSize: 10})
|
|
|
|
|
|
const queryForm: Ref<any> = defineModel('queryForm', {
|
|
|
|
|
|
default: {
|
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
|
pageSize: 0,
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2023-12-17 14:38:53 +08:00
|
|
|
|
// table 实例
|
|
|
|
|
|
const tableRef = ref<InstanceType<typeof ElTable>>();
|
|
|
|
|
|
|
2023-12-12 23:31:53 +08:00
|
|
|
|
// 接收 columns 并设置为响应式
|
|
|
|
|
|
const tableColumns = reactive<TableColumn[]>(props.columns);
|
|
|
|
|
|
|
2023-12-16 17:41:15 +08:00
|
|
|
|
// 接收 searchItems 并设置为响应式
|
|
|
|
|
|
const tableSearchItems = reactive<SearchItem[]>(props.searchItems);
|
|
|
|
|
|
|
2023-11-29 17:34:54 +08:00
|
|
|
|
const { themeConfig } = storeToRefs(useThemeConfig());
|
2023-06-28 21:35:03 +08:00
|
|
|
|
|
2023-12-16 17:41:15 +08:00
|
|
|
|
// 是否显示搜索模块
|
|
|
|
|
|
const isShowSearch = ref(props.showSearch);
|
|
|
|
|
|
|
|
|
|
|
|
// 控制 ToolButton 显示
|
|
|
|
|
|
const showToolButton = (key: 'setting' | 'search') => {
|
|
|
|
|
|
return Array.isArray(props.toolButton) ? props.toolButton.includes(key) : props.toolButton;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const nowSearchItem: Ref<SearchItem> = ref(null) as any;
|
2023-12-12 23:31:53 +08:00
|
|
|
|
|
2023-12-16 17:41:15 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 改变当前的搜索项
|
|
|
|
|
|
* @param searchItem 当前点击的搜索项
|
|
|
|
|
|
*/
|
|
|
|
|
|
const changeSimpleFormItem = (searchItem: SearchItem) => {
|
|
|
|
|
|
// 将之前的值置为空,避免因为只显示一个搜索项却搜索多个条件
|
2023-12-29 16:48:15 +08:00
|
|
|
|
queryForm.value[nowSearchItem.value.prop] = null;
|
2023-12-16 17:41:15 +08:00
|
|
|
|
nowSearchItem.value = searchItem;
|
|
|
|
|
|
};
|
2023-11-29 17:34:54 +08:00
|
|
|
|
|
2024-10-20 03:52:23 +00:00
|
|
|
|
const pageSizeChange = (val: number) => {
|
|
|
|
|
|
emit('pageSizeChange', val);
|
|
|
|
|
|
handlePageSizeChange(val);
|
|
|
|
|
|
};
|
|
|
|
|
|
const pageNumChange = (val: number) => {
|
|
|
|
|
|
emit('pageNumChange', val);
|
|
|
|
|
|
handlePageNumChange(val);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2024-02-06 07:32:03 +00:00
|
|
|
|
let { tableData, total, loading, search, reset, getTableData, handlePageNumChange, handlePageSizeChange } = usePageTable(
|
2023-12-18 22:39:32 +08:00
|
|
|
|
props.pageable,
|
2023-12-17 14:38:53 +08:00
|
|
|
|
props.pageApi,
|
2023-12-29 16:48:15 +08:00
|
|
|
|
queryForm,
|
2023-12-17 14:38:53 +08:00
|
|
|
|
props.beforeQueryFn,
|
|
|
|
|
|
props.dataHandlerFn
|
2023-11-29 17:34:54 +08:00
|
|
|
|
);
|
2023-06-28 21:35:03 +08:00
|
|
|
|
|
2023-12-17 14:38:53 +08:00
|
|
|
|
const state = reactive({
|
|
|
|
|
|
pageSizes: [] as any, // 可选每页显示的数据量
|
|
|
|
|
|
// 输入框宽度
|
|
|
|
|
|
formatVal: '', // 格式化后的值
|
|
|
|
|
|
tableMaxHeight: '500px',
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const { pageSizes, formatVal, tableMaxHeight } = toRefs(state);
|
|
|
|
|
|
|
|
|
|
|
|
watch(tableData, (newValue: any) => {
|
|
|
|
|
|
if (newValue && newValue.length > 0) {
|
|
|
|
|
|
props.columns.forEach((item) => {
|
|
|
|
|
|
if (item.autoWidth && item.show) {
|
|
|
|
|
|
item.autoCalculateMinWidth(tableData.value);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2023-12-13 17:32:17 +08:00
|
|
|
|
watch(isShowSearch, () => {
|
|
|
|
|
|
calcuTableHeight();
|
|
|
|
|
|
});
|
2023-12-12 23:31:53 +08:00
|
|
|
|
|
2024-02-06 07:32:03 +00:00
|
|
|
|
watch(
|
|
|
|
|
|
() => props.data,
|
|
|
|
|
|
(newValue: any) => {
|
|
|
|
|
|
tableData = newValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2023-12-11 01:00:09 +08:00
|
|
|
|
onMounted(async () => {
|
2023-12-12 23:31:53 +08:00
|
|
|
|
calcuTableHeight();
|
|
|
|
|
|
useEventListener(window, 'resize', calcuTableHeight);
|
2023-11-29 17:34:54 +08:00
|
|
|
|
|
2023-12-16 17:41:15 +08:00
|
|
|
|
if (props.searchItems.length > 0) {
|
|
|
|
|
|
nowSearchItem.value = props.searchItems[0];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-12-29 16:48:15 +08:00
|
|
|
|
let pageSize = queryForm.value.pageSize;
|
2023-11-29 17:34:54 +08:00
|
|
|
|
// 如果pageSize设为0,则使用系统全局配置的pageSize
|
|
|
|
|
|
if (!pageSize) {
|
|
|
|
|
|
pageSize = themeConfig.value.defaultListPageSize;
|
|
|
|
|
|
// 可能storage已经存在配置json,则可能没值,需要清storage重试
|
|
|
|
|
|
if (!pageSize) {
|
|
|
|
|
|
pageSize = 10;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-07-05 22:06:32 +08:00
|
|
|
|
|
2023-12-29 16:48:15 +08:00
|
|
|
|
queryForm.value.pageNum = 1;
|
|
|
|
|
|
queryForm.value.pageSize = pageSize;
|
2023-08-04 12:22:21 +08:00
|
|
|
|
state.pageSizes = [pageSize, pageSize * 2, pageSize * 3, pageSize * 4, pageSize * 5];
|
2023-07-04 14:13:47 +08:00
|
|
|
|
|
2023-12-11 01:00:09 +08:00
|
|
|
|
if (!props.lazy) {
|
2023-12-17 14:38:53 +08:00
|
|
|
|
await getTableData();
|
2023-12-11 01:00:09 +08:00
|
|
|
|
}
|
2023-11-29 17:34:54 +08:00
|
|
|
|
});
|
2023-06-28 21:35:03 +08:00
|
|
|
|
|
2023-08-16 17:37:33 +08:00
|
|
|
|
const calcuTableHeight = () => {
|
2024-01-09 17:31:21 +08:00
|
|
|
|
const headerHeight = isShowSearch.value ? 330 : 250;
|
2023-12-12 23:31:53 +08:00
|
|
|
|
state.tableMaxHeight = window.innerHeight - headerHeight + 'px';
|
2023-11-29 17:34:54 +08:00
|
|
|
|
};
|
2023-07-20 22:41:13 +08:00
|
|
|
|
|
2023-12-20 23:01:51 +08:00
|
|
|
|
const searchFormItemKeyUpEnter = (event: any) => {
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
search();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2023-12-05 23:03:51 +08:00
|
|
|
|
const formatText = (data: any) => {
|
|
|
|
|
|
state.formatVal = '';
|
|
|
|
|
|
try {
|
|
|
|
|
|
state.formatVal = JSON.stringify(JSON.parse(data), null, 4);
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
state.formatVal = data;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2023-07-01 14:34:42 +08:00
|
|
|
|
const handleSelectionChange = (val: any) => {
|
|
|
|
|
|
emit('update:selectionData', val);
|
2023-11-29 17:34:54 +08:00
|
|
|
|
};
|
2023-06-28 21:35:03 +08:00
|
|
|
|
|
2023-12-18 22:39:32 +08:00
|
|
|
|
const getData = () => {
|
|
|
|
|
|
return toValue(tableData);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2023-12-11 01:00:09 +08:00
|
|
|
|
defineExpose({
|
2023-12-17 14:38:53 +08:00
|
|
|
|
tableRef: tableRef,
|
|
|
|
|
|
search: getTableData,
|
2023-12-18 22:39:32 +08:00
|
|
|
|
getData,
|
2024-10-20 03:52:23 +00:00
|
|
|
|
total,
|
2023-12-11 01:00:09 +08:00
|
|
|
|
});
|
2023-06-28 21:35:03 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
2023-12-12 23:31:53 +08:00
|
|
|
|
.table-box,
|
|
|
|
|
|
.table-main {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
|
|
|
|
// 表格 header 样式
|
|
|
|
|
|
.table-header {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
.header-button-lf {
|
|
|
|
|
|
float: left;
|
2023-06-28 21:35:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-12-12 23:31:53 +08:00
|
|
|
|
.header-button-ri {
|
|
|
|
|
|
float: right;
|
2023-12-16 17:41:15 +08:00
|
|
|
|
|
|
|
|
|
|
.tool-button {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.simple-search-form {
|
|
|
|
|
|
margin-right: 10px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
|
|
|
|
::v-deep(.el-form-item__content > *) {
|
|
|
|
|
|
width: 100% !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.simple-search-form-label {
|
|
|
|
|
|
text-align: right;
|
|
|
|
|
|
margin-right: 5px;
|
|
|
|
|
|
}
|
2023-12-19 19:23:33 +08:00
|
|
|
|
|
|
|
|
|
|
.simple-search-form-btn:hover {
|
|
|
|
|
|
color: var(--el-color-primary);
|
|
|
|
|
|
}
|
2023-12-16 17:41:15 +08:00
|
|
|
|
}
|
2023-06-28 21:35:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-12-12 23:31:53 +08:00
|
|
|
|
.el-button {
|
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
|
}
|
2023-06-28 21:35:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-12-12 23:31:53 +08:00
|
|
|
|
// el-table 表格样式
|
|
|
|
|
|
.el-table {
|
|
|
|
|
|
flex: 1;
|
2023-06-28 21:35:03 +08:00
|
|
|
|
|
2023-12-12 23:31:53 +08:00
|
|
|
|
// 修复 safari 浏览器表格错位 https://github.com/HalseySpicy/Geeker-Admin/issues/83
|
|
|
|
|
|
table {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
}
|
2023-07-04 14:13:47 +08:00
|
|
|
|
|
2023-12-12 23:31:53 +08:00
|
|
|
|
// .el-table__header th {
|
|
|
|
|
|
// height: 45px;
|
|
|
|
|
|
// font-size: 15px;
|
|
|
|
|
|
// font-weight: bold;
|
|
|
|
|
|
// color: var(--el-text-color-primary);
|
|
|
|
|
|
// background: var(--el-fill-color-light);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// .el-table__row {
|
|
|
|
|
|
// height: 45px;
|
|
|
|
|
|
// font-size: 14px;
|
|
|
|
|
|
|
|
|
|
|
|
// .move {
|
|
|
|
|
|
// cursor: move;
|
|
|
|
|
|
|
|
|
|
|
|
// .el-icon {
|
|
|
|
|
|
// cursor: move;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// 设置 el-table 中 header 文字不换行,并省略
|
|
|
|
|
|
.el-table__header .el-table__cell > .cell {
|
|
|
|
|
|
// white-space: nowrap;
|
|
|
|
|
|
white-space: wrap;
|
|
|
|
|
|
}
|
2023-06-28 21:35:03 +08:00
|
|
|
|
|
2023-12-12 23:31:53 +08:00
|
|
|
|
// 解决表格数据为空时样式不居中问题(仅在element-plus中)
|
|
|
|
|
|
// .el-table__empty-block {
|
|
|
|
|
|
// position: absolute;
|
|
|
|
|
|
// top: 50%;
|
|
|
|
|
|
// left: 50%;
|
|
|
|
|
|
// transform: translate(-50%, -50%);
|
|
|
|
|
|
|
|
|
|
|
|
// .table-empty {
|
|
|
|
|
|
// line-height: 30px;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// table 中 image 图片样式
|
|
|
|
|
|
.table-image {
|
|
|
|
|
|
width: 50px;
|
|
|
|
|
|
height: 50px;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-06-28 21:35:03 +08:00
|
|
|
|
|
2023-12-16 17:41:15 +08:00
|
|
|
|
::v-deep(.el-form-item__label) {
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
}
|
2023-06-28 21:35:03 +08:00
|
|
|
|
}
|
2023-07-06 20:59:22 +08:00
|
|
|
|
</style>
|