index.jsx 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import { history, Link } from 'umi';
  2. import { useRef, useState, useEffect } from 'react';
  3. import { Button, Popconfirm, message, Tooltip } from 'antd';
  4. import { PlusOutlined, QuestionCircleOutlined, DownOutlined } from '@ant-design/icons';
  5. import { PageHeaderWrapper } from '@ant-design/pro-layout';
  6. import ProTable from '@ant-design/pro-table';
  7. export default (props) => {
  8. const dataSource = [
  9. {
  10. id: 9,
  11. key: '1',
  12. name: '胡彦斌',
  13. age: 32,
  14. address: '西湖区湖底公园1号',
  15. },
  16. {
  17. id: 10,
  18. key: '2',
  19. name: '胡彦祖',
  20. age: 42,
  21. address: '西湖区湖底公园1号',
  22. },
  23. ];
  24. const actions = () => [
  25. <Button key="add" type="primary" icon={<PlusOutlined />} onClick={() => gotoDetail()}>
  26. 新增商户
  27. </Button>,
  28. ];
  29. const columns = [
  30. {
  31. title: '消息ID',
  32. key: 'id',
  33. dataIndex: 'id',
  34. search: false,
  35. render: (t, record) => (
  36. <Link key={1} to={`./edit?id=${record.shopId}`}>
  37. {record.shopName}
  38. </Link>
  39. ),
  40. },
  41. {
  42. title: '消息标题',
  43. key: 'title',
  44. dataIndex: 'title',
  45. render: (t, record) => (
  46. <Link key={1} to={`./package?shopId=${record.shopId}`}>
  47. {record?.packageNum}
  48. </Link>
  49. ),
  50. },
  51. {
  52. title: '推送对象',
  53. key: 'pushPerson',
  54. search: false,
  55. dataIndex: 'pushPerson',
  56. render: (t, record) => (record.pushPerson === 1 ? '农机手' : '农户'),
  57. },
  58. {
  59. title: '推送方式',
  60. key: 'status',
  61. dataIndex: 'status',
  62. // render: (t, record) => record.status === 1 ? '发布' : '未发布',
  63. formItemProps: { label: '推送方式' },
  64. valueType: 'select',
  65. valueEnum: {
  66. 0: { text: '通知栏推送' },
  67. 1: { text: 'APP内消息中心推送' },
  68. 2: { text: '短信推送' },
  69. },
  70. },
  71. {
  72. title: (
  73. <>
  74. 创建时间
  75. <Tooltip placement="top">
  76. <QuestionCircleOutlined style={{ marginLeft: 4 }} />
  77. </Tooltip>
  78. </>
  79. ),
  80. width: 140,
  81. key: 'createdAt',
  82. dataIndex: 'createdAt',
  83. valueType: 'date',
  84. // render: (t) => formatterTime(t),
  85. sorter: (a, b) => a.createdAt - b.createdAt,
  86. },
  87. {
  88. title: '操作',
  89. valueType: 'option',
  90. width: '300px',
  91. render: (_, record) => [
  92. <Link key={2} to={`./MessageEdit`}>
  93. 查看
  94. </Link>,
  95. <Popconfirm
  96. key={3}
  97. title="您是否确认删除 ?"
  98. onConfirm={() => handleDelete(record.noticeId)}
  99. okText="确定"
  100. cancelText="取消"
  101. >
  102. <a href="#">删除</a>
  103. </Popconfirm>,
  104. ],
  105. },
  106. ];
  107. return (
  108. <PageHeaderWrapper>
  109. <ProTable
  110. dataSource={dataSource}
  111. columns={columns}
  112. // request={getList}
  113. rowKey="id"
  114. options={false}
  115. toolBarRender={actions}
  116. scroll={{ x: 1000 }}
  117. />
  118. </PageHeaderWrapper>
  119. );
  120. };