index.jsx 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import React from 'react';
  2. import { useNavigate, Link } from 'react-router-dom';
  3. import { queryTable } from '@/utils/request';
  4. import { ProTable } from '@ant-design/pro-components';
  5. import { Button, message, Popconfirm } from 'antd';
  6. import { getMessageList } from '@/services/message';
  7. const queryMessage = queryTable(getMessageList);
  8. export default (props) => {
  9. const columns = [
  10. {
  11. title: '时间',
  12. dataIndex: 'createDate',
  13. valueType: 'date',
  14. search: false,
  15. width: 160,
  16. },
  17. {
  18. title: '时间',
  19. dataIndex: 'createDate',
  20. valueType: 'dateRange',
  21. hideInTable: true,
  22. search: {
  23. transform: (value) => {
  24. return {
  25. startDate: value[0],
  26. endDate: value[1],
  27. };
  28. },
  29. },
  30. },
  31. {
  32. title: '内容',
  33. dataIndex: 'message',
  34. },
  35. {
  36. title: '状态',
  37. dataIndex: 'isReaded',
  38. search: false,
  39. width: 120,
  40. valueEnum: {
  41. true: {
  42. text: '已读',
  43. status: 'Processing',
  44. },
  45. false: {
  46. text: '未读',
  47. status: 'Error',
  48. },
  49. },
  50. },
  51. {
  52. title: '操作',
  53. valueType: 'option',
  54. width: 200,
  55. render: (_, record) => {
  56. const doUrl = record.targetType === 'store' ?
  57. `/stock/list?id=${record.targetId}` : undefined;
  58. return [
  59. <Button
  60. key={1}
  61. type="link"
  62. disabled={record.isReaded}
  63. >
  64. 设为已读
  65. </Button>,
  66. <Link
  67. key={2}
  68. to={doUrl}
  69. >
  70. 去处理
  71. </Link>,
  72. ]
  73. },
  74. },
  75. ]
  76. return (
  77. <ProTable
  78. rowKey="id"
  79. request={queryMessage}
  80. columns={columns}
  81. />
  82. )
  83. }