wjx 2 лет назад
Родитель
Сommit
010ac458c8

+ 12 - 36
src/components/FileBoxAD/components/fileModal/index.tsx

@@ -37,46 +37,22 @@ function FileModal(props: { isAll?: boolean }) {
                 placeholder='请输入序号, 数值越大越靠前'
                 onChange={(e: number) => {
                     set({ sort: e })
-                }} 
+                }}
             />
         </div>
 
         {
-            actionItem?.fileType === 'VIDEO' ? <div>
-                <div style={{ display: 'flex', flexFlow: 'row', marginBottom: 10, alignItems: 'center' }}>
-                    <label style={{ width: '15%' }}>名称:</label>
-                    <Input
-                        value={videoTitle}
-                        allowClear
-                        placeholder='请输入名称'
-                        onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
-                            set({ videoTitle: event.target.value })
-                        }}
-                    /></div>
-                <div style={{ display: 'flex', flexFlow: 'row', alignItems: 'center' }}>
-                    <label style={{ width: '15%' }}>描述:</label>
-                    <Input.TextArea
-                        placeholder='请输入描述内容'
-                        allowClear
-                        value={videoDescription}
-                        onChange={(event: React.ChangeEvent<HTMLTextAreaElement>) => {
-                            set({ videoDescription: event.target.value })
-                        }}
-                    />
-                </div>
-            </div> : <>
-                <div style={{ display: 'flex', flexFlow: 'row', marginBottom: 10, alignItems: 'center' }}>
-                    <label style={{ width: '15%' }}>名称:</label>
-                    <Input
-                        value={fileName}
-                        allowClear
-                        placeholder='请输入名称'
-                        onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
-                            set({ fileName: event.target.value })
-                        }}
-                    />
-                </div>
-            </>
+            <div style={{ display: 'flex', flexFlow: 'row', marginBottom: 10, alignItems: 'center' }}>
+                <label style={{ width: '15%' }}>名称:</label>
+                <Input
+                    value={fileName}
+                    allowClear
+                    placeholder='请输入名称'
+                    onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
+                        set({ fileName: event.target.value })
+                    }}
+                />
+            </div>
         }
     </Modal>
 }

+ 5 - 3
src/components/FileBoxAD/index.tsx

@@ -72,12 +72,14 @@ function FlieBox(props: Props) {
     }, [])
     /**全局右键菜单 */
     const Menu = useCallback((props: { isItem?: boolean }) => {
+        console.log('props--->', props, rightClickPup);
+        
         if (props.isItem && isAll) {
             return <ul style={{ top: xy?.y, left: xy?.x }} className={style.menu} >
                 {
                     isAll || num === 100 && <li onClick={allFile}>全选/反选</li>
                 }
-                {mediaType === 'PAGE' ? <>
+                {mediaType === 'PAGE' && !rightClickPup.folder ? <>
                     {/* <li onClick={() => { setPage && setPage(1, rightClickPup.id) }}>查看</li> */}
                     <li onClick={() => { setPage && setPage(2, rightClickPup.id) }}>复制</li>
                     <li onClick={() => { setPage && setPage(3, rightClickPup.id) }}>批量复制</li>
@@ -89,7 +91,7 @@ function FlieBox(props: Props) {
                 <li onClick={() => { set({ imgVisrible: true }) }}>新建素材</li>
                 <li onClick={(e) => { delPupOn(rightClickPup.id); onFile(e, rightClickPup, isAll, true) }} style={{ color: 'red' }}> 删除</li>
                 {
-                    isAll && <li onClick={dels} style={{ color: 'red' }}>删除选中文件</li>
+                    isAll && selectFile && selectFile?.length > 0 && <li onClick={dels} style={{ color: 'red' }}>删除选中文件</li>
                 }
             </ul>
         }
@@ -107,7 +109,7 @@ function FlieBox(props: Props) {
                 mediaType === 'IMG' && <li onClick={() => { set({ imgsVisrible: true }) }}>批量新建素材</li>
             }
             {
-                isAll && <li onClick={dels} style={{ color: 'red' }}>删除选中文件</li>
+                isAll && selectFile && selectFile?.length > 0 && <li onClick={dels} style={{ color: 'red' }}>删除选中文件</li>
             }
         </ul>
     }, [xy, rightClickPup, allFile, mediaType])

+ 14 - 12
src/models/useLaunchAdq/useBdMedia.ts

@@ -325,11 +325,11 @@ function useBdMediaPup() {
     /**编辑非图文素材名称*/
     const nameOk = useCallback((selectWx?: any) => {
         if (fileName && actionItem) {
-            let obj = { title: fileName, belongUser: belongUser === '0' ? false : true, sysMediaId: actionItem?.id, mediaType: actionItem?.mediaType, folder: actionItem?.folder, url: actionItem?.url, sort }
-            if (mediaType === 'VIDEO') {
-                obj['videoTitle'] = videoTitle
-                obj['videoDescription'] = videoDescription
-            }
+            let obj = { title: fileName, belongUser: belongUser === '0' ? false : true, sysMediaId: actionItem?.id, mediaType: mediaType, folder: actionItem?.folder, url: actionItem?.url, sort }
+            // if (mediaType === 'VIDEO') {
+            //     obj['videoTitle'] = videoTitle
+            //     obj['videoDescription'] = videoDescription
+            // }
             edit.run(obj).then((res) => {
                 list.refresh()
                 offEditFile()//关闭弹窗并清空相关数据
@@ -350,6 +350,8 @@ function useBdMediaPup() {
                     }
                 })
             })
+        } else {
+            message.error('请选择文件')
         }
     }, [list, selectFile, mediaType])
     /**获取本地素材数据列表 */
@@ -470,14 +472,14 @@ function useBdMediaPup() {
     const editFile = useCallback((e?: any,) => {
         e?.stopPropagation()
         onFile(null, rightClickPup, true, true)
-        // if (rightClickPup?.mediaType !== 'news') {//不是图文开启编辑名字弹窗
-        let obj = { fileVisible: true, actionItem: rightClickPup, fileName: rightClickPup.title, sort: rightClickPup.sort }
-        if (rightClickPup?.mediaType === 'video') {
-            obj['videoTitle'] = rightClickPup?.videoTitle || rightClickPup?.title
-            obj['videoDescription'] = rightClickPup?.videoDescription
-        }
-        set(obj)
+        let obj = { fileVisible: true, actionItem: { ...rightClickPup, fileType: mediaType }, fileName: rightClickPup.title, sort: rightClickPup.sort }
+        // if (rightClickPup?.mediaType === "VIDEO") {
+        //     obj['videoTitle'] = rightClickPup?.videoTitle || rightClickPup?.title
+        //     obj['videoDescription'] = rightClickPup?.videoDescription
         // }
+        console.log('222222->', obj);
+
+        set(obj)
     }, [rightClickPup])
     /**取消编辑后清空选中存放的数据并关闭弹窗*/
     const offEditFile = useCallback(() => {

+ 18 - 26
src/models/useLaunchAdq/useBdMediaPup.ts

@@ -408,8 +408,7 @@ function useBdMediaPup() {
   }
 
   /**编辑非图文素材名称*/
-  const nameOk = useCallback(
-    (selectWx: any) => {
+  const nameOk = useCallback((selectWx: any) => {
       if (fileName && actionItem) {
         let obj = {
           title: fileName,
@@ -420,10 +419,10 @@ function useBdMediaPup() {
           url: actionItem?.url,
           sort,
         };
-        if (mediaType === 'VIDEO') {
-          obj['videoTitle'] = videoTitle;
-          obj['videoDescription'] = videoDescription;
-        }
+        // if (mediaType === 'VIDEO') {
+        //   obj['videoTitle'] = videoTitle;
+        //   obj['videoDescription'] = videoDescription;
+        // }
         edit.run(obj).then((res) => {
           list.refresh();
           offEditFile(); //关闭弹窗并清空相关数据
@@ -433,8 +432,7 @@ function useBdMediaPup() {
     [fileName, actionItem, edit, belongUser, mediaType, videoTitle, videoDescription],
   );
   /**删除文件 */
-  const dels = useCallback(
-    (id?: any) => {
+  const dels = useCallback((id?: any) => {
       let arr = typeof id === 'number' ? [id] : selectFile;
       let len = arr?.length || 0;
       if (len) {
@@ -447,6 +445,8 @@ function useBdMediaPup() {
             }
           });
         });
+      } else {
+        message.error('请选择文件')
       }
     },
     [list, selectFile, mediaType],
@@ -623,24 +623,16 @@ function useBdMediaPup() {
     offFile(null, { id: delPupId });
   }, [delPupId]);
   /**编辑 */
-  const editFile = useCallback(
-    (e?: any) => {
-      e?.stopPropagation();
-      onFile(null, rightClickPup, true, true);
-      // if (rightClickPup?.mediaType !== 'news') {//不是图文开启编辑名字弹窗
-      let obj = {
-        fileVisible: true,
-        actionItem: rightClickPup,
-        fileName: rightClickPup.title,
-        sort: rightClickPup.sort,
-      };
-      if (rightClickPup?.mediaType === 'video') {
-        obj['videoTitle'] = rightClickPup?.videoTitle || rightClickPup?.title;
-        obj['videoDescription'] = rightClickPup?.videoDescription;
-      }
-      set(obj);
-      // }
-    },
+  const editFile = useCallback((e?: any) => {
+    e?.stopPropagation();
+    onFile(null, rightClickPup, true, true);
+    let obj = { fileVisible: true, actionItem: { ...rightClickPup, fileType: mediaType }, fileName: rightClickPup.title, sort: rightClickPup.sort };
+    // if (rightClickPup?.mediaType === "video") {
+    //   obj['videoTitle'] = rightClickPup?.videoTitle || rightClickPup?.title;
+    //   obj['videoDescription'] = rightClickPup?.videoDescription;
+    // }
+    set(obj);
+  },
     [rightClickPup],
   );
   /**取消编辑后清空选中存放的数据并关闭弹窗*/