import{e as O,aq as v,d as K,h as Q,r as c,o as R,c as W,f as i,w as u,a as r,n as k,x as X,v as Z,O as tt,F as at,aL as et,an as ot,C as st,aT as rt,G as lt,I as it,_ as ct,__tla as ut}from"./index-3f6d2b3a.js";import{_ as nt,__tla as dt}from"./Dialog-d80e1167.js";import{_ as pt,__tla as mt}from"./Form-197a6011.js";import _t,{__tla as ft}from"./SpuSelect-9040abfa.js";import yt,{__tla as vt}from"./SpuAndSkuList-0929dad7.js";import{b as U,__tla as ht}from"./formatTime-15ffed0a.js";import{r as h,__tla as wt}from"./formRules-7bf77ca2.js";import{D as gt,__tla as Pt}from"./dict-9cca1721.js";import{u as bt,__tla as kt}from"./useCrudSchemas-d5f442c6.js";import{c as St,__tla as Tt}from"./spu-b0eb5157.js";import{g as Ct,__tla as Dt}from"./index-dbeefd5d.js";import{u as It,__tla as Vt}from"./useMessage-d75e3be7.js";let S,A,E,L,j,Ft=Promise.all([(()=>{try{return ut}catch{}})(),(()=>{try{return dt}catch{}})(),(()=>{try{return mt}catch{}})(),(()=>{try{return ft}catch{}})(),(()=>{try{return vt}catch{}})(),(()=>{try{return ht}catch{}})(),(()=>{try{return wt}catch{}})(),(()=>{try{return Pt}catch{}})(),(()=>{try{return kt}catch{}})(),(()=>{try{return Tt}catch{}})(),(()=>{try{return Dt}catch{}})(),(()=>{try{return Vt}catch{}})()]).then(async()=>{let T,C,D;T=O({spuId:[h],name:[h],startTime:[h],endTime:[h],discountType:[h]}),C=O([{label:"\u6D3B\u52A8\u540D\u79F0",field:"name",isSearch:!0,form:{colProps:{span:24}},table:{width:120}},{label:"\u6D3B\u52A8\u5F00\u59CB\u65F6\u95F4",field:"startTime",formatter:U,isSearch:!0,search:{component:"DatePicker",componentProps:{valueFormat:"YYYY-MM-DD",type:"daterange"}},form:{component:"DatePicker",componentProps:{type:"date",valueFormat:"x"}},table:{width:120}},{label:"\u6D3B\u52A8\u7ED3\u675F\u65F6\u95F4",field:"endTime",formatter:U,isSearch:!0,search:{component:"DatePicker",componentProps:{valueFormat:"YYYY-MM-DD",type:"daterange"}},form:{component:"DatePicker",componentProps:{type:"date",valueFormat:"x"}},table:{width:120}},{label:"\u4F18\u60E0\u7C7B\u578B",field:"discountType",dictType:gt.PROMOTION_DISCOUNT_TYPE,dictClass:"number",isSearch:!0,form:{component:"Radio",value:1}},{label:"\u6D3B\u52A8\u5546\u54C1",field:"spuId",isTable:!0,isSearch:!1,form:{colProps:{span:24}},table:{width:300}},{label:"\u5907\u6CE8",field:"remark",isSearch:!1,form:{component:"Input",componentProps:{type:"textarea",rows:4},colProps:{span:24}},table:{width:300}}]),{allSchemas:D}=bt(C),j=async m=>await v.get({url:"/promotion/discount-activity/page",params:m}),E=async m=>await v.put({url:"/promotion/discount-activity/close?id="+m}),L=async m=>await v.delete({url:"/promotion/discount-activity/delete?id="+m}),S=ct(K({name:"PromotionDiscountActivityForm",__name:"DiscountActivityForm",emits:["success"],setup(m,{expose:z,emit:N}){const{t:P}=Q(),I=It(),_=c(!1),V=c(""),f=c(!1),F=c(""),n=c(),Y=c(),x=c(),q=[],w=c([]),b=c([]),G=(s,a)=>{n.value.setValues({spuId:s}),M(s,a)},M=async(s,a,e)=>{var g;const l=[],d=await St([s]);if(d.length==0)return;w.value=[];const t=d[0],y=a===void 0?t==null?void 0:t.skus:(g=t==null?void 0:t.skus)==null?void 0:g.filter(o=>a.includes(o.id));y==null||y.forEach(o=>{let p={skuId:o.id,spuId:t.id,discountType:1,discountPercent:0,discountPrice:0};e!==void 0&&(p=e.find(J=>J.skuId===o.id)||p),o.productConfig=p}),t.skus=y,l.push({spuId:t.id,spuDetail:t,propertyList:Ct(t)}),w.value.push(t),b.value=l};z({open:async(s,a)=>{var e;if(_.value=!0,V.value=P("action."+s),F.value=s,await $(),a){f.value=!0;try{const l=await(async t=>await v.get({url:"/promotion/discount-activity/get?id="+t}))(a),d=l.products[0].spuId;await M(d,(e=l.products)==null?void 0:e.map(t=>t.skuId),l.products),n.value.setValues(l)}finally{f.value=!1}}}});const B=N,H=async()=>{if(n&&await n.value.getElFormRef().validate()){f.value=!0;try{const s=n.value.formModel,a=et(x.value.getSkuConfigs("productConfig"));a.forEach(e=>{e.discountType=s.discountType}),s.products=a,F.value==="create"?(await(async e=>await v.post({url:"/promotion/discount-activity/create",data:e}))(s),I.success(P("common.createSuccess"))):(await(async e=>await v.put({url:"/promotion/discount-activity/update",data:e}))(s),I.success(P("common.updateSuccess"))),_.value=!1,B("success")}finally{f.value=!1}}},$=async()=>{w.value=[],b.value=[],await ot(),n.value.getElFormRef().resetFields()};return(s,a)=>{const e=st,l=rt,d=lt,t=pt,y=nt,g=it;return R(),W(at,null,[i(y,{modelValue:r(_),"onUpdate:modelValue":a[2]||(a[2]=o=>tt(_)?_.value=o:null),title:r(V),width:"65%"},{footer:u(()=>[i(e,{disabled:r(f),type:"primary",onClick:H},{default:u(()=>[k("\u786E \u5B9A")]),_:1},8,["disabled"]),i(e,{onClick:a[1]||(a[1]=o=>_.value=!1)},{default:u(()=>[k("\u53D6 \u6D88")]),_:1})]),default:u(()=>[X((R(),Z(t,{ref_key:"formRef",ref:n,isCol:!0,rules:r(T),schema:r(D).formSchema},{spuId:u(()=>[i(e,{onClick:a[0]||(a[0]=o=>r(Y).open())},{default:u(()=>[k("\u9009\u62E9\u5546\u54C1")]),_:1}),i(r(yt),{ref_key:"spuAndSkuListRef",ref:x,"rule-config":q,"spu-list":r(w),"spu-property-list-p":r(b)},{default:u(()=>[i(d,{align:"center",label:"\u4F18\u60E0\u91D1\u989D","min-width":"168"},{default:u(({row:o})=>[i(l,{modelValue:o.productConfig.discountPrice,"onUpdate:modelValue":p=>o.productConfig.discountPrice=p,min:0,class:"w-100%"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),i(d,{align:"center",label:"\u6298\u6263\u767E\u5206\u6BD4(%)","min-width":"168"},{default:u(({row:o})=>[i(l,{modelValue:o.productConfig.discountPercent,"onUpdate:modelValue":p=>o.productConfig.discountPercent=p,class:"w-100%"},null,8,["modelValue","onUpdate:modelValue"])]),_:1})]),_:1},8,["spu-list","spu-property-list-p"])]),_:1},8,["rules","schema"])),[[g,r(f)]])]),_:1},8,["modelValue","title"]),i(r(_t),{ref_key:"spuSelectRef",ref:Y,isSelectSku:!0,onConfirm:G},null,512)],64)}}}),[["__file","D:/zx/mall-newfeifan-zx-admin/src/views/mall/promotion/discountActivity/DiscountActivityForm.vue"]]),A=Object.freeze(Object.defineProperty({__proto__:null,default:S},Symbol.toStringTag,{value:"Module"}))});export{S as D,Ft as __tla,A as a,E as c,L as d,j as g};