import{G as X,H as Y,k as U,J as ee,K as te,D as oe,w as ue,M as le,b as ae,N as se,C as re,F as ie,I as ne,L as pe}from"./element-plus.a63a26dd.js";import{_ as de}from"./index.vue_vue_type_script_setup_true_name_systemStoreLists_lang.5b5e293a.js";import{_ as me}from"./index.vue_vue_type_script_setup_true_name_systemStoreLists_lang.7c721c19.js";import{k as ce}from"./index.92d8c5bb.js";import{e as _e}from"./store_product.8bd42dba.js";import{d as I,s as fe,r,Z as Ee,ap as he,o as _,K as v,L as u,a as c,U as e,u as i,j as B,c as we,T as ve,a9 as be,R as n,S as Be,M as R,Q as ke}from"./@vue.18505fe0.js";import"./lodash.2473fc51.js";import{u as Ce,a as De}from"./vue-router.101084e3.js";import{a as ye}from"./store_product_unit.35dd8558.js";import{a as ge}from"./warehouse.0fb5e6df.js";import"./lodash-es.f52bd8b1.js";import"./async-validator.fb49d0f5.js";import"./@vueuse.fbc6a400.js";import"./@element-plus.edbd5a83.js";import"./dayjs.4884cfc2.js";import"./axios.932d3f8a.js";import"./@ctrl.b082b0c1.js";import"./normalize-wheel-es.8aeb3683.js";import"./@popperjs.36402333.js";import"./index.vue_vue_type_script_setup_true_lang.ecb80feb.js";import"./usePaging.6a6670f9.js";import"./useDictOptions.3cac3739.js";import"./store_branch_product.df35f6d8.js";import"./warehouse_product_storege.3d014b40.js";import"./system_store.2e10935c.js";import"./pinia.a969beab.js";import"./css-color-function.9f6a56f3.js";import"./color.d1bc3784.js";import"./clone.83700f2e.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.fcc9be76.js";import"./vue-clipboard3.9e751565.js";import"./clipboard.dda64e67.js";import"./echarts.5016c48c.js";import"./zrender.58d022a1.js";import"./tslib.60310f1a.js";import"./highlight.js.31cd7941.js";import"./@highlightjs.b0c09b66.js";const Fe=c("div",{class:"mb-4 text-lg font-bold"},"\u5BFC\u5165\u5546\u54C1\u5230\u95E8\u5E97",-1),xe={class:"flex-1 w-full"},Ve={class:"mb-2"},Se={class:"flex-1 w-full"},Ae={class:"mb-2"},Le=c("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),Ue=I({name:"storeProductEdit"}),yt=I({...Ue,props:{dictData:{type:Object,default:()=>({})}},emits:["success","close"],setup(Re,{emit:Ie}){const y=Ce(),P=fe();ce(),r("add");const p=r(""),g=r([]);r(0);const T=Ee({store_id:""});y.query.warehouse_id&&(p.value=parseInt(y.query.warehouse_id));const $=()=>{ge({}).then(a=>{g.value=a.lists})},f=r(!1),d=r([]),N=a=>{d.value=d.value.filter(o=>o.id!==a)},M=a=>{a.forEach(o=>{d.value.find(l=>l.id==o.id)||d.value.push(o)}),C(),f.value=!1},E=r(!1),m=r([]),O=a=>{m.value=m.value.filter(o=>o.id!==a)},j=a=>{a.forEach(o=>{m.value.find(l=>l.id==o.id)||m.value.push(o)}),E.value=!1},q=r([]);(()=>{ye({}).then(a=>{q.value=a.lists})})();const b=r(1),k=r(!0),C=()=>{const a=m.value.map(l=>({id:l.product_id,stock:l.new_stock||0,stocks:l.stock||0})),o=d.value.length;if(o>0&&a.length>0)try{a.forEach(l=>{if(l.stock*o>l.stocks)throw k.value=!1,new Error("\u8D85\u51FA\u4ED3\u5E93\u5E93\u5B58,\u8BF7\u91CD\u65B0\u8BBE\u7F6E")})}catch{U.error("\u8D85\u51FA\u4ED3\u5E93\u5E93\u5B58,\u8BF7\u91CD\u65B0\u8BBE\u7F6E");return}k.value=!0},G=De(),K=async()=>{if(p.value==""){U.error("\u8BF7\u9009\u62E9\u4ED3\u5E93");return}if(C(),k.value==!1)return;const a=m.value.map(l=>({id:l.product_id,stock:l.new_stock||0,batch:l.batch||0})),o=d.value.map(l=>l.id);_e({product_arr:a,store_arr:o,stock_type:b.value,warehouse_id:p.value}).then(l=>{setTimeout(()=>{G.push({path:"/warehouse/outbound_list"})},2e3)})};return $(),(a,o)=>{const l=ee,F=te,h=oe,w=ue,s=le,x=ae,V=se,H=re,S=X,J=Y,Q=ie,W=me,A=ne,Z=de,z=pe,L=he("perms");return _(),v(z,null,{default:u(()=>[Fe,c("div",null,[e(Q,{ref_key:"formRef",ref:P,model:i(T),"label-width":"90px"},{default:u(()=>[e(h,{label:"\u4ED3\u5E93",prop:"uid"},{default:u(()=>[e(F,{modelValue:i(p),"onUpdate:modelValue":o[0]||(o[0]=t=>B(p)?p.value=t:null),style:{width:"240px"}},{default:u(()=>[(_(!0),we(ve,null,be(i(g),t=>(_(),v(l,{key:t.id,label:t.name,value:t.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),e(h,{label:"\u95E8\u5E97",prop:"store_id"},{default:u(()=>[c("div",xe,[c("div",Ve,[e(w,{type:"primary",onClick:o[1]||(o[1]=t=>f.value=!0)},{default:u(()=>[n("\u6DFB\u52A0\u95E8\u5E97")]),_:1})]),e(V,{data:i(d)},{default:u(()=>[e(s,{label:"ID",prop:"id","show-overflow-tooltip":""}),e(s,{label:"\u95E8\u5E97\u540D\u79F0",prop:"name","show-overflow-tooltip":""}),e(s,{label:"\u624B\u673A\u53F7\u7801",prop:"phone","show-overflow-tooltip":""}),e(s,{label:"\u8BE6\u7EC6\u5730\u5740",prop:"detailed_address","show-overflow-tooltip":""}),e(s,{label:"\u95E8\u5E97logo",prop:"image","show-overflow-tooltip":""},{default:u(({row:t})=>[e(x,{src:t.image,class:"w-[40px] h-[40px]","preview-teleported":!0},null,8,["src"])]),_:1}),e(s,{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(s,{label:"\u64CD\u4F5C",width:"120",fixed:"right"},{default:u(({row:t})=>[R((_(),v(w,{type:"danger",link:"",onClick:D=>N(t.id)},{default:u(()=>[n(" \u5220\u9664 ")]),_:2},1032,["onClick"])),[[L,["system_store.system_store/delete"]]])]),_:1})]),_:1},8,["data"])])]),_:1}),e(h,{label:"\u5546\u54C1",prop:"store_id"},{default:u(()=>[c("div",Se,[c("div",Ae,[e(w,{type:"primary",onClick:o[2]||(o[2]=t=>E.value=!0)},{default:u(()=>[n("\u6DFB\u52A0\u5546\u54C1")]),_:1})]),e(V,{data:i(m)},{default:u(()=>[e(s,{label:"\u5546\u54C1ID",prop:"id","show-overflow-tooltip":""}),e(s,{label:"\u5546\u54C1\u56FE\u7247",prop:"image","min-width":"80"},{default:u(({row:t})=>[e(x,{style:{width:"50px",height:"50px"},src:t.image,"preview-teleported":!0},null,8,["src"])]),_:1}),e(s,{label:"\u5546\u54C1\u540D\u79F0",prop:"store_name","min-width":"200","show-overflow-tooltip":""}),e(s,{label:"\u5206\u7C7B",prop:"cate_name","min-width":"120","show-overflow-tooltip":""}),e(s,{label:"\u5355\u4F4D",prop:"unit_name","min-width":"80","show-overflow-tooltip":""}),e(s,{label:"\u5546\u54C1\u4EF7\u683C",prop:"price","min-width":"100","show-overflow-tooltip":""}),e(s,{label:"\u5E93\u5B58",prop:"stock","min-width":"100","show-overflow-tooltip":""}),e(s,{label:"\u5206\u914D\u5E93\u5B58","min-width":"150"},{default:u(({row:t})=>[t.stock>0?(_(),v(H,{key:0,modelValue:t.new_stock,"onUpdate:modelValue":D=>t.new_stock=D,min:1,max:t.stock,onChange:C},null,8,["modelValue","onUpdate:modelValue","max"])):ke("",!0)]),_:1}),e(s,{label:"\u64CD\u4F5C",width:"120",fixed:"right"},{default:u(({row:t})=>[R((_(),v(w,{type:"danger",link:"",onClick:D=>O(t.id)},{default:u(()=>[n(" \u5220\u9664 ")]),_:2},1032,["onClick"])),[[L,["system_store.system_store/delete"]]])]),_:1})]),_:1},8,["data"])])]),_:1}),e(h,{label:"\u5E93\u5B58\u7C7B\u578B",prop:"stock_type"},{default:u(()=>[e(J,{modelValue:i(b),"onUpdate:modelValue":o[3]||(o[3]=t=>B(b)?b.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"]),Le]),_:1}),e(h,{label:""},{default:u(()=>[e(w,{onClick:K,type:"primary",class:"w-40"},{default:u(()=>[n("\u63D0\u4EA4")]),_:1})]),_:1})]),_:1},8,["model"])]),e(A,{modelValue:i(f),"onUpdate:modelValue":o[4]||(o[4]=t=>B(f)?f.value=t:null),title:"\u9009\u62E9\u95E8\u5E97",width:"70%"},{default:u(()=>[e(W,{onOnBindStore:M})]),_:1},8,["modelValue"]),e(A,{modelValue:i(E),"onUpdate:modelValue":o[5]||(o[5]=t=>B(E)?E.value=t:null),title:"\u9009\u62E9\u5546\u54C1",width:"70%"},{default:u(()=>[e(Z,{onOnBindStore:j,is_warehouse:"1",warehouse_id:i(p)},null,8,["warehouse_id"])]),_:1},8,["modelValue"])]),_:1})}}});export{yt as default};