mg-ocr-invoice 0.2.0 → 0.2.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.
@@ -4,6 +4,7 @@ declare const _default: import("vue").DefineComponent<{
4
4
  listId: {
5
5
  required: true;
6
6
  type: StringConstructor;
7
+ default: string;
7
8
  };
8
9
  multiple: {
9
10
  required: true;
@@ -13,6 +14,7 @@ declare const _default: import("vue").DefineComponent<{
13
14
  listId: {
14
15
  required: true;
15
16
  type: StringConstructor;
17
+ default: string;
16
18
  };
17
19
  multiple: {
18
20
  required: true;
@@ -21,5 +23,7 @@ declare const _default: import("vue").DefineComponent<{
21
23
  }>> & {
22
24
  onOk?: ((...args: any[]) => any) | undefined;
23
25
  onEdit?: ((...args: any[]) => any) | undefined;
24
- }, {}, {}>;
26
+ }, {
27
+ listId: string;
28
+ }, {}>;
25
29
  export default _default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mg-ocr-invoice",
3
3
  "private": false,
4
- "version": "0.2.0",
4
+ "version": "0.2.2",
5
5
  "type": "module",
6
6
  "types": "dist/types/index.d.ts",
7
7
  "module": "dist/index.es.js",
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="Invoice">
3
- <div class="top">
3
+ <div class="top" @click="openPreViewImg">
4
4
  <img :src="invoiceData.attachmentLink" alt="" />
5
5
  </div>
6
6
  <div class="company">
@@ -114,7 +114,13 @@
114
114
  import { ref } from 'vue'
115
115
  import '@/utils/disableZoom'
116
116
  import { __updateInvoice } from '@/api/invoice'
117
- import { showToast, Overlay, Loading, showFailToast } from 'vant'
117
+ import {
118
+ showToast,
119
+ Overlay,
120
+ Loading,
121
+ showFailToast,
122
+ showImagePreview,
123
+ } from 'vant'
118
124
  import { ElInputNumber } from 'element-plus'
119
125
  const { ids, invoiceData } = defineProps({
120
126
  ids: {
@@ -134,6 +140,9 @@ const showLoading = ref(false)
134
140
  const close = () => {
135
141
  emit('saveSuccess')
136
142
  }
143
+ const openPreViewImg = () => {
144
+ showImagePreview([invoiceData.attachmentLink])
145
+ }
137
146
  const editFlag = ref(false)
138
147
  const submit = async () => {
139
148
  if (!editFlag.value) {
@@ -1,17 +1,37 @@
1
1
  <template>
2
2
  <div class="InvoiceList">
3
+ <div class="selectAll">
4
+ <div class="left">
5
+ 已选 {{ selectedLength }}/{{ selectedLengthCount }}
6
+ </div>
7
+ <div class="right">
8
+ <span>全选</span>
9
+ <input
10
+ type="checkbox"
11
+ @change.self="changeSelectAll"
12
+ v-model="selectedAll"
13
+ @click.stop
14
+ class="checkbox" />
15
+ <!-- <Checkbox
16
+ @change.self="changeSelectAll"
17
+ v-model="selectedAll"
18
+ @click.stop
19
+ icon-size="22px"></Checkbox> -->
20
+ </div>
21
+ </div>
22
+
3
23
  <div class="card">
4
24
  <ul>
5
- <li
6
- v-for="(item, index) in list"
7
- :key="index"
8
- @click="openDetails(item)">
25
+ <li v-for="(item, index) in list" :key="index" @click="clickItem(item)">
9
26
  <div class="li">
10
27
  <div
11
28
  class="item-card"
12
29
  v-if="
13
30
  item.taskStatus === 'finish' || item.taskStatus === 'repeat'
14
31
  ">
32
+ <div class="details-btn" @click.stop="openDetails(item)">
33
+ 详情
34
+ </div>
15
35
  <div
16
36
  class="title"
17
37
  :class="{ person: item.invoiceCompanyType === '公司' }">
@@ -21,7 +41,7 @@
21
41
  <div class="name">
22
42
  <div class="left">{{ item.sellerName }}</div>
23
43
  <div class="right" v-if="item.taskStatus === 'repeat'">
24
- 重复录入
44
+ 已收录
25
45
  </div>
26
46
  </div>
27
47
  <div class="tags">
@@ -59,10 +79,13 @@
59
79
  </div>
60
80
  </div>
61
81
  <div class="rightCheckbox">
62
- <Checkbox
82
+ <input
63
83
  @click.stop
84
+ type="checkbox"
85
+ class="checkbox"
86
+ @change="changeItemCheckbox"
64
87
  v-model="item.selected"
65
- icon-size="22px"></Checkbox>
88
+ icon-size="22px" />
66
89
  </div>
67
90
  </div>
68
91
  </div>
@@ -83,7 +106,7 @@
83
106
  <Skeleton :loading="true" title :row="6"></Skeleton>
84
107
  </div>
85
108
  <div class="err-card" v-else>
86
- <div class="left-img">
109
+ <div class="left-img" @click="openErrImg(item.fileUrlKey)">
87
110
  <img :src="item.fileUrlKey" alt="" />
88
111
  </div>
89
112
  <div class="right-errText">
@@ -94,10 +117,11 @@
94
117
  <p>可以重新拍照识别,或手动添加信息导入</p>
95
118
  </div>
96
119
  <div>
97
- <Checkbox
120
+ <input
121
+ type="checkbox"
122
+ class="checkbox"
98
123
  @click.stop
99
- v-model="item.selected"
100
- icon-size="22px"></Checkbox>
124
+ v-model="item.selected" />
101
125
  </div>
102
126
  </div>
103
127
  </div>
@@ -141,7 +165,6 @@ import 'vant/lib/index.css'
141
165
  import { ref, onMounted, computed } from 'vue'
142
166
  import {
143
167
  Popup,
144
- Checkbox,
145
168
  Skeleton,
146
169
  Loading,
147
170
  showToast,
@@ -161,14 +184,14 @@ import {
161
184
  const_taskStatus,
162
185
  setClass,
163
186
  } from './const'
164
-
187
+ import { showImagePreview } from 'vant'
165
188
  // console.log(addNumber('495.28', '29.72'))
166
189
  const emit = defineEmits(['edit', 'ok'])
167
190
  const { listId, multiple } = defineProps({
168
191
  listId: {
169
192
  required: true,
170
193
  type: String,
171
- // default: '1676054202318585856',
194
+ default: '1690918419274137620',
172
195
  },
173
196
  multiple: {
174
197
  required: true,
@@ -187,6 +210,7 @@ const getList = async () => {
187
210
  return new Promise(async (resolve, reject) => {
188
211
  const data: any = {}
189
212
  data.batchId = listId
213
+ if (!data.batchId) return
190
214
  try {
191
215
  const res: any = await __getUploadInvoiceList(data, token.value)
192
216
  if (res.code === 200) {
@@ -205,7 +229,9 @@ const getList = async () => {
205
229
  }
206
230
  })
207
231
  }
208
-
232
+ const clickItem = (row: any) => {
233
+ row.selected = !row.selected
234
+ }
209
235
  const openDetails = (row: any) => {
210
236
  if (row.taskStatus !== 'finish' && row.taskStatus !== 'repeat') {
211
237
  return
@@ -219,6 +245,31 @@ const openDetails = (row: any) => {
219
245
  row
220
246
  )
221
247
  }
248
+ const everyStatus = (item: any) => {
249
+ return (
250
+ item.invoiceStatus === 'unused' ||
251
+ item.invoiceStatus === 'invalid' ||
252
+ item.taskStatus === 'ocr_success' ||
253
+ item.taskStatus === 'repeat' ||
254
+ item.taskStatus === 'finish' ||
255
+ item.realStatus === 'noNeed' ||
256
+ item.realStatus === 'notCheck' ||
257
+ item.realStatus === 'checked' ||
258
+ item.realStatus === 'checkFail'
259
+ )
260
+ }
261
+ const selectedAll: any = ref(false)
262
+ const changeSelectAll = (v: any) => {
263
+ list.value.forEach((item) => {
264
+ item.selected = everyStatus(item) && selectedAll.value
265
+ })
266
+ }
267
+ const changeItemCheckbox = () => {
268
+ const status = list.value
269
+ .filter((item) => everyStatus(item))
270
+ .every((item) => item.selected)
271
+ selectedAll.value = status
272
+ }
222
273
  const deleteSelectItem = () => {
223
274
  if (selectId.value.length <= 0) {
224
275
  showToast({ type: 'text', message: '请先选择发票' })
@@ -276,23 +327,33 @@ const submitBtn = computed(() => {
276
327
  const flag = list.value
277
328
  .filter((item) => item.selected)
278
329
  .every((item) => {
279
- return (
280
- item.invoiceStatus === 'unused' &&
281
- (item.taskStatus === 'ocr_success' ||
282
- item.taskStatus === 'repeat' ||
283
- item.taskStatus === 'finish' ||
284
- item.invoiceStatus === 'invalid' ||
285
- item.invoiceStatus === 'invalid' ||
286
- item.invoiceStatus === 'used' ||
287
- item.realStatus === 'noNeed' ||
288
- item.realStatus === 'notCheck' ||
289
- item.realStatus === 'checked' ||
290
- item.realStatus === 'checkFail')
291
- )
330
+ console.log(item.invoiceStatus, 'invoiceStatus')
331
+ console.log(item.taskStatus, 'taskStatus')
332
+ console.log(item.realStatus, 'realStatus')
333
+ return everyStatus(item)
334
+ // item.invoiceStatus === 'unused' &&
335
+ // (item.taskStatus === 'ocr_success' ||
336
+ // item.taskStatus === 'repeat' ||
337
+ // item.taskStatus === 'finish' ||
338
+ // item.invoiceStatus === 'invalid' ||
339
+ // item.invoiceStatus === 'invalid' ||
340
+ // item.invoiceStatus === 'used' ||
341
+ // item.realStatus === 'noNeed' ||
342
+ // item.realStatus === 'notCheck' ||
343
+ // item.realStatus === 'checked' ||
344
+ // item.realStatus === 'checkFail')
292
345
  })
293
346
  return flag && list.value.filter((item) => item.selected).length > 0
294
347
  })
295
-
348
+ const selectedLength = computed(() => {
349
+ return list.value.filter((item) => item.selected && everyStatus(item)).length
350
+ })
351
+ const selectedLengthCount = computed(() => {
352
+ return list.value.filter((item) => everyStatus(item)).length
353
+ })
354
+ const openErrImg = (url: any) => {
355
+ showImagePreview([url])
356
+ }
296
357
  const ok = () => {
297
358
  if (selectId.value.length <= 0) {
298
359
  showToast({ type: 'text', message: '请先选择发票' })
@@ -336,12 +397,25 @@ onMounted(() => {
336
397
  padding-bottom: 100px;
337
398
  position: relative;
338
399
  width: 100%;
339
- min-height: 100%;
400
+ min-height: 100vh;
340
401
  background-color: #f3f4f6;
402
+ .selectAll {
403
+ background-color: #f3f4f6;
404
+ position: sticky;
405
+ top: 0;
406
+ z-index: 999;
407
+ padding: 12px;
408
+ display: flex;
409
+ justify-content: space-between;
410
+ .right {
411
+ display: flex;
412
+ gap: 5px;
413
+ padding-right: 12px;
414
+ }
415
+ }
341
416
  .card {
342
417
  width: 100%;
343
418
  ul {
344
- padding-top: 12px;
345
419
  display: flex;
346
420
  flex-direction: column;
347
421
  gap: 12px;
@@ -353,11 +427,24 @@ onMounted(() => {
353
427
  align-items: center;
354
428
  gap: 12px;
355
429
  overflow: hidden;
430
+
356
431
  .item-card {
357
432
  flex: 1;
433
+ position: relative;
434
+
358
435
  background-color: #fff;
359
436
  padding-bottom: 20px;
360
437
  min-width: 100%;
438
+ .details-btn {
439
+ position: absolute;
440
+ bottom: 12px;
441
+ right: 9px;
442
+ border: 1px solid #dcdee0;
443
+ padding: 4px 16px;
444
+ font-size: 14px;
445
+ color: #333;
446
+ border-radius: 2px;
447
+ }
361
448
  div.person {
362
449
  background-color: #ff8b26;
363
450
  }
@@ -597,4 +684,27 @@ onMounted(() => {
597
684
  }
598
685
  }
599
686
  }
687
+
688
+ /* 重置复选框的默认样式 */
689
+ .checkbox {
690
+ appearance: none; /* 去除默认外观 */
691
+ -webkit-appearance: none;
692
+ -moz-appearance: none;
693
+ display: inline-block;
694
+ width: 22px;
695
+ height: 22px;
696
+ border: 1px solid #c9cacd; /* 边框宽度和颜色 */
697
+ border-radius: 50%; /* 使复选框成为圆形 */
698
+ outline: none; /* 去除点击时的边框 */
699
+ cursor: pointer;
700
+ }
701
+
702
+ /* 根据复选框的选中状态设置颜色 */
703
+ .checkbox:checked {
704
+ width: 22px;
705
+ height: 22px;
706
+ background: url('@/assets/xuanzhong@2x.png') no-repeat center;
707
+ background-size: 110%;
708
+ border: none;
709
+ }
600
710
  </style>
@@ -1,22 +1,25 @@
1
1
  <template>
2
2
  <div class="OCRInvoice">
3
- <PaymentMode
4
- :batchId="batchId"
5
- :multiple="multiple"
6
- @uploadSuccess="uploadSuccess"
7
- v-if="activePage === 1"></PaymentMode>
8
- <InvoiceList
9
- :multiple="multiple"
10
- :listId="listId"
11
- @ok="submit"
12
- @edit="edit"
13
- v-if="activePage === 2">
14
- </InvoiceList>
15
- <Invoice
16
- @saveSuccess="saveSuccess"
17
- :ids="ids"
18
- :invoiceData="invoiceData"
19
- v-if="activePage === 3"></Invoice>
3
+ <div v-if="activePage === 1" class="box">
4
+ <PaymentMode
5
+ :batchId="batchId"
6
+ :multiple="multiple"
7
+ @uploadSuccess="uploadSuccess"></PaymentMode>
8
+ </div>
9
+ <div v-if="activePage === 2" class="box">
10
+ <InvoiceList
11
+ :multiple="multiple"
12
+ :listId="listId"
13
+ @ok="submit"
14
+ @edit="edit">
15
+ </InvoiceList>
16
+ </div>
17
+ <div v-if="activePage === 3" class="box">
18
+ <Invoice
19
+ @saveSuccess="saveSuccess"
20
+ :ids="ids"
21
+ :invoiceData="invoiceData"></Invoice>
22
+ </div>
20
23
  </div>
21
24
  </template>
22
25
  <script lang="ts" setup>
@@ -54,28 +57,12 @@ const { token, multiple, Base_URL, OCR_AuthDomain, batchId } = defineProps({
54
57
  required: false,
55
58
  },
56
59
  })
57
- const tempToken =
58
- 'z7v5gIDRD-sMhb9lRaspBmrWU8y--e5YK2xqWxMCIMTqBReMcoHNTJQ3XyNBdHmLVHiwommCp-HtP4wWSiK9oZDwTWvCW9CZswjLNNL4nGM'
60
+
59
61
  const initToken = () => {
60
62
  activePage.value = 1
61
63
  const params = getUrlParams(window.location.href)
62
64
  const linkToken = params.token
63
- if (!linkToken && !token) {
64
- // showToast({
65
- // type: 'fail',
66
- // message: '请在URL拼接token或者组件传递token',
67
- // duration: 0,
68
- // })
69
- sessionStorage.setItem('token', tempToken)
70
- } else {
71
- sessionStorage.setItem(
72
- 'token',
73
- linkToken ||
74
- token ||
75
- 'z7v5gIDRD-tZIqYE1f7is2aWk6u0y6RCK2xqWxMCIMTqBReMcoHNTJQ3XyNBdHmLVHiwommCp-HtP4wWSiK9oZDwTWvCW9CZswjLNNL4nGM'
76
- )
77
- activePage.value = 1
78
- }
65
+ Cookies.set('token', linkToken || token)
79
66
  }
80
67
  const init_Base_URL = () => {
81
68
  const params = getUrlParams(window.location.href)
@@ -112,6 +99,10 @@ onMounted(() => {
112
99
  <style lang="scss" scoped>
113
100
  .OCRInvoice {
114
101
  width: 100%;
115
- height: 100%;
102
+ height: 100vh;
103
+ .box {
104
+ width: 100%;
105
+ min-height: 100%;
106
+ }
116
107
  }
117
108
  </style>