2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
var e=Object.defineProperty,a=Object.defineProperties,t=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,r=(a,t,l)=>t in a?e(a,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):a[t]=l,d=(e,a)=>{for(var t in a||(a={}))i.call(a,t)&&r(e,t,a[t]);if(l)for(var t of l(a))o.call(a,t)&&r(e,t,a[t]);return e},n=(e,a,t)=>new Promise((l,i)=>{var o=e=>{try{d(t.next(e))}catch(a){i(a)}},r=e=>{try{d(t.throw(e))}catch(a){i(a)}},d=e=>e.done?l(e.value):Promise.resolve(e.value).then(o,r);d((t=t.apply(e,a)).next())});import{c1 as u,d as p,k as s,r as m,o as c,b as y,e as _,g as f,w as v,p as b,E as g,j as w,v as j,h,i as V,K as k,I as x,J as C,T as U,aV as z}from"./index-BoIUJTA2.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{_ as I}from"./index-Bwtbh5WQ.js";import{A as O}from"./index-BaXJ8CyS.js";import{u as q}from"./useTable-DzUOUR11.js";import{f as P,a as E,b as D}from"./task-center-B4yQCrbd.js";import{f as S}from"./product-qKpGgPBm.js";import{E as A}from"./index-ZsMdSUVI.js";import{E as T}from"./index-CjpBlozU.js";import{a as W,E as R}from"./index-BcfO0-fK.js";import{E as $,a as F}from"./index-D2gD5Tn5.js";import{E as Y}from"./index-C_S0YbqD.js";import{a as B,b as H}from"./index-DqTthkO7.js";import{E as J}from"./index-BaD29Izp.js";/* empty css *//* empty css *//* empty css */import"./el-tooltip-l0sNRNKZ.js";import"./el-empty-CV-PB2A2.js";import"./index-BjuMygln.js";import"./index-Cp4NEpJ7.js";import"./index-BMeOzN3u.js";import"./index-COyGylbk.js";import"./index-Bq8lawOo.js";import"./_initCloneObject-DRmC-q3t.js";import"./isArrayLikeObject-CFQi-X2M.js";import"./raf-DsHSIRfX.js";import"./_baseIteratee-CtIat01j.js";import"./castArray-nM8ho4U3.js";import"./debounce-DQl5eUwG.js";import"./index-D8nVJoNy.js";import"./index-CXORCV4U.js";import"./index-C1haaLtB.js";import"./_plugin-vue_export-helper-BCo6x5W8.js";/* empty css */import"./el-dropdown-item-D7SYN_RE.js";import"./dropdown-Dk_wSiK6.js";import"./refs-Cw5r5QN8.js";import"./index.vue_vue_type_script_setup_true_lang-DUbflfBQ.js";import"./iconify-DFoKediz.js";/* empty css */import"./index-CZJaGuxf.js";import"./useTableColumns-FR69a2pD.js";import"./use-dialog-FwJ-QdmW.js";import"./_baseClone-Ct7RL6h5.js";import"./token-DWNpOE8r.js";import"./index-BnK4BbY2.js";const K={class:"art-full-height"},L={key:1,class:"text-gray-400"},M=p({__name:"product-rewards",setup(e){const l=e=>({game_ticket:"游戏资格",coupon:"优惠券",points:"积分",product:"商品",item_card:"道具卡",title:"称号"}[e]||e),{data:i,loading:o,columns:r,pagination:p,handleSizeChange:M,handleCurrentChange:Q,refreshData:X}=q({core:{apiFn:e=>function(e){return u.get({url:"admin/douyin/product-rewards",params:e})}({page:e.page,page_size:e.page_size}),columnsFactory:()=>[{prop:"id",label:"ID",width:80},{prop:"product_id",label:"商品ID",minWidth:180},{prop:"product_name",label:"商品名称",minWidth:150},{prop:"activity_name",label:"关联活动",minWidth:120,useSlot:!0},{prop:"reward_type",label:"奖励类型",width:100,useSlot:!0},{prop:"quantity",label:"数量",width:80},{prop:"status",label:"状态",width:80,useSlot:!0},{prop:"created_at",label:"创建时间",width:170},{prop:"actions",label:"操作",width:150,useSlot:!0,fixed:"right"}]}}),G=s({visible:!1,mode:"create",submitting:!1,currentId:0}),N={product_id:"",product_name:"",activity_id:null,reward_type:"game_ticket",payload:{game_code:"minesweeper"},quantity:1,status:1},Z=s(d({},N)),ee=m(),ae={product_id:[{required:!0,message:"请输入商品ID",trigger:"blur"}],reward_type:[{required:!0,message:"请选择奖励类型",trigger:"change"}]},te=m([]),le=m([]),ie=m(!1),oe=m([]),re=m(!1),de=m([]),ne=m(!1),ue=m([]),pe=m(!1);function se(e){return n(this,null,function*(){ie.value=!0;try{const a=yield P({name:e,page:1,page_size:50});le.value=a.list||[]}finally{ie.value=!1}})}function me(e){return n(this,null,function*(){re.value=!0;try{const a=yield S({name:e,page:1,page_size:50,status:1});oe.value=a.list||[]}finally{re.value=!1}})}function ce(e){return n(this,null,function*(){ne.value=!0;try{const a=yield E({name:e,page:1,page_size:50});de.value=a.list||[]}finally{ne.value=!1}})}function ye(e){return n(this,null,function*(){pe.value=!0;try{const a=yield D({name:e,page:1,page_size:50});ue.value=a.list||[]}finally{pe.value=!1}})}function _e(){Z.payload={},"game_ticket"===Z.reward_type?Z.payload.game_code="minesweeper":"points"===Z.reward_type&&(Z.payload.points=100)}function fe(){var e;G.mode="create",G.visible=!0,G.currentId=0,Object.assign(Z,(e=d({},N),a(e,t({activity_id:null,payload:{game_code:"minesweeper"}}))))}function ve(){return n(this,null,function*(){ee.value&&(yield ee.value.validate(e=>n(this,null,function*(){if(e){G.submitting=!0;try{const e={product_id:Z.product_id,product_name:Z.product_name,activity_id:Z.activity_id||void 0,reward_type:Z.reward_type,reward_payload:Z.payload,quantity:Z.quantity,status:Z.status};"create"===G.mode?(yield function(e){return u.post({url:"admin/douyin/product-rewards",data:e})}(e),U.success("创建成功")):(yield function(e,a){return u.put({url:`admin/douyin/product-rewards/${e}`,data:a})}(G.currentId,e),U.success("修改成功")),G.visible=!1,X()}finally{G.submitting=!1}}})))})}function be(e){z.confirm(`确认删除规则【${e.product_name||e.product_id}】?`,"提示",{type:"warning"}).then(()=>n(this,null,function*(){var a;yield(a=e.id,u.del({url:`admin/douyin/product-rewards/${a}`})),U.success("删除成功"),X()}))}function ge(){return n(this,null,function*(){try{const e=yield u.get({url:"admin/livestream/activities",params:{page:1,page_size:500}});te.value=e.list||[]}catch(e){}})}return c(()=>{X(),ge()}),(e,a)=>{const t=g,d=A,n=k,u=R,s=F,m=$,c=Y,U=H,z=B,q=W,P=T,E=J;return _(),y("div",K,[f(E,{class:"art-table-card",shadow:"never"},{default:v(()=>[f(O,{loading:b(o),onRefresh:b(X)},{left:v(()=>[f(t,{type:"primary",onClick:fe},{default:v(()=>[...a[14]||(a[14]=[w("新增规则",-1)])]),_:1})]),_:1},8,["loading","onRefresh"]),f(I,{loading:b(o),data:b(i),columns:b(r),pagination:b(p),"onPagination:sizeChange":b(M),"onPagination:currentChange":b(Q)},{reward_type:v(({row:e})=>{return[f(d,{type:(a=e.reward_type,{game_ticket:"success",coupon:"warning",points:"primary",product:void 0,item_card:"info",title:"danger"}[a])},{default:v(()=>[w(j(l(e.reward_type)),1)]),_:2},1032,["type"])];var a}),activity_name:v(({row:e})=>[e.activity_name?(_(),h(d,{key:0,type:"info",size:"small"},{default:v(()=>[w(j(e.activity_name),1)]),_:2},1024)):(_(),y("span",L,"-"))]),status:v(({row:e})=>[f(d,{type:1===e.status?"success":"danger"},{default:v(()=>[w(j(1===e.status?"启用":"禁用"),1)]),_:2},1032,["type"])]),actions:v(({row:e})=>[f(t,{link:"",type:"primary",onClick:a=>function(e){G.mode="edit",G.visible=!0,G.currentId=e.id,Object.assign(Z,{product_id:e.product_id,product_name:e.product_name,activity_id:e.activity_id||null,reward_type:e.reward_type,payload:e.reward_payload||{},quantity:e.quantity,status:e.status}),"coupon"===e.reward_type&&se(""),"product"===e.reward_type&&me(""),"item_card"===e.reward_type&&ce(""),"title"===e.reward_type&&ye("")}(e)},{default:v(()=>[...a[15]||(a[15]=[w("编辑",-1)])]),_:1},8,["onClick"]),f(t,{link:"",type:"danger",onClick:a=>be(e)},{default:v(()=>[...a[16]||(a[16]=[w("删除",-1)])]),_:1},8,["onClick"])]),_:1},8,["loading","data","columns","pagination","onPagination:sizeChange","onPagination:currentChange"]),f(P,{modelValue:G.visible,"onUpdate:modelValue":a[13]||(a[13]=e=>G.visible=e),title:"create"===G.mode?"新增规则":"编辑规则",width:"550px","destroy-on-close":""},{footer:v(()=>[f(t,{onClick:a[12]||(a[12]=e=>G.visible=!1)},{default:v(()=>[...a[19]||(a[19]=[w("取消",-1)])]),_:1}),f(t,{type:"primary",onClick:ve,loading:G.submitting},{default:v(()=>[...a[20]||(a[20]=[w("提交",-1)])]),_:1},8,["loading"])]),default:v(()=>[f(q,{model:Z,"label-width":"100px",rules:ae,ref_key:"formRef",ref:ee},{default:v(()=>[f(u,{label:"商品ID",prop:"product_id"},{default:v(()=>[f(n,{modelValue:Z.product_id,"onUpdate:modelValue":a[0]||(a[0]=e=>Z.product_id=e),placeholder:"抖店商品ID",disabled:"edit"===G.mode},null,8,["modelValue","disabled"])]),_:1}),f(u,{label:"商品名称",prop:"product_name"},{default:v(()=>[f(n,{modelValue:Z.product_name,"onUpdate:modelValue":a[1]||(a[1]=e=>Z.product_name=e),placeholder:"便于识别(选填)"},null,8,["modelValue"])]),_:1}),f(u,{label:"关联活动",prop:"activity_id"},{default:v(()=>[f(m,{modelValue:Z.activity_id,"onUpdate:modelValue":a[2]||(a[2]=e=>Z.activity_id=e),placeholder:"选择关联的直播活动(可选)",clearable:"",filterable:"",style:{width:"100%"}},{default:v(()=>[(_(!0),y(x,null,C(te.value,e=>(_(),h(s,{key:e.id,value:e.id,label:e.name},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1}),f(u,{label:"奖励类型",prop:"reward_type"},{default:v(()=>[f(m,{modelValue:Z.reward_type,"onUpdate:modelValue":a[3]||(a[3]=e=>Z.reward_type=e),placeholder:"选择奖励类型",style:{width:"100%"},onChange:_e},{default:v(()=>[f(s,{value:"game_ticket",label:"游戏资格"}),f(s,{value:"coupon",label:"优惠券"}),f(s,{value:"points",label:"积分"}),f(s,{value:"product",label:"商品"}),f(s,{value:"item_card",label:"道具卡"}),f(s,{value:"title",label:"称号"})]),_:1},8,["modelValue"])]),_:1}),"game_ticket"===Z.reward_type?(_(),h(u,{key:0,label:"游戏代码"},{default:v(()=>[f(m,{modelValue:Z.payload.game_code,"onUpdate:modelValue":a[4]||(a[4]=e=>Z.payload.game_code=e),placeholder:"选择游戏",style:{width:"100%"}},{default:v(()=>[f(s,{value:"minesweeper",label:"扫雷"})]),_:1},8,["modelValue"])]),_:1})):V("",!0),"points"===Z.reward_type?(_(),h(u,{key:1,label:"积分数量"},{default:v(()=>[f(c,{modelValue:Z.payload.points,"onUpdate:modelValue":a[5]||(a[5]=e=>Z.payload.points=e),min:1,style:{width:"100%"}},null,8,["modelValue"])]),_:1})):V("",!0),"coupon"===Z.reward_type?(_(),h(u,{key:2,label:"优惠券"},{default:v(()=>[f(m,{modelValue:Z.payload.coupon_id,"onUpdate:modelValue":a[6]||(a[6]=e=>Z.payload.coupon_id=e),filterable:"",remote:"","reserve-keyword":"",placeholder:"搜索优惠券","remote-method":se,loading:ie.value,style:{width:"100%"}},{default:v(()=>[(_(!0),y(x,null,C(le.value,e=>(_(),h(s,{key:e.id,value:e.id,label:e.name},null,8,["value","label"]))),128))]),_:1},8,["modelValue","loading"])]),_:1})):V("",!0),"product"===Z.reward_type?(_(),h(u,{key:3,label:"商品"},{default:v(()=>[f(m,{modelValue:Z.payload.product_id,"onUpdate:modelValue":a[7]||(a[7]=e=>Z.payload.product_id=e),filterable:"",remote:"","reserve-keyword":"",placeholder:"搜索商品","remote-method":me,loading:re.value,style:{width:"100%"}},{default:v(()=>[(_(!0),y(x,null,C(oe.value,e=>(_(),h(s,{key:e.id,value:e.id,label:e.name},null,8,["value","label"]))),128))]),_:1},8,["modelValue","loading"])]),_:1})):V("",!0),"item_card"===Z.reward_type?(_(),h(u,{key:4,label:"道具卡"},{default:v(()=>[f(m,{modelValue:Z.payload.card_id,"onUpdate:modelValue":a[8]||(a[8]=e=>Z.payload.card_id=e),filterable:"",remote:"","reserve-keyword":"",placeholder:"搜索道具卡","remote-method":ce,loading:ne.value,style:{width:"100%"}},{default:v(()=>[(_(!0),y(x,null,C(de.value,e=>(_(),h(s,{key:e.id,value:e.id,label:e.name},null,8,["value","label"]))),128))]),_:1},8,["modelValue","loading"])]),_:1})):V("",!0),"title"===Z.reward_type?(_(),h(u,{key:5,label:"称号"},{default:v(()=>[f(m,{modelValue:Z.payload.title_id,"onUpdate:modelValue":a[9]||(a[9]=e=>Z.payload.title_id=e),filterable:"",remote:"","reserve-keyword":"",placeholder:"搜索称号","remote-method":ye,loading:pe.value,style:{width:"100%"}},{default:v(()=>[(_(!0),y(x,null,C(ue.value,e=>(_(),h(s,{key:e.id,value:e.id,label:e.name},null,8,["value","label"]))),128))]),_:1},8,["modelValue","loading"])]),_:1})):V("",!0),f(u,{label:"发放数量",prop:"quantity"},{default:v(()=>[f(c,{modelValue:Z.quantity,"onUpdate:modelValue":a[10]||(a[10]=e=>Z.quantity=e),min:1,style:{width:"100%"}},null,8,["modelValue"])]),_:1}),f(u,{label:"状态",prop:"status"},{default:v(()=>[f(z,{modelValue:Z.status,"onUpdate:modelValue":a[11]||(a[11]=e=>Z.status=e)},{default:v(()=>[f(U,{value:1},{default:v(()=>[...a[17]||(a[17]=[w("启用",-1)])]),_:1}),f(U,{value:0},{default:v(()=>[...a[18]||(a[18]=[w("禁用",-1)])]),_:1})]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue","title"])]),_:1})])}}});export{M as default};
|