浏览代码

refactor: 剔除table重构后mobx多余的代码

lanjianrong 4 年之前
父节点
当前提交
1d86f0b022
共有 2 个文件被更改,包括 44 次插入44 次删除
  1. 9 9
      src/store/mobx/contractPaid/index.ts
  2. 35 35
      src/store/mobx/contractReturn/index.ts

+ 9 - 9
src/store/mobx/contractPaid/index.ts

@@ -2,7 +2,7 @@ import { apiContractTree } from "@/pages/Contract/Content/Income/components/Moda
 import { iContractState, ContractTree } from "@/types/contract"
 import consts from "@/utils/consts"
 import { action, computed, observable } from "mobx"
-import { ContractType, lookupNode, nodeCheck } from "../contractReturn"
+import { ContractType } from "../contractReturn"
 
 class Contract {
 
@@ -52,16 +52,16 @@ class Contract {
   }
 
   // 增加行
-  @action addRowTree(id: string) {
-    const newTree = lookupNode(id, this.tree)
-    this.tree = newTree
-  }
+  // @action addRowTree(id: string) {
+  //   const newTree = lookupNode(id, this.tree)
+  //   this.tree = newTree
+  // }
 
   // 行点击
-  @action rowChange(id: string) {
-    const newTree = nodeCheck(id, this.tree)
-    this.tree = newTree
-  }
+  // @action rowChange(id: string) {
+  //   const newTree = nodeCheck(id, this.tree)
+  //   this.tree = newTree
+  // }
   @computed get showTable() {
     return this.tree && this.tree.length > 1
   }

+ 35 - 35
src/store/mobx/contractReturn/index.ts

@@ -80,50 +80,50 @@ class Contract {
   }
 
   // 增加行
-  @action addRowTree(id: string) {
-    const newTree = lookupNode(id, this.tree)
-    this.tree = newTree
-  }
+  // @action addRowTree(id: string) {
+  //   const newTree = lookupNode(id, this.tree)
+  //   this.tree = newTree
+  // }
 
   // 行点击
-  @action rowChange(id: string) {
-    const newTree = nodeCheck(id, this.tree)
-    this.tree = newTree
-  }
+  // @action rowChange(id: string) {
+  //   const newTree = nodeCheck(id, this.tree)
+  //   this.tree = newTree
+  // }
   @computed get showTable() {
     return this.tree && this.tree.length > 1
   }
 }
 
-export function lookupNode(id: string, tree: ContractTree[]) {
-  return tree.map((item:ContractTree) => {
-    item.isEdit = false
-    if (item.id === id) {
-      if (Array.isArray(item.children)) {
-        item.children.push({ ...initData[0], isNew: true, code: item.code + `-${item.children.length + 1 }`, parentId: item.id, bidsectionId: item.bidsectionId, attribution: item.code + '-', serial: 1, children: [] })
-      } else {
-        item.children = [ { ...initData[0], isNew: true, code: item.code + '-1', parentId: item.id, bidsectionId: item.bidsectionId, attribution: item.code + '-', serial: 1, children: [] } ]
-      }
-      return item
-    } else if(item.children && item.children.length) {
-      item.children = lookupNode(id, item.children)
-    }
-    return item
-  })
-}
+// export function lookupNode(id: string, tree: ContractTree[]) {
+//   return tree.map((item:ContractTree) => {
+//     item.isEdit = false
+//     if (item.id === id) {
+//       if (Array.isArray(item.children)) {
+//         item.children.push({ ...initData[0], isNew: true, code: item.code + `-${item.children.length + 1 }`, parentId: item.id, bidsectionId: item.bidsectionId, attribution: item.code + '-', serial: 1, children: [] })
+//       } else {
+//         item.children = [ { ...initData[0], isNew: true, code: item.code + '-1', parentId: item.id, bidsectionId: item.bidsectionId, attribution: item.code + '-', serial: 1, children: [] } ]
+//       }
+//       return item
+//     } else if(item.children && item.children.length) {
+//       item.children = lookupNode(id, item.children)
+//     }
+//     return item
+//   })
+// }
 
 // 项目节被选中更改isEdit的值
-export function nodeCheck(id: string, tree: ContractTree[]) {
-  return tree.map((item: ContractTree) => {
-    item.isEdit = false
-    if (item.id === id) {
-      item.isEdit = true
+// export function nodeCheck(id: string, tree: ContractTree[]) {
+//   return tree.map((item: ContractTree) => {
+//     item.isEdit = false
+//     if (item.id === id) {
+//       item.isEdit = true
 
-    } else if(Array.isArray(item.children)) {
-      item.children = nodeCheck(id, item.children)
-    }
-    return item
-  })
-}
+//     } else if(Array.isArray(item.children)) {
+//       item.children = nodeCheck(id, item.children)
+//     }
+//     return item
+//   })
+// }
 
 export default new Contract()