index.tsx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. import { FC, useEffect, useRef, useState } from "react";
  2. import { Button, Tabs, Tag } from "antd";
  3. import { FormPageFooter, PageContainer } from "@/components";
  4. import { OverallAssessment } from "./components/OverallAssessment";
  5. import { IndexAssessment } from "./components/IndexAssessment";
  6. import style from "./index.module.scss";
  7. import { useHashQuery } from "@/hooks";
  8. import { DEPT_STATUS_MAP, PUBLISH_STATUS_MAP } from "@/constants";
  9. import { useParams } from "react-router-dom";
  10. import {
  11. getManageEvaluationDetailApi,
  12. getManageFormDetailApi,
  13. getManageIndexDetailApi,
  14. } from "@/api";
  15. import { IManageFormDetail, IManageIndexDetail } from "@/types";
  16. import { DageLoading } from "@dage/pc-components";
  17. import { isNumber } from "lodash";
  18. const AssessmentDetailPage: FC = () => {
  19. // 判断是否为考核填报进入
  20. const isReportDetail = useRef(window.location.hash.indexOf("form") > -1);
  21. // 判断是否为考核评定进入
  22. const isEvalutionDetail = useRef(
  23. window.location.hash.indexOf("evaluation") > -1
  24. );
  25. // 判断是否为考核管理进入
  26. const isIndexDetail = useRef(window.location.hash.indexOf("index") > -1);
  27. const [tab, setTab] = useHashQuery("tab", "1");
  28. const [loading, setLoading] = useState(false);
  29. const [detail, setDetail] = useState<
  30. IManageIndexDetail | IManageFormDetail | null
  31. >(null);
  32. const params = useParams();
  33. const getDetail = async () => {
  34. try {
  35. setLoading(true);
  36. const data = await (isReportDetail.current
  37. ? getManageFormDetailApi
  38. : isEvalutionDetail.current
  39. ? getManageEvaluationDetailApi
  40. : getManageIndexDetailApi)(params.id as string);
  41. setDetail(data);
  42. } finally {
  43. setLoading(false);
  44. }
  45. };
  46. useEffect(() => {
  47. getDetail();
  48. }, []);
  49. return (
  50. <>
  51. <PageContainer
  52. title={detail?.name || ""}
  53. style={{
  54. background: "white",
  55. borderRadius: 5,
  56. padding: "0 25px",
  57. boxShadow: "0px 0px 10px 0px rgba(0,0,0,0.05)",
  58. }}
  59. headerSlot={
  60. detail ? (
  61. <div style={{ flex: 1 }}>
  62. {!isIndexDetail.current ? (
  63. <Tag
  64. color={
  65. DEPT_STATUS_MAP[(detail as IManageFormDetail).deptStatus]
  66. .color
  67. }
  68. >
  69. {
  70. DEPT_STATUS_MAP[(detail as IManageFormDetail).deptStatus]
  71. .label
  72. }
  73. </Tag>
  74. ) : (
  75. <Tag
  76. color={
  77. PUBLISH_STATUS_MAP[(detail as IManageIndexDetail).status]
  78. .color
  79. }
  80. >
  81. {
  82. PUBLISH_STATUS_MAP[(detail as IManageIndexDetail).status]
  83. .label
  84. }
  85. </Tag>
  86. )}
  87. </div>
  88. ) : undefined
  89. }
  90. >
  91. {loading && <DageLoading />}
  92. <div className={style.topContent}>
  93. <div className={style.topContentLeft}>
  94. <div className={style.topContentItem}>
  95. <label>总分值</label>
  96. <span>{isNumber(detail?.score) ? detail?.score : "--"}</span>
  97. </div>
  98. </div>
  99. <div className={style.topContentRight}>
  100. <div className={style.topContentItem}>
  101. <label>考核周期</label>
  102. <span>
  103. {detail?.dateStart}~{detail?.dateEnd}
  104. </span>
  105. </div>
  106. <div className={style.topContentItem}>
  107. <label>{detail?.creatorName}</label>
  108. <span style={{ fontWeight: "normal" }}>{detail?.createTime}</span>
  109. </div>
  110. </div>
  111. </div>
  112. </PageContainer>
  113. <div className={style.pane}>
  114. <Tabs
  115. size="large"
  116. defaultActiveKey={tab}
  117. tabBarGutter={60}
  118. className={style.tabs}
  119. indicator={{
  120. size: 75,
  121. }}
  122. items={[
  123. {
  124. key: "1",
  125. label: "总体考核",
  126. children: (
  127. <OverallAssessment
  128. detail={detail}
  129. isReportDetail={isReportDetail.current}
  130. isEvalutionDetail={isEvalutionDetail.current}
  131. />
  132. ),
  133. },
  134. {
  135. key: "2",
  136. label: "指标考核",
  137. children: (
  138. <IndexAssessment
  139. isReportDetail={isReportDetail.current}
  140. isEvalutionDetail={isEvalutionDetail.current}
  141. />
  142. ),
  143. },
  144. ]}
  145. onChange={(v) => setTab(v)}
  146. />
  147. </div>
  148. {isReportDetail.current && (
  149. <FormPageFooter>
  150. <Button size="large" type="primary">
  151. 提交
  152. </Button>
  153. <Button size="large">保存并关闭</Button>
  154. </FormPageFooter>
  155. )}
  156. {isEvalutionDetail.current && (
  157. <FormPageFooter>
  158. <Button size="large" type="primary">
  159. 完成评定
  160. </Button>
  161. <Button size="large" type="primary" ghost>
  162. 保存
  163. </Button>
  164. <Button size="large" danger style={{ width: 160 }}>
  165. 退回不合格的资料
  166. </Button>
  167. <Button size="large">关闭</Button>
  168. </FormPageFooter>
  169. )}
  170. </>
  171. );
  172. };
  173. export default AssessmentDetailPage;