Procházet zdrojové kódy

Merge branch 'dev' of http://git.ycjcjy.com/SpaceOfCheng/admin into dev

wangfei před 6 roky
rodič
revize
f0c7665b84

+ 6
- 1
src/pages/system/library/books/detail.vue Zobrazit soubor

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

+ 30
- 13
src/pages/system/library/books/list.vue Zobrazit soubor

13
           </el-select>
13
           </el-select>
14
         </el-form-item>
14
         </el-form-item>
15
         <el-form-item label="条码">
15
         <el-form-item label="条码">
16
-          <el-input v-model="bookBarcode"></el-input>
16
+          <el-input v-model="formData.bookBarcode"></el-input>
17
         </el-form-item>
17
         </el-form-item>
18
         <el-form-item label="书名">
18
         <el-form-item label="书名">
19
-          <el-input v-model="bookName"></el-input>
19
+          <el-input v-model="formData.bookName"></el-input>
20
         </el-form-item>
20
         </el-form-item>
21
         <el-form-item :style="{ float: 'right' }">
21
         <el-form-item :style="{ float: 'right' }">
22
           <el-button type="primary" size="medium" @click="filterList">搜索</el-button>
22
           <el-button type="primary" size="medium" @click="filterList">搜索</el-button>
30
         <el-table :data="list" border style="width: 100%">
30
         <el-table :data="list" border style="width: 100%">
31
           <el-table-column label="图片" width="128">
31
           <el-table-column label="图片" width="128">
32
             <template slot-scope="scope">
32
             <template slot-scope="scope">
33
-              <img width="64" :src="scope.row.BookImg" alt>
33
+              <img width="64" :src="scope.row.BookImg + '?x-oss-process=style/compress-rotate'" alt>
34
             </template>
34
             </template>
35
           </el-table-column>
35
           </el-table-column>
36
           <el-table-column prop="BookBarcode" label="条码"></el-table-column>
36
           <el-table-column prop="BookBarcode" label="条码"></el-table-column>
52
           </el-table-column>
52
           </el-table-column>
53
           <el-table-column prop="BorrowDays" label="借阅(天)"></el-table-column>
53
           <el-table-column prop="BorrowDays" label="借阅(天)"></el-table-column>
54
           <el-table-column prop="InStock" label="总数量"></el-table-column>
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
           <el-table-column label="预约">
56
           <el-table-column label="预约">
57
             <template slot-scope="scope">
57
             <template slot-scope="scope">
58
               <span>{{ getReserveNum(scope.row) }}</span>
58
               <span>{{ getReserveNum(scope.row) }}</span>
104
 import { createNamespacedHelpers, mapState } from 'vuex'
104
 import { createNamespacedHelpers, mapState } from 'vuex'
105
 import { Loading } from 'element-ui'
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
 export default {
109
 export default {
110
   name: 'bookList',
110
   name: 'bookList',
111
   data() {
111
   data() {
112
     return {
112
     return {
113
-      caseId: '',
114
-      bookBarcode: '',
115
-      bookName: '',
113
+      formData: {
114
+        caseId: '',
115
+        bookBarcode: '',
116
+        bookName: '',
117
+      },
116
       inputRef: window.document.createElement('input'),
118
       inputRef: window.document.createElement('input'),
117
       showDialog: false,
119
       showDialog: false,
118
     }
120
     }
128
       page: s => s.page,
130
       page: s => s.page,
129
       pagenum: s => s.pagenum,
131
       pagenum: s => s.pagenum,
130
       types: s => s.type.list
132
       types: s => s.type.list
131
-    })
133
+    }),
134
+    caseId: {
135
+      get() {
136
+        return this.formData.caseId || this.defaultCase
137
+      },
138
+      set(nv) {
139
+        this.formData.caseId = nv
140
+      }
141
+    },
132
   },
142
   },
133
   created() {
143
   created() {
134
     this.inputRef.type = 'file'
144
     this.inputRef.type = 'file'
136
     this.inputRef.accept = 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
146
     this.inputRef.accept = 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
137
     this.inputRef.addEventListener('change', this.importBatch.bind(this))
147
     this.inputRef.addEventListener('change', this.importBatch.bind(this))
138
 
148
 
139
-    this.filterList()
149
+    // this.filterList()
150
+  },
151
+  beforeRouteLeave (to, from, next) {
152
+    this.resetStore('list')
153
+    next()
140
   },
154
   },
141
   methods: {
155
   methods: {
156
+    ...mapMutations({
157
+      resetStore: 'clearData',
158
+    }),
142
     ...mapActions({
159
     ...mapActions({
143
       getList: 'getBookList',
160
       getList: 'getBookList',
144
       getTypeList: 'getTypeList',
161
       getTypeList: 'getTypeList',
164
       this.getList({
181
       this.getList({
165
         page,
182
         page,
166
         caseid: caseId,
183
         caseid: caseId,
167
-        barcode: this.bookBarcode,
168
-        name: this.bookName
184
+        barcode: this.formData.bookBarcode,
185
+        name: this.formData.bookName
169
       }).catch(err => {
186
       }).catch(err => {
170
         this.$message({
187
         this.$message({
171
           showClose: true,
188
           showClose: true,
217
     // 设为/取消推荐
234
     // 设为/取消推荐
218
     setRecommend(book) {
235
     setRecommend(book) {
219
       const tipMsg = book.IsRecommend === 1 ? '确定取消推荐?' : '确认设置为推荐?'
236
       const tipMsg = book.IsRecommend === 1 ? '确定取消推荐?' : '确认设置为推荐?'
220
-      book.IsRecommend = Math.abs(book.IsRecommend - 1)
221
 
237
 
222
       this.$confirm(tipMsg, '提示', {
238
       this.$confirm(tipMsg, '提示', {
223
         confirmButtonText: '是',
239
         confirmButtonText: '是',
225
         type: 'warning'
241
         type: 'warning'
226
       })
242
       })
227
         .then(() => {
243
         .then(() => {
244
+          book.IsRecommend = Math.abs(book.IsRecommend - 1)
228
           this.setBookRecommend(book)
245
           this.setBookRecommend(book)
229
             .then(() => {
246
             .then(() => {
230
               this.$message({
247
               this.$message({

+ 7
- 8
src/pages/system/library/books/types/detail.vue Zobrazit soubor

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

+ 28
- 8
src/pages/system/library/books/types/list.vue Zobrazit soubor

23
         <el-table :data="list" border style="width: 100%">
23
         <el-table :data="list" border style="width: 100%">
24
           <el-table-column label="图片" width="128">
24
           <el-table-column label="图片" width="128">
25
             <template slot-scope="scope">
25
             <template slot-scope="scope">
26
-              <img width="64" :src="scope.row.BookTypeImg" alt>
26
+              <img width="64" :src="scope.row.BookTypeImg + '?x-oss-process=style/compress-rotate'" alt>
27
             </template>
27
             </template>
28
           </el-table-column>
28
           </el-table-column>
29
           <el-table-column prop="BookTypeName" label="名称"></el-table-column>
29
           <el-table-column prop="BookTypeName" label="名称"></el-table-column>
56
 
56
 
57
 const {
57
 const {
58
   mapState: mapLibSate,
58
   mapState: mapLibSate,
59
-  mapActions
59
+  mapActions,
60
+  mapMutations,
60
 } = createNamespacedHelpers('library')
61
 } = createNamespacedHelpers('library')
61
 
62
 
62
 export default {
63
 export default {
63
   name: 'bookTypeList',
64
   name: 'bookTypeList',
64
   data() {
65
   data() {
65
     return {
66
     return {
66
-      caseId: ''
67
+      formData: { caseid: '' },
67
     }
68
     }
68
   },
69
   },
69
   computed: {
70
   computed: {
76
       list: s => s.type.list,
77
       list: s => s.type.list,
77
       page: s => s.type.page,
78
       page: s => s.type.page,
78
       pagenum: s => s.type.pagenum,
79
       pagenum: s => s.type.pagenum,
79
-    })
80
+    }),
81
+    caseId: {
82
+      get() {
83
+        return this.formData.caseid || this.defaultCase
84
+      },
85
+      set(nv) {
86
+        this.formData.caseid = nv
87
+      },
88
+    }
80
   },
89
   },
81
-  created() {
82
-    this.filterList()
90
+  beforeRouteLeave (to, from, next) {
91
+    this.resetStore('type.list')
92
+    next()
83
   },
93
   },
84
   methods: {
94
   methods: {
95
+    ...mapMutations({
96
+      resetStore: 'clearData',
97
+    }),
85
     ...mapActions({
98
     ...mapActions({
86
       getList: 'getTypeList',
99
       getList: 'getTypeList',
87
       deleteType: 'deleteType',
100
       deleteType: 'deleteType',
88
     }),
101
     }),
89
 
102
 
90
     filterList({ page = 0 } = {}) {
103
     filterList({ page = 0 } = {}) {
91
-      const caseId = this.caseId || this.defaultCase
92
-      if (!caseId) return
104
+      const caseId = this.formData.caseId || this.defaultCase
105
+      if (!caseId) {
106
+        this.$message({
107
+          showClose: true,
108
+          message: '请选择案场',
109
+          type: 'error'
110
+        })
111
+        return
112
+      }
93
 
113
 
94
       this.getList({
114
       this.getList({
95
         page,
115
         page,

+ 10
- 3
src/pages/system/library/borrow/appointmentList.vue Zobrazit soubor

37
         <el-table-column label="案场">
37
         <el-table-column label="案场">
38
           <template slot-scope="scope">{{returnCaseName(scope.row.CaseId)}}</template>
38
           <template slot-scope="scope">{{returnCaseName(scope.row.CaseId)}}</template>
39
         </el-table-column>
39
         </el-table-column>
40
-        <el-table-column label="图片" width="300">
40
+        <el-table-column label="图片" width="128">
41
           <template slot-scope="scope">
41
           <template slot-scope="scope">
42
-            <img :src="scope.row.BookImg" style="height: 150px;">
42
+            <img :src="scope.row.BookImg + '?x-oss-process=style/compress-rotate'" style="height: 64px;">
43
           </template>
43
           </template>
44
         </el-table-column>
44
         </el-table-column>
45
         <el-table-column prop="BookBarcode" label="条形码"></el-table-column>
45
         <el-table-column prop="BookBarcode" label="条形码"></el-table-column>
71
 
71
 
72
 <script>
72
 <script>
73
 import { createNamespacedHelpers, mapState } from 'vuex'
73
 import { createNamespacedHelpers, mapState } from 'vuex'
74
-const { mapState: mapLibSate, mapActions: mapLibActions } = createNamespacedHelpers('library')
74
+const { mapState: mapLibSate, mapActions: mapLibActions, mapMutations } = createNamespacedHelpers('library')
75
 export default {
75
 export default {
76
   name: 'borrowList',
76
   name: 'borrowList',
77
   data () {
77
   data () {
99
       this.total = res.pagenum
99
       this.total = res.pagenum
100
     })
100
     })
101
   },
101
   },
102
+  beforeRouteLeave (to, from, next) {
103
+    this.resetStore('borrow.list')
104
+    next()
105
+  },
102
   computed: {
106
   computed: {
103
     ...mapState({
107
     ...mapState({
104
       cases: x => x.app.cases.list,
108
       cases: x => x.app.cases.list,
118
     }
122
     }
119
   },
123
   },
120
   methods: {
124
   methods: {
125
+    ...mapMutations({
126
+      resetStore: 'clearData',
127
+    }),
121
     ...mapLibActions(['getBorrowList', 'cancelBorrow']),
128
     ...mapLibActions(['getBorrowList', 'cancelBorrow']),
122
     cancel (id) {
129
     cancel (id) {
123
       this.$confirm('确认取消预约?', '提示', {
130
       this.$confirm('确认取消预约?', '提示', {

+ 14
- 9
src/pages/system/library/borrow/borrow.vue Zobrazit soubor

36
       <!-- 过滤条件 -->
36
       <!-- 过滤条件 -->
37
       <el-form inline>
37
       <el-form inline>
38
         <el-form-item label="案场">
38
         <el-form-item label="案场">
39
-          <el-select v-model="formData.caseid" size="medium" placeholder="请选择案场">
39
+          <el-select v-model="caseId" size="medium" placeholder="请选择案场">
40
             <el-option
40
             <el-option
41
               v-for="item in cases"
41
               v-for="item in cases"
42
               :key="item.CaseId"
42
               :key="item.CaseId"
105
       list: s => s.list,
105
       list: s => s.list,
106
       borrowHistory: s => s.borrow.history,
106
       borrowHistory: s => s.borrow.history,
107
     }),
107
     }),
108
-  },
109
-  watch: {
110
-    defaultCase(nv) {
111
-      if (!this.formData.caseid) {
112
-        this.formData.caseid = nv
113
-      }
114
-    }
108
+    caseId: {
109
+      get() {
110
+        return this.formData.caseid || this.defaultCase
111
+      },
112
+      set(val) {
113
+        this.formData.caseid = val
114
+      },
115
+    },
115
   },
116
   },
116
   methods: {
117
   methods: {
117
     ...mapActions({
118
     ...mapActions({
143
 
144
 
144
     search() {
145
     search() {
145
       // 必须选案场
146
       // 必须选案场
146
-      if (!this.formData.caseid) {
147
+      if (!this.formData.caseid && !this.defaultCase) {
147
         this.$message({
148
         this.$message({
148
           showClose: true,
149
           showClose: true,
149
           message: '请选择案场',
150
           message: '请选择案场',
153
         return
154
         return
154
       }
155
       }
155
 
156
 
157
+      if (!this.formData.caseid) {
158
+        this.formData.caseid = this.defaultCase
159
+      }
160
+
156
       // 先扫码或者输入图书名称
161
       // 先扫码或者输入图书名称
157
       if (!this.formData.barcode && !this.formData.name) {
162
       if (!this.formData.barcode && !this.formData.name) {
158
         this.$message({
163
         this.$message({

+ 10
- 3
src/pages/system/library/borrow/borrowList.vue Zobrazit soubor

47
         <el-table-column label="案场">
47
         <el-table-column label="案场">
48
           <template slot-scope="scope">{{returnCaseName(scope.row.CaseId)}}</template>
48
           <template slot-scope="scope">{{returnCaseName(scope.row.CaseId)}}</template>
49
         </el-table-column>
49
         </el-table-column>
50
-        <el-table-column label="图片" width="300">
50
+        <el-table-column label="图片" width="128">
51
           <template slot-scope="scope">
51
           <template slot-scope="scope">
52
-            <img :src="scope.row.BookImg" style="height: 150px;">
52
+            <img :src="scope.row.BookImg + '?x-oss-process=style/compress-rotate'" style="height: 64px;">
53
           </template>
53
           </template>
54
         </el-table-column>
54
         </el-table-column>
55
         <el-table-column prop="BookBarcode" label="条形码"></el-table-column>
55
         <el-table-column prop="BookBarcode" label="条形码"></el-table-column>
82
 
82
 
83
 <script>
83
 <script>
84
 import { createNamespacedHelpers, mapState } from 'vuex'
84
 import { createNamespacedHelpers, mapState } from 'vuex'
85
-const { mapState: mapLibSate, mapActions: mapLibActions } = createNamespacedHelpers('library')
85
+const { mapState: mapLibSate, mapActions: mapLibActions, mapMutations } = createNamespacedHelpers('library')
86
 export default {
86
 export default {
87
   name: 'borrowList',
87
   name: 'borrowList',
88
   data () {
88
   data () {
140
       }
140
       }
141
     }
141
     }
142
   },
142
   },
143
+  beforeRouteLeave (to, from, next) {
144
+    this.resetStore('borrow.list')
145
+    next()
146
+  },
143
   methods: {
147
   methods: {
148
+    ...mapMutations({
149
+      resetStore: 'clearData',
150
+    }),
144
     ...mapLibActions(['getBorrowList']),
151
     ...mapLibActions(['getBorrowList']),
145
     search () {
152
     search () {
146
       this.page = 1
153
       this.page = 1

+ 22
- 0
src/store/library/index.js Zobrazit soubor

30
     },
30
     },
31
   },
31
   },
32
   mutations: {
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
     mergeTypeDetail (state, payload) {
55
     mergeTypeDetail (state, payload) {
34
       state.type.detail = payload || {}
56
       state.type.detail = payload || {}
35
 
57