|
@@ -1,11 +1,21 @@
|
|
|
<template>
|
|
|
- <div class="table-header-cell el-table-v2__header-cell-text">
|
|
|
+ <div
|
|
|
+ :class="[
|
|
|
+ 'table-header-cell',
|
|
|
+ 'el-table-v2__header-cell-text',
|
|
|
+ {
|
|
|
+ 'table-header-cell-space-between':
|
|
|
+ (filterable && filterStyle === 'arrow') || sortable,
|
|
|
+ },
|
|
|
+ ]"
|
|
|
+ >
|
|
|
<template v-if="!filterable || filterStyle === 'arrow'">
|
|
|
- {{ label }}
|
|
|
+ <span style="flex: 1">{{ label }}</span>
|
|
|
</template>
|
|
|
<template v-if="filterable">
|
|
|
<el-popover
|
|
|
- :visible="visible"
|
|
|
+ :width="224"
|
|
|
+ trigger="click"
|
|
|
class="table-header-cell-popover"
|
|
|
placement="bottom"
|
|
|
@show="expand = true"
|
|
@@ -13,30 +23,32 @@
|
|
|
>
|
|
|
<template v-if="filterStyle === 'underline'" #reference>
|
|
|
<span
|
|
|
- :class="['btn-filter', { 'btn-filter-active': active }]"
|
|
|
- @click="visible = !visible"
|
|
|
+ :class="['filter-button', { 'filter-button-active': active }]"
|
|
|
>{{ label }}</span
|
|
|
>
|
|
|
</template>
|
|
|
<template v-if="filterStyle === 'arrow'" #reference>
|
|
|
- <i
|
|
|
- :class="[
|
|
|
- 'filter-arrow',
|
|
|
- 'el-icon-arrow-down',
|
|
|
- { 'arrow-active': active, 'arrow-expand': expand },
|
|
|
- ]"
|
|
|
- @click="visible = !visible"
|
|
|
- />
|
|
|
+ <div class="filter-arrow-wrapper">
|
|
|
+ <el-icon
|
|
|
+ :class="[
|
|
|
+ 'filter-arrow',
|
|
|
+ { 'arrow-active': active, 'arrow-expand': expand },
|
|
|
+ ]"
|
|
|
+ >
|
|
|
+ <CaretBottom />
|
|
|
+ </el-icon>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
<el-select
|
|
|
v-model="selections"
|
|
|
- size="small"
|
|
|
+ size="default"
|
|
|
placeholder="筛选"
|
|
|
multiple
|
|
|
filterable
|
|
|
default-first-option
|
|
|
collapse-tags
|
|
|
clearable
|
|
|
+ :teleported="false"
|
|
|
@change="
|
|
|
newVal => {
|
|
|
$emit('update:filter-values', newVal)
|
|
@@ -53,9 +65,12 @@
|
|
|
</el-popover>
|
|
|
</template>
|
|
|
<template v-if="sortable">
|
|
|
- <span class="caret-wrapper" @click="sortChange">
|
|
|
- <i class="sort-caret ascending" />
|
|
|
- <i class="sort-caret descending" />
|
|
|
+ <span class="sort-wrapper" @click="sortChange">
|
|
|
+ <el-icon class="sort">
|
|
|
+ <SortUp v-show="sortRule === 'ascending'" />
|
|
|
+ <SortDown v-show="sortRule === 'descending'" />
|
|
|
+ <Sort v-show="!sortRule" />
|
|
|
+ </el-icon>
|
|
|
</span>
|
|
|
</template>
|
|
|
</div>
|
|
@@ -63,6 +78,7 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import { PropType } from 'vue'
|
|
|
+import { CaretBottom, Sort, SortUp, SortDown } from '@element-plus/icons-vue'
|
|
|
|
|
|
const props = defineProps({
|
|
|
label: {
|
|
@@ -91,8 +107,6 @@ const props = defineProps({
|
|
|
|
|
|
const emit = defineEmits(['update:sortRule'])
|
|
|
|
|
|
-const visible = ref(false)
|
|
|
-
|
|
|
const selections = ref<string[]>([])
|
|
|
const expand = ref(false)
|
|
|
const active = computed(() => !!props.filterValues?.length)
|
|
@@ -111,51 +125,85 @@ const sortChange = () => {
|
|
|
: ''
|
|
|
emit('update:sortRule', sortRule)
|
|
|
}
|
|
|
-
|
|
|
-onUpdated(() => {
|
|
|
- if (props.label === '航班号') {
|
|
|
- console.log(filterable.value)
|
|
|
- }
|
|
|
-})
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-.filter-arrow {
|
|
|
- cursor: pointer;
|
|
|
- transition: 0.3s transform;
|
|
|
-
|
|
|
- &.arrow-expand {
|
|
|
- transform: rotate(-180deg);
|
|
|
+.table-header-cell {
|
|
|
+ flex: 1;
|
|
|
+ height: 100%;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 14px;
|
|
|
+ position: relative;
|
|
|
+ &.table-header-cell-space-between {
|
|
|
+ justify-content: space-between;
|
|
|
}
|
|
|
-
|
|
|
- &.arrow-active {
|
|
|
- color: #2d7cff;
|
|
|
- font-weight: bold;
|
|
|
+ .filter-arrow-wrapper {
|
|
|
+ width: 14px;
|
|
|
+ height: 100%;
|
|
|
+ background-color: #dfc37f;
|
|
|
+ position: relative;
|
|
|
+ cursor: pointer;
|
|
|
+ .filter-arrow {
|
|
|
+ display: inline;
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ right: 0;
|
|
|
+ bottom: 0;
|
|
|
+ left: 0;
|
|
|
+ margin: auto;
|
|
|
+ transition: 0.3s transform;
|
|
|
+ &.arrow-expand {
|
|
|
+ transform: rotate(-180deg);
|
|
|
+ }
|
|
|
+ &.arrow-active {
|
|
|
+ color: #2d7cff;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
+ .filter-button {
|
|
|
+ flex: 1;
|
|
|
+ cursor: pointer;
|
|
|
+ position: relative;
|
|
|
|
|
|
-.btn-filter {
|
|
|
- cursor: pointer;
|
|
|
- position: relative;
|
|
|
+ &:hover {
|
|
|
+ color: #2d7cff;
|
|
|
+ }
|
|
|
|
|
|
- &:hover {
|
|
|
- color: #2d7cff;
|
|
|
- }
|
|
|
+ &::after {
|
|
|
+ content: '';
|
|
|
+ display: block;
|
|
|
+ width: calc(100% + 4px);
|
|
|
+ position: absolute;
|
|
|
+ bottom: -4px;
|
|
|
+ left: -2px;
|
|
|
+ border-bottom: 1px solid #101116;
|
|
|
+ }
|
|
|
|
|
|
- &::after {
|
|
|
- content: '';
|
|
|
- display: block;
|
|
|
- width: calc(100% + 4px);
|
|
|
- position: absolute;
|
|
|
- bottom: -4px;
|
|
|
- left: -2px;
|
|
|
- border-bottom: 1px solid #101116;
|
|
|
+ &.filter-button-active,
|
|
|
+ &:hover {
|
|
|
+ &::after {
|
|
|
+ border-bottom: 2px solid #2d7cff;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- &.btn-filter-active,
|
|
|
- &:hover {
|
|
|
- &::after {
|
|
|
- border-bottom: 2px solid #2d7cff;
|
|
|
+ .sort-wrapper {
|
|
|
+ width: 14px;
|
|
|
+ height: 100%;
|
|
|
+ background-color: #dfc37f;
|
|
|
+ position: relative;
|
|
|
+ cursor: pointer;
|
|
|
+ .sort {
|
|
|
+ display: inline;
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ right: 0;
|
|
|
+ bottom: 0;
|
|
|
+ left: 0;
|
|
|
+ margin: auto;
|
|
|
}
|
|
|
}
|
|
|
}
|