Quellcode durchsuchen

fix(core): 修复

wjx vor 1 Jahr
Ursprung
Commit
a39b188eee
2 geänderte Dateien mit 12 neuen und 4 gelöschten Zeilen
  1. 3 2
      src/pages/Task/submitTask.tsx
  2. 9 2
      src/pages/Task/video.tsx

+ 3 - 2
src/pages/Task/submitTask.tsx

@@ -26,6 +26,7 @@ const SubmitTask: React.FC<Props> = ({
 }) => {
   /*********************************/
   const [form] = Form.useForm<{ materialBeanList: TASKAPI.MaterialBean[] }>();
+  const materialBeanList = Form.useWatch('materialBeanList', form);
   const [visible, setVisible] = useState<boolean>(false);
   const addMaterial = useRequest(addMaterialApi, { manual: true });
   /*********************************/
@@ -48,11 +49,11 @@ const SubmitTask: React.FC<Props> = ({
     switch (materialType) {
       // 视频提交
       case 'MATERIAL_TYPE_VIDEO' as MaterialTypeEnum:
-        return <Video materialClaimJson={materialClaimJson} />;
+        return <Video materialClaimJson={materialClaimJson} materialBeanList={materialBeanList} />;
       default:
         return null;
     }
-  }, [materialType, materialClaimJson]);
+  }, [materialType, materialClaimJson, materialBeanList]);
 
   return (
     <>

+ 9 - 2
src/pages/Task/video.tsx

@@ -10,6 +10,7 @@ import './index.less';
 
 interface Props {
   materialClaimJson: string;
+  materialBeanList: TASKAPI.MaterialBean[];
   value?: TASKAPI.MaterialBean;
   onChange?: (value?: TASKAPI.MaterialBean) => void;
 }
@@ -17,7 +18,7 @@ interface Props {
  * 视频上传
  * @returns
  */
-const Video: React.FC<Props> = ({ value, onChange, materialClaimJson }) => {
+const Video: React.FC<Props> = ({ value, onChange, materialClaimJson, materialBeanList = [] }) => {
   /** 变量START */
   const [videoFile, setVideoFile] = useState<TASKAPI.MaterialBean | undefined>(value);
   const [loading, setLoading] = useState<boolean>(false);
@@ -43,7 +44,13 @@ const Video: React.FC<Props> = ({ value, onChange, materialClaimJson }) => {
     if (!isWHCorrect) {
       message.error(`视频宽高必须${w} * ${h}!`);
     }
-    return isZipOrRar && isLt20M && isWHCorrect;
+    const md5 = await getMD5(file);
+    const isRepeat =
+      materialBeanList?.length > 0 ? !materialBeanList.some((item) => item.md5 === md5) : true;
+    if (!isRepeat) {
+      message.error(`请勿重复选择!`);
+    }
+    return isZipOrRar && isLt20M && isWHCorrect && isRepeat;
   };
 
   return (