|
|
@@ -7,30 +7,27 @@ import React, {
|
|
|
} from "react";
|
|
|
import styles from "./index.module.scss";
|
|
|
import TextArea from "antd/es/input/TextArea";
|
|
|
-import { Button, Popconfirm, Table } from "antd";
|
|
|
-import {
|
|
|
- A2addInfoType,
|
|
|
- A2inTableType,
|
|
|
- statusTxtObj,
|
|
|
- storageStatusTxtObj,
|
|
|
-} from "../data";
|
|
|
+import { Button, Popconfirm } from "antd";
|
|
|
+import { A2addInfoType } from "../data";
|
|
|
import A2AddModal from "./A2AddModal";
|
|
|
import { MessageFu } from "@/utils/message";
|
|
|
-import ImageLazy from "@/components/ImageLazy";
|
|
|
import {
|
|
|
A2_APIaddWai,
|
|
|
A2_APIgetInfoWai,
|
|
|
A2_APIinDels,
|
|
|
} from "@/store/action/A2Goods";
|
|
|
import history from "@/utils/history";
|
|
|
+import { A2tableType } from "@/types";
|
|
|
+import ZlistTable from "@/components/ZlistTable";
|
|
|
|
|
|
type Props = {
|
|
|
closeFu: () => void;
|
|
|
upInfoFu: () => void;
|
|
|
outInfo: A2addInfoType;
|
|
|
+ type: "DJ" | "ZX";
|
|
|
};
|
|
|
|
|
|
-function A2Register({ closeFu, outInfo, upInfoFu }: Props) {
|
|
|
+function A2Register({ closeFu, outInfo, upInfoFu, type }: Props) {
|
|
|
// 记录删除了的所有id集合
|
|
|
const delIdArr = useRef<number[]>([]);
|
|
|
|
|
|
@@ -52,7 +49,7 @@ function A2Register({ closeFu, outInfo, upInfoFu }: Props) {
|
|
|
}, [getInfoFu, outInfo.id, outInfo.txt]);
|
|
|
|
|
|
// 表格信息
|
|
|
- const [tableList, setTableList] = useState<A2inTableType[]>([]);
|
|
|
+ const [tableList, setTableList] = useState<A2tableType[]>([]);
|
|
|
|
|
|
// 申请说明字段
|
|
|
const [topValue, setTopValue] = useState("");
|
|
|
@@ -87,68 +84,37 @@ function A2Register({ closeFu, outInfo, upInfoFu }: Props) {
|
|
|
[closeFu, outInfo.id, outInfo.txt, tableList, topValue, upInfoFu]
|
|
|
);
|
|
|
|
|
|
- const columns = useMemo(() => {
|
|
|
- return [
|
|
|
- {
|
|
|
- title: "缩略图",
|
|
|
- render: (item: A2inTableType) => (
|
|
|
- <div className="tableImgAuto">
|
|
|
- <ImageLazy width={60} height={60} src={item.thumb} />
|
|
|
- </div>
|
|
|
- ),
|
|
|
- },
|
|
|
- {
|
|
|
- title: "编号",
|
|
|
- dataIndex: "num",
|
|
|
- },
|
|
|
- {
|
|
|
- title: "名称",
|
|
|
- dataIndex: "name",
|
|
|
- },
|
|
|
- {
|
|
|
- title: "级别",
|
|
|
- dataIndex: "dictLevel",
|
|
|
- },
|
|
|
- {
|
|
|
- title: "藏品状态",
|
|
|
- render: (item: A2inTableType) =>
|
|
|
- Reflect.get(statusTxtObj, item.status) || "-",
|
|
|
- },
|
|
|
- {
|
|
|
- title: "库存状态",
|
|
|
- render: (item: A2inTableType) =>
|
|
|
- Reflect.get(storageStatusTxtObj, item.storageStatus) || "-",
|
|
|
- },
|
|
|
- {
|
|
|
- title: "操作",
|
|
|
- render: (item: A2inTableType) => (
|
|
|
- <>
|
|
|
- <Button
|
|
|
- size="small"
|
|
|
- type="text"
|
|
|
- onClick={() => setAddInfo({ id: item.id, txt: "编辑" })}
|
|
|
- >
|
|
|
- 编辑
|
|
|
+ // 表格的操作模块的列
|
|
|
+ const listTableBtn = useMemo(() => {
|
|
|
+ return {
|
|
|
+ title: "操作",
|
|
|
+ render: (item: A2tableType) => (
|
|
|
+ <>
|
|
|
+ <Button
|
|
|
+ size="small"
|
|
|
+ type="text"
|
|
|
+ onClick={() => setAddInfo({ id: item.id, txt: "编辑" })}
|
|
|
+ >
|
|
|
+ 编辑
|
|
|
+ </Button>
|
|
|
+ <Popconfirm
|
|
|
+ title="删除后无法恢复,是否删除?"
|
|
|
+ okText="删除"
|
|
|
+ cancelText="取消"
|
|
|
+ onConfirm={() => {
|
|
|
+ delIdArr.current.push(item.id);
|
|
|
+ setTableList(tableList.filter((v) => v.id !== item.id));
|
|
|
+ MessageFu.success("删除成功!");
|
|
|
+ }}
|
|
|
+ okButtonProps={{ loading: false }}
|
|
|
+ >
|
|
|
+ <Button size="small" type="text" danger>
|
|
|
+ 删除
|
|
|
</Button>
|
|
|
- <Popconfirm
|
|
|
- title="删除后无法恢复,是否删除?"
|
|
|
- okText="删除"
|
|
|
- cancelText="取消"
|
|
|
- onConfirm={() => {
|
|
|
- delIdArr.current.push(item.id);
|
|
|
- setTableList(tableList.filter((v) => v.id !== item.id));
|
|
|
- MessageFu.success("删除成功!");
|
|
|
- }}
|
|
|
- okButtonProps={{ loading: false }}
|
|
|
- >
|
|
|
- <Button size="small" type="text" danger>
|
|
|
- 删除
|
|
|
- </Button>
|
|
|
- </Popconfirm>
|
|
|
- </>
|
|
|
- ),
|
|
|
- },
|
|
|
- ];
|
|
|
+ </Popconfirm>
|
|
|
+ </>
|
|
|
+ ),
|
|
|
+ };
|
|
|
}, [tableList]);
|
|
|
|
|
|
// 新增和编辑
|
|
|
@@ -156,7 +122,7 @@ function A2Register({ closeFu, outInfo, upInfoFu }: Props) {
|
|
|
|
|
|
// 从里面的弹窗 新增 / 编辑完工
|
|
|
const addOrEditSuccFu = useCallback(
|
|
|
- (item: A2inTableType, flag: "新增" | "编辑") => {
|
|
|
+ (item: A2tableType, flag: "新增" | "编辑") => {
|
|
|
if (flag === "新增") setTableList([...tableList, item]);
|
|
|
else {
|
|
|
setTableList(tableList.map((v) => (v.id === item.id ? item : v)));
|
|
|
@@ -168,7 +134,14 @@ function A2Register({ closeFu, outInfo, upInfoFu }: Props) {
|
|
|
return (
|
|
|
<div className={styles.A2Register}>
|
|
|
<div className="A2Rtop">
|
|
|
- <div className="A2RTitle">登记申请</div>
|
|
|
+ {type === "ZX" ? (
|
|
|
+ <div className="A2RtopTit">
|
|
|
+ 注:注销后,将无法在清单中查询到此藏品;请谨慎操作
|
|
|
+ </div>
|
|
|
+ ) : null}
|
|
|
+ <div className="A2RTitle">
|
|
|
+ {type === "DJ" ? "登记申请" : "注销申请"}
|
|
|
+ </div>
|
|
|
<div className="A2Rtop1">申请说明:</div>
|
|
|
<div className="A2Rtop2">
|
|
|
<TextArea
|
|
|
@@ -191,14 +164,7 @@ function A2Register({ closeFu, outInfo, upInfoFu }: Props) {
|
|
|
</Button>
|
|
|
</div>
|
|
|
<div className="A2Rtable2">
|
|
|
- <Table
|
|
|
- size="small"
|
|
|
- scroll={{ y: 482 }}
|
|
|
- dataSource={tableList}
|
|
|
- columns={columns}
|
|
|
- rowKey="id"
|
|
|
- pagination={false}
|
|
|
- />
|
|
|
+ <ZlistTable list={tableList} btnDom={listTableBtn} y={478} />
|
|
|
</div>
|
|
|
<div className="A2Rtable3">
|
|
|
<Button
|
|
|
@@ -225,13 +191,18 @@ function A2Register({ closeFu, outInfo, upInfoFu }: Props) {
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- {/* 点击新增和编辑出来的弹窗 */}
|
|
|
+ {/* 点击新增和编辑出来的弹窗 --- 登记申请*/}
|
|
|
{addInfo.id ? (
|
|
|
- <A2AddModal
|
|
|
- addInfo={addInfo}
|
|
|
- closeFu={() => setAddInfo({ id: 0, txt: "" })}
|
|
|
- upTableFu={(item, flag) => addOrEditSuccFu(item, flag)}
|
|
|
- />
|
|
|
+ <>
|
|
|
+ {type === "DJ" ? (
|
|
|
+ <A2AddModal
|
|
|
+ addInfo={addInfo}
|
|
|
+ closeFu={() => setAddInfo({ id: 0, txt: "" })}
|
|
|
+ upTableFu={(item, flag) => addOrEditSuccFu(item, flag)}
|
|
|
+ />
|
|
|
+ ) : null}
|
|
|
+ {/* 待完善 ZX 新增 和 编辑 的页面*/}
|
|
|
+ </>
|
|
|
) : null}
|
|
|
</div>
|
|
|
);
|