@@ -143,6 +143,48 @@ <h4>預算表資訊</h4>
143
143
</ tbody >
144
144
</ table >
145
145
</ div >
146
+ < div class ="content ">
147
+ < h4 > 已申請的單據</ h4 >
148
+ </ div >
149
+ < div class ="content ">
150
+ < div class ="field " v-for ="invoice, index in has_sent_invoices ">
151
+ < div class ="field-body ">
152
+ < div class ="field ">
153
+ < label class ="label "> [[ index+1 ]]. 發票號碼或收據</ label >
154
+ < div class ="control ">
155
+ < input class ="input " type ="text " v-model ="invoice.name " disabled >
156
+ </ div >
157
+ </ div >
158
+ < div class ="field ">
159
+ < label class ="label "> 單據金額</ label >
160
+ < div class ="field has-addons ">
161
+ < div class ="control ">
162
+ < span class ="select ">
163
+ < select v-model ="invoice.currency " disabled >
164
+ < option > TWD</ option >
165
+ < option > USD</ option >
166
+ </ select >
167
+ </ span >
168
+ </ div >
169
+ < div class ="control ">
170
+ < input class ="input " type ="number " step ="0.01 " v-model.number ="invoice.total " disabled >
171
+ </ div >
172
+ </ div >
173
+ </ div >
174
+ < div class ="field ">
175
+ < label class ="label "> 單據狀況</ label >
176
+ < div class ="control ">
177
+ < span class ="select ">
178
+ < select v-model ="invoice.status " disabled >
179
+ < option value ="sent "> 已寄出</ option >
180
+ < option value ="not_send "> 還未寄出</ option >
181
+ </ select >
182
+ </ span >
183
+ </ div >
184
+ </ div >
185
+ </ div >
186
+ </ div >
187
+ </ div >
146
188
< form @submit.prevent ="submit_expense ">
147
189
< div class ="content ">
148
190
< h4 > 檢附單據</ h4 >
@@ -199,15 +241,47 @@ <h4>檢附單據</h4>
199
241
</ a >
200
242
</ div >
201
243
< div class ="content " v-if ="invoices.length > 0 ">
202
- < h4 class ="mt-5 "> 申請金額 </ h4 >
244
+ < h4 class ="mt-5 "> 申請金額試算 </ h4 >
203
245
</ div >
204
- < div class ="field " v-if ="invoices.length > 0 ">
205
- < label class ="label "> 合計</ label >
206
- < div class ="field is-grouped is-grouped-multiline ">
207
- < div class ="control " v-for ="[currency, total] in Object.entries(invoices_total) ">
208
- < div class ="tags has-addons ">
209
- < span class ="tag is-info "> [[ currency ]]</ span >
210
- < span class ="tag is-success is-light "> $[[ total.toLocaleString('en') ]]</ span >
246
+ < div class ="field ">
247
+ < div class ="field-body ">
248
+ < div class ="field has-background-link-light p-3 " v-if ="invoices.length > 0 ">
249
+ < label class ="label "> 此次申請合計</ label >
250
+ < div class ="field is-grouped is-grouped-multiline ">
251
+ < div class ="control " v-for ="[currency, total] in Object.entries(invoices_total) ">
252
+ < div class ="tags has-addons ">
253
+ < span class ="tag is-info "> [[ currency ]]</ span >
254
+ < span class ="tag is-success is-light " :class ="{'is-danger': total < 0} ">
255
+ $[[ total.toLocaleString('en') ]]
256
+ </ span >
257
+ </ div >
258
+ </ div >
259
+ </ div >
260
+ </ div >
261
+ < div class ="field has-background-warning-light p-3 " v-if ="has_sent_invoices.length > 0 ">
262
+ < label class ="label "> 已申請合計</ label >
263
+ < div class ="field is-grouped is-grouped-multiline ">
264
+ < div class ="control " v-for ="[currency, total] in Object.entries(has_sent_invoices_total) ">
265
+ < div class ="tags has-addons ">
266
+ < span class ="tag is-info "> [[ currency ]]</ span >
267
+ < span class ="tag is-success is-light " :class ="{'is-danger': total < 0} ">
268
+ $[[ total.toLocaleString('en') ]]
269
+ </ span >
270
+ </ div >
271
+ </ div >
272
+ </ div >
273
+ </ div >
274
+ < div class ="field has-background-info-light p-3 " v-if ="has_sent_invoices.length > 0 ">
275
+ < label class ="label "> 預算餘額計算</ label >
276
+ < div class ="field is-grouped is-grouped-multiline ">
277
+ < div class ="control " v-for ="[currency, total] in Object.entries(diff_invoices_total) ">
278
+ < div class ="tags has-addons ">
279
+ < span class ="tag is-info "> [[ currency ]]</ span >
280
+ < span class ="tag is-success is-light " :class ="{'is-danger': total < 0} ">
281
+ $[[ total.toLocaleString('en') ]]
282
+ </ span >
283
+ </ div >
284
+ </ div >
211
285
</ div >
212
286
</ div >
213
287
</ div >
@@ -299,6 +373,9 @@ <h4 class="mt-5">設定撥款資訊</h4>
299
373
default_invoice : { name : '' , currency : 'TWD' , total : 0 , status : '' } ,
300
374
invoices : [ ] ,
301
375
invoices_total : { } ,
376
+ has_sent_invoices : [ ] ,
377
+ has_sent_invoices_total : { } ,
378
+ diff_invoices_total : { } ,
302
379
bank : { } ,
303
380
bank_alert : 0 ,
304
381
teams : [ ] ,
@@ -345,6 +422,38 @@ <h4 class="mt-5">設定撥款資訊</h4>
345
422
}
346
423
$expenselists . invoices_total [ raw . currency ] += raw . total ;
347
424
} ) ;
425
+ this . cal_invoices_total ( ) ;
426
+ } ,
427
+ sum_has_sent_invoices : function ( ) {
428
+ this . has_sent_invoices_total = { } ;
429
+ $this = this ;
430
+ this . has_sent_invoices . forEach ( function ( raw ) {
431
+ if ( $this . has_sent_invoices_total [ raw . currency ] === undefined ) {
432
+ $this . has_sent_invoices_total [ raw . currency ] = 0 ;
433
+ }
434
+ $this . has_sent_invoices_total [ raw . currency ] += raw . total ;
435
+ } ) ;
436
+ } ,
437
+ cal_invoices_total : function ( ) {
438
+ let base = { } ;
439
+ base [ this . modaldata . currency ] = this . modaldata . total ;
440
+ let diff_total = Object . assign ( { } , base ) ;
441
+
442
+ Object . entries ( this . has_sent_invoices_total ) . forEach ( function ( raw ) {
443
+ if ( diff_total [ raw [ 0 ] ] === undefined ) {
444
+ diff_total [ raw [ 0 ] ] = 0 ;
445
+ }
446
+ diff_total [ raw [ 0 ] ] -= raw [ 1 ] ;
447
+ } ) ;
448
+
449
+ Object . entries ( this . invoices_total ) . forEach ( function ( raw ) {
450
+ if ( diff_total [ raw [ 0 ] ] === undefined ) {
451
+ diff_total [ raw [ 0 ] ] = 0 ;
452
+ }
453
+ diff_total [ raw [ 0 ] ] -= raw [ 1 ] ;
454
+ } ) ;
455
+
456
+ this . diff_invoices_total = Object . assign ( { } , diff_total ) ;
348
457
} ,
349
458
load : function ( ) {
350
459
++ this . is_loading ;
@@ -365,8 +474,26 @@ <h4 class="mt-5">設定撥款資訊</h4>
365
474
} ) ;
366
475
} ,
367
476
create : function ( item ) {
477
+ ++ this . is_loading ;
368
478
this . modaldata = Object . assign ( { } , item ) ;
369
479
this . create_expense ( ) ;
480
+ if ( this . invoices . length == 0 ) {
481
+ this . add_invoice ( ) ;
482
+ }
483
+ this . has_sent_invoices = [ ] ;
484
+ $this = this ;
485
+ axios . post ( './' , { casename : 'get_has_sent' , buid : this . modaldata . _id } ) . then ( function ( resp ) {
486
+ console . info ( resp . data . data ) ;
487
+ resp . data . data . forEach ( function ( raw ) {
488
+ raw . invoices . forEach ( function ( invoice ) {
489
+ invoice [ 'expense_id' ] = raw . _id ;
490
+ $this . has_sent_invoices . push ( invoice ) ;
491
+ } ) ;
492
+ } ) ;
493
+ $this . sum_has_sent_invoices ( ) ;
494
+ $this . cal_invoices_total ( ) ;
495
+ -- $this . is_loading ;
496
+ } ) ;
370
497
} ,
371
498
submit_expense : function ( ) {
372
499
++ this . modaldata . is_loading ;
0 commit comments