shaogen1995 преди 10 месеца
родител
ревизия
d253c669da
променени са 5 файла, в които са добавени 22 реда и са изтрити 11 реда
  1. 10 5
      src/pages/A2classify/A2add.tsx
  2. 1 1
      src/pages/A2classify/index.module.scss
  3. 5 5
      src/pages/A2classify/index.tsx
  4. 1 0
      src/store/action/A2classify.ts
  5. 5 0
      src/store/reducer/A2classify.ts

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

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

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

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

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

@@ -18,7 +18,7 @@ export type TopLeftArrType = '中图法分类' | '展示分类'
 const topLeftArr: TopLeftArrType[] = ['中图法分类', '展示分类']
 
 function A2classify() {
-  const treeDataTemp = useSelector((state: RootState) => state.A2classify.treeData)
+  const { treeData: treeDataTemp, treeFlag } = useSelector((state: RootState) => state.A2classify)
   const dispatch = useDispatch()
 
   const [topType, setTopType] = useState<TopLeftArrType>('中图法分类')
@@ -248,9 +248,9 @@ function A2classify() {
                 // 点击
                 onSelect={onSelect}
               />
-            ) : (
+            ) : treeFlag ? (
               <div className='A2Null'>暂无数据</div>
-            )}
+            ) : null}
           </div>
           <div className='A2m1rr'>
             <div className='A2mr1'>分类详情</div>
@@ -295,9 +295,9 @@ function A2classify() {
                   <div className='A2mr3rr'>{rightData.creatorName}</div>
                 </div>
               </>
-            ) : (
+            ) : treeFlag ? (
               <div className='A2Null'>暂无数据</div>
-            )}
+            ) : null}
           </div>
         </div>
         <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')
     if (res.code === 0) {
       dispatch({ type: 'A2/getTree', payload: res.data })
+      dispatch({ type: 'A2/treeFlag', payload: true })
       // console.log(123, res)
     }
   }

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

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