useTableCellClick.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // import { ElMessage } from 'element-plus'
  2. import type { CellRenderProps } from '../type'
  3. export function useTableCellClick(tableName?: string) {
  4. const router = useRouter()
  5. const route = useRoute()
  6. const containerNO = ref('')
  7. const dialogFlag = ref(false)
  8. const cellClickHandler = (row, column, cell, event) => {
  9. if (tableName?.includes('Airport')) {
  10. switch (column.property) {
  11. case 'flightNO':
  12. router.push({
  13. path: `${route.path.split('/').slice(0, -1).join('/')}/flight`,
  14. query: {
  15. flightDate: row.flightDate,
  16. flightNO: String(row.IATACode) + String(row.flightNO),
  17. },
  18. })
  19. break
  20. default:
  21. break
  22. }
  23. }
  24. if (tableName?.includes('FlightWaybill')) {
  25. switch (column.property) {
  26. case 'stockCode': {
  27. let path
  28. if (route.path.includes('dataQuery')) {
  29. path = route.path
  30. .replace('flightQuery', 'waybillQuery')
  31. .replace('Flight', 'Waybill')
  32. } else {
  33. path = `${route.path.split('/').slice(0, -1).join('/')}/waybill`
  34. }
  35. router.push({
  36. path,
  37. query: {
  38. flightDate: route.query.flightDate,
  39. waybillNO: row.stockCode,
  40. },
  41. })
  42. break
  43. }
  44. default:
  45. break
  46. }
  47. }
  48. if (tableName?.includes('FlightContainer')) {
  49. switch (column.property) {
  50. case 'stowageNo':
  51. containerNO.value = row.stowageNo
  52. dialogFlag.value = true
  53. break
  54. default:
  55. break
  56. }
  57. }
  58. // if (tableName?.includes('WaybillGoods')) {
  59. // switch (column.property) {
  60. // case 'CargoSN':
  61. // router.push({
  62. // path: `${route.path.split('/').slice(0, -1).join('/')}/goods`,
  63. // query: {
  64. // waybillNO: route.query.waybillNO,
  65. // goodsNO: row.CargoSN,
  66. // },
  67. // })
  68. // break
  69. // default:
  70. // break
  71. // }
  72. // }
  73. }
  74. const cellClickHandlerV2 = ({ column, rowData }: CellRenderProps) => {
  75. if (tableName?.includes('Airport')) {
  76. switch (column.columnName) {
  77. case 'flightNO':
  78. router.push({
  79. path: `${route.path.split('/').slice(0, -1).join('/')}/flight`,
  80. query: {
  81. flightDate: rowData.flightDate,
  82. flightNO: String(rowData.IATACode) + String(rowData.flightNO),
  83. },
  84. })
  85. break
  86. default:
  87. break
  88. }
  89. }
  90. }
  91. return {
  92. cellClickHandler,
  93. cellClickHandlerV2,
  94. dialogFlag,
  95. containerNO,
  96. }
  97. }