import{e as r}from"./emitter.bff31cdd.js";import M from"./ProductDialogList.a36b09db.js";import{g as T,p as j,a as z}from"./api.ac18b8be.js";import{E as s}from"./elementPlus.4833989a.js";import{d as A,B as G,r as m,Z as x,A as O,ai as d,aq as Z,o as f,M as _,O as t,P as E,U as i,a as D,S as w,R as V,aF as H,aG as J}from"./vue.adf17aba.js";import{_ as K}from"./_plugin-vue_export-helper.c27b6911.js";import"./index.ad3efb29.js";import"./echarts.72dc8373.js";const C=u=>(H("data-v-0e6f1326"),u=u(),J(),u),Q=C(()=>D("span",{class:"form-label"}," 产品线名称: ",-1)),W=C(()=>D("span",{class:"form-label"}," 商品: ",-1)),X={style:{display:"flex","flex-direction":"row-reverse"}},Y=A({__name:"ProductDialog",setup(u){const g=G("profile"),n=m(!1),v=m(!1);let L=[],N="";const p=m(!1);r.on("open-productLine-dialog",o=>{n.value=o.isVisible}),r.on("ProductList-asinList",o=>{L=o}),r.on("ProductTab-editProductCard",o=>{N=o.data.productlineId,I(),p.value=!0,n.value=o.isVisible,a.productLineName=o.data.productlineName});async function I(){const o={profileId:g.value.profile_id,productlineId:N};try{const e=await T(o);r.emit("ProductLineDialog-sendDetailData",{data:e.data})}catch(e){console.log("error:",e)}}async function h(){const o={profileId:g.value.profile_id,productLineName:a.productLineName,asinList:L};try{const e=await z(o);e.data.code=="success"?s.success("更新成功"):e.data.code=="error"?s.warning(`${e.data.description}`):s.error("更新失败")}catch(e){console.log("error:",e)}}function k(){p.value=!1,a.productLineName="",r.emit("ProductLineDialog-closeDialog",{clear:!0})}const y=m(),a=x({productLineName:""}),F=x({productLineName:[{required:!0,message:"请输入产品线名称",trigger:"blur"}]}),U=async o=>{o&&await o.validate((e,c)=>{e?(console.log("submit!"),h()):console.log("error submit!",c)})},B=async o=>{o&&await o.validate(async(e,c)=>{e?(console.log("submit!"),await $(),r.emit("ProductLineDialog-reloading",{reloading:!0})):console.log("error submit!",c)})};async function $(){v.value=!0;const o={profileId:g.value.profile_id,productLineName:a.productLineName,asinList:L};try{const e=await j(o);e.data.code=="success"?s.success("创建成功"):e.data.code=="error"?s.warning(`${e.data.description}`):s.error("创建失败")}catch(e){console.log("error:",e)}finally{v.value=!1}}return O(()=>{r.all.clear()}),(o,e)=>{const c=d("el-input"),b=d("el-form-item"),P=d("el-button"),q=d("el-form"),S=d("el-dialog"),R=Z("loading");return f(),_(S,{modelValue:n.value,"onUpdate:modelValue":e[4]||(e[4]=l=>n.value=l),onClose:k,title:"新建产品线",width:"1300"},{default:t(()=>[E((f(),_(q,{ref_key:"ruleFormRef",ref:y,class:"custom-ruleForm",model:a,rules:F,"label-width":"120px",size:"default","label-position":"top","status-icon":""},{default:t(()=>[i(b,{prop:"productLineName"},{label:t(()=>[Q]),default:t(()=>[i(c,{modelValue:a.productLineName,"onUpdate:modelValue":e[0]||(e[0]=l=>a.productLineName=l),"show-word-limit":"",placeholder:"请输入产品线名称",maxlength:"150",style:{width:"500px"}},null,8,["modelValue"])]),_:1}),i(b,{required:""},{label:t(()=>[W]),default:t(()=>[i(M)]),_:1}),i(b,null,{default:t(()=>[D("div",X,[p.value?V("",!0):(f(),_(P,{key:0,style:{"margin-left":"10px"},color:"#3c59b0",onClick:e[1]||(e[1]=l=>B(y.value))},{default:t(()=>[w(" 创建 ")]),_:1})),p.value?(f(),_(P,{key:1,style:{"margin-left":"10px"},color:"#3c59b0",onClick:e[2]||(e[2]=l=>U(y.value))},{default:t(()=>[w(" 确定 ")]),_:1})):V("",!0),i(P,{plain:"",onClick:e[3]||(e[3]=l=>n.value=!1)},{default:t(()=>[w("取消")]),_:1})])]),_:1})]),_:1},8,["model","rules"])),[[R,v.value]])]),_:1},8,["modelValue"])}}});const ne=K(Y,[["__scopeId","data-v-0e6f1326"]]);export{ne as default};
