table.data.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import type { BasicTableProps, BasicColumn } from '/@/components/Table';
  2. import type { DynamicProps } from '/#/utils';
  3. import { api } from '/@/api/eav/index';
  4. import { h, unref } from 'vue';
  5. import { Avatar, Button } from 'ant-design-vue';
  6. import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
  7. import { useMessage } from '/@/hooks/web/useMessage';
  8. const { clipboardRef, copiedRef } = useCopyToClipboard();
  9. const { createMessage } = useMessage();
  10. type Props = Partial<DynamicProps<BasicTableProps>>;
  11. const getBasicColumns: BasicColumn[] = [
  12. {
  13. title: '标题',
  14. dataIndex: 'title',
  15. width: 150,
  16. customRender: ({ record }) => {
  17. return h('span', [
  18. h(Avatar, { src: record.logo, style: { marginRight: '5px' } }),
  19. h('span', record.title),
  20. ]);
  21. },
  22. },
  23. {
  24. title: '域名',
  25. dataIndex: 'logo',
  26. customRender: ({ record }) => {
  27. return h('div', [
  28. h('div', [h('a', { target: '_blank', href: 'https://www.xingyousoft.com' }, '官网')]),
  29. h(
  30. Button,
  31. {
  32. onclick: () => {
  33. clipboardRef.value = 'http://www.xingyousoft.com/download/' + record.mid;
  34. if (unref(copiedRef)) {
  35. createMessage.warning('下载地址 复制成功!');
  36. }
  37. },
  38. },
  39. {
  40. default: () => {
  41. return '复制下载地址';
  42. },
  43. },
  44. ),
  45. ]);
  46. },
  47. },
  48. {
  49. title: '月价',
  50. dataIndex: 'price1',
  51. customRender: ({ record }) => {
  52. return h('div', [
  53. h('div', '月价: ' + record.price1),
  54. h('div', '半年价: ' + record.price2),
  55. h('div', '一年价: ' + record.price3),
  56. h('div', '永久价: ' + record.price4),
  57. ]);
  58. },
  59. },
  60. {
  61. title: '7天价',
  62. dataIndex: 'price5',
  63. },
  64. {
  65. title: '状态',
  66. dataIndex: 'status',
  67. slots: { customRender: 'status' },
  68. },
  69. {
  70. title: '管理',
  71. slots: { customRender: 'menu' },
  72. },
  73. ];
  74. const registerTableProps: Props = {
  75. title: '产品列表',
  76. titleHelpMessage: '比如:后台管理模块,前台管理模块,命名空间必须与代码模块保持一致!',
  77. api: () => {
  78. return api('product_list', {});
  79. },
  80. columns: getBasicColumns,
  81. bordered: true,
  82. showTableSetting: true,
  83. loading: true,
  84. pagination: {
  85. defaultPageSize: 20,
  86. },
  87. actionColumn: {
  88. width: 280,
  89. title: '操作',
  90. dataIndex: 'action',
  91. slots: { customRender: 'action' },
  92. },
  93. };
  94. export { registerTableProps };