mg-ocr-invoice 0.0.2 → 0.0.3
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.
- package/dist/index.es.js +10 -2
- package/dist/index.umd.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -4093,7 +4093,7 @@ const processImage = async (o) => {
|
|
|
4093
4093
|
default:
|
|
4094
4094
|
return "ok";
|
|
4095
4095
|
}
|
|
4096
|
-
}, _withScopeId$1 = (o) => (pushScopeId("data-v-
|
|
4096
|
+
}, _withScopeId$1 = (o) => (pushScopeId("data-v-fae0d232"), o = o(), popScopeId(), o), _hoisted_1$2 = { class: "InvoiceList" }, _hoisted_2$1 = { class: "card" }, _hoisted_3$1 = ["onClick"], _hoisted_4$1 = { class: "li" }, _hoisted_5$1 = {
|
|
4097
4097
|
key: 0,
|
|
4098
4098
|
class: "item-card"
|
|
4099
4099
|
}, _hoisted_6$1 = { class: "storeName" }, _hoisted_7$1 = { class: "name" }, _hoisted_8$1 = { class: "left" }, _hoisted_9 = {
|
|
@@ -4148,6 +4148,10 @@ const processImage = async (o) => {
|
|
|
4148
4148
|
k
|
|
4149
4149
|
);
|
|
4150
4150
|
}, L = () => {
|
|
4151
|
+
if (y.value.length <= 0) {
|
|
4152
|
+
showToast({ type: "text", message: "请先选择发票" });
|
|
4153
|
+
return;
|
|
4154
|
+
}
|
|
4151
4155
|
showConfirmDialog({
|
|
4152
4156
|
title: "提醒",
|
|
4153
4157
|
message: "请确认是否需要删除选中项,删除后不可恢复!"
|
|
@@ -4173,6 +4177,10 @@ const processImage = async (o) => {
|
|
|
4173
4177
|
}
|
|
4174
4178
|
v.value = !1;
|
|
4175
4179
|
}, D = () => {
|
|
4180
|
+
if (y.value.length <= 0) {
|
|
4181
|
+
showToast({ type: "text", message: "请先选择发票" });
|
|
4182
|
+
return;
|
|
4183
|
+
}
|
|
4176
4184
|
const k = _.value.filter((P) => P.selected);
|
|
4177
4185
|
console.log(k), c("ok", k);
|
|
4178
4186
|
};
|
|
@@ -4343,7 +4351,7 @@ const processImage = async (o) => {
|
|
|
4343
4351
|
}, 8, ["show"])
|
|
4344
4352
|
], 64));
|
|
4345
4353
|
}
|
|
4346
|
-
}),
|
|
4354
|
+
}), index_vue_vue_type_style_index_0_scoped_fae0d232_lang = "", InvoiceList = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-fae0d232"]]), _withScopeId = (o) => (pushScopeId("data-v-54509002"), o = o(), popScopeId(), o), _hoisted_1$1 = { class: "PaymentMode" }, _hoisted_2 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", { class: "title" }, "选择识别方式", -1)), _hoisted_3 = { class: "list" }, _hoisted_4 = ["onClick"], _hoisted_5 = { class: "left-text" }, _hoisted_6 = { class: "icon-left" }, _hoisted_7 = { class: "text" }, _hoisted_8 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", { class: "right-icon" }, [
|
|
4347
4355
|
/* @__PURE__ */ createElementVNode("i", { class: "iconfont icon-xiangyou" })
|
|
4348
4356
|
], -1)), _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
4349
4357
|
__name: "index",
|
package/dist/index.umd.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Released under the MIT license
|
|
9
9
|
*
|
|
10
10
|
* Date: 2023-02-28T14:09:41.732Z
|
|
11
|
-
*/function ownKeys(o,c){var n=Object.keys(o);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(o);c&&(f=f.filter(function(v){return Object.getOwnPropertyDescriptor(o,v).enumerable})),n.push.apply(n,f)}return n}function _objectSpread2(o){for(var c=1;c<arguments.length;c++){var n=arguments[c]!=null?arguments[c]:{};c%2?ownKeys(Object(n),!0).forEach(function(f){_defineProperty(o,f,n[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(f){Object.defineProperty(o,f,Object.getOwnPropertyDescriptor(n,f))})}return o}function _classCallCheck(o,c){if(!(o instanceof c))throw new TypeError("Cannot call a class as a function")}function _defineProperties(o,c){for(var n=0;n<c.length;n++){var f=c[n];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(o,_toPropertyKey(f.key),f)}}function _createClass(o,c,n){return c&&_defineProperties(o.prototype,c),n&&_defineProperties(o,n),Object.defineProperty(o,"prototype",{writable:!1}),o}function _defineProperty(o,c,n){return c=_toPropertyKey(c),c in o?Object.defineProperty(o,c,{value:n,enumerable:!0,configurable:!0,writable:!0}):o[c]=n,o}function _extends(){return _extends=Object.assign?Object.assign.bind():function(o){for(var c=1;c<arguments.length;c++){var n=arguments[c];for(var f in n)Object.prototype.hasOwnProperty.call(n,f)&&(o[f]=n[f])}return o},_extends.apply(this,arguments)}function _toPrimitive(o,c){if(typeof o!="object"||o===null)return o;var n=o[Symbol.toPrimitive];if(n!==void 0){var f=n.call(o,c||"default");if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(o)}function _toPropertyKey(o){var c=_toPrimitive(o,"string");return typeof c=="symbol"?c:String(c)}var canvasToBlob={exports:{}};(function(o){typeof window>"u"||function(c){var n=c.HTMLCanvasElement&&c.HTMLCanvasElement.prototype,f=c.Blob&&function(){try{return!!new Blob}catch{return!1}}(),v=f&&c.Uint8Array&&function(){try{return new Blob([new Uint8Array(100)]).size===100}catch{return!1}}(),p=c.BlobBuilder||c.WebKitBlobBuilder||c.MozBlobBuilder||c.MSBlobBuilder,e=/^data:((.*?)(;charset=.*?)?)(;base64)?,/,_=(f||p)&&c.atob&&c.ArrayBuffer&&c.Uint8Array&&function(w){var y,x,C,L,$,T,D,R,k;if(y=w.match(e),!y)throw new Error("invalid data URI");for(x=y[2]?y[1]:"text/plain"+(y[3]||";charset=US-ASCII"),C=!!y[4],L=w.slice(y[0].length),C?$=atob(L):$=decodeURIComponent(L),T=new ArrayBuffer($.length),D=new Uint8Array(T),R=0;R<$.length;R+=1)D[R]=$.charCodeAt(R);return f?new Blob([v?D:T],{type:x}):(k=new p,k.append(T),k.getBlob(x))};c.HTMLCanvasElement&&!n.toBlob&&(n.mozGetAsFile?n.toBlob=function(w,y,x){var C=this;setTimeout(function(){x&&n.toDataURL&&_?w(_(C.toDataURL(y,x))):w(C.mozGetAsFile("blob",y))})}:n.toDataURL&&_&&(n.msToBlob?n.toBlob=function(w,y,x){var C=this;setTimeout(function(){(y&&y!=="image/png"||x)&&n.toDataURL&&_?w(_(C.toDataURL(y,x))):w(C.msToBlob(y))})}:n.toBlob=function(w,y,x){var C=this;setTimeout(function(){w(_(C.toDataURL(y,x)))})})),o.exports?o.exports=_:c.dataURLtoBlob=_}(window)})(canvasToBlob);var toBlob=canvasToBlob.exports,isBlob=function(c){return typeof Blob>"u"?!1:c instanceof Blob||Object.prototype.toString.call(c)==="[object Blob]"},DEFAULTS={strict:!0,checkOrientation:!0,retainExif:!1,maxWidth:1/0,maxHeight:1/0,minWidth:0,minHeight:0,width:void 0,height:void 0,resize:"none",quality:.8,mimeType:"auto",convertTypes:["image/png"],convertSize:5e6,beforeDraw:null,drew:null,success:null,error:null},IS_BROWSER=typeof window<"u"&&typeof window.document<"u",WINDOW=IS_BROWSER?window:{},isPositiveNumber=function(c){return c>0&&c<1/0},slice=Array.prototype.slice;function toArray(o){return Array.from?Array.from(o):slice.call(o)}var REGEXP_IMAGE_TYPE=/^image\/.+$/;function isImageType(o){return REGEXP_IMAGE_TYPE.test(o)}function imageTypeToExtension(o){var c=isImageType(o)?o.substr(6):"";return c==="jpeg"&&(c="jpg"),".".concat(c)}var fromCharCode=String.fromCharCode;function getStringFromCharCode(o,c,n){var f="",v;for(n+=c,v=c;v<n;v+=1)f+=fromCharCode(o.getUint8(v));return f}var btoa$1=WINDOW.btoa;function arrayBufferToDataURL(o,c){for(var n=[],f=8192,v=new Uint8Array(o);v.length>0;)n.push(fromCharCode.apply(null,toArray(v.subarray(0,f)))),v=v.subarray(f);return"data:".concat(c,";base64,").concat(btoa$1(n.join("")))}function resetAndGetOrientation(o){var c=new DataView(o),n;try{var f,v,p;if(c.getUint8(0)===255&&c.getUint8(1)===216)for(var e=c.byteLength,_=2;_+1<e;){if(c.getUint8(_)===255&&c.getUint8(_+1)===225){v=_;break}_+=1}if(v){var w=v+4,y=v+10;if(getStringFromCharCode(c,w,4)==="Exif"){var x=c.getUint16(y);if(f=x===18761,(f||x===19789)&&c.getUint16(y+2,f)===42){var C=c.getUint32(y+4,f);C>=8&&(p=y+C)}}}if(p){var L=c.getUint16(p,f),$,T;for(T=0;T<L;T+=1)if($=p+T*12+2,c.getUint16($,f)===274){$+=8,n=c.getUint16($,f),c.setUint16($,1,f);break}}}catch{n=1}return n}function parseOrientation(o){var c=0,n=1,f=1;switch(o){case 2:n=-1;break;case 3:c=-180;break;case 4:f=-1;break;case 5:c=90,f=-1;break;case 6:c=90;break;case 7:c=90,n=-1;break;case 8:c=-90;break}return{rotate:c,scaleX:n,scaleY:f}}var REGEXP_DECIMALS=/\.\d*(?:0|9){12}\d*$/;function normalizeDecimalNumber(o){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e11;return REGEXP_DECIMALS.test(o)?Math.round(o*c)/c:o}function getAdjustedSizes(o){var c=o.aspectRatio,n=o.height,f=o.width,v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"none",p=isPositiveNumber(f),e=isPositiveNumber(n);if(p&&e){var _=n*c;(v==="contain"||v==="none")&&_>f||v==="cover"&&_<f?n=f/c:f=n*c}else p?n=f/c:e&&(f=n*c);return{width:f,height:n}}function getExif(o){for(var c=toArray(new Uint8Array(o)),n=c.length,f=[],v=0;v+3<n;){var p=c[v],e=c[v+1];if(p===255&&e===218)break;if(p===255&&e===216)v+=2;else{var _=c[v+2]*256+c[v+3],w=v+_+2,y=c.slice(v,w);f.push(y),v=w}}return f.reduce(function(x,C){return C[0]===255&&C[1]===225?x.concat(C):x},[])}function insertExif(o,c){var n=toArray(new Uint8Array(o));if(n[2]!==255||n[3]!==224)return o;var f=n[4]*256+n[5],v=[255,216].concat(c,n.slice(4+f));return new Uint8Array(v)}var ArrayBuffer$1=WINDOW.ArrayBuffer,FileReader=WINDOW.FileReader,URL$1=WINDOW.URL||WINDOW.webkitURL,REGEXP_EXTENSION=/\.\w+$/,AnotherCompressor=WINDOW.Compressor,Compressor=function(){function o(c,n){_classCallCheck(this,o),this.file=c,this.exif=[],this.image=new Image,this.options=_objectSpread2(_objectSpread2({},DEFAULTS),n),this.aborted=!1,this.result=null,this.init()}return _createClass(o,[{key:"init",value:function(){var n=this,f=this.file,v=this.options;if(!isBlob(f)){this.fail(new Error("The first argument must be a File or Blob object."));return}var p=f.type;if(!isImageType(p)){this.fail(new Error("The first argument must be an image File or Blob object."));return}if(!URL$1||!FileReader){this.fail(new Error("The current browser does not support image compression."));return}ArrayBuffer$1||(v.checkOrientation=!1,v.retainExif=!1);var e=p==="image/jpeg",_=e&&v.checkOrientation,w=e&&v.retainExif;if(URL$1&&!_&&!w)this.load({url:URL$1.createObjectURL(f)});else{var y=new FileReader;this.reader=y,y.onload=function(x){var C=x.target,L=C.result,$={},T=1;_&&(T=resetAndGetOrientation(L),T>1&&_extends($,parseOrientation(T))),w&&(n.exif=getExif(L)),_||w?!URL$1||T>1?$.url=arrayBufferToDataURL(L,p):$.url=URL$1.createObjectURL(f):$.url=L,n.load($)},y.onabort=function(){n.fail(new Error("Aborted to read the image with FileReader."))},y.onerror=function(){n.fail(new Error("Failed to read the image with FileReader."))},y.onloadend=function(){n.reader=null},_||w?y.readAsArrayBuffer(f):y.readAsDataURL(f)}}},{key:"load",value:function(n){var f=this,v=this.file,p=this.image;p.onload=function(){f.draw(_objectSpread2(_objectSpread2({},n),{},{naturalWidth:p.naturalWidth,naturalHeight:p.naturalHeight}))},p.onabort=function(){f.fail(new Error("Aborted to load the image."))},p.onerror=function(){f.fail(new Error("Failed to load the image."))},WINDOW.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(WINDOW.navigator.userAgent)&&(p.crossOrigin="anonymous"),p.alt=v.name,p.src=n.url}},{key:"draw",value:function(n){var f=this,v=n.naturalWidth,p=n.naturalHeight,e=n.rotate,_=e===void 0?0:e,w=n.scaleX,y=w===void 0?1:w,x=n.scaleY,C=x===void 0?1:x,L=this.file,$=this.image,T=this.options,D=document.createElement("canvas"),R=D.getContext("2d"),k=Math.abs(_)%180===90,P=(T.resize==="contain"||T.resize==="cover")&&isPositiveNumber(T.width)&&isPositiveNumber(T.height),A=Math.max(T.maxWidth,0)||1/0,F=Math.max(T.maxHeight,0)||1/0,H=Math.max(T.minWidth,0)||0,B=Math.max(T.minHeight,0)||0,j=v/p,V=T.width,J=T.height;if(k){var re=[F,A];A=re[0],F=re[1];var ae=[B,H];H=ae[0],B=ae[1];var be=[J,V];V=be[0],J=be[1]}P&&(j=V/J);var le=getAdjustedSizes({aspectRatio:j,width:A,height:F},"contain");A=le.width,F=le.height;var Oe=getAdjustedSizes({aspectRatio:j,width:H,height:B},"cover");if(H=Oe.width,B=Oe.height,P){var Te=getAdjustedSizes({aspectRatio:j,width:V,height:J},T.resize);V=Te.width,J=Te.height}else{var De=getAdjustedSizes({aspectRatio:j,width:V,height:J}),K=De.width;V=K===void 0?v:K;var X=De.height;J=X===void 0?p:X}V=Math.floor(normalizeDecimalNumber(Math.min(Math.max(V,H),A))),J=Math.floor(normalizeDecimalNumber(Math.min(Math.max(J,B),F)));var me=-V/2,xe=-J/2,se=V,Y=J,N=[];if(P){var q=0,ee=0,he=v,Ie=p,Fe=getAdjustedSizes({aspectRatio:j,width:v,height:p},{contain:"cover",cover:"contain"}[T.resize]);he=Fe.width,Ie=Fe.height,q=(v-he)/2,ee=(p-Ie)/2,N.push(q,ee,he,Ie)}if(N.push(me,xe,se,Y),k){var We=[J,V];V=We[0],J=We[1]}D.width=V,D.height=J,isImageType(T.mimeType)||(T.mimeType=L.type);var Se="transparent";L.size>T.convertSize&&T.convertTypes.indexOf(T.mimeType)>=0&&(T.mimeType="image/jpeg");var Be=T.mimeType==="image/jpeg";if(Be&&(Se="#fff"),R.fillStyle=Se,R.fillRect(0,0,V,J),T.beforeDraw&&T.beforeDraw.call(this,R,D),!this.aborted&&(R.save(),R.translate(V/2,J/2),R.rotate(_*Math.PI/180),R.scale(y,C),R.drawImage.apply(R,[$].concat(N)),R.restore(),T.drew&&T.drew.call(this,R,D),!this.aborted)){var ze=function(Ye){if(!f.aborted){var Ae=function(dt){return f.done({naturalWidth:v,naturalHeight:p,result:dt})};if(Ye&&Be&&T.retainExif&&f.exif&&f.exif.length>0){var je=function(dt){return Ae(toBlob(arrayBufferToDataURL(insertExif(dt,f.exif),T.mimeType)))};if(Ye.arrayBuffer)Ye.arrayBuffer().then(je).catch(function(){f.fail(new Error("Failed to read the compressed image with Blob.arrayBuffer()."))});else{var Re=new FileReader;f.reader=Re,Re.onload=function(it){var dt=it.target;je(dt.result)},Re.onabort=function(){f.fail(new Error("Aborted to read the compressed image with FileReader."))},Re.onerror=function(){f.fail(new Error("Failed to read the compressed image with FileReader."))},Re.onloadend=function(){f.reader=null},Re.readAsArrayBuffer(Ye)}}else Ae(Ye)}};D.toBlob?D.toBlob(ze,T.mimeType,T.quality):ze(toBlob(D.toDataURL(T.mimeType,T.quality)))}}},{key:"done",value:function(n){var f=n.naturalWidth,v=n.naturalHeight,p=n.result,e=this.file,_=this.image,w=this.options;if(URL$1&&_.src.indexOf("blob:")===0&&URL$1.revokeObjectURL(_.src),p)if(w.strict&&!w.retainExif&&p.size>e.size&&w.mimeType===e.type&&!(w.width>f||w.height>v||w.minWidth>f||w.minHeight>v||w.maxWidth<f||w.maxHeight<v))p=e;else{var y=new Date;p.lastModified=y.getTime(),p.lastModifiedDate=y,p.name=e.name,p.name&&p.type!==e.type&&(p.name=p.name.replace(REGEXP_EXTENSION,imageTypeToExtension(p.type)))}else p=e;this.result=p,w.success&&w.success.call(this,p)}},{key:"fail",value:function(n){var f=this.options;if(f.error)f.error.call(this,n);else throw n}},{key:"abort",value:function(){this.aborted||(this.aborted=!0,this.reader?this.reader.abort():this.image.complete?this.fail(new Error("The compression process has been aborted.")):(this.image.onload=null,this.image.onabort()))}}],[{key:"noConflict",value:function(){return window.Compressor=AnotherCompressor,o}},{key:"setDefaults",value:function(n){_extends(DEFAULTS,n)}}]),o}();const processImage=async o=>{if(console.log(o,"file"),!!o)return new Promise((c,n)=>{new Compressor(o,{quality:.6,mimeType:o.type,success(f){const v=new File([f],o.name,{type:o.type,lastModified:o.lastModified});console.log(v),c(v)},error(f){console.log(f.message),n(f)}})})},takePhoto=()=>new Promise((o,c)=>{var n=document.createElement("input");n.type="file",n.accept="image/*",n.capture="camera",n.style.display="none",document.body.appendChild(n);let f=new FormData;n.onchange=async function(v){console.log("ddd");var p=v.target.files[0];try{const e=await processImage(p);f.append("invoiceFiles",e),document.body.removeChild(n),o(f)}catch(e){console.log(e),document.body.removeChild(n),c(e)}},n.click()}),selectPhoto=async o=>new Promise((c,n)=>{var f=document.createElement("input");f.type="file",f.accept="image/*",f.multiple=o,f.style.display="none",document.body.appendChild(f);let v=new FormData;f.onchange=async function(p){var e=p.target.files;if(e.length>9){f.value="";return}for(let _=0;_<e.length;_++){const w=e[_];try{const y=await processImage(w);v.append("invoiceFiles",y),document.body.removeChild(f),c(v)}catch(y){console.log(y),document.body.removeChild(f),n(y)}}},f.click()}),const_invoiceStatus={invalid:"无效发票",unused:"未使用",using:"使用中",used:"已使用"},const_realStatus={noNeed:"无需验真",notCheck:"未验真",checked:"已验真",checkFail:"验真失败"},setClass=o=>{switch(o){case"invalid":return"error";case"unused":return"warning";case"using":return"ok";case"used":return"default";case"noNeed":return"ok";case"notCheck":return"warning";case"checked":return"ok";case"checkFail":return"error";default:return"ok"}},_withScopeId$1=o=>(vue.pushScopeId("data-v-4e7bf75a"),o=o(),vue.popScopeId(),o),_hoisted_1$2={class:"InvoiceList"},_hoisted_2$1={class:"card"},_hoisted_3$1=["onClick"],_hoisted_4$1={class:"li"},_hoisted_5$1={key:0,class:"item-card"},_hoisted_6$1={class:"storeName"},_hoisted_7$1={class:"name"},_hoisted_8$1={class:"left"},_hoisted_9={key:0,class:"right"},_hoisted_10={class:"tags"},_hoisted_11={class:"InvoiceInfo"},_hoisted_12={class:"leftinfo"},_hoisted_13={class:"item-info"},_hoisted_14=_withScopeId$1(()=>vue.createElementVNode("span",{class:"label"},"发票金额",-1)),_hoisted_15={class:"value price"},_hoisted_16={class:"item-info"},_hoisted_17=_withScopeId$1(()=>vue.createElementVNode("span",{class:"label"},"发票抬头",-1)),_hoisted_18={class:"value"},_hoisted_19={class:"item-info"},_hoisted_20=_withScopeId$1(()=>vue.createElementVNode("span",{class:"label"},"发票类型",-1)),_hoisted_21={class:"value"},_hoisted_22={class:"item-info"},_hoisted_23=_withScopeId$1(()=>vue.createElementVNode("span",{class:"label"},"发票时间",-1)),_hoisted_24={class:"value"},_hoisted_25={class:"rightCheckbox"},_hoisted_26={key:1,style:{"background-color":"#fff",padding:"21px 0 15px 12px",position:"relative",width:"100%"}},_hoisted_27={key:2,class:"err-card"},_hoisted_28={class:"left-img"},_hoisted_29=["src"],_hoisted_30={class:"right-errText"},_hoisted_31=_withScopeId$1(()=>vue.createElementVNode("div",{class:"title"},[vue.createElementVNode("span",null,"识别失败")],-1)),_hoisted_32={class:"content"},_hoisted_33=_withScopeId$1(()=>vue.createElementVNode("div",{class:"recognitionResult"},[vue.createElementVNode("p",{class:"errContent"},"OCR识别失败"),vue.createElementVNode("p",null,"可以重新拍照识别,或手动添加信息导入")],-1)),_hoisted_34={class:"boxPopup"},_hoisted_35=_withScopeId$1(()=>vue.createElementVNode("div",{class:"title"},[vue.createElementVNode("span",null,"添加发票")],-1)),_sfc_main$2=vue.defineComponent({__name:"index",props:{listId:{required:!0,type:String},multiple:{required:!0,type:Boolean}},emits:["edit","ok"],setup(o,{emit:c}){const{listId:n,multiple:f}=o,v=vue.ref(sessionStorage.getItem("token")),p=vue.ref(!1),e=vue.ref(!1),_=vue.ref([]),w=vue.ref(""),y=vue.computed(()=>_.value.filter(k=>k.selected).map(k=>k.taskId)),x=async()=>new Promise(async(k,P)=>{const A={};A.batchId=n;try{const F=await __getUploadInvoiceList(A,v.value);console.log(F),F.code===200&&(_.value=F.data.invoiceList.map(H=>({...H,selected:!1})),w.value=F.data.batchId,k(_.value))}catch(F){console.log(F),P(F)}}),C=k=>{k.taskStatus!=="finish"&&k.taskStatus!=="repeat"||c("edit",{taskId:k.taskId,batchId:w.value},k)},L=()=>{showConfirmDialog({title:"提醒",message:"请确认是否需要删除选中项,删除后不可恢复!"}).then(async()=>{var k=new URLSearchParams;k.append("batchId",w.value);const P=y.value.join(",");k.append("taskIds",P),(await __deleteInvoice(k,v.value)).code===200&&(showToast({type:"success",message:"删除成功"}),x())}).catch(()=>{})},$=()=>{e.value=!0},T=async k=>{let P;k===1?P=await selectPhoto(f):P=await takePhoto(),P.append("batchId",w.value),p.value=!0,e.value=!1;try{(await __uploadInvoice(P)).code===200&&(showToast({type:"success",message:"上传成功"}),R())}catch(A){console.log(A),R()}p.value=!1},D=()=>{const k=_.value.filter(P=>P.selected);console.log(k),c("ok",k)};vue.ref(null);const R=()=>{x().then(k=>{k.some(A=>A.taskStatus==="ocr_doing"||A.taskStatus==="ocr_success")&&setTimeout(R,2e3)}).catch(k=>{setTimeout(R,2e3)})};return vue.onMounted(()=>{R()}),(k,P)=>(vue.openBlock(),vue.createElementBlock(vue.Fragment,null,[vue.createElementVNode("div",_hoisted_1$2,[vue.createElementVNode("div",_hoisted_2$1,[vue.createElementVNode("ul",null,[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(_.value,(A,F)=>(vue.openBlock(),vue.createElementBlock("li",{key:F,onClick:H=>C(A)},[vue.createElementVNode("div",_hoisted_4$1,[A.taskStatus==="finish"||A.taskStatus==="repeat"?(vue.openBlock(),vue.createElementBlock("div",_hoisted_5$1,[vue.createElementVNode("div",{class:vue.normalizeClass(["title",{person:A.invoiceCompanyType==="公司"}])},vue.toDisplayString(A.invoiceCompanyType),3),vue.createElementVNode("div",_hoisted_6$1,[vue.createElementVNode("div",_hoisted_7$1,[vue.createElementVNode("div",_hoisted_8$1,vue.toDisplayString(A.sellerName),1),A.taskStatus==="repeat"?(vue.openBlock(),vue.createElementBlock("div",_hoisted_9," 重复录入 ")):vue.createCommentVNode("",!0)]),vue.createElementVNode("div",_hoisted_10,[vue.createElementVNode("span",{class:vue.normalizeClass(vue.unref(setClass)(A.realStatus))},vue.toDisplayString(vue.unref(const_realStatus)[A.realStatus]),3),vue.createElementVNode("span",{class:vue.normalizeClass(vue.unref(setClass)(A.invoiceStatus))},vue.toDisplayString(vue.unref(const_invoiceStatus)[A.invoiceStatus]),3)]),vue.createElementVNode("div",_hoisted_11,[vue.createElementVNode("div",_hoisted_12,[vue.createElementVNode("div",_hoisted_13,[_hoisted_14,vue.createElementVNode("span",_hoisted_15,"¥"+vue.toDisplayString(A.noTaxAmountTotal),1)]),vue.createElementVNode("div",_hoisted_16,[_hoisted_17,vue.createElementVNode("span",_hoisted_18,vue.toDisplayString(A.payerName),1)]),vue.createElementVNode("div",_hoisted_19,[_hoisted_20,vue.createElementVNode("span",_hoisted_21,vue.toDisplayString(A.description),1)]),vue.createElementVNode("div",_hoisted_22,[_hoisted_23,vue.createElementVNode("span",_hoisted_24,vue.toDisplayString(A.invoiceDate),1)])]),vue.createElementVNode("div",_hoisted_25,[vue.createVNode(vue.unref(Checkbox),{onClick:P[0]||(P[0]=vue.withModifiers(()=>{},["stop"])),modelValue:A.selected,"onUpdate:modelValue":H=>A.selected=H,"icon-size":"22px"},null,8,["modelValue","onUpdate:modelValue"])])])])])):A.taskStatus==="ocr_doing"||A.taskStatus==="ocr_success"?(vue.openBlock(),vue.createElementBlock("div",_hoisted_26,[vue.createVNode(vue.unref(Loading),{class:"loading",color:"#0094ff"},{default:vue.withCtx(()=>[vue.createTextVNode("识别中...")]),_:1}),vue.createVNode(vue.unref(Skeleton),{loading:!0,title:"",row:6})])):(vue.openBlock(),vue.createElementBlock("div",_hoisted_27,[vue.createElementVNode("div",_hoisted_28,[vue.createElementVNode("img",{src:A.attachmentLink,alt:""},null,8,_hoisted_29)]),vue.createElementVNode("div",_hoisted_30,[_hoisted_31,vue.createElementVNode("div",_hoisted_32,[_hoisted_33,vue.createElementVNode("div",null,[vue.createVNode(vue.unref(Checkbox),{onClick:P[1]||(P[1]=vue.withModifiers(()=>{},["stop"])),modelValue:A.selected,"onUpdate:modelValue":H=>A.selected=H,"icon-size":"22px"},null,8,["modelValue","onUpdate:modelValue"])])])])]))])],8,_hoisted_3$1))),128))])]),vue.createElementVNode("div",{class:"btn-form"},[vue.createElementVNode("div",{class:"operate"},[vue.createElementVNode("div",{class:"delete"},[vue.createElementVNode("span",{onClick:L},"删除")]),vue.createElementVNode("div",{class:"right-btn"},[vue.createElementVNode("span",{class:"add",onClick:$},"继续添加发票"),vue.createElementVNode("span",{class:"ok",onClick:D},"确定选择")])])])]),vue.createVNode(vue.unref(Popup),{show:e.value,"onUpdate:show":P[4]||(P[4]=A=>e.value=A),position:"bottom",closeable:""},{default:vue.withCtx(()=>[vue.createElementVNode("div",_hoisted_34,[_hoisted_35,vue.createElementVNode("div",{style:{"padding-bottom":"24px"},onClick:P[2]||(P[2]=A=>T(1))},"从相册中选择"),vue.createElementVNode("div",{onClick:P[3]||(P[3]=A=>T(2))},"拍照上传")])]),_:1},8,["show"]),vue.createVNode(vue.unref(Overlay),{style:{display:"flex","justify-content":"center","align-items":"center"},show:p.value},{default:vue.withCtx(()=>[vue.createVNode(vue.unref(Loading),{class:"loading",color:"#0094ff"},{default:vue.withCtx(()=>[vue.createTextVNode("上传中...")]),_:1})]),_:1},8,["show"])],64))}}),index_vue_vue_type_style_index_0_scoped_4e7bf75a_lang="",InvoiceList=_export_sfc(_sfc_main$2,[["__scopeId","data-v-4e7bf75a"]]),_withScopeId=o=>(vue.pushScopeId("data-v-54509002"),o=o(),vue.popScopeId(),o),_hoisted_1$1={class:"PaymentMode"},_hoisted_2=_withScopeId(()=>vue.createElementVNode("div",{class:"title"},"选择识别方式",-1)),_hoisted_3={class:"list"},_hoisted_4=["onClick"],_hoisted_5={class:"left-text"},_hoisted_6={class:"icon-left"},_hoisted_7={class:"text"},_hoisted_8=_withScopeId(()=>vue.createElementVNode("div",{class:"right-icon"},[vue.createElementVNode("i",{class:"iconfont icon-xiangyou"})],-1)),_sfc_main$1=vue.defineComponent({__name:"index",props:["multiple"],emits:["uploadSuccess"],setup(o,{emit:c}){const{multiple:n}=o,f=[{text:"拍照",leftIcon:"icon-xiangji"},{text:"相册",leftIcon:"icon-xiangce"}];document.title="请选择添加费用方式";const v=vue.ref(!1),p=async e=>{let _;e=="拍照"&&(_=await takePhoto()),e=="相册"&&(_=await selectPhoto(n)),v.value=!0;try{const w=await __uploadInvoice(_);console.log(w),w.code===200&&(showToast({type:"success",message:"上传成功"}),c("uploadSuccess",w.data))}catch(w){console.log(w),showFailToast("上传失败")}v.value=!1};return(e,_)=>(vue.openBlock(),vue.createElementBlock(vue.Fragment,null,[vue.createElementVNode("div",_hoisted_1$1,[_hoisted_2,vue.createElementVNode("div",_hoisted_3,[(vue.openBlock(),vue.createElementBlock(vue.Fragment,null,vue.renderList(f,(w,y)=>vue.createElementVNode("div",{class:"method-item",onClick:x=>p(w.text),key:w.id||y},[vue.createElementVNode("div",_hoisted_5,[vue.createElementVNode("span",_hoisted_6,[vue.createElementVNode("i",{class:vue.normalizeClass(["iconfont",w.leftIcon])},null,2)]),vue.createElementVNode("span",_hoisted_7,vue.toDisplayString(w.text),1)]),_hoisted_8],8,_hoisted_4)),64))])]),vue.createVNode(vue.unref(Overlay),{style:{display:"flex","justify-content":"center","align-items":"center"},show:v.value},{default:vue.withCtx(()=>[vue.createVNode(vue.unref(Loading),{class:"loading",color:"#0094ff"},{default:vue.withCtx(()=>[vue.createTextVNode("上传中...")]),_:1})]),_:1},8,["show"])],64))}}),index_vue_vue_type_style_index_0_scoped_54509002_lang="",PaymentMode=_export_sfc(_sfc_main$1,[["__scopeId","data-v-54509002"]]);function getUrlParams(o){const c={},n=o.split("?")[1];return n&&n.split("&").forEach(v=>{const[p,e]=v.split("=");c[p]=decodeURIComponent(e)}),c}var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var vconsole_min={exports:{}};/*!
|
|
11
|
+
*/function ownKeys(o,c){var n=Object.keys(o);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(o);c&&(f=f.filter(function(v){return Object.getOwnPropertyDescriptor(o,v).enumerable})),n.push.apply(n,f)}return n}function _objectSpread2(o){for(var c=1;c<arguments.length;c++){var n=arguments[c]!=null?arguments[c]:{};c%2?ownKeys(Object(n),!0).forEach(function(f){_defineProperty(o,f,n[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(f){Object.defineProperty(o,f,Object.getOwnPropertyDescriptor(n,f))})}return o}function _classCallCheck(o,c){if(!(o instanceof c))throw new TypeError("Cannot call a class as a function")}function _defineProperties(o,c){for(var n=0;n<c.length;n++){var f=c[n];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(o,_toPropertyKey(f.key),f)}}function _createClass(o,c,n){return c&&_defineProperties(o.prototype,c),n&&_defineProperties(o,n),Object.defineProperty(o,"prototype",{writable:!1}),o}function _defineProperty(o,c,n){return c=_toPropertyKey(c),c in o?Object.defineProperty(o,c,{value:n,enumerable:!0,configurable:!0,writable:!0}):o[c]=n,o}function _extends(){return _extends=Object.assign?Object.assign.bind():function(o){for(var c=1;c<arguments.length;c++){var n=arguments[c];for(var f in n)Object.prototype.hasOwnProperty.call(n,f)&&(o[f]=n[f])}return o},_extends.apply(this,arguments)}function _toPrimitive(o,c){if(typeof o!="object"||o===null)return o;var n=o[Symbol.toPrimitive];if(n!==void 0){var f=n.call(o,c||"default");if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(o)}function _toPropertyKey(o){var c=_toPrimitive(o,"string");return typeof c=="symbol"?c:String(c)}var canvasToBlob={exports:{}};(function(o){typeof window>"u"||function(c){var n=c.HTMLCanvasElement&&c.HTMLCanvasElement.prototype,f=c.Blob&&function(){try{return!!new Blob}catch{return!1}}(),v=f&&c.Uint8Array&&function(){try{return new Blob([new Uint8Array(100)]).size===100}catch{return!1}}(),p=c.BlobBuilder||c.WebKitBlobBuilder||c.MozBlobBuilder||c.MSBlobBuilder,e=/^data:((.*?)(;charset=.*?)?)(;base64)?,/,_=(f||p)&&c.atob&&c.ArrayBuffer&&c.Uint8Array&&function(w){var y,x,C,L,$,T,D,R,k;if(y=w.match(e),!y)throw new Error("invalid data URI");for(x=y[2]?y[1]:"text/plain"+(y[3]||";charset=US-ASCII"),C=!!y[4],L=w.slice(y[0].length),C?$=atob(L):$=decodeURIComponent(L),T=new ArrayBuffer($.length),D=new Uint8Array(T),R=0;R<$.length;R+=1)D[R]=$.charCodeAt(R);return f?new Blob([v?D:T],{type:x}):(k=new p,k.append(T),k.getBlob(x))};c.HTMLCanvasElement&&!n.toBlob&&(n.mozGetAsFile?n.toBlob=function(w,y,x){var C=this;setTimeout(function(){x&&n.toDataURL&&_?w(_(C.toDataURL(y,x))):w(C.mozGetAsFile("blob",y))})}:n.toDataURL&&_&&(n.msToBlob?n.toBlob=function(w,y,x){var C=this;setTimeout(function(){(y&&y!=="image/png"||x)&&n.toDataURL&&_?w(_(C.toDataURL(y,x))):w(C.msToBlob(y))})}:n.toBlob=function(w,y,x){var C=this;setTimeout(function(){w(_(C.toDataURL(y,x)))})})),o.exports?o.exports=_:c.dataURLtoBlob=_}(window)})(canvasToBlob);var toBlob=canvasToBlob.exports,isBlob=function(c){return typeof Blob>"u"?!1:c instanceof Blob||Object.prototype.toString.call(c)==="[object Blob]"},DEFAULTS={strict:!0,checkOrientation:!0,retainExif:!1,maxWidth:1/0,maxHeight:1/0,minWidth:0,minHeight:0,width:void 0,height:void 0,resize:"none",quality:.8,mimeType:"auto",convertTypes:["image/png"],convertSize:5e6,beforeDraw:null,drew:null,success:null,error:null},IS_BROWSER=typeof window<"u"&&typeof window.document<"u",WINDOW=IS_BROWSER?window:{},isPositiveNumber=function(c){return c>0&&c<1/0},slice=Array.prototype.slice;function toArray(o){return Array.from?Array.from(o):slice.call(o)}var REGEXP_IMAGE_TYPE=/^image\/.+$/;function isImageType(o){return REGEXP_IMAGE_TYPE.test(o)}function imageTypeToExtension(o){var c=isImageType(o)?o.substr(6):"";return c==="jpeg"&&(c="jpg"),".".concat(c)}var fromCharCode=String.fromCharCode;function getStringFromCharCode(o,c,n){var f="",v;for(n+=c,v=c;v<n;v+=1)f+=fromCharCode(o.getUint8(v));return f}var btoa$1=WINDOW.btoa;function arrayBufferToDataURL(o,c){for(var n=[],f=8192,v=new Uint8Array(o);v.length>0;)n.push(fromCharCode.apply(null,toArray(v.subarray(0,f)))),v=v.subarray(f);return"data:".concat(c,";base64,").concat(btoa$1(n.join("")))}function resetAndGetOrientation(o){var c=new DataView(o),n;try{var f,v,p;if(c.getUint8(0)===255&&c.getUint8(1)===216)for(var e=c.byteLength,_=2;_+1<e;){if(c.getUint8(_)===255&&c.getUint8(_+1)===225){v=_;break}_+=1}if(v){var w=v+4,y=v+10;if(getStringFromCharCode(c,w,4)==="Exif"){var x=c.getUint16(y);if(f=x===18761,(f||x===19789)&&c.getUint16(y+2,f)===42){var C=c.getUint32(y+4,f);C>=8&&(p=y+C)}}}if(p){var L=c.getUint16(p,f),$,T;for(T=0;T<L;T+=1)if($=p+T*12+2,c.getUint16($,f)===274){$+=8,n=c.getUint16($,f),c.setUint16($,1,f);break}}}catch{n=1}return n}function parseOrientation(o){var c=0,n=1,f=1;switch(o){case 2:n=-1;break;case 3:c=-180;break;case 4:f=-1;break;case 5:c=90,f=-1;break;case 6:c=90;break;case 7:c=90,n=-1;break;case 8:c=-90;break}return{rotate:c,scaleX:n,scaleY:f}}var REGEXP_DECIMALS=/\.\d*(?:0|9){12}\d*$/;function normalizeDecimalNumber(o){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e11;return REGEXP_DECIMALS.test(o)?Math.round(o*c)/c:o}function getAdjustedSizes(o){var c=o.aspectRatio,n=o.height,f=o.width,v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"none",p=isPositiveNumber(f),e=isPositiveNumber(n);if(p&&e){var _=n*c;(v==="contain"||v==="none")&&_>f||v==="cover"&&_<f?n=f/c:f=n*c}else p?n=f/c:e&&(f=n*c);return{width:f,height:n}}function getExif(o){for(var c=toArray(new Uint8Array(o)),n=c.length,f=[],v=0;v+3<n;){var p=c[v],e=c[v+1];if(p===255&&e===218)break;if(p===255&&e===216)v+=2;else{var _=c[v+2]*256+c[v+3],w=v+_+2,y=c.slice(v,w);f.push(y),v=w}}return f.reduce(function(x,C){return C[0]===255&&C[1]===225?x.concat(C):x},[])}function insertExif(o,c){var n=toArray(new Uint8Array(o));if(n[2]!==255||n[3]!==224)return o;var f=n[4]*256+n[5],v=[255,216].concat(c,n.slice(4+f));return new Uint8Array(v)}var ArrayBuffer$1=WINDOW.ArrayBuffer,FileReader=WINDOW.FileReader,URL$1=WINDOW.URL||WINDOW.webkitURL,REGEXP_EXTENSION=/\.\w+$/,AnotherCompressor=WINDOW.Compressor,Compressor=function(){function o(c,n){_classCallCheck(this,o),this.file=c,this.exif=[],this.image=new Image,this.options=_objectSpread2(_objectSpread2({},DEFAULTS),n),this.aborted=!1,this.result=null,this.init()}return _createClass(o,[{key:"init",value:function(){var n=this,f=this.file,v=this.options;if(!isBlob(f)){this.fail(new Error("The first argument must be a File or Blob object."));return}var p=f.type;if(!isImageType(p)){this.fail(new Error("The first argument must be an image File or Blob object."));return}if(!URL$1||!FileReader){this.fail(new Error("The current browser does not support image compression."));return}ArrayBuffer$1||(v.checkOrientation=!1,v.retainExif=!1);var e=p==="image/jpeg",_=e&&v.checkOrientation,w=e&&v.retainExif;if(URL$1&&!_&&!w)this.load({url:URL$1.createObjectURL(f)});else{var y=new FileReader;this.reader=y,y.onload=function(x){var C=x.target,L=C.result,$={},T=1;_&&(T=resetAndGetOrientation(L),T>1&&_extends($,parseOrientation(T))),w&&(n.exif=getExif(L)),_||w?!URL$1||T>1?$.url=arrayBufferToDataURL(L,p):$.url=URL$1.createObjectURL(f):$.url=L,n.load($)},y.onabort=function(){n.fail(new Error("Aborted to read the image with FileReader."))},y.onerror=function(){n.fail(new Error("Failed to read the image with FileReader."))},y.onloadend=function(){n.reader=null},_||w?y.readAsArrayBuffer(f):y.readAsDataURL(f)}}},{key:"load",value:function(n){var f=this,v=this.file,p=this.image;p.onload=function(){f.draw(_objectSpread2(_objectSpread2({},n),{},{naturalWidth:p.naturalWidth,naturalHeight:p.naturalHeight}))},p.onabort=function(){f.fail(new Error("Aborted to load the image."))},p.onerror=function(){f.fail(new Error("Failed to load the image."))},WINDOW.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(WINDOW.navigator.userAgent)&&(p.crossOrigin="anonymous"),p.alt=v.name,p.src=n.url}},{key:"draw",value:function(n){var f=this,v=n.naturalWidth,p=n.naturalHeight,e=n.rotate,_=e===void 0?0:e,w=n.scaleX,y=w===void 0?1:w,x=n.scaleY,C=x===void 0?1:x,L=this.file,$=this.image,T=this.options,D=document.createElement("canvas"),R=D.getContext("2d"),k=Math.abs(_)%180===90,P=(T.resize==="contain"||T.resize==="cover")&&isPositiveNumber(T.width)&&isPositiveNumber(T.height),A=Math.max(T.maxWidth,0)||1/0,F=Math.max(T.maxHeight,0)||1/0,H=Math.max(T.minWidth,0)||0,B=Math.max(T.minHeight,0)||0,j=v/p,V=T.width,J=T.height;if(k){var re=[F,A];A=re[0],F=re[1];var ae=[B,H];H=ae[0],B=ae[1];var be=[J,V];V=be[0],J=be[1]}P&&(j=V/J);var le=getAdjustedSizes({aspectRatio:j,width:A,height:F},"contain");A=le.width,F=le.height;var Oe=getAdjustedSizes({aspectRatio:j,width:H,height:B},"cover");if(H=Oe.width,B=Oe.height,P){var Te=getAdjustedSizes({aspectRatio:j,width:V,height:J},T.resize);V=Te.width,J=Te.height}else{var De=getAdjustedSizes({aspectRatio:j,width:V,height:J}),K=De.width;V=K===void 0?v:K;var X=De.height;J=X===void 0?p:X}V=Math.floor(normalizeDecimalNumber(Math.min(Math.max(V,H),A))),J=Math.floor(normalizeDecimalNumber(Math.min(Math.max(J,B),F)));var me=-V/2,xe=-J/2,se=V,Y=J,N=[];if(P){var q=0,ee=0,he=v,Ie=p,Fe=getAdjustedSizes({aspectRatio:j,width:v,height:p},{contain:"cover",cover:"contain"}[T.resize]);he=Fe.width,Ie=Fe.height,q=(v-he)/2,ee=(p-Ie)/2,N.push(q,ee,he,Ie)}if(N.push(me,xe,se,Y),k){var We=[J,V];V=We[0],J=We[1]}D.width=V,D.height=J,isImageType(T.mimeType)||(T.mimeType=L.type);var Se="transparent";L.size>T.convertSize&&T.convertTypes.indexOf(T.mimeType)>=0&&(T.mimeType="image/jpeg");var Be=T.mimeType==="image/jpeg";if(Be&&(Se="#fff"),R.fillStyle=Se,R.fillRect(0,0,V,J),T.beforeDraw&&T.beforeDraw.call(this,R,D),!this.aborted&&(R.save(),R.translate(V/2,J/2),R.rotate(_*Math.PI/180),R.scale(y,C),R.drawImage.apply(R,[$].concat(N)),R.restore(),T.drew&&T.drew.call(this,R,D),!this.aborted)){var ze=function(Ye){if(!f.aborted){var Ae=function(dt){return f.done({naturalWidth:v,naturalHeight:p,result:dt})};if(Ye&&Be&&T.retainExif&&f.exif&&f.exif.length>0){var je=function(dt){return Ae(toBlob(arrayBufferToDataURL(insertExif(dt,f.exif),T.mimeType)))};if(Ye.arrayBuffer)Ye.arrayBuffer().then(je).catch(function(){f.fail(new Error("Failed to read the compressed image with Blob.arrayBuffer()."))});else{var Re=new FileReader;f.reader=Re,Re.onload=function(it){var dt=it.target;je(dt.result)},Re.onabort=function(){f.fail(new Error("Aborted to read the compressed image with FileReader."))},Re.onerror=function(){f.fail(new Error("Failed to read the compressed image with FileReader."))},Re.onloadend=function(){f.reader=null},Re.readAsArrayBuffer(Ye)}}else Ae(Ye)}};D.toBlob?D.toBlob(ze,T.mimeType,T.quality):ze(toBlob(D.toDataURL(T.mimeType,T.quality)))}}},{key:"done",value:function(n){var f=n.naturalWidth,v=n.naturalHeight,p=n.result,e=this.file,_=this.image,w=this.options;if(URL$1&&_.src.indexOf("blob:")===0&&URL$1.revokeObjectURL(_.src),p)if(w.strict&&!w.retainExif&&p.size>e.size&&w.mimeType===e.type&&!(w.width>f||w.height>v||w.minWidth>f||w.minHeight>v||w.maxWidth<f||w.maxHeight<v))p=e;else{var y=new Date;p.lastModified=y.getTime(),p.lastModifiedDate=y,p.name=e.name,p.name&&p.type!==e.type&&(p.name=p.name.replace(REGEXP_EXTENSION,imageTypeToExtension(p.type)))}else p=e;this.result=p,w.success&&w.success.call(this,p)}},{key:"fail",value:function(n){var f=this.options;if(f.error)f.error.call(this,n);else throw n}},{key:"abort",value:function(){this.aborted||(this.aborted=!0,this.reader?this.reader.abort():this.image.complete?this.fail(new Error("The compression process has been aborted.")):(this.image.onload=null,this.image.onabort()))}}],[{key:"noConflict",value:function(){return window.Compressor=AnotherCompressor,o}},{key:"setDefaults",value:function(n){_extends(DEFAULTS,n)}}]),o}();const processImage=async o=>{if(console.log(o,"file"),!!o)return new Promise((c,n)=>{new Compressor(o,{quality:.6,mimeType:o.type,success(f){const v=new File([f],o.name,{type:o.type,lastModified:o.lastModified});console.log(v),c(v)},error(f){console.log(f.message),n(f)}})})},takePhoto=()=>new Promise((o,c)=>{var n=document.createElement("input");n.type="file",n.accept="image/*",n.capture="camera",n.style.display="none",document.body.appendChild(n);let f=new FormData;n.onchange=async function(v){console.log("ddd");var p=v.target.files[0];try{const e=await processImage(p);f.append("invoiceFiles",e),document.body.removeChild(n),o(f)}catch(e){console.log(e),document.body.removeChild(n),c(e)}},n.click()}),selectPhoto=async o=>new Promise((c,n)=>{var f=document.createElement("input");f.type="file",f.accept="image/*",f.multiple=o,f.style.display="none",document.body.appendChild(f);let v=new FormData;f.onchange=async function(p){var e=p.target.files;if(e.length>9){f.value="";return}for(let _=0;_<e.length;_++){const w=e[_];try{const y=await processImage(w);v.append("invoiceFiles",y),document.body.removeChild(f),c(v)}catch(y){console.log(y),document.body.removeChild(f),n(y)}}},f.click()}),const_invoiceStatus={invalid:"无效发票",unused:"未使用",using:"使用中",used:"已使用"},const_realStatus={noNeed:"无需验真",notCheck:"未验真",checked:"已验真",checkFail:"验真失败"},setClass=o=>{switch(o){case"invalid":return"error";case"unused":return"warning";case"using":return"ok";case"used":return"default";case"noNeed":return"ok";case"notCheck":return"warning";case"checked":return"ok";case"checkFail":return"error";default:return"ok"}},_withScopeId$1=o=>(vue.pushScopeId("data-v-fae0d232"),o=o(),vue.popScopeId(),o),_hoisted_1$2={class:"InvoiceList"},_hoisted_2$1={class:"card"},_hoisted_3$1=["onClick"],_hoisted_4$1={class:"li"},_hoisted_5$1={key:0,class:"item-card"},_hoisted_6$1={class:"storeName"},_hoisted_7$1={class:"name"},_hoisted_8$1={class:"left"},_hoisted_9={key:0,class:"right"},_hoisted_10={class:"tags"},_hoisted_11={class:"InvoiceInfo"},_hoisted_12={class:"leftinfo"},_hoisted_13={class:"item-info"},_hoisted_14=_withScopeId$1(()=>vue.createElementVNode("span",{class:"label"},"发票金额",-1)),_hoisted_15={class:"value price"},_hoisted_16={class:"item-info"},_hoisted_17=_withScopeId$1(()=>vue.createElementVNode("span",{class:"label"},"发票抬头",-1)),_hoisted_18={class:"value"},_hoisted_19={class:"item-info"},_hoisted_20=_withScopeId$1(()=>vue.createElementVNode("span",{class:"label"},"发票类型",-1)),_hoisted_21={class:"value"},_hoisted_22={class:"item-info"},_hoisted_23=_withScopeId$1(()=>vue.createElementVNode("span",{class:"label"},"发票时间",-1)),_hoisted_24={class:"value"},_hoisted_25={class:"rightCheckbox"},_hoisted_26={key:1,style:{"background-color":"#fff",padding:"21px 0 15px 12px",position:"relative",width:"100%"}},_hoisted_27={key:2,class:"err-card"},_hoisted_28={class:"left-img"},_hoisted_29=["src"],_hoisted_30={class:"right-errText"},_hoisted_31=_withScopeId$1(()=>vue.createElementVNode("div",{class:"title"},[vue.createElementVNode("span",null,"识别失败")],-1)),_hoisted_32={class:"content"},_hoisted_33=_withScopeId$1(()=>vue.createElementVNode("div",{class:"recognitionResult"},[vue.createElementVNode("p",{class:"errContent"},"OCR识别失败"),vue.createElementVNode("p",null,"可以重新拍照识别,或手动添加信息导入")],-1)),_hoisted_34={class:"boxPopup"},_hoisted_35=_withScopeId$1(()=>vue.createElementVNode("div",{class:"title"},[vue.createElementVNode("span",null,"添加发票")],-1)),_sfc_main$2=vue.defineComponent({__name:"index",props:{listId:{required:!0,type:String},multiple:{required:!0,type:Boolean}},emits:["edit","ok"],setup(o,{emit:c}){const{listId:n,multiple:f}=o,v=vue.ref(sessionStorage.getItem("token")),p=vue.ref(!1),e=vue.ref(!1),_=vue.ref([]),w=vue.ref(""),y=vue.computed(()=>_.value.filter(k=>k.selected).map(k=>k.taskId)),x=async()=>new Promise(async(k,P)=>{const A={};A.batchId=n;try{const F=await __getUploadInvoiceList(A,v.value);console.log(F),F.code===200&&(_.value=F.data.invoiceList.map(H=>({...H,selected:!1})),w.value=F.data.batchId,k(_.value))}catch(F){console.log(F),P(F)}}),C=k=>{k.taskStatus!=="finish"&&k.taskStatus!=="repeat"||c("edit",{taskId:k.taskId,batchId:w.value},k)},L=()=>{if(y.value.length<=0){showToast({type:"text",message:"请先选择发票"});return}showConfirmDialog({title:"提醒",message:"请确认是否需要删除选中项,删除后不可恢复!"}).then(async()=>{var k=new URLSearchParams;k.append("batchId",w.value);const P=y.value.join(",");k.append("taskIds",P),(await __deleteInvoice(k,v.value)).code===200&&(showToast({type:"success",message:"删除成功"}),x())}).catch(()=>{})},$=()=>{e.value=!0},T=async k=>{let P;k===1?P=await selectPhoto(f):P=await takePhoto(),P.append("batchId",w.value),p.value=!0,e.value=!1;try{(await __uploadInvoice(P)).code===200&&(showToast({type:"success",message:"上传成功"}),R())}catch(A){console.log(A),R()}p.value=!1},D=()=>{if(y.value.length<=0){showToast({type:"text",message:"请先选择发票"});return}const k=_.value.filter(P=>P.selected);console.log(k),c("ok",k)};vue.ref(null);const R=()=>{x().then(k=>{k.some(A=>A.taskStatus==="ocr_doing"||A.taskStatus==="ocr_success")&&setTimeout(R,2e3)}).catch(k=>{setTimeout(R,2e3)})};return vue.onMounted(()=>{R()}),(k,P)=>(vue.openBlock(),vue.createElementBlock(vue.Fragment,null,[vue.createElementVNode("div",_hoisted_1$2,[vue.createElementVNode("div",_hoisted_2$1,[vue.createElementVNode("ul",null,[(vue.openBlock(!0),vue.createElementBlock(vue.Fragment,null,vue.renderList(_.value,(A,F)=>(vue.openBlock(),vue.createElementBlock("li",{key:F,onClick:H=>C(A)},[vue.createElementVNode("div",_hoisted_4$1,[A.taskStatus==="finish"||A.taskStatus==="repeat"?(vue.openBlock(),vue.createElementBlock("div",_hoisted_5$1,[vue.createElementVNode("div",{class:vue.normalizeClass(["title",{person:A.invoiceCompanyType==="公司"}])},vue.toDisplayString(A.invoiceCompanyType),3),vue.createElementVNode("div",_hoisted_6$1,[vue.createElementVNode("div",_hoisted_7$1,[vue.createElementVNode("div",_hoisted_8$1,vue.toDisplayString(A.sellerName),1),A.taskStatus==="repeat"?(vue.openBlock(),vue.createElementBlock("div",_hoisted_9," 重复录入 ")):vue.createCommentVNode("",!0)]),vue.createElementVNode("div",_hoisted_10,[vue.createElementVNode("span",{class:vue.normalizeClass(vue.unref(setClass)(A.realStatus))},vue.toDisplayString(vue.unref(const_realStatus)[A.realStatus]),3),vue.createElementVNode("span",{class:vue.normalizeClass(vue.unref(setClass)(A.invoiceStatus))},vue.toDisplayString(vue.unref(const_invoiceStatus)[A.invoiceStatus]),3)]),vue.createElementVNode("div",_hoisted_11,[vue.createElementVNode("div",_hoisted_12,[vue.createElementVNode("div",_hoisted_13,[_hoisted_14,vue.createElementVNode("span",_hoisted_15,"¥"+vue.toDisplayString(A.noTaxAmountTotal),1)]),vue.createElementVNode("div",_hoisted_16,[_hoisted_17,vue.createElementVNode("span",_hoisted_18,vue.toDisplayString(A.payerName),1)]),vue.createElementVNode("div",_hoisted_19,[_hoisted_20,vue.createElementVNode("span",_hoisted_21,vue.toDisplayString(A.description),1)]),vue.createElementVNode("div",_hoisted_22,[_hoisted_23,vue.createElementVNode("span",_hoisted_24,vue.toDisplayString(A.invoiceDate),1)])]),vue.createElementVNode("div",_hoisted_25,[vue.createVNode(vue.unref(Checkbox),{onClick:P[0]||(P[0]=vue.withModifiers(()=>{},["stop"])),modelValue:A.selected,"onUpdate:modelValue":H=>A.selected=H,"icon-size":"22px"},null,8,["modelValue","onUpdate:modelValue"])])])])])):A.taskStatus==="ocr_doing"||A.taskStatus==="ocr_success"?(vue.openBlock(),vue.createElementBlock("div",_hoisted_26,[vue.createVNode(vue.unref(Loading),{class:"loading",color:"#0094ff"},{default:vue.withCtx(()=>[vue.createTextVNode("识别中...")]),_:1}),vue.createVNode(vue.unref(Skeleton),{loading:!0,title:"",row:6})])):(vue.openBlock(),vue.createElementBlock("div",_hoisted_27,[vue.createElementVNode("div",_hoisted_28,[vue.createElementVNode("img",{src:A.attachmentLink,alt:""},null,8,_hoisted_29)]),vue.createElementVNode("div",_hoisted_30,[_hoisted_31,vue.createElementVNode("div",_hoisted_32,[_hoisted_33,vue.createElementVNode("div",null,[vue.createVNode(vue.unref(Checkbox),{onClick:P[1]||(P[1]=vue.withModifiers(()=>{},["stop"])),modelValue:A.selected,"onUpdate:modelValue":H=>A.selected=H,"icon-size":"22px"},null,8,["modelValue","onUpdate:modelValue"])])])])]))])],8,_hoisted_3$1))),128))])]),vue.createElementVNode("div",{class:"btn-form"},[vue.createElementVNode("div",{class:"operate"},[vue.createElementVNode("div",{class:"delete"},[vue.createElementVNode("span",{onClick:L},"删除")]),vue.createElementVNode("div",{class:"right-btn"},[vue.createElementVNode("span",{class:"add",onClick:$},"继续添加发票"),vue.createElementVNode("span",{class:"ok",onClick:D},"确定选择")])])])]),vue.createVNode(vue.unref(Popup),{show:e.value,"onUpdate:show":P[4]||(P[4]=A=>e.value=A),position:"bottom",closeable:""},{default:vue.withCtx(()=>[vue.createElementVNode("div",_hoisted_34,[_hoisted_35,vue.createElementVNode("div",{style:{"padding-bottom":"24px"},onClick:P[2]||(P[2]=A=>T(1))},"从相册中选择"),vue.createElementVNode("div",{onClick:P[3]||(P[3]=A=>T(2))},"拍照上传")])]),_:1},8,["show"]),vue.createVNode(vue.unref(Overlay),{style:{display:"flex","justify-content":"center","align-items":"center"},show:p.value},{default:vue.withCtx(()=>[vue.createVNode(vue.unref(Loading),{class:"loading",color:"#0094ff"},{default:vue.withCtx(()=>[vue.createTextVNode("上传中...")]),_:1})]),_:1},8,["show"])],64))}}),index_vue_vue_type_style_index_0_scoped_fae0d232_lang="",InvoiceList=_export_sfc(_sfc_main$2,[["__scopeId","data-v-fae0d232"]]),_withScopeId=o=>(vue.pushScopeId("data-v-54509002"),o=o(),vue.popScopeId(),o),_hoisted_1$1={class:"PaymentMode"},_hoisted_2=_withScopeId(()=>vue.createElementVNode("div",{class:"title"},"选择识别方式",-1)),_hoisted_3={class:"list"},_hoisted_4=["onClick"],_hoisted_5={class:"left-text"},_hoisted_6={class:"icon-left"},_hoisted_7={class:"text"},_hoisted_8=_withScopeId(()=>vue.createElementVNode("div",{class:"right-icon"},[vue.createElementVNode("i",{class:"iconfont icon-xiangyou"})],-1)),_sfc_main$1=vue.defineComponent({__name:"index",props:["multiple"],emits:["uploadSuccess"],setup(o,{emit:c}){const{multiple:n}=o,f=[{text:"拍照",leftIcon:"icon-xiangji"},{text:"相册",leftIcon:"icon-xiangce"}];document.title="请选择添加费用方式";const v=vue.ref(!1),p=async e=>{let _;e=="拍照"&&(_=await takePhoto()),e=="相册"&&(_=await selectPhoto(n)),v.value=!0;try{const w=await __uploadInvoice(_);console.log(w),w.code===200&&(showToast({type:"success",message:"上传成功"}),c("uploadSuccess",w.data))}catch(w){console.log(w),showFailToast("上传失败")}v.value=!1};return(e,_)=>(vue.openBlock(),vue.createElementBlock(vue.Fragment,null,[vue.createElementVNode("div",_hoisted_1$1,[_hoisted_2,vue.createElementVNode("div",_hoisted_3,[(vue.openBlock(),vue.createElementBlock(vue.Fragment,null,vue.renderList(f,(w,y)=>vue.createElementVNode("div",{class:"method-item",onClick:x=>p(w.text),key:w.id||y},[vue.createElementVNode("div",_hoisted_5,[vue.createElementVNode("span",_hoisted_6,[vue.createElementVNode("i",{class:vue.normalizeClass(["iconfont",w.leftIcon])},null,2)]),vue.createElementVNode("span",_hoisted_7,vue.toDisplayString(w.text),1)]),_hoisted_8],8,_hoisted_4)),64))])]),vue.createVNode(vue.unref(Overlay),{style:{display:"flex","justify-content":"center","align-items":"center"},show:v.value},{default:vue.withCtx(()=>[vue.createVNode(vue.unref(Loading),{class:"loading",color:"#0094ff"},{default:vue.withCtx(()=>[vue.createTextVNode("上传中...")]),_:1})]),_:1},8,["show"])],64))}}),index_vue_vue_type_style_index_0_scoped_54509002_lang="",PaymentMode=_export_sfc(_sfc_main$1,[["__scopeId","data-v-54509002"]]);function getUrlParams(o){const c={},n=o.split("?")[1];return n&&n.split("&").forEach(v=>{const[p,e]=v.split("=");c[p]=decodeURIComponent(e)}),c}var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var vconsole_min={exports:{}};/*!
|
|
12
12
|
* vConsole v3.15.1 (https://github.com/Tencent/vConsole)
|
|
13
13
|
*
|
|
14
14
|
* Tencent is pleased to support the open source community by making vConsole available.
|