DiscountActivityForm-b96701ef.js 5.9 KB

1
  1. import{f as O,ar as v,d as G,i as K,r as c,o as R,c as W,g as i,w as u,a as r,q as k,y as Z,x as $,Q as tt,F as et,av as at,ao as ot,D as st,aX as rt,H as lt,J as it,_ as ct,__tla as ut}from"./index-12a7743c.js";import{_ as nt,__tla as dt}from"./Dialog-639a3ed8.js";import{_ as pt,__tla as mt}from"./Form-815a3cb1.js";import _t,{__tla as ft}from"./SpuSelect-28a9780a.js";import yt,{__tla as vt}from"./SpuAndSkuList-6a605601.js";import{b as U,__tla as ht}from"./formatTime-adaaebb7.js";import{r as h,__tla as wt}from"./formRules-3c0e1dc5.js";import{D as gt,__tla as Pt}from"./dict-0bfe78a3.js";import{u as bt,__tla as kt}from"./useCrudSchemas-c9bfd170.js";import{f as St,__tla as Dt}from"./spu-eef4392f.js";import{g as Tt,__tla as Ct}from"./index-0231b9cf.js";import{u as It,__tla as Vt}from"./useMessage-9e9b1c85.js";let S,A,E,z,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 Dt}catch{}})(),(()=>{try{return Ct}catch{}})(),(()=>{try{return Vt}catch{}})()]).then(async()=>{let D,T,C;D=O({spuId:[h],name:[h],startTime:[h],endTime:[h],discountType:[h]}),T=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:C}=bt(T),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}),z=async m=>await v.delete({url:"/promotion/discount-activity/delete?id="+m}),S=ct(G({name:"PromotionDiscountActivityForm",__name:"DiscountActivityForm",emits:["success"],setup(m,{expose:L,emit:N}){const{t:P}=K(),I=It(),_=c(!1),V=c(""),f=c(!1),F=c(""),n=c(),Y=c(),x=c(),q=[],w=c([]),b=c([]),H=(s,e)=>{n.value.setValues({spuId:s}),M(s,e)},M=async(s,e,a)=>{var g;const l=[],d=await St([s]);if(d.length==0)return;w.value=[];const t=d[0],y=e===void 0?t==null?void 0:t.skus:(g=t==null?void 0:t.skus)==null?void 0:g.filter(o=>e.includes(o.id));y==null||y.forEach(o=>{let p={skuId:o.id,spuId:t.id,discountType:1,discountPercent:0,discountPrice:0};a!==void 0&&(p=a.find(B=>B.skuId===o.id)||p),o.productConfig=p}),t.skus=y,l.push({spuId:t.id,spuDetail:t,propertyList:Tt(t)}),w.value.push(t),b.value=l};L({open:async(s,e)=>{var a;if(_.value=!0,V.value=P("action."+s),F.value=s,await X(),e){f.value=!0;try{const l=await(async t=>await v.get({url:"/promotion/discount-activity/get?id="+t}))(e),d=l.products[0].spuId;await M(d,(a=l.products)==null?void 0:a.map(t=>t.skuId),l.products),n.value.setValues(l)}finally{f.value=!1}}}});const J=N,Q=async()=>{if(n&&await n.value.getElFormRef().validate()){f.value=!0;try{const s=n.value.formModel,e=at(x.value.getSkuConfigs("productConfig"));e.forEach(a=>{a.discountType=s.discountType}),s.products=e,F.value==="create"?(await(async a=>await v.post({url:"/promotion/discount-activity/create",data:a}))(s),I.success(P("common.createSuccess"))):(await(async a=>await v.put({url:"/promotion/discount-activity/update",data:a}))(s),I.success(P("common.updateSuccess"))),_.value=!1,J("success")}finally{f.value=!1}}},X=async()=>{w.value=[],b.value=[],await ot(),n.value.getElFormRef().resetFields()};return(s,e)=>{const a=st,l=rt,d=lt,t=pt,y=nt,g=it;return R(),W(et,null,[i(y,{modelValue:r(_),"onUpdate:modelValue":e[2]||(e[2]=o=>tt(_)?_.value=o:null),title:r(V),width:"65%"},{footer:u(()=>[i(a,{disabled:r(f),type:"primary",onClick:Q},{default:u(()=>[k("\u786E \u5B9A")]),_:1},8,["disabled"]),i(a,{onClick:e[1]||(e[1]=o=>_.value=!1)},{default:u(()=>[k("\u53D6 \u6D88")]),_:1})]),default:u(()=>[Z((R(),$(t,{ref_key:"formRef",ref:n,isCol:!0,rules:r(D),schema:r(C).formSchema},{spuId:u(()=>[i(a,{onClick:e[0]||(e[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:H},null,512)],64)}}}),[["__file","D:/zx/mall-newfeifan-zx-business/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,z as d,j as g};