zjxpcyc 6 年前
父节点
当前提交
04167c0de5

+ 6
- 1
src/pages/system/library/books/detail.vue 查看文件

@@ -153,9 +153,14 @@ export default {
153 153
       immediate: true,
154 154
     },
155 155
   },
156
+  beforeRouteLeave (to, from, next) {
157
+    this.resetStore('detail')
158
+    next()
159
+  },
156 160
   methods: {
157 161
     ...mapMutations({
158
-      mergeDetail: 'mergeBookDetail'
162
+      mergeDetail: 'mergeBookDetail',
163
+      resetStore: 'clearData',
159 164
     }),
160 165
     ...mapActions({
161 166
       getInfo: 'getBookDetail',

+ 18
- 3
src/pages/system/library/books/list.vue 查看文件

@@ -52,7 +52,7 @@
52 52
           </el-table-column>
53 53
           <el-table-column prop="BorrowDays" label="借阅(天)"></el-table-column>
54 54
           <el-table-column prop="InStock" label="总数量"></el-table-column>
55
-          <el-table-column prop="LeftNum" label="借出"></el-table-column>
55
+          <el-table-column prop="BorrowNum" label="借出"></el-table-column>
56 56
           <el-table-column label="预约">
57 57
             <template slot-scope="scope">
58 58
               <span>{{ getReserveNum(scope.row) }}</span>
@@ -104,7 +104,7 @@
104 104
 import { createNamespacedHelpers, mapState } from 'vuex'
105 105
 import { Loading } from 'element-ui'
106 106
 
107
-const { mapState: mapLibSate, mapActions } = createNamespacedHelpers('library')
107
+const { mapState: mapLibSate, mapActions, mapMutations } = createNamespacedHelpers('library')
108 108
 
109 109
 export default {
110 110
   name: 'bookList',
@@ -130,15 +130,30 @@ export default {
130 130
       types: s => s.type.list
131 131
     })
132 132
   },
133
+  watch: {
134
+    defaultCase(nv) {
135
+      if (nv && !this.caseId) {
136
+        this.caseId = nv
137
+        this.filterList()
138
+      }
139
+    },
140
+  },
133 141
   created() {
134 142
     this.inputRef.type = 'file'
135 143
     // https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types
136 144
     this.inputRef.accept = 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
137 145
     this.inputRef.addEventListener('change', this.importBatch.bind(this))
138 146
 
139
-    this.filterList()
147
+    // this.filterList()
148
+  },
149
+  beforeRouteLeave (to, from, next) {
150
+    this.resetStore('list')
151
+    next()
140 152
   },
141 153
   methods: {
154
+    ...mapMutations({
155
+      resetStore: 'clearData',
156
+    }),
142 157
     ...mapActions({
143 158
       getList: 'getBookList',
144 159
       getTypeList: 'getTypeList',

+ 7
- 8
src/pages/system/library/books/types/detail.vue 查看文件

@@ -88,22 +88,19 @@ export default {
88 88
           return
89 89
         }
90 90
 
91
+        if (!this.$route.params.id) {
92
+          return
93
+        }
94
+
91 95
         let CaseId = nv.CaseId
92 96
         if (!CaseId) {
93 97
           CaseId = this.defaultCase
94 98
         }
95 99
 
96 100
         this.formData = { ...nv, CaseId }
97
-        // this.mergeDetail(nv)
98 101
       },
99 102
       immediate: true,
100
-    },
101
-    // formData: {
102
-    //   handler (nv) {
103
-    //     this.mergeDetail(nv)
104
-    //   },
105
-    //   deep: true,
106
-    // },
103
+    }
107 104
   },
108 105
   methods: {
109 106
     ...mapMutations({
@@ -129,6 +126,8 @@ export default {
129 126
                 message: '更新或编辑分类成功',
130 127
                 type: 'success'
131 128
               })
129
+
130
+              this.$router.push({ name: 'libraryType' })
132 131
             })
133 132
             .catch(err => {
134 133
               this.$message({

+ 16
- 3
src/pages/system/library/books/types/list.vue 查看文件

@@ -56,7 +56,8 @@ import { createNamespacedHelpers, mapState } from 'vuex'
56 56
 
57 57
 const {
58 58
   mapState: mapLibSate,
59
-  mapActions
59
+  mapActions,
60
+  mapMutations,
60 61
 } = createNamespacedHelpers('library')
61 62
 
62 63
 export default {
@@ -78,10 +79,22 @@ export default {
78 79
       pagenum: s => s.type.pagenum,
79 80
     })
80 81
   },
81
-  created() {
82
-    this.filterList()
82
+  watch: {
83
+    defaultCase(nv) {
84
+      if (nv && !this.caseId) {
85
+        this.caseId = nv
86
+        this.filterList()
87
+      }
88
+    },
89
+  },
90
+  beforeRouteLeave (to, from, next) {
91
+    this.resetStore('type.list')
92
+    next()
83 93
   },
84 94
   methods: {
95
+    ...mapMutations({
96
+      resetStore: 'clearData',
97
+    }),
85 98
     ...mapActions({
86 99
       getList: 'getTypeList',
87 100
       deleteType: 'deleteType',

+ 1
- 1
src/pages/system/library/borrow/borrow.vue 查看文件

@@ -108,7 +108,7 @@ export default {
108 108
   },
109 109
   watch: {
110 110
     defaultCase(nv) {
111
-      if (!this.formData.caseid) {
111
+      if (nv && !this.formData.caseid) {
112 112
         this.formData.caseid = nv
113 113
       }
114 114
     }

+ 22
- 0
src/store/library/index.js 查看文件

@@ -30,6 +30,28 @@ export default {
30 30
     },
31 31
   },
32 32
   mutations: {
33
+    clearData(state, key = '') {
34
+      if (!key) return
35
+
36
+      const ks = key.split('.')
37
+      const lastInx = ks.length - 1
38
+
39
+      ks.reduce((acc, it, inx) => {
40
+        if (inx === lastInx) {
41
+          if (it === 'list') {
42
+            acc[it] = []
43
+          } else if (it === 'detail') {
44
+            acc[it] = {}
45
+          } else if (it.indexOf('page') > -1) {
46
+            acc[it] = 1
47
+          } else {
48
+            acc[it] = undefined
49
+          }
50
+        }
51
+
52
+        return acc[it]
53
+      }, state)
54
+    },
33 55
     mergeTypeDetail (state, payload) {
34 56
       state.type.detail = payload || {}
35 57