1 |
- import{f as R,ar as v,d as Q,i as W,r as c,o as O,c as X,g as i,w as u,a as r,n as k,y as Z,x as $,P as tt,F as at,aO as et,ao as ot,D as st,aY as rt,H as lt,J as it,_ as ct,__tla as ut}from"./index-52b99925.js";import{_ as nt,__tla as dt}from"./Dialog-01a79427.js";import{_ as pt,__tla as mt}from"./Form-8e607ed0.js";import _t,{__tla as ft}from"./SpuSelect-4fab66f2.js";import yt,{__tla as vt}from"./SpuAndSkuList-97e24e4d.js";import{b as U,__tla as ht}from"./formatTime-16b790f5.js";import{r as h,__tla as wt}from"./formRules-d64fa1d2.js";import{D as gt,__tla as Pt}from"./dict-954b1420.js";import{u as bt,__tla as kt}from"./useCrudSchemas-b2748ccc.js";import{c as St,__tla as Dt}from"./spu-1f519991.js";import{g as Tt,__tla as Ct}from"./index-d67478b4.js";import{u as It,__tla as Vt}from"./useMessage-c41e583e.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=R({spuId:[h],name:[h],startTime:[h],endTime:[h],discountType:[h]}),T=R([{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(Q({name:"PromotionDiscountActivityForm",__name:"DiscountActivityForm",emits:["success"],setup(m,{expose:L,emit:N}){const{t:P}=W(),I=It(),_=c(!1),V=c(""),f=c(!1),F=c(""),n=c(),Y=c(),x=c(),H=[],w=c([]),b=c([]),J=(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(K=>K.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,a)=>{var e;if(_.value=!0,V.value=P("action."+s),F.value=s,await G(),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 q=N,B=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,q("success")}finally{f.value=!1}}},G=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 O(),X(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:B},{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(()=>[Z((O(),$(t,{ref_key:"formRef",ref:n,isCol:!0,rules:r(D),schema:r(C).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":H,"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:J},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,z as d,j as g};
|