123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import React from 'react';
  2. import { Button, Card, Table, message, Descriptions, Col, Row } from 'antd';
  3. import { getDeviceJobByOrg, exportDeviceJobByOrg } from '@/services/job';
  4. export default (props) => {
  5. const { machine, userId } = props;
  6. const columns = [
  7. {
  8. title: '设备类型',
  9. dataIndex: 'deviceKind',
  10. key: 'deviceKind',
  11. render: (t) => (t === 'shensong' ? '深松' : t === 'feifang' ? '飞防' : '-'),
  12. },
  13. {
  14. title: '设备编号',
  15. dataIndex: 'deviceNo',
  16. key: 'deviceNo',
  17. },
  18. {
  19. title: '作业面积(亩)',
  20. dataIndex: 'jobArea',
  21. key: 'jobArea',
  22. },
  23. {
  24. title: '耕深(厘米)',
  25. dataIndex: 'depth',
  26. key: 'depth',
  27. },
  28. {
  29. title: '平均喷量(升/亩)',
  30. dataIndex: 'traffic',
  31. key: 'traffic',
  32. },
  33. {
  34. title: '作业时间',
  35. dataIndex: 'jobTime',
  36. key: 'jobTime',
  37. },
  38. ];
  39. const [loading, setLoading] = React.useState(false);
  40. const [list, setList] = React.useState([]);
  41. const [total, setTotal] = React.useState(0);
  42. const [page, setPage] = React.useState({ current: 1, pageSize: 10, total: 0 });
  43. const pagination = React.useMemo(
  44. () => ({
  45. ...page,
  46. showTotal: (total, range) => `总计 ${total} 条`,
  47. onChange: (page, pageSize) => {
  48. setPage({
  49. current: page,
  50. pageSize,
  51. total: 0,
  52. });
  53. queryData({
  54. machineryId: machine.machineryId,
  55. userId,
  56. pageNum: page,
  57. pageSize,
  58. });
  59. },
  60. }),
  61. [page, machine, userId],
  62. );
  63. const queryData = (params) => {
  64. setLoading(true);
  65. getDeviceJobByOrg({ ...params, startDate: '2000-01-01', endDate: '2099-12-31' })
  66. .then((res) => {
  67. setLoading(false);
  68. const { list: dtList, totalArea } = res;
  69. setList(dtList.records || []);
  70. setTotal(totalArea || 0);
  71. setPage({
  72. current: dtList.current,
  73. pageSize: dtList.size,
  74. total: dtList.total,
  75. });
  76. })
  77. .catch((err) => {
  78. console.error(err);
  79. setLoading(false);
  80. });
  81. };
  82. React.useEffect(() => {
  83. if (machine) {
  84. const { machineryId } = machine;
  85. queryData({
  86. machineryId,
  87. userId,
  88. pageNum: 1,
  89. pageSize: 10,
  90. });
  91. }
  92. }, [machine, userId]);
  93. return (
  94. <div>
  95. <div style={{ textAlign: 'left', marginBottom: '16px', fontSize: '16px' }}>
  96. <span>总作业面积 </span>
  97. <strong>{total}</strong>
  98. <span> 亩</span>
  99. </div>
  100. <Table
  101. loading={loading}
  102. rowKey="jobNo"
  103. columns={columns}
  104. dataSource={list}
  105. pagination={pagination}
  106. />
  107. </div>
  108. );
  109. };