shaogen1995 2 vuotta sitten
vanhempi
commit
57cb2c95dc

+ 1 - 0
package-lock.json

@@ -21,6 +21,7 @@
         "echarts": "^5.4.0",
         "js-base64": "^3.7.3",
         "js-export-excel": "^1.1.4",
+        "lodash": "^4.17.21",
         "react": "^18.2.0",
         "react-dom": "^18.2.0",
         "react-lazyimg-component": "^1.0.1",

+ 1 - 0
package.json

@@ -16,6 +16,7 @@
     "echarts": "^5.4.0",
     "js-base64": "^3.7.3",
     "js-export-excel": "^1.1.4",
+    "lodash": "^4.17.21",
     "react": "^18.2.0",
     "react-dom": "^18.2.0",
     "react-lazyimg-component": "^1.0.1",

+ 11 - 8
src/components/ImageLazy/index.tsx

@@ -16,7 +16,7 @@ type Props = {
 };
 
 function ImageLazy({ width = 100, height = 100, src, noLook }: Props) {
-  const [defaultUrl, setDefaultUrl] = useState(imgLoding);
+  const [defaultUrl, setDefaultUrl] = useState(src?imgLoding:imgErr);
   const [defaultShow, setDefaultShow] = useState(true);
 
   const onLoad = (val: any) => {
@@ -38,13 +38,16 @@ function ImageLazy({ width = 100, height = 100, src, noLook }: Props) {
   return (
     <div className={styles.ImageLazy} style={{ width: width, height: height }}>
       <div className="lazyBox">
-        <Lazyimg
-          onLoad={onLoad}
-          src={baseURL + src}
-          width={width}
-          height={height}
-          alt=""
-        />
+        {src ? (
+          <Lazyimg
+            onLoad={onLoad}
+            src={baseURL + src}
+            width={width}
+            height={height}
+            alt=""
+          />
+        ) : null}
+
         {/* 图片预览 */}
         {noLook ? null : (
           <div className="lookImg" onClick={() => setVisible(true)}>

+ 3 - 0
src/components/ObjectAdd/index.css

@@ -98,6 +98,9 @@
   width: 119px;
   text-align: right;
 }
+.ObjectAdd .fileBox .fileBoxRow .fileBoxRow_tit2 {
+  line-height: 30px;
+}
 .ObjectAdd .fileBox .fileBoxRow .fileBoxRow_r {
   padding-left: 20px;
   position: relative;

+ 3 - 0
src/components/ObjectAdd/index.less

@@ -136,6 +136,9 @@
         width: 119px;
         text-align: right;
       }
+      .fileBoxRow_tit2{
+        line-height: 30px;
+      }
 
       .fileBoxRow_r {
         padding-left: 20px;

+ 80 - 52
src/components/ObjectAdd/index.tsx

@@ -12,21 +12,14 @@ import {
 } from "antd";
 import { PlusOutlined, CloseCircleOutlined } from "@ant-design/icons";
 import TextArea from "antd/es/input/TextArea";
-import React, {
-  useCallback,
-  useEffect,
-  useMemo,
-  useRef,
-  useState,
-} from "react";
+import React, { useCallback, useMemo, useRef, useState } from "react";
 import styles from "./index.module.scss";
 import classNames from "classnames";
 import "./index.css";
 import { useDispatch, useSelector } from "react-redux";
 import { RootState } from "@/store";
 import ImageLazy from "../ImageLazy";
-import { object1AddUpFileAPI } from "@/store/action/object1";
-import dayjs from "dayjs";
+import { goodsSonAddAPI, object1AddUpFileAPI } from "@/store/action/object1";
 const { Option } = Select;
 
 type Props = {
@@ -46,9 +39,46 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
   };
   // 通过校验之后发送请求
   const onFinish = async (values: any) => {
-    console.log("具体质量的单位", danweiValue);
+    const oldObj = {} as any;
+    for (const k in values) {
+      if (values[k]) oldObj[k] = values[k];
+    }
+
+    // 外形尺寸 3个 字段 变成一个组数
+    const size = [values.size1, values.size2, values.size3];
+    // 具体质量 + 单位
+    let quality = "";
+    if (values.quality) quality = values.quality + danweiValue;
+    // 文件id
+    const fileIds = [] as any;
+    for (const k in results) {
+      results[k].forEach((v: any) => {
+        fileIds.push(v.id);
+      });
+    }
+    // 年代
+    const dictAge = values.dictAge.join("/");
+    // 文物质地
+    const dictTexture = values.dictTexture.join("/");
+
+    const obj = {
+      ...oldObj,
+      size,
+      quality,
+      thumb: cover,
+      dirCode: dirCode + "",
+      fileIds: fileIds.join(","),
+      registerId: dirCode,
+      dictAge,
+      dictTexture,
+    };
+    await dispatch(goodsSonAddAPI(obj));
+    //  关闭弹窗
+    colsePage();
+
+    // console.log('------封面信息',cover);
 
-    console.log("--点击确定存到仓库", values);
+    // console.log('-------附件信息',results);
   };
 
   // 选择商品信息还是附近(默认商品信息)
@@ -92,20 +122,20 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
   const defaultData = useRef<any>(null);
   if (id) {
     defaultData.current = {
-      name1: "编辑",
-      name3: "索书号",
-      name5: ["其他"],
+      name: "编辑",
+      dictNum: "索书号",
+      dictAge: ["其他"],
     };
   } else {
     defaultData.current = {
-      name3: options1[0].name ? options1[0].name : null,
-      name5: ["地质年代", "显生宙", "新生代", "第四纪"],
-      name6: ["单一质地", "有机质", "竹"],
-      name8: options4[0].name ? options4[0].name : null,
-      name10: options5[0].name ? options5[0].name : null,
-      name15: options6[0].name ? options6[0].name : null,
-      name17: options7[0].name ? options7[0].name : null,
-      name19: options9[0].name ? options9[0].name : null,
+      dictNum: options1[0].name ? options1[0].name : null,
+      dictAge: ["地质年代", "显生宙", "新生代", "第四纪"],
+      dictTexture: ["单一质地", "有机质", "竹"],
+      dictGoodType: options4[0].name ? options4[0].name : null,
+      dictLevel: options5[0].name ? options5[0].name : null,
+      dictQualityScope: options6[0].name ? options6[0].name : null,
+      complete: options7[0].name ? options7[0].name : null,
+      dictCheckInScope: options9[0].name ? options9[0].name : null,
     };
   }
 
@@ -142,7 +172,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
     const tempArr = [
       {
         title: "附件名称",
-        dataIndex: "fileName",
+        dataIndex: "name",
       },
       {
         title: "上传时间",
@@ -255,6 +285,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
         if (res.code === 0) {
           message.success("上传成功!");
           if (upFileFlagRef.current) {
+            // 重新上传
             const id = upFileFlagRef.current;
             const data = {
               ...results,
@@ -263,20 +294,17 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
                 else
                   return {
                     ...res.data,
-                    id:Date.now(),
-                    createTime: dayjs(Date.now()).format("YYYY-MM-DD"),
                   };
               }),
             };
             dispatch({ type: "login/setFileData", payload: data });
           } else {
+            // 新上传
             const data = {
               ...results,
               [fileSelect]: [
                 {
                   ...res.data,
-                  id:Date.now(),
-                  createTime: dayjs(Date.now()).format("YYYY-MM-DD"),
                 },
                 ...results[fileSelect],
               ],
@@ -333,19 +361,19 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
             <div className="formRow">
               <Form.Item
                 label="藏品名称"
-                name="name1"
+                name="name"
                 rules={[{ required: true, message: "不能为空!" }]}
               >
                 <Input maxLength={50} showCount placeholder="请输入" />
               </Form.Item>
-              <Form.Item label="原名" name="name2">
+              <Form.Item label="原名" name="namePrimitive">
                 <Input maxLength={50} showCount placeholder="请输入" />
               </Form.Item>
             </div>
             {/* 藏品编号名称----------藏品编号 */}
             <div className="formRow">
               <div className="bs">*</div>
-              <Form.Item label="藏品编号名称" name="name3">
+              <Form.Item label="藏品编号名称" name="dictNum">
                 <Select
                   placeholder="请选择"
                   options={options1.map((v: any) => ({
@@ -354,7 +382,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
                   }))}
                 />
               </Form.Item>
-              <Form.Item label="藏品编号" name="name4">
+              <Form.Item label="藏品编号" name="num">
                 <Input maxLength={50} showCount placeholder="请输入" />
               </Form.Item>
             </div>
@@ -362,7 +390,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
             <div className="formRow">
               <div className="bs bs2">*</div>
               <div className="bs bs3">*</div>
-              <Form.Item label="年代" name="name5">
+              <Form.Item label="年代" name="dictAge">
                 <Cascader
                   allowClear={false}
                   fieldNames={{
@@ -374,7 +402,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
                   placeholder="请选择"
                 />
               </Form.Item>
-              <Form.Item label="文物质地" name="name6">
+              <Form.Item label="文物质地" name="dictTexture">
                 <Cascader
                   allowClear={false}
                   fieldNames={{
@@ -390,10 +418,10 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
             {/* 具体年代----------文物类别 */}
             <div className="formRow">
               <div className="bs bs3">*</div>
-              <Form.Item label="具体年代" name="name7">
+              <Form.Item label="具体年代" name="ageSpecific">
                 <Input maxLength={50} showCount placeholder="请输入" />
               </Form.Item>
-              <Form.Item label="文物类别" name="name8">
+              <Form.Item label="文物类别" name="dictGoodType">
                 <Select
                   placeholder="请选择"
                   options={options4.map((v: any) => ({
@@ -409,11 +437,11 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
               <Form.Item
                 rules={[{ required: true, message: "不能为空!" }]}
                 label="实际数量"
-                name="name9"
+                name="pcs"
               >
                 <InputNumber min={1} maxLength={8} placeholder="请输入数字" />
               </Form.Item>
-              <Form.Item label="文物级别" name="name10">
+              <Form.Item label="文物级别" name="dictLevel">
                 <Select
                   placeholder="请选择"
                   options={options5.map((v: any) => ({
@@ -428,7 +456,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
               <Form.Item
                 rules={[{ required: true, message: "不能为空!" }]}
                 label="外形尺寸"
-                name="name11"
+                name="size1"
               >
                 <InputNumber
                   min={1}
@@ -440,7 +468,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
               <Form.Item
                 rules={[{ required: true, message: "不能为空!" }]}
                 label=""
-                name="name12"
+                name="size2"
               >
                 <InputNumber
                   min={1}
@@ -453,7 +481,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
                 className="formRowThreeRow"
                 rules={[{ required: true, message: "不能为空!" }]}
                 label=""
-                name="name13"
+                name="size3"
               >
                 <InputNumber
                   min={1}
@@ -467,7 +495,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
             <div className="formRow formRowFull">
               <Form.Item
                 label="具体尺寸"
-                name="name14"
+                name="sizeSpecific"
                 rules={[{ required: true, message: "不能为空!" }]}
               >
                 <Input maxLength={50} showCount placeholder="请输入" />
@@ -476,7 +504,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
             {/* 质量范围----------具体质量 */}
             <div className="formRow">
               <div className="bs bs4">*</div>
-              <Form.Item label="质量范围" name="name15">
+              <Form.Item label="质量范围" name="dictQualityScope">
                 <Select
                   placeholder="请选择"
                   options={options6.map((v: any) => ({
@@ -488,7 +516,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
               <Form.Item
                 className="formRowSelec"
                 label="具体质量"
-                name="name16"
+                name="quality"
               >
                 <InputNumber
                   min={1}
@@ -512,7 +540,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
             {/* 完残程度----------保存状态 */}
             <div className="formRow">
               <div className="bs bs4">*</div>
-              <Form.Item label="完残程度" name="name17">
+              <Form.Item label="完残程度" name="complete">
                 <Select
                   placeholder="请选择"
                   options={options7.map((v: any) => ({
@@ -521,7 +549,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
                   }))}
                 />
               </Form.Item>
-              <Form.Item label="保存状态" name="name18">
+              <Form.Item label="保存状态" name="repair">
                 <Select
                   placeholder="请选择"
                   options={options8.map((v: any) => ({
@@ -534,7 +562,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
             {/* 入藏时间范围----------入藏年度 */}
             <div className="formRow">
               <div className="bs">*</div>
-              <Form.Item label="入藏时间范围" name="name19">
+              <Form.Item label="入藏时间范围" name="dictCheckInScope">
                 <Select
                   placeholder="请选择"
                   options={options9.map((v: any) => ({
@@ -543,7 +571,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
                   }))}
                 />
               </Form.Item>
-              <Form.Item label="入藏年度" name="name20">
+              <Form.Item label="入藏年度" name="checkInYear">
                 <InputNumber
                   min={1000}
                   maxLength={4}
@@ -553,22 +581,22 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
             </div>
             {/* 著者----------版本 */}
             <div className="formRow">
-              <Form.Item label="著者" name="name21">
+              <Form.Item label="著者" name="author">
                 <Input maxLength={50} showCount placeholder="请输入" />
               </Form.Item>
-              <Form.Item label="版本" name="name22">
+              <Form.Item label="版本" name="vision">
                 <Input maxLength={50} showCount placeholder="请输入" />
               </Form.Item>
             </div>
             {/* 存卷*/}
             <div className="formRow formRowFull">
-              <Form.Item label="存卷" name="name23">
+              <Form.Item label="存卷" name="onFile">
                 <Input maxLength={50} showCount placeholder="请输入" />
               </Form.Item>
             </div>
             {/* 来源说明*/}
             <div className="formRow formRowFull">
-              <Form.Item label="来源说明" name="name24">
+              <Form.Item label="来源说明" name="description">
                 <TextArea
                   rows={3}
                   placeholder="请输入"
@@ -618,7 +646,7 @@ function ObjectAdd({ id, colsePage, editId, dirCode }: Props) {
               </div>
               {/* 附件上传 */}
               <div className="fileBoxRow">
-                <div className="fileBoxRow_tit">上传附件:</div>
+                <div className="fileBoxRow_tit fileBoxRow_tit2">上传附件:</div>
                 <div className="fileBoxRow_r">
                   <input
                     type="file"

+ 92 - 30
src/pages/ObjectSon/Object1/AddObject1/index.tsx

@@ -13,10 +13,18 @@ import { useLocation } from "react-router-dom";
 import styles from "./index.module.scss";
 import ObjectAdd from "@/components/ObjectAdd";
 import ImageLazy from "@/components/ImageLazy/index";
-import { useSelector } from "react-redux";
+import { useDispatch, useSelector } from "react-redux";
 import { RootState } from "@/store";
-import { object1AddAPI } from "@/store/action/object1";
+import {
+  delInTablesAPI,
+  getObj1InfoTableAPI,
+  object1AddAPI,
+  object1infoOutAPI,
+} from "@/store/action/object1";
+import _ from "lodash";
 function AddObject1() {
+  const dispatch = useDispatch();
+
   // 从仓库中获取藏品来源下拉数据
   const options = useSelector(
     (state: RootState) => state.loginStore.selectAll["文物来源"]
@@ -33,6 +41,17 @@ function AddObject1() {
     });
   }, [options]);
 
+  // 通过id获取详情函数
+  const object1infoOutAPIFu = useCallback(
+    async (id: number) => {
+      const res = await object1infoOutAPI(id);
+      setAddInfoTop(res.data);
+      // 获取表格详情信息
+      dispatch(getObj1InfoTableAPI(id));
+    },
+    [dispatch]
+  );
+
   // 获取地址栏参数
   const location = useLocation();
   const [urlParam, setUrlParam] = useState<any>({});
@@ -41,8 +60,10 @@ function AddObject1() {
     setUrlParam(obj);
 
     if (obj.id) {
+      // 如果是编辑
+      object1infoOutAPIFu(obj.id);
     } else object1AddAPIFu();
-  }, [location, object1AddAPIFu]);
+  }, [location, object1AddAPIFu, object1infoOutAPIFu]);
 
   // 藏品来源下拉框
   const handleChange = (value: string) => {
@@ -54,14 +75,37 @@ function AddObject1() {
   // 选中的表格数据
   const [tableSelectList, setTableSelectList] = useState([]);
 
+  // 从仓库拿表格信息
+  const results = useSelector(
+    (state: RootState) => state.loginStore.goodsTableList
+  );
+
+  // 前端删除成功的id集合,用于点击存入草稿或者提交成功之后 传入后端删除
+  const delIds = useRef<any>([]);
+
   // 点击删除
-  const delTableListFu = () => {
+  const delTableListFu = useCallback(() => {
     console.log("多个删除", tableSelectList);
-  };
+    const data = _.differenceBy(results, tableSelectList, "id");
+    dispatch({ type: "login/setGoodsSonList", payload: data });
 
-  const delOne = (id: number) => {
-    console.log("单个删除", id);
-  };
+    // 删除的id存起来
+    tableSelectList.forEach((v: any) => {
+      delIds.current.push(v.id);
+    });
+  }, [dispatch, results, tableSelectList]);
+
+  const delOne = useCallback(
+    (id: number) => {
+      const data = results.filter((v: any) => v.id !== id);
+      dispatch({ type: "login/setGoodsSonList", payload: data });
+      console.log("单个删除", id);
+      // 删除的id存起来
+      delIds.current.push(id);
+    },
+
+    [dispatch, results]
+  );
 
   const rowSelection = {
     onChange: (selectedRowKeys: any, selectedRows: any) => {
@@ -69,10 +113,6 @@ function AddObject1() {
     },
   };
 
-  const results = useMemo(() => {
-    return [];
-  }, []);
-
   // 点击添加或者编辑
 
   const addId = useRef<any>(null);
@@ -87,18 +127,16 @@ function AddObject1() {
       {
         title: "缩略图",
         render: (item: any) => (
-          <div className="tableImg">
-            <ImageLazy width={120} height={70} src={item.img} />
-          </div>
+          <ImageLazy width={120} height={70} src={item.thumb} />
         ),
       },
       {
         title: "藏品编号名称",
-        dataIndex: "name",
+        dataIndex: "dictNum",
       },
       {
         title: "藏品编号",
-        dataIndex: "name",
+        render: (item: any) => (item.num ? item.num : "-"),
       },
       {
         title: "藏品名称",
@@ -106,15 +144,15 @@ function AddObject1() {
       },
       {
         title: "类别",
-        dataIndex: "name",
+        dataIndex: "dictGoodType",
       },
       {
         title: "完残程度",
-        dataIndex: "name",
+        dataIndex: "complete",
       },
       {
         title: "年代",
-        dataIndex: "name",
+        dataIndex: "dictAge",
       },
       {
         title: "操作",
@@ -137,22 +175,42 @@ function AddObject1() {
         ),
       },
     ];
-  }, [addPageFu]);
+  }, [addPageFu, delOne]);
 
   // 点击返回
-  const cancelFu = () => {
+  const cancelFu = useCallback(() => {
     history.push({
       pathname: `/object`,
       state: { k: urlParam.k ? urlParam.k : "1" },
     });
-  };
+  }, [urlParam.k]);
 
   // 点击提交
-  const submitFu = (val: number) => {
-    if (results.length === 0)
-      return message.warning("至少需要添加一条藏品信息!");
-    // cancelFu()
-  };
+  const submitFu = useCallback(
+    async (val: number) => {
+      if (results.length === 0)
+        return message.warning("至少需要添加一条藏品信息!");
+      const obj = {
+        ...addInfoTop,
+        status: val,
+      };
+      const res: any = await object1AddAPI(obj);
+      if (res.code === 0) {
+        // 真正进行删除
+        if (delIds.current.length) {
+          const res2: any = await delInTablesAPI(delIds.current.join(","));
+          if (res2.code === 0) {
+            message.warning("操作成功!");
+            cancelFu();
+          }
+        } else {
+          message.warning("操作成功!");
+          cancelFu();
+        }
+      }
+    },
+    [addInfoTop, cancelFu, results.length]
+  );
 
   // 点击添加或者编辑出来页面
   const [addPage, setAddPage] = useState(false);
@@ -179,7 +237,11 @@ function AddObject1() {
             </div>
             <div>
               <span className="bs">登记人员:</span>
-              <Input style={{ width: 400 }} value={addInfoTop.creatorName} disabled />
+              <Input
+                style={{ width: 400 }}
+                value={addInfoTop.creatorName}
+                disabled
+              />
             </div>
           </div>
           <div className="row">
@@ -245,7 +307,7 @@ function AddObject1() {
             />
           </div>
           <div className="addTableBox_btn">
-            <Button onClick={() => submitFu(1)}>存入草稿</Button>
+            <Button onClick={() => submitFu(0)}>存入草稿</Button>
             &emsp;
             <Button type="primary" onClick={() => submitFu(1)}>
               提交

+ 108 - 81
src/pages/ObjectSon/Object1/index.tsx

@@ -2,30 +2,43 @@ import BreadTit from "@/components/BreadTit";
 import classNames from "classnames";
 import { useEffect, useMemo, useRef, useState } from "react";
 import styles from "./index.module.scss";
-import { Select, Input, DatePicker, Table, Button, Popconfirm } from "antd";
+import {
+  Select,
+  Input,
+  DatePicker,
+  Table,
+  Button,
+  Popconfirm,
+  message,
+} from "antd";
 import AuthButton from "@/components/AuthButton";
 import history from "@/utils/history";
 import { useLocation } from "react-router-dom";
-import { useSelector } from "react-redux";
+import { useDispatch, useSelector } from "react-redux";
 import { RootState } from "@/store";
+import {
+  getObject1List,
+  getObject1ListNum,
+  object1DelAPI,
+} from "@/store/action/object1";
 
 const { RangePicker } = DatePicker;
 
 export default function Object1() {
-  const dataTit = useMemo(() => {
-    return [
-      { id: 1, name: "全部", num: 30 },
-      { id: 2, name: "代办理", num: 10 },
-      { id: 3, name: "待审核", num: 0 },
-      { id: 4, name: "审核不通过", num: 15 },
-      { id: 5, name: "已完成", num: 5 },
-    ];
-  }, []);
+  const dispatch = useDispatch();
+
+  // 获取顶部数量
+
+  useEffect(() => {
+    dispatch(getObject1ListNum());
+  }, [dispatch]);
+
+  const dataTit = useSelector((state: RootState) => state.objectStore.infoNum1);
 
   // 封装发送请求的函数
   const getList = () => {
     const data = { ...tableSelect, pageNum: pageNumRef.current };
-    console.log("------", data);
+    dispatch(getObject1List(data));
   };
 
   // 获取地址栏参数
@@ -43,10 +56,10 @@ export default function Object1() {
 
   // 顶部筛选
   const [tableSelect, setTableSelect] = useState({
-    state: 1,
-    laiyuan: null,
-    name: "",
-    staTime: "",
+    status: null as null | number,
+    sourceName: null,
+    searchKey: "",
+    startTime: "",
     endTime: "",
     pageSize: 10,
     pageNum: 1,
@@ -72,7 +85,7 @@ export default function Object1() {
 
   // 藏品来源下拉框筛选
   const handleChange = (value: any) => {
-    setTableSelect({ ...tableSelect, laiyuan: value, pageNum: 1 });
+    setTableSelect({ ...tableSelect, sourceName: value, pageNum: 1 });
   };
 
   // 登记人员输入
@@ -80,73 +93,77 @@ export default function Object1() {
   const nameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
     clearTimeout(nameTime.current);
     nameTime.current = window.setTimeout(() => {
-      setTableSelect({ ...tableSelect, name: e.target.value, pageNum: 1 });
+      setTableSelect({ ...tableSelect, searchKey: e.target.value, pageNum: 1 });
     }, 500);
   };
 
   // 时间选择器改变
   const timeChange = (date: any, dateString: any) => {
-    let staTime = "";
+    let startTime = "";
     let endTime = "";
     if (dateString[0] && dateString[1]) {
-      staTime = dateString[0] + " 00:00:00";
+      startTime = dateString[0] + " 00:00:00";
       endTime = dateString[1] + " 23:59:59";
     }
-    setTableSelect({ ...tableSelect, staTime, endTime, pageNum: 1 });
+    setTableSelect({ ...tableSelect, startTime, endTime, pageNum: 1 });
   };
 
   // 点击新增或者编辑按钮
   const addObject = (id?: any) => {
+    // 清空详情页面里面的附件表格信息
+    dispatch({ type: "login/setGoodsSonList", payload: [] });
+
     if (id) history.push(`/object/1/add?k=${pageNumRef.current}&id=${id}`);
     else history.push(`/object/1/add?k=${pageNumRef.current}`);
   };
 
   // 点击删除按钮
-  const delOne = (id: number) => {
-    console.log("删除", id);
+  const delOne = async (id: number) => {
+    const res: any = await object1DelAPI(id);
+    if (res.code === 0) {
+      message.success("删除成功!");
+      getList();
+      dispatch(getObject1ListNum());
+    }
   };
 
-  // 关于表格的数据
+  // ---------关于表格
+
+  // 页码变化
   const paginationChange = (pageNum: number, pageSize: number) => {
     setTableSelect({ ...tableSelect, pageNum, pageSize });
   };
 
-  const results = {
-    list: [
-      { name: "666-1", id: 1 },
-      { name: "666-2", id: 2 },
-      { name: "666-3", id: 3 },
-      { name: "666-4", id: 4 },
-      { name: "666-5", id: 5 },
-      { name: "666-6", id: 6 },
-      { name: "666-7", id: 7 },
-      { name: "666-8", id: 8 },
-      { name: "666-9", id: 9 },
-      { name: "666-10", id: 10 },
-      { name: "666-11", id: 11 },
-      { name: "666-12", id: 12 },
-      { name: "666-13", id: 13 },
-      { name: "666-14", id: 14 },
-      { name: "666-15", id: 15 },
-      { name: "666-16", id: 16 },
-      { name: "666-17", id: 17 },
-      { name: "666-18", id: 18 },
-      { name: "666-19", id: 19 },
-      { name: "666-20", id: 20 },
-      { name: "666-21", id: 21 },
-      { name: "666-22", id: 22 },
-      { name: "666-23", id: 23 },
-    ],
-    total: 23,
-  };
+  const results = useSelector((state: RootState) => state.objectStore.info1);
 
   const columns = useMemo(() => {
     return [
       {
-        title: "标题",
-        dataIndex: "name",
+        title: "登记编号",
+        dataIndex: "num",
+      },
+      {
+        title: "藏品来源",
+        dataIndex: "sourceName",
+      },
+      {
+        title: "登记人员",
+        dataIndex: "creatorName",
+      },
+      {
+        title: "创建日期",
+        dataIndex: "createTime",
+      },
+      {
+        title: "完成日期",
+        render: (item: any) => (item.day ? item.day : "-"),
       },
       {
+        title: "状态",
+        dataIndex: "statusTxt",
+      },
+
+      {
         title: "操作",
         render: (item: any) => (
           <>
@@ -161,31 +178,39 @@ export default function Object1() {
             >
               查看
             </Button>
-            <AuthButton type="text" danger onClick={() => addObject(item.id)}>
-              编辑
-            </AuthButton>
 
-            <AuthButton
-              onClick={() =>
-                history.push(
-                  `/object/1/audit?k=${pageNumRef.current}&id=${item.id}`
-                )
-              }
-              type="text"
-              danger
-            >
-              审核
-            </AuthButton>
-            <Popconfirm
-              title="确定删除吗?"
-              okText="确定"
-              cancelText="取消"
-              onConfirm={() => delOne(item.id)}
-            >
-              <AuthButton type="text" danger>
-                删除
+            {item.status === 0 || item.status === 2 ? (
+              <AuthButton type="text" danger onClick={() => addObject(item.id)}>
+                编辑
+              </AuthButton>
+            ) : null}
+
+            {item.status === 1 ? (
+              <AuthButton
+                onClick={() =>
+                  history.push(
+                    `/object/1/audit?k=${pageNumRef.current}&id=${item.id}`
+                  )
+                }
+                type="text"
+                danger
+              >
+                审核
               </AuthButton>
-            </Popconfirm>
+            ) : null}
+
+            {item.status === 0 || item.status === 2 ? (
+              <Popconfirm
+                title="确定删除吗?"
+                okText="确定"
+                cancelText="取消"
+                onConfirm={() => delOne(item.id)}
+              >
+                <AuthButton type="text" danger>
+                  删除
+                </AuthButton>
+              </Popconfirm>
+            ) : null}
           </>
         ),
       },
@@ -208,13 +233,15 @@ export default function Object1() {
       <div className="objectSonMain">
         {/* 顶部筛选 */}
         <div className="objectSonMainTit">
-          {dataTit.map((v) => (
+          {dataTit.map((v: any) => (
             <div
               key={v.id}
               onClick={() =>
-                setTableSelect({ ...tableSelect, state: v.id, pageNum: 1 })
+                setTableSelect({ ...tableSelect, status: v.id, pageNum: 1 })
               }
-              className={classNames(v.id === tableSelect.state ? "active" : "")}
+              className={classNames(
+                v.id === tableSelect.status ? "active" : ""
+              )}
             >
               {v.name}({v.num})
             </div>
@@ -229,7 +256,7 @@ export default function Object1() {
                 placeholder="请选择"
                 allowClear
                 style={{ width: 150 }}
-                value={tableSelect.laiyuan}
+                value={tableSelect.sourceName}
                 onChange={handleChange}
                 options={options.map((v: any) => ({
                   label: v.name,

+ 0 - 10
src/store/action/login.ts

@@ -33,13 +33,3 @@ export const getSelectAllAPI = () => {
     dispatch({type:'login/getSelectAll',payload:obj})
   };
 };
-
-// export const addNunAction = () => {
-
-//   return async (dispatch: AppDispatch) => {
-//     // const res = await http.get(`http://geek.itheima.net/v1_0/sms/codes/${18702025090}`)
-//     // console.log('----', res);
-//     const { num } = store.getState().loginStore
-//     dispatch({ type: 'login/addNum', payload: num + 1 })
-//   }
-// }

+ 98 - 2
src/store/action/object1.ts

@@ -1,15 +1,111 @@
 import http from "@/utils/http";
+import { message } from "antd";
+import store, { AppDispatch } from "..";
 
 /**
  * 藏品登记页面点击新增
  */
 export const object1AddAPI = (data?: any) => {
-  return http.post("cms/register/save", {...data});
+  return http.post("cms/register/save", { ...data });
 };
 
 /**
- * 藏品登记页面点击新增
+ * 藏品登记页面上传封面图和附件
  */
 export const object1AddUpFileAPI = (data: any) => {
   return http.post("cms/register/goods/file/upload", data);
 };
+
+/**
+ * 里面的一条藏品添加
+ */
+export const goodsSonAddAPI = (data: any) => {
+  return async (dispatch: AppDispatch) => {
+    const res: any = await http.post("cms/register/goods/save", data);
+
+    if (res.code === 0) {
+      const newData = [res.data, ...store.getState().loginStore.goodsTableList];
+      message.success("操作成功!");
+      dispatch({ type: "login/setGoodsSonList", payload: newData });
+    }
+  };
+};
+
+// 状态的筛选
+const statusObj = {
+  0: "待办理", //草稿中
+  1: "待审核", //待审核
+  2: "审核不通过", //审核不通过
+  3: "已完成", //审核通过
+} as any;
+
+/**
+ * 获取藏品登记列表信息
+ */
+export const getObject1List = (data: any) => {
+  return async (dispatch: AppDispatch) => {
+    // 获取列表数据
+    const res: any = await http.post("cms/register/pageList", data);
+    const list = res.data.records;
+    list.forEach((v: any) => {
+      v.statusTxt = statusObj[v.status];
+    });
+    const obj = {
+      list,
+      total: res.data.total,
+    };
+    dispatch({ type: "object1/getList", payload: obj });
+  };
+};
+
+/**
+ * 获取藏品登记列表顶部数字信息
+ */
+export const getObject1ListNum = () => {
+  return async (dispatch: AppDispatch) => {
+    // 获取统计数据
+    const res: any = await http.get("cms/register/countByStatus");
+
+    const data = [
+      { id: null, name: "全部", num: res.data.all ? res.data.all : 0 },
+      { id: 0, name: "待办理", num: res.data[0] ? res.data[0] : 0 },
+      { id: 1, name: "待审核", num: res.data[1] ? res.data[1] : 0 },
+      { id: 2, name: "审核不通过", num: res.data[2] ? res.data[2] : 0 },
+      { id: 3, name: "已完成", num: res.data[3] ? res.data[3] : 0 },
+    ];
+    dispatch({ type: "object1/getListNum", payload: data });
+  };
+};
+
+/**
+ * 删除外层表格数据
+ */
+export const object1DelAPI = (id: number) => {
+  return http.get(`cms/register/remove/${id}`);
+};
+
+/**
+ * 通过id获取信息
+ */
+export const object1infoOutAPI = (id: number) => {
+  return http.get(`cms/register/detail/${id}`);
+};
+
+/**
+ * 通过id获取表格信息
+ */
+export const getObj1InfoTableAPI = (id: number) => {
+  return async (dispatch: AppDispatch) => {
+    // 获取统计数据
+    const res: any = await http.get(`cms/register/goods/list/${id}`);
+    dispatch({ type: "login/setGoodsSonList", payload: res.data });
+  };
+};
+
+
+/**
+ * 删除里面的表格藏品 s
+ */
+export const delInTablesAPI = (ids: string) => {
+  return http.get(`cms/register/goods/removes/${ids}`);
+};

+ 2 - 0
src/store/reducer/index.ts

@@ -1,9 +1,11 @@
 import { combineReducers } from 'redux'
 import loginReducer from './login'
+import objectReducer from './object'
 
 // 合并 reducer
 const rootReducer = combineReducers({
   loginStore: loginReducer,
+  objectStore:objectReducer
 })
 
 export default rootReducer

+ 24 - 16
src/store/reducer/login.ts

@@ -1,29 +1,34 @@
 // 初始化状态应用注解
 const initState = {
+  // 所有下拉数据
   selectAll: {
-    "藏品编号名称":[],
-    "文物级别":[],
-    "文物来源":[],
-    "完残程度":[],
-    "保存状态":[],
-    "入藏时间范围":[],
-    "质量范围":[],
-    "文物类别":[],
-    "质地":[],
-    "年代":[],
+    藏品编号名称: [],
+    文物级别: [],
+    文物来源: [],
+    完残程度: [],
+    保存状态: [],
+    入藏时间范围: [],
+    质量范围: [],
+    文物类别: [],
+    质地: [],
+    年代: [],
   } as any,
+  // 单个里面的藏品的附件信息
   fileData: {
-    img:[],
-    video:[],
-    audio:[],
-    model:[],
-    doc:[]
+    img: [],
+    video: [],
+    audio: [],
+    model: [],
+    doc: [],
   } as any,
+  // 藏品的表格信息
+  goodsTableList: [] as any,
 };
 
 type LoginActionType =
   | { type: "login/getSelectAll"; payload: any }
-  | { type: "login/setFileData"; payload: any };
+  | { type: "login/setFileData"; payload: any }
+  | { type: "login/setGoodsSonList"; payload: any };
 // 频道 reducer
 export default function loginReducer(
   state = initState,
@@ -36,6 +41,9 @@ export default function loginReducer(
     // 新增编辑藏品的附件数据
     case "login/setFileData":
       return { ...state, fileData: action.payload };
+    // 新增编辑藏品 的外层 表格信息
+    case "login/setGoodsSonList":
+      return { ...state, goodsTableList: action.payload };
     default:
       return state;
   }

+ 30 - 0
src/store/reducer/object.ts

@@ -0,0 +1,30 @@
+// 初始化状态应用注解
+const initState = {
+  // 表格数据
+  info1: {
+    list: [] as any,
+    total: 0,
+  },
+  // 表格顶部数字数据
+  infoNum1: [],
+};
+
+type LoginActionType =
+  | { type: "object1/getList"; payload: any }
+  | { type: "object1/getListNum"; payload: any };
+// 频道 reducer
+export default function objectReducer(
+  state = initState,
+  action: LoginActionType
+) {
+  switch (action.type) {
+    // 表格数据1
+    case "object1/getList":
+      return { ...state, info1: action.payload };
+    // 表格顶部数字数据1
+    case "object1/getListNum":
+      return { ...state, infoNum1: action.payload };
+    default:
+      return state;
+  }
+}

+ 2 - 1
src/types/declaration.d.ts

@@ -4,4 +4,5 @@ declare module '*.png';
 declare module '*.gif';
 declare module 'moment';
 declare module 'react-lazy-load-image-component'
-declare module 'js-export-excel'
+declare module 'js-export-excel'
+declare module 'lodash'