import{D as E}from"./index.K_MFulpu.js";import{u as G}from"./useResponse.DqThFJSa.js";import{c as J}from"./api.SqjU0NMY.js";import{F as L,G as Z,h as U}from"./elementPlus.CSBdF9Zt.js";import{d as $,aJ as z,r as D,aI as H,aK as Q,Z as F,ai as u,o as d,M as p,O as t,B as w,U as o,S as C,u as s,c as b,a8 as V,F as y}from"./vue.1RczIYhx.js";import{_ as W}from"./_plugin-vue_export-helper.DlAUqK2U.js";const X=$({__name:"CreateDialog",props:{modelValue:{default:!1},modelModifiers:{}},emits:z(["refresh"],["update:modelValue"]),setup(x,{emit:M}){const O=w("shopOptions"),S=w("groupOptions"),{data:B}=E(),k=D(!1),v=H("createDialog"),m=Q(x,"modelValue"),I=M,c=D(),a=F({asin:"",sku:"",country:"",shop:"",group:"",frequency:6,description:""}),N=F({asin:[{required:!0,message:"请输入ASIN",trigger:"blur"}],sku:[{required:!0,message:"请输入SKU",trigger:"blur"}],country:[{required:!0,message:"请选择国家",trigger:"change"}],shop:[{required:!0,message:"请输入店铺",trigger:"blur"}],group:[{required:!0,message:"请输入分组",trigger:"blur"}]}),R=async i=>{i&&await i.validate(async(l,f)=>{if(l){const r={asin:a.asin,sku:a.sku,country_code:a.country,shop_id:a.shop,tag:a.group,goods:{sku:a.sku,tag:a.group},freq:a.frequency};(await G(J,r,k)).code===2e3&&(U.success({message:"创建成功",plain:!0,icon:"CirclePlus"}),m.value=!1,I("refresh"))}else U.error("创建失败，请检查表单")})};function h(){K(c.value),v.value.visible=!1}const K=i=>{i&&i.resetFields()};return(i,l)=>{const f=u("el-input"),r=u("el-form-item"),n=u("el-col"),_=u("el-option"),g=u("el-select"),A=u("el-input-number"),P=u("el-row"),T=u("el-form"),q=u("el-button"),j=u("el-dialog");return d(),p(j,{ref_key:"createDialog",ref:v,modelValue:m.value,"onUpdate:modelValue":l[7]||(l[7]=e=>m.value=e),"close-on-click-modal":!1,"close-on-press-escape":!1,title:"商品监控 - 创建 ",style:{width:"40%"}},{footer:t(()=>[o(q,{icon:s(L),onClick:h},{default:t(()=>l[8]||(l[8]=[C("取 消")])),_:1},8,["icon"]),o(q,{icon:s(Z),loading:s(k),type:"primary",onClick:l[6]||(l[6]=e=>R(s(c)))},{default:t(()=>l[9]||(l[9]=[C("确 定")])),_:1},8,["icon","loading"])]),default:t(()=>[o(T,{ref_key:"ruleFormRef",ref:c,model:s(a),rules:s(N),"label-position":"top","label-width":"auto",class:"mx-2.5 mt-5","status-icon":""},{default:t(()=>[o(P,{gutter:20},{default:t(()=>[o(n,{span:24},{default:t(()=>[o(r,{class:"font-medium",label:"ASIN",prop:"asin"},{default:t(()=>[o(f,{modelValue:s(a).asin,"onUpdate:modelValue":l[0]||(l[0]=e=>s(a).asin=e),placeholder:"不再支持批量创建（批量创建使用Excel导入），请填写单个asin"},null,8,["modelValue"])]),_:1})]),_:1}),o(n,{span:12},{default:t(()=>[o(r,{class:"font-medium",label:"SKU",prop:"sku"},{default:t(()=>[o(f,{modelValue:s(a).sku,"onUpdate:modelValue":l[1]||(l[1]=e=>s(a).sku=e),placeholder:"多个sku请以逗号相隔"},null,8,["modelValue"])]),_:1})]),_:1}),o(n,{span:12},{default:t(()=>[o(r,{class:"font-medium",label:"店 铺",prop:"shop"},{default:t(()=>[o(g,{modelValue:s(a).shop,"onUpdate:modelValue":l[2]||(l[2]=e=>s(a).shop=e),placeholder:"请选择店铺"},{default:t(()=>[(d(!0),b(y,null,V(s(O),e=>(d(),p(_,{key:e.id,label:e.name,value:e.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1}),o(n,{span:12},{default:t(()=>[o(r,{class:"font-medium",label:"分 组",prop:"group"},{default:t(()=>[o(g,{modelValue:s(a).group,"onUpdate:modelValue":l[3]||(l[3]=e=>s(a).group=e),placeholder:"请选择分组",filterable:"","allow-create":"","default-first-option":""},{default:t(()=>[(d(!0),b(y,null,V(s(S),e=>(d(),p(_,{label:e.tag,value:e.tag},null,8,["label","value"]))),256))]),_:1},8,["modelValue"])]),_:1})]),_:1}),o(n,{span:12},{default:t(()=>[o(r,{class:"font-medium",label:"国 家",prop:"country"},{default:t(()=>[o(g,{modelValue:s(a).country,"onUpdate:modelValue":l[4]||(l[4]=e=>s(a).country=e),placeholder:"请选择国家"},{default:t(()=>[(d(!0),b(y,null,V(s(B).country_code,e=>(d(),p(_,{key:e.value,label:e.label,value:e.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1}),o(n,{span:12},{default:t(()=>[o(r,{class:"font-medium",label:"更新频率",prop:"frequency"},{default:t(()=>[o(A,{modelValue:s(a).frequency,"onUpdate:modelValue":l[5]||(l[5]=e=>s(a).frequency=e),min:"3"},null,8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue"])}}}),se=W(X,[["__scopeId","data-v-50ce942e"]]);export{se as default};
