import{p as M,h as T,a as U,b as $}from"./pageListModal.b8e2dd01.js";import{r as y}from"./responseHandle.fe68d5aa.js";import{u as q}from"./useNav.5e73c372.js";import"./remote-select.36ee67a3.js";import{a as O,r as s,W as S,b as p,a7 as H,c as C,e as I,Z as L,j as b,h as t,f as l,u as F,m as P,x,l as W,am as Y,F as Z,an as z}from"./index.4d061c66.js";import{_ as G}from"./ComCard.vue_vue_type_script_setup_true_lang.ad550102.js";import{_ as J}from"./ladder-table.vue_vue_type_script_setup_true_lang.8ca68982.js";const K={class:"flex justify-end"},de=O({__name:"edit-dialog",emits:["reload"],setup(Q,{expose:k,emit:V}){const h=s(null),{logout:w}=q(),c=s(!1),f=s("create"),B=s(null),d=s(!1),m=s(""),E=s(""),a=s({...{group_id:"",good_id:[]}}),D=S({group_id:[{required:!0,trigger:"change",message:"\u8BF7\u9009\u62E9\u4F01\u4E1A\u5361\u7C7B\u578B"}],good_id:[{required:!0,type:"array",trigger:"change",message:"\u8BF7\u9009\u62E9\u5546\u54C1"}]}),A=async()=>{const{code:n,data:e,message:o}=await $({id:E.value});y({code:n,message:o,logout:w,handler:()=>{Object.keys(a.value).forEach(u=>{a.value[u]=e[u]?e[u]+"":""})}})};async function N(n,e,o){switch(E.value=e,a.value={group_id:"",good_id:[]},f.value=o,f.value){case"create":m.value="\u65B0\u5EFA\u516C\u53F8\u5546\u54C1";break;case"edit":m.value="\u7F16\u8F91\u516C\u53F8\u5546\u54C1";break;case"view":m.value="\u516C\u53F8\u5546\u54C1\u8BE6\u60C5";break;default:m.value="\u65B0\u5EFA\u516C\u53F8\u5546\u54C1"}f.value!=="create"&&await A(),c.value=!0}function R(n){n.forEach(e=>{const{id:o}=e;a.value.good_id.findIndex(r=>r.id+""==o+"")==-1&&a.value.good_id.push(e)})}function j(){B.value.validate(async n=>{if(n){if(d.value)return;d.value=!0;const{group_id:e,good_id:o}=a.value;if(o.length===0){d.value=!1,z.warning("\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A\u5546\u54C1\uFF01");return}const u=[];o.forEach(g=>{u.push(g.id)});const r={group_id:e,good_id:u},{message:_,code:v}=f.value==="create"?await T(r):await U(r);d.value=!1,y({code:v,message:_,logout:w,handler:()=>{c.value=!1,V("reload")}})}})}return k({show:N}),(n,e)=>{const o=p("el-form-item"),u=p("el-col"),r=p("el-row"),_=p("el-button"),v=p("el-dialog"),g=H("loading");return C(),I(Z,null,[L((C(),b(v,{modelValue:c.value,"onUpdate:modelValue":e[4]||(e[4]=i=>c.value=i),"close-on-press-escape":!1,center:"","append-to-body":"","destroy-on-close":"",width:"1040px",title:m.value},{default:t(()=>[l(F(Y),{ref_key:"formRef",ref:B,model:a.value,rules:D,"label-width":"100px",style:{"margin-top":"-10px"},class:"demo-ruleForm","status-icon":""},{default:t(()=>[l(r,null,{default:t(()=>[l(u,{span:24},{default:t(()=>[l(o,{label:"\u516C\u53F8\u5361\u7C7B\u578B",prop:"group_id"},{default:t(()=>[l(F(G),{modelValue:a.value.group_id,"onUpdate:modelValue":e[0]||(e[0]=i=>a.value.group_id=i),placeholder:"\u516C\u53F8\u5361\u7C7B\u578B"},null,8,["modelValue"])]),_:1})]),_:1}),l(u,{span:24},{default:t(()=>[l(o,{label:"\u5546\u54C1\u5217\u8868",prop:"good_id"},{default:t(()=>[l(J,{readonly:!1,ladder:a.value.good_id,onChoose:e[1]||(e[1]=()=>h.value.show("")),onDelete:e[2]||(e[2]=i=>a.value.good_id.splice(i,1))},null,8,["ladder"])]),_:1})]),_:1})]),_:1}),P("div",K,[f.value!=="view"?(C(),b(_,{key:0,loading:d.value,disabled:d.value,type:"primary",onClick:j},{default:t(()=>[x("\u4FDD\u5B58")]),_:1},8,["loading","disabled"])):W("",!0),l(_,{onClick:e[3]||(e[3]=i=>c.value=!1)},{default:t(()=>[x("\u53D6\u6D88")]),_:1})])]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])),[[g,d.value]]),l(F(M),{ref_key:"modelRef",ref:h,onSaveBtnClick:R},null,512)],64)}}});export{de as _};
