wangfei 6 years ago
parent
commit
9f4af56fb9

+ 53
- 9
src/pages/system/newOrder/caseRecord/index.vue View File

3
     <div class="system-table-search">
3
     <div class="system-table-search">
4
       <div class="flex-h">
4
       <div class="flex-h">
5
         <div class="flex-item flex-h">
5
         <div class="flex-item flex-h">
6
-          <el-button size="mini" type="success" @click='addRecord'>新增</el-button>
6
+          <el-button size="mini" type="success" @click='addVisible = true'>新增</el-button>
7
         </div>
7
         </div>
8
         <ul>
8
         <ul>
9
           <li>
9
           <li>
43
         </el-table-column>
43
         </el-table-column>
44
         <el-table-column fixed='right' label="操作" width="300">
44
         <el-table-column fixed='right' label="操作" width="300">
45
           <template slot-scope="scope">
45
           <template slot-scope="scope">
46
-            <el-button size="mini" type="warning" @click="handleReport(scope.$index, scope.row)">导出Excel</el-button>
46
+            <el-button size="mini" type="warning" @click="handleReport(scope.row)">导出Excel</el-button>
47
           </template>
47
           </template>
48
         </el-table-column>
48
         </el-table-column>
49
       </el-table>
49
       </el-table>
113
 import { createNamespacedHelpers, mapState } from 'vuex'
113
 import { createNamespacedHelpers, mapState } from 'vuex'
114
 
114
 
115
 const { mapState: mapRecordState, mapActions: mapRecordActions } = createNamespacedHelpers('caserecord')
115
 const { mapState: mapRecordState, mapActions: mapRecordActions } = createNamespacedHelpers('caserecord')
116
+const { mapState: mapOrdersState, mapActions: mapOrdersActions } = createNamespacedHelpers('goodsorder')
116
 
117
 
117
 export default {
118
 export default {
118
   name: '',
119
   name: '',
119
   data () {
120
   data () {
120
     return {
121
     return {
121
       addVisible: false,
122
       addVisible: false,
123
+      excelData: [],
122
       detail: {
124
       detail: {
123
         CaseId: '',
125
         CaseId: '',
126
+        Month: '',
127
+        Num: 0,
124
       },
128
       },
125
       postData: {
129
       postData: {
126
         caseid: '',
130
         caseid: '',
137
     ...mapRecordState({
141
     ...mapRecordState({
138
       records: x => x.recordList,
142
       records: x => x.recordList,
139
     }),
143
     }),
144
+    ...mapOrdersState({
145
+      orders: x => x.recordOrders,
146
+    }),
140
     CaseId: {
147
     CaseId: {
141
       get () {
148
       get () {
142
-        return this.caseid || this.defaultCaseId
149
+        return this.postData.caseid || this.defaultCaseId
143
       },
150
       },
144
       set (val) {
151
       set (val) {
145
-        this.caseid = val
152
+        this.postData.caseid = val
146
       }
153
       }
147
-    }
154
+    },
148
   },
155
   },
149
   methods: {
156
   methods: {
150
     ...mapRecordActions([
157
     ...mapRecordActions([
151
       'GetRecordList',
158
       'GetRecordList',
159
+      'AddRecord',
160
+    ]),
161
+    ...mapOrdersActions([
162
+      'GetOrdersByRecord',
152
     ]),
163
     ]),
153
     getCaseName (caseid) {
164
     getCaseName (caseid) {
154
       return ((this.cases.filter(x => x.CaseId === caseid) || [])[0] || {}).CaseName
165
       return ((this.cases.filter(x => x.CaseId === caseid) || [])[0] || {}).CaseName
155
     },
166
     },
156
-    addRecord () {
157
-      this.addVisible = true
158
-    },
159
     search () {
167
     search () {
160
       this.getList()
168
       this.getList()
161
     },
169
     },
162
     submit () {
170
     submit () {
171
+      if (this.detail.CaseId === '') {
172
+        this.$message({
173
+          type: 'error',
174
+          message: '请先选择对应案场!'
175
+        })
176
+        return
177
+      }
178
+      if (this.detail.Month === '') {
179
+        this.$message({
180
+          type: 'error',
181
+          message: '请先选择月份!'
182
+        })
183
+        return
184
+      }
185
+      if (this.detail.Num <= 0) {
186
+        this.$message({
187
+          type: 'error',
188
+          message: '请输入规定次数!'
189
+        })
190
+        return
191
+      }
192
+      this.AddRecord({...this.detail, callback: this.afterSave, Month: this.toolClass.dateFormat(this.detail.Month, 'yyyy-MM')})
193
+    },
194
+    afterSave () {
195
+      this.$message({
196
+        type: 'success',
197
+        message: '保存成功!'
198
+      })
199
+      this.addVisible = false
200
+      this.getList()
163
     },
201
     },
164
     getList () {
202
     getList () {
165
-      this.GetRecordList(this.postData)
203
+      this.GetRecordList({...this.postData, caseid: this.CaseId})
166
     },
204
     },
167
     handleCurrentChange (val) { // 跳转到分页
205
     handleCurrentChange (val) { // 跳转到分页
168
       this.postData.page = val
206
       this.postData.page = val
169
       this.getList()
207
       this.getList()
170
     },
208
     },
209
+    handleReport (row) {
210
+      this.GetOrdersByRecord({id: row.RecordId, callback: this.ordersExport})
211
+    },
212
+  },
213
+  mounted () {
214
+    this.getList()
171
   }
215
   }
172
 }
216
 }
173
 </script>
217
 </script>

+ 14
- 2
src/store/case/record.js View File

13
   },
13
   },
14
   actions: {
14
   actions: {
15
     GetRecordList ({ commit }, payload) {
15
     GetRecordList ({ commit }, payload) {
16
-      ajax(api.case.getRecordList.url, {
17
-        method: api.case.getRecordList.method,
16
+      ajax(api.caseManager.getRecordList.url, {
17
+        method: api.caseManager.getRecordList.method,
18
         queryData: {
18
         queryData: {
19
           ...payload,
19
           ...payload,
20
         }
20
         }
25
         }
25
         }
26
       })
26
       })
27
     },
27
     },
28
+    AddRecord ({ commit }, payload) {
29
+      ajax(api.caseManager.addRecord.url, {
30
+        method: api.caseManager.addRecord.method,
31
+        data: {
32
+          ...payload,
33
+        }
34
+      }).then(res => {
35
+        if (payload.callback) {
36
+          payload.callback()
37
+        }
38
+      })
39
+    },
28
   }
40
   }
29
 }
41
 }

+ 17
- 0
src/store/goods/order.js View File

5
   namespaced: true,
5
   namespaced: true,
6
   state: {
6
   state: {
7
     ordersList: [],
7
     ordersList: [],
8
+    recordOrders: [],
8
   },
9
   },
9
   mutations: {
10
   mutations: {
10
     updateList (state, payload) {
11
     updateList (state, payload) {
11
       state.ordersList = payload || []
12
       state.ordersList = payload || []
12
     },
13
     },
14
+    updateRecordList (state, payload) {
15
+      state.recordOrders = payload || []
16
+    },
13
   },
17
   },
14
   actions: {
18
   actions: {
15
     GetOrdersList ({ commit }, payload) {
19
     GetOrdersList ({ commit }, payload) {
22
         commit('updateList', res)
26
         commit('updateList', res)
23
       })
27
       })
24
     },
28
     },
29
+    GetOrdersByRecord ({ commit }, { id, callback }) {
30
+      ajax(api.goodsOrder.getOrdersByRecord.url, {
31
+        method: api.goodsOrder.getOrdersByRecord.method,
32
+        urlData: {
33
+          id
34
+        }
35
+      }).then(res => {
36
+        commit('updateRecordList', res)
37
+        if (callback) {
38
+          callback()
39
+        }
40
+      })
41
+    }
25
   }
42
   }
26
 }
43
 }

+ 4
- 0
src/util/api.js View File

538
       method: 'get',
538
       method: 'get',
539
       url: `${baseUrl}${common}/order/online/goods`
539
       url: `${baseUrl}${common}/order/online/goods`
540
     },
540
     },
541
+    getOrdersByRecord: {
542
+      method: 'get',
543
+      url: `${baseUrl}${common}/order/goods/record/:id`
544
+    },
541
   },
545
   },
542
 }
546
 }
543
 export default $api
547
 export default $api