index.tsx 6.4 KB

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