index.tsx 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. import BreadTit from "@/components/BreadTit";
  2. import ImageLazy from "@/components/ImageLazy";
  3. import LookModal from "@/components/LookObjTable/LookModal";
  4. import { RootState } from "@/store";
  5. import { auditObject6API, object6infoOutAPI } from "@/store/action/object6";
  6. import { statusObj } from "@/utils/dataChange";
  7. import history, { urlParameter } from "@/utils/history";
  8. import { Button, message, Select, Table } from "antd";
  9. import TextArea from "antd/es/input/TextArea";
  10. import React, {
  11. useCallback,
  12. useEffect,
  13. useMemo,
  14. useRef,
  15. useState,
  16. } from "react";
  17. import { useDispatch, useSelector } from "react-redux";
  18. import { useLocation } from "react-router-dom";
  19. import styles from "./index.module.scss";
  20. const { Option } = Select;
  21. function AuditObject6() {
  22. const dispatch = useDispatch();
  23. // 获取地址栏参数
  24. const location = useLocation();
  25. const urlParamRef = useRef<any>({});
  26. useEffect(() => {
  27. urlParamRef.current = urlParameter(location.search);
  28. // console.log("地址栏参数", urlParamRef.current);
  29. }, [location]);
  30. const { info, list: tableList } = useSelector(
  31. (state: RootState) => state.object6Store.lookInfo
  32. );
  33. // 审核结果筛选
  34. const [value, setValue] = useState(3);
  35. const valueChangeFu = (val: number) => {
  36. setValue(val);
  37. };
  38. // 审核说明
  39. const [value2, setValue2] = useState("");
  40. const getInfo = useCallback(async () => {
  41. const id = urlParamRef.current.id;
  42. const res1 = await object6infoOutAPI(id);
  43. const info = res1.data.entity;
  44. const list = res1.data.child;
  45. info.statusTxt = statusObj[info.status];
  46. dispatch({ type: "object6/getLookInfo", payload: { info, list } });
  47. }, [dispatch]);
  48. useEffect(() => {
  49. getInfo();
  50. }, [getInfo]);
  51. // 控制弹窗的显示隐藏
  52. const [show, setShow] = useState(false);
  53. // 点击表格里面的查看
  54. const lookIdRef = useRef(-1);
  55. const lookGoods = useCallback((id: number) => {
  56. lookIdRef.current = id;
  57. setShow(true);
  58. }, []);
  59. // 点击返回
  60. const cancelFu = useCallback(() => {
  61. history.push({
  62. pathname: `/object/6`,
  63. state: {
  64. k: urlParamRef.current.k ? urlParamRef.current.k : "1",
  65. d: urlParamRef.current.d,
  66. },
  67. });
  68. }, []);
  69. // 点击确定
  70. const btnOkFu = useCallback(async () => {
  71. const txt = value2.replaceAll(" ", "").replaceAll("\n", "");
  72. if (txt === "") return message.warning("审核说明不能为空!");
  73. const res: any = await auditObject6API({
  74. id: Number(urlParamRef.current.id),
  75. reason: value2,
  76. status: value,
  77. });
  78. if (res.code === 0) {
  79. message.success("操作成功!");
  80. cancelFu();
  81. }
  82. }, [cancelFu, value, value2]);
  83. // 表格格式
  84. const columns = useMemo(() => {
  85. const tempArr = [
  86. {
  87. title: "缩略图",
  88. render: (item: any) => (
  89. <ImageLazy width={120} height={70} src={item.thumb} />
  90. ),
  91. },
  92. {
  93. title: "藏品编号名称",
  94. dataIndex: "dictNum",
  95. },
  96. {
  97. title: "藏品编号",
  98. render: (item: any) => (item.num ? item.num : "-"),
  99. },
  100. {
  101. title: "藏品名称",
  102. dataIndex: "name",
  103. },
  104. {
  105. title: "类别",
  106. dataIndex: "dictGoodType",
  107. },
  108. {
  109. title: "完残程度",
  110. dataIndex: "complete",
  111. },
  112. {
  113. title: "年代",
  114. dataIndex: "dictAge",
  115. },
  116. {
  117. title: "操作",
  118. render: (item: any) => (
  119. <>
  120. <Button type="text" danger onClick={() => lookGoods(item.id)}>
  121. 查看
  122. </Button>
  123. </>
  124. ),
  125. },
  126. ];
  127. return tempArr;
  128. }, [lookGoods]);
  129. return (
  130. <div className={styles.AuditObject6}>
  131. <div className="breadTit">
  132. <BreadTit>
  133. <div className="breadTitRow">藏品注销</div>
  134. <div className="splitStr">/</div>
  135. <div className="breadTitRow active">审核</div>
  136. </BreadTit>
  137. </div>
  138. <div className="objectSonMain">
  139. <div className="topTit">注销信息</div>
  140. <div className="topInfo">
  141. <div className="topInfoRow">
  142. <div>
  143. <div className="one">注销编号:</div>
  144. <div>{info.num}</div>
  145. </div>
  146. <div>
  147. <div className="one">登记人员:</div>
  148. <div>{info.creatorName}</div>
  149. </div>
  150. </div>
  151. <div className="topInfoTex" title={info.description}>
  152. <span>注销说明:</span>
  153. {info.description ? info.description : "-"}
  154. </div>
  155. </div>
  156. <br />
  157. <div className="topTit">藏品信息</div>
  158. <div className="goodsInfo">
  159. {/* 表格信息 */}
  160. <Table
  161. size="small"
  162. scroll={{ y: 245 }}
  163. dataSource={tableList}
  164. columns={columns}
  165. rowKey="id"
  166. pagination={false}
  167. />
  168. <br />
  169. <div className="inputBox1">
  170. <div className="inputBoxTit">
  171. <span>* </span>审核结果:
  172. </div>
  173. <Select
  174. style={{ width: 150 }}
  175. value={value}
  176. onChange={(val) => valueChangeFu(val)}
  177. >
  178. <Option value={3}>通过</Option>
  179. <Option value={2}>不通过</Option>
  180. </Select>
  181. </div>
  182. <div className="inputBox1 inputBox2">
  183. <div className="inputBoxTit">
  184. <span>* </span>审核说明:
  185. </div>
  186. <div className="inputBoxText">
  187. <TextArea
  188. value={value2}
  189. onChange={(e) => setValue2(e.target.value)}
  190. rows={3}
  191. placeholder="请输入"
  192. showCount
  193. maxLength={255}
  194. />
  195. </div>
  196. </div>
  197. </div>
  198. <div className="backBtn">
  199. <Button onClick={btnOkFu} type="primary">
  200. 提交
  201. </Button>
  202. &emsp;
  203. <Button onClick={cancelFu}>返回</Button>
  204. </div>
  205. </div>
  206. {/* 点击查看出来的对话框 */}
  207. {show ? (
  208. <LookModal
  209. id={lookIdRef.current}
  210. show={show}
  211. closeShow={() => setShow(false)}
  212. />
  213. ) : null}
  214. </div>
  215. );
  216. }
  217. const MemoAuditObject6 = React.memo(AuditObject6);
  218. export default MemoAuditObject6;