import{a0 as W,G as X,H as Y,k as ee,D as ue,C as le,w as te,M as oe,b as ae,N as re,F as se,I as ie,L as de}from"./element-plus.78e68aed.js";import{a as pe,b as ne,c as me,_ as _e}from"./store_product.3ba65c83.js";import{_ as ce}from"./picker.15da75ec.js";import{q as fe}from"./index.b18da889.js";import{d as L,s as Fe,r as F,Z as S,i as be,ap as Ee,o as b,K as E,L as a,a as C,S as x,u as t,U as u,R as p,Q as h,M as ge,j as Ce}from"./@vue.18505fe0.js";import"./lodash.60201f64.js";import{a as Be,u as Ve}from"./vue-router.101084e3.js";import{a as ve}from"./store_category.b3e75a16.js";import{a as ye}from"./store_product_unit.3306f523.js";import"./lodash-es.f52bd8b1.js";import"./async-validator.fb49d0f5.js";import"./@vueuse.fbc6a400.js";import"./@element-plus.edbd5a83.js";import"./dayjs.8ae0c638.js";import"./axios.2b8d80bd.js";import"./@ctrl.b082b0c1.js";import"./normalize-wheel-es.8aeb3683.js";import"./@popperjs.36402333.js";import"./index.vue_vue_type_script_setup_true_lang.3c4454b7.js";import"./usePaging.6a6670f9.js";import"./useDictOptions.0e0294ee.js";import"./system_store.fdf20cc8.js";import"./index.68558adb.js";import"./index.vue_vue_type_style_index_0_scoped_d380c88d_lang.d9a16ced.js";import"./index.d0196d59.js";import"./index.9895a04d.js";import"./vuedraggable.d1fd737a.js";import"./vue.feef8fd6.js";import"./sortablejs.c8f4cbb7.js";import"./pinia.a969beab.js";import"./css-color-function.b82a2ce7.js";import"./color.b905eb26.js";import"./clone.e1fb2883.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.495afef3.js";import"./vue-clipboard3.cb649e18.js";import"./clipboard.4592e390.js";import"./echarts.5016c48c.js";import"./zrender.58d022a1.js";import"./tslib.60310f1a.js";import"./highlight.js.31cd7941.js";import"./@highlightjs.b0c09b66.js";const De={class:"mb-4 text-lg font-bold"},we={style:{width:"500px"}},he=C("div",{class:"w-full",style:{color:"#64748b"}},"\u53EF\u9009\u62E9\u5C06\u5546\u54C1\u540C\u6B65\u5230\u54EA\u4E9B\u95E8\u5E97\u4F7F\u7528",-1),ke={class:"mb-2"},Ue=L({name:"storeProductEdit"}),wu=L({...Ue,props:{dictData:{type:Object,default:()=>({})}},emits:["success","close"],setup(qe,{emit:Ae}){const k=Fe(),{removeTab:R}=fe(),m=F("add"),l=S({id:"",image:"",store_name:"",bar_code:"",cate_arr:[],cate_id:"",price:"",unit:"",stock:"",cost:"",purchase:"",rose:"0",is_return:1,is_store_all:1}),f=F(!1),_=F([]),N=r=>{_.value=_.value.filter(e=>e.id!==r)},P=r=>{r.forEach(e=>{_.value.find(d=>d.id==e.id)||_.value.push(e)}),f.value=!1};let B,V,v=F(!1),y;be(()=>{});const z=r=>(y=r,v.value=!0,U.lazyLoad(V,B),!1),U={value:"id",label:"name",lazy:!0,lazyLoad(r,e){B||(B=e),V||(V=r);let d=r.value||0,s={};v.value?(s={name:y},y||(s={pid:d,page_size:1e4})):s={pid:d,page_size:1e4},ve({...s}).then(i=>{e(i.lists.map(c=>(c.leaf=c.is_children==0,v.value=!1,c)))})}},q=F([]);(()=>{ye({}).then(r=>{q.value=r.lists})})();const I=S({store_name:[{required:!0,message:"\u8BF7\u8F93\u5165\u5546\u54C1\u540D\u79F0",trigger:["blur"]}],bar_code:[{required:!0,message:"\u8BF7\u8F93\u5165\u5546\u54C1\u6761\u7801",trigger:["blur"]}],cate_id:[{required:!0,message:"\u8BF7\u8F93\u5165\u5546\u54C1\u5206\u7C7B",trigger:["blur","change"]}],cate_arr:[{required:!0,message:"\u8BF7\u9009\u62E9\u5546\u54C1\u5206\u7C7B",trigger:["blur","change"]}],price:[{required:!0,message:"\u8BF7\u8F93\u5165\u5546\u54C1\u4EF7\u683C",trigger:["blur"]}],unit:[{required:!0,message:"\u8BF7\u8F93\u5165\u5546\u54C1\u5355\u4F4D",trigger:["blur","change"]}],stock:[{required:!0,message:"\u8BF7\u8F93\u5165\u5E93\u5B58",trigger:["blur"]}],cost:[{required:!0,message:"\u8BF7\u8F93\u5165\u6210\u672C\u4EF7",trigger:["blur"]}],purchase:[{required:!0,message:"\u8BF7\u8F93\u5165\u91C7\u8D2D\u4EF7",trigger:["blur"]}],image:[{required:!0,message:"\u8BF7\u8F93\u5165\u5546\u54C1\u56FE\u7247",trigger:["blur","change"]}]}),M=async r=>{for(const e in l)r[e]!=null&&r[e]!=null&&(l[e]=r[e]);l.cate_arr[0]&&(l.cate_arr=l.cate_arr.map(e=>Number(e)))},T=async r=>{const e=await pe({id:r.id});M(e)},$=Be(),D=Ve(),j=async()=>{var e;await((e=k.value)==null?void 0:e.validate());let r={...l};if(l.is_store_all==0&&m.value=="add"?r.store_arr=_.value.map(d=>d.id):m.value=="edit"&&(r.is_store_all=0),!r.cate_arr.length)return ee.error("\u8BF7\u9009\u62E9\u5546\u54C1\u5206\u7C7B");r.cate_id=r.cate_arr[r.cate_arr.length-1],delete r.cate_arr,m.value=="edit"?await ne(r):await me(r),R(),$.push({path:"/store/store_product"})};return D.query.id&&D.query.mode=="edit"&&(m.value="edit",T({id:D.query.id})),(r,e)=>{const d=ce,s=ue,i=le,c=W,g=X,A=Y,w=te,n=oe,G=ae,O=re,H=se,K=_e,Q=ie,Z=de,J=Ee("perms");return b(),E(Z,null,{default:a(()=>[C("div",De,x(t(m)=="add"?"\u6DFB\u52A0\u5546\u54C1":"\u7F16\u8F91\u5546\u54C1"),1),C("div",we,[u(H,{ref_key:"formRef",ref:k,model:t(l),"label-width":"90px",rules:t(I)},{default:a(()=>[u(s,{label:"\u5546\u54C1\u56FE\u7247",prop:"image"},{default:a(()=>[u(d,{modelValue:t(l).image,"onUpdate:modelValue":e[0]||(e[0]=o=>t(l).image=o),limit:1},null,8,["modelValue"])]),_:1}),u(s,{label:"\u5546\u54C1\u540D\u79F0",prop:"store_name"},{default:a(()=>[u(i,{modelValue:t(l).store_name,"onUpdate:modelValue":e[1]||(e[1]=o=>t(l).store_name=o),clearable:"",placeholder:"\u8BF7\u8F93\u5165\u5546\u54C1\u540D\u79F0",readonly:!1},null,8,["modelValue"])]),_:1}),u(s,{label:"\u5546\u54C1\u6761\u7801",prop:"bar_code"},{default:a(()=>[u(i,{modelValue:t(l).bar_code,"onUpdate:modelValue":e[2]||(e[2]=o=>t(l).bar_code=o),clearable:"",placeholder:"\u8BF7\u8F93\u5165\u5546\u54C1\u6761\u7801",readonly:!1},null,8,["modelValue"])]),_:1}),u(s,{label:"\u5546\u54C1\u5206\u7C7B",prop:"cate_arr"},{default:a(()=>[u(c,{style:{width:"100%"},modelValue:t(l).cate_arr,"onUpdate:modelValue":e[3]||(e[3]=o=>t(l).cate_arr=o),class:"caser",filterable:"","before-filter":z,props:U,placeholder:"\u8BF7\u9009\u62E9\u5546\u54C1\u5206\u7C7B"},null,8,["modelValue"])]),_:1}),u(s,{label:"\u5546\u54C1\u4EF7\u683C",prop:"price"},{default:a(()=>[u(i,{modelValue:t(l).price,"onUpdate:modelValue":e[4]||(e[4]=o=>t(l).price=o),clearable:"",placeholder:"\u8BF7\u8F93\u5165\u5546\u54C1\u4EF7\u683C",readonly:!1},null,8,["modelValue"])]),_:1}),u(s,{label:"\u5546\u54C1\u5355\u4F4D",prop:"unit"},{default:a(()=>[u(c,{style:{width:"100%"},modelValue:t(l).unit,"onUpdate:modelValue":e[5]||(e[5]=o=>t(l).unit=o),options:t(q),props:{value:"id",label:"name",emitPath:!1},placeholder:"\u8BF7\u9009\u62E9\u5546\u54C1\u5355\u4F4D"},null,8,["modelValue","options"])]),_:1}),u(s,{label:"\u5E93\u5B58",prop:"stock"},{default:a(()=>[u(i,{modelValue:t(l).stock,"onUpdate:modelValue":e[6]||(e[6]=o=>t(l).stock=o),clearable:"",placeholder:"\u8BF7\u8F93\u5165\u5E93\u5B58",readonly:!1},null,8,["modelValue"])]),_:1}),u(s,{label:"\u6210\u672C\u4EF7",prop:"cost"},{default:a(()=>[u(i,{modelValue:t(l).cost,"onUpdate:modelValue":e[7]||(e[7]=o=>t(l).cost=o),clearable:"",placeholder:"\u8BF7\u8F93\u5165\u6210\u672C\u4EF7",readonly:!1},null,8,["modelValue"])]),_:1}),u(s,{label:"\u91C7\u8D2D\u4EF7",prop:"purchase"},{default:a(()=>[u(i,{modelValue:t(l).purchase,"onUpdate:modelValue":e[8]||(e[8]=o=>t(l).purchase=o),clearable:"",placeholder:"\u8BF7\u8F93\u5165\u91C7\u8D2D\u4EF7",readonly:!1},null,8,["modelValue"])]),_:1}),u(s,{label:"\u4E0A\u6D6E\u6BD4\u4F8B",prop:"rose"},{default:a(()=>[u(i,{modelValue:t(l).rose,"onUpdate:modelValue":e[9]||(e[9]=o=>t(l).rose=o),clearable:"",placeholder:"\u8BF7\u8F93\u5165\u4E0A\u6D6E\u6BD4\u4F8B",readonly:!1},null,8,["modelValue"])]),_:1}),u(s,{label:"\u9000\u8D27",prop:"is_return"},{default:a(()=>[u(A,{modelValue:t(l).is_return,"onUpdate:modelValue":e[10]||(e[10]=o=>t(l).is_return=o)},{default:a(()=>[u(g,{label:1},{default:a(()=>[p("\u652F\u6301")]),_:1}),u(g,{label:0},{default:a(()=>[p("\u4E0D\u652F\u6301")]),_:1})]),_:1},8,["modelValue"])]),_:1}),t(m)=="add"?(b(),E(s,{key:0,label:"\u6240\u5C5E\u95E8\u5E97",prop:"store_id"},{default:a(()=>[u(A,{modelValue:t(l).is_store_all,"onUpdate:modelValue":e[11]||(e[11]=o=>t(l).is_store_all=o)},{default:a(()=>[u(g,{label:1},{default:a(()=>[p("\u5168\u90E8\u95E8\u5E97")]),_:1}),u(g,{label:0},{default:a(()=>[p("\u90E8\u5206\u95E8\u5E97")]),_:1})]),_:1},8,["modelValue"]),he,C("div",ke,[t(l).is_store_all==0?(b(),E(w,{key:0,type:"primary",onClick:e[12]||(e[12]=o=>f.value=!0)},{default:a(()=>[p("\u6DFB\u52A0\u95E8\u5E97")]),_:1})):h("",!0)]),t(l).is_store_all==0?(b(),E(O,{key:0,data:t(_)},{default:a(()=>[u(n,{label:"ID",prop:"id","show-overflow-tooltip":""}),u(n,{label:"\u95E8\u5E97\u540D\u79F0",prop:"name","show-overflow-tooltip":""}),u(n,{label:"\u624B\u673A\u53F7\u7801",prop:"phone","show-overflow-tooltip":""}),u(n,{label:"\u8BE6\u7EC6\u5730\u5740",prop:"detailed_address","show-overflow-tooltip":""}),u(n,{label:"\u95E8\u5E97logo",prop:"image","show-overflow-tooltip":""},{default:a(({row:o})=>[u(G,{src:o.image,class:"w-[50px] h-[50px]"},null,8,["src"])]),_:1}),u(n,{label:"\u8425\u4E1A\u72B6\u6001",prop:"is_show","show-overflow-tooltip":""},{default:a(({row:o})=>[p(x(o.is_show?"\u8425\u4E1A":"\u6253\u70CA"),1)]),_:1}),u(n,{label:"\u64CD\u4F5C",width:"120",fixed:"right"},{default:a(({row:o})=>[ge((b(),E(w,{type:"danger",link:"",onClick:xe=>N(o.id)},{default:a(()=>[p(" \u5220\u9664 ")]),_:2},1032,["onClick"])),[[J,["system_store.system_store/delete"]]])]),_:1})]),_:1},8,["data"])):h("",!0)]),_:1})):h("",!0),u(s,{label:""},{default:a(()=>[u(w,{onClick:j,type:"primary",class:"w-40"},{default:a(()=>[p("\u63D0\u4EA4")]),_:1})]),_:1})]),_:1},8,["model","rules"])]),u(Q,{modelValue:t(f),"onUpdate:modelValue":e[13]||(e[13]=o=>Ce(f)?f.value=o:null),title:"\u9009\u62E9\u95E8\u5E97",width:"70%"},{default:a(()=>[u(K,{onOnBindStore:P})]),_:1},8,["modelValue"])]),_:1})}}});export{wu as default};