import{b as K,d as $,e as q}from"./goods-CWDKnOy3.js";import{d as A,v as P,r as i,a as Q,G,E as r,g as n,J as X,z as g,k as y,w as a,K as Y,c as Z,e as t,t as l,x as T,b as k,H as ee,D as oe,_ as ae}from"./index-CUnFTKV2.js";const te={class:"form-tip"},le={class:"dialog-footer"},ne={class:"footer-right"},se=A({__name:"GoodsExtendDialog",props:{modelValue:{type:Boolean},goodsId:{},goodsTitle:{}},emits:["update:modelValue","success"],setup(f,{emit:W}){const u=f,v=W,b=P({get:()=>u.modelValue,set:o=>v("update:modelValue",o)}),C=i(!1),x=i(!1),V=i(!1),N=i(),m=i(null),c=i([]),s=Q({payWechat:0,payBalance:0,payCurrency:0,payCurrency2:0,payCoupon:0,isDeduction:0});G(c,o=>{s.payWechat=o.includes("wechat")?1:0,s.payBalance=o.includes("balance")?1:0,s.payCurrency=o.includes("currency")?1:0,s.payCurrency2=o.includes("currency2")?1:0,s.payCoupon=o.includes("coupon")?1:0}),G(()=>u.modelValue,async o=>{o&&u.goodsId>0&&await M()});const M=async()=>{C.value=!0;try{const o=await K(u.goodsId);if(o.code===0&&o.data){m.value=o.data,Object.assign(s,{payWechat:o.data.payWechat,payBalance:o.data.payBalance,payCurrency:o.data.payCurrency,payCurrency2:o.data.payCurrency2,payCoupon:o.data.payCoupon,isDeduction:o.data.isDeduction});const e=[];o.data.payWechat===1&&e.push("wechat"),o.data.payBalance===1&&e.push("balance"),o.data.payCurrency===1&&e.push("currency"),o.data.payCurrency2===1&&e.push("currency2"),o.data.payCoupon===1&&e.push("coupon"),c.value=e}}catch(o){console.error("加载扩展设置失败:",o),r.error("加载扩展设置失败")}finally{C.value=!1}},U=()=>{m.value=null,c.value=[],Object.assign(s,{payWechat:0,payBalance:0,payCurrency:0,payCurrency2:0,payCoupon:0,isDeduction:0})},_=()=>{b.value=!1,U()},j=async()=>{x.value=!0;try{const o=await $(u.goodsId,s);o.code===0?(r.success("保存成功"),v("success"),_()):r.error(o.message||"保存失败")}catch(o){console.error("保存扩展设置失败:",o),r.error("保存失败")}finally{x.value=!1}},z=async()=>{try{await oe.confirm("删除扩展设置后，该盒子将恢复使用盒子类型的默认支付配置，确定要删除吗？","确认删除",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"})}catch{return}V.value=!0;try{const o=await q(u.goodsId);o.code===0?(r.success("删除成功，已恢复使用类型默认配置"),v("success"),_()):r.error(o.message||"删除失败")}catch(o){console.error("删除扩展设置失败:",o),r.error("删除失败")}finally{V.value=!1}};return(o,e)=>{const B=n("el-descriptions-item"),L=n("el-descriptions"),E=n("el-alert"),p=n("el-checkbox"),O=n("el-checkbox-group"),I=n("el-form-item"),h=n("el-radio"),R=n("el-radio-group"),S=n("el-text"),F=n("el-form"),w=n("el-button"),H=n("el-dialog"),J=X("loading");return y(),g(H,{modelValue:b.value,"onUpdate:modelValue":e[2]||(e[2]=d=>b.value=d),title:`扩展设置 - ${f.goodsTitle}`,width:"600px","close-on-click-modal":!1,onClose:_},{footer:a(()=>{var d;return[k("div",le,[(d=m.value)!=null&&d.isInherited?ee("",!0):(y(),g(w,{key:0,type:"danger",plain:"",loading:V.value,onClick:z},{default:a(()=>[...e[13]||(e[13]=[l(" 删除扩展设置 ",-1)])]),_:1},8,["loading"])),k("div",ne,[t(w,{onClick:_},{default:a(()=>[...e[14]||(e[14]=[l("取消",-1)])]),_:1}),t(w,{type:"primary",loading:x.value,onClick:j},{default:a(()=>[...e[15]||(e[15]=[l(" 保存 ",-1)])]),_:1},8,["loading"])])])]}),default:a(()=>{var d;return[Y((y(),Z("div",null,[t(L,{column:2,border:"",class:"goods-info"},{default:a(()=>[t(B,{label:"盒子ID"},{default:a(()=>[l(T(f.goodsId),1)]),_:1}),t(B,{label:"盒子名称"},{default:a(()=>[l(T(f.goodsTitle),1)]),_:1})]),_:1}),(d=m.value)!=null&&d.isInherited?(y(),g(E,{key:0,type:"info",closable:!1,"show-icon":"",class:"inherit-alert"},{title:a(()=>[...e[3]||(e[3]=[l(" 当前使用盒子类型的默认支付配置，修改后将创建独立配置 ",-1)])]),_:1})):(y(),g(E,{key:1,type:"success",closable:!1,"show-icon":"",class:"inherit-alert"},{title:a(()=>[...e[4]||(e[4]=[l(' 当前使用独立支付配置，可点击"删除扩展设置"恢复使用类型默认配置 ',-1)])]),_:1})),t(F,{ref_key:"formRef",ref:N,model:s,"label-width":"100px",class:"extend-form"},{default:a(()=>[t(I,{label:"支付方式"},{default:a(()=>[t(O,{modelValue:c.value,"onUpdate:modelValue":e[0]||(e[0]=D=>c.value=D)},{default:a(()=>[t(p,{label:"wechat"},{default:a(()=>[...e[5]||(e[5]=[l("微信支付",-1)])]),_:1}),t(p,{label:"balance"},{default:a(()=>[...e[6]||(e[6]=[l("余额支付",-1)])]),_:1}),t(p,{label:"currency"},{default:a(()=>[...e[7]||(e[7]=[l("积分支付",-1)])]),_:1}),t(p,{label:"currency2"},{default:a(()=>[...e[8]||(e[8]=[l("积分2支付",-1)])]),_:1}),t(p,{label:"coupon"},{default:a(()=>[...e[9]||(e[9]=[l("优惠券支付",-1)])]),_:1})]),_:1},8,["modelValue"])]),_:1}),t(I,{label:"支付类型"},{default:a(()=>[t(R,{modelValue:s.isDeduction,"onUpdate:modelValue":e[1]||(e[1]=D=>s.isDeduction=D)},{default:a(()=>[t(h,{value:0},{default:a(()=>[...e[10]||(e[10]=[l("支付模式",-1)])]),_:1}),t(h,{value:1},{default:a(()=>[...e[11]||(e[11]=[l("抵扣模式",-1)])]),_:1})]),_:1},8,["modelValue"]),k("div",te,[t(S,{type:"info",size:"small"},{default:a(()=>[...e[12]||(e[12]=[l(" 支付模式：用户选择一种支付方式完成支付；抵扣模式：积分/优惠券可抵扣部分金额 ",-1)])]),_:1})])]),_:1})]),_:1},8,["model"])])),[[J,C.value]])]}),_:1},8,["modelValue","title"])}}}),ue=ae(se,[["__scopeId","data-v-38bbdd1d"]]);export{ue as default};
