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