DetailModal.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. import React, { useState, useEffect, useMemo, useRef } from 'react';
  2. import { Form, Modal, Steps, Tabs, TreeSelect } from 'antd';
  3. import styles from './DetailModal.less';
  4. import TableRender from './TableRender';
  5. import MemberModal from './MemberModal';
  6. import StatusRender from './StatusRender';
  7. const { Step } = Steps;
  8. // 新建
  9. function DetailModal(props) {
  10. const {
  11. visible,
  12. onClose,
  13. depUserTree,
  14. onOk,
  15. form,
  16. data,
  17. isEdit,
  18. flowList = [],
  19. disabled,
  20. loading,
  21. } = props;
  22. const [codes, setCodes] = useState({
  23. type: '',
  24. industry: '',
  25. location: '',
  26. name: '',
  27. version: '',
  28. });
  29. const [params, setParams] = useState({
  30. sub_status: data.sub_status,
  31. });
  32. useEffect(() => {
  33. if (!visible || !data.id) return;
  34. setCodes({
  35. type: data.TypeInfo?.code,
  36. industry: data.IndustryInfo?.code,
  37. location: data.location_code,
  38. name: data.name,
  39. version: data.version,
  40. });
  41. }, [data, visible]);
  42. const renderDetail = () => (
  43. <>
  44. <div className={styles.subTitle}>项目详情</div>
  45. <Form labelCol={{ span: 4 }} wrapperCol={{ span: 18 }}>
  46. <Form.Item className={styles.formItem} label="项目名称">
  47. {data.project_name}
  48. </Form.Item>
  49. {data.TypeInfo && (
  50. <Form.Item className={styles.formItem} label="项目类别">
  51. {data.TypeInfo?.name}
  52. </Form.Item>
  53. )}
  54. <Form.Item className={styles.formItem} label="流程">
  55. {flowList.find(item => item.id == data.flow_id)?.name}
  56. </Form.Item>
  57. {data.type_id != 7 && (
  58. <>
  59. <Form.Item className={styles.formItem} label="行业名称">
  60. {data.IndustryInfo?.name}
  61. </Form.Item>
  62. <Form.Item className={styles.formItem} label="项目地区">
  63. {data.location}({data.location_code})
  64. </Form.Item>
  65. <Form.Item className={styles.formItem} label="项目简称">
  66. {data.name}
  67. </Form.Item>
  68. <Form.Item className={styles.formItem} label="项目批次">
  69. {data.version}期
  70. </Form.Item>
  71. </>
  72. )}
  73. {!isEdit && data.AuthorUser ? (
  74. <Form.Item className={styles.formItem} label="售前项目经理">
  75. {data.AuthorUser.CName}
  76. </Form.Item>
  77. ) : (
  78. <Form.Item label="售前项目经理" className={styles.formItem} name="managerID">
  79. <TreeSelect
  80. defaultValue={data.AuthorUser?.CName}
  81. showSearch
  82. allowClear
  83. style={{ width: '60%' }}
  84. placeholder="请选择项目经理"
  85. multiple={false}
  86. filterTreeNode={(input, option) => {
  87. return option.props.title === input;
  88. }}
  89. treeData={depUserTree}
  90. />
  91. </Form.Item>
  92. )}
  93. {data.AuthorDepInfo && (
  94. <Form.Item className={styles.formItem} label="所属部门">
  95. {data.AuthorDepInfo.Name}
  96. </Form.Item>
  97. )}
  98. {data.project_full_code && (
  99. <Form.Item className={styles.formItem} label="项目编号">
  100. {data.project_full_code}
  101. </Form.Item>
  102. )}
  103. {data.WtyManager && (
  104. <Form.Item className={styles.formItem} label="质保经理">
  105. {data.WtyManager.CName}
  106. </Form.Item>
  107. )}
  108. {data.OptManager && (
  109. <Form.Item className={styles.formItem} label="运营经理">
  110. {data.OptManager.CName}
  111. </Form.Item>
  112. )}
  113. {/* <Form.Item className={styles.formItem} label="项目阶段">
  114. {data.OptManager.CName}
  115. </Form.Item>
  116. <Form.Item className={styles.formItem} label="现阶段状态">
  117. {data.OptManager.CName}
  118. </Form.Item> */}
  119. <Form.Item className={styles.formItem} label="项目规模">
  120. <TableRender
  121. onlyShow={true}
  122. value={'[{"type":"UF","scale":"10"},{"type":"RO","scale":"20"}]'}
  123. />
  124. </Form.Item>
  125. </Form>
  126. </>
  127. );
  128. const flow = useMemo(() => {
  129. if (!data.flow_id) return {};
  130. return flowList.find(item => item.id == data.flow_id) || {};
  131. }, [flowList, data]);
  132. const current = useMemo(() => {
  133. if (!data.node_id) return 0;
  134. return flow.Nodes?.findIndex(item => item.id == data.node_id);
  135. }, [flowList, data]);
  136. const getAudits = nodeInfo => {
  137. switch (nodeInfo.id) {
  138. case 11:
  139. return '执行项目经理';
  140. case 12:
  141. return '运营经理';
  142. case 13:
  143. return '执行项目经理';
  144. case 14:
  145. return '质保经理';
  146. default:
  147. return (nodeInfo.NodeAudits || []).map(item => item.AuthorRoleInfo.Name).join(',');
  148. }
  149. };
  150. const renderAuth = () => (
  151. <div className={styles.authDetail}>
  152. <div className={styles.subTitle}>审核详情</div>
  153. <Steps className={styles.auth} current={current}>
  154. {(flow.Nodes || []).map(item => (
  155. <Step key={item.id} title={item.node} description={`审批人:${getAudits(item)}`} />
  156. ))}
  157. </Steps>
  158. </div>
  159. );
  160. return (
  161. <Modal title="项目详情" width={800} visible={visible} onCancel={onClose} footer={null}>
  162. {renderDetail()}
  163. {/* {data.audit_status != 0 && renderAuth()} */}
  164. <Tabs defaultActiveKey="3">
  165. <Tabs.TabPane tab="成员管理" key="1">
  166. <MemberModal isEdit={isEdit} currentItem={data} />
  167. </Tabs.TabPane>
  168. <Tabs.TabPane tab="审核详情" key="2">
  169. {renderAuth()}
  170. </Tabs.TabPane>
  171. <Tabs.TabPane tab="状态记录" key="3">
  172. <StatusRender />
  173. </Tabs.TabPane>
  174. </Tabs>
  175. </Modal>
  176. );
  177. }
  178. export default DetailModal;