feat(finances/invoice): send logisticsCompanyName, sync logisticsCompanyName to formItem
Showing
1 changed file
with
21 additions
and
5 deletions
@@ -118,12 +118,29 @@ export default { | @@ -118,12 +118,29 @@ export default { | ||
118 | created() { | 118 | created() { |
119 | this.invoiceAPI = new InvoiceService(); | 119 | this.invoiceAPI = new InvoiceService(); |
120 | this.tradeAPI = new TradeService(); | 120 | this.tradeAPI = new TradeService(); |
121 | - if (this.expressList.length === 0) { | ||
122 | this.tradeAPI.allotExpressCompList().then(data => { | 121 | this.tradeAPI.allotExpressCompList().then(data => { |
123 | this.expressList = data; | 122 | this.expressList = data; |
124 | - }); | 123 | + // create expressId2Name map |
124 | + const ExpressId2Name = data.reduce((acc, item) => { | ||
125 | + acc[item.id] = item.companyName; | ||
126 | + return acc; | ||
127 | + }, {}); | ||
128 | + | ||
129 | + this.$watch( | ||
130 | + 'formItem.logisticsId', | ||
131 | + newVal => { | ||
132 | + if (newVal === '' || newVal == null) { | ||
133 | + this.formItem.logisticsCompanyName = ''; | ||
134 | + } else { | ||
135 | + this.formItem.logisticsCompanyName = ExpressId2Name[newVal] || ''; | ||
125 | } | 136 | } |
126 | }, | 137 | }, |
138 | + { | ||
139 | + immediate: true, | ||
140 | + } | ||
141 | + ); | ||
142 | + }); | ||
143 | + }, | ||
127 | methods: { | 144 | methods: { |
128 | setTitle(invoice) { | 145 | setTitle(invoice) { |
129 | if (invoice.status === InvoiceStatusName2Id.UNOPEN) { | 146 | if (invoice.status === InvoiceStatusName2Id.UNOPEN) { |
@@ -141,6 +158,7 @@ export default { | @@ -141,6 +158,7 @@ export default { | ||
141 | pdfUrl: null, | 158 | pdfUrl: null, |
142 | logisticsId: null, | 159 | logisticsId: null, |
143 | expressNumber: null, | 160 | expressNumber: null, |
161 | + logisticsCompanyName: null, | ||
144 | logisticsSwitch: this.LOGISTICS_YES, | 162 | logisticsSwitch: this.LOGISTICS_YES, |
145 | ...invoice, | 163 | ...invoice, |
146 | }; | 164 | }; |
@@ -241,12 +259,11 @@ export default { | @@ -241,12 +259,11 @@ export default { | ||
241 | 'pdfUrl', | 259 | 'pdfUrl', |
242 | 'type', | 260 | 'type', |
243 | 'logisticsId', | 261 | 'logisticsId', |
244 | - // logisticsCompanyName | 262 | + 'logisticsCompanyName', |
245 | 'expressNumber', | 263 | 'expressNumber', |
246 | 'logisticsSwitch', | 264 | 'logisticsSwitch', |
247 | ]); | 265 | ]); |
248 | 266 | ||
249 | - // clean data? | ||
250 | if (!this.updateState(params)) { | 267 | if (!this.updateState(params)) { |
251 | this.close(); | 268 | this.close(); |
252 | return; | 269 | return; |
@@ -277,7 +294,6 @@ export default { | @@ -277,7 +294,6 @@ export default { | ||
277 | }, | 294 | }, |
278 | }; | 295 | }; |
279 | </script> | 296 | </script> |
280 | - | ||
281 | <style lang="scss" scoped> | 297 | <style lang="scss" scoped> |
282 | .modal-footer { | 298 | .modal-footer { |
283 | & > span { | 299 | & > span { |
-
Please register or login to post a comment