NewList.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import React, { useState, useEffect } from 'react';
  2. import { Table, Divider } from 'antd';
  3. import { connect } from 'dva';
  4. import router from 'umi/router';
  5. function List(props) {
  6. const { excel, loading, dispatch } = props;
  7. const columns = [
  8. {
  9. title: '名称',
  10. dataIndex: 'name',
  11. },
  12. // {
  13. // title: '所属项目',
  14. // dataIndex: 'project_id',
  15. // render: id => {
  16. // return project.list.find(item => item.ID == id)?.Name;
  17. // },
  18. // },
  19. {
  20. title: '版本名称',
  21. dataIndex: 'version_name',
  22. },
  23. {
  24. title: '操作',
  25. render: record => (
  26. <>
  27. <a
  28. onClick={() => {
  29. localStorage.excelId = record.id;
  30. router.push(`/home/detail/${record.project_id}`);
  31. }}
  32. >
  33. 查看
  34. </a>
  35. </>
  36. ),
  37. },
  38. ];
  39. const queryList = page => {
  40. console.log(page);
  41. dispatch({
  42. type: 'newList/queryProjectRecord',
  43. payload: {
  44. ...page,
  45. currentPage: page.current,
  46. },
  47. });
  48. };
  49. useEffect(() => {
  50. dispatch({
  51. type: 'newList/queryProjectRecord',
  52. payload: {
  53. pageSize: 20,
  54. },
  55. });
  56. }, []);
  57. return (
  58. <div>
  59. <Table
  60. loading={loading}
  61. rowKey="id"
  62. dataSource={excel.list}
  63. pagination={excel.pagination}
  64. columns={columns}
  65. onChange={queryList}
  66. />
  67. </div>
  68. );
  69. }
  70. export default connect(({ newList, loading }) => ({
  71. excel: newList.excel,
  72. loading: loading.models.newList,
  73. }))(List);