import{d as w,r as E,p as A,s as S,o as V,dx as h,c as x,e as c,k as P,i as _,g as s,H as k,t as D,f as v,A as B,m as F,F as y,j as q,u as I,q as K,E as p,R as N,S as L,_ as M}from"./index.0308b213.js";const $=a=>(N("data-v-0736815c"),a=a(),L(),a),R={class:"my-header"},T=["id"],U={key:0,class:"discount-tabs"},j={class:"main"},z={class:"amount"},H={key:0,class:"quick-discount"},Q=$(()=>s("div",{class:"quick-discount-label"},"\u5E38\u7528\u6298\u6263\uFF1A",-1)),G={class:"quick-discount-buttons"},J={class:"keyboard"},O=["onClick"],W=F(" \u786E\u8BA4 "),X=$(()=>s("p",null,"[Enter]",-1)),Y=[W,X],Z=w({props:{show:{type:Boolean,default:!1},title:{type:String,default:""},amount:{type:Number,default:0},isCheckEnabled:{type:Boolean,default:!1}},emits:["update:show","save"],setup(a,{emit:C}){const o=a,u=E(""),l=E("amount");A(()=>o.show,t=>{t&&(u.value="",l.value="amount")});const f=S({get(){return o.show},set(t){u.value="",C("update:show",t)}});function i(t){typeof t=="string"?t==="del"?u.value=u.value.slice(0,-1):t==="clear"?u.value="":t==="."?u.value.includes(".")||(u.value+="."):t==="00"&&(u.value+="00"):typeof t=="number"&&(u.value+=t.toString());const e=u.value.split(".");e.length>1&&e[1].length>2&&(u.value=e[0]+"."+e[1].substring(0,2)),o.title==="\u51CF\u514D\u91D1\u989D"?l.value==="amount"&&o.isCheckEnabled?(parseFloat(u.value)||0)>o.amount&&(p.error("\u51CF\u514D\u91D1\u989D\u4E0D\u80FD\u8D85\u8FC7\u8BA2\u5355\u91D1\u989D"),u.value=o.amount.toString()):l.value==="percent"&&(parseFloat(u.value)||0)>100&&(p.error("\u6298\u6263\u6BD4\u4F8B\u4E0D\u80FD\u8D85\u8FC7100%"),u.value="100"):o.isCheckEnabled&&(parseFloat(u.value)||0)>o.amount&&(p.error("\u8F93\u5165\u91D1\u989D\u4E0D\u80FD\u8D85\u8FC7"+o.amount),u.value=o.amount.toString())}function g(){if(!u.value){p.error("\u8BF7\u8F93\u5165\u91D1\u989D");return}if(o.title==="\u51CF\u514D\u91D1\u989D"&&l.value==="percent"){const t=parseFloat(u.value)||0;if(t<=0||t>100){p.error("\u8BF7\u8F93\u5165\u6709\u6548\u7684\u6298\u6263\u6BD4\u4F8B(1-100)");return}const e=o.amount*(100-t)/100;C("save",{value:e.toFixed(2),title:o.title,type:"percent",percent:t})}else C("save",{value:u.value,title:o.title});f.value=!1}function b(t){t.key==="Enter"&&g(),t.key==="Backspace"&&(u.value=u.value.slice(0,-1)),["0","1","2","3","4","5","6","7","8","9"].includes(t.key)&&i(+t.key),["."].includes(t.key)&&i(t.key)}V(()=>{document.addEventListener("keydown",b)}),h(()=>{document.removeEventListener("keydown",b)});function d(t){u.value=t.toString()}return(t,e)=>{const m=x("el-dialog");return c(),P(m,{modelValue:I(f),"onUpdate:modelValue":e[13]||(e[13]=n=>K(f)?f.value=n:null),width:"500px",class:"my-dialog"},{header:_(({titleId:n,titleClass:r})=>[s("div",R,[s("h4",{id:n,class:k(r)},D(a.title),11,T)])]),default:_(()=>[a.title==="\u51CF\u514D\u91D1\u989D"?(c(),v("div",U,[s("div",{class:k({active:l.value==="amount"}),onClick:e[0]||(e[0]=n=>l.value="amount")}," \u91D1\u989D\u51CF\u514D ",2),s("div",{class:k({active:l.value==="percent"}),onClick:e[1]||(e[1]=n=>l.value="percent")}," \u6574\u5355\u6253\u6298 ",2)])):B("",!0),s("div",j,[s("div",z,[l.value==="percent"?(c(),v(y,{key:0},[F(D(u.value)+"%",1)],64)):(c(),v(y,{key:1},[F("\uFFE5"+D(u.value),1)],64))]),l.value==="percent"?(c(),v("div",H,[Q,s("div",G,[s("div",{class:"discount-btn",onClick:e[2]||(e[2]=n=>d(95))},"95\u6298"),s("div",{class:"discount-btn",onClick:e[3]||(e[3]=n=>d(90))},"9\u6298"),s("div",{class:"discount-btn",onClick:e[4]||(e[4]=n=>d(88))},"88\u6298"),s("div",{class:"discount-btn",onClick:e[5]||(e[5]=n=>d(80))},"8\u6298"),s("div",{class:"discount-btn",onClick:e[6]||(e[6]=n=>d(70))},"7\u6298"),s("div",{class:"discount-btn",onClick:e[7]||(e[7]=n=>d(50))},"5\u6298")])])):B("",!0),s("div",J,[(c(),v(y,null,q(10,(n,r)=>s("div",{class:k(`key-${r}`),key:r,onClick:ee=>i(r)},D(r),11,O)),64)),s("div",{class:"key-00",onClick:e[8]||(e[8]=n=>i("00"))},"00"),s("div",{class:"key-point",onClick:e[9]||(e[9]=n=>i("."))},"."),s("div",{class:"key-del",onClick:e[10]||(e[10]=n=>i("del"))},"\u5220\u9664[Del]"),s("div",{class:"key-clear",onClick:e[11]||(e[11]=n=>i("clear"))},"\u6E05\u7A7A"),s("div",{class:"key-enter",onClick:e[12]||(e[12]=n=>g())},Y)])])]),_:1},8,["modelValue"])}}});const ue=M(Z,[["__scopeId","data-v-0736815c"]]);export{ue as default};
