123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- // import { ElMessage } from 'element-plus'
- import type { CellRenderProps } from '../type'
- export function useTableCellClick(tableName?: string) {
- const router = useRouter()
- const route = useRoute()
- const containerNO = ref('')
- const dialogFlag = ref(false)
- const cellClickHandler = (row, column, cell, event) => {
- if (tableName?.includes('Airport')) {
- switch (column.property) {
- case 'flightNO':
- router.push({
- path: `${route.path.split('/').slice(0, -1).join('/')}/flight`,
- query: {
- flightDate: row.flightDate,
- flightNO: String(row.IATACode) + String(row.flightNO),
- },
- })
- break
- default:
- break
- }
- }
- if (tableName?.includes('FlightWaybill')) {
- switch (column.property) {
- case 'stockCode': {
- let path
- if (route.path.includes('dataQuery')) {
- path = route.path
- .replace('flightQuery', 'waybillQuery')
- .replace('Flight', 'Waybill')
- } else {
- path = `${route.path.split('/').slice(0, -1).join('/')}/waybill`
- }
- router.push({
- path,
- query: {
- flightDate: route.query.flightDate,
- waybillNO: row.stockCode,
- },
- })
- break
- }
- default:
- break
- }
- }
- if (tableName?.includes('FlightContainer')) {
- switch (column.property) {
- case 'stowageNo':
- containerNO.value = row.stowageNo
- dialogFlag.value = true
- break
- default:
- break
- }
- }
- // if (tableName?.includes('WaybillGoods')) {
- // switch (column.property) {
- // case 'CargoSN':
- // router.push({
- // path: `${route.path.split('/').slice(0, -1).join('/')}/goods`,
- // query: {
- // waybillNO: route.query.waybillNO,
- // goodsNO: row.CargoSN,
- // },
- // })
- // break
- // default:
- // break
- // }
- // }
- }
- const cellClickHandlerV2 = ({ column, rowData }: CellRenderProps) => {
- if (tableName?.includes('Airport')) {
- switch (column.columnName) {
- case 'flightNO':
- router.push({
- path: `${route.path.split('/').slice(0, -1).join('/')}/flight`,
- query: {
- flightDate: rowData.flightDate,
- flightNO: String(rowData.IATACode) + String(rowData.flightNO),
- },
- })
- break
- default:
- break
- }
- }
- }
- return {
- cellClickHandler,
- cellClickHandlerV2,
- dialogFlag,
- containerNO,
- }
- }
|