index-9a895eb5.js
2.69 KB
var m=(t,o,e)=>new Promise((a,u)=>{var l=n=>{try{r(e.next(n))}catch(c){u(c)}},s=n=>{try{r(e.throw(n))}catch(c){u(c)}},r=n=>n.done?a(n.value):Promise.resolve(n.value).then(l,s);r((e=e.apply(t,o)).next())});import{ai as $,c as B,r as b,_ as v,h as I,aj as C}from"./index.js";import{k as p,u as i,d as _,e as h,s as z,a8 as d,_ as w,a9 as S,aa as f,E as F,a1 as k,ad as y,ae as A,ab as D,R as N,aj as T,ak as j,f as E}from"./vue-5a35c3f5.js";import{a5 as O}from"./antd-6b087f69.js";import{u as P}from"./useFormItem-9ea791b8.js";function R(t){const o=p(t),e=p(!1);let a;function u(){a&&window.clearInterval(a)}function l(){e.value=!1,u(),a=null}function s(){i(e)||a||(e.value=!0,a=setInterval(()=>{i(o)===1?(l(),o.value=t):o.value-=1},1e3))}function r(){o.value=t,l()}function n(){r(),s()}return $(()=>{r()}),{start:s,reset:r,restart:n,clear:u,stop:l,currentCount:o,isStart:e}}const V={value:{type:[Object,Number,String,Array]},count:{type:Number,default:60},beforeStartFunc:{type:Function,default:null}},L=_({name:"CountButton",components:{Button:O},props:V,setup(t){const o=p(!1),{currentCount:e,isStart:a,start:u,reset:l}=R(t.count),{t:s}=B(),r=h(()=>i(a)?s("component.countdown.sendText",[i(e)]):s("component.countdown.normalText"));z(()=>{t.value===void 0&&l()});function n(){return m(this,null,function*(){const{beforeStartFunc:c}=t;if(c&&b(c)){o.value=!0;try{(yield c())&&u()}finally{o.value=!1}}else u()})}return{handleStart:n,currentCount:e,loading:o,getButtonText:r,isStart:a}}});function U(t,o,e,a,u,l){const s=d("Button");return w(),S(s,y(t.$attrs,{disabled:t.isStart,onClick:t.handleStart,loading:t.loading}),{default:f(()=>[F(k(t.getButtonText),1)]),_:1},16,["disabled","onClick","loading"])}const g=v(L,[["render",U],["__file","E:/allcode/erp/test7901/order-erp-front/src/components/CountDown/src/CountButton.vue"]]),q={value:{type:String},size:{type:String,validator:t=>["default","large","small"].includes(t)},count:{type:Number,default:60},sendCodeApi:{type:Function,default:null}},G=_({name:"CountDownInput",components:{CountButton:g},inheritAttrs:!1,props:q,setup(t){const{prefixCls:o}=I("countdown-input"),[e]=P(t);return{prefixCls:o,state:e}}});function H(t,o,e,a,u,l){const s=d("CountButton"),r=d("a-input");return w(),S(r,y(t.$attrs,{class:t.prefixCls,size:t.size,value:t.state}),A({addonAfter:f(()=>[E(s,{size:t.size,count:t.count,value:t.state,beforeStartFunc:t.sendCodeApi},null,8,["size","count","value","beforeStartFunc"])]),_:2},[D(Object.keys(t.$slots).filter(n=>n!=="addonAfter"),n=>({name:n,fn:f(c=>[N(t.$slots,n,T(j(c||{})))])}))]),1040,["class","size","value"])}const J=v(G,[["render",H],["__file","E:/allcode/erp/test7901/order-erp-front/src/components/CountDown/src/CountdownInput.vue"]]),Z=C(J);C(g);export{Z as C};