List.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import React, { useState, useEffect } from 'react';
  2. import { Form, Select, Button, Table, Input, Checkbox, Divider } from 'antd';
  3. import { connect } from 'dva';
  4. import FlowModal from './FlowModal';
  5. import router from 'umi/router';
  6. import Link from 'umi/link';
  7. const { Option } = Select;
  8. function List(props) {
  9. const { userList, list, dispatch, projectList } = props;
  10. const [visible, setVisible] = useState(false);
  11. const columns = [
  12. {
  13. title: '流程名称',
  14. dataIndex: 'Name',
  15. },
  16. {
  17. title: '所属项目',
  18. dataIndex: ['Project', 'Name'],
  19. },
  20. {
  21. title: '操作',
  22. render: (item, index) => (
  23. <>
  24. <a onClick={() => router.push(`/home/flow/${item.Id}`)}>查看</a>
  25. </>
  26. ),
  27. },
  28. ];
  29. const onOk = values => {
  30. console.log(values);
  31. dispatch({
  32. type: 'flow/addFlow',
  33. payload: values,
  34. callback: () => {
  35. setVisible(false);
  36. },
  37. });
  38. };
  39. useEffect(() => {
  40. dispatch({
  41. type: 'flow/queryFlowList',
  42. });
  43. dispatch({
  44. type: 'flow/queryProject',
  45. });
  46. // dispatch({
  47. // type: 'flow/getRoleList',
  48. // });
  49. // dispatch({
  50. // type: 'flow/queryDingTemplateList',
  51. // });
  52. }, []);
  53. return (
  54. <div>
  55. <div style={{ marginBottom: 20 }}>
  56. <Button type="primary" style={{ marginRight: 20 }} onClick={() => setVisible(true)}>
  57. 新增工作流
  58. </Button>
  59. <Link to="/home/audit-list">
  60. <Button type="primary">审批流管理</Button>
  61. </Link>
  62. </div>
  63. <Table rowKey="Id" dataSource={list} columns={columns} />
  64. <FlowModal
  65. visible={visible}
  66. projectList={projectList}
  67. onCancel={() => setVisible(false)}
  68. onOk={onOk}
  69. />
  70. </div>
  71. );
  72. }
  73. export default connect(({ user, flow, loading }) => ({
  74. userList: user.list,
  75. list: flow.flowList,
  76. projectList: flow.projectList,
  77. loading: loading.models.purchaseList2,
  78. }))(List);