|
@@ -17,9 +17,9 @@
|
|
|
<div v-permission="getPermission('count')">
|
|
|
<CommonSwitch v-model:flag="countFlag" label="显示件数" />
|
|
|
</div>
|
|
|
- <div v-permission="getPermission('UTC')">
|
|
|
+ <!-- <div v-permission="getPermission('UTC')">
|
|
|
<CommonSwitch v-model:flag="UTCFlag" label="开启UTC" />
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
<div v-permission="getPermission('columnSet')">
|
|
|
<ColumnSet
|
|
|
:table-columns="tableColumns"
|
|
@@ -86,8 +86,14 @@ import { useTableFilterAndSort } from '@/hooks/useTableFilterAndSort'
|
|
|
import { useFormatter } from './useFormatter'
|
|
|
import { ElTableV2, RowEventHandlers, TableV2Instance } from 'element-plus'
|
|
|
import { CommonData } from '~/common'
|
|
|
-import type { HeaderRenderProps, CellRenderProps, RowClassGetter, ScrollParams } from '../../type'
|
|
|
+import type {
|
|
|
+ HeaderRenderProps,
|
|
|
+ CellRenderProps,
|
|
|
+ RowClassGetter,
|
|
|
+ ScrollParams,
|
|
|
+} from '../../type'
|
|
|
import { useLoop } from '@/hooks/useLoop'
|
|
|
+import { useTableSettingsStore } from '@/store/tableSettings'
|
|
|
|
|
|
const props = defineProps({
|
|
|
name: {
|
|
@@ -108,8 +114,18 @@ const { tableColumns, tableData, getTableData } = useAirportTable(
|
|
|
formData
|
|
|
)
|
|
|
|
|
|
-const customRendererColumns = computed(() =>
|
|
|
- tableColumns.value.map(column => ({
|
|
|
+const customRendererColumns = computed(() => [
|
|
|
+ {
|
|
|
+ key: 'rowNO',
|
|
|
+ width: 33,
|
|
|
+ title: '序号',
|
|
|
+ cellRenderer: ({ rowIndex }: CellRenderProps) => (
|
|
|
+ <div class="el-table-v2__cell-text">{rowIndex + 1}</div>
|
|
|
+ ),
|
|
|
+ align: 'center',
|
|
|
+ fixed: isDeparture,
|
|
|
+ },
|
|
|
+ ...tableColumns.value.map(column => ({
|
|
|
...column,
|
|
|
headerCellRenderer: ({column}: HeaderRenderProps) => (
|
|
|
<TableHeaderCell
|
|
@@ -139,8 +155,8 @@ const customRendererColumns = computed(() =>
|
|
|
}
|
|
|
</>
|
|
|
),
|
|
|
- }))
|
|
|
-)
|
|
|
+ })),
|
|
|
+])
|
|
|
|
|
|
const countFlag = ref(true)
|
|
|
const { tableColumnFormatter, tableDataFormatter } = useFormatter(countFlag)
|
|
@@ -154,16 +170,19 @@ const cellPropsGetter = params => ({
|
|
|
class: cellClassV2(params),
|
|
|
})
|
|
|
const dealedCount = ref(0)
|
|
|
-const rowClass: RowClassGetter = (params) => {
|
|
|
+const rowClass: RowClassGetter = params => {
|
|
|
const { rowData, rowIndex } = params
|
|
|
const classes: string[] = []
|
|
|
if (rowData.hasTakenOff === 'Y' || rowData.hasLanded === 'Y') {
|
|
|
classes.push('bg-gray')
|
|
|
- if (dealedCount.value < tableData.value.length && rowIndex === dealedCount.value - 1) {
|
|
|
+ if (
|
|
|
+ dealedCount.value < tableData.value.length &&
|
|
|
+ rowIndex === dealedCount.value - 1
|
|
|
+ ) {
|
|
|
classes.push('underline-red')
|
|
|
}
|
|
|
}
|
|
|
- if (selectedRowKey.value && params.rowData.rowKey === selectedRowKey.value) {
|
|
|
+ if (selectedRowKey.value && rowData.rowKey === selectedRowKey.value) {
|
|
|
classes.push('is-selected')
|
|
|
}
|
|
|
|
|
@@ -173,10 +192,10 @@ const selectedRowKey = ref('')
|
|
|
watch(formData, () => {
|
|
|
selectedRowKey.value = ''
|
|
|
})
|
|
|
-const rowEventHandlers:RowEventHandlers = {
|
|
|
- onClick: (params) => {
|
|
|
+const rowEventHandlers: RowEventHandlers = {
|
|
|
+ onClick: params => {
|
|
|
selectedRowKey.value = params.rowKey as string
|
|
|
- }
|
|
|
+ },
|
|
|
}
|
|
|
|
|
|
const tableDataCount = computed(() =>
|
|
@@ -216,6 +235,12 @@ const tableDataCount = computed(() =>
|
|
|
|
|
|
const { cellClickHandlerV2 } = useTableCellClick(props.name)
|
|
|
|
|
|
+const route = useRoute()
|
|
|
+const {
|
|
|
+ savedTableFilterValueMap,
|
|
|
+ saveTableFilterValues,
|
|
|
+} = useTableSettingsStore()
|
|
|
+const defaultFilterValueMap = savedTableFilterValueMap[route.path]
|
|
|
const flightStateFilter = computed<{} | { [x: string]: string[] }>(() => {
|
|
|
switch (formData.flightState) {
|
|
|
case 'hasTakenOff':
|
|
@@ -237,12 +262,23 @@ const {
|
|
|
filterValueMap,
|
|
|
sortRuleMap,
|
|
|
dealedTableData,
|
|
|
-} = useTableFilterAndSort(
|
|
|
- tableColumns,
|
|
|
- tableData,
|
|
|
- flightStateFilter,
|
|
|
- { [props.name.includes('Departure') ? 'planDepartureTime' : 'planLandingTime']: 'ascending' }
|
|
|
-)
|
|
|
+} = useTableFilterAndSort(tableColumns, tableData, {
|
|
|
+ defaultFilterValueMap,
|
|
|
+ extraFilterValueMap: flightStateFilter,
|
|
|
+ extraSortRuleMap: {
|
|
|
+ [props.name.includes('Departure')
|
|
|
+ ? 'planDepartureTime'
|
|
|
+ : 'planLandingTime']: 'ascending',
|
|
|
+ },
|
|
|
+})
|
|
|
+const columnsShouldCache = ['IATACode']
|
|
|
+watch(filterValueMap, map => {
|
|
|
+ const values: { [x: string]: string[] } = {}
|
|
|
+ columnsShouldCache.forEach(columnName => {
|
|
|
+ values[columnName] = map[columnName]
|
|
|
+ })
|
|
|
+ saveTableFilterValues(values)
|
|
|
+})
|
|
|
|
|
|
const permissionMap = {
|
|
|
DepartureAirport: {
|
|
@@ -276,7 +312,10 @@ const getPermission = (type?: string) => {
|
|
|
|
|
|
const hasSetTableScroll = ref(false)
|
|
|
watch(formData, (newData, oldData) => {
|
|
|
- if (newData.startDate !== oldData.startDate || newData.endDate !== oldData.endDate) {
|
|
|
+ if (
|
|
|
+ newData.startDate !== oldData.startDate ||
|
|
|
+ newData.endDate !== oldData.endDate
|
|
|
+ ) {
|
|
|
hasSetTableScroll.value = false
|
|
|
}
|
|
|
})
|
|
@@ -329,11 +368,11 @@ const tableScrollHandler = ({ scrollLeft, scrollTop }: ScrollParams) => {
|
|
|
onActivated(() => {
|
|
|
const { x, y } = scrollPosition
|
|
|
if (x > 0 || y > 0) {
|
|
|
- visibility.value = 'hidden'
|
|
|
- tableRef.value?.scrollTo({ scrollLeft: 0, scrollTop: 0 })
|
|
|
- // 不加延迟的话横向滚动会出错
|
|
|
- // 等待滚动完成再显示,一定要使用visibility,使用v-show或者说display: none一样会变空白
|
|
|
- setTimeout(() => {
|
|
|
+ visibility.value = 'hidden'
|
|
|
+ tableRef.value?.scrollTo({ scrollLeft: 0, scrollTop: 0 })
|
|
|
+ // 不加延迟的话横向滚动会出错
|
|
|
+ // 等待滚动完成再显示,一定要使用visibility,使用v-show或者说display: none一样会变空白
|
|
|
+ setTimeout(() => {
|
|
|
tableRef.value?.scrollTo({
|
|
|
scrollLeft: x,
|
|
|
scrollTop: y,
|
|
@@ -341,7 +380,7 @@ onActivated(() => {
|
|
|
visibility.value = 'visible'
|
|
|
}, 0)
|
|
|
}
|
|
|
- })
|
|
|
+})
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
@import './index.scss';
|