import{h as M,a as S}from"./shopStock.64721617.js";import{r as x}from"./responseHandle.fe68d5aa.js";import{u as G}from"./useNav.5e73c372.js";import{F as H}from"./status.2b37e8be.js";import{_ as I,g as W}from"./goodDetail.config.df7d45a7.js";import{a as Y,r,W as Z,b as d,a7 as z,Z as J,c as v,j as _,h as l,f as t,e as K,i as Q,u as b,F as X,l as E,x as A,am as ee,an as ae}from"./index.4d061c66.js";const ie=Y({__name:"edit-dialog",emits:["reload"],setup(le,{expose:N,emit:k}){const{logout:B}=G(),f=r(!1),n=r("create"),D=r(null),y=r(null),s=r(!1),p=r(""),F=r(0),h=r(""),V={id:"",number:1,inventory:0,flag:"1"},u=r({...V}),U=Z({number:[{required:!0,trigger:"change",message:"\u8BF7\u9009\u62E9\u53D8\u52A8\u6570\uFF01"}],flag:[{required:!0,trigger:"change",message:"\u9009\u62E9\u53D8\u52A8\u7C7B\u578B"}]}),j=async()=>{const{code:m,data:e,message:i}=await M({id:h.value});x({code:m,message:i,logout:B,handler:()=>{Object.keys(u.value).forEach(a=>{a==="flag"?u.value[a]="1":a==="id"?u.value[a]=e[a]?e[a]+"":"":u.value[a]=e[a]?Number(e[a]+""):0}),F.value=Number(e.inventory),y.value.reload({id:e.good_id})}})};async function O(m,e,i){switch(h.value=e,s.value=!0,Object.keys(u.value).forEach(a=>{u.value[a]=V[a]}),n.value=i,n.value){case"create":p.value="\u65B0\u5EFA\u5151\u6362\u5546\u54C1\u5E93\u5B58";break;case"edit":p.value="\u7F16\u8F91\u5151\u6362\u5546\u54C1\u5E93\u5B58";break;case"view":p.value="\u5151\u6362\u5546\u54C1\u5E93\u5B58\u8BE6\u60C5";break;default:p.value="\u65B0\u5EFA\u5151\u6362\u5546\u54C1\u5E93\u5B58"}f.value=!0,n.value!=="create"&&await j(),s.value=!1}function P(){return{data:{...u.value},api:S}}function R(){D.value.validate(async m=>{if(m){if(s.value)return;s.value=!0;const e=P,{api:i,data:a}=e(),{flag:c,number:C}=a;if(c==="-1"&&Number(C)>Number(F.value)){ae.warning(`\u51CF\u5C11\u5E93\u5B58\u64CD\u4F5C\u65F6\uFF0C\u53D8\u52A8\u5E93\u5B58\u4E0D\u80FD\u5927\u4E8E\u5F53\u524D\u5E93\u5B58${F.value}\uFF01`),s.value=!1;return}const{message:w,code:g}=await i(a);s.value=!1,x({code:g,message:w,logout:B,handler:()=>{f.value=!1,k("reload")}})}})}return N({show:O}),(m,e)=>{const i=d("el-input-number"),a=d("el-form-item"),c=d("el-col"),C=d("el-option"),w=d("el-select"),g=d("el-button"),T=d("el-row"),$=d("el-dialog"),q=z("loading");return J((v(),_($,{modelValue:f.value,"onUpdate:modelValue":e[4]||(e[4]=o=>f.value=o),"close-on-press-escape":!1,center:"","append-to-body":"","destroy-on-close":"",width:"1040px",title:p.value},{default:l(()=>[t(b(ee),{ref_key:"formRef",ref:D,model:u.value,rules:U,"label-width":"100px",style:{"margin-top":"-10px"},class:"demo-ruleForm","status-icon":""},{default:l(()=>[t(T,null,{default:l(()=>[t(c,{span:6},{default:l(()=>[t(a,{label:"\u5F53\u524D\u5E93\u5B58\u6570",prop:"inventory"},{default:l(()=>[t(i,{modelValue:u.value.inventory,"onUpdate:modelValue":e[0]||(e[0]=o=>u.value.inventory=o),step:1,min:0,disabled:!0,precision:0,style:{width:"100%"},max:99999999,"value-on-clear":"min","controls-position":"right","step-strictly":""},null,8,["modelValue"])]),_:1})]),_:1}),n.value!=="view"?(v(),_(c,{key:0,span:6},{default:l(()=>[t(a,{label:"\u53D8\u52A8\u7C7B\u578B",prop:"flag"},{default:l(()=>[t(w,{modelValue:u.value.flag,"onUpdate:modelValue":e[1]||(e[1]=o=>u.value.flag=o),placeholder:"\u53D8\u52A8\u7C7B\u578B",disabled:n.value==="view",style:{width:"100%"}},{default:l(()=>[(v(!0),K(X,null,Q(b(H),(o,L)=>(v(),_(C,{label:o.label,value:o.id,key:o.id+L},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"])]),_:1})]),_:1})):E("",!0),n.value!=="view"?(v(),_(c,{key:1,span:6},{default:l(()=>[t(a,{label:"\u53D8\u52A8\u6570\u91CF",prop:"number"},{default:l(()=>[t(i,{modelValue:u.value.number,"onUpdate:modelValue":e[2]||(e[2]=o=>u.value.number=o),step:1,min:1,disabled:n.value==="view",precision:0,style:{width:"100%"},max:99999999,"value-on-clear":"min","controls-position":"right","step-strictly":""},null,8,["modelValue","disabled"])]),_:1})]),_:1})):E("",!0),t(c,{span:n.value!=="view"?6:18,class:"flex justify-end"},{default:l(()=>[n.value!=="view"?(v(),_(g,{key:0,loading:s.value,disabled:s.value,type:"primary",onClick:R},{default:l(()=>[A("\u4FDD\u5B58")]),_:1},8,["loading","disabled"])):E("",!0),t(g,{onClick:e[3]||(e[3]=o=>f.value=!1)},{default:l(()=>[A("\u53D6\u6D88")]),_:1})]),_:1},8,["span"]),t(c,{span:24},{default:l(()=>[t(a,{label:"\u5546\u54C1\u4FE1\u606F"},{default:l(()=>[t(b(I),{ref_key:"PageDetailRef",ref:y,contentConfig:b(W)},null,8,["contentConfig"])]),_:1})]),_:1})]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])),[[q,s.value]])}}});export{ie as _};
