Browse Source

原厂专区,品牌推荐,代理经销,库存寄售 数据请求调整

hangb 8 years ago
parent
commit
edf0457908
1 changed files with 39 additions and 39 deletions
  1. 39 39
      store/product/kind.js

+ 39 - 39
store/product/kind.js

@@ -1,8 +1,8 @@
 export const state = () => ({
-  // kinds: {
-  //   fetching: false,
-  //   data: []
-  // },
+  kinds: {
+    fetching: false,
+    data: []
+  },
   kindsParentWithBother: {
     fetching: false,
     data: []
@@ -22,41 +22,41 @@ export const state = () => ({
 })
 
 export const mutations = {
-  // REQUEST_KIND (state, action) {
-  //   if (!action.id) {
-  //     state.kinds.fetching = true
-  //   } else {
-  //     const kind = state.kinds.data.find(kind => Object.is(kind.id, action.id))
-  //     if (kind) {
-  //       kind.fetching = true
-  //     }
-  //   }
-  // },
-  // GET_KIND_FAILURE (state, action) {
-  //   if (!action.id) {
-  //     state.kinds.fetching = false
-  //   } else {
-  //     const kind = state.kinds.data.find(kind => Object.is(kind.id, action.id))
-  //     if (kind) {
-  //       kind.fetching = false
-  //     }
-  //   }
-  // },
-  // GET_KIND_SUCCESS (state, action) {
-  //   if (!action.id) {
-  //     state.kinds.fetching = false
-  //     action.result.forEach(kind => {
-  //       kind.fetching = false
-  //     })
-  //     state.kinds.data = action.result
-  //   } else {
-  //     const kind = state.kinds.data.find(kind => Object.is(kind.id, action.id))
-  //     if (kind) {
-  //       kind.fetching = false
-  //       kind.children = action.result
-  //     }
-  //   }
-  // },
+  REQUEST_KIND (state, action) {
+    if (!action.id) {
+      state.kinds.fetching = true
+    } else {
+      const kind = state.kinds.data.find(kind => Object.is(kind.id, action.id))
+      if (kind) {
+        kind.fetching = true
+      }
+    }
+  },
+  GET_KIND_FAILURE (state, action) {
+    if (!action.id) {
+      state.kinds.fetching = false
+    } else {
+      const kind = state.kinds.data.find(kind => Object.is(kind.id, action.id))
+      if (kind) {
+        kind.fetching = false
+      }
+    }
+  },
+  GET_KIND_SUCCESS (state, action) {
+    if (!action.id) {
+      state.kinds.fetching = false
+      action.result.forEach(kind => {
+        kind.fetching = false
+      })
+      state.kinds.data = action.result
+    } else {
+      const kind = state.kinds.data.find(kind => Object.is(kind.id, action.id))
+      if (kind) {
+        kind.fetching = false
+        kind.children = action.result
+      }
+    }
+  },
   REQUEST_KINDPARENTSWITHBOTHERS (state) {
     state.kindsParentWithBother.fetching = true
   },