1 line
10 KiB
JavaScript
1 line
10 KiB
JavaScript
import{i as e}from"./rolldown-runtime-BgaNhQyE.js";import{Dr as t,t as n}from"./jsx-runtime-CRBytmvs.js";import{t as r}from"./request--UCyt0wo.js";import{t as i}from"./typography-DRFhazK9.js";import{L as a,a as o}from"./lodash-DzOfPy0f.js";import{t as s}from"./table-BXi9q3AE.js";import{t as c}from"./button-BILozH6U.js";import{n as l}from"./LockOutlined-B8eRH1x4.js";import{u}from"./XinForm-BPDYdeax.js";import{t as d}from"./modal-g8Q5gNCx.js";import{t as f}from"./descriptions-BLF6MKiu.js";import{t as p}from"./form-B3R3kIqp.js";import{t as m}from"./input-CHcsaDtX.js";import{r as h}from"./PictureOutlined-CB8Pr7jP.js";import{t as g}from"./tag-DBV1bHre.js";import{t as _}from"./DownloadOutlined-DJY9Mu8c.js";import{t as v}from"./XinTable-DOLiJ5rL.js";import{t as y}from"./AuthButton-DvrpreK4.js";import{t as b}from"./download-DC9wDwqQ.js";import{t as x}from"./store-JDnJsv44.js";import{n as S}from"./iStoreOrder-CyyYoLoV.js";import{t as C}from"./iPurchaseOrder-Dn-laOqY.js";var w=e(t(),1),T=e(l(),1);async function E(e){return r({url:`/recon/bill/${e}`,method:`get`})}async function D(e,t){return r({url:`/recon/bill/${e}/pay`,method:`put`,data:t})}async function O(e){return b(`/recon/bill/${e}/export`,{},`门店账单.xlsx`)}var k=n(),{Title:A,Text:j}=i,M=()=>{let e=(0,w.useRef)(null),[t,n]=(0,w.useState)([]),[r,i]=(0,w.useState)(!1),[l,b]=(0,w.useState)(null),[M,N]=(0,w.useState)(!1),[P,F]=(0,w.useState)(null),[I,L]=(0,w.useState)(!1),[R]=p.useForm(),[z,B]=(0,w.useState)(null);(0,w.useEffect)(()=>{x().then(e=>n(e.data.data??[]))},[]);let V=async e=>{i(!0),N(!0);try{let t=await E(e);b(t.data.data??null)}finally{N(!1)}},H=e=>{F(e),R.setFieldsValue({paid_at:(0,T.default)(),pay_remark:``})},U=async t=>{if(P?.id){L(!0);try{await D(P.id,{paid_at:t.paid_at.format(`YYYY-MM-DD HH:mm:ss`),pay_remark:t.pay_remark??``}),h.success(`收款已登记,账单已置为已支付`),F(null),await e.current?.reload()}finally{L(!1)}}},W=async e=>{if(e.id){B(e.id);try{await O(e.id)}finally{B(null)}}},G=[{title:`品名`,dataIndex:`product_name`,width:160,align:`center`},{title:`包规`,dataIndex:`product_spec`,width:100,align:`center`,render:e=>e||`-`},{title:`单位`,dataIndex:`unit`,width:80,align:`center`,render:e=>e||`-`},{title:`单价`,dataIndex:`price`,width:100,align:`center`,render:e=>`¥${Number(e).toFixed(2)}`},{title:`数量`,dataIndex:`quantity`,width:90,align:`center`,render:e=>(0,k.jsx)(j,{strong:!0,children:e})},{title:`重量`,dataIndex:`weight`,width:100,align:`center`,render:e=>`${e}斤`},{title:`金额`,dataIndex:`amount`,width:110,align:`center`,render:e=>(0,k.jsxs)(j,{strong:!0,children:[`¥`,Number(e).toFixed(2)]})}],K=()=>{let e=l?.items??[],t=e.reduce((e,t)=>e+Number(t.quantity),0),n=e.reduce((e,t)=>e+Number(t.weight),0),r=e.reduce((e,t)=>e+Number(t.amount),0);return(0,k.jsxs)(s.Summary.Row,{children:[(0,k.jsx)(s.Summary.Cell,{index:0,colSpan:4,align:`center`,children:(0,k.jsx)(j,{strong:!0,children:`合计`})}),(0,k.jsx)(s.Summary.Cell,{index:4,align:`center`,children:(0,k.jsx)(j,{strong:!0,children:t})}),(0,k.jsx)(s.Summary.Cell,{index:5,align:`center`,children:(0,k.jsxs)(j,{strong:!0,children:[n.toFixed(3),`斤`]})}),(0,k.jsx)(s.Summary.Cell,{index:6,align:`center`,children:(0,k.jsxs)(j,{strong:!0,type:`danger`,children:[`¥`,r.toFixed(2)]})})]})},q=[{title:`订单号`,dataIndex:`order_no`,align:`center`,render:e=>(0,k.jsx)(j,{copyable:{text:e},children:e})},{title:`订货日期`,dataIndex:`order_date`,align:`center`},{title:`订货数量`,dataIndex:`total_quantity`,align:`center`},{title:`总重量`,dataIndex:`total_weight`,align:`center`,render:e=>`${e}斤`},{title:`订单金额`,dataIndex:`total_amount`,align:`center`,render:e=>(0,k.jsxs)(j,{strong:!0,children:[`¥`,e]})},{title:`状态`,dataIndex:`status`,align:`center`,render:e=>{let t=S[Number(e??0)];return(0,k.jsx)(g,{color:t?.color,children:t?.text})}}],J=[{title:`账单号`,dataIndex:`bill_no`,valueType:`text`,hideInForm:!0,width:210,render:(e,t)=>(0,k.jsx)(j,{copyable:{text:t.bill_no},children:t.bill_no})},{title:`门店`,dataIndex:`store_id`,valueType:`select`,hideInForm:!0,fieldProps:{options:t.map(e=>({label:e.name,value:e.id})),showSearch:!0,optionFilterProp:`label`},render:(e,t)=>t.store?.name??`门店#${t.store_id}`},{title:`采购单号`,dataIndex:`purchase_no`,valueType:`text`,hideInForm:!0,render:(e,t)=>t.purchase?.purchase_no??`-`},{title:`账单日期`,dataIndex:`bill_date`,valueType:`dateRange`,hideInForm:!0,align:`center`,render:(e,t)=>t.bill_date},{title:`商品金额`,dataIndex:`product_amount`,hideInForm:!0,hideInSearch:!0,align:`center`,render:(e,t)=>`¥${t.product_amount}`},{title:`配送费`,dataIndex:`delivery_fee`,hideInForm:!0,hideInSearch:!0,align:`center`,render:(e,t)=>`¥${t.delivery_fee}`},{title:`附加金额`,dataIndex:`added_amount`,hideInForm:!0,hideInSearch:!0,align:`center`,render:(e,t)=>(0,k.jsxs)(`span`,{title:`周转筐 ${t.box_num} 个 / 周转托盘 ${t.tray_num} 个`,children:[`¥`,t.added_amount]})},{title:`售后金额`,dataIndex:`after_sale`,hideInForm:!0,hideInSearch:!0,align:`center`,render:(e,t)=>(0,k.jsxs)(j,{type:Number(t.after_sale??0)<0?`success`:void 0,children:[`¥`,t.after_sale??`0.00`]})},{title:`账单总金额`,dataIndex:`total_amount`,hideInForm:!0,hideInSearch:!0,align:`center`,render:(e,t)=>(0,k.jsxs)(j,{strong:!0,type:`danger`,children:[`¥`,t.total_amount]})},{title:`支付状态`,dataIndex:`status`,valueType:`select`,hideInForm:!0,align:`center`,fieldProps:{options:Object.entries(C).map(([e,t])=>({value:Number(e),label:t.text}))},render:(e,t)=>{let n=C[t.status??0];return(0,k.jsx)(g,{color:n?.color,children:n?.text})}},{title:`关联订单`,dataIndex:`orders_count`,hideInForm:!0,hideInSearch:!0,align:`center`,render:(e,t)=>`${t.orders_count??0} 笔`},{title:`生成时间`,dataIndex:`created_at`,hideInForm:!0,hideInSearch:!0,align:`center`}];return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`mb-5`,children:[(0,k.jsx)(A,{level:3,children:`门店账单`}),(0,k.jsx)(j,{type:`secondary`,children:`采购单完成后在「采购单」页生成,每个门店单独一张;账单总金额 = 商品金额 + 配送费 + 附加金额(周转筐/托盘)+ 售后金额(可正负); 每行可单独导出为一个 Excel(账单内明细按商品合并)。`})]}),(0,k.jsx)(v,{api:`/recon/bill`,columns:J,rowKey:`id`,accessName:`recon.bill`,tableRef:e,operateRender:e=>[(0,k.jsx)(c,{size:`small`,type:`primary`,icon:(0,k.jsx)(o,{}),onClick:()=>V(e.id)},`detail`),(0,k.jsx)(y,{auth:`recon.bill.export`,children:(0,k.jsx)(c,{size:`small`,color:`orange`,variant:`solid`,icon:(0,k.jsx)(_,{}),loading:z===e.id,onClick:()=>W(e)})},`export`),e.status===0?(0,k.jsx)(y,{auth:`recon.bill.pay`,children:(0,k.jsx)(c,{size:`small`,variant:`solid`,color:`green`,onClick:()=>H(e),children:`确认收款`})},`pay`):null],formProps:!1,actionBarRender:e=>[e.search,e.keywordSearch],toolBarRender:e=>[e.columnSetting,e.hideBorder,e.reload,e.columnHeight]}),(0,k.jsx)(a,{title:l?`账单 ${l.bill.bill_no}`:`账单详情`,open:r,onClose:()=>i(!1),size:1e3,loading:M,children:l?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(f,{column:3,size:`small`,bordered:!0,children:[(0,k.jsx)(f.Item,{label:`门店`,children:l.bill.store?.name??`门店#${l.bill.store_id}`}),(0,k.jsx)(f.Item,{label:`采购单号`,children:l.bill.purchase?.purchase_no??`-`}),(0,k.jsx)(f.Item,{label:`账单日期`,children:l.bill.bill_date}),(0,k.jsxs)(f.Item,{label:`商品金额`,children:[`¥`,l.bill.product_amount]}),(0,k.jsxs)(f.Item,{label:`配送费`,children:[`¥`,l.bill.delivery_fee]}),(0,k.jsxs)(f.Item,{label:`附加金额`,children:[`¥`,l.bill.added_amount,(0,k.jsxs)(j,{type:`secondary`,className:`ml-2!`,children:[`(筐 `,l.bill.box_num,`×¥`,l.bill.box_price,`,托盘 `,l.bill.tray_num,`×¥`,l.bill.tray_price,`)`]})]}),(0,k.jsxs)(f.Item,{label:`售后金额`,children:[(0,k.jsxs)(j,{type:Number(l.bill.after_sale??0)<0?`success`:void 0,children:[`¥`,l.bill.after_sale??`0.00`]}),(0,k.jsx)(j,{type:`secondary`,className:`ml-2!`,children:`(可正负,计入总金额)`})]}),(0,k.jsx)(f.Item,{label:`账单总金额`,children:(0,k.jsxs)(j,{strong:!0,type:`danger`,children:[`¥`,l.bill.total_amount]})}),(0,k.jsx)(f.Item,{label:`支付状态`,children:(0,k.jsx)(g,{color:C[l.bill.status??0]?.color,children:C[l.bill.status??0]?.text})}),(0,k.jsx)(f.Item,{label:`付款时间`,children:l.bill.paid_at??`-`}),(0,k.jsx)(f.Item,{label:`收款人`,children:l.bill.paid_operator?.nickname??`-`}),(0,k.jsx)(f.Item,{label:`生成人`,children:l.bill.operator?.nickname??`-`}),(0,k.jsx)(f.Item,{label:`生成时间`,children:l.bill.created_at}),l.bill.pay_remark?(0,k.jsx)(f.Item,{label:`付款备注`,span:3,children:l.bill.pay_remark}):null,l.bill.remark?(0,k.jsx)(f.Item,{label:`备注`,span:3,children:l.bill.remark}):null]}),(0,k.jsx)(A,{level:5,className:`mt-6! mb-3!`,children:`商品明细(按商品合并)`}),(0,k.jsx)(s,{rowKey:`product_id`,size:`small`,bordered:!0,columns:G,dataSource:l.items,pagination:!1,scroll:{x:`max-content`},summary:K}),(0,k.jsxs)(A,{level:5,className:`mt-6! mb-3!`,children:[`关联订单(`,l.orders.length,` 笔)`]}),(0,k.jsx)(s,{rowKey:`id`,size:`small`,bordered:!0,columns:q,dataSource:l.orders,pagination:!1,scroll:{x:`max-content`}})]}):null}),(0,k.jsxs)(d,{title:P?`确认收款 · ${P.bill_no}`:`确认收款`,open:P!==null,onCancel:()=>F(null),onOk:()=>R.submit(),confirmLoading:I,okText:`确认收款`,destroyOnHidden:!0,children:[(0,k.jsxs)(`div`,{className:`py-2 text-gray-500`,children:[`应收金额 `,(0,k.jsxs)(j,{strong:!0,type:`danger`,children:[`¥`,P?.total_amount??`0.00`]}),`(商品 ¥`,P?.product_amount??`0.00`,` + 配送费 ¥`,P?.delivery_fee??`0.00`,` + 附加 ¥`,P?.added_amount??`0.00`,` + 售后 ¥`,P?.after_sale??`0.00`,`); 线下收款完成后登记付款信息,账单支付状态将置为「已支付」。`]}),(0,k.jsxs)(p,{form:R,layout:`vertical`,onFinish:U,children:[(0,k.jsx)(p.Item,{label:`付款时间`,name:`paid_at`,rules:[{required:!0,message:`请选择付款时间`}],children:(0,k.jsx)(u,{className:`w-full`,showTime:!0,allowClear:!1})}),(0,k.jsx)(p.Item,{label:`付款备注`,name:`pay_remark`,rules:[{max:255}],children:(0,k.jsx)(m.TextArea,{rows:2,maxLength:255,placeholder:`如:现金/转账单号等线下收款信息(选填)`})})]})]})]})};export{M as default}; |