goodsInventoryAdd-CC8zzjMs.js 16 KB

1
  1. import{d as ze,u as Se,r as v,a as Te,c as se,o as Fe,a3 as Ye,D as qe,f as c,i as n,w as o,h as $,k as _,l as w,s as Re,E as A,p as g,a4 as Me,q as Be,v as We,x as s,t as r,F as D,y as L,m as y,a2 as de,Y as Q,L as Ne,_ as He}from"./index-GCZD4BFP.js";import{b as Pe,c as Ke,e as Je,d as Oe,f as Qe}from"./goodsInventory-2NVqbt9i.js";import{c as X,d as Xe,s as Ze,k as xe}from"./goodsExchange-CxLOr8W3.js";import{a as el}from"./setting-CjsMgkQh.js";import{g as ll}from"./basicSetting-B0Aq66-n.js";const tl={class:"bg-in-stock dark:!bg-[#060818]"},al={style:{width:"100%"}},ol={key:0},nl={key:0},ul={key:0},sl={key:0},dl={key:0},rl={key:0},il={class:"mx"},vl={style:{width:"100%",display:"block"}},cl={key:0},_l={key:0},pl={key:1},ml={key:0},yl={key:1},gl={key:0},fl={key:1},hl={key:0},bl={class:"footer"},kl={style:{display:"flex","align-items":"center","justify-content":"flex-end",padding:"10px 0"}},wl=ze({__name:"goodsInventoryAdd",setup(Vl){const{t:i}=Se(),Z=Be(),G=Re(),h=We(),E=v(!1),I=v([]),q=v(!1),F=v([]);v([]),v([]);const p=v(""),u=v(""),a=v({product_list:[],inventory_time:"",inventory_person_id:"",creator_id:"",has_notice:!1}),re=v({inventory_person_id:{required:!0,message:i("change")+i("inventoryPeople"),trigger:"change"},warehouse_id:{required:!0,message:i("change")+i("warechouse"),trigger:"change"},creator_id:{required:!0,message:i("change")+i("creator"),trigger:"change"}});v(null);const R=v([]),M=v(!1),V=v({}),Y=v("");v([]);const k=v(""),B=v(!1),j=v(!1),U=v([]),C=Te({page_no:1,page_size:10,keyWord:""}),x=()=>{j.value=!1},W=()=>{X(C,a.value.warehouse_id).then(e=>{U.value=e})},N=v([]),ie=e=>{N.value=e.map(t=>t)},ve=()=>{N.value.length>=1?(a.value.product_list=N.value.map(e=>e),j.value=!1):A.error(i("change")+i("goods_info"))},ce=e=>{C.page_size=e,W()},_e=e=>{C.page_no=e,W()},H=se(()=>h.getters.user);se(()=>{const e=new Date;return`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()} ${e.getHours()}:${e.getMinutes()}:${e.getSeconds()}`});const P=v([]),pe=()=>{Ke().then(e=>{P.value=e})};Fe(()=>{G.query.type==="view"?(u.value="view",p.value=G.query.id,ne()):G.query.type==="edit"&&(u.value="edit",p.value=G.query.id,ne()),a.value.creator_id=H.value.uid,a.value.inventory_person_id=H.value.uid,a.value.dept_id=H.value.dept_id,Ve(),ae(),Ue(),pe()});const me=e=>{if(a.value.product_list=[],e==="ALL_INVENTORY"){if(!a.value.warehouse_id){h.dispatch("message/error",i("change")+i("warechouse")+"!");return}E.value=!0,X(C,a.value.warehouse_id,"le").then(t=>{a.value.product_list=t.records,B.value=!0,E.value=!1}).catch(()=>{E.value=!1})}else B.value=!1},K=v(),ye=async()=>{if(V.value.bar_code==="")return h.dispatch("message/error","请录入正确的sku");await Xe("inventory",V.value.bar_code,Y.value.replace(/\s+/g,"")).then(async e=>{Y.value="",a.value.product_list[k.value].sn_code_list.find(d=>d.sn_code===e.sn_code&&d.sku===e.sku)||(p.value?await Ze({send_order_id:p.value,item_id:a.value.product_list[k.value].id,sku:e}).then(()=>{a.value.product_list[k.value].sn_code_list.push(e)}):a.value.product_list[k.value].sn_code_list.push(e)),a.value.product_list[k.value].inventory_num=a.value.product_list[k.value].sn_code_list.length,V.value.bar_code="",Q(()=>{K.value.focus()})})},ee=v(),ge=()=>{xe(a.value.warehouse_id,V.value.bar_code.replace(/\s+/g,"")).then(e=>{e.sn_code_list=[];const t=a.value.product_list.findIndex(d=>d.goods_id===e.goods_id&&d.product_id===e.product_id&&d.product_vo.sku===e.product_vo.sku);t===-1?(k.value=a.value.product_list.length,a.value.product_list.push(e)):k.value=t,e.product_vo.have_sn?Q(()=>{ee.value.focus()}):a.value.product_list[k.value].inventory_num+=1})},fe=()=>{if(!a.value.warehouse_id){h.dispatch("message/error",i("change")+i("warechouse")+"!");return}if(!a.value.inventory_type){h.dispatch("message/error",i("change")+i("inventoryType")+"!");return}M.value=!0,Q(()=>{K.value.focus()})},he=e=>{const t=P.value.find(d=>d.id===e);return t?t.nickname:i("unknown")},le=e=>{const t=I.value.find(d=>d.id===e);return t?t.nickname:i("unknown")},be=e=>{const t=R.value.find(d=>d.value===e);return t?t.label:i("unknown")},ke=e=>{const t=F.value.find(d=>d.id===e);return t?t.name:i("unknown")},we=()=>{},te=()=>{h.dispatch("forceUpdate")},Ve=()=>{Ye({page_no:1,page_size:9999,user_state:0}).then(e=>{I.value=e.data})},$e=()=>{if(!a.value.reject_reason){A.error(i("reject_reason"));return}Ne.confirm(i("confirm_rejec"),i("prompt"),{type:"warning"}).then(()=>{Qe(p.value,{status:"REJECT",reject_reason:a.value.reject_reason}).then(()=>{A.success(i("rejected"));const{callback:e}=h.state.route.params;typeof e=="function"&&e(),h.dispatch("delCurrentViews",{view:h.state.route,$router:h.state.router}),h.state.router.push({name:"goodsInventory"})})}).catch(()=>{})},ae=e=>{ll().then(t=>{F.value=t})},oe=v(),Ce=()=>{oe.value.validate(e=>{if(e){const t={...a.value};t.warehouse_id&&(t.warehouse_name=F.value.find(d=>d.id===t.warehouse_id).name),t.creator_id&&(t.creator=I.value.find(d=>d.id===t.creator_id).real_name),t.inventory_person_id&&(t.inventory_person=I.value.find(d=>d.id===t.inventory_person_id).real_name),t.product_list=t.product_list.map(d=>({diff_num:d.usable_stock-d.inventory_num,inventory_num:d.inventory_num*1,product_name:d.product_name,product_sn:d.product_sn,product_id:d.product_id,specification:d.product_specification,unit:d.product_unit,remark:d.remark,product_stock_id:d.id,sn_code_list:d.sn_code_list})),p.value?Je(p.value,t).then(()=>{A.success(i("edit_success")+"!"),Z.push({name:"goodsInventory"})}):Oe(t).then(()=>{A.success(i("add_success")+"!"),Z.push({name:"goodsInventory"})})}})},Ie=async()=>{if(!a.value.warehouse_id){A.error(i("change")+i("warechouse")+"!");return}X(C,a.value.warehouse_id,"le").then(e=>{U.value=e,j.value=!0})},Ue=()=>{el({dictType:"inventory_type"}).then(e=>{R.value=e.data})},Ae=e=>{a.value.product_list=[]},ne=()=>{Pe(G.query.id).then(e=>{e.product_list||(e.product_list=[]),a.value=e,ae()})};return(e,t)=>{const d=g("el-input"),f=g("el-form-item"),De=g("el-date-picker"),z=g("el-option"),S=g("el-select"),Le=g("el-switch"),b=g("el-button"),Ge=g("el-popover"),m=g("el-table-column"),ue=g("el-table"),J=g("el-form"),O=g("el-dialog"),Ee=g("el-pagination"),je=Me("loading");return qe((s(),c("div",tl,[n(J,{ref_key:"goodsInventoryAddFormRef",ref:oe,model:a.value,rules:re.value,"label-width":"120px",inline:"",class:"change-form"},{default:o(()=>[$("h3",al,r(e.$t("inventory")),1),u.value==="edit"||u.value==="view"?(s(),_(f,{key:0,label:e.$t("inventorySn"),prop:"sn",class:"change-form-item"},{default:o(()=>[n(d,{modelValue:a.value.sn,"onUpdate:modelValue":t[0]||(t[0]=l=>a.value.sn=l),disabled:!0},null,8,["modelValue"])]),_:1},8,["label"])):w("",!0),n(f,{label:e.$t("inventory_time"),prop:"inventory_time",class:"change-form-item"},{default:o(()=>[p.value&&u.value!=="edit"?(s(),c("span",ol,r(a.value.inventory_time),1)):(s(),_(De,{key:1,modelValue:a.value.inventory_time,"onUpdate:modelValue":t[1]||(t[1]=l=>a.value.inventory_time=l),format:"YYYY-MM-DD HH:mm:ss","value-format":"YYYY-MM-DD HH:mm:ss",type:"datetime",disabled:u.value==="detail"||u.value==="audit"||u.value==="check",placeholder:e.$t("change")+e.$t("date")},null,8,["modelValue","disabled","placeholder"]))]),_:1},8,["label"]),n(f,{label:e.$t("warechouse"),prop:"warehouse_id",class:"change-form-item"},{default:o(()=>[p.value&&u.value!=="edit"?(s(),c("span",nl,r(ke(a.value.warehouse_id)),1)):(s(),_(S,{key:1,modelValue:a.value.warehouse_id,"onUpdate:modelValue":t[2]||(t[2]=l=>a.value.warehouse_id=l),onChange:Ae,disabled:u.value==="detail"||u.value==="audit"||u.value==="check"},{default:o(()=>[(s(!0),c(D,null,L(F.value,l=>(s(),_(z,{key:l.id,label:l.name,value:l.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"]))]),_:1},8,["label"]),n(f,{label:e.$t("inventoryPeople"),prop:"inventory_person_id",class:"change-form-item"},{default:o(()=>[p.value&&u.value!=="edit"?(s(),c("span",ul,r(le(a.value.inventory_person_id)),1)):(s(),_(S,{key:1,onChange:te,modelValue:a.value.inventory_person_id,"onUpdate:modelValue":t[3]||(t[3]=l=>a.value.inventory_person_id=l),disabled:u.value==="detail"||u.value==="audit"||u.value==="check"},{default:o(()=>[(s(!0),c(D,null,L(I.value,l=>(s(),_(z,{key:l.id,label:l.nickname,value:l.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"]))]),_:1},8,["label"]),n(f,{label:e.$t("creator"),prop:"creator_id",class:"change-form-item"},{default:o(()=>[p.value&&u.value!=="edit"?(s(),c("span",sl,r(le(a.value.creator_id)),1)):(s(),_(S,{key:1,modelValue:a.value.creator_id,"onUpdate:modelValue":t[4]||(t[4]=l=>a.value.creator_id=l),disabled:u.value==="detail"||u.value==="audit"||u.value==="check",onChange:te},{default:o(()=>[(s(!0),c(D,null,L(I.value,l=>(s(),_(z,{key:l.id,label:l.nickname,value:l.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"]))]),_:1},8,["label"]),n(f,{label:e.$t("inventoryType"),prop:"inventory_type",class:"change-form-item"},{default:o(()=>[p.value&&u.value!=="edit"?(s(),c("span",dl,r(be(a.value.inventory_type)),1)):(s(),_(S,{key:1,modelValue:a.value.inventory_type,"onUpdate:modelValue":t[5]||(t[5]=l=>a.value.inventory_type=l),onChange:t[6]||(t[6]=l=>me(l)),disabled:u.value==="detail"||u.value==="audit"||u.value==="check"},{default:o(()=>[(s(!0),c(D,null,L(R.value,l=>(s(),_(z,{key:l.id,label:l.label,value:l.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"]))]),_:1},8,["label"]),n(f,{label:e.$t("notifiedre")+":",prop:"has_notice",class:"change-form-item"},{default:o(()=>[n(Le,{modelValue:a.value.has_notice,"onUpdate:modelValue":t[7]||(t[7]=l=>a.value.has_notice=l),disabled:u.value==="view","inline-prompt":"","active-text":!0,"inactive-text":!1},null,8,["modelValue","disabled"])]),_:1},8,["label"]),a.value.has_notice?(s(),_(f,{key:1,label:e.$t("reviewer")+":",prop:"notice_user_id",class:"change-form-item"},{default:o(()=>[p.value&&u.value!=="edit"?(s(),c("span",rl,r(he(a.value.notice_user_id)),1)):(s(),_(S,{key:1,modelValue:a.value.notice_user_id,"onUpdate:modelValue":t[8]||(t[8]=l=>a.value.notice_user_id=l),disabled:u.value==="detail"||u.value==="audit"||u.value==="view"},{default:o(()=>[(s(!0),c(D,null,L(P.value,l=>(s(),_(z,{key:l.id,label:l.nickname,value:l.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"]))]),_:1},8,["label"])):w("",!0),$("div",il,[$("h3",null,r(e.$t("goods_inventory")),1),u.value!=="detail"&&u.value!=="view"?(s(),_(b,{key:0,class:"button",size:"mini",type:"primary",onClick:fe},{default:o(()=>[y(r(e.$t("goods_code")),1)]),_:1})):w("",!0),u.value!=="detail"&&u.value!=="view"?(s(),_(b,{key:1,class:"button",size:"mini",type:"primary",onClick:Ie,disabled:B.value},{default:o(()=>[y(r(e.$t("select")),1)]),_:1},8,["disabled"])):w("",!0)]),$("div",vl,[n(f,{style:{width:"100%"}},{default:o(()=>[n(ue,{data:a.value.product_list,border:"","cell-style":{textAlign:"center"},"header-cell-style":{textAlign:"center"},loading:E.value,style:{width:"100%","margin-top":"20px"}},{default:o(()=>[n(m,{label:e.$t("warechouse_code")},{default:o(l=>[l.row.area_stock_list?(s(),_(Ge,{key:0,placement:"right",trigger:"click"},{reference:o(()=>[l.row.area_stock_list.length!==0?(s(),c("span",cl,r(l.row.area_stock_list[0].warehouse_area_name),1)):w("",!0)]),default:o(()=>[$("div",null,[(s(!0),c(D,null,L(l.row.area_stock_list,T=>(s(),c("p",{key:T.id},r(T.warehouse_area_name),1))),128))])]),_:2},1024)):w("",!0)]),_:1},8,["label"]),n(m,{label:e.$t("goods_name")},{default:o(l=>[p.value?(s(),c("span",_l,r(l.row.product_vo.name),1)):(s(),c("span",pl,r(l.row.product_vo.name),1))]),_:1},8,["label"]),n(m,{label:"sku"},{default:o(l=>[p.value?(s(),c("span",yl,r(l.row.product_vo.sku),1)):(s(),c("span",ml,r(l.row.product_vo.sku),1))]),_:1}),n(m,{label:e.$t("goods_unit")},{default:o(l=>[p.value?(s(),c("span",fl,r(l.row.product_vo.unit),1)):(s(),c("span",gl,r(l.row.product_vo.unit),1))]),_:1},8,["label"]),n(m,{label:e.$t("stock")},{default:o(l=>[y(r(l.row.actual_stock),1)]),_:1},8,["label"]),n(m,{label:e.$t("inventory_num")},{default:o(l=>[u.value==="view"?(s(),c("span",hl,r(l.row.inventory_num),1)):(s(),_(d,{key:1,modelValue:l.row.inventory_num,"onUpdate:modelValue":T=>l.row.inventory_num=T,type:"number",min:0,maxlength:20,disabled:u.value==="detail"||u.value==="audit"||u.value==="view"},null,8,["modelValue","onUpdate:modelValue","disabled"]))]),_:1},8,["label"]),n(m,{label:e.$t("diff")},{default:o(l=>[y(r(l.row.inventory_num-l.row.actual_stock||0),1)]),_:1},8,["label"]),u.value!=="detail"&&u.value!=="audit"&&u.value!=="view"?(s(),_(m,{key:0,label:e.$t("operate")},{default:o(l=>[n(b,{size:"mini",type:"danger",onClick:T=>a.value.product_list.splice(l.$index,1)},{default:o(()=>[y(r(e.$t("delete")),1)]),_:2},1032,["onClick"])]),_:1},8,["label"])):w("",!0)]),_:1},8,["data","loading"])]),_:1})])]),_:1},8,["model","rules"]),$("div",bl,[u.value!=="audit"&&u.value!=="detail"&&u.value!=="view"?(s(),_(b,{key:0,type:"primary",onClick:Ce},{default:o(()=>[y(r(e.$t("save")),1)]),_:1})):w("",!0),u.value=="check"?(s(),_(b,{key:1,onClick:we},{default:o(()=>[y(r(e.$t("print")),1)]),_:1})):w("",!0),n(b,{onClick:t[9]||(t[9]=l=>e.$router.back())},{default:o(()=>[y(r(e.$t("return")),1)]),_:1})]),n(O,{title:e.$t("goods_code"),modelValue:M.value,"onUpdate:modelValue":t[14]||(t[14]=l=>M.value=l),width:"30%","close-on-click-modal":!1,class:"!rounded-lg"},{default:o(()=>[n(J,{ref_key:"scanGoodsForm",ref:V,model:V.value,"label-width":"120px",inline:""},{default:o(()=>[n(f,{label:"sku",prop:"bar_code"},{default:o(()=>[n(d,{modelValue:V.value.bar_code,"onUpdate:modelValue":t[10]||(t[10]=l=>V.value.bar_code=l),ref_key:"input",ref:K,onKeyup:t[11]||(t[11]=de(l=>ge(),["enter"])),minlength:0,maxlength:100},null,8,["modelValue"])]),_:1}),n(f,{label:"序列号",prop:"sn_code"},{default:o(()=>[n(d,{ref_key:"sn_input",ref:ee,modelValue:Y.value,"onUpdate:modelValue":t[12]||(t[12]=l=>Y.value=l),onKeyup:t[13]||(t[13]=de(l=>ye(),["enter"])),minlength:0,maxlength:100},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["title","modelValue"]),n(O,{title:e.$t("prompt"),modelValue:q.value,"onUpdate:modelValue":t[18]||(t[18]=l=>q.value=l),width:"30%",class:"!rounded-lg"},{footer:o(()=>[n(b,{onClick:t[16]||(t[16]=l=>q.value=!1)},{default:o(()=>[y(r(e.$t("cancel")),1)]),_:1}),n(b,{type:"primary",onClick:t[17]||(t[17]=l=>$e())},{default:o(()=>[y(r(e.$t("submit")),1)]),_:1})]),default:o(()=>[n(J,{ref_key:"goodsInventoryAddForm",ref:a,model:a.value,"label-width":"120px",inline:""},{default:o(()=>[n(f,{label:e.$t("reject"),prop:"reject_reason",required:"true"},{default:o(()=>[n(d,{modelValue:a.value.reject_reason,"onUpdate:modelValue":t[15]||(t[15]=l=>a.value.reject_reason=l),type:"textarea",minlength:0,maxlength:100},null,8,["modelValue"])]),_:1},8,["label"])]),_:1},8,["model"])]),_:1},8,["title","modelValue"]),n(O,{title:e.$t("inven"),modelValue:j.value,"onUpdate:modelValue":t[21]||(t[21]=l=>j.value=l),width:"1000px",onClose:x,class:"!rounded-lg"},{footer:o(()=>[n(b,{onClick:x},{default:o(()=>[y(r(e.$t("cancel")),1)]),_:1}),n(b,{type:"primary",onClick:t[20]||(t[20]=l=>ve())},{default:o(()=>[y(r(e.$t("submit")),1)]),_:1})]),default:o(()=>[$("div",kl,[$("span",null,r(e.$t("search")+e.$t("goods_info"))+":",1),n(d,{modelValue:C.keyWord,"onUpdate:modelValue":t[19]||(t[19]=l=>C.keyWord=l),style:{width:"200px","margin-right":"5px"}},null,8,["modelValue"]),n(b,{onClick:W},{default:o(()=>[y(r(e.$t("search")),1)]),_:1})]),n(ue,{data:U.value.records,border:"",style:{width:"100%"},onSelectionChange:ie},{default:o(()=>[n(m,{type:"selection",width:"55"}),n(m,{prop:"product_vo.name",label:e.$t("goods_name")},null,8,["label"]),n(m,{prop:"product_vo.sku",label:"sku"}),n(m,{prop:"",label:e.$t("brand")},{default:o(l=>[y(r(l.row.product_vo.brand),1)]),_:1},8,["label"]),n(m,{prop:"product_vo.weight",label:e.$t("weight")},null,8,["label"]),n(m,{prop:"product_vo.unit",label:e.$t("goods_unit")},null,8,["label"])]),_:1},8,["data"]),n(Ee,{onSizeChange:ce,onCurrentChange:_e,"current-page":U.value.current,"page-sizes":[10,20,50,100],"page-size":U.value.size,layout:"total, sizes, prev, pager, next, jumper",total:U.value.total},null,8,["current-page","page-size","total"])]),_:1},8,["title","modelValue"])])),[[je,E.value]])}}}),Dl=He(wl,[["__scopeId","data-v-96f4782b"]]);export{Dl as default};