StdTableTransformer.tsx 1009 B

1234567891011121314151617181920212223242526272829303132333435
  1. // text, record, index, column
  2. import dayjs from 'dayjs'
  3. import type { JSX } from 'vue/jsx-runtime'
  4. export interface customRender {
  5. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  6. text: any
  7. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  8. record: any
  9. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  10. index: any
  11. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  12. column: any
  13. }
  14. export const datetime = (args: customRender) => {
  15. return dayjs(args.text).format('YYYY-MM-DD HH:mm:ss')
  16. }
  17. export const date = (args: customRender) => {
  18. return dayjs(args.text).format('YYYY-MM-DD')
  19. }
  20. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  21. export const mask = (args: customRender, maskObj: any): JSX.Element => {
  22. let v
  23. if (typeof maskObj?.[args.text] === 'function')
  24. v = maskObj[args.text]()
  25. else if (typeof maskObj?.[args.text] === 'string')
  26. v = maskObj[args.text]
  27. else
  28. v = args.text
  29. return <div>{v}</div>
  30. }