mg-ocr-invoice 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,565 +1,564 @@
1
- <template>
2
- <div class="Invoice">
3
- <div class="top">
4
- <img
5
- :src="props.invoiceData.attachmentLink"
6
- @click.stop="openPreViewImg"
7
- alt="" />
8
- </div>
9
- <div>
10
- <Form label-width="70px">
11
- <CellGroup inset>
12
- <template #title>
13
- <div class="Field-title">
14
- <span class="titleLeft">公司信息</span>
15
- <!-- <span class="titleright">重新查验</span> -->
16
- </div>
17
- </template>
18
- <div class="marPX">
19
- <Field
20
- autocomplete="off"
21
- label="销售方"
22
- placeholder="请输入销售方"
23
- v-model="formData.sellerReq.sellerName">
24
- <template #right-icon>
25
- <div @click="expandObj.showSeller = !expandObj.showSeller">
26
- <Icon
27
- name="arrow-down"
28
- v-if="!expandObj.showSeller"
29
- color="#969799" />
30
- <Icon v-else name="arrow-up" color="#969799" />
31
- </div>
32
- </template>
33
- </Field>
34
- <div v-show="expandObj.showSeller">
35
- <Field
36
- autocomplete="off"
37
- label="纳税人识别号"
38
- placeholder="请输入纳税人识别号"
39
- v-model="formData.sellerReq.sellerId" />
40
- <Field
41
- autocomplete="off"
42
- label="地址/电话"
43
- autosize
44
- type="textarea"
45
- placeholder="请输入地址+电话"
46
- v-model="formData.sellerReq.sellerContact" />
47
- <!-- <Field
48
- autocomplete="off"
49
- label="电话"
50
- placeholder="请输入电话"
51
- v-model="formData.sellerReq.sellerName" /> -->
52
- <Field
53
- autocomplete="off"
54
- autosize
55
- type="textarea"
56
- label="开户银行/银行账号"
57
- placeholder="请输入开户银行+银行账户"
58
- v-model="formData.sellerReq.sellerAccount" />
59
- <!-- <Field
60
- autocomplete="off"
61
- label="银行账号"
62
- placeholder="请输入银行账号"
63
- v-model="formData.sellerReq.sellerName" /> -->
64
- </div>
65
- </div>
66
- <div class="marPX">
67
- <Field
68
- autocomplete="off"
69
- label="购买方"
70
- placeholder="请输入购买方名称"
71
- v-model="formData.payerReq.payerName">
72
- <template #right-icon>
73
- <div
74
- @click="expandObj.showPurchaser = !expandObj.showPurchaser">
75
- <Icon
76
- name="arrow-down"
77
- v-if="!expandObj.showPurchaser"
78
- color="#969799" />
79
- <Icon v-else name="arrow-up" color="#969799" />
80
- </div>
81
- </template>
82
- </Field>
83
- <div v-show="expandObj.showPurchaser">
84
- <Field
85
- autocomplete="off"
86
- label="纳税人识别号"
87
- placeholder="请输入纳税人识别号"
88
- v-model="formData.payerReq.payerId" />
89
- <Field
90
- autocomplete="off"
91
- label="地址/电话"
92
- type="textarea"
93
- placeholder="请输入地址+电话"
94
- v-model="formData.payerReq.payerContact" />
95
- <!-- <Field
96
- autocomplete="off"
97
- label="电话"
98
- placeholder="请输入电话"
99
- v-model="formData.payerReq.sellerName" /> -->
100
- <Field
101
- autocomplete="off"
102
- autosize
103
- type="textarea"
104
- label="开户银行/银行账号"
105
- placeholder="请输入开户银行+银行账户"
106
- v-model="formData.payerReq.payerAccount" />
107
- <!-- <Field
108
- autocomplete="off"
109
- label="银行账号"
110
- placeholder="请输入银行账号"
111
- v-model="formData.payerReq.sellerName" /> -->
112
- </div>
113
- </div>
114
- <div class="marPX">
115
- <Field
116
- autocomplete="off"
117
- readonly
118
- label="发票类型"
119
- :model-value="props.invoiceData.description" />
120
- </div>
121
- <div class="marPX">
122
- <Cell title="价税合计" :value="computed_amount">
123
- <template #value>
124
- <div
125
- style="
126
- color: #333;
127
- font-weight: 400;
128
- font-size: 16px;
129
- margin-right: 12px;
130
- ">
131
- {{ computed_amount }}
132
- </div>
133
- </template>
134
- <template #right-icon>
135
- <div @click="expandObj.showPrice = !expandObj.showPrice">
136
- <Icon
137
- name="arrow-down"
138
- v-if="!expandObj.showPrice"
139
- color="#969799" />
140
- <Icon v-else name="arrow-up" color="#969799" />
141
- </div>
142
- </template>
143
- </Cell>
144
- <div v-show="!expandObj.showPrice">
145
- <Field>
146
- <template #input>
147
- <table>
148
- <thead>
149
- <tr>
150
- <th>商品金额(不含税)</th>
151
- <th>税率</th>
152
- <th>税额</th>
153
- </tr>
154
- </thead>
155
- <tbody>
156
- <tr
157
- v-for="(item, index) in formData.itemAmountReqs"
158
- @click="openEditpopUp(item, index)">
159
- <td>{{ item.itemExTaxAmount }}</td>
160
- <td>{{ item.itemTaxRate }}</td>
161
- <td>
162
- {{
163
- computedTaxAmount(
164
- item.itemExTaxAmount,
165
- item.itemTaxRate
166
- )
167
- }}
168
- </td>
169
- </tr>
170
- </tbody>
171
- </table>
172
- </template>
173
- </Field>
174
- </div>
175
- </div>
176
- <div class="marPX">
177
- <Field
178
- autocomplete="off"
179
- label="发票代码"
180
- placeholder="请输入发票代码"
181
- v-model="formData.codeReq.invoiceCode">
182
- <template #right-icon>
183
- <div @click="expandObj.invoiceCode = !expandObj.invoiceCode">
184
- <Icon
185
- name="arrow-down"
186
- v-if="!expandObj.invoiceCode"
187
- color="#969799" />
188
- <Icon v-else name="arrow-up" color="#969799" />
189
- </div>
190
- </template>
191
- </Field>
192
- <div v-show="expandObj.invoiceCode">
193
- <Field
194
- autocomplete="off"
195
- label="发票号码"
196
- placeholder="请输入发票号码"
197
- v-model="formData.codeReq.invoiceNum" />
198
- <Field
199
- autocomplete="off"
200
- label="校验码"
201
- placeholder="请输入校验码"
202
- v-model="formData.codeReq.checkCode" />
203
- </div>
204
- </div>
205
- <div class="marPX">
206
- <Field
207
- autocomplete="off"
208
- label="开票日期"
209
- readonly
210
- v-model="props.invoiceData.invoiceDate" />
211
- </div>
212
- <div class="marPX">
213
- <Field
214
- autocomplete="off"
215
- label="查验状态"
216
- readonly
217
- :model-value="const_realStatus[props.invoiceData.realStatus]" />
218
- </div>
219
- </CellGroup>
220
- <div class="submit">
221
- <span
222
- style="flex: 1; background-color: #07c160; color: #fff"
223
- @click="close">
224
- 返回
225
- </span>
226
- <span v-if="isEdit" @click="submit">保存</span>
227
- </div>
228
- </Form>
229
- </div>
230
- </div>
231
- <ActionSheet v-model:show="showEdit" :title="editTitle(titleIndex)">
232
- <div class="content">
233
- <Form ref="REF_editForm">
234
- <Field
235
- autocomplete="off"
236
- @blur="blurInput($event, 'itemExTaxAmount')"
237
- label="不含税金额"
238
- v-model="activeRow.itemExTaxAmount" />
239
- <Field
240
- autocomplete="off"
241
- label="税率"
242
- @blur="blurInput($event, 'itemTaxRate')"
243
- v-model="activeRow.itemTaxRate">
244
- <template #right-icon>%</template>
245
- </Field>
246
- <Cell title="税额" :value="rateAmount"> </Cell>
247
- </Form>
248
- <div class="btn">
249
- <Button type="primary" @click="confirmEdit">确定</Button>
250
- </div>
251
- </div>
252
- </ActionSheet>
253
- <Overlay
254
- style="
255
- display: flex;
256
- justify-content: center;
257
- align-items: center;
258
- z-index: 999;
259
- "
260
- :show="showLoading">
261
- <Loading class="loading" color="#0094ff">保存中...</Loading>
262
- </Overlay>
263
- </template>
264
- <script setup lang="ts">
265
- import { ref } from 'vue'
266
- import '@/utils/disableZoom'
267
- import { __updateInvoiceData } from '@/api/invoice'
268
- import {
269
- showToast,
270
- Overlay,
271
- Loading,
272
- showFailToast,
273
- showImagePreview,
274
- CellGroup,
275
- Field,
276
- Form,
277
- Icon,
278
- Button,
279
- ActionSheet,
280
- Cell,
281
- } from 'vant'
282
- import { onMounted } from 'vue'
283
- import { const_realStatus } from '../InvoiceList/const'
284
- import { RowAttribute } from './const'
285
- import { filterNumber } from '@/utils/number'
286
- import { computed } from 'vue'
287
- import Decimal from 'decimal.js'
288
- const props = defineProps(['ids', 'invoiceData'])
289
- const formData = ref({
290
- codeReq: {
291
- invoiceCode: '',
292
- invoiceNum: '',
293
- checkCode: '',
294
- },
295
- itemAmountReqs: [
296
- {
297
- detailCode: '',
298
- itemExTaxAmount: 0,
299
- itemTaxRate: 0,
300
- },
301
- ],
302
- payerReq: {
303
- payerAccount: '',
304
- payerContact: '',
305
- payerId: '',
306
- payerName: '',
307
- },
308
- sellerReq: {
309
- sellerAccount: '',
310
- sellerContact: '',
311
- sellerId: '',
312
- sellerName: '',
313
- },
314
- taskId: '',
315
- })
316
- const emit = defineEmits(['saveSuccess'])
317
- document.title = '发票信息'
318
- const expandObj: any = ref({})
319
- const showRequiredMsg = ref(false)
320
- // const modules = ref([Pagination])
321
- const showLoading = ref(false)
322
- const close = () => {
323
- emit('saveSuccess')
324
- }
325
- const openPreViewImg = () => {
326
- showImagePreview([props.invoiceData.attachmentLink])
327
- }
328
- const isEdit = computed(() => {
329
- // true 允许
330
- return (
331
- props.invoiceData.realStatus === 'noNeed' ||
332
- props.invoiceData.invoiceExceptionInfo === 'abnormal' ||
333
- props.invoiceData.manualModify ||
334
- props.invoiceData.realStatus === 'checkFail'||
335
- props.invoiceData.realStatus === 'notCheck'
336
- )
337
- })
338
- const submit = async () => {
339
- showLoading.value = true
340
- try {
341
- const res: any = await __updateInvoiceData(formData.value)
342
- if (res.code === 200) {
343
- showToast({
344
- type: 'success',
345
- message: '保存成功',
346
- })
347
- emit('saveSuccess')
348
- }
349
- } catch (err: any) {
350
- showFailToast(err.msg)
351
- emit('saveSuccess')
352
- }
353
- showLoading.value = false
354
- }
355
- const initData = () => {
356
- console.log(props.invoiceData)
357
- // 销售方数据回显
358
- formData.value.sellerReq.sellerName = props.invoiceData.sellerName
359
- formData.value.sellerReq.sellerAccount = props.invoiceData.sellerAccount
360
- formData.value.sellerReq.sellerContact = props.invoiceData.sellerContact
361
- formData.value.sellerReq.sellerId = props.invoiceData.sellerId
362
- // 购买方数据回显
363
- formData.value.payerReq.payerAccount = props.invoiceData.payerAccount
364
- formData.value.payerReq.payerContact = props.invoiceData.payerContact
365
- formData.value.payerReq.payerName = props.invoiceData.payerName
366
- formData.value.payerReq.payerId = props.invoiceData.payerId
367
- // 发票代码回显
368
- formData.value.codeReq.invoiceCode = props.invoiceData.invoiceCode
369
- formData.value.codeReq.invoiceNum = props.invoiceData.invoiceNum
370
- formData.value.codeReq.checkCode = props.invoiceData.checkCode
371
- formData.value.taskId = props.invoiceData.taskId
372
- // 金额数据回显
373
- formData.value.itemAmountReqs = JSON.parse(
374
- JSON.stringify(props.invoiceData.deatis)
375
- ).map((item: any) => {
376
- return {
377
- detailCode: item.code,
378
- itemExTaxAmount: item.itemExTaxAmount,
379
- itemTaxRate: item.itemTaxRate.replace(/%/g, ''),
380
- }
381
- })
382
- }
383
- const showEdit = ref(false)
384
- const activeRow = ref<RowAttribute | any>({})
385
- const titleIndex = ref<number>(0)
386
- const editTitle = (index: number) => {
387
- return `第${index + 1}行金额`
388
- }
389
- const openEditpopUp = (row: RowAttribute, index: number) => {
390
- activeRow.value = JSON.parse(JSON.stringify(row))
391
- activeRow.value.itemTaxRate = filterNumber(activeRow.value.itemTaxRate)
392
- titleIndex.value = index
393
- showEdit.value = true
394
- }
395
- const confirmEdit = () => {
396
- formData.value.itemAmountReqs[titleIndex.value].detailCode =
397
- activeRow.value.detailCode
398
- formData.value.itemAmountReqs[titleIndex.value].itemExTaxAmount =
399
- activeRow.value.itemExTaxAmount
400
- formData.value.itemAmountReqs[titleIndex.value].itemTaxRate =
401
- activeRow.value.itemTaxRate
402
- showEdit.value = false
403
- }
404
- const blurInput = (e: any, key: any) => {
405
- let value = activeRow.value[key]
406
- activeRow.value[key] = filterNumber(value)
407
- }
408
-
409
- const computed_amount = computed(() => {
410
- let count = new Decimal(0)
411
- formData.value.itemAmountReqs.forEach((item) => {
412
- let tax_amount = new Decimal(filterNumber(item.itemExTaxAmount)).times(
413
- new Decimal(filterNumber(item.itemTaxRate / 100))
414
- ).toFixed(2)
415
- count = count.plus(
416
- new Decimal(filterNumber(item.itemExTaxAmount)).plus(tax_amount)
417
- )
418
- })
419
- return count.toFixed(2)
420
- })
421
- const rateAmount = computed(() => {
422
- return new Decimal(filterNumber(Number(activeRow.value.itemExTaxAmount)))
423
- .times(new Decimal(filterNumber(activeRow.value.itemTaxRate / 100)))
424
- .toFixed(2)
425
- })
426
- const computedTaxAmount = (ExTaxAmount: any, TaxRate: any) => {
427
- let rate: any = TaxRate + ''
428
- return new Decimal(filterNumber(ExTaxAmount))
429
- .times(new Decimal(filterNumber(rate / 100)))
430
- .toFixed(2)
431
- }
432
- onMounted(() => {
433
- initData()
434
- })
435
- </script>
436
-
437
- <style lang="scss" scoped>
438
- .content {
439
- background-color: #f7f8fa;
440
- height: 200px;
441
- :deep(.van-field__value) {
442
- border: 1px solid #2196f3;
443
- border-radius: 4px;
444
- input {
445
- padding-left: 12px;
446
- }
447
- }
448
- .btn {
449
- display: flex;
450
- justify-content: space-between;
451
- gap: 12px;
452
- padding: 12px 16px 0;
453
- button {
454
- flex: 1;
455
- border-radius: 25px;
456
- }
457
- }
458
- }
459
- :deep(.van-cell-group) {
460
- background-color: transparent;
461
- .van-field__label {
462
- color: #333333;
463
- font-size: 16px;
464
- font-weight: 400;
465
- }
466
- .van-field__control {
467
- font-size: 16px;
468
- }
469
- }
470
-
471
- .Invoice {
472
- padding-bottom: 100px;
473
- width: 100%;
474
- min-height: 100%;
475
- background-color: #f2f4f7;
476
- .top {
477
- width: 100%;
478
- padding: 12px 4px;
479
- img {
480
- width: 100%;
481
- height: 179px;
482
- display: block;
483
- }
484
- }
485
-
486
- .Field-title {
487
- display: flex;
488
- justify-content: space-between;
489
- align-items: center;
490
- .titleLeft {
491
- font-size: 16px;
492
- color: #333333;
493
- font-family: PingFangSC-Medium, PingFang SC;
494
- font-weight: 600;
495
- &::before {
496
- margin-right: 4px;
497
- display: inline-block;
498
- content: '';
499
- width: 4px;
500
- height: 14px;
501
- background-color: #266fe8;
502
- border-radius: 2px;
503
- }
504
- }
505
- .titleright {
506
- font-size: 14px;
507
- color: #266fe8;
508
- }
509
- }
510
- .marPX {
511
- margin-bottom: 12px;
512
- }
513
-
514
- table {
515
- background-color: #fff;
516
- border-radius: 4px;
517
- border: 1px solid #f2f4f7;
518
- width: 100%;
519
- border-spacing: 0;
520
- }
521
- thead {
522
- background-color: #f2f4f7;
523
- font-size: 12px;
524
- color: #666666;
525
- th {
526
- padding: 12px 0;
527
- text-align: center;
528
- }
529
- }
530
- tbody {
531
- td {
532
- text-align: center;
533
- padding: 10px 0;
534
- white-space: nowrap;
535
- }
536
- }
537
- .submit {
538
- position: fixed;
539
- bottom: 0;
540
- left: 0;
541
- width: 100%;
542
- box-shadow: 0px -1px 12px 0px rgba(173, 173, 173, 0.1);
543
- height: 90px;
544
- display: flex;
545
- justify-content: space-between;
546
- align-items: center;
547
- padding: 0 12px;
548
- z-index: 2;
549
- background-color: #fff;
550
- gap: 12px;
551
- span {
552
- flex: 2;
553
- background-color: #266fe8;
554
- // width: 68%;
555
- font-size: 15px;
556
- color: #fff;
557
- height: 44px;
558
- text-align: center;
559
- display: flex;
560
- justify-content: center;
561
- align-items: center;
562
- }
563
- }
564
- }
565
- </style>
1
+ <template>
2
+ <div class="Invoice">
3
+ <div class="top">
4
+ <img
5
+ :src="props.invoiceData.attachmentLink"
6
+ @click.stop="openPreViewImg"
7
+ alt="" />
8
+ </div>
9
+ <div>
10
+ <Form label-width="70px">
11
+ <CellGroup inset>
12
+ <template #title>
13
+ <div class="Field-title">
14
+ <span class="titleLeft">公司信息</span>
15
+ <!-- <span class="titleright">重新查验</span> -->
16
+ </div>
17
+ </template>
18
+ <div class="marPX">
19
+ <Field
20
+ autocomplete="off"
21
+ label="销售方"
22
+ placeholder="请输入销售方"
23
+ v-model="formData.sellerReq.sellerName">
24
+ <template #right-icon>
25
+ <div @click="expandObj.showSeller = !expandObj.showSeller">
26
+ <Icon
27
+ name="arrow-down"
28
+ v-if="!expandObj.showSeller"
29
+ color="#969799" />
30
+ <Icon v-else name="arrow-up" color="#969799" />
31
+ </div>
32
+ </template>
33
+ </Field>
34
+ <div v-show="expandObj.showSeller">
35
+ <Field
36
+ autocomplete="off"
37
+ label="纳税人识别号"
38
+ placeholder="请输入纳税人识别号"
39
+ v-model="formData.sellerReq.sellerId" />
40
+ <Field
41
+ autocomplete="off"
42
+ label="地址/电话"
43
+ autosize
44
+ type="textarea"
45
+ placeholder="请输入地址+电话"
46
+ v-model="formData.sellerReq.sellerContact" />
47
+ <!-- <Field
48
+ autocomplete="off"
49
+ label="电话"
50
+ placeholder="请输入电话"
51
+ v-model="formData.sellerReq.sellerName" /> -->
52
+ <Field
53
+ autocomplete="off"
54
+ autosize
55
+ type="textarea"
56
+ label="开户银行/银行账号"
57
+ placeholder="请输入开户银行+银行账户"
58
+ v-model="formData.sellerReq.sellerAccount" />
59
+ <!-- <Field
60
+ autocomplete="off"
61
+ label="银行账号"
62
+ placeholder="请输入银行账号"
63
+ v-model="formData.sellerReq.sellerName" /> -->
64
+ </div>
65
+ </div>
66
+ <div class="marPX">
67
+ <Field
68
+ autocomplete="off"
69
+ label="购买方"
70
+ placeholder="请输入购买方名称"
71
+ v-model="formData.payerReq.payerName">
72
+ <template #right-icon>
73
+ <div
74
+ @click="expandObj.showPurchaser = !expandObj.showPurchaser">
75
+ <Icon
76
+ name="arrow-down"
77
+ v-if="!expandObj.showPurchaser"
78
+ color="#969799" />
79
+ <Icon v-else name="arrow-up" color="#969799" />
80
+ </div>
81
+ </template>
82
+ </Field>
83
+ <div v-show="expandObj.showPurchaser">
84
+ <Field
85
+ autocomplete="off"
86
+ label="纳税人识别号"
87
+ placeholder="请输入纳税人识别号"
88
+ v-model="formData.payerReq.payerId" />
89
+ <Field
90
+ autocomplete="off"
91
+ label="地址/电话"
92
+ type="textarea"
93
+ placeholder="请输入地址+电话"
94
+ v-model="formData.payerReq.payerContact" />
95
+ <!-- <Field
96
+ autocomplete="off"
97
+ label="电话"
98
+ placeholder="请输入电话"
99
+ v-model="formData.payerReq.sellerName" /> -->
100
+ <Field
101
+ autocomplete="off"
102
+ autosize
103
+ type="textarea"
104
+ label="开户银行/银行账号"
105
+ placeholder="请输入开户银行+银行账户"
106
+ v-model="formData.payerReq.payerAccount" />
107
+ <!-- <Field
108
+ autocomplete="off"
109
+ label="银行账号"
110
+ placeholder="请输入银行账号"
111
+ v-model="formData.payerReq.sellerName" /> -->
112
+ </div>
113
+ </div>
114
+ <div class="marPX">
115
+ <Field
116
+ autocomplete="off"
117
+ readonly
118
+ label="发票类型"
119
+ :model-value="props.invoiceData.description" />
120
+ </div>
121
+ <div class="marPX">
122
+ <Cell title="价税合计" :value="computed_amount">
123
+ <template #value>
124
+ <div
125
+ style="
126
+ color: #333;
127
+ font-weight: 400;
128
+ font-size: 16px;
129
+ margin-right: 12px;
130
+ ">
131
+ {{ computed_amount }}
132
+ </div>
133
+ </template>
134
+ <template #right-icon>
135
+ <div @click="expandObj.showPrice = !expandObj.showPrice">
136
+ <Icon
137
+ name="arrow-down"
138
+ v-if="!expandObj.showPrice"
139
+ color="#969799" />
140
+ <Icon v-else name="arrow-up" color="#969799" />
141
+ </div>
142
+ </template>
143
+ </Cell>
144
+ <div v-show="!expandObj.showPrice">
145
+ <Field>
146
+ <template #input>
147
+ <table>
148
+ <thead>
149
+ <tr>
150
+ <th>商品金额(不含税)</th>
151
+ <th>税率</th>
152
+ <th>税额</th>
153
+ </tr>
154
+ </thead>
155
+ <tbody>
156
+ <tr
157
+ v-for="(item, index) in formData.itemAmountReqs"
158
+ @click="openEditpopUp(item, index)">
159
+ <td>{{ item.itemExTaxAmount }}</td>
160
+ <td>{{ item.itemTaxRate }}</td>
161
+ <td>{{item.itemTaxAmount}}</td>
162
+ </tr>
163
+ </tbody>
164
+ </table>
165
+ </template>
166
+ </Field>
167
+ </div>
168
+ </div>
169
+ <div class="marPX">
170
+ <Field
171
+ autocomplete="off"
172
+ label="发票代码"
173
+ placeholder="请输入发票代码"
174
+ v-model="formData.codeReq.invoiceCode">
175
+ <template #right-icon>
176
+ <div @click="expandObj.invoiceCode = !expandObj.invoiceCode">
177
+ <Icon
178
+ name="arrow-down"
179
+ v-if="!expandObj.invoiceCode"
180
+ color="#969799" />
181
+ <Icon v-else name="arrow-up" color="#969799" />
182
+ </div>
183
+ </template>
184
+ </Field>
185
+ <div v-show="expandObj.invoiceCode">
186
+ <Field
187
+ autocomplete="off"
188
+ label="发票号码"
189
+ placeholder="请输入发票号码"
190
+ v-model="formData.codeReq.invoiceNum" />
191
+ <Field
192
+ autocomplete="off"
193
+ label="校验码"
194
+ placeholder="请输入校验码"
195
+ v-model="formData.codeReq.checkCode" />
196
+ </div>
197
+ </div>
198
+ <div class="marPX">
199
+ <Field
200
+ autocomplete="off"
201
+ label="开票日期"
202
+ readonly
203
+ v-model="props.invoiceData.invoiceDate" />
204
+ </div>
205
+ <div class="marPX">
206
+ <Field
207
+ autocomplete="off"
208
+ label="查验状态"
209
+ readonly
210
+ :model-value="const_realStatus[props.invoiceData.realStatus]" />
211
+ </div>
212
+ </CellGroup>
213
+ <div class="submit">
214
+ <span
215
+ style="flex: 1; background-color: #07c160; color: #fff"
216
+ @click="close">
217
+ 返回
218
+ </span>
219
+ <span v-if="isEdit" @click="submit">保存</span>
220
+ </div>
221
+ </Form>
222
+ </div>
223
+ </div>
224
+ <ActionSheet v-model:show="showEdit" :title="editTitle(titleIndex)">
225
+ <div class="content">
226
+ <Form ref="REF_editForm">
227
+ <Field
228
+ autocomplete="off"
229
+ @blur="blurInput($event, 'itemExTaxAmount')"
230
+ label="不含税金额"
231
+ v-model="activeRow.itemExTaxAmount" />
232
+ <Field
233
+ autocomplete="off"
234
+ label="税率"
235
+ @blur="blurInput($event, 'itemTaxRate')"
236
+ v-model="activeRow.itemTaxRate">
237
+ <template #right-icon>%</template>
238
+ </Field>
239
+ <Cell title="税额" :value="rateAmount"> </Cell>
240
+ </Form>
241
+ <div class="btn">
242
+ <Button type="primary" @click="confirmEdit">确定</Button>
243
+ </div>
244
+ </div>
245
+ </ActionSheet>
246
+ <Overlay
247
+ style="
248
+ display: flex;
249
+ justify-content: center;
250
+ align-items: center;
251
+ z-index: 999;
252
+ "
253
+ :show="showLoading">
254
+ <Loading class="loading" color="#0094ff">保存中...</Loading>
255
+ </Overlay>
256
+ </template>
257
+ <script setup lang="ts">
258
+ import { ref } from 'vue'
259
+ import '@/utils/disableZoom'
260
+ import { __updateInvoiceData } from '@/api/invoice'
261
+ import {
262
+ showToast,
263
+ Overlay,
264
+ Loading,
265
+ showFailToast,
266
+ showImagePreview,
267
+ CellGroup,
268
+ Field,
269
+ Form,
270
+ Icon,
271
+ Button,
272
+ ActionSheet,
273
+ Cell,
274
+ } from 'vant'
275
+ import { onMounted } from 'vue'
276
+ import { const_realStatus } from '../InvoiceList/const'
277
+ import { RowAttribute } from './const'
278
+ import { filterNumber } from '@/utils/number'
279
+ import { computed } from 'vue'
280
+ import Decimal from 'decimal.js'
281
+ const props = defineProps(['ids', 'invoiceData'])
282
+ const formData = ref({
283
+ codeReq: {
284
+ invoiceCode: '',
285
+ invoiceNum: '',
286
+ checkCode: '',
287
+ },
288
+ itemAmountReqs: [
289
+ {
290
+ detailCode: '',
291
+ itemExTaxAmount: 0,
292
+ itemTaxRate: 0,
293
+ itemTaxAmount:0
294
+ },
295
+ ],
296
+ payerReq: {
297
+ payerAccount: '',
298
+ payerContact: '',
299
+ payerId: '',
300
+ payerName: '',
301
+ },
302
+ sellerReq: {
303
+ sellerAccount: '',
304
+ sellerContact: '',
305
+ sellerId: '',
306
+ sellerName: '',
307
+ },
308
+ taskId: '',
309
+ })
310
+ const emit = defineEmits(['saveSuccess'])
311
+ document.title = '发票信息'
312
+ const expandObj: any = ref({})
313
+ const showRequiredMsg = ref(false)
314
+ // const modules = ref([Pagination])
315
+ const showLoading = ref(false)
316
+ const close = () => {
317
+ emit('saveSuccess')
318
+ }
319
+ const openPreViewImg = () => {
320
+ showImagePreview([props.invoiceData.attachmentLink])
321
+ }
322
+ const isEdit = computed(() => {
323
+ // true 允许
324
+ return (
325
+ props.invoiceData.realStatus === 'noNeed' ||
326
+ props.invoiceData.invoiceExceptionInfo === 'abnormal' ||
327
+ props.invoiceData.manualModify ||
328
+ props.invoiceData.realStatus === 'checkFail'||
329
+ props.invoiceData.realStatus === 'notCheck'
330
+ )
331
+ })
332
+ const submit = async () => {
333
+ showLoading.value = true
334
+ try {
335
+ const res: any = await __updateInvoiceData(formData.value)
336
+ if (res.code === 200) {
337
+ showToast({
338
+ type: 'success',
339
+ message: '保存成功',
340
+ })
341
+ emit('saveSuccess')
342
+ }
343
+ } catch (err: any) {
344
+ showFailToast(err.msg)
345
+ emit('saveSuccess')
346
+ }
347
+ showLoading.value = false
348
+ }
349
+ const initData = () => {
350
+ console.log(props.invoiceData)
351
+ // 销售方数据回显
352
+ formData.value.sellerReq.sellerName = props.invoiceData.sellerName
353
+ formData.value.sellerReq.sellerAccount = props.invoiceData.sellerAccount
354
+ formData.value.sellerReq.sellerContact = props.invoiceData.sellerContact
355
+ formData.value.sellerReq.sellerId = props.invoiceData.sellerId
356
+ // 购买方数据回显
357
+ formData.value.payerReq.payerAccount = props.invoiceData.payerAccount
358
+ formData.value.payerReq.payerContact = props.invoiceData.payerContact
359
+ formData.value.payerReq.payerName = props.invoiceData.payerName
360
+ formData.value.payerReq.payerId = props.invoiceData.payerId
361
+ // 发票代码回显
362
+ formData.value.codeReq.invoiceCode = props.invoiceData.invoiceCode
363
+ formData.value.codeReq.invoiceNum = props.invoiceData.invoiceNum
364
+ formData.value.codeReq.checkCode = props.invoiceData.checkCode
365
+ formData.value.taskId = props.invoiceData.taskId
366
+ // 金额数据回显
367
+ formData.value.itemAmountReqs = JSON.parse(
368
+ JSON.stringify(props.invoiceData.deatis)
369
+ ).map((item: any) => {
370
+ return {
371
+ detailCode: item.code,
372
+ itemExTaxAmount: item.itemExTaxAmount,
373
+ itemTaxRate: item.itemTaxRate.replace(/%/g, ''),
374
+ itemTaxAmount:item.itemTaxAmount
375
+ }
376
+ })
377
+ }
378
+ const showEdit = ref(false)
379
+ const activeRow = ref<RowAttribute | any>({})
380
+ const titleIndex = ref<number>(0)
381
+ const editTitle = (index: number) => {
382
+ return `第${index + 1}行金额`
383
+ }
384
+ const openEditpopUp = (row: RowAttribute, index: number) => {
385
+ activeRow.value = JSON.parse(JSON.stringify(row))
386
+ activeRow.value.itemTaxRate = filterNumber(activeRow.value.itemTaxRate)
387
+ titleIndex.value = index
388
+ showEdit.value = true
389
+ }
390
+ const confirmEdit = () => {
391
+ formData.value.itemAmountReqs[titleIndex.value].detailCode =
392
+ activeRow.value.detailCode
393
+ formData.value.itemAmountReqs[titleIndex.value].itemExTaxAmount =
394
+ activeRow.value.itemExTaxAmount
395
+ formData.value.itemAmountReqs[titleIndex.value].itemTaxRate =
396
+ activeRow.value.itemTaxRate
397
+ formData.value.itemAmountReqs[titleIndex.value].itemTaxAmount = Number(new Decimal(filterNumber(activeRow.value.itemExTaxAmount)).times(new Decimal(filterNumber(activeRow.value.itemTaxRate / 100))).toFixed(2))
398
+ showEdit.value = false
399
+ }
400
+ const blurInput = (e: any, key: any) => {
401
+ let value = activeRow.value[key]
402
+ activeRow.value[key] = filterNumber(value)
403
+ }
404
+
405
+ const computed_amount = computed(() => {
406
+ let count = new Decimal(0)
407
+ formData.value.itemAmountReqs.forEach((item) => {
408
+ // let tax_amount = new Decimal(filterNumber(item.itemExTaxAmount)).times(
409
+ // new Decimal(filterNumber(item.itemTaxRate / 100))
410
+ // )
411
+ // count = count.plus(
412
+ // new Decimal(filterNumber(item.itemExTaxAmount)).plus(tax_amount)
413
+ // )
414
+ count = count.plus(
415
+ new Decimal(filterNumber(item.itemExTaxAmount)).plus(new Decimal(item.itemTaxAmount))
416
+ )
417
+ })
418
+ return count.toFixed(2)
419
+ })
420
+ const rateAmount = computed(() => {
421
+ return new Decimal(filterNumber(Number(activeRow.value.itemExTaxAmount)))
422
+ .times(new Decimal(filterNumber(activeRow.value.itemTaxRate / 100)))
423
+ .toFixed(2)
424
+ })
425
+ const computedTaxAmount = (ExTaxAmount: any, TaxRate: any) => {
426
+ let rate: any = TaxRate + ''
427
+ return new Decimal(filterNumber(ExTaxAmount))
428
+ .times(new Decimal(filterNumber(rate / 100)))
429
+ .toFixed(2)
430
+ }
431
+ onMounted(() => {
432
+ initData()
433
+ })
434
+ </script>
435
+
436
+ <style lang="scss" scoped>
437
+ .content {
438
+ background-color: #f7f8fa;
439
+ height: 200px;
440
+ :deep(.van-field__value) {
441
+ border: 1px solid #2196f3;
442
+ border-radius: 4px;
443
+ input {
444
+ padding-left: 12px;
445
+ }
446
+ }
447
+ .btn {
448
+ display: flex;
449
+ justify-content: space-between;
450
+ gap: 12px;
451
+ padding: 12px 16px 0;
452
+ button {
453
+ flex: 1;
454
+ border-radius: 25px;
455
+ }
456
+ }
457
+ }
458
+ :deep(.van-cell-group) {
459
+ background-color: transparent;
460
+ .van-field__label {
461
+ color: #333333;
462
+ font-size: 16px;
463
+ font-weight: 400;
464
+ }
465
+ .van-field__control {
466
+ font-size: 16px;
467
+ }
468
+ }
469
+
470
+ .Invoice {
471
+ padding-bottom: 100px;
472
+ width: 100%;
473
+ min-height: 100%;
474
+ background-color: #f2f4f7;
475
+ .top {
476
+ width: 100%;
477
+ padding: 12px 4px;
478
+ img {
479
+ width: 100%;
480
+ height: 179px;
481
+ display: block;
482
+ }
483
+ }
484
+
485
+ .Field-title {
486
+ display: flex;
487
+ justify-content: space-between;
488
+ align-items: center;
489
+ .titleLeft {
490
+ font-size: 16px;
491
+ color: #333333;
492
+ font-family: PingFangSC-Medium, PingFang SC;
493
+ font-weight: 600;
494
+ &::before {
495
+ margin-right: 4px;
496
+ display: inline-block;
497
+ content: '';
498
+ width: 4px;
499
+ height: 14px;
500
+ background-color: #266fe8;
501
+ border-radius: 2px;
502
+ }
503
+ }
504
+ .titleright {
505
+ font-size: 14px;
506
+ color: #266fe8;
507
+ }
508
+ }
509
+ .marPX {
510
+ margin-bottom: 12px;
511
+ }
512
+
513
+ table {
514
+ background-color: #fff;
515
+ border-radius: 4px;
516
+ border: 1px solid #f2f4f7;
517
+ width: 100%;
518
+ border-spacing: 0;
519
+ }
520
+ thead {
521
+ background-color: #f2f4f7;
522
+ font-size: 12px;
523
+ color: #666666;
524
+ th {
525
+ padding: 12px 0;
526
+ text-align: center;
527
+ }
528
+ }
529
+ tbody {
530
+ td {
531
+ text-align: center;
532
+ padding: 10px 0;
533
+ white-space: nowrap;
534
+ }
535
+ }
536
+ .submit {
537
+ position: fixed;
538
+ bottom: 0;
539
+ left: 0;
540
+ width: 100%;
541
+ box-shadow: 0px -1px 12px 0px rgba(173, 173, 173, 0.1);
542
+ height: 90px;
543
+ display: flex;
544
+ justify-content: space-between;
545
+ align-items: center;
546
+ padding: 0 12px;
547
+ z-index: 2;
548
+ background-color: #fff;
549
+ gap: 12px;
550
+ span {
551
+ flex: 2;
552
+ background-color: #266fe8;
553
+ // width: 68%;
554
+ font-size: 15px;
555
+ color: #fff;
556
+ height: 44px;
557
+ text-align: center;
558
+ display: flex;
559
+ justify-content: center;
560
+ align-items: center;
561
+ }
562
+ }
563
+ }
564
+ </style>