Files
xin-procurement/public/assets/store-Wda1wq7X.js
T
2026-09-07 23:28:54 +08:00

1 line
16 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"./space-Cu4QVMgQ.js";import{t as c}from"./button-BILozH6U.js";import{t as l}from"./empty-_1ZFK8yy.js";import{n as u}from"./LockOutlined-B8eRH1x4.js";import{u as ee}from"./XinForm-BPDYdeax.js";import{t as d}from"./radio-CxFl70_7.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"./image-CTRBNpBE.js";import{r as g}from"./PictureOutlined-CB8Pr7jP.js";import{t as _}from"./popconfirm-DyseZgpU.js";import{t as v}from"./tag-DBV1bHre.js";import{t as y}from"./DeleteOutlined-DwOvobSM.js";import{t as b}from"./XinTable-DOLiJ5rL.js";import{t as x}from"./AuthButton-DvrpreK4.js";import{t as S}from"./store-JDnJsv44.js";import{n as C,t as w}from"./iStoreOrder-CyyYoLoV.js";import{s as T}from"./order-C6L8DsOz.js";import{n as E}from"./iPurchaseOrder-Dn-laOqY.js";var D=e(t(),1),O=e(u(),1);async function k(e){return r({url:`/order/store/${e}`,method:`get`})}async function A(e,t){return r({url:`/order/store/${e}/status`,method:`put`,data:{status:t}})}async function j(e,t){return r({url:`/order/store/batchStatus`,method:`put`,data:{ids:e,status:t}})}async function M(e){return r({url:`/order/store/${e}`,method:`delete`})}var N=n(),{Title:P,Text:F}=i,I={0:{status:1,label:`接单`}},L=[{value:1,label:`接单(待接单 → 已接单)`},{value:9,label:`取消订单(待接单 → 已取消)`}],R=()=>{let e=(0,D.useRef)(null),[t,n]=(0,D.useState)([]),[r,i]=(0,D.useState)(!1),[u,R]=(0,D.useState)(null),[z,B]=(0,D.useState)(!1),[V,H]=(0,D.useState)([]),[U,W]=(0,D.useState)(!1),[G,K]=(0,D.useState)(null),[q,J]=(0,D.useState)(!1),[te,Y]=(0,D.useState)(!1),[ne,X]=(0,D.useState)(!1),[Z]=m.useForm();(0,D.useEffect)(()=>{S().then(e=>n(e.data.data??[]))},[]);let re=async e=>{i(!0),B(!0);try{let t=await k(e);R(t.data.data??null)}finally{B(!1)}},Q=async(t,n)=>{await A(t,n),g.success(`状态已更新`),i(!1),await e.current?.reload()},ie=async()=>{if(G===null){g.warning(`请选择要流转的目标状态`);return}J(!0);try{let t=await j(V,G);g.success(`已批量流转 ${t.data.data?.success??0} 单`),W(!1),K(null),H([]),await e.current?.reload()}finally{J(!1)}},ae=async t=>{X(!0);try{let n=V.length>0?V.map(Number):void 0,r=await T(t.purchase_date.format(`YYYY-MM-DD`),n);g.success(`采购单 ${r.data.data?.purchase_no} 已生成,源订单已转为采购中`),Y(!1),H([]),await e.current?.reload()}finally{X(!1)}},$=async t=>{await M(t),g.success(`订单已删除`),i(!1),await e.current?.reload()},oe={api:`/order/store`,columns:[{title:`订单号`,hideInTable:!0,dataIndex:`order_no`,valueType:`text`,hideInForm:!0},{title:`商品名称`,hideInTable:!0,dataIndex:`product_name`,valueType:`text`,hideInForm:!0},{title:`基本信息`,dataIndex:`order_no`,hideInForm:!0,hideInSearch:!0,width:300,render:(e,t)=>(0,N.jsxs)(s,{orientation:`vertical`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(F,{type:`secondary`,children:`订单号:`}),(0,N.jsx)(F,{copyable:{text:t.order_no},children:t.order_no})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(F,{type:`secondary`,children:`订货时间:`}),t.created_at]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(F,{type:`secondary`,children:`订单状态:`}),(0,N.jsx)(v,{color:C[t.status??0]?.color,children:C[t.status??0]?.text})]})]})},{title:`商品信息`,dataIndex:`items`,hideInForm:!0,hideInSearch:!0,defaultHiddenInTable:!0,width:550,render:(e,t)=>(0,N.jsx)(s,{wrap:!0,size:20,children:t.items&&t.items.length>0&&t.items.map(e=>(0,N.jsxs)(`div`,{className:`flex`,children:[(0,N.jsx)(h,{src:e.image,width:60,height:60}),(0,N.jsxs)(`div`,{className:`ml-2.5`,children:[(0,N.jsx)(`div`,{children:e.product_name}),(0,N.jsxs)(`div`,{className:`text-[12px] text-[#999]`,children:[e.product_spec,` `,e.unit]}),(0,N.jsxs)(`div`,{className:`text-[12px] text-[#999]`,children:[(0,N.jsxs)(`span`,{className:`text-[red]`,children:[e.price,` ¥`]}),` × `,e.quantity]})]})]}))})},{title:`门店`,dataIndex:`store_id`,valueType:`select`,hideInForm:!0,hideInTable:!0,fieldProps:{options:[{label:`全部`,value:``},...t.map(e=>({label:e.name,value:e.id}))],showSearch:!0,optionFilterProp:`label`},render:(e,t)=>t.store?.name??`-`},{title:`门店信息`,dataIndex:`store_id`,hideInForm:!0,hideInSearch:!0,width:300,render:(e,t)=>(0,N.jsxs)(s,{orientation:`vertical`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(F,{type:`secondary`,children:`订货门店:`}),(0,N.jsx)(v,{color:`blue`,children:t.store?.name??`门店#${t.store_id}`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(F,{type:`secondary`,children:`联系人:`}),t.store?.contact??`-`]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(F,{type:`secondary`,children:`联系电话:`}),t.store?.phone??`-`]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(F,{type:`secondary`,children:`门店地址:`}),t.store?.address??`-`]})]})},{title:`订货日期`,dataIndex:`order_date`,valueType:`dateRange`,hideInForm:!0,hideInTable:!0,align:`center`,fieldProps:{presets:[{label:`今天`,value:[(0,O.default)(),(0,O.default)()]},{label:`昨天`,value:[(0,O.default)().subtract(1,`day`),(0,O.default)().subtract(1,`day`)]},{label:`前天`,value:[(0,O.default)().subtract(2,`day`),(0,O.default)().subtract(2,`day`)]},{label:`本周`,value:[(0,O.default)().startOf(`week`),(0,O.default)().endOf(`week`)]},{label:`本月`,value:[(0,O.default)().startOf(`month`),(0,O.default)().endOf(`month`)]}]}},{title:`附加信息`,hideInForm:!0,dataIndex:`status`,hideInSearch:!0,width:200,render:(e,t)=>(0,N.jsxs)(s,{orientation:`vertical`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(F,{type:`secondary`,children:`订货数量:`}),t.total_quantity]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(F,{type:`secondary`,children:`总重量:`}),t.total_weight,`斤`]})]})},{title:`订单金额`,hideInForm:!0,dataIndex:`total_amount`,hideInSearch:!0,width:200,render:e=>(0,N.jsxs)(`span`,{className:`text-[red] text-[16px]`,children:[e,` ¥`]})},{title:`订单状态`,dataIndex:`status`,valueType:`select`,hideInForm:!0,align:`center`,hideInTable:!0,fieldProps:{options:[{label:`全部`,value:``},...Object.entries(C).map(([e,t])=>({value:Number(e),label:t.text}))]}},{title:`采购单号`,dataIndex:`purchase_no`,valueType:`text`,hideInForm:!0,hideInTable:!0,fieldProps:{placeholder:`采购单号`,allowClear:!0}},{title:`采购单`,dataIndex:`purchase_id`,valueType:`digit`,hideInForm:!0,hideInSearch:!0,render:(e,t)=>t.purchase?(0,N.jsxs)(s,{orientation:`vertical`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(F,{type:`secondary`,children:`采购单号:`}),t.purchase.purchase_no]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(F,{type:`secondary`,children:`采购单日期:`}),t.purchase.purchase_date]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(F,{type:`secondary`,children:`采购单状态:`}),(0,N.jsx)(v,{color:E[t.purchase.status??0]?.color,children:E[t.purchase.status??0]?.text})]})]}):`-`},{title:`账单信息`,dataIndex:`bill_id`,hideInForm:!0,hideInSearch:!0,width:240,render:(e,t)=>t.bill?(0,N.jsxs)(s,{orientation:`vertical`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(F,{type:`secondary`,children:`账单号:`}),t.bill.bill_no]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(F,{type:`secondary`,children:`支付状态:`}),(0,N.jsx)(v,{color:w[t.bill.pay_state??0]?.color,children:t.bill.pay_state_name??w[t.bill.pay_state??0]?.text})]})]}):`-`},{title:`操作栏`,dataIndex:`operate`,hideInForm:!0,hideInSearch:!0,width:180,render:(e,t)=>(0,N.jsxs)(s,{size:5,wrap:!0,children:[(0,N.jsx)(c,{type:`primary`,icon:(0,N.jsx)(o,{}),onClick:()=>re(t.id)}),I[t.status]&&(0,N.jsx)(x,{auth:`order.store.update`,children:(0,N.jsx)(_,{title:`确认将订单状态更新为「${I[t.status].label}」?`,onConfirm:()=>Q(t.id,I[t.status].status),children:(0,N.jsx)(c,{type:`primary`,color:`green`,variant:`solid`,children:I[t.status].label})})}),t.status===0&&(0,N.jsx)(x,{auth:`order.store.update`,children:(0,N.jsx)(_,{title:`确认取消该订单吗?`,onConfirm:()=>Q(t.id,9),children:(0,N.jsx)(c,{type:`primary`,color:`danger`,variant:`solid`,children:`取消订单`})})}),t.status===9&&(0,N.jsx)(x,{auth:`order.store.delete`,children:(0,N.jsx)(_,{title:`确认删除该订单吗?`,description:`仅已取消订单可删除,删除后后台与小程序端均不可见`,onConfirm:()=>$(t.id),children:(0,N.jsx)(c,{icon:(0,N.jsx)(y,{}),color:`danger`,variant:`solid`})})})]})}],rowKey:`id`,accessName:`order.store`,tableRef:e,operateShow:!1,formProps:!1,searchDefaultOpen:!0,rowSelection:{selectedRowKeys:V,onChange:e=>H(e)},actionBarRender:e=>[e.search,(0,N.jsx)(x,{auth:`purchase.order.generate`,children:(0,N.jsx)(c,{type:`primary`,onClick:()=>Y(!0),children:`生成采购单`})},`generate`),(0,N.jsx)(x,{auth:`order.store.update`,children:(0,N.jsxs)(c,{type:`primary`,disabled:V.length===0,onClick:()=>W(!0),children:[`批量操作`,V.length>0?`${V.length}`:``]})},`batch`),e.keywordSearch]};return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`mb-5`,children:[(0,N.jsx)(P,{level:3,children:`门店订单`}),(0,N.jsx)(F,{type:`secondary`,children:`小程序下单为待接单;接单后通过「生成采购单」合并为采购单并转采购中,采购单完成后订单自动转配送中,生成账单后订单自动完成。`})]}),(0,N.jsx)(b,{...oe}),(0,N.jsx)(a,{title:`订单详情`,open:r,onClose:()=>i(!1),size:1e3,loading:z,footer:u?(0,N.jsxs)(s,{className:`flex justify-end`,wrap:!0,children:[I[u.status]&&(0,N.jsx)(x,{auth:`order.store.update`,children:(0,N.jsx)(_,{title:`确认将订单状态更新为「${I[u.status].label}」?`,onConfirm:()=>Q(u.id,I[u.status].status),children:(0,N.jsx)(c,{type:`primary`,color:`green`,variant:`solid`,children:I[u.status].label})})}),u.status===0&&(0,N.jsx)(x,{auth:`order.store.update`,children:(0,N.jsx)(_,{title:`确认取消该订单吗?`,onConfirm:()=>Q(u.id,9),children:(0,N.jsx)(c,{type:`primary`,color:`danger`,variant:`solid`,children:`取消订单`})})}),u.status===9&&(0,N.jsx)(x,{auth:`order.store.delete`,children:(0,N.jsx)(_,{title:`确认删除该订单吗?`,description:`仅已取消订单可删除,删除后后台与小程序端均不可见`,onConfirm:()=>$(u.id),children:(0,N.jsx)(c,{icon:(0,N.jsx)(y,{}),color:`danger`,variant:`solid`,children:`删除`})})})]}):null,children:u?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(p,{title:`门店信息`,column:3,size:`small`,bordered:!0,children:[(0,N.jsx)(p.Item,{label:`门店名称`,children:u.store?.name??`门店#${u.store_id}`}),(0,N.jsx)(p.Item,{label:`联系人`,children:u.store?.contact??`-`}),(0,N.jsx)(p.Item,{label:`联系电话`,children:u.store?.phone??`-`}),(0,N.jsx)(p.Item,{label:`门店地址`,span:3,children:u.store?.address??`-`})]}),(0,N.jsxs)(p,{title:`订单信息`,column:3,size:`small`,bordered:!0,className:`mt-4!`,children:[(0,N.jsx)(p.Item,{label:`订单号`,children:u.order_no}),(0,N.jsx)(p.Item,{label:`订货日期`,children:u.order_date}),(0,N.jsx)(p.Item,{label:`状态`,children:(0,N.jsx)(v,{color:C[u.status??0]?.color,children:C[u.status??0]?.text})}),(0,N.jsx)(p.Item,{label:`订货总量`,children:u.total_quantity}),(0,N.jsxs)(p.Item,{label:`总重量`,children:[u.total_weight,`斤`]}),(0,N.jsx)(p.Item,{label:`账单ID`,children:u.bill_id??`-`}),u.remark?(0,N.jsx)(p.Item,{label:`备注`,span:3,children:u.remark}):null]}),u.bill?(0,N.jsxs)(p,{title:`账单信息`,column:3,size:`small`,bordered:!0,className:`mt-4!`,children:[(0,N.jsx)(p.Item,{label:`账单号`,children:u.bill.bill_no}),(0,N.jsx)(p.Item,{label:`账单日期`,children:u.bill.bill_date??`-`}),(0,N.jsx)(p.Item,{label:`支付状态`,children:(0,N.jsx)(v,{color:w[u.bill.pay_state??0]?.color,children:u.bill.pay_state_name??w[u.bill.pay_state??0]?.text})}),(0,N.jsx)(p.Item,{label:`付款时间`,children:u.bill.paid_at??`-`}),(0,N.jsx)(p.Item,{label:`付款备注`,children:u.bill.pay_remark||`-`})]}):null,(0,N.jsx)(P,{level:5,className:`mt-6! mb-3!`,children:`商品明细`}),(0,N.jsxs)(`div`,{className:`overflow-hidden rounded border border-gray-200`,children:[(0,N.jsxs)(`div`,{className:`flex bg-gray-50 px-4 py-2 text-sm text-gray-500`,children:[(0,N.jsx)(`div`,{className:`flex-1`,children:`商品信息`}),(0,N.jsx)(`div`,{className:`w-30 shrink-0 text-center`,children:`供应商`}),(0,N.jsx)(`div`,{className:`w-30 shrink-0 text-center`,children:`单价`}),(0,N.jsx)(`div`,{className:`w-26 shrink-0 text-center`,children:`订货量`}),(0,N.jsx)(`div`,{className:`w-33 shrink-0 text-center`,children:`订货金额`}),(0,N.jsx)(`div`,{className:`w-33 shrink-0 text-center`,children:`重量`})]}),(u.items??[]).map(e=>(0,N.jsxs)(`div`,{className:`flex items-center border-t border-gray-100 px-4 py-3`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,N.jsx)(h.PreviewGroup,{children:e.image?(0,N.jsx)(h,{src:e.image,width:64,height:64,style:{objectFit:`cover`,borderRadius:4}}):(0,N.jsx)(`div`,{className:`flex h-16 w-16 shrink-0 items-center justify-center rounded bg-gray-100 text-xs text-gray-400`,children:`暂无图片`})}),(0,N.jsxs)(`div`,{className:`ml-3 min-w-0`,children:[(0,N.jsx)(`div`,{className:`text-sm font-medium`,children:e.product_name}),(0,N.jsxs)(`div`,{className:`mt-0.5 text-xs text-gray-500`,children:[e.product_spec||`-`,` `,e.unit||`-`,(0,N.jsxs)(`div`,{children:[`成本:¥`,e.cost_price??`0.00`]})]}),e.remark?(0,N.jsxs)(`div`,{className:`mt-0.5 truncate text-xs text-gray-500`,children:[`备注:`,e.remark]}):null]})]}),(0,N.jsx)(`div`,{className:`w-30 shrink-0 text-center`,children:e.supplier?.name??`-`}),(0,N.jsxs)(`div`,{className:`w-30 shrink-0 text-center`,children:[`¥`,e.price]}),(0,N.jsx)(`div`,{className:`w-26 shrink-0 text-center`,children:e.quantity}),(0,N.jsx)(`div`,{className:`w-33 shrink-0 text-center`,children:(0,N.jsxs)(F,{strong:!0,children:[`¥`,e.amount]})}),(0,N.jsxs)(`div`,{className:`w-33 shrink-0 text-center`,children:[e.weight??`-`,` 斤`]})]},e.id)),(0,N.jsxs)(`div`,{className:`flex bg-gray-50 px-4 py-3 text-sm`,children:[(0,N.jsx)(`div`,{className:`flex-1`,children:`总计`}),(0,N.jsx)(`div`,{className:`w-30 shrink-0 text-center`}),(0,N.jsx)(`div`,{className:`w-30 shrink-0 text-center`}),(0,N.jsx)(`div`,{className:`w-26 shrink-0 text-center`,children:u.total_quantity}),(0,N.jsxs)(`div`,{className:`w-33 shrink-0 text-center text-[red] text-[16px]`,children:[`¥`,u.total_amount]}),(0,N.jsxs)(`div`,{className:`w-33 shrink-0 text-center`,children:[u.total_weight,`斤`]})]}),(u.items??[]).length===0&&(0,N.jsx)(l,{image:l.PRESENTED_IMAGE_SIMPLE,description:`暂无商品明细`,className:`py-8!`})]})]}):null}),(0,N.jsxs)(f,{title:`生成采购单`,open:te,onCancel:()=>Y(!1),onOk:()=>Z.submit(),confirmLoading:ne,okText:`确认生成`,destroyOnHidden:!0,children:[(0,N.jsxs)(`div`,{className:`py-2 text-gray-500`,children:[V.length>0?`将合并选中的 ${V.length} 笔订单生成一张采购单(须均为已接单状态,否则整批中止)。`:`未勾选订单时,将合并全部「已接单」订单生成一张采购单。`,`生成后源订单自动转为「采购中」。`]}),(0,N.jsx)(m,{form:Z,layout:`vertical`,onFinish:ae,children:(0,N.jsx)(m.Item,{label:`采购日期`,name:`purchase_date`,initialValue:(0,O.default)(),rules:[{required:!0,message:`请选择采购日期`}],children:(0,N.jsx)(ee,{className:`w-full`,allowClear:!1})})})]}),(0,N.jsxs)(f,{title:`批量状态流转`,open:U,onCancel:()=>W(!1),onOk:ie,confirmLoading:q,okText:`确认流转`,destroyOnHidden:!0,children:[(0,N.jsxs)(`div`,{className:`py-2 text-gray-500`,children:[`已勾选 `,V.length,` 笔订单;任一订单不满足流转条件时,本次批量操作将整批中止,不做任何修改。`]}),(0,N.jsx)(d.Group,{className:`w-full py-2`,value:G,onChange:e=>K(e.target.value),children:(0,N.jsx)(s,{orientation:`vertical`,children:L.map(e=>(0,N.jsx)(d,{value:e.value,children:e.label},e.value))})})]})]})};export{R as default};