import{d as Y,b as E,s as J,a as L,u as $,c as A,r as G,C as H,o as M,t as y,L as g,e as U,f as V,g as r,w as l,F as k,D as z,k as b,j as m,n as d,A as D,m as K,h as Q,y as W,E as X}from"./index-b3d5c748.js";import{A as Z}from"./index-aacf363a.js";import{F as h,C as ee}from"./index-e0a50352.js";import"./index-d5acb7e5.js";import{F as oe}from"./index-36e50274.js";import{f as te}from"./formatTime-325dcd9a.js";import{u as ae}from"./index-7da3b21b.js";import{u as ne}from"./dict-49db7f1e.js";import{g as re}from"./other-0a6516d1.js";import{u as le}from"./claim-a88c89b9.js";import{u as me}from"./index-d9753d4f.js";import{_ as ue}from"./_plugin-vue_export-helper-c27b6911.js";import"./use-id-d2a65d0a.js";const se={class:"container"},de=Y({__name:"edit",setup(ie){const _=E(),{userInfos:fe,openId:v,unionId:I}=J(_),i=L(),f=$(),x=ae(),B=me(),C=ne(),F=le();A([]);const S=A(),N=A([]),o=G({loading:!1,isActiveService:!1,showProject:!1,shwoService:!1,showExpenseCard:!1,showAppointUser:!1,isInstrHead:!1,fundDetail:{},detail:[],form:{allotAmount:null,amount:null,unAmount:0,manageAmount:0,taxAmount:0,projectName:"",createdName:"",createdTime:"",date:"",id:0,remark:"",serialNo:"",type:"",unit:"",status:""}}),j=()=>{Promise.all([C.getDictDataByType("PaymentReceivedType"),x.getAllFirstSubj()]).then(([t,e])=>{var n;N.value=((n=t==null?void 0:t.data)==null?void 0:n.values)||[],o.detail=(e==null?void 0:e.data.map(u=>({...u,amount:0})))||[]})};H(()=>((o.form.amount?Number(o.form.amount*100-o.form.manageAmount*100-o.form.taxAmount*100):0)/100).toString().replace(/\B(?=(\d{3})+(?!\d))/g,","));const p=t=>(t=t*100,(t/100).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")),q=async t=>{const[e,n]=await y(x.getDetails({id:t}));e||(o.fundDetail=n.data,o.form={...o.form,...n.data},o.form.unAmount=o.form.amount-o.form.manageAmount-o.form.taxAmount,o.form.status=="20"&&f.push({path:"/fund/claim/detail",query:{id:t}}))},w=(t,e)=>{f.push({path:t,query:{...e}})},R=async()=>{o.loading=!0;const t=JSON.parse(JSON.stringify(o.form));t.fundId=o.form.id,t.detail=o.detail,t.amount=Number(t.amount),t.detail=t.detail.map(n=>({...n,amount:Number(n.amount)})),t.externalAmount=Number(t.externalAmount),t.internalAmount=Number(t.internalAmount);const[e]=await y(F.create(t));o.loading=!1,!e&&(W({type:"success",message:"操作成功"}),f.push({path:"/fund/claim",query:{id:t.instId}}))};return M(async()=>{var u;const t=i.query.code?i.query.code.toString():"";await _.setOpenId(t);let e={code:v.value,unionId:I.value};if(v.value){const[c,s]=await y(B.weChatLoginUnionId(e));if(c){g.remove("token"),f.push("/login");return}g.set("token",(u=s==null?void 0:s.data)==null?void 0:u.token),g.set("Tenant",s.data.tenant)}const n=i.query.id?+i.query.id:0;j(),q(n)}),(t,e)=>{const n=oe,u=ee,c=h,s=Z,T=X,O=z;return b(),U(k,null,[V("div",se,[r(c,{ref_key:"formRef",ref:S,required:"auto"},{default:l(()=>[e[15]||(e[15]=V("h4",null,"到款信息",-1)),r(u,{class:"mt10"},{default:l(()=>[r(n,{modelValue:o.form.projectName,"onUpdate:modelValue":e[0]||(e[0]=a=>o.form.projectName=a),label:"项目到款",readonly:""},null,8,["modelValue"]),r(n,{modelValue:o.form.amount,"onUpdate:modelValue":e[1]||(e[1]=a=>o.form.amount=a),label:"到款金额",readonly:""},{input:l(()=>[m(d(p(o.form.amount)),1)]),extra:l(()=>e[10]||(e[10]=[m("元")])),_:1},8,["modelValue"]),r(n,{modelValue:o.form.taxAmount,"onUpdate:modelValue":e[2]||(e[2]=a=>o.form.taxAmount=a),label:"管理费",readonly:""},{input:l(()=>[m(d(p(o.form.manageAmount)),1)]),extra:l(()=>e[11]||(e[11]=[m("元")])),_:1},8,["modelValue"]),r(n,{modelValue:o.form.taxAmount,"onUpdate:modelValue":e[3]||(e[3]=a=>o.form.taxAmount=a),label:"税费",readonly:""},{input:l(()=>[m(d(p(o.form.taxAmount)),1)]),extra:l(()=>e[12]||(e[12]=[m("元")])),_:1},8,["modelValue"]),r(n,{modelValue:o.form.unAmount,"onUpdate:modelValue":e[4]||(e[4]=a=>o.form.unAmount=a),label:"待认领金额",readonly:""},{input:l(()=>[m(d(p(o.form.unAmount)),1)]),extra:l(()=>e[13]||(e[13]=[m("元")])),_:1},8,["modelValue"]),r(n,{modelValue:o.form.date,"onUpdate:modelValue":e[5]||(e[5]=a=>o.form.date=a),label:"到款日期",readonly:""},{input:l(()=>[m(d(D(te)(new Date(o.form.date),"YYYY-mm-dd")),1)]),_:1},8,["modelValue"]),r(n,{modelValue:o.form.type,"onUpdate:modelValue":e[6]||(e[6]=a=>o.form.type=a),label:"到款类型",readonly:""},{input:l(()=>[m(d(D(re)(N.value,o.form.type)),1)]),_:1},8,["modelValue"]),r(n,{modelValue:o.form.unit,"onUpdate:modelValue":e[7]||(e[7]=a=>o.form.unit=a),label:"打款单位",readonly:""},null,8,["modelValue"])]),_:1}),e[16]||(e[16]=V("h4",null,"认领经费",-1)),r(u,{class:"mt10"},{default:l(()=>[(b(!0),U(k,null,K(o.detail,a=>(b(),Q(n,{key:a.id,label:a.subjName,placeholder:a.subjName,modelValue:a.amount,"onUpdate:modelValue":P=>a.amount=P},{extra:l(()=>e[14]||(e[14]=[m("元")])),_:2},1032,["label","placeholder","modelValue","onUpdate:modelValue"]))),128))]),_:1})]),_:1},512)]),r(O,{placeholder:""},{default:l(()=>[r(s,{icon:"wap-home-o",text:"首页",onClick:e[8]||(e[8]=a=>w("/home"))}),r(s,{icon:"balance-o",text:"经费认领",onClick:e[9]||(e[9]=a=>w("/fund/claim"))}),r(T,{class:"w100",type:"primary",text:"提交",onClick:R})]),_:1})],64)}}});const ke=ue(de,[["__scopeId","data-v-407ba15f"]]);export{ke as default};