Files
xin-procurement/public/assets/bill-d4QJGLlp.js
T
2026-08-31 22:21:59 +08:00

1 line
11 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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{r as l}from"./DoubleRightOutlined-Blfli1UU.js";import{n as u}from"./LockOutlined-B8eRH1x4.js";import{u as d}from"./XinForm-BPDYdeax.js";import{t as f}from"./modal-g8Q5gNCx.js";import{t as p}from"./descriptions-BLF6MKiu.js";import{t as m}from"./form-B3R3kIqp.js";import{t as h}from"./input-CHcsaDtX.js";import{r as g}from"./PictureOutlined-CB8Pr7jP.js";import{t as _}from"./tag-DBV1bHre.js";import{t as v}from"./DownloadOutlined-DJY9Mu8c.js";import{t as y}from"./XinTable-DOLiJ5rL.js";import{t as b}from"./AuthButton-DvrpreK4.js";import{t as x}from"./download-DC9wDwqQ.js";import{t as S}from"./store-JDnJsv44.js";import{n as C}from"./iStoreOrder-CyyYoLoV.js";import{t as w}from"./iPurchaseOrder-Dn-laOqY.js";import{n as T}from"./category-MmrJkdbs.js";var E=e(t(),1),D=e(u(),1);async function O(e){return r({url:`/recon/bill/${e}`,method:`get`})}async function k(e,t){return r({url:`/recon/bill/${e}/pay`,method:`put`,data:t})}async function A(e,t){return x(`/recon/bill/export`,{ids:e.join(`,`),category_id:t},`门店账单.xlsx`)}var j=n(),{Title:M,Text:N}=i,P=()=>{let e=(0,E.useRef)(null),[t,n]=(0,E.useState)([]),[r,i]=(0,E.useState)(!1),[u,x]=(0,E.useState)(null),[P,F]=(0,E.useState)(!1),[I,L]=(0,E.useState)(null),[R,z]=(0,E.useState)(!1),[B]=m.useForm(),[V,H]=(0,E.useState)([]),[U,W]=(0,E.useState)(!1),[G,K]=(0,E.useState)(!1),[q,J]=(0,E.useState)(0),[Y,X]=(0,E.useState)([]);(0,E.useEffect)(()=>{S().then(e=>n(e.data.data??[])),T().then(e=>X((e.data.data??[]).map(e=>({value:e.id,label:e.name??``}))))},[]);let Z=async e=>{i(!0),F(!0);try{let t=await O(e);x(t.data.data??null)}finally{F(!1)}},Q=e=>{L(e),B.setFieldsValue({paid_at:(0,D.default)(),pay_remark:``})},$=async t=>{if(I?.id){z(!0);try{await k(I.id,{paid_at:t.paid_at.format(`YYYY-MM-DD HH:mm:ss`),pay_remark:t.pay_remark??``}),g.success(`收款已登记,账单已置为已支付`),L(null),await e.current?.reload()}finally{z(!1)}}},ee=async()=>{if(V.length!==0){K(!0);try{await A(V,q),W(!1)}finally{K(!1)}}},te=[{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,j.jsx)(N,{strong:!0,children:e})},{title:`重量`,dataIndex:`weight`,width:100,align:`center`,render:e=>`${e}斤`},{title:`金额`,dataIndex:`amount`,width:110,align:`center`,render:e=>(0,j.jsxs)(N,{strong:!0,children:[`¥`,Number(e).toFixed(2)]})}],ne=()=>{let e=u?.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,j.jsxs)(s.Summary.Row,{children:[(0,j.jsx)(s.Summary.Cell,{index:0,colSpan:4,align:`center`,children:(0,j.jsx)(N,{strong:!0,children:`合计`})}),(0,j.jsx)(s.Summary.Cell,{index:4,align:`center`,children:(0,j.jsx)(N,{strong:!0,children:t})}),(0,j.jsx)(s.Summary.Cell,{index:5,align:`center`,children:(0,j.jsxs)(N,{strong:!0,children:[n.toFixed(3),`斤`]})}),(0,j.jsx)(s.Summary.Cell,{index:6,align:`center`,children:(0,j.jsxs)(N,{strong:!0,type:`danger`,children:[`¥`,r.toFixed(2)]})})]})},re=[{title:`订单号`,dataIndex:`order_no`,align:`center`,render:e=>(0,j.jsx)(N,{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,j.jsxs)(N,{strong:!0,children:[`¥`,e]})},{title:`状态`,dataIndex:`status`,align:`center`,render:e=>{let t=C[Number(e??0)];return(0,j.jsx)(_,{color:t?.color,children:t?.text})}}],ie=[{title:`账单号`,dataIndex:`bill_no`,valueType:`text`,hideInForm:!0,width:210,render:(e,t)=>(0,j.jsx)(N,{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,j.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,j.jsxs)(N,{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,j.jsxs)(N,{strong:!0,type:`danger`,children:[`¥`,t.total_amount]})},{title:`支付状态`,dataIndex:`status`,valueType:`select`,hideInForm:!0,align:`center`,fieldProps:{options:Object.entries(w).map(([e,t])=>({value:Number(e),label:t.text}))},render:(e,t)=>{let n=w[t.status??0];return(0,j.jsx)(_,{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,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`mb-5`,children:[(0,j.jsx)(M,{level:3,children:`门店账单`}),(0,j.jsx)(N,{type:`secondary`,children:`采购单完成后在「采购单」页生成,每个门店单独一张;账单总金额 = 商品金额 + 配送费 + 附加金额(周转筐/托盘)+ 售后金额(可正负); 勾选多张账单可合并导出为一个 Excel(明细跨账单按商品合并,可按一级分类过滤)。`})]}),(0,j.jsx)(y,{api:`/recon/bill`,columns:ie,rowKey:`id`,accessName:`recon.bill`,tableRef:e,operateRender:e=>[(0,j.jsx)(c,{size:`small`,type:`primary`,icon:(0,j.jsx)(o,{}),onClick:()=>Z(e.id)},`detail`),e.status===0?(0,j.jsx)(b,{auth:`recon.bill.pay`,children:(0,j.jsx)(c,{size:`small`,variant:`solid`,color:`green`,onClick:()=>Q(e),children:`确认收款`})},`pay`):null],formProps:!1,actionBarRender:e=>[e.search,e.keywordSearch],rowSelection:{selectedRowKeys:V,onChange:e=>H(e.map(Number)),preserveSelectedRowKeys:!0},toolBarRender:e=>[(0,j.jsx)(b,{auth:`recon.bill.export`,children:(0,j.jsxs)(c,{icon:(0,j.jsx)(v,{}),disabled:V.length===0,onClick:()=>W(!0),children:[`导出`,V.length>0?`${V.length}`:``]})},`export`),e.columnSetting,e.hideBorder,e.reload,e.columnHeight]}),(0,j.jsx)(a,{title:u?`账单 ${u.bill.bill_no}`:`账单详情`,open:r,onClose:()=>i(!1),size:1e3,loading:P,children:u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(p,{column:3,size:`small`,bordered:!0,children:[(0,j.jsx)(p.Item,{label:`门店`,children:u.bill.store?.name??`门店#${u.bill.store_id}`}),(0,j.jsx)(p.Item,{label:`采购单号`,children:u.bill.purchase?.purchase_no??`-`}),(0,j.jsx)(p.Item,{label:`账单日期`,children:u.bill.bill_date}),(0,j.jsxs)(p.Item,{label:`商品金额`,children:[`¥`,u.bill.product_amount]}),(0,j.jsxs)(p.Item,{label:`配送费`,children:[`¥`,u.bill.delivery_fee]}),(0,j.jsxs)(p.Item,{label:`附加金额`,children:[`¥`,u.bill.added_amount,(0,j.jsxs)(N,{type:`secondary`,className:`ml-2!`,children:[`(筐 `,u.bill.box_num,`×¥`,u.bill.box_price,`,托盘 `,u.bill.tray_num,`×¥`,u.bill.tray_price,``]})]}),(0,j.jsxs)(p.Item,{label:`售后金额`,children:[(0,j.jsxs)(N,{type:Number(u.bill.after_sale??0)<0?`success`:void 0,children:[`¥`,u.bill.after_sale??`0.00`]}),(0,j.jsx)(N,{type:`secondary`,className:`ml-2!`,children:`(可正负,计入总金额)`})]}),(0,j.jsx)(p.Item,{label:`账单总金额`,children:(0,j.jsxs)(N,{strong:!0,type:`danger`,children:[`¥`,u.bill.total_amount]})}),(0,j.jsx)(p.Item,{label:`支付状态`,children:(0,j.jsx)(_,{color:w[u.bill.status??0]?.color,children:w[u.bill.status??0]?.text})}),(0,j.jsx)(p.Item,{label:`付款时间`,children:u.bill.paid_at??`-`}),(0,j.jsx)(p.Item,{label:`收款人`,children:u.bill.paid_operator?.nickname??`-`}),(0,j.jsx)(p.Item,{label:`生成人`,children:u.bill.operator?.nickname??`-`}),(0,j.jsx)(p.Item,{label:`生成时间`,children:u.bill.created_at}),u.bill.pay_remark?(0,j.jsx)(p.Item,{label:`付款备注`,span:3,children:u.bill.pay_remark}):null,u.bill.remark?(0,j.jsx)(p.Item,{label:`备注`,span:3,children:u.bill.remark}):null]}),(0,j.jsx)(M,{level:5,className:`mt-6! mb-3!`,children:`商品明细(按商品合并)`}),(0,j.jsx)(s,{rowKey:`product_id`,size:`small`,bordered:!0,columns:te,dataSource:u.items,pagination:!1,scroll:{x:`max-content`},summary:ne}),(0,j.jsxs)(M,{level:5,className:`mt-6! mb-3!`,children:[`关联订单(`,u.orders.length,` 笔)`]}),(0,j.jsx)(s,{rowKey:`id`,size:`small`,bordered:!0,columns:re,dataSource:u.orders,pagination:!1,scroll:{x:`max-content`}})]}):null}),(0,j.jsxs)(f,{title:I?`确认收款 · ${I.bill_no}`:`确认收款`,open:I!==null,onCancel:()=>L(null),onOk:()=>B.submit(),confirmLoading:R,okText:`确认收款`,destroyOnHidden:!0,children:[(0,j.jsxs)(`div`,{className:`py-2 text-gray-500`,children:[`应收金额 `,(0,j.jsxs)(N,{strong:!0,type:`danger`,children:[`¥`,I?.total_amount??`0.00`]}),`(商品 ¥`,I?.product_amount??`0.00`,` + 配送费 ¥`,I?.delivery_fee??`0.00`,` + 附加 ¥`,I?.added_amount??`0.00`,` + 售后 ¥`,I?.after_sale??`0.00`,`); 线下收款完成后登记付款信息,账单支付状态将置为「已支付」。`]}),(0,j.jsxs)(m,{form:B,layout:`vertical`,onFinish:$,children:[(0,j.jsx)(m.Item,{label:`付款时间`,name:`paid_at`,rules:[{required:!0,message:`请选择付款时间`}],children:(0,j.jsx)(d,{className:`w-full`,showTime:!0,allowClear:!1})}),(0,j.jsx)(m.Item,{label:`付款备注`,name:`pay_remark`,rules:[{max:255}],children:(0,j.jsx)(h.TextArea,{rows:2,maxLength:255,placeholder:`如:现金/转账单号等线下收款信息(选填)`})})]})]}),(0,j.jsxs)(f,{title:`导出账单`,open:U,onCancel:()=>W(!1),onOk:ee,confirmLoading:G,okText:`导出`,destroyOnHidden:!0,children:[(0,j.jsxs)(`div`,{className:`py-2 text-gray-500`,children:[`已选 `,(0,j.jsx)(N,{strong:!0,children:V.length}),` 张账单,导出为一个 Excel:商品明细跨账单按商品合并,表尾汇总配送费、附加金额与总金额; 选择分类后仅导出该一级分类下的商品明细(配送费/附加金额仍全额汇总)。`]}),(0,j.jsx)(m,{layout:`vertical`,children:(0,j.jsx)(m.Item,{label:`商品分类`,children:(0,j.jsx)(l,{value:q,onChange:e=>J(e),options:[{value:0,label:`全部分类`},...Y]})})})]})]})};export{P as default};