TaskOrder.tsx 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. import PageContent from '@/components/PageContent';
  2. import PageTitle from '@/components/PageTitle';
  3. import { IUserType } from '@/pages/TaskManage/Detail/TaskList/taskList.types';
  4. import SubTitle from '@/pages/TaskManage/components/SubTitle';
  5. import { OrderStatus } from '@/pages/TaskManage/constent';
  6. import {
  7. getCraftRecordList,
  8. getMaintainRecordList,
  9. getRepairRecordList,
  10. } from '@/services/TaskManage';
  11. import { useLocation } from '@@/exports';
  12. import { connect, useRequest } from '@umijs/max';
  13. import { Col, Row } from 'antd';
  14. import dayjs from 'dayjs';
  15. import { DefaultOptionType } from 'rc-select/es/Select';
  16. import React, { useEffect, useState } from 'react';
  17. import styles from './taskOrder.less';
  18. interface IPropsType {
  19. userList: IUserType[];
  20. dispatch: (args: { type: string; payload: object }) => {};
  21. }
  22. interface IOrderInfo {
  23. CreateTime: string;
  24. PlanTime: string;
  25. RepairTime: string;
  26. Reason: string;
  27. Repairman: string | IUserType;
  28. DispatchMan: string | IUserType;
  29. OrderStatus: string | DefaultOptionType;
  30. Lubrication?: number;
  31. Fasten?: number;
  32. RustRemoval?: number;
  33. AntiCorrosive?: number;
  34. Clean?: number;
  35. Check?: number;
  36. }
  37. const TaskOrder: React.FC<IPropsType> = (props) => {
  38. const { userList, dispatch } = props;
  39. const location = useLocation();
  40. const queryParams = new URLSearchParams(location.search);
  41. const project_id = Number(queryParams.get('project_id'));
  42. const order_id = Number(queryParams.get('order_id'));
  43. const order_type = Number(queryParams.get('order_type'));
  44. const [orderInfo, setOrderInfo] = useState<IOrderInfo>();
  45. // 根据type请求详情
  46. const { run: getMaintainDetail } = useRequest(getMaintainRecordList, {
  47. manual: true,
  48. formatResult: (result) => {
  49. const temp = result.data.list[0];
  50. const tempDetail = {
  51. CreateTime: dayjs(temp.CreateTime).format('YYYY-MM-DD HH:mm'),
  52. PlanTime: dayjs(temp.PlanTime).format('YYYY-MM-DD HH:mm'),
  53. RepairTime: dayjs(temp.RepairTime).format('YYYY-MM-DD HH:mm') || '-',
  54. Reason: temp.Note,
  55. Lubrication: temp.Lubrication,
  56. Fasten: temp.Fasten,
  57. RustRemoval: temp.RustRemoval,
  58. AntiCorrosive: temp.Anticorrosive,
  59. Clean: temp.Clean,
  60. Check: temp.Check,
  61. Repairman:
  62. userList.find((item) => item.ID === temp.MaintenancePerson) || '-',
  63. DispatchMan:
  64. userList.find(
  65. (item) => (item.ID = temp.Operators[0]?.Operator?.ID),
  66. ) || '-',
  67. OrderStatus:
  68. OrderStatus.find((item) => item.value === temp.Status) || '-',
  69. };
  70. setOrderInfo(tempDetail);
  71. },
  72. });
  73. // 根据type请求详情
  74. const { run: getRepairDetail } = useRequest(getRepairRecordList, {
  75. manual: true,
  76. formatResult: (result: any) => {
  77. const temp = result.data.list[0];
  78. if (temp === undefined) {
  79. return;
  80. }
  81. const tempDetail: IOrderInfo = {
  82. CreateTime: dayjs(temp.CreateTime).format('YYYY-MM-DD HH:mm'),
  83. PlanTime: dayjs(temp.PlanTime).format('YYYY-MM-DD HH:mm'),
  84. RepairTime:
  85. (temp.RepairTime &&
  86. dayjs(temp.RepairTime).format('YYYY-MM-DD HH:mm')) ||
  87. '-',
  88. Reason: temp.Reason,
  89. Repairman: userList.find((item) => item.ID === temp.Repairman) || '-',
  90. DispatchMan:
  91. userList.find((item) => {
  92. item.ID === temp.operator_id;
  93. }) || '-',
  94. OrderStatus:
  95. OrderStatus.find((item) => item.value === temp.AcceptanceStatus) ||
  96. '-',
  97. };
  98. setOrderInfo(tempDetail);
  99. },
  100. });
  101. // 根据type请求详情
  102. const { run: getCraftDetail } = useRequest(getCraftRecordList, {
  103. manual: true,
  104. formatResult: (result) => {
  105. const temp = result.data.list[0];
  106. const tempDetail = {
  107. CreateTime: dayjs(temp.start_time).format('YYYY-MM-DD HH:mm'),
  108. PlanTime: dayjs(temp.plan_end_time).format('YYYY-MM-DD HH:mm'),
  109. RepairTime:
  110. (temp.actual_end_time &&
  111. dayjs(temp.actual_end_time).format('YYYY-MM-DD HH:mm')) ||
  112. '-',
  113. Reason: temp.detail,
  114. Repairman: userList.find((item) => item.ID === temp.checker_id) || '-',
  115. DispatchMan:
  116. userList.find((item) => item.ID === temp.operator_id) || '-',
  117. OrderStatus:
  118. OrderStatus.find((item) => item.value === temp.status) || '-',
  119. };
  120. setOrderInfo(tempDetail);
  121. },
  122. });
  123. useEffect(() => {
  124. if (userList.length === 0) {
  125. dispatch({
  126. type: 'taskUser/fetchUserList',
  127. payload: { project_id },
  128. });
  129. }
  130. switch (order_type) {
  131. // 工艺
  132. case 1:
  133. getCraftDetail({ project_id, work_id: order_id });
  134. break;
  135. // 维修
  136. case 2:
  137. getRepairDetail({ project_id, id: order_id });
  138. break;
  139. // 保养
  140. case 3:
  141. getMaintainDetail({ project_id, id: order_id });
  142. break;
  143. }
  144. }, []);
  145. return (
  146. <PageContent closeable={false}>
  147. <PageTitle returnable>工单详情</PageTitle>
  148. <div className={styles.selfCardBox}>
  149. <div className={styles.orderInfo}>
  150. <SubTitle
  151. title="工单信息"
  152. // @ts-ignore
  153. showStatus={orderInfo?.OrderStatus.value === 2}
  154. radius
  155. />
  156. <div style={{ padding: '15px', letterSpacing: '1.5px' }}>
  157. <Row className={styles.rowMargin}>
  158. <Col className={styles.fontS28} span={16}>
  159. {/*// @ts-ignore*/}
  160. 工单类型:
  161. {order_type === 1 ? '工艺' : order_type === 2 ? '维修' : '保养'}
  162. </Col>
  163. <Col className={styles.fontS28} span={8}>
  164. {/*// @ts-ignore*/}
  165. 工单负责人:{orderInfo?.Repairman?.CName || '-'}
  166. </Col>
  167. </Row>
  168. <Row className={styles.rowMargin}>
  169. <Col className={styles.fontS28} span={16}>
  170. {/*// @ts-ignore*/}
  171. 工单状态:{orderInfo?.OrderStatus?.label}
  172. </Col>
  173. <Col className={styles.fontS28} span={8}>
  174. {/*// @ts-ignore*/}
  175. 派单人员:{orderInfo?.DispatchMan?.CName}
  176. </Col>
  177. </Row>
  178. <Row className={styles.rowMargin}>
  179. <Col className={styles.fontS28}>
  180. 派单时间:{orderInfo?.CreateTime || '-'}
  181. </Col>
  182. </Row>
  183. <Row className={styles.rowMargin}>
  184. <Col className={styles.fontS28}>
  185. 计划完成时间:{orderInfo?.PlanTime || '-'}
  186. </Col>
  187. </Row>
  188. <Row className={styles.rowMargin}>
  189. <Col className={styles.fontS28}>
  190. 实际完成时间:{orderInfo?.RepairTime || '-'}
  191. </Col>
  192. </Row>
  193. <Row>
  194. <Col className={styles.fontS28}>工单详情:</Col>
  195. <Col className={styles.fontS28} span={18}>
  196. {orderInfo?.Reason}
  197. {/*<Table />*/}
  198. </Col>
  199. </Row>
  200. </div>
  201. </div>
  202. {order_type === 3 && (
  203. <div>
  204. <SubTitle title="维修内容" />
  205. <div style={{ padding: '15px' }}>
  206. <Row className={styles.rowMargin} justify={'space-around'}>
  207. <Col className={styles.fontS28} span={8}>
  208. 是否润滑/加油:{orderInfo?.Lubrication === 1 ? '是' : '否'}
  209. </Col>
  210. <Col className={styles.fontS28} span={8}>
  211. 是否拆检:{orderInfo?.Check === 1 ? '是' : '否'}
  212. </Col>
  213. <Col className={styles.fontS28} span={8}>
  214. 是否清洁:{orderInfo?.Clean === 1 ? '是' : '否'}
  215. </Col>
  216. </Row>
  217. <Row justify={'space-around'}>
  218. <Col className={styles.fontS28} span={8}>
  219. 是否紧固:{orderInfo?.Fasten === 1 ? '是' : '否'}
  220. </Col>
  221. <Col className={styles.fontS28} span={8}>
  222. 是否除锈:{orderInfo?.AntiCorrosive === 1 ? '是' : '否'}
  223. </Col>
  224. <Col className={styles.fontS28} span={8}>
  225. 是否防腐:{orderInfo?.RustRemoval === 1 ? '是' : '否'}
  226. </Col>
  227. </Row>
  228. </div>
  229. </div>
  230. )}
  231. {/*<div>*/}
  232. {/* <SubTitle title="工单流程" />*/}
  233. {/* <div style={{ padding: '15px' }}>*/}
  234. {/* <Steps*/}
  235. {/* direction="vertical"*/}
  236. {/* style={{ fontSize: '14px' }}*/}
  237. {/* current={1}*/}
  238. {/* items={[*/}
  239. {/* {*/}
  240. {/* title: '工单已派遣至值班人员张**',*/}
  241. {/* description: '2023-08-02 13:23',*/}
  242. {/* },*/}
  243. {/* {*/}
  244. {/* title: '张**接收工单',*/}
  245. {/* description: '2023-08-02 13:23',*/}
  246. {/* },*/}
  247. {/* {*/}
  248. {/* title: '张**提交处理结果',*/}
  249. {/* description: '2023-08-02 13:23',*/}
  250. {/* },*/}
  251. {/* {*/}
  252. {/* title: '工单审批通过',*/}
  253. {/* description: '2023-08-02 13:23',*/}
  254. {/* },*/}
  255. {/* ]}*/}
  256. {/* />*/}
  257. {/* </div>*/}
  258. {/*</div>*/}
  259. </div>
  260. </PageContent>
  261. );
  262. };
  263. export default connect(({ taskUser }: any): { userList: IUserType[] } => {
  264. return {
  265. userList: taskUser.userList,
  266. };
  267. })(TaskOrder);