index.tsx 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905
  1. import {
  2. Button,
  3. Cascader,
  4. Form,
  5. Input,
  6. InputNumber,
  7. message,
  8. Modal,
  9. Popconfirm,
  10. Select,
  11. Table,
  12. } from "antd";
  13. import { PlusOutlined, CloseCircleOutlined } from "@ant-design/icons";
  14. import TextArea from "antd/es/input/TextArea";
  15. import React, {
  16. useCallback,
  17. useEffect,
  18. useMemo,
  19. useRef,
  20. useState,
  21. } from "react";
  22. import styles from "./index.module.scss";
  23. import classNames from "classnames";
  24. import "./index.css";
  25. import { useDispatch, useSelector } from "react-redux";
  26. import { RootState } from "@/store";
  27. import ImageLazy from "../ImageLazy";
  28. import {
  29. delInfileAPI,
  30. getInfoInAPI,
  31. goodsSonAddAPI,
  32. object1AddUpFileAPI,
  33. } from "@/store/action/object1";
  34. import { goodsChangeObj } from "@/utils/dataChange";
  35. import { editObj2GoodsAPI } from "@/store/action/object2";
  36. const { Option } = Select;
  37. type Props = {
  38. id: any;
  39. colsePage: any;
  40. editId?: any;
  41. dirCode: any;
  42. upInfoAPIFu?: any;
  43. };
  44. function ObjectAdd({ id, colsePage, editId, dirCode, upInfoAPIFu }: Props) {
  45. const dispatch = useDispatch();
  46. // 没有通过校验
  47. const onFinishFailed = () => {
  48. setTitSelect("tit1");
  49. return message.warning("有表单不符号规则!");
  50. };
  51. // --------通过校验之后发送请求----------点击确定
  52. const onFinish = async (values: any) => {
  53. const oldObj = {} as any;
  54. for (const k in values) {
  55. if (values[k]) oldObj[k] = values[k];
  56. }
  57. // 外形尺寸 3个 字段 变成一个组数
  58. const size = [values.size1, values.size2, values.size3];
  59. // 具体质量 + 单位
  60. let quality = [] as any;
  61. if (values.quality) quality = [values.quality, danweiValue];
  62. // 文件id
  63. const fileIds = [] as any;
  64. // 新的完整附件数据
  65. const newDataFile = [] as any;
  66. for (const k in results) {
  67. results[k].forEach((v: any) => {
  68. fileIds.push(v.id);
  69. newDataFile.push(v);
  70. });
  71. }
  72. // 年代
  73. const dictAge = values.dictAge.join("/");
  74. // 文物质地
  75. const dictTexture = values.dictTexture.join("/");
  76. const obj = {
  77. ...oldObj,
  78. id: id ? id : null,
  79. size: size.join(","),
  80. quality: quality.join(","),
  81. thumb: cover,
  82. dirCode: dirCode + "",
  83. fileIds: fileIds.join(","),
  84. registerId: dirCode,
  85. dictAge,
  86. dictTexture,
  87. };
  88. // -----------------藏品修改
  89. if (editId === "edit") {
  90. // 表单信息对比
  91. const oldData = oldDataRef.current.entity;
  92. // 有变化的数据---更新前
  93. const before = {} as any;
  94. // 有变化的数据---更新后
  95. const after = {} as any;
  96. for (const k in obj) {
  97. if (oldData[k] !== obj[k] && goodsChangeObj[k] && k !== "fileIds") {
  98. before[k] = oldData[k];
  99. after[k] = obj[k];
  100. } else if (k === "fileIds") {
  101. // 单独处理附件信息
  102. before["fileIds"] = oldDataRef.current.file
  103. .map((v: any) => v.id)
  104. .join(",");
  105. after["fileIds"] = newDataFile.map((v: any) => v.id).join(",");
  106. before["fileIdsName"] = oldDataRef.current.file
  107. .map((v: any) => v.name)
  108. .join(",");
  109. after["fileIdsName"] = newDataFile.map((v: any) => v.name).join(",");
  110. if (
  111. before["fileIds"] === after["fileIds"] ||
  112. before["fileIdsName"] === after["fileIdsName"]
  113. ) {
  114. delete before["fileIds"];
  115. delete after["fileIds"];
  116. delete before["fileIdsName"];
  117. delete after["fileIdsName"];
  118. }
  119. }
  120. }
  121. if (JSON.stringify(before) === "{}")
  122. return message.warning("没有改变藏品的信息!");
  123. const editData = {
  124. afterJson: after,
  125. beforeJson: before,
  126. goodsIds: Number(id),
  127. };
  128. const res: any = await editObj2GoodsAPI(editData);
  129. if (res.code === 0) {
  130. message.success("编辑成功!");
  131. // 通知父组件更新页面
  132. upInfoAPIFu();
  133. // 真正的删除 ----在藏品总账里面修改的时候不能删除
  134. // if (delFileList.current.length) {
  135. // await delInfileAPI(delFileList.current.join(","));
  136. // }
  137. // 关闭弹窗
  138. colsePage();
  139. }
  140. console.log("旧数据", before);
  141. console.log("新数据", after);
  142. } else {
  143. // ------------藏品新增和编辑
  144. await dispatch(goodsSonAddAPI(obj, id));
  145. // 真正的删除
  146. if (delFileList.current.length) {
  147. await delInfileAPI(delFileList.current.join(","));
  148. }
  149. // 关闭弹窗
  150. colsePage();
  151. }
  152. };
  153. // 选择商品信息还是附近(默认商品信息)
  154. const [titSelect, setTitSelect] = useState("tit1");
  155. // 从仓库中获取各下拉数据
  156. const options1 = useSelector(
  157. (state: RootState) => state.loginStore.selectAll["藏品编号名称"]
  158. );
  159. const options2 = useSelector(
  160. (state: RootState) => state.loginStore.selectAll["年代"]
  161. );
  162. const options3 = useSelector(
  163. (state: RootState) => state.loginStore.selectAll["质地"]
  164. );
  165. const options4 = useSelector(
  166. (state: RootState) => state.loginStore.selectAll["文物类别"]
  167. );
  168. const options5 = useSelector(
  169. (state: RootState) => state.loginStore.selectAll["文物级别"]
  170. );
  171. const options6 = useSelector(
  172. (state: RootState) => state.loginStore.selectAll["质量范围"]
  173. );
  174. const options7 = useSelector(
  175. (state: RootState) => state.loginStore.selectAll["完残程度"]
  176. );
  177. const options8 = useSelector(
  178. (state: RootState) => state.loginStore.selectAll["保存状态"]
  179. );
  180. const options9 = useSelector(
  181. (state: RootState) => state.loginStore.selectAll["入藏时间范围"]
  182. );
  183. // 单位选择
  184. const [danweiValue, setDanweiValue] = useState("kg");
  185. // 把旧的数据保存起来--用于藏品修改的对比
  186. const oldDataRef = useRef<any>({});
  187. // 设置表单初始数据(区分编辑和新增)
  188. const FormBoxRef = useRef<any>({});
  189. const getInfoInAPIFu = useCallback(
  190. async (id: number) => {
  191. const res = await getInfoInAPI(id);
  192. // 把旧的数据存起来
  193. oldDataRef.current = res.data;
  194. const data = res.data.entity;
  195. const size = data.size.split(",");
  196. const quality = data.quality ? data.quality.split(",") : ["", "kg"];
  197. const dictAge = data.dictAge.split(",");
  198. const dictTexture = data.dictTexture.split(",");
  199. FormBoxRef.current.setFieldsValue({
  200. ...data,
  201. size1: size[0],
  202. size2: size[1],
  203. size3: size[2],
  204. quality: quality[0],
  205. dictAge,
  206. dictTexture,
  207. });
  208. // 具体质量的单位
  209. setDanweiValue(quality[1]);
  210. // 藏品图片
  211. setCover(data.thumb);
  212. const fileData = {
  213. img: [],
  214. video: [],
  215. audio: [],
  216. model: [],
  217. doc: [],
  218. } as any;
  219. res.data.file.forEach((v: any) => {
  220. fileData[v.type].push(v);
  221. });
  222. // 修改附件仓库信息
  223. dispatch({ type: "login/setFileData", payload: fileData });
  224. },
  225. [dispatch]
  226. );
  227. // 进页面看看是编辑就 从仓库获取信息,新增就设置默认值
  228. useEffect(() => {
  229. if (id) {
  230. getInfoInAPIFu(id);
  231. } else {
  232. FormBoxRef.current.setFieldsValue({
  233. dictNum: options1[0].name ? options1[0].name : null,
  234. dictAge: ["地质年代", "显生宙", "新生代", "第四纪"],
  235. dictTexture: ["单一质地", "有机质", "竹"],
  236. dictGoodType: options4[0].name ? options4[0].name : null,
  237. dictLevel: options5[0].name ? options5[0].name : null,
  238. dictQualityScope: options6[0].name ? options6[0].name : null,
  239. complete: options7[0].name ? options7[0].name : null,
  240. dictCheckInScope: options9[0].name ? options9[0].name : null,
  241. });
  242. // 初始化附件仓库信息
  243. dispatch({
  244. type: "login/setFileData",
  245. payload: {
  246. img: [],
  247. video: [],
  248. audio: [],
  249. model: [],
  250. doc: [],
  251. },
  252. });
  253. }
  254. }, [
  255. dispatch,
  256. getInfoInAPIFu,
  257. id,
  258. options1,
  259. options4,
  260. options5,
  261. options6,
  262. options7,
  263. options9,
  264. ]);
  265. // -----------关于藏品附件的信息
  266. const [fileSelect, setFileSelect] = useState("img");
  267. const fileSelectChangeFu = (value: string) => {
  268. setFileSelect(value);
  269. };
  270. const results = useSelector((state: RootState) => state.loginStore.fileData);
  271. // 点击表格里面的删除
  272. const delOne = useCallback(
  273. (id: number) => {
  274. const data = {
  275. ...results,
  276. [fileSelect]: results[fileSelect].filter((v: any) => v.id !== id),
  277. };
  278. dispatch({ type: "login/setFileData", payload: data });
  279. // 把删除的id存起来
  280. delFileList.current.push(id);
  281. },
  282. [dispatch, fileSelect, results]
  283. );
  284. // 表格格式
  285. const columns = useMemo(() => {
  286. const tempArr = [
  287. {
  288. title: "附件名称",
  289. dataIndex: "name",
  290. },
  291. {
  292. title: "上传时间",
  293. dataIndex: "createTime",
  294. },
  295. {
  296. title: "操作",
  297. render: (item: any) => (
  298. <>
  299. <Button type="text" danger onClick={() => upFileFu(item.id)}>
  300. 重传
  301. </Button>
  302. <Popconfirm
  303. title="确定删除吗?"
  304. okText="确定"
  305. cancelText="取消"
  306. onConfirm={() => delOne(item.id)}
  307. >
  308. <Button type="text" danger>
  309. 删除
  310. </Button>
  311. </Popconfirm>
  312. </>
  313. ),
  314. },
  315. ];
  316. if (fileSelect === "img") {
  317. tempArr.unshift({
  318. title: "缩略图",
  319. render: (item: any) => (
  320. <div className="tableImg">
  321. <ImageLazy width={120} height={70} src={item.filePath} />
  322. </div>
  323. ),
  324. });
  325. }
  326. return tempArr;
  327. }, [delOne, fileSelect]);
  328. // 封面地址
  329. const [cover, setCover] = useState("");
  330. const fileSelectList = useMemo(() => {
  331. return [
  332. { id: 1, value: "img", label: "高清图片" },
  333. { id: 2, value: "video", label: "视频文件" },
  334. { id: 3, value: "audio", label: "音频文件" },
  335. { id: 4, value: "model", label: "三维模型" },
  336. { id: 5, value: "doc", label: "文档资料" },
  337. ];
  338. }, []);
  339. // 上传附件的进度条
  340. const UpAsyncLodingDom: any = document.querySelector("#UpAsyncLoding");
  341. const progressDom: any = document.querySelector("#progress");
  342. // 上传封面
  343. const myInput = useRef<HTMLInputElement>(null);
  344. const handeUpPhoto = async (e: React.ChangeEvent<HTMLInputElement>) => {
  345. if (e.target.files) {
  346. // 拿到files信息
  347. const filesInfo = e.target.files[0];
  348. // 校验格式
  349. const type = ["image/jpeg", "image/png"];
  350. if (!type.includes(filesInfo.type)) {
  351. e.target.value = "";
  352. return message.warning("只支持jpg、png格式!");
  353. }
  354. // 校验大小
  355. if (filesInfo.size > 10 * 1024 * 1024) {
  356. e.target.value = "";
  357. return message.warning("最大支持10M!");
  358. }
  359. // 创建FormData对象
  360. const fd = new FormData();
  361. // 把files添加进FormData对象(‘photo’为后端需要的字段)
  362. fd.append("type", "thumb");
  363. fd.append("dirCode", dirCode);
  364. fd.append("file", filesInfo);
  365. e.target.value = "";
  366. const res: any = await object1AddUpFileAPI(fd);
  367. if (res.code === 0) {
  368. message.success("上传成功!");
  369. setCover(res.data.filePath);
  370. }
  371. UpAsyncLodingDom.style.opacity = 0;
  372. progressDom.style.width = "0%";
  373. }
  374. };
  375. // 上传附件
  376. const myInput2 = useRef<HTMLInputElement>(null);
  377. const upFileFlagRef = useRef(false);
  378. const delFileList = useRef<any>([]);
  379. const upFileFu = (flag?: any) => {
  380. upFileFlagRef.current = flag ? flag : 0;
  381. myInput2.current?.click();
  382. };
  383. const handeUpPhoto2 = useCallback(
  384. async (e: React.ChangeEvent<HTMLInputElement>) => {
  385. if (e.target.files) {
  386. // 拿到files信息
  387. const filesInfo = e.target.files[0];
  388. let type = [] as string[];
  389. let tit = "";
  390. if (
  391. fileSelect === "img" ||
  392. fileSelect === "video" ||
  393. fileSelect === "audio"
  394. ) {
  395. if (fileSelect === "img") {
  396. type = ["image/jpeg", "image/png", "image/gif"];
  397. tit = "只支持jpg、png、gif格式!";
  398. } else if (fileSelect === "video") {
  399. type = ["video/mp4"];
  400. tit = "只支持mp4格式!";
  401. } else if (fileSelect === "audio") {
  402. type = ["audio/mpeg"];
  403. tit = "只支持mp3格式!";
  404. }
  405. // 校验格式
  406. if (!type.includes(filesInfo.type)) {
  407. e.target.value = "";
  408. return message.warning(tit);
  409. }
  410. }
  411. // 创建FormData对象
  412. const fd = new FormData();
  413. // 把files添加进FormData对象(‘photo’为后端需要的字段)
  414. fd.append("type", fileSelect);
  415. fd.append("dirCode", dirCode);
  416. fd.append("file", filesInfo);
  417. e.target.value = "";
  418. const res: any = await object1AddUpFileAPI(fd);
  419. if (res.code === 0) {
  420. message.success("上传成功!");
  421. if (upFileFlagRef.current) {
  422. // 重新上传
  423. const id = upFileFlagRef.current;
  424. const data = {
  425. ...results,
  426. [fileSelect]: results[fileSelect].map((v: any) => {
  427. if (id !== v.id) return v;
  428. else
  429. return {
  430. ...res.data,
  431. };
  432. }),
  433. };
  434. dispatch({ type: "login/setFileData", payload: data });
  435. // 把删除的id存起来
  436. delFileList.current.push(upFileFlagRef.current);
  437. } else {
  438. // 新上传
  439. const data = {
  440. ...results,
  441. [fileSelect]: [
  442. {
  443. ...res.data,
  444. },
  445. ...results[fileSelect],
  446. ],
  447. };
  448. dispatch({ type: "login/setFileData", payload: data });
  449. }
  450. }
  451. UpAsyncLodingDom.style.opacity = 0;
  452. progressDom.style.width = "0%";
  453. }
  454. },
  455. [
  456. UpAsyncLodingDom.style,
  457. dirCode,
  458. dispatch,
  459. fileSelect,
  460. progressDom.style,
  461. results,
  462. ]
  463. );
  464. return (
  465. <div className={styles.ObjectAdd}>
  466. <Modal
  467. wrapClassName="ObjectAdd"
  468. destroyOnClose
  469. open={true}
  470. title={id ? "编辑藏品" : "添加藏品"}
  471. footer={
  472. [] // 设置footer为空,去掉 取消 确定默认按钮
  473. }
  474. >
  475. {/* 商品信息和附件切换 */}
  476. <div className="ObjectAddTit">
  477. <div
  478. onClick={() => setTitSelect("tit1")}
  479. className={classNames(titSelect === "tit1" ? "active" : "")}
  480. >
  481. 藏品信息
  482. </div>
  483. <div
  484. onClick={() => setTitSelect("tit2")}
  485. className={classNames(
  486. "ObjectAddTitTow",
  487. titSelect === "tit2" ? "active" : ""
  488. )}
  489. >
  490. 附件
  491. </div>
  492. </div>
  493. <Form
  494. ref={FormBoxRef}
  495. name="basic"
  496. onFinish={onFinish}
  497. onFinishFailed={onFinishFailed}
  498. autoComplete="off"
  499. >
  500. {/* -----------------------表单信息 */}
  501. <div className="formBox" hidden={titSelect === "tit2"}>
  502. {/* 藏品名称----------原名 */}
  503. <div className="formRow">
  504. <Form.Item
  505. label="藏品名称"
  506. name="name"
  507. rules={[{ required: true, message: "不能为空!" }]}
  508. >
  509. <Input maxLength={50} showCount placeholder="请输入" />
  510. </Form.Item>
  511. <Form.Item label="原名" name="namePrimitive">
  512. <Input maxLength={50} showCount placeholder="请输入" />
  513. </Form.Item>
  514. </div>
  515. {/* 藏品编号名称----------藏品编号 */}
  516. <div className="formRow">
  517. <div className="bs">*</div>
  518. <Form.Item label="藏品编号名称" name="dictNum">
  519. <Select
  520. placeholder="请选择"
  521. options={options1.map((v: any) => ({
  522. label: v.name,
  523. value: v.name,
  524. }))}
  525. />
  526. </Form.Item>
  527. <Form.Item label="藏品编号" name="num">
  528. <Input maxLength={50} showCount placeholder="请输入" />
  529. </Form.Item>
  530. </div>
  531. {/* 年代----------文物质地 */}
  532. <div className="formRow">
  533. <div className="bs bs2">*</div>
  534. <div className="bs bs3">*</div>
  535. <Form.Item label="年代" name="dictAge">
  536. <Cascader
  537. allowClear={false}
  538. fieldNames={{
  539. label: "name",
  540. value: "name",
  541. children: "children",
  542. }}
  543. options={options2}
  544. placeholder="请选择"
  545. />
  546. </Form.Item>
  547. <Form.Item label="文物质地" name="dictTexture">
  548. <Cascader
  549. allowClear={false}
  550. fieldNames={{
  551. label: "name",
  552. value: "name",
  553. children: "children",
  554. }}
  555. options={options3}
  556. placeholder="请选择"
  557. />
  558. </Form.Item>
  559. </div>
  560. {/* 具体年代----------文物类别 */}
  561. <div className="formRow">
  562. <div className="bs bs3">*</div>
  563. <Form.Item label="具体年代" name="ageSpecific">
  564. <Input maxLength={50} showCount placeholder="请输入" />
  565. </Form.Item>
  566. <Form.Item label="文物类别" name="dictGoodType">
  567. <Select
  568. placeholder="请选择"
  569. options={options4.map((v: any) => ({
  570. label: v.name,
  571. value: v.name,
  572. }))}
  573. />
  574. </Form.Item>
  575. </div>
  576. {/* 实际数量----------文物级别 */}
  577. <div className="formRow">
  578. <div className="bs bs3">*</div>
  579. <Form.Item
  580. rules={[{ required: true, message: "不能为空!" }]}
  581. label="实际数量"
  582. name="pcs"
  583. >
  584. <InputNumber min={1} maxLength={8} placeholder="请输入数字" />
  585. </Form.Item>
  586. <Form.Item label="文物级别" name="dictLevel">
  587. <Select
  588. placeholder="请选择"
  589. options={options5.map((v: any) => ({
  590. label: v.name,
  591. value: v.name,
  592. }))}
  593. />
  594. </Form.Item>
  595. </div>
  596. {/* 外形尺寸----------通长,宽,高 */}
  597. <div className="formRow formRowThree">
  598. <Form.Item
  599. rules={[{ required: true, message: "不能为空!" }]}
  600. label="外形尺寸"
  601. name="size1"
  602. >
  603. <InputNumber
  604. min={1}
  605. maxLength={8}
  606. placeholder="通长"
  607. addonAfter="cm"
  608. />
  609. </Form.Item>
  610. <Form.Item
  611. rules={[{ required: true, message: "不能为空!" }]}
  612. label=""
  613. name="size2"
  614. >
  615. <InputNumber
  616. min={1}
  617. maxLength={8}
  618. placeholder="通宽"
  619. addonAfter="cm"
  620. />
  621. </Form.Item>
  622. <Form.Item
  623. className="formRowThreeRow"
  624. rules={[{ required: true, message: "不能为空!" }]}
  625. label=""
  626. name="size3"
  627. >
  628. <InputNumber
  629. min={1}
  630. maxLength={8}
  631. placeholder="通高"
  632. addonAfter="cm"
  633. />
  634. </Form.Item>
  635. </div>
  636. {/* 具体尺寸*/}
  637. <div className="formRow formRowFull">
  638. <Form.Item
  639. label="具体尺寸"
  640. name="sizeSpecific"
  641. rules={[{ required: true, message: "不能为空!" }]}
  642. >
  643. <Input maxLength={50} showCount placeholder="请输入" />
  644. </Form.Item>
  645. </div>
  646. {/* 质量范围----------具体质量 */}
  647. <div className="formRow">
  648. <div className="bs bs4">*</div>
  649. <Form.Item label="质量范围" name="dictQualityScope">
  650. <Select
  651. placeholder="请选择"
  652. options={options6.map((v: any) => ({
  653. label: v.name,
  654. value: v.name,
  655. }))}
  656. />
  657. </Form.Item>
  658. <Form.Item
  659. className="formRowSelec"
  660. label="具体质量"
  661. name="quality"
  662. >
  663. <InputNumber
  664. min={1}
  665. maxLength={8}
  666. placeholder="请输入数字"
  667. addonAfter={
  668. <Select
  669. value={danweiValue}
  670. onChange={(val) => setDanweiValue(val)}
  671. >
  672. <Option value="kg">kg</Option>
  673. <Option value="g">g</Option>
  674. </Select>
  675. }
  676. />
  677. {/* <div className="formRowSelecSon">
  678. </div> */}
  679. </Form.Item>
  680. </div>
  681. {/* 完残程度----------保存状态 */}
  682. <div className="formRow">
  683. <div className="bs bs4">*</div>
  684. <Form.Item label="完残程度" name="complete">
  685. <Select
  686. placeholder="请选择"
  687. options={options7.map((v: any) => ({
  688. label: v.name,
  689. value: v.name,
  690. }))}
  691. />
  692. </Form.Item>
  693. <Form.Item label="保存状态" name="repair">
  694. <Select
  695. placeholder="请选择"
  696. options={options8.map((v: any) => ({
  697. label: v.name,
  698. value: v.name,
  699. }))}
  700. />
  701. </Form.Item>
  702. </div>
  703. {/* 入藏时间范围----------入藏年度 */}
  704. <div className="formRow">
  705. <div className="bs">*</div>
  706. <Form.Item label="入藏时间范围" name="dictCheckInScope">
  707. <Select
  708. placeholder="请选择"
  709. options={options9.map((v: any) => ({
  710. label: v.name,
  711. value: v.name,
  712. }))}
  713. />
  714. </Form.Item>
  715. <Form.Item label="入藏年度" name="checkInYear">
  716. <InputNumber
  717. min={1000}
  718. maxLength={4}
  719. placeholder="请输入数字"
  720. />
  721. </Form.Item>
  722. </div>
  723. {/* 著者----------版本 */}
  724. <div className="formRow">
  725. <Form.Item label="著者" name="author">
  726. <Input maxLength={50} showCount placeholder="请输入" />
  727. </Form.Item>
  728. <Form.Item label="版本" name="vision">
  729. <Input maxLength={50} showCount placeholder="请输入" />
  730. </Form.Item>
  731. </div>
  732. {/* 存卷*/}
  733. <div className="formRow formRowFull">
  734. <Form.Item label="存卷" name="onFile">
  735. <Input maxLength={50} showCount placeholder="请输入" />
  736. </Form.Item>
  737. </div>
  738. {/* 来源说明*/}
  739. <div className="formRow formRowFull">
  740. <Form.Item label="来源说明" name="description">
  741. <TextArea
  742. rows={3}
  743. placeholder="请输入"
  744. showCount
  745. maxLength={255}
  746. />
  747. </Form.Item>
  748. </div>
  749. </div>
  750. {/* -----------------------附件信息 */}
  751. <div hidden={titSelect === "tit1"}>
  752. <div className="fileBox">
  753. {/* 封面上传 */}
  754. <div className="fileBoxRow">
  755. <div className="fileBoxRow_tit">藏品图片:</div>
  756. <div className="fileBoxRow_r">
  757. <div
  758. hidden={cover !== ""}
  759. className="fileBoxRow_up"
  760. onClick={() => myInput.current?.click()}
  761. >
  762. <PlusOutlined />
  763. <input
  764. type="file"
  765. accept=".png,.jpg"
  766. ref={myInput}
  767. onChange={(e) => handeUpPhoto(e)}
  768. />
  769. </div>
  770. <div className="fileBoxRow_r_img" hidden={cover === ""}>
  771. <ImageLazy width={120} height={120} src={cover} />
  772. <Popconfirm
  773. title="确定删除吗?"
  774. okText="确定"
  775. cancelText="取消"
  776. onConfirm={() => setCover("")}
  777. >
  778. <div className="clearCover">
  779. <CloseCircleOutlined />
  780. </div>
  781. </Popconfirm>
  782. </div>
  783. <div className="fileBoxRow_r_tit">
  784. 支持上传jpg,png格式,大小&lt;10M
  785. </div>
  786. </div>
  787. </div>
  788. {/* 附件上传 */}
  789. <div className="fileBoxRow">
  790. <div className="fileBoxRow_tit fileBoxRow_tit2">上传附件:</div>
  791. <div className="fileBoxRow_r">
  792. <input
  793. type="file"
  794. ref={myInput2}
  795. onChange={(e) => handeUpPhoto2(e)}
  796. />
  797. <Select
  798. style={{ width: 150 }}
  799. value={fileSelect}
  800. onChange={fileSelectChangeFu}
  801. options={fileSelectList}
  802. />
  803. &emsp;
  804. <Button onClick={() => upFileFu()}>上传附件</Button>
  805. </div>
  806. &emsp;
  807. <div className="fileBoxRowUpTit">
  808. {fileSelect === "img" ? (
  809. <>支持上传jpg,png,gif格式</>
  810. ) : fileSelect === "video" ? (
  811. <>支持上传mp4格式</>
  812. ) : fileSelect === "audio" ? (
  813. <>支持上传mp3格式</>
  814. ) : (
  815. ""
  816. )}
  817. </div>
  818. </div>
  819. {/* 表格主体 */}
  820. <div className="addTableBox_table">
  821. <Table
  822. size="small"
  823. scroll={{ y: 300 }}
  824. dataSource={results[fileSelect]}
  825. columns={columns}
  826. rowKey="id"
  827. pagination={false}
  828. />
  829. </div>
  830. </div>
  831. </div>
  832. <br />
  833. <Form.Item wrapperCol={{ offset: 20 }}>
  834. <Button onClick={colsePage}>取消</Button>
  835. &emsp;
  836. <Button type="primary" htmlType="submit">
  837. 确定
  838. </Button>
  839. </Form.Item>
  840. </Form>
  841. </Modal>
  842. </div>
  843. );
  844. }
  845. const MemoObjectAdd = React.memo(ObjectAdd);
  846. export default MemoObjectAdd;