import{E as k,s as w,g as v}from"./EditGoodsDialog.e681ac40.js";import{d as x,a as l,s as M,r as m,b as B,p as N,c as i,e as A,k as I,i as u,h as o,u as s,a2 as H,g as D,m as C,E as p}from"./index.0308b213.js";const U=D("div",{class:"tn-form-item__tips"},"\u8BBE\u7F6E\u751F\u6548\u65E5\u671F",-1),R=D("div",{class:"tn-form-item__tips"},"\u8BBE\u7F6E\u751F\u6548\u65F6\u95F4",-1),$=C("\u63D0\u4EA4"),j=C("\u53D6\u6D88"),q=x({props:{modelValue:{type:Boolean,default:!1},sid:null},emits:["update:modelValue","onClose"],setup(V,{emit:F}){const n=V;l().format("YYYY-MM-DD"),M(()=>Number(n.sid)>0);const f=m(!1),h=m(),e=B({sid:"",date:[],time:[],goodsInfo:[]});m(!1),m(!1);const y=()=>{if(e.date=[e.date[0],e.date[1]],e.time=[e.time[0],e.time[1]],e.start_date=l(e.date[0]).format("YYYY-MM-DD"),e.end_date=l(e.date[1]).format("YYYY-MM-DD"),e.start_time=l(e.time[0]).format("HH:mm:ss"),e.end_time=l(e.time[1]).format("HH:mm:ss"),e.goodsInfo.length===0){p({message:"\u8BF7\u9009\u62E9\u53C2\u4E0E\u7684\u5546\u54C1",type:"warning"});return}let a=!1;e.goodsInfo.forEach(t=>{let c=Number(t.price),d=Number(t.platform_rate),g=Number(t.agent_rate);if(!c){a=!0,p({message:"\u8BF7\u586B\u5199\u5B8C\u6574",type:"warning"});return}if(d+g!==100){a=!0,p({message:"\u6BD4\u4F8B\u603B\u548C\u5FC5\u987B\u7B49\u4E8E100",type:"warning"});return}}),!a&&w(e).then(t=>{p({message:"\u63D0\u4EA4\u6210\u529F",type:"success"}),_()})};B({list:[]});const b=()=>{v({sid:n.sid}).then(a=>{if(console.log("res",a),a.data&&a.data.id){let t=a.data;e.date=[t.start_date,t.end_date],e.time=[l(`2000-01-01 ${t.start_time}`).toDate(),l(`2000-01-01 ${t.end_time}`).toDate()],e.goodsInfo=t.goods}})};N(()=>n.modelValue,a=>{f.value=a,a&&n.sid&&(e.sid=n.sid,b())});const _=()=>{F("update:modelValue",!1),F("onClose")};return(a,t)=>{const c=i("el-date-picker"),d=i("el-form-item"),g=i("el-time-picker"),E=i("el-button"),Y=i("el-dialog");return A(),I(Y,{modelValue:f.value,"onUpdate:modelValue":t[2]||(t[2]=r=>f.value=r),title:"\u67E5\u770B",width:"70%","destroy-on-close":"",onClose:_},{default:u(()=>[o(s(H),{ref_key:"formRef",ref:h,model:s(e),"inline-message":!0,"label-width":"160px"},{default:u(()=>[o(d,{label:"\u751F\u6548\u65E5\u671F"},{default:u(()=>[o(c,{style:{width:"400px"},modelValue:s(e).date,"onUpdate:modelValue":t[0]||(t[0]=r=>s(e).date=r),type:"daterange","range-separator":"\u81F3","start-placeholder":"\u5F00\u542F\u65F6\u95F4","end-placeholder":"\u7ED3\u675F\u65F6\u95F4"},null,8,["modelValue"]),U]),_:1}),o(d,{label:"\u751F\u6548\u65F6\u95F4"},{default:u(()=>[o(g,{style:{width:"400px"},modelValue:s(e).time,"onUpdate:modelValue":t[1]||(t[1]=r=>s(e).time=r),"is-range":"","range-separator":"\u81F3","start-placeholder":"\u5F00\u59CB\u65F6\u95F4","end-placeholder":"\u7ED3\u675F\u65F6\u95F4"},null,8,["modelValue"]),R]),_:1}),o(d,{label:"\u5546\u54C1\u8BBE\u7F6E"},{default:u(()=>[o(k,{goods:s(e).goodsInfo,sid:s(e).sid},null,8,["goods","sid"])]),_:1}),o(d,null,{default:u(()=>[o(E,{type:"primary",onClick:y},{default:u(()=>[$]),_:1}),o(E,{onClick:_},{default:u(()=>[j]),_:1})]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue"])}}});export{q as _};
