|
|
@@ -1,8 +1,14 @@
|
|
|
-import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
|
+import React, {
|
|
|
+ useCallback,
|
|
|
+ useEffect,
|
|
|
+ useMemo,
|
|
|
+ useRef,
|
|
|
+ useState,
|
|
|
+} from "react";
|
|
|
import styles from "./index.module.scss";
|
|
|
import { B1tableType } from "@/types";
|
|
|
import { B1StatusObj, B1TieleObj, antdTagColorFObj } from "../data";
|
|
|
-import { Button, Popconfirm, Table, Tag } from "antd";
|
|
|
+import { Button, Popconfirm, Radio, Table, Tag } from "antd";
|
|
|
import {
|
|
|
A2addInfoType,
|
|
|
A2inTableType,
|
|
|
@@ -10,11 +16,15 @@ import {
|
|
|
storageStatusTxtObj,
|
|
|
} from "@/pages/A2Goods/data";
|
|
|
import ImageLazy from "@/components/ImageLazy";
|
|
|
-import { A2_APIgetInfo } from "@/store/action/B1Submit";
|
|
|
+import { A2_APIdelOrder, A2_APIgetInfo } from "@/store/action/B1Submit";
|
|
|
import B1Look from "../B1Look";
|
|
|
import A2Register from "@/pages/A2Goods/A2Register";
|
|
|
import { A2_APIaudit } from "@/store/action/A2Goods";
|
|
|
import { MessageFu } from "@/utils/message";
|
|
|
+import TextArea from "antd/es/input/TextArea";
|
|
|
+import { B1EditKeyObj, B1EditTable } from "./data";
|
|
|
+import classNames from "classnames";
|
|
|
+import A2AddModal from "@/pages/A2Goods/A2Register/A2AddModal";
|
|
|
|
|
|
type Props = {
|
|
|
closeFu: () => void;
|
|
|
@@ -26,11 +36,66 @@ type Props = {
|
|
|
function B1Info({ closeFu, lookId, pageKey, upTableFu }: Props) {
|
|
|
const [info, setInfo] = useState({} as B1tableType);
|
|
|
|
|
|
+ // 藏品编辑的id存储
|
|
|
+ const oldToNewId = useRef(0);
|
|
|
+
|
|
|
const getInfoFu = useCallback(
|
|
|
async (id: number, flag?: boolean) => {
|
|
|
const res = await A2_APIgetInfo(id);
|
|
|
if (res.code === 0) {
|
|
|
- setTableList(res.data.child);
|
|
|
+ if (res.data.entity.type === "BJ") {
|
|
|
+ // 藏品编辑的信息,特殊处理
|
|
|
+ let oldTxt = "{}";
|
|
|
+ let newTxt = "{}";
|
|
|
+ if (res.data.edit) {
|
|
|
+ if (res.data.edit.beforeGoods) oldTxt = res.data.edit.beforeGoods;
|
|
|
+ if (res.data.edit.afterGoods) newTxt = res.data.edit.afterGoods;
|
|
|
+ }
|
|
|
+
|
|
|
+ const oldObj = JSON.parse(oldTxt);
|
|
|
+ const newObj = JSON.parse(newTxt);
|
|
|
+
|
|
|
+ // 把 这个 单个藏品的id 存起来 用于 审批失败的 编辑按钮
|
|
|
+ oldToNewId.current = oldObj.id;
|
|
|
+
|
|
|
+ const tempArr = [] as B1EditTable[];
|
|
|
+
|
|
|
+ for (const k in newObj) {
|
|
|
+ if (k !== "id") {
|
|
|
+ const txt = Reflect.get(B1EditKeyObj, k);
|
|
|
+ let oldValue = Reflect.get(oldObj, k);
|
|
|
+ let newValue = Reflect.get(newObj, k);
|
|
|
+
|
|
|
+ if (k === "size") {
|
|
|
+ // 尺寸信息的处理
|
|
|
+ const arr1 = oldValue
|
|
|
+ .split(",")
|
|
|
+ .map((v: string) => v.replace(" ", ""));
|
|
|
+ oldValue = `长:${arr1[0] || "-"} 宽:${arr1[1] || "-"} 高:${
|
|
|
+ arr1[2] || "-"
|
|
|
+ } `;
|
|
|
+ const arr2 = newValue
|
|
|
+ .split(",")
|
|
|
+ .map((v: string) => v.replace(" ", ""));
|
|
|
+ newValue = `长:${arr2[0] || "-"} 宽:${arr2[1] || "-"} 高:${
|
|
|
+ arr2[2] || "-"
|
|
|
+ } `;
|
|
|
+ }
|
|
|
+
|
|
|
+ tempArr.push({
|
|
|
+ id: newObj.id + txt,
|
|
|
+ txt,
|
|
|
+ oldValue: oldValue || "(空)",
|
|
|
+ newValue: newValue || "(空)",
|
|
|
+ type: txt === "封面图" ? "img" : "",
|
|
|
+ } as B1EditTable);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setTableListByEdit(tempArr);
|
|
|
+ } else {
|
|
|
+ // 除了藏品编辑之外的表格数据
|
|
|
+ setTableList(res.data.child);
|
|
|
+ }
|
|
|
setInfo(res.data.entity);
|
|
|
// 通知 列表 页面 更新
|
|
|
if (flag) upTableFu();
|
|
|
@@ -46,31 +111,44 @@ function B1Info({ closeFu, lookId, pageKey, upTableFu }: Props) {
|
|
|
// 点击编辑
|
|
|
const [outInfo, setOutInfo] = useState<A2addInfoType>({ id: 0, txt: "" });
|
|
|
const editFu = useCallback(() => {
|
|
|
- setOutInfo({ id: info.id, txt: "编辑" });
|
|
|
- }, [info.id]);
|
|
|
-
|
|
|
- // 点击删除
|
|
|
- const delFu = useCallback(() => {}, []);
|
|
|
-
|
|
|
- // 点击撤回
|
|
|
- const annulFu = useCallback(async () => {
|
|
|
- const res = await A2_APIaudit({
|
|
|
- auditDesc: info.auditDesc,
|
|
|
- id: info.id,
|
|
|
- status: 0,
|
|
|
+ setOutInfo({
|
|
|
+ id: info.type === "BJ" ? oldToNewId.current : info.id,
|
|
|
+ txt: "编辑",
|
|
|
});
|
|
|
+ }, [info.id, info.type]);
|
|
|
|
|
|
+ // 点击删除
|
|
|
+ const delFu = useCallback(async () => {
|
|
|
+ const res = await A2_APIdelOrder(lookId);
|
|
|
if (res.code === 0) {
|
|
|
- MessageFu.success("操作成功!");
|
|
|
+ MessageFu.success("删除成功!");
|
|
|
upTableFu();
|
|
|
closeFu();
|
|
|
}
|
|
|
- }, [closeFu, info.auditDesc, info.id, upTableFu]);
|
|
|
+ }, [closeFu, lookId, upTableFu]);
|
|
|
+
|
|
|
+ // 点击撤回(我审核的:审批)
|
|
|
+ const annulFu = useCallback(
|
|
|
+ async (status: number, auditDesc: string) => {
|
|
|
+ const res = await A2_APIaudit({
|
|
|
+ auditDesc,
|
|
|
+ id: info.id,
|
|
|
+ status,
|
|
|
+ });
|
|
|
+
|
|
|
+ if (res.code === 0) {
|
|
|
+ MessageFu.success("操作成功!");
|
|
|
+ upTableFu();
|
|
|
+ closeFu();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ [closeFu, info.id, upTableFu]
|
|
|
+ );
|
|
|
|
|
|
// 表格里面的查看信息
|
|
|
const [goodsId, setGoodsId] = useState(0);
|
|
|
|
|
|
- // 能够出现的 按钮
|
|
|
+ // 能够出现的 按钮(我提交的)
|
|
|
const btnArr = useMemo(() => {
|
|
|
const btn1 = (
|
|
|
<Button type="primary" onClick={editFu}>
|
|
|
@@ -87,7 +165,9 @@ function B1Info({ closeFu, lookId, pageKey, upTableFu }: Props) {
|
|
|
<Button danger>删除</Button>
|
|
|
</Popconfirm>
|
|
|
);
|
|
|
- const btn3 = <Button onClick={annulFu}>撤回</Button>;
|
|
|
+ const btn3 = (
|
|
|
+ <Button onClick={() => annulFu(0, info.auditDesc)}>撤回</Button>
|
|
|
+ );
|
|
|
|
|
|
let res: React.ReactNode = "";
|
|
|
|
|
|
@@ -98,7 +178,7 @@ function B1Info({ closeFu, lookId, pageKey, upTableFu }: Props) {
|
|
|
{btn2}
|
|
|
</>
|
|
|
))
|
|
|
- ) : info.status === 1 ? (
|
|
|
+ ) : info.status === 1 && info.type !== "BJ" ? (
|
|
|
(res = btn3)
|
|
|
) : info.status === 2 ? (
|
|
|
(res = btn1)
|
|
|
@@ -106,59 +186,97 @@ function B1Info({ closeFu, lookId, pageKey, upTableFu }: Props) {
|
|
|
<></>
|
|
|
);
|
|
|
return res;
|
|
|
- }, [annulFu, delFu, editFu, info.status]);
|
|
|
+ }, [annulFu, delFu, editFu, info.auditDesc, info.status, info.type]);
|
|
|
+
|
|
|
+ // 表格信息(藏品编辑)
|
|
|
+ const [tableListByEdit, setTableListByEdit] = useState<B1EditTable[]>([]);
|
|
|
|
|
|
- // 表格信息
|
|
|
+ // 表格信息(除了藏品编辑之外)
|
|
|
const [tableList, setTableList] = useState<A2inTableType[]>([]);
|
|
|
|
|
|
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={() => setGoodsId(item.id)}
|
|
|
- >
|
|
|
- 查看
|
|
|
- </Button>
|
|
|
- </>
|
|
|
- ),
|
|
|
- },
|
|
|
- ];
|
|
|
- }, []);
|
|
|
+ if (info.type === "BJ")
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ title: "编辑内容",
|
|
|
+ dataIndex: "txt",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "编辑前",
|
|
|
+ render: (item: B1EditTable) =>
|
|
|
+ item.type === "img" ? (
|
|
|
+ <div className="tableImgAuto">
|
|
|
+ <ImageLazy width={60} height={60} src={item.oldValue} />
|
|
|
+ </div>
|
|
|
+ ) : (
|
|
|
+ item.oldValue
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "编辑后",
|
|
|
+ render: (item: B1EditTable) =>
|
|
|
+ item.type === "img" ? (
|
|
|
+ <div className="tableImgAuto">
|
|
|
+ <ImageLazy width={60} height={60} src={item.newValue} />
|
|
|
+ </div>
|
|
|
+ ) : (
|
|
|
+ item.newValue
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ else {
|
|
|
+ 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={() => setGoodsId(item.id)}
|
|
|
+ >
|
|
|
+ 查看
|
|
|
+ </Button>
|
|
|
+ </>
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }, [info.type]);
|
|
|
+
|
|
|
+ // 我审核的 待审核的 输入框
|
|
|
+ const [auditDesc, setAuditDesc] = useState("");
|
|
|
+ const [auditStatus, setAuditStatus] = useState(0);
|
|
|
|
|
|
return (
|
|
|
<div className={styles.B1Info}>
|
|
|
@@ -199,51 +317,132 @@ function B1Info({ closeFu, lookId, pageKey, upTableFu }: Props) {
|
|
|
<div className="mySorrl">{info.description || "(空)"}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div className="B1IBox">
|
|
|
- <div className="B1IRow">
|
|
|
- <div>审批人:</div>
|
|
|
- <div>{info.auditUser || "(空)"}</div>
|
|
|
- </div>
|
|
|
- <div className="B1IRow">
|
|
|
- <div>审批时间:</div>
|
|
|
- <div>{info.auditTime || "(空)"}</div>
|
|
|
+
|
|
|
+ {!info.auditUser && !info.auditTime ? null : (
|
|
|
+ <div className="B1IBox">
|
|
|
+ <div className="B1IRow">
|
|
|
+ <div>审批人:</div>
|
|
|
+ <div>{info.auditUser || "(空)"}</div>
|
|
|
+ </div>
|
|
|
+ <div className="B1IRow">
|
|
|
+ <div>审批时间:</div>
|
|
|
+ <div>{info.auditTime || "(空)"}</div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ )}
|
|
|
|
|
|
- <div className="B1IBox B1IBox2">
|
|
|
- <div className="B1IRow">
|
|
|
- <div>审批备注:</div>
|
|
|
- <div className="mySorrl">{info.auditDesc || "(空)"}</div>
|
|
|
+ {!info.auditUser && !info.auditTime && !info.auditDesc ? null : (
|
|
|
+ <div className="B1IBox B1IBox2">
|
|
|
+ <div className="B1IRow">
|
|
|
+ <div>审批备注:</div>
|
|
|
+ <div className="mySorrl">{info.auditDesc || "(空)"}</div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ )}
|
|
|
|
|
|
- {/* 操作按钮 */}
|
|
|
- <div className="B1IbtnArr">{btnArr}</div>
|
|
|
+ {/* 操作按钮*/}
|
|
|
+ <div className="B1IbtnArr">
|
|
|
+ {pageKey === "我提交的" ? (
|
|
|
+ btnArr
|
|
|
+ ) : info.status === 1 ? (
|
|
|
+ // 我审核的 (待审核的操作)
|
|
|
+ <div className="B1IbtnArrAudit">
|
|
|
+ <div>
|
|
|
+ <Button
|
|
|
+ disabled={!auditStatus}
|
|
|
+ type="primary"
|
|
|
+ onClick={() => annulFu(auditStatus, auditDesc)}
|
|
|
+ >
|
|
|
+ 完成审批
|
|
|
+ </Button>
|
|
|
+  
|
|
|
+ <Radio
|
|
|
+ onChange={(e) => setAuditStatus(e.target.value)}
|
|
|
+ value={3}
|
|
|
+ checked={auditStatus === 3}
|
|
|
+ >
|
|
|
+ 审批通过
|
|
|
+ </Radio>
|
|
|
+  
|
|
|
+ <Radio
|
|
|
+ onChange={(e) => setAuditStatus(e.target.value)}
|
|
|
+ value={2}
|
|
|
+ checked={auditStatus === 2}
|
|
|
+ >
|
|
|
+ 审批驳回
|
|
|
+ </Radio>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <TextArea
|
|
|
+ value={auditDesc}
|
|
|
+ onChange={(e) => setAuditDesc(e.target.value)}
|
|
|
+ maxLength={100}
|
|
|
+ showCount
|
|
|
+ placeholder="请输入备注"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ ) : null}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
{/* 下面的表格 */}
|
|
|
- <div className="B1Itable">
|
|
|
- <Table
|
|
|
- size="small"
|
|
|
- scroll={{ y: 438 }}
|
|
|
- dataSource={tableList}
|
|
|
- columns={columns}
|
|
|
- rowKey="id"
|
|
|
- pagination={false}
|
|
|
- />
|
|
|
+ <div
|
|
|
+ className={classNames(
|
|
|
+ "B1Itable",
|
|
|
+ info.type !== "BJ" ? "B1ItableNoEdit" : ""
|
|
|
+ )}
|
|
|
+ >
|
|
|
+ {/* <div className="B1ItableLeft">
|
|
|
+ {info.type === "BJ" ? "编辑信息" : "藏品清单"}:
|
|
|
+ </div> */}
|
|
|
+
|
|
|
+ {/* 藏品编辑表格 */}
|
|
|
+ {info.type === "BJ" ? (
|
|
|
+ <Table
|
|
|
+ size="small"
|
|
|
+ scroll={{ y: 438 }}
|
|
|
+ dataSource={tableListByEdit}
|
|
|
+ columns={columns}
|
|
|
+ rowKey="id"
|
|
|
+ pagination={false}
|
|
|
+ />
|
|
|
+ ) : (
|
|
|
+ // 其他表格
|
|
|
+ <Table
|
|
|
+ size="small"
|
|
|
+ scroll={{ y: 438 }}
|
|
|
+ dataSource={tableList}
|
|
|
+ columns={columns}
|
|
|
+ rowKey="id"
|
|
|
+ pagination={false}
|
|
|
+ />
|
|
|
+ )}
|
|
|
</div>
|
|
|
{/* 点击表格里面的查看出来的页面 */}
|
|
|
{goodsId ? (
|
|
|
- <B1Look goodsId={goodsId} closeFu={() => setGoodsId(0)} />
|
|
|
+ <B1Look
|
|
|
+ goodsId={goodsId}
|
|
|
+ closeFu={() => setGoodsId(0)}
|
|
|
+ />
|
|
|
) : null}
|
|
|
|
|
|
{/* 点击编辑按钮出来的页面 */}
|
|
|
{outInfo.id ? (
|
|
|
- <A2Register
|
|
|
- closeFu={() => setOutInfo({ id: 0, txt: "" })}
|
|
|
- outInfo={outInfo}
|
|
|
- upInfoFu={() => getInfoFu(info.id, true)}
|
|
|
- />
|
|
|
+ info.type === "BJ" ? (
|
|
|
+ <A2AddModal
|
|
|
+ addInfo={{ id: outInfo.id, txt: "编辑" }}
|
|
|
+ upTableFu={() => {}}
|
|
|
+ closeFu={() => setOutInfo({ id: 0, txt: "" })}
|
|
|
+ idOldToNew={true}
|
|
|
+ />
|
|
|
+ ) : (
|
|
|
+ <A2Register
|
|
|
+ closeFu={() => setOutInfo({ id: 0, txt: "" })}
|
|
|
+ outInfo={outInfo}
|
|
|
+ upInfoFu={() => getInfoFu(info.id, true)}
|
|
|
+ />
|
|
|
+ )
|
|
|
) : null}
|
|
|
</div>
|
|
|
);
|