useTableCellClick.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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('FlightWaybill')) {
  10. switch (column.property) {
  11. case 'stockCode':
  12. router.push({
  13. path: `${route.path.split('/').slice(0, -1).join('/')}/waybill`,
  14. query: {
  15. waybillNO: row.stockCode,
  16. },
  17. })
  18. break
  19. // case 'stowageNum':
  20. // ElMessage.info('开发中')
  21. // break
  22. default:
  23. break
  24. }
  25. }
  26. if (tableName?.includes('FlightContainer')) {
  27. switch (column.property) {
  28. case 'stowageNo':
  29. containerNO.value = row.stowageNo
  30. dialogFlag.value = true
  31. break
  32. default:
  33. break
  34. }
  35. }
  36. // if (tableName?.includes('WaybillGoods')) {
  37. // switch (column.property) {
  38. // case 'CargoSN':
  39. // router.push({
  40. // path: `${route.path.split('/').slice(0, -1).join('/')}/goods`,
  41. // query: {
  42. // waybillNO: route.query.waybillNO,
  43. // goodsNO: row.CargoSN,
  44. // },
  45. // })
  46. // break
  47. // default:
  48. // break
  49. // }
  50. // }
  51. }
  52. const cellClickHandlerV2 = ({ column, rowData }: CellRenderProps) => {
  53. if (tableName?.includes('Airport')) {
  54. switch (column.columnName) {
  55. case 'flightNO':
  56. router.push({
  57. path: `${route.path.split('/').slice(0, -1).join('/')}/flight`,
  58. query: {
  59. flightDate: rowData.flightDate,
  60. flightNO: String(rowData.IATACode) + String(rowData.flightNO),
  61. },
  62. })
  63. break
  64. default:
  65. break
  66. }
  67. }
  68. }
  69. return {
  70. cellClickHandler,
  71. cellClickHandlerV2,
  72. dialogFlag,
  73. containerNO,
  74. }
  75. }