import{_ as ve,d as fe,E as d,a5 as P,A as _e,aI as ye,a7 as he,H as we,F as be,x as c,aF as Ce,o as _,c as g,O as z,N as A,K as a,y as e,L as I,M as V,u as f,aJ as Fe,b as S,W as h,T as b,R as H,P as Be,aK as De,aZ as C,G as Ee,$ as ke,a0 as ge}from"./index.41f41f3b.js";import{e as Ae,f as xe}from"./index.62a94740.js";import{h as Ne}from"./index.de9c7fd0.js";import Ie from"./order-dialog.54234224.js";import Ve from"./edit-order.0d4f5366.js";import K from"./invoice-title.6856bbf1.js";import{convertInvoiceTitleData as G,convertInvoiceTitle as Se}from"./columns.34b3309a.js";import{A as Te}from"./configs.861a6cc0.js";import{u as J,b as Re}from"./status.367fcae1.js";import"./use-page-search.28d482f8.js";import"./inv-open.ca8f4458.js";import"./tootip.172bf606.js";import"./basic-descriptions.67d9cd18.js";const Oe=F=>(ke("data-v-9bdd5bf4"),F=F(),ge(),F),Ue={class:"addEditForm"},qe={flex:"","justify-between":"","w-full":"","mb-2":""},Le=h("\u6DFB\u52A0"),je=Oe(()=>S("span",null,"\u64CD\u4F5C",-1)),Me={"w-full":""},$e=h("\u4FDD\u5B58"),Pe=fe({__name:"add-edit-form",setup(F){const W=d("order"),{companyList:Y}=P(),{push:Z}=_e(),T=d(null),R=d(null),B=d(null),v=d({}),O=ye(),U=d(!1),m=d([]),{currentCompany:Q}=P(),q=d(0),D=150,o=d({...{companyNo:"",buy_id:"",invtype:"",email:"",remark:"",exam_remark:"",orderArr:[],companyType:"01",platform_type:""}}),L=d([]),j=he({...Te});function X(t,l){R.value.onDisplay({row:l})}function ee({row:t,inv_fee:l,num:n}){v.value[t.sequenceNo]={inv_fee:l,num:n,platform_type}}const le=(t,l)=>{const n=l===m.value.length-1;if(m.value.length===1)return o.value.remark=o.value.remark.split(t).join("");o.value.remark=o.value.remark.split(n?";"+t:t+";").join("")},ue=t=>{const{sequenceNo:l,poCode:n}=m.value[t];le(n,t),delete v.value[l],m.value.splice(t,1)};function M(){return{orderArr:Object.keys(v.value).map(n=>{const{inv_fee:i,num:r,platform_type:s}=v.value[n];return{sequenceNo:n,inv_fee:i,num:r,platform_type:s}})}}function oe(){B.value.validate(async t=>{if(!t)return;if(o.value.remark.length>184)return C.error("\u53D1\u7968\u5907\u6CE8\u4E0D\u80FD\u8D85\u8FC7184\u4E2A\u5B57\u7B26");if(m.value.length>D)return C.error(`\u8BA2\u5355\u6570\u91CF\u4E0D\u80FD\u8D85\u8FC7${D}\u4E2A`);const{orderArr:l}=M();if(l.reduce((s,{inv_fee:y})=>s+Number(y),0)>q.value)return C.error("\u8BA2\u5355\u603B\u91D1\u989D\u8D85\u8FC7\u6700\u5927\u5F00\u7968\u9762\u989D");const{code:i,message:r}=await xe({relaComNo:o.value.companyNo,...o.value,...M()});O({code:i,message:r,handler:()=>Z("/InvoiceSales/invoiceApply")})})}function ae(){const{invtype:t}=o.value;j.email[0].required=t==="special_electronic"||t==="electronic"}function te(){const{companyNo:t,platform_type:l}=o.value;if(!t)return C.warning("\u8BF7\u9009\u62E9\u9500\u552E\u516C\u53F8\u62AC\u5934");if(!l)return C.warning("\u8BF7\u9009\u62E9\u5E73\u53F0\u7C7B\u578B");T.value.show(t,l)}function ne(t){o.value.remark="",t.forEach((l,n)=>{const{sequenceNo:i,platform_type:r,winv_fee:s,winv_num:y,poCode:w}=l;v.value[i]||(v.value[i]={inv_fee:s,num:y,platform_type:r},m.value.push(l),o.value.remark+=n===0?w:";"+w)})}const x=d({}),N=d({});function $(t,l){if(!l)return t?x.value={}:N.value={};if(t){const{invoiceType:n,denomination:i}=l;q.value=Number(i)*1e4;const r=n.split(",");o.value.invtype="",L.value=Re.filter(({value:s})=>r.includes(s))}t?x.value=G(Se(l)):N.value=G(l)}const re=$.bind(null,!0),ie=$.bind(null,!1);async function se(t){o.value.companyNo=t;const{code:l,data:n,message:i}=await Ne({companyNo:t});Ee(()=>{B.value&&B.value.validateField("companyNo")}),O({code:l,message:i,handler:()=>re(n.list[0])})}return we(()=>o.value.platform_type,()=>{o.value.remark="",m.value=[],v.value={}},{immediate:!0}),be(()=>{se(Q.value.companyNo)}),(t,l)=>{const n=c("el-option"),i=c("el-select"),r=c("el-form-item"),s=c("el-col"),y=c("el-input"),w=c("el-tag"),E=c("el-button"),p=c("el-table-column"),de=c("el-table"),pe=c("el-row"),me=Ce("loading");return _(),g("div",Ue,[z((_(),A(f(De),{ref_key:"formRef",ref:B,model:o.value,rules:j,"label-width":"100px","status-icon":"",size:"small"},{default:a(()=>[e(pe,null,{default:a(()=>[e(s,{span:12},{default:a(()=>[e(r,{label:"\u9500\u552E\u65B9\u516C\u53F8\u62AC\u5934",prop:"companyNo","label-width":"135px"},{default:a(()=>[e(i,{style:{width:"100%"},placeholder:"\u9500\u552E\u65B9\u516C\u53F8\u62AC\u5934",disabled:"",modelValue:o.value.companyNo,"onUpdate:modelValue":l[0]||(l[0]=u=>o.value.companyNo=u)},{default:a(()=>[(_(!0),g(I,null,V(f(Y),u=>(_(),A(n,{key:u.companyCode,value:u.companyCode,label:u.companyName},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1}),e(K,{detail:x.value},null,8,["detail"])]),_:1}),e(s,{span:12},{default:a(()=>[e(r,{label:"\u8D2D\u4E70\u65B9\u516C\u53F8\u62AC\u5934",prop:"buy_id","label-width":"135px"},{default:a(()=>[e(f(Fe),{"is-root":"",value:o.value.buy_id,"onUpdate:value":l[1]||(l[1]=u=>o.value.buy_id=u),api:f(Ae),style:{width:"100%"},placeholder:"\u8D2D\u4E70\u65B9\u516C\u53F8\u62AC\u5934","request-prop":"name","response-label-prop":"invoice_title","response-val-prop":"id",onItemChange:f(ie)},null,8,["value","api","onItemChange"])]),_:1}),e(K,{detail:N.value},null,8,["detail"])]),_:1}),e(s,{span:6},{default:a(()=>[e(r,{"label-width":"100px",label:"\u53D1\u7968\u7C7B\u578B",prop:"invtype"},{default:a(()=>[e(i,{modelValue:o.value.invtype,"onUpdate:modelValue":l[2]||(l[2]=u=>o.value.invtype=u),style:{width:"100%"},onChange:ae,placeholder:"\u53D1\u7968\u7C7B\u578B","no-data-text":"\u8BF7\u9009\u62E9\u5176\u4ED6\u9500\u552E\u65B9\u516C\u53F8"},{default:a(()=>[(_(!0),g(I,null,V(L.value,u=>(_(),A(n,{key:u.value,label:u.label,value:u.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),e(r,{"label-width":"100px",label:"\u7535\u5B50\u90AE\u7BB1",prop:"email"},{default:a(()=>[e(y,{modelValue:o.value.email,"onUpdate:modelValue":l[3]||(l[3]=u=>o.value.email=u),placeholder:"\u7535\u5B50\u90AE\u7BB1"},null,8,["modelValue"])]),_:1}),e(r,{"label-width":"100px",label:"\u5E73\u53F0\u7C7B\u578B",prop:"platform_type"},{default:a(()=>[e(i,{modelValue:o.value.platform_type,"onUpdate:modelValue":l[4]||(l[4]=u=>o.value.platform_type=u),style:{width:"100%"},placeholder:"\u5E73\u53F0\u7C7B\u578B"},{default:a(()=>[(_(!0),g(I,null,V(f(J),u=>(_(),A(n,{key:u.value,label:u.label,value:u.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1}),e(s,{span:18},{default:a(()=>[e(r,{label:"\u7533\u8BF7\u5907\u6CE8",prop:"exam_remark","label-width":"135px"},{default:a(()=>[e(y,{"w-full":"",modelValue:o.value.exam_remark,"onUpdate:modelValue":l[5]||(l[5]=u=>o.value.exam_remark=u),rows:5,type:"textarea",maxlength:"2000",placeholder:"\u7533\u8BF7\u5907\u6CE8","show-word-limit":""},null,8,["modelValue"])]),_:1})]),_:1}),z(e(s,{span:24},{default:a(()=>[e(r,{label:"\u8BA2\u5355\u5217\u8868"},{default:a(()=>[S("div",qe,[e(w,{type:m.value.length>D?"danger":"info"},{default:a(()=>[h(b(m.value.length)+" / "+b(D),1)]),_:1},8,["type"]),e(E,{type:"primary",onClick:te},{default:a(()=>[Le]),_:1})]),e(de,{data:m.value,stripe:"",border:"","max-height":"300"},{default:a(()=>[e(p,{prop:"sequenceNo",label:"\u9500\u552E\u8BA2\u5355\u7F16\u7801","show-overflow-tooltip":"",width:"150"}),e(p,{prop:"poCode",label:"\u5E73\u53F0\u8BA2\u5355\u7F16\u7801","show-overflow-tooltip":"",width:"150"}),e(p,{prop:"customerNo",label:"\u8D2D\u4E70\u65B9\u516C\u53F8\u7F16\u7801",width:"150","show-overflow-tooltip":""}),e(p,{prop:"customerName",label:"\u8D2D\u4E70\u65B9\u516C\u53F8\u540D\u79F0","show-overflow-tooltip":"",width:"200"}),e(p,{prop:"winv_num",label:"\u672A\u5F00\u7968\u6570\u91CF","show-overflow-tooltip":"",width:"110"}),e(p,{prop:"winv_fee",label:"\u672A\u5F00\u7968\u91D1\u989D","show-overflow-tooltip":"",width:"110"}),e(p,{label:"\u5E73\u53F0\u7C7B\u578B",width:"110","show-overflow-tooltip":""},{default:a(({row:u})=>[e(w,{size:"small"},{default:a(()=>{var k;return[h(b((k=f(J).find(ce=>ce.value===String(u.platform_type)))==null?void 0:k.label),1)]}),_:2},1024)]),_:1}),e(p,{label:"\u5F00\u7968\u91D1\u989D",width:"110","show-overflow-tooltip":""},{default:a(({row:u})=>[h(b(v.value[u.sequenceNo].inv_fee),1)]),_:1}),e(p,{label:"\u5F00\u7968\u6570\u91CF","show-overflow-tooltip":""},{default:a(({row:u})=>[h(b(v.value[u.sequenceNo].num),1)]),_:1}),e(p,{label:"\u4E1A\u52A1\u5458","show-overflow-tooltip":"",prop:"ownerName",width:"80"}),e(p,{fixed:"right",width:"70"},{header:a(()=>[je]),default:a(u=>[e(E,{size:"small",type:"primary",link:"",icon:f(H)("edits"),onClick:k=>X(u.$index,u.row)},null,8,["icon","onClick"]),e(E,{size:"small",type:"danger",link:"",icon:f(H)("delete"),onClick:k=>ue(u.$index)},null,8,["icon","onClick"])]),_:1})]),_:1},8,["data"])]),_:1})]),_:1},512),[[Be,W.value==="order"]]),e(s,{span:24},{default:a(()=>[e(r,{label:"\u53D1\u7968\u5907\u6CE8",prop:"remark"},{default:a(()=>[S("div",Me,[e(y,{"w-full":"",modelValue:o.value.remark,"onUpdate:modelValue":l[6]||(l[6]=u=>o.value.remark=u),rows:3,type:"textarea",maxlength:"2000","show-word-limit":"",placeholder:"\u53D1\u7968\u5907\u6CE8"},null,8,["modelValue"])])]),_:1})]),_:1}),e(s,{span:24,flex:"","justify-end":""},{default:a(()=>[e(E,{loading:U.value,type:"primary",onClick:oe},{default:a(()=>[$e]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["model","rules"])),[[me,U.value]]),e(Ie,{ref_key:"modelRef",ref:T,onSaveBtnClick:ne},null,512),e(Ve,{ref_key:"editOrderRef",ref:R,onSaveBtnClick:ee},null,512)])}}});var al=ve(Pe,[["__scopeId","data-v-9bdd5bf4"],["__file","/Users/apple/Desktop/Company Projects/accout-vue3-ui/src/views/InvoiceSales/invoiceApply/components/add-edit-form/add-edit-form.vue"]]);export{al as default};