Bläddra i källkod

修改万物墙

aamin 1 år sedan
förälder
incheckning
09bc2046c5
1 ändrade filer med 63 tillägg och 38 borttagningar
  1. 63 38
      houtai/src/pages/B3Wall/index.tsx

+ 63 - 38
houtai/src/pages/B3Wall/index.tsx

@@ -34,6 +34,7 @@ function Wall() {
       console.log(data);
       setValueType(data.isAuto);
       setTimeType0(data.startTime + "," + data.endTime);
+      setTypeDisplay(data.type)
     }
   }, []);
 
@@ -85,6 +86,12 @@ function Wall() {
   // 文物类型列表
   const [types, setTypes] = useState([]);
 
+  // 文物类型展示
+  const [typeDisplay, setTypeDisplay] = useState([]);
+
+  // 文物类型修改
+  const [typeEdit, setTypeEdit] = useState([]);
+
   // 点击修改(海报/场景)
   const editAutoPlay = useCallback(() => {
     setValue1(value0);
@@ -104,9 +111,10 @@ function Wall() {
     setTime1(dateString);
   };
   // 时间选择器改变
-  //  const timeTyoChange = (date: any, dateString: any) => {
-  //   setTime1(dateString);
-  // };
+  const timeTypeChange = (date: any, dateString: any) => {
+    setTimeType1(dateString);
+    console.log(dateString);
+  };
 
   // 点击确定 (海报/场景)
   const btnOk = useCallback(async () => {
@@ -130,15 +138,15 @@ function Wall() {
       endTime: timeType1[1],
       startTime: timeType1[0],
       isAuto: value2,
+      type: typeEdit
     };
-
     const res: any = await editWallTypeApi({ content: JSON.stringify(obj) });
     if (res.code === 0) {
       MessageFu.success("修改成功!");
       getWallCategoryApiFu();
     }
-    setEdit(false);
-  }, [getWallCategoryApiFu, timeType1, value2]);
+    setEditType(false);
+  }, [getWallCategoryApiFu, timeType1, typeEdit, value2]);
 
   // 点击新增或者编辑
   const [editId, setEditId] = useState(0);
@@ -257,37 +265,54 @@ function Wall() {
             </div>
             {editType ? (
               // 修改信息
-              <div className="edit">
-                <div>展示日期:</div>
-                <Radio.Group
-                  onChange={(e) => setValueType(e.target.value)}
-                  value={valueType}
-                >
-                  <Radio value={0}>关闭</Radio>
-                  <Radio value={1}>开启</Radio>
-                </Radio.Group>
-                &emsp;
-                <RangePicker
-                  allowClear={false}
-                  // defaultValue={[
-                  //   dayjs(timeType1[0], "YYYY/MM/DD"),
-                  //   dayjs(timeType1[1], "YYYY/MM/DD"),
-                  // ]}
-                  onChange={timeChange}
-                />
-                &emsp;
-                <Button type="primary" onClick={btnOkType}>
-                  确定
-                </Button>
-                &emsp;
-                <Popconfirm
-                  title="放弃编辑后,信息将不会保存!"
-                  okText="放弃"
-                  cancelText="取消"
-                  onConfirm={() => setEditType(false)}
-                >
-                  <Button>取消</Button>
-                </Popconfirm>
+              <div>
+                <div className="edit">
+                  <div>展示日期:</div>
+                  <Radio.Group
+                    onChange={(e) => setValue2(e.target.value)}
+                    value={value2}
+                  >
+                    <Radio value={0}>关闭</Radio>
+                    <Radio value={1}>开启</Radio>
+                  </Radio.Group>
+                  &emsp;
+                  <RangePicker
+                    allowClear={false}
+                    defaultValue={[
+                      dayjs(timeType1[0], "YYYY/MM/DD"),
+                      dayjs(timeType1[1], "YYYY/MM/DD"),
+                    ]}
+                    onChange={timeTypeChange}
+                  />
+                  &emsp;
+                  <Button type="primary" onClick={btnOkType}>
+                    确定
+                  </Button>
+                  &emsp;
+                  <Popconfirm
+                    title="放弃编辑后,信息将不会保存!"
+                    okText="放弃"
+                    cancelText="取消"
+                    onConfirm={() => setEditType(false)}
+                  >
+                    <Button>取消</Button>
+                  </Popconfirm>
+                </div>
+                <div className="txt">
+                  <div style={{ marginRight: "5px" }}>展示类别:</div>
+                  <Radio.Group
+                    onChange={(e) => setTypeEdit(e.target.value)}
+                    value={typeEdit}
+                  >
+                    {types.map((item) => {
+                      return (
+                        <Radio key={item} value={item}>
+                          {item}
+                        </Radio>
+                      );
+                    })}
+                  </Radio.Group>
+                </div>
               </div>
             ) : (
               // 展示信息
@@ -305,7 +330,7 @@ function Wall() {
                 </div>
                 <div className="txt">
                   <div style={{ marginRight: "5px" }}>展示类别:</div>
-                  <div>{types}</div>
+                  <div>{typeDisplay}</div>
                 </div>
               </div>
             )}