2023-12-26 16:17:30 +08:00
|
|
|
<template>
|
2024-01-04 16:39:05 +08:00
|
|
|
<div ref="tableHeader" class="cn-table-header">
|
2024-01-04 10:38:41 +08:00
|
|
|
<!-- 通用搜索 -->
|
2024-01-04 16:39:05 +08:00
|
|
|
<transition name="el-zoom-in-bottom" mode="out-in">
|
2024-01-05 10:02:18 +08:00
|
|
|
<div id="table-com-search1" class="table-com-search" v-show="showSelect">
|
2024-01-04 10:38:41 +08:00
|
|
|
</div>
|
|
|
|
|
</transition>
|
2024-01-04 16:39:05 +08:00
|
|
|
<div class="table-header ba-scroll-style">
|
2024-01-05 10:02:18 +08:00
|
|
|
<div id="table-com-search2" style="flex: 1; height: 32px; overflow: hidden; margin-right: 20px">
|
2024-01-04 16:39:05 +08:00
|
|
|
<el-form
|
|
|
|
|
id="header-form"
|
|
|
|
|
@submit.prevent=""
|
|
|
|
|
@keyup.enter="onComSearch"
|
|
|
|
|
label-position="left"
|
|
|
|
|
:inline="true"
|
2024-01-05 10:02:18 +08:00
|
|
|
class="table-com-search-form"
|
|
|
|
|
:label-width="90"
|
2024-01-04 16:39:05 +08:00
|
|
|
>
|
2024-01-05 10:02:18 +08:00
|
|
|
<el-form-item label="日期" v-if="datePicker" style="grid-column: span 2; max-width: unset">
|
2024-01-05 09:14:53 +08:00
|
|
|
<DatePicker ref="Picker"></DatePicker>
|
2024-01-04 16:39:05 +08:00
|
|
|
</el-form-item>
|
2024-01-05 10:02:18 +08:00
|
|
|
<slot name="select"></slot>
|
2024-01-04 16:39:05 +08:00
|
|
|
</el-form>
|
|
|
|
|
</div>
|
|
|
|
|
<template v-if="$slots.select">
|
|
|
|
|
<el-button @click="onComSearch" type="primary">查询</el-button>
|
|
|
|
|
<el-button @click="onResetForm">重置</el-button>
|
|
|
|
|
<div class="table-search-button-group" v-if="showUnfoldButton">
|
2024-01-04 10:38:41 +08:00
|
|
|
<el-button class="table-search-button-item" color="#dcdfe6" plain @click="showSelectChange">
|
|
|
|
|
<Icon size="14" name="el-icon-Search" />
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
2024-01-04 16:39:05 +08:00
|
|
|
</template>
|
|
|
|
|
<slot name="operation"></slot>
|
2023-12-26 16:17:30 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2024-01-04 10:38:41 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { inject, ref, onMounted, nextTick, onUnmounted } from 'vue'
|
2023-12-26 16:17:30 +08:00
|
|
|
import type TableStore from '@/utils/tableStore'
|
2023-12-29 10:05:09 +08:00
|
|
|
import DatePicker from '@/components/form/datePicker/index.vue'
|
2024-01-04 10:38:41 +08:00
|
|
|
import { mainHeight } from '@/utils/layout'
|
2023-12-26 16:17:30 +08:00
|
|
|
|
|
|
|
|
const tableStore = inject('tableStore') as TableStore
|
2024-01-04 10:38:41 +08:00
|
|
|
const tableHeader = ref()
|
2024-01-05 09:14:53 +08:00
|
|
|
const Picker = ref()
|
2024-01-04 10:38:41 +08:00
|
|
|
const date = ref([
|
|
|
|
|
window.XEUtils.toDateString(new Date(), 'yyyy-MM-dd'),
|
|
|
|
|
window.XEUtils.toDateString(new Date(), 'yyyy-MM-dd')
|
|
|
|
|
])
|
2023-12-27 10:39:40 +08:00
|
|
|
|
|
|
|
|
interface Props {
|
2023-12-27 16:36:10 +08:00
|
|
|
datePicker?: boolean
|
2023-12-27 10:39:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
2023-12-27 16:36:10 +08:00
|
|
|
datePicker: false
|
2023-12-27 10:39:40 +08:00
|
|
|
})
|
2023-12-27 16:36:10 +08:00
|
|
|
if (props.datePicker) {
|
2024-01-05 09:14:53 +08:00
|
|
|
// tableStore.table.params.searchBeginTime = Picker.value.timeValue[0]
|
|
|
|
|
// tableStore.table.params.searchEndTime = Picker.value.timeValue[1]
|
2023-12-27 16:36:10 +08:00
|
|
|
}
|
2024-01-04 10:38:41 +08:00
|
|
|
// 动态计算table高度
|
|
|
|
|
const resizeObserver = new ResizeObserver(entries => {
|
|
|
|
|
for (const entry of entries) {
|
|
|
|
|
handlerHeight()
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-01-04 16:39:05 +08:00
|
|
|
const showUnfoldButton = ref(false)
|
2024-01-04 10:38:41 +08:00
|
|
|
onMounted(() => {
|
2024-01-05 09:14:53 +08:00
|
|
|
tableStore.table.params.searchBeginTime = Picker.value.timeValue[0]
|
|
|
|
|
tableStore.table.params.searchEndTime = Picker.value.timeValue[1]
|
2024-01-04 16:39:05 +08:00
|
|
|
nextTick(() => {
|
|
|
|
|
resizeObserver.observe(tableHeader.value)
|
2024-01-05 10:02:18 +08:00
|
|
|
const dom = document.getElementById('header-form') as HTMLElement
|
2024-01-04 16:39:05 +08:00
|
|
|
if (dom.offsetHeight > 50) {
|
|
|
|
|
showUnfoldButton.value = true
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-01-04 10:38:41 +08:00
|
|
|
})
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
resizeObserver.disconnect()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const handlerHeight = () => {
|
|
|
|
|
tableStore.table.height = mainHeight(
|
|
|
|
|
tableStore.table.publicHeight + tableHeader.value.offsetHeight + (tableStore.showPage ? 58 : 0) + 20
|
|
|
|
|
).height as string
|
|
|
|
|
}
|
2024-01-04 16:39:05 +08:00
|
|
|
const showSelect = ref(false)
|
2023-12-27 10:39:40 +08:00
|
|
|
const showSelectChange = () => {
|
|
|
|
|
showSelect.value = !showSelect.value
|
2024-01-05 10:02:18 +08:00
|
|
|
// 把dom(id=header-form)插入到table-com-search1或者table-com-search2
|
|
|
|
|
const dom = document.getElementById('header-form') as HTMLElement
|
|
|
|
|
if (showSelect.value) {
|
|
|
|
|
const dom1 = document.getElementById('table-com-search1') as HTMLElement
|
|
|
|
|
dom1.appendChild(dom)
|
|
|
|
|
}else{
|
|
|
|
|
const dom2 = document.getElementById('table-com-search2') as HTMLElement
|
|
|
|
|
dom2.appendChild(dom)
|
|
|
|
|
}
|
2023-12-27 10:39:40 +08:00
|
|
|
}
|
2024-01-05 09:14:53 +08:00
|
|
|
const onComSearch = async () => {
|
|
|
|
|
console.log('时间1233123')
|
|
|
|
|
|
|
|
|
|
tableStore.table.params.searchBeginTime = Picker.value.timeValue[0]
|
|
|
|
|
tableStore.table.params.searchEndTime = Picker.value.timeValue[1]
|
|
|
|
|
await tableStore.onTableAction('search', {})
|
2023-12-27 10:39:40 +08:00
|
|
|
}
|
|
|
|
|
const onResetForm = () => {
|
|
|
|
|
tableStore.onTableAction('reset', {})
|
2023-12-26 16:17:30 +08:00
|
|
|
}
|
2023-12-27 16:36:10 +08:00
|
|
|
const dateChange = () => {
|
2024-01-05 09:14:53 +08:00
|
|
|
// tableStore.table.params.searchBeginTime = date.value[0]
|
|
|
|
|
// tableStore.table.params.searchEndTime = date.value[1]
|
2023-12-27 16:36:10 +08:00
|
|
|
}
|
2023-12-26 16:17:30 +08:00
|
|
|
</script>
|
|
|
|
|
|
2024-01-04 10:38:41 +08:00
|
|
|
<style scoped lang="scss">
|
2023-12-26 16:17:30 +08:00
|
|
|
.table-header {
|
|
|
|
|
position: relative;
|
|
|
|
|
overflow-x: auto;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
width: 100%;
|
|
|
|
|
max-width: 100%;
|
|
|
|
|
background-color: var(--ba-bg-color-overlay);
|
|
|
|
|
border: 1px solid var(--ba-border-color);
|
|
|
|
|
border-bottom: none;
|
|
|
|
|
padding: 13px 15px;
|
|
|
|
|
font-size: 14px;
|
2023-12-27 10:39:40 +08:00
|
|
|
|
2023-12-26 16:17:30 +08:00
|
|
|
.table-header-operate-text {
|
|
|
|
|
margin-left: 6px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.table-com-search {
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
width: 100%;
|
|
|
|
|
max-width: 100%;
|
|
|
|
|
background-color: var(--ba-bg-color-overlay);
|
|
|
|
|
border: 1px solid var(--ba-border-color);
|
|
|
|
|
border-bottom: none;
|
2024-01-04 16:39:05 +08:00
|
|
|
padding: 13px 15px 20px 15px;
|
2023-12-26 16:17:30 +08:00
|
|
|
font-size: 14px;
|
2024-01-04 16:39:05 +08:00
|
|
|
}
|
|
|
|
|
.table-com-search-form,
|
|
|
|
|
.table-com-search-form2 {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-gap: 20px;
|
|
|
|
|
grid-template-columns: repeat(5, 1fr);
|
|
|
|
|
:deep(.el-select),
|
|
|
|
|
:deep(.el-cascader),
|
|
|
|
|
:deep(.el-input) {
|
|
|
|
|
width: 100%;
|
2023-12-26 16:17:30 +08:00
|
|
|
}
|
2024-01-04 16:39:05 +08:00
|
|
|
:deep(.el-form-item) {
|
|
|
|
|
max-width: 600px;
|
|
|
|
|
margin-right: 0;
|
|
|
|
|
margin-bottom: 0;
|
2023-12-26 16:17:30 +08:00
|
|
|
}
|
2024-01-04 16:39:05 +08:00
|
|
|
}
|
2023-12-27 10:39:40 +08:00
|
|
|
|
2024-01-04 16:39:05 +08:00
|
|
|
@media screen and (max-width: 2600px) {
|
|
|
|
|
.table-com-search-form {
|
|
|
|
|
grid-template-columns: repeat(4, 1fr);
|
2023-12-26 16:17:30 +08:00
|
|
|
}
|
2024-01-04 16:39:05 +08:00
|
|
|
}
|
|
|
|
|
@media screen and (max-width: 2000px) {
|
|
|
|
|
.table-com-search-form {
|
|
|
|
|
grid-template-columns: repeat(3, 1fr);
|
2023-12-26 16:17:30 +08:00
|
|
|
}
|
|
|
|
|
}
|
2024-01-05 10:32:39 +08:00
|
|
|
@media screen and (max-width: 1500px) {
|
2024-01-04 16:39:05 +08:00
|
|
|
.table-com-search-form {
|
|
|
|
|
grid-template-columns: repeat(2, 1fr);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-01-05 10:02:18 +08:00
|
|
|
.table-header .table-com-search-form2 {
|
2024-01-04 16:39:05 +08:00
|
|
|
grid-template-columns: repeat(auto-fit, 400px);
|
|
|
|
|
}
|
2023-12-27 10:39:40 +08:00
|
|
|
|
2023-12-26 16:17:30 +08:00
|
|
|
.mlr-12 {
|
|
|
|
|
margin-left: 12px;
|
|
|
|
|
}
|
2023-12-27 10:39:40 +08:00
|
|
|
|
2023-12-26 16:17:30 +08:00
|
|
|
.mlr-12 + .el-button {
|
|
|
|
|
margin-left: 12px;
|
|
|
|
|
}
|
2023-12-27 10:39:40 +08:00
|
|
|
|
2023-12-26 16:17:30 +08:00
|
|
|
.table-search {
|
|
|
|
|
display: flex;
|
|
|
|
|
margin-left: auto;
|
2023-12-27 10:39:40 +08:00
|
|
|
|
2023-12-26 16:17:30 +08:00
|
|
|
.quick-search {
|
|
|
|
|
width: auto;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-27 10:39:40 +08:00
|
|
|
|
2023-12-26 16:17:30 +08:00
|
|
|
.table-search-button-group {
|
|
|
|
|
display: flex;
|
|
|
|
|
margin-left: 12px;
|
|
|
|
|
border: 1px solid var(--el-border-color);
|
|
|
|
|
border-radius: var(--el-border-radius-base);
|
|
|
|
|
overflow: hidden;
|
2023-12-27 10:39:40 +08:00
|
|
|
|
2023-12-26 16:17:30 +08:00
|
|
|
button:focus,
|
|
|
|
|
button:active {
|
|
|
|
|
background-color: var(--ba-bg-color-overlay);
|
|
|
|
|
}
|
2023-12-27 10:39:40 +08:00
|
|
|
|
2023-12-26 16:17:30 +08:00
|
|
|
button:hover {
|
|
|
|
|
background-color: var(--el-color-info-light-7);
|
|
|
|
|
}
|
2023-12-27 10:39:40 +08:00
|
|
|
|
2023-12-26 16:17:30 +08:00
|
|
|
.table-search-button-item {
|
|
|
|
|
height: 30px;
|
|
|
|
|
border: none;
|
|
|
|
|
border-radius: 0;
|
|
|
|
|
}
|
2023-12-27 10:39:40 +08:00
|
|
|
|
2023-12-26 16:17:30 +08:00
|
|
|
.el-button + .el-button {
|
|
|
|
|
margin: 0;
|
|
|
|
|
}
|
2023-12-27 10:39:40 +08:00
|
|
|
|
2023-12-26 16:17:30 +08:00
|
|
|
.right-border {
|
|
|
|
|
border-right: 1px solid var(--el-border-color);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html.dark {
|
|
|
|
|
.table-search-button-group {
|
|
|
|
|
button:focus,
|
|
|
|
|
button:active {
|
|
|
|
|
background-color: var(--el-color-info-dark-2);
|
|
|
|
|
}
|
2023-12-27 10:39:40 +08:00
|
|
|
|
2023-12-26 16:17:30 +08:00
|
|
|
button:hover {
|
|
|
|
|
background-color: var(--el-color-info-light-7);
|
|
|
|
|
}
|
2023-12-27 10:39:40 +08:00
|
|
|
|
2023-12-26 16:17:30 +08:00
|
|
|
button {
|
|
|
|
|
background-color: var(--ba-bg-color-overlay);
|
2023-12-27 10:39:40 +08:00
|
|
|
|
2023-12-26 16:17:30 +08:00
|
|
|
el-icon {
|
|
|
|
|
color: white !important;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|