Jelajahi Sumber

馆藏-时代从手动输入改成下拉

shaogen1995 4 minggu lalu
induk
melakukan
62383fdf7d
3 mengubah file dengan 37 tambahan dan 3 penghapusan
  1. 3 0
      .env
  2. 28 3
      src/pages/A5goods/A5add/index.tsx
  3. 6 0
      src/store/action/A5goods.ts

+ 3 - 0
.env

@@ -0,0 +1,3 @@
+# .env.production
+GENERATE_SOURCEMAP = false
+# 关闭映射

+ 28 - 3
src/pages/A5goods/A5add/index.tsx

@@ -1,6 +1,6 @@
 import React, { useCallback, useEffect, useRef, useState } from "react";
 import styles from "./index.module.scss";
-import { A5_APIgetInfo, A5_APIsave } from "@/store/action/A5goods";
+import { A5_APIgetAgeList, A5_APIgetInfo, A5_APIsave } from "@/store/action/A5goods";
 import dayjs from "dayjs";
 import {
   Button,
@@ -50,6 +50,23 @@ type Props = {
 };
 
 function A5add({ addId, closeFu, addTableFu, editTableFu }: Props) {
+
+
+  // 获取时代下拉数组
+  const [ageList,setAgeList] =useState<any[]>([])
+
+  const getAgeListFu =useCallback(async()=>{
+    const res =await A5_APIgetAgeList()
+    if(res.code===0){
+      setAgeList(res.data||[])
+      
+    }
+  },[])
+
+  useEffect(()=>{
+    getAgeListFu()
+  },[getAgeListFu])
+
   const getInfoFu = useCallback(async (id: number) => {
     const res = await A5_APIgetInfo(id);
     if (res.code === 0) {
@@ -280,13 +297,21 @@ function A5add({ addId, closeFu, addTableFu, editTableFu }: Props) {
             />
           </Form.Item>
 
-          <Form.Item
+          <Form.Item label="时代" name="dictAgeId">
+            <Select
+              placeholder="请选择"
+              style={{ width: 400 }}
+              options={ageList.map(v=>({value:v.id,label:v.name}))}
+            />
+          </Form.Item>
+
+          {/* <Form.Item
             label="时代"
             name="dictAge"
             getValueFromEvent={(e) => e.target.value.replace(/\s+/g, "")}
           >
             <Input maxLength={10} showCount placeholder="请输入内容" />
-          </Form.Item>
+          </Form.Item> */}
 
           <Form.Item
             label="质地"

+ 6 - 0
src/store/action/A5goods.ts

@@ -36,3 +36,9 @@ export const A5_APIgetInfo = (id: number) => {
 export const A5_APIsave = (data: any) => {
   return http.post("cms/goods/save", data);
 };
+/**
+ * 从字典里面拿时代数组
+ */
+export const A5_APIgetAgeList = () => {
+  return http.get(`cms/dict/getList?type=age`);
+};