推荐商品
This commit is contained in:
@@ -0,0 +1 @@
|
||||
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{t as a}from"./PlusOutlined-B8K2rG8r.js";import{t as o}from"./button-BILozH6U.js";import{r as s}from"./DoubleRightOutlined-Blfli1UU.js";import{t as c}from"./modal-g8Q5gNCx.js";import{t as l}from"./form-B3R3kIqp.js";import{t as u}from"./image-CTRBNpBE.js";import{r as d}from"./PictureOutlined-CB8Pr7jP.js";import{t as f}from"./tag-DBV1bHre.js";import{t as p}from"./DeleteOutlined-DwOvobSM.js";import{t as m}from"./XinTable-DOLiJ5rL.js";import{t as h}from"./AuthButton-DvrpreK4.js";import{t as g}from"./iProduct-l9WpLyUD.js";import{o as _}from"./goods-DPA1smJU.js";var v=e(t(),1),y={0:{text:`停用`,color:`error`},1:{text:`正常`,color:`success`}};async function b(e){return r({url:`/client/special/batch`,method:`post`,data:{product_ids:e}})}async function x(e){return r({url:`/client/special/batch`,method:`delete`,data:{ids:e}})}var S=n(),{Title:C,Text:w}=i,T=()=>{let e=(0,v.useRef)(null),[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)(!1),T=()=>{window.$modal?.confirm({title:`确定要删除选中的 ${t.length} 条推荐吗?`,okText:`删除`,okButtonProps:{danger:!0},cancelText:`取消`,onOk:async()=>{i(!0);try{await x(t),d.success(`批量删除成功`),n([]),await e.current?.reload()}finally{i(!1)}}})},[E,D]=(0,v.useState)(!1),[O,k]=(0,v.useState)(!1),[A]=l.useForm(),[j,M]=(0,v.useState)([]),N=()=>{A.resetFields(),D(!0),j.length===0&&_().then(e=>M(e.data.data??[]))};return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`mb-5`,children:[(0,S.jsx)(C,{level:3,children:`特价推荐`}),(0,S.jsx)(w,{type:`secondary`,children:`小程序首页「特价推荐」区展示的商品;价格按门店客户等级价展示,推荐停用或商品下架后不展示,排序越小越靠前。`})]}),(0,S.jsx)(m,{api:`/client/special`,columns:[{title:`ID`,dataIndex:`id`,hideInForm:!0,hideInSearch:!0,width:70,align:`center`},{title:`商品图片`,dataIndex:`image`,hideInForm:!0,hideInSearch:!0,align:`center`,width:100,render:(e,t)=>{let n=t.product?.images_arr?.[0]?.preview_url;return n?(0,S.jsx)(u,{src:n,width:60,height:60,style:{objectFit:`cover`,borderRadius:4}}):`-`}},{title:`商品名称`,dataIndex:`keyword`,hideInForm:!0,valueType:`text`,fieldProps:{placeholder:`按商品名称搜索`},render:(e,t)=>{let n=t.product;return n?`${n.name}${n.spec?`(${n.spec})`:``}`:`-`}},{title:`市场`,dataIndex:`market`,hideInForm:!0,hideInSearch:!0,align:`center`,render:(e,t)=>t.product?.market||`-`},{title:`计价单位`,dataIndex:`unit`,hideInForm:!0,hideInSearch:!0,align:`center`,width:90,render:(e,t)=>t.product?.unit||`-`},{title:`商品状态`,dataIndex:`product_status`,hideInForm:!0,hideInSearch:!0,align:`center`,width:100,render:(e,t)=>{let n=g[t.product?.status??1];return(0,S.jsx)(f,{color:n?.color,children:n?.text})}},{title:`排序`,dataIndex:`sort`,valueType:`digit`,hideInSearch:!0,initialValue:0,fieldProps:{min:0,precision:0},align:`center`,width:80},{title:`状态`,dataIndex:`status`,valueType:`radioButton`,initialValue:1,fieldProps:{options:[{value:1,label:`正常`},{value:0,label:`停用`}]},render:(e,t)=>{let n=y[t.status??1];return(0,S.jsx)(f,{color:n?.color,children:n?.text})},align:`center`,width:90},{title:`创建时间`,dataIndex:`created_at`,hideInForm:!0,hideInSearch:!0,align:`center`}],rowKey:`id`,accessName:`client.special`,tableRef:e,addShow:!1,rowSelection:{selectedRowKeys:t,onChange:e=>n(e.map(Number))},actionBarRender:e=>[e.search,(0,S.jsx)(h,{auth:`client.special.create`,children:(0,S.jsx)(o,{type:`primary`,icon:(0,S.jsx)(a,{}),onClick:N,children:`添加商品`})},`add`),(0,S.jsx)(h,{auth:`client.special.delete`,children:(0,S.jsxs)(o,{danger:!0,icon:(0,S.jsx)(p,{}),disabled:t.length===0,loading:r,onClick:T,children:[`批量删除`,t.length>0?` (${t.length})`:``]})},`batchDelete`)],formProps:{grid:!0,colProps:{span:12},layout:`vertical`},modalProps:{width:640}}),(0,S.jsx)(c,{title:`添加推荐商品`,open:E,onCancel:()=>D(!1),onOk:()=>A.submit(),confirmLoading:O,okText:`添加`,destroyOnHidden:!0,children:(0,S.jsx)(l,{form:A,layout:`vertical`,onFinish:async t=>{k(!0);try{let{added:n=0,skipped:r=0}=(await b(t.product_ids)).data.data??{};d.success(`已添加 ${n} 件推荐商品${r>0?`,${r} 件已在推荐中自动跳过`:``}`),D(!1),await e.current?.reload()}finally{k(!1)}},preserve:!1,children:(0,S.jsx)(l.Item,{label:`商品`,name:`product_ids`,rules:[{required:!0,message:`请选择商品`}],children:(0,S.jsx)(s,{mode:`multiple`,showSearch:{optionFilterProp:`label`},placeholder:`搜索并选择商品(可多选)`,options:j.map(e=>({value:e.id,label:`${e.name}${e.spec?`(${e.spec})`:``}`}))})})})})]})};export{T as default};
|
||||
Reference in New Issue
Block a user