import{_ as ue,d as se,w as v,aW as G,a0 as ie,W as re,a5 as F,r as U,ar as de,H as M,l as e,o as c,c as z,j as l,C as m,aH as g,G as h,a as C,h as b,L as T,aI as ne,aK as me,aL as p,M as j,aY as B,aP as E,J as N,af as pe,aG as ce,ax as _}from"./index.js";import{o as fe,i as ve,a as Ce,C as he}from"./ChildGoodEditModal.b0de1a.js";import{u as ge}from"./useDetail.9b72801b.js";import{B as x}from"./basic-descriptions.65a76ad2.js";import be from"./index.04a7a9.js";import{h as L,c as we}from"./index.f05cfa47.js";import{P as Fe}from"./index.e2551c7f.js";import{S as Ee}from"./index.4da7e22a.js";import{a as _e}from"./calc.850c7422.js";import{B as De}from"./index.df2b578c.js";import"./status.b7512d56.js";import"./shared.c745d8d9.js";import"./tootip.236f17fc.js";import"./shared.24c07afb.js";import"./use-page-search.15129a46.js";import"./index.d2fead55.js";import"./columnRenderHelper.c38ed50d.js";import"./columns.6ae6573b.js";import"./index.0bffb9a0.js";const ke={class:"padding__container"},ye={class:"w-full flex justify-between mb-[10px]"},Te={class:"w-full flex justify-between"},Be={class:"flex w-full justify-end"},Ne=se({__name:"detail",setup(xe){const{title:O,collapses:D,id:w}=ge({baseName:"\u51FA\u5E93",collapseLen:5}),k=v(!1),A=v(!1),V=v(!1),P=v(0),y=G(),i=G(),{isSuperUser:$}=ie(),f=re({editVisible:!1,index:-1,data:{}}),S=v(!1),I=v(null),q=F(()=>{var o,a;return i.data?{...{},good_type:String((o=i.data)==null?void 0:o.goodType),status:"1",good_source:String((a=i.data)==null?void 0:a.source)}:{}}),J=F(()=>{const u=t.value.goods.map(({id:r,goodNum:n})=>({id:r,num:n})),o={};let a=0;for(const r of u)if(!o[r.id]){o[r.id]=!0;const{num:n="0"}=r;a=_e(n,a)}return a}),H=F(()=>t.value.goods.map(({id:o,goodNum:a,isJT:r})=>({id:o,num:a,isJT:r})).some(({isJT:o})=>o)),R=F(()=>t.value.goods.filter(u=>!u.isJT)),t=v({goods:[],month:""}),W={goods:[{required:!0,message:"\u8BF7\u9009\u62E9\u64CD\u4F5C\u5546\u54C1"}],month:[{required:!0,message:"\u8BF7\u9009\u62E9\u5165\u8D26\u6708\u4EFD"}]};function K(u){const o=t.value.goods.map(({id:r})=>r),a=[];u.forEach(r=>{o.includes(r.id)||a.push(r)}),t.value.goods=[...t.value.goods,...a]}function Y(u){f.index=u,f.editVisible=!0,f.data={...t.value.goods[u]}}function Q(u,o){let a=Array.isArray(u)?u.length:0;if(a>0){let r=0,n=u[0][o],s=[1];for(let d=1;d<a;d++)u[d][o]==n?(s[r]+=1,s[d]=0):(r=d,s[d]=1,n=u[d][o]);return s}else return[0]}function X({row:u,column:o,rowIndex:a,columnIndex:r}){if([0,1,2,3,4,5,9].includes(Number(r)))return{rowspan:Q(t.value.goods,"id")[a],colspan:1}}async function Z(){try{await I.value.validate();const u=t.value.goods.map(({id:d,goodNum:le,unit_price:te,subunit_price:ae})=>({id:d,unit_price:te,num:le,subunit_price:ae})),o=[],a={};for(const d of u)a[d.id]||(o.push(d),a[d.id]=!0);if(Number(i.data.balance_num)!==Number(J.value)){_.warning("\u64CD\u4F5C\u6570\u91CF\u5FC5\u987B\u7B49\u4E8E\u5F85\u5904\u7406\u6570\u91CF");return}if(t.value.goods.filter(d=>!!d.num).length!==0){_.warning("\u5546\u54C1\u64CD\u4F5C\u6570\u91CF\u4E0D\u80FD\u4E3A\u7A7A");return}S.value=!0;const{code:n,message:s}=await we({relaArr:o,manager_id:w.value,is_checkOrder:H.value?"1":"0",fz_date:t.value.month});S.value=!1,n==0?(_.success("\u64CD\u4F5C\u5B8C\u6210"),i.run(L({id:w.value}))):_.warning(s)}catch{}}function ee(u,o){const{id:a}=t.value.goods[u];t.value.goods.forEach((r,n)=>{if(r.id===a){t.value.goods[n].goodNum=o.goodNum;const{goodNum:s,residue_stock:d}=o;t.value.goods[n].isJT=s>d,t.value.goods[n].childNum&&(t.value.goods[n].isJT=s>d,t.value.goods[n].childActionNum=t.value.goods[n].childNum*o.goodNum)}})}function oe(u){const{id:o}=t.value.goods[u];t.value.goods=t.value.goods.filter(a=>a.id!==o)}return w.value&&i.run(L({id:w.value})),(u,o)=>{const a=U("ElFormItem"),r=U("ElDialog"),n=de("loading");return M((c(),z("div",ke,[l(e(ce),{modelValue:e(D),"onUpdate:modelValue":o[2]||(o[2]=s=>pe(D)?D.value=s:null)},{default:m(()=>[l(e(g),{title:e(O),name:"1"},{default:m(()=>[e(i).data?(c(),h(e(x),{key:0,columns:e(fe),data:e(i).data},null,8,["columns","data"])):C("v-if",!0)]),_:1},8,["title"]),l(e(g),{title:"\u8BA2\u5355\u8BE6\u60C5",name:"2"},{default:m(()=>[e(i).data?(c(),h(e(x),{key:0,columns:e(ve),data:e(i).data},null,8,["columns","data"])):C("v-if",!0)]),_:1}),l(e(g),{title:"\u53D1\u7968\u8BE6\u60C5",name:"3"},{default:m(()=>[e(i).data?(c(),h(e(x),{key:0,columns:e(Ce),data:e(i).data},null,8,["columns","data"])):C("v-if",!0)]),_:1}),e(i).data&&e(i).data.ProductRela.length!==0?(c(),h(e(g),{key:0,title:"\u5546\u54C1\u4FE1\u606F",name:"4"},{default:m(()=>[C(` <ElTable size="small" border :data="detailTask.data.ProductRela">\r
          <ElTableColumn label="\u5546\u54C1ID" prop="product_id" width="60px" show-overflow-tooltip />\r
          <ElTableColumn label="\u5546\u54C1\u7F16\u53F7" prop="skuCode" show-overflow-tooltip />\r
          <ElTableColumn label="\u5546\u54C1\u540D\u79F0" prop="goodName" show-overflow-tooltip />\r
          <ElTableColumn label="\u64CD\u4F5C\u6570\u91CF" prop="num" width="80px" show-overflow-tooltip />\r
          <ElTableColumn label="\u64CD\u4F5C\u4EBA" prop="apply_name" width="80px" show-overflow-tooltip />\r
          <ElTableColumn label="\u521B\u5EFA\u65F6\u95F4" prop="create_time" show-overflow-tooltip />\r
          <ElTableColumn label="\u64CD\u4F5C" width="100px">\r
            <template #="scope">\r
              <ElTooltip content="\u67E5\u770B\u8BE6\u60C5">\r
                <ElButton type="primary" link :icon="useRenderIcon('eye-view')"\r
                  @click="handleShowDetail(scope.row.product_id, scope.$index)" />\r
              </ElTooltip>\r
            </template>\r
          </ElTableColumn>\r
        </ElTable> `),l(De,{ProductRela:e(i).data.ProductRela},null,8,["ProductRela"])]),_:1})):C("v-if",!0),!e($)&&e(i).data&&(e(i).data.status=="1"||e(i).data.status=="4")?(c(),h(e(g),{key:1,name:"5",title:"\u5F85\u5904\u7406\u4FE1\u606F"},{default:m(()=>[b("div",ye,[b("p",null,"\u5F85\u5904\u7406 "+T(Number(e(i).data.balance_num))+" / "+T(J.value),1)]),l(e(ne),{ref_key:"formRef",ref:I,rules:W,model:t.value},{default:m(()=>[l(a,{label:"\u64CD\u4F5C\u5546\u54C1",prop:"goods"},{default:m(()=>[l(e(me),{"span-method":X,border:"",size:"small",data:t.value.goods},{default:m(()=>[l(e(p),{label:"\u5546\u54C1ID",prop:"id",width:"60px","show-overflow-tooltip":""}),l(e(p),{label:"\u5546\u54C1\u7F16\u53F7",prop:"skuCode","show-overflow-tooltip":""}),l(e(p),{label:"\u5546\u54C1\u540D\u79F0",prop:"goodName","show-overflow-tooltip":""}),l(e(p),{label:"\u662F\u5426\u4E3A\u8BA1\u63D0",prop:"residue_stock",width:"80px","show-overflow-tooltip":""},{default:m(({row:s})=>[j(T(s.isJT?"\u662F":"\u5426"),1)]),_:1}),l(e(p),{label:"\u7ED3\u5B58\u6570",prop:"residue_stock",width:"80px","show-overflow-tooltip":""}),l(e(p),{label:"\u64CD\u4F5C\u6570\u91CF",prop:"goodNum",width:"80px","show-overflow-tooltip":""}),l(e(p),{label:"\u5B50\u5546\u54C1\u7F16\u53F7",prop:"childCode","show-overflow-tooltip":""}),l(e(p),{label:"\u5B50\u5546\u54C1\u6BD4\u4F8B",prop:"childNum","show-overflow-tooltip":""}),l(e(p),{label:"\u5B50\u5546\u54C1\u64CD\u4F5C\u6570\u91CF",prop:"childActionNum",width:"110px","show-overflow-tooltip":""}),l(e(p),{width:"70px",label:"\u64CD\u4F5C"},{header:m(()=>[b("div",Te,[o[6]||(o[6]=b("span",null,"\u64CD\u4F5C",-1)),l(e(B),{content:"\u6DFB\u52A0",placement:"top"},{default:m(()=>[l(e(E),{link:"",size:"small",type:"primary",icon:e(N)("add"),onClick:o[0]||(o[0]=s=>{A.value=!1,k.value=!0})},null,8,["icon"])]),_:1})])]),default:m(({$index:s})=>[l(e(B),{content:"\u7F16\u8F91",placement:"top"},{default:m(()=>[l(e(E),{icon:e(N)("edits"),type:"primary",size:"small",link:"",onClick:d=>Y(s)},null,8,["icon","onClick"])]),_:2},1024),l(e(B),{content:"\u5220\u9664",placement:"top"},{default:m(()=>[l(e(E),{icon:e(N)("delete"),type:"danger",size:"small",link:"",onClick:d=>oe(s)},null,8,["icon","onClick"])]),_:2},1024)]),_:1})]),_:1},8,["data"])]),_:1}),l(a,{label:"\u5165\u8D26\u6708\u4EFD",prop:"month"},{default:m(()=>[l(Ee,{placeholder:"\u5165\u8D26\u6708\u4EFD",modelValue:t.value.month,"onUpdate:modelValue":o[1]||(o[1]=s=>t.value.month=s),company_code:e(i).data.inv_seller_code},null,8,["modelValue","company_code"])]),_:1})]),_:1},8,["model"]),b("div",Be,[l(e(E),{type:"primary",onClick:Z},{default:m(()=>o[7]||(o[7]=[j("\u4FDD\u5B58")])),_:1})])]),_:1})):C("v-if",!0)]),_:1},8,["modelValue"]),l(be,{visible:k.value,"onUpdate:visible":o[3]||(o[3]=s=>k.value=s),isJT:A.value,otherSearchParameter:q.value,onSubmit:K,skuCode:R.value.length===0?"":R.value[0].skuCode},null,8,["visible","isJT","otherSearchParameter","skuCode"]),l(he,{data:f.data,index:f.index,visible:f.editVisible,"onUpdate:visible":o[4]||(o[4]=s=>f.editVisible=s),onSubmit:ee},null,8,["data","index","visible"]),l(r,{center:"",title:"\u5546\u54C1\u8BE6\u60C5",modelValue:V.value,"onUpdate:modelValue":o[5]||(o[5]=s=>V.value=s),style:{overflow:"hidden"}},{default:m(()=>[M((c(),z("div",null,[e(y).data?(c(),h(Fe,{key:0,data:e(y).data,num:e(i).data.ProductRela[P.value].num,time:e(i).data.ProductRela[P.value].create_time},null,8,["data","num","time"])):C("v-if",!0)])),[[n,e(y).loading]])]),_:1},8,["modelValue"])])),[[n,e(i).loading]])}}});var Ye=ue(Ne,[["__file","C:/Users/89793/Desktop/projects/ticket-system/src/views/invoiceInOut/outManager/detail.vue"]]);export{Ye as default};
