|
@@ -17,20 +17,35 @@ import {
|
|
|
import A2AddModal from "./A2AddModal";
|
|
import A2AddModal from "./A2AddModal";
|
|
|
import { MessageFu } from "@/utils/message";
|
|
import { MessageFu } from "@/utils/message";
|
|
|
import ImageLazy from "@/components/ImageLazy";
|
|
import ImageLazy from "@/components/ImageLazy";
|
|
|
-import { A2_APIaddWai, A2_APIinDels } from "@/store/action/A2Goods";
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ A2_APIaddWai,
|
|
|
|
|
+ A2_APIgetInfoWai,
|
|
|
|
|
+ A2_APIinDels,
|
|
|
|
|
+} from "@/store/action/A2Goods";
|
|
|
import history from "@/utils/history";
|
|
import history from "@/utils/history";
|
|
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
|
closeFu: () => void;
|
|
closeFu: () => void;
|
|
|
|
|
+ upInfoFu: () => void;
|
|
|
outInfo: A2addInfoType;
|
|
outInfo: A2addInfoType;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-function A2Register({ closeFu, outInfo }: Props) {
|
|
|
|
|
|
|
+function A2Register({ closeFu, outInfo, upInfoFu }: Props) {
|
|
|
// 记录删除了的所有id集合
|
|
// 记录删除了的所有id集合
|
|
|
const delIdArr = useRef<number[]>([]);
|
|
const delIdArr = useRef<number[]>([]);
|
|
|
|
|
|
|
|
|
|
+ // 当前审批的状态
|
|
|
|
|
+ const statusRef = useRef(0);
|
|
|
|
|
+
|
|
|
// 获取详情
|
|
// 获取详情
|
|
|
- const getInfoFu = useCallback((id: number) => {}, []);
|
|
|
|
|
|
|
+ const getInfoFu = useCallback(async (id: number) => {
|
|
|
|
|
+ const res = await A2_APIgetInfoWai(id);
|
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
|
+ setTopValue(res.data.entity.description);
|
|
|
|
|
+ statusRef.current = res.data.entity.status;
|
|
|
|
|
+ setTableList(res.data.child);
|
|
|
|
|
+ }
|
|
|
|
|
+ }, []);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (outInfo.txt !== "新增") getInfoFu(outInfo.id);
|
|
if (outInfo.txt !== "新增") getInfoFu(outInfo.id);
|
|
@@ -46,7 +61,8 @@ function A2Register({ closeFu, outInfo }: Props) {
|
|
|
const btnOkFu = useCallback(
|
|
const btnOkFu = useCallback(
|
|
|
async (status: 0 | 1) => {
|
|
async (status: 0 | 1) => {
|
|
|
const obj = {
|
|
const obj = {
|
|
|
- id: outInfo.txt === "新增" ? null : outInfo.id,
|
|
|
|
|
|
|
+ id:
|
|
|
|
|
+ outInfo.txt === "新增" || statusRef.current === 2 ? null : outInfo.id,
|
|
|
description: topValue,
|
|
description: topValue,
|
|
|
goodsIds: tableList.map((v) => v.id).join(","),
|
|
goodsIds: tableList.map((v) => v.id).join(","),
|
|
|
status,
|
|
status,
|
|
@@ -56,16 +72,19 @@ function A2Register({ closeFu, outInfo }: Props) {
|
|
|
const res1 = await A2_APIaddWai(obj);
|
|
const res1 = await A2_APIaddWai(obj);
|
|
|
|
|
|
|
|
// 删除id集合
|
|
// 删除id集合
|
|
|
- if(delIdArr.current.length>0){
|
|
|
|
|
- await A2_APIinDels(delIdArr.current.join(","));
|
|
|
|
|
|
|
+ if (delIdArr.current.length > 0) {
|
|
|
|
|
+ await A2_APIinDels(delIdArr.current.join(","));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (res1.code === 0) {
|
|
if (res1.code === 0) {
|
|
|
MessageFu.success(`${outInfo.txt}成功!`);
|
|
MessageFu.success(`${outInfo.txt}成功!`);
|
|
|
- history.push("/submit");
|
|
|
|
|
|
|
+ if (window.location.hash.includes("/submit")) {
|
|
|
|
|
+ upInfoFu();
|
|
|
|
|
+ closeFu();
|
|
|
|
|
+ } else history.push("/submit");
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- [outInfo.id, outInfo.txt, tableList, topValue]
|
|
|
|
|
|
|
+ [closeFu, outInfo.id, outInfo.txt, tableList, topValue, upInfoFu]
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
const columns = useMemo(() => {
|
|
const columns = useMemo(() => {
|
|
@@ -104,7 +123,11 @@ function A2Register({ closeFu, outInfo }: Props) {
|
|
|
title: "备注",
|
|
title: "备注",
|
|
|
render: (item: A2inTableType) => (
|
|
render: (item: A2inTableType) => (
|
|
|
<>
|
|
<>
|
|
|
- <Button size="small" type="text">
|
|
|
|
|
|
|
+ <Button
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ onClick={() => setAddInfo({ id: item.id, txt: "编辑" })}
|
|
|
|
|
+ >
|
|
|
编辑
|
|
编辑
|
|
|
</Button>
|
|
</Button>
|
|
|
<Popconfirm
|
|
<Popconfirm
|
|
@@ -131,9 +154,21 @@ function A2Register({ closeFu, outInfo }: Props) {
|
|
|
// 新增和编辑
|
|
// 新增和编辑
|
|
|
const [addInfo, setAddInfo] = useState<A2addInfoType>({ id: 0, txt: "" });
|
|
const [addInfo, setAddInfo] = useState<A2addInfoType>({ id: 0, txt: "" });
|
|
|
|
|
|
|
|
|
|
+ // 从里面的弹窗 新增 / 编辑完工
|
|
|
|
|
+ const addOrEditSuccFu = useCallback(
|
|
|
|
|
+ (item: A2inTableType, flag: "新增" | "编辑") => {
|
|
|
|
|
+ if (flag === "新增") setTableList([...tableList, item]);
|
|
|
|
|
+ else {
|
|
|
|
|
+ setTableList(tableList.map((v) => (v.id === item.id ? item : v)));
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ [tableList]
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<div className={styles.A2Register}>
|
|
<div className={styles.A2Register}>
|
|
|
<div className="A2Rtop">
|
|
<div className="A2Rtop">
|
|
|
|
|
+ <div className="A2RTitle">登记申请</div>
|
|
|
<div className="A2Rtop1">申请说明:</div>
|
|
<div className="A2Rtop1">申请说明:</div>
|
|
|
<div className="A2Rtop2">
|
|
<div className="A2Rtop2">
|
|
|
<TextArea
|
|
<TextArea
|
|
@@ -166,11 +201,18 @@ function A2Register({ closeFu, outInfo }: Props) {
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
<div className="A2Rtable3">
|
|
<div className="A2Rtable3">
|
|
|
- <Button type="primary" onClick={() => btnOkFu(1)}>
|
|
|
|
|
|
|
+ <Button
|
|
|
|
|
+ disabled={!tableList.length}
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ onClick={() => btnOkFu(1)}
|
|
|
|
|
+ >
|
|
|
提交
|
|
提交
|
|
|
</Button>
|
|
</Button>
|
|
|
 
|
|
 
|
|
|
- <Button onClick={() => btnOkFu(0)}>存草稿</Button> 
|
|
|
|
|
|
|
+ <Button disabled={!tableList.length} onClick={() => btnOkFu(0)}>
|
|
|
|
|
+ 存草稿
|
|
|
|
|
+ </Button>
|
|
|
|
|
+  
|
|
|
<Popconfirm
|
|
<Popconfirm
|
|
|
title="放弃编辑后,信息将不会保存!"
|
|
title="放弃编辑后,信息将不会保存!"
|
|
|
okText="放弃"
|
|
okText="放弃"
|
|
@@ -188,7 +230,7 @@ function A2Register({ closeFu, outInfo }: Props) {
|
|
|
<A2AddModal
|
|
<A2AddModal
|
|
|
addInfo={addInfo}
|
|
addInfo={addInfo}
|
|
|
closeFu={() => setAddInfo({ id: 0, txt: "" })}
|
|
closeFu={() => setAddInfo({ id: 0, txt: "" })}
|
|
|
- upTableFu={(item) => setTableList([...tableList, item])}
|
|
|
|
|
|
|
+ upTableFu={(item, flag) => addOrEditSuccFu(item, flag)}
|
|
|
/>
|
|
/>
|
|
|
) : null}
|
|
) : null}
|
|
|
</div>
|
|
</div>
|