import{U as X,G as ee,H as te,k as F,J as oe,K as ue,D as le,C as ae,w as re,M as se,b as ie,N as ne,F as pe,I as de,L as me}from"./element-plus.4a7d92a3.js";import{_ as _e}from"./index.vue_vue_type_script_setup_true_name_systemStoreLists_lang.14212f4c.js";import{_ as ce}from"./index.vue_vue_type_script_setup_true_name_systemStoreLists_lang.61cccbee.js";import{k as fe}from"./index.76ab889f.js";import{a as Ee}from"./warehouse_order.2c6f75d8.js";import{d as O,s as we,r as i,Z as he,ap as ve,o as E,K as b,L as u,a as f,U as e,u as s,j as D,c as be,T as ke,a9 as De,R as n,S as Be,M,Q as Ce}from"./@vue.18505fe0.js";import"./lodash.9dc701ad.js";import{u as ye,a as Fe}from"./vue-router.101084e3.js";import{a as Ve}from"./store_product_unit.1efda4a6.js";import{a as ge}from"./warehouse.c3d36ae7.js";import"./lodash-es.f52bd8b1.js";import"./async-validator.fb49d0f5.js";import"./@vueuse.fbc6a400.js";import"./@element-plus.edbd5a83.js";import"./dayjs.7347fedc.js";import"./axios.4607972f.js";import"./@ctrl.b082b0c1.js";import"./normalize-wheel-es.8aeb3683.js";import"./@popperjs.36402333.js";import"./index.vue_vue_type_script_setup_true_lang.5d4e738c.js";import"./usePaging.6a6670f9.js";import"./useDictOptions.26465201.js";import"./store_product.0597be78.js";import"./store_branch_product.294bfb5e.js";import"./warehouse_product_storege.61da8649.js";import"./system_store.7936fc74.js";import"./pinia.a969beab.js";import"./css-color-function.bb8c34b2.js";import"./color.fbd63fe8.js";import"./clone.31a3aa2c.js";import"./color-convert.755d189f.js";import"./color-name.e7a4e1d3.js";import"./color-string.e356f5de.js";import"./balanced-match.d2a36341.js";import"./ms.564e106c.js";import"./nprogress.0d2736b7.js";import"./vue-clipboard3.7d5a7a5d.js";import"./clipboard.860a1cea.js";import"./echarts.5016c48c.js";import"./zrender.58d022a1.js";import"./tslib.60310f1a.js";import"./highlight.js.31cd7941.js";import"./@highlightjs.b0c09b66.js";const xe=f("div",{class:"mb-4 text-lg font-bold"},"\u51FA\u5E93\u5546\u54C1\u5230\u95E8\u5E97",-1),Ae={class:"flex-1 w-full"},Ue={class:"mb-2"},Le={class:"flex-1 w-full"},Se={class:"mb-2"},Re=f("span",{class:"text-info text-xs ml-6"},"\u9ED8\u8BA4\u4E3A\u5206\u914D\u552E\u5356\u5E93\u5B58, \u5982\u9700\u5206\u914D\u5151\u6362\u5E93\u5B58\u8BF7\u9009\u62E9\u5206\u914D\u5151\u6362\u5E93\u5B58",-1),Ie=O({name:"storeProductEdit"}),gt=O({...Ie,props:{dictData:{type:Object,default:()=>({})}},emits:["success","close"],setup(Me,{emit:Oe}){const V=ye(),P=we();fe(),i("add");const p=i(""),g=i([]);i(0);const d=he({store_id:"",manufacture:"",remark:""});V.query.warehouse_id&&(p.value=parseInt(V.query.warehouse_id));const T=()=>{ge({}).then(a=>{g.value=a.lists})},w=i(!1),m=i([]),$=a=>{m.value=m.value.filter(o=>o.id!==a)},N=a=>{m.value=[],m.value.push(a),C(),w.value=!1},h=i(!1),_=i([]),Y=a=>{_.value=_.value.filter(o=>o.id!==a)},j=a=>{a.forEach(o=>{_.value.find(l=>l.id==o.id)||_.value.push(o)}),h.value=!1},q=i([]);(()=>{Ve({}).then(a=>{q.value=a.lists})})();const k=i(1),B=i(!0),C=()=>{const a=_.value.map(l=>({id:l.product_id,stock:l.new_stock||0,stocks:l.stock||0})),o=m.value.length;if(o>0&&a.length>0)try{a.forEach(l=>{if(l.stock*o>l.stocks)throw B.value=!1,new Error("\u8D85\u51FA\u4ED3\u5E93\u5E93\u5B58,\u8BF7\u91CD\u65B0\u8BBE\u7F6E")})}catch{F.error("\u8D85\u51FA\u4ED3\u5E93\u5E93\u5B58,\u8BF7\u91CD\u65B0\u8BBE\u7F6E");return}B.value=!0},G=Fe(),K=async()=>{if(p.value==""){F.error("\u8BF7\u9009\u62E9\u4ED3\u5E93");return}if(C(),B.value==!1)return;const a=_.value.map(l=>({id:l.product_id,stock:l.new_stock||0,batch:l.batch||0})),o=m.value.map(l=>l.id);if(o.length>1){F.error("\u95E8\u5E97\u4E0D\u80FD\u8D85\u8FC7\u4E00\u4E2A");return}Ee({product_arr:a,store_arr:o,stock_type:k.value,warehouse_id:p.value,delivery_time:d.manufacture,mark:d.remark}).then(l=>{setTimeout(()=>{G.push({path:"/warehouse/outbound_order"})},2e3)})};return T(),(a,o)=>{const l=oe,x=ue,c=le,W=X,A=ae,v=re,r=se,U=ie,L=ne,S=ee,H=te,J=pe,Q=ce,R=de,Z=_e,z=me,I=ve("perms");return E(),b(z,null,{default:u(()=>[xe,f("div",null,[e(J,{ref_key:"formRef",ref:P,model:s(d),"label-width":"90px"},{default:u(()=>[e(c,{label:"\u4ED3\u5E93",prop:"uid"},{default:u(()=>[e(x,{modelValue:s(p),"onUpdate:modelValue":o[0]||(o[0]=t=>D(p)?p.value=t:null),style:{width:"240px"}},{default:u(()=>[(E(!0),be(ke,null,De(s(g),t=>(E(),b(l,{key:t.id,label:t.name,value:t.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),e(c,{label:"\u9001\u8D27\u65F6\u95F4"},{default:u(()=>[e(W,{readonly:!1,class:"flex-1 !flex",modelValue:s(d).manufacture,"onUpdate:modelValue":o[1]||(o[1]=t=>s(d).manufacture=t),clearable:"",type:"datetime","value-format":"YYYY-MM-DD",placeholder:"\u9009\u62E9\u751F\u4EA7\u65E5\u671F"},null,8,["modelValue"])]),_:1}),e(c,{label:"\u5907\u6CE8"},{default:u(()=>[e(A,{modelValue:s(d).remark,"onUpdate:modelValue":o[2]||(o[2]=t=>s(d).remark=t),type:"input",rows:"4"},null,8,["modelValue"])]),_:1}),e(c,{label:"\u95E8\u5E97",prop:"store_id"},{default:u(()=>[f("div",Ae,[f("div",Ue,[e(v,{type:"primary",onClick:o[3]||(o[3]=t=>w.value=!0)},{default:u(()=>[n("\u6DFB\u52A0\u95E8\u5E97")]),_:1})]),e(L,{data:s(m)},{default:u(()=>[e(r,{label:"ID",prop:"id","show-overflow-tooltip":""}),e(r,{label:"\u95E8\u5E97\u540D\u79F0",prop:"name","show-overflow-tooltip":""}),e(r,{label:"\u624B\u673A\u53F7\u7801",prop:"phone","show-overflow-tooltip":""}),e(r,{label:"\u8BE6\u7EC6\u5730\u5740",prop:"detailed_address","show-overflow-tooltip":""}),e(r,{label:"\u95E8\u5E97logo",prop:"image","show-overflow-tooltip":""},{default:u(({row:t})=>[e(U,{src:t.image,class:"w-[40px] h-[40px]","preview-teleported":!0},null,8,["src"])]),_:1}),e(r,{label:"\u8425\u4E1A\u72B6\u6001",prop:"is_show","show-overflow-tooltip":""},{default:u(({row:t})=>[n(Be(t.is_show?"\u8425\u4E1A":"\u6253\u70CA"),1)]),_:1}),e(r,{label:"\u64CD\u4F5C",width:"120",fixed:"right"},{default:u(({row:t})=>[M((E(),b(v,{type:"danger",link:"",onClick:y=>$(t.id)},{default:u(()=>[n(" \u5220\u9664 ")]),_:2},1032,["onClick"])),[[I,["system_store.system_store/delete"]]])]),_:1})]),_:1},8,["data"])])]),_:1}),e(c,{label:"\u5546\u54C1",prop:"store_id"},{default:u(()=>[f("div",Le,[f("div",Se,[e(v,{type:"primary",onClick:o[4]||(o[4]=t=>h.value=!0)},{default:u(()=>[n("\u6DFB\u52A0\u5546\u54C1")]),_:1})]),e(L,{data:s(_)},{default:u(()=>[e(r,{label:"\u5546\u54C1ID",prop:"id","show-overflow-tooltip":""}),e(r,{label:"\u5546\u54C1\u56FE\u7247",prop:"image","min-width":"80"},{default:u(({row:t})=>[e(U,{style:{width:"50px",height:"50px"},src:t.image,"preview-teleported":!0},null,8,["src"])]),_:1}),e(r,{label:"\u5546\u54C1\u540D\u79F0",prop:"store_name","min-width":"200","show-overflow-tooltip":""}),e(r,{label:"\u5206\u7C7B",prop:"cate_name","min-width":"120","show-overflow-tooltip":""}),e(r,{label:"\u5355\u4F4D",prop:"unit_name","min-width":"80","show-overflow-tooltip":""}),e(r,{label:"\u5546\u54C1\u4EF7\u683C",prop:"price","min-width":"100","show-overflow-tooltip":""}),e(r,{label:"\u5E93\u5B58",prop:"stock","min-width":"100","show-overflow-tooltip":""}),e(r,{label:"\u5206\u914D\u5E93\u5B58","min-width":"150"},{default:u(({row:t})=>[t.stock>0?(E(),b(A,{key:0,modelValue:t.new_stock,"onUpdate:modelValue":y=>t.new_stock=y,min:1,max:t.stock,onChange:C},null,8,["modelValue","onUpdate:modelValue","max"])):Ce("",!0)]),_:1}),e(r,{label:"\u64CD\u4F5C",width:"120",fixed:"right"},{default:u(({row:t})=>[M((E(),b(v,{type:"danger",link:"",onClick:y=>Y(t.id)},{default:u(()=>[n(" \u5220\u9664 ")]),_:2},1032,["onClick"])),[[I,["system_store.system_store/delete"]]])]),_:1})]),_:1},8,["data"])])]),_:1}),e(c,{label:"\u5E93\u5B58\u7C7B\u578B",prop:"stock_type"},{default:u(()=>[e(H,{modelValue:s(k),"onUpdate:modelValue":o[5]||(o[5]=t=>D(k)?k.value=t:null),class:"ml-6"},{default:u(()=>[e(S,{value:1,label:1},{default:u(()=>[n("\u5206\u914D\u552E\u5356\u5E93\u5B58")]),_:1}),e(S,{value:2,label:2},{default:u(()=>[n("\u5206\u914D\u5151\u6362\u5E93\u5B58")]),_:1})]),_:1},8,["modelValue"]),Re]),_:1}),e(c,{label:""},{default:u(()=>[e(v,{onClick:K,type:"primary",class:"w-40"},{default:u(()=>[n("\u63D0\u4EA4")]),_:1})]),_:1})]),_:1},8,["model"])]),e(R,{modelValue:s(w),"onUpdate:modelValue":o[6]||(o[6]=t=>D(w)?w.value=t:null),title:"\u9009\u62E9\u95E8\u5E97",width:"70%"},{default:u(()=>[e(Q,{onOnBindStore:N,is_selection:0})]),_:1},8,["modelValue"]),e(R,{modelValue:s(h),"onUpdate:modelValue":o[7]||(o[7]=t=>D(h)?h.value=t:null),title:"\u9009\u62E9\u5546\u54C1",width:"70%"},{default:u(()=>[e(Z,{onOnBindStore:j,is_warehouse:"1",warehouse_id:s(p)},null,8,["warehouse_id"])]),_:1},8,["modelValue"])]),_:1})}}});export{gt as default};