DepCompareModal.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import React, { useState, useEffect } from 'react';
  2. import { Modal, Table } from 'antd';
  3. import { connect } from 'dva';
  4. import moment from 'moment';
  5. import { set } from 'lodash';
  6. function DepCompareModal(props) {
  7. const {
  8. dispatch,
  9. visible,
  10. onOk,
  11. onCancel,
  12. depCompare,
  13. depUserProject,
  14. depUser,
  15. filter,
  16. loading,
  17. } = props;
  18. const [userVisible, setUserVisible] = useState(false);
  19. //本部门
  20. const columns = [
  21. { title: '用户名称', dataIndex: 'c_name' },
  22. { title: '员工号', dataIndex: 'user_name' },
  23. { title: '执行项目人日', dataIndex: 'type_project_cnt' },
  24. { title: '售前支持', dataIndex: 'type_sale_cnt' },
  25. { title: '市场品牌', dataIndex: 'type_market_cnt' },
  26. { title: '日常', dataIndex: 'type_normal_cnt' },
  27. { title: '标准化', dataIndex: 'type_standardize_cnt' },
  28. { title: '研发', dataIndex: 'type_rd_cnt' },
  29. // { title: '漏填工时', dataIndex: 'type_lost_cnt' },
  30. { title: '应填报总工时', dataIndex: 'total_cnt' },
  31. {
  32. title: '有效利用率',
  33. dataIndex: 'usage_percent',
  34. render: (percent = 0) => (percent * 100).toFixed(2) + '%',
  35. },
  36. ];
  37. // 其他部门
  38. const columnsDep = [
  39. {
  40. width: 350,
  41. render: record =>
  42. // record.dep_name || <a onClick={() => onClickUser(record)}>{record.c_name}</a>,
  43. record.dep_name || record.c_name,
  44. },
  45. { title: '执行项目', dataIndex: 'type_project_cnt' },
  46. { title: '售前项目', dataIndex: 'type_sale_cnt' },
  47. { title: '研发项目', dataIndex: 'type_rd_cnt' },
  48. { title: '运营项目', dataIndex: 'type_opt_cnt' },
  49. { title: '质保项目', dataIndex: 'type_wty_cnt' },
  50. { title: '总计', dataIndex: 'total_cnt' },
  51. ];
  52. const columnsUser = [
  53. { title: '项目名称', dataIndex: 'project_name' },
  54. { title: '总工时', dataIndex: 'total_cnt' },
  55. ];
  56. const onChangePage = pagination => {
  57. dispatch({
  58. type: 'report/queryUserReport',
  59. payload: {
  60. ...filter,
  61. currentPage: pagination.current,
  62. },
  63. });
  64. };
  65. const onExpand = (expanded, record) => {
  66. if (expanded && !record.isLoad) {
  67. dispatch({
  68. type: 'report/queryDepCompareUser',
  69. payload: {
  70. s_time: filter.s_time,
  71. e_time: filter.e_time,
  72. project_dep_id: filter.dep_id,
  73. record: record,
  74. },
  75. });
  76. }
  77. };
  78. const onClickUser = user => {
  79. dispatch({
  80. type: 'report/queryDepUserProject',
  81. payload: {
  82. s_time: filter.s_time,
  83. e_time: filter.e_time,
  84. project_dep_id: filter.dep_id,
  85. dep_id: user.dep_id,
  86. user_id: user.user_id,
  87. },
  88. });
  89. setUserVisible(true);
  90. };
  91. useEffect(() => {
  92. if (!filter?.dep_id) return;
  93. dispatch({
  94. type: 'report/queryUserReport',
  95. payload: filter,
  96. });
  97. // dispatch({
  98. // type: 'report/queryDepCompare',
  99. // payload: filter,
  100. // });
  101. }, [filter]);
  102. return (
  103. <>
  104. <Modal
  105. title="部门对账单"
  106. width="80%"
  107. visible={visible}
  108. onCancel={onCancel}
  109. footer={false}
  110. destroyOnClose
  111. >
  112. <Table
  113. title={() => '本部门工时详情'}
  114. columns={columns}
  115. loading={loading}
  116. dataSource={depUser.list}
  117. pagination={depUser.pagination}
  118. onChange={onChangePage}
  119. ></Table>
  120. {/* <Table
  121. title={() => '本部门在所属项目下产生的工时'}
  122. columns={columns}
  123. loading={loading}
  124. dataSource={depCompare.length == 0 ? [] : [depCompare[0]]}
  125. rowKey="key"
  126. childrenColumnName="child"
  127. pagination={false}
  128. onExpand={onExpand}
  129. /> */}
  130. {/* {depCompare.length > 0 && (
  131. <Table
  132. title={() => '其他部门在所属项目下产生的工时'}
  133. columns={columnsDep}
  134. loading={loading}
  135. dataSource={depCompare}
  136. rowKey="key"
  137. childrenColumnName="child"
  138. pagination={false}
  139. onExpand={onExpand}
  140. />
  141. )} */}
  142. </Modal>
  143. {/* <Modal
  144. title="用户详情"
  145. width="80%"
  146. visible={userVisible}
  147. onCancel={() => setUserVisible(false)}
  148. footer={false}
  149. destroyOnClose
  150. >
  151. <Table
  152. columns={columnsUser}
  153. loading={loading}
  154. dataSource={depUserProject}
  155. pagination={false}
  156. rowKey="project_name"
  157. ></Table>
  158. </Modal> */}
  159. </>
  160. );
  161. }
  162. export default connect(({ report, loading }) => ({
  163. depCompare: report.depCompare,
  164. depUserProject: report.depUserProject,
  165. depUser: report.depUser,
  166. loading: loading.models.report,
  167. }))(DepCompareModal);