shaogen1995 2 лет назад
Родитель
Сommit
88de01d13b

+ 23 - 10
houtai/src/pages/A4Venue/VenueEdit/index.tsx

@@ -1,5 +1,9 @@
-import { venueUploadAPI } from "@/store/action/A4Venue";
-import { ImgListType } from "@/types";
+import {
+  getVenueDetailAPI,
+  setVenueSaveApi,
+  venueUploadAPI,
+} from "@/store/action/A4Venue";
+import { ImgListType, VenueTableType } from "@/types";
 import { domShowFu, progressDomFu } from "@/utils/domShow";
 import { MessageFu } from "@/utils/message";
 import { Button, Form, FormInstance, Input, Popconfirm } from "antd";
@@ -32,9 +36,13 @@ function VenueEdit({ id, closePageFu, editTableFu }: Props) {
   const myInput = useRef<HTMLInputElement>(null);
 
   // 通过id获取详情,回显数据
-  const getInfoFu = useCallback((id: number) => {
-    // setDirCode(res.data.entity.dirCode);
-    FormBoxRef.current?.setFieldsValue({})
+  const getInfoFu = useCallback(async (id: number) => {
+    const res = await getVenueDetailAPI(id);
+    const data: VenueTableType = res.data.entity;
+    const fileList: ImgListType[] = res.data.file;
+    setDirCode(data.dirCode);
+    FormBoxRef.current?.setFieldsValue(data);
+    setImgList(fileList);
   }, []);
 
   useEffect(() => {
@@ -134,7 +142,7 @@ function VenueEdit({ id, closePageFu, editTableFu }: Props) {
 
   // 通过校验点击确定
   const onFinish = useCallback(
-    (values: any) => {
+    async (values: VenueTableType) => {
       setTypeOk(true);
 
       if (fileCheckFu) return;
@@ -144,10 +152,15 @@ function VenueEdit({ id, closePageFu, editTableFu }: Props) {
         id: id > 0 ? id : null,
         dirCode,
         fileIds: imgList.map((v) => v.id).join(","),
+        thumb: imgList[0].filePath,
       };
-      console.log(obj);
-      editTableFu();
-      closePageFu();
+      // console.log(obj);
+      const res = await setVenueSaveApi(obj);
+      if (res.code === 0) {
+        MessageFu.success("编辑成功!");
+        editTableFu();
+        closePageFu();
+      }
     },
     [closePageFu, dirCode, editTableFu, fileCheckFu, id, imgList]
   );
@@ -174,7 +187,7 @@ function VenueEdit({ id, closePageFu, editTableFu }: Props) {
 
           <Form.Item
             label="位置"
-            name="myLoc"
+            name="location"
             rules={[{ required: true, message: "请输入位置!" }]}
             getValueFromEvent={(e) => e.target.value.replace(/\s+/g, "")}
           >

+ 9 - 8
houtai/src/pages/A4Venue/VenueTable/index.tsx

@@ -10,12 +10,14 @@ import styles from "./index.module.scss";
 // 表格拖动排序-----------------
 import { DndProvider, useDrag, useDrop } from "react-dnd";
 import { HTML5Backend } from "react-dnd-html5-backend";
+import { venueSortApi } from "@/store/action/A4Venue";
 
 type Porps = {
   editInfoFu: (id: number) => void;
+  delInfoFu:()=>void
 };
 
-function VenueTable({ editInfoFu }: Porps) {
+function VenueTable({ editInfoFu,delInfoFu }: Porps) {
   // 有关表格数据
   const results = useSelector(
     (state: RootState) => state.venueReducer.tableInfo
@@ -46,7 +48,7 @@ function VenueTable({ editInfoFu }: Porps) {
       {
         title: "位置",
         render: (item: VenueTableType) =>
-          item.creatorName ? item.creatorName : "(空)",
+          item.location ? item.location : "(空)",
       },
       {
         title: "简介",
@@ -74,7 +76,7 @@ function VenueTable({ editInfoFu }: Porps) {
 
       {
         title: "最近编辑时间",
-        dataIndex: "time1",
+        dataIndex: "updateTime",
       },
 
       {
@@ -84,7 +86,7 @@ function VenueTable({ editInfoFu }: Porps) {
             <Button
               size="small"
               type="text"
-              onClick={() => editInfoFu(item.id)}
+              onClick={() => editInfoFu(item.id!)}
             >
               编辑
             </Button>
@@ -165,13 +167,12 @@ function VenueTable({ editInfoFu }: Porps) {
       // 交互位置-之前的id
       const beforeId = results[dragIndex].id;
       const afterId = results[hoverIndex].id;
-      console.log("发送请求", beforeId, afterId);
 
-      // const res = await wallSortAPI(beforeId, afterId);
+      const res = await venueSortApi(beforeId!, afterId!);
 
-      // if (res.code === 0) dispatch(getWallTableListAPI());
+      if (res.code === 0) delInfoFu()
     },
-    [results]
+    [delInfoFu, results]
   );
 
   return (

+ 5 - 2
houtai/src/pages/A4Venue/index.tsx

@@ -105,10 +105,13 @@ function Venue() {
         <VenueEdit
           id={editId}
           closePageFu={() => setEditId(0)}
-          editTableFu={() => console.log("编辑了数据")}
+          editTableFu={() => dispatch(getVenueListAPI(tableSelect))}
         />
       ) : (
-        <VenueTable editInfoFu={(id) => addInfoFu(id)} />
+        <VenueTable
+          editInfoFu={(id) => addInfoFu(id)}
+          delInfoFu={() => dispatch(getVenueListAPI(tableSelect))}
+        />
       )}
     </div>
   );

Разница между файлами не показана из-за своего большого размера
+ 11 - 9
houtai/src/pages/A5Guest/index.tsx


+ 24 - 3
houtai/src/store/action/A4Venue.ts

@@ -1,4 +1,4 @@
-import { VenueTableApiType } from "@/types";
+import { VenueTableApiType, VenueTableType } from "@/types";
 import { domShowFu, progressDomFu } from "@/utils/domShow";
 import http from "@/utils/http";
 import axios from "axios";
@@ -11,7 +11,7 @@ const CancelToken = axios.CancelToken;
 export const venueUploadAPI = (data: any) => {
   domShowFu("#UpAsyncLoding", true);
 
-  return http.post("cms/goods/upload", data, {
+  return http.post("cms/exhibition/upload", data, {
     timeout: 50000,
     // 显示进度条
     onUploadProgress: (e: any) => {
@@ -39,4 +39,25 @@ export const getVenueListAPI = (data: VenueTableApiType) => {
       payload: res.data,
     });
   };
-};
+};
+
+/**
+ * 详情
+ */
+export const getVenueDetailAPI = (id:number) => {
+  return http.get(`cms/exhibition/detail/${id}`);
+};
+
+/**
+ * 拖动排序
+ */
+export const venueSortApi = (id1:number,id2:number) => {
+  return http.get(`cms/exhibition/sort/${id1}/${id2}`);
+};
+
+/**
+ * 新增|编辑
+ */
+export const setVenueSaveApi = (data:VenueTableType) => {
+  return http.post('cms/exhibition/save',data);
+};

+ 1 - 1
houtai/src/types/api/A4Venue.d.ts

@@ -5,7 +5,7 @@ export type VenueTableType = {
   description: string;
   dirCode: string;
   fileIds: string;
-  id: number;
+  id: number|null;
   location: string;
   name: string;
   sort?: any;