shaogen1995 10 月之前
父節點
當前提交
d253c669da

+ 10 - 5
src/pages/A2classify/A2add.tsx

@@ -38,8 +38,13 @@ function A2add({ addInfo, addFu, closeFu }: Props) {
     if (addInfo.acInfo.ancestor)
     if (addInfo.acInfo.ancestor)
       ids = [...addInfo.acInfo.ancestor.split(',').map(v => Number(v)), addInfo.acInfo.id]
       ids = [...addInfo.acInfo.ancestor.split(',').map(v => Number(v)), addInfo.acInfo.id]
 
 
-    setParentIdArr(ids)
-  }, [addInfo.acInfo])
+    const idsRes = ids
+    if (ids && ids.length >= 1 && addInfo.txt === '编辑') {
+      ids.pop()
+    }
+
+    setParentIdArr(idsRes)
+  }, [addInfo.acInfo, addInfo.txt])
 
 
   const cardChange = useCallback((aa: any, bb: any) => {
   const cardChange = useCallback((aa: any, bb: any) => {
     setParentIdArr(aa)
     setParentIdArr(aa)
@@ -130,8 +135,8 @@ function A2add({ addInfo, addFu, closeFu }: Props) {
           onFinishFailed={onFinishFailed}
           onFinishFailed={onFinishFailed}
           autoComplete='off'
           autoComplete='off'
         >
         >
-          <div className='fromRow' hidden={addInfo.txt === '编辑'}>
-            <div className='fromRowll'>{addInfo.txt === '新增' ? '父级' : '当前'}分类:</div>
+          <div className='fromRow'>
+            <div className='fromRowll'>父级分类:</div>
             <div className='fromRowrr'>
             <div className='fromRowrr'>
               <Cascader
               <Cascader
                 style={{ width: 658 }}
                 style={{ width: 658 }}
@@ -139,7 +144,7 @@ function A2add({ addInfo, addFu, closeFu }: Props) {
                 changeOnSelect
                 changeOnSelect
                 fieldNames={{ label: 'name', value: 'id', children: 'children' }}
                 fieldNames={{ label: 'name', value: 'id', children: 'children' }}
                 options={treeData}
                 options={treeData}
-                placeholder='请选择'
+                placeholder={addInfo.txt === '编辑' ? '空' : '请选择'}
                 value={parentIdArr ? [...parentIdArr] : []}
                 value={parentIdArr ? [...parentIdArr] : []}
                 onChange={cardChange}
                 onChange={cardChange}
               />
               />

+ 1 - 1
src/pages/A2classify/index.module.scss

@@ -107,12 +107,12 @@
       }
       }
       .fromRow {
       .fromRow {
         display: flex;
         display: flex;
+        align-items: center;
         margin-bottom: 24px;
         margin-bottom: 24px;
         .fromRowll {
         .fromRowll {
           width: 94px;
           width: 94px;
           text-align: right;
           text-align: right;
           position: relative;
           position: relative;
-          top: 3px;
         }
         }
         .fromRowrr {
         .fromRowrr {
           width: calc(100% - 94px);
           width: calc(100% - 94px);

+ 5 - 5
src/pages/A2classify/index.tsx

@@ -18,7 +18,7 @@ export type TopLeftArrType = '中图法分类' | '展示分类'
 const topLeftArr: TopLeftArrType[] = ['中图法分类', '展示分类']
 const topLeftArr: TopLeftArrType[] = ['中图法分类', '展示分类']
 
 
 function A2classify() {
 function A2classify() {
-  const treeDataTemp = useSelector((state: RootState) => state.A2classify.treeData)
+  const { treeData: treeDataTemp, treeFlag } = useSelector((state: RootState) => state.A2classify)
   const dispatch = useDispatch()
   const dispatch = useDispatch()
 
 
   const [topType, setTopType] = useState<TopLeftArrType>('中图法分类')
   const [topType, setTopType] = useState<TopLeftArrType>('中图法分类')
@@ -248,9 +248,9 @@ function A2classify() {
                 // 点击
                 // 点击
                 onSelect={onSelect}
                 onSelect={onSelect}
               />
               />
-            ) : (
+            ) : treeFlag ? (
               <div className='A2Null'>暂无数据</div>
               <div className='A2Null'>暂无数据</div>
-            )}
+            ) : null}
           </div>
           </div>
           <div className='A2m1rr'>
           <div className='A2m1rr'>
             <div className='A2mr1'>分类详情</div>
             <div className='A2mr1'>分类详情</div>
@@ -295,9 +295,9 @@ function A2classify() {
                   <div className='A2mr3rr'>{rightData.creatorName}</div>
                   <div className='A2mr3rr'>{rightData.creatorName}</div>
                 </div>
                 </div>
               </>
               </>
-            ) : (
+            ) : treeFlag ? (
               <div className='A2Null'>暂无数据</div>
               <div className='A2Null'>暂无数据</div>
-            )}
+            ) : null}
           </div>
           </div>
         </div>
         </div>
         <div className='A2m2' hidden={topType !== '展示分类'}>
         <div className='A2m2' hidden={topType !== '展示分类'}>

+ 1 - 0
src/store/action/A2classify.ts

@@ -10,6 +10,7 @@ export const A2_APIgetList1 = (): any => {
     const res = await http.get('cms/storage/getTree')
     const res = await http.get('cms/storage/getTree')
     if (res.code === 0) {
     if (res.code === 0) {
       dispatch({ type: 'A2/getTree', payload: res.data })
       dispatch({ type: 'A2/getTree', payload: res.data })
+      dispatch({ type: 'A2/treeFlag', payload: true })
       // console.log(123, res)
       // console.log(123, res)
     }
     }
   }
   }

+ 5 - 0
src/store/reducer/A2classify.ts

@@ -4,6 +4,7 @@ import { A2tableType, A2TreeType } from '@/types'
 const initState = {
 const initState = {
   // 树数据
   // 树数据
   treeData: [] as A2TreeType[],
   treeData: [] as A2TreeType[],
+  treeFlag: false,
 
 
   // 列表数据
   // 列表数据
   tableInfo: {
   tableInfo: {
@@ -19,6 +20,10 @@ type Props =
       payload: A2TreeType[]
       payload: A2TreeType[]
     }
     }
   | {
   | {
+      type: 'A2/treeFlag'
+      payload: boolean
+    }
+  | {
       type: 'A2/getList'
       type: 'A2/getList'
       payload: { list: A2tableType[]; total: number }
       payload: { list: A2tableType[]; total: number }
     }
     }