import{r as c,d as ae,u as le,a as oe,o as ne,c as re,b as t,w as l,e as y,p as ie,f as s,g as z,h as de,i as w,j as r,N as D,B as g,k as f,l as S,q as j,m as ue,n as _,_ as se}from"./index-CkzfmDGw.js";import{S as pe}from"./SearchOutline-BKr0yDBJ.js";import{R as ce}from"./RefreshOutline-DXhpU5zO.js";import{D as fe}from"./DownloadOutline-DvUGqON3.js";import{C as me}from"./CloudUploadOutline-DMPKBx4X.js";import{T as ve}from"./TrashOutline-DHG1tVXU.js";const b={page(o){return c({url:"/biz/order/page",method:"get",params:o})},detail(o){return c({url:`/biz/order/${o}`,method:"get"})},create(o){return c({url:"/biz/order",method:"post",data:o})},update(o){return c({url:"/biz/order",method:"put",data:o})},audit(o){return c({url:"/biz/order/audit",method:"put",data:o})},delete(o){return c({url:`/biz/order/${o.join(",")}`,method:"delete"})},export(o){var x;const d={};return(x=o==null?void 0:o.ids)!=null&&x.length&&(d.ids=o.ids.join(",")),(o==null?void 0:o.id)!==void 0&&(o==null?void 0:o.id)!==null&&(d.id=o.id),c({url:"/biz/order/export",method:"get",params:d,responseType:"blob"})},importData(o){const d=new FormData;return d.append("file",o),c({url:"/biz/order/import",method:"post",data:d,headers:{"Content-Type":"multipart/form-data"}})},downloadTemplate(){return c({url:"/biz/order/template",method:"get",responseType:"blob"})}},ye={class:"page-container"},ge={class:"search-form"},be={style:{"margin-bottom":"12px"}},_e=ae({__name:"index",setup(o){const d=le(),x=oe(),h=z({orderNo:null}),C=y([]),U=y(!1),q=y([]),m=z({page:1,pageSize:10,itemCount:0,showSizePicker:!0,pageSizes:[10,20,50]}),T=y(!1),$=y(""),k=y(!1),I=y(),i=z({...{orderNo:"",userId:void 0,productId:void 0,quota:void 0,totalPrice:void 0,unitPrice:void 0,payStatus:void 0}}),N=y([]),V={},B=[{title:"订单编号",key:"orderNo"},{title:"购买人",key:"userName"},{title:"商品",key:"productName"},{title:"购买份额",key:"quota"},{title:"总价",key:"totalPrice"},{title:"创建时间",key:"createTime"},{title:"购买结果",key:" payPhotoUrl",render(a){return a.payPhotoUrl?_("img",{src:a.payPhotoUrl,style:{width:"60px",height:"60px",objectFit:"cover",borderRadius:"4px"}}):"-"}},{title:"购买状态",key:"payStatus",render(a){return _(j,{value:a.payStatus,"onUpdate:value":e=>{a.payStatus=e,Object.assign(i,a),E()},options:N.value,disabled:a.payStatus!==1})}},{title:"操作",key:"actions",width:140,fixed:"right",render(a){return _("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"nowrap"}},[_(g,{size:"small",quaternary:!0,type:"error",onClick:()=>W(a),disabled:a.payStatus===2},{default:()=>[_(S,null,{default:()=>_(ve)})," 删除"]})])}}];async function v(){U.value=!0;try{const a=await b.page({page:m.page,pageSize:m.pageSize,orderNo:h.orderNo||void 0});C.value=a.list,m.itemCount=a.total}finally{U.value=!1}}function P(){m.page=1,v()}function F(){h.orderNo=null,P()}function L(a){m.page=a,v()}function A(a){m.pageSize=a,m.page=1,v()}function M(a){q.value=a}async function E(){try{const a={...i};typeof a.createTime=="number"&&(a.createTime=new Date(a.createTime).toISOString().slice(0,19).replace("T"," ")),typeof a.updateTime=="number"&&(a.updateTime=new Date(a.updateTime).toISOString().slice(0,19).replace("T"," ")),await b.audit(a),d.success("修改成功"),v()}catch{}}async function K(){var a;await((a=I.value)==null?void 0:a.validate());try{const e={...i};typeof e.createTime=="number"&&(e.createTime=new Date(e.createTime).toISOString().slice(0,19).replace("T"," ")),typeof e.updateTime=="number"&&(e.updateTime=new Date(e.updateTime).toISOString().slice(0,19).replace("T"," ")),e.id?(await b.update(e),d.success("修改成功")):(await b.create(e),d.success("新增成功")),T.value=!1,v()}catch{}}function W(a){x.warning({title:"提示",content:"确定要删除该记录吗？",positiveText:"确定",negativeText:"取消",onPositiveClick:async()=>{try{await b.delete([a.id]),d.success("删除成功"),v()}catch{}}})}async function G(){try{const a=await b.downloadTemplate(),e=window.URL.createObjectURL(a),u=document.createElement("a");u.href=e,u.download="订单导入模板.xlsx",u.click(),window.URL.revokeObjectURL(e)}catch{}}async function H({file:a}){if(a.file)try{const e=await b.importData(a.file);e.fail>0?x.warning({title:"导入结果",content:`成功: ${e.success} 条，失败: ${e.fail} 条
错误信息: ${(e.errors||[]).join(`
`)||"无"}`,positiveText:"确定"}):(d.success(`导入成功，共 ${e.success} 条数据`),k.value=!1),v()}catch{}}async function J(){try{const a=await ie.listByType("pay_status");N.value=a.map(e=>({label:e.dictLabel,value:Number(e.dictValue)||e.dictValue}))}catch{}}return ne(()=>{v(),J()}),(a,e)=>{const u=s("n-input"),p=s("n-form-item"),O=s("n-form"),Q=s("n-data-table"),X=s("n-card"),R=s("n-modal"),Y=s("n-alert"),Z=s("n-text"),ee=s("n-p"),te=s("n-upload-dragger");return de(),re("div",ye,[t(X,null,{default:l(()=>[w("div",ge,[t(O,{inline:"",model:h,"label-placement":"left"},{default:l(()=>[t(p,{label:"订单编号"},{default:l(()=>[t(u,{value:h.orderNo,"onUpdate:value":e[0]||(e[0]=n=>h.orderNo=n),placeholder:"请输入订单编号",clearable:""},null,8,["value"])]),_:1}),t(p,null,{default:l(()=>[t(r(D),null,{default:l(()=>[t(r(g),{type:"primary",onClick:P},{icon:l(()=>[t(r(S),null,{default:l(()=>[t(r(pe))]),_:1})]),default:l(()=>[e[12]||(e[12]=f(" 搜索 ",-1))]),_:1}),t(r(g),{onClick:F},{icon:l(()=>[t(r(S),null,{default:l(()=>[t(r(ce))]),_:1})]),default:l(()=>[e[13]||(e[13]=f(" 重置 ",-1))]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])]),t(Q,{columns:B,data:C.value,loading:U.value,pagination:m,"row-key":n=>n.id,"scroll-x":1200,"onUpdate:page":L,"onUpdate:pageSize":A,"onUpdate:checkedRowKeys":M},null,8,["data","loading","pagination","row-key"])]),_:1}),t(R,{show:T.value,"onUpdate:show":e[9]||(e[9]=n=>T.value=n),preset:"card",title:$.value,style:{width:"600px"}},{footer:l(()=>[t(r(D),{justify:"end"},{default:l(()=>[t(r(g),{onClick:e[8]||(e[8]=n=>T.value=!1)},{default:l(()=>[...e[14]||(e[14]=[f("取消",-1)])]),_:1}),t(r(g),{type:"primary",onClick:K},{default:l(()=>[...e[15]||(e[15]=[f("确定",-1)])]),_:1})]),_:1})]),default:l(()=>[t(O,{ref_key:"formRef",ref:I,model:i,rules:V,"label-placement":"left","label-width":"100px"},{default:l(()=>[t(p,{label:"订单编号",path:"orderNo"},{default:l(()=>[t(u,{value:i.orderNo,"onUpdate:value":e[1]||(e[1]=n=>i.orderNo=n),placeholder:"请输入订单编号"},null,8,["value"])]),_:1}),t(p,{label:"购买人ID",path:"userId"},{default:l(()=>[t(u,{value:i.userId,"onUpdate:value":e[2]||(e[2]=n=>i.userId=n),placeholder:"请输入购买人ID"},null,8,["value"])]),_:1}),t(p,{label:"商品id",path:"productId"},{default:l(()=>[t(u,{value:i.productId,"onUpdate:value":e[3]||(e[3]=n=>i.productId=n),placeholder:"请输入商品id"},null,8,["value"])]),_:1}),t(p,{label:"购买份额",path:"quota"},{default:l(()=>[t(u,{value:i.quota,"onUpdate:value":e[4]||(e[4]=n=>i.quota=n),placeholder:"请输入购买份额"},null,8,["value"])]),_:1}),t(p,{label:"总价",path:"totalPrice"},{default:l(()=>[t(u,{value:i.totalPrice,"onUpdate:value":e[5]||(e[5]=n=>i.totalPrice=n),placeholder:"请输入总价"},null,8,["value"])]),_:1}),t(p,{label:"单价",path:"unitPrice"},{default:l(()=>[t(u,{value:i.unitPrice,"onUpdate:value":e[6]||(e[6]=n=>i.unitPrice=n),placeholder:"请输入单价"},null,8,["value"])]),_:1}),t(p,{label:"购买状态",path:"payStatus"},{default:l(()=>[t(r(j),{value:i.payStatus,"onUpdate:value":e[7]||(e[7]=n=>i.payStatus=n),placeholder:"请选择购买状态",options:N.value},null,8,["value","options"])]),_:1})]),_:1},8,["model"])]),_:1},8,["show","title"]),t(R,{show:k.value,"onUpdate:show":e[11]||(e[11]=n=>k.value=n),preset:"card",title:"导入订单",style:{width:"500px"}},{footer:l(()=>[t(r(g),{onClick:e[10]||(e[10]=n=>k.value=!1)},{default:l(()=>[...e[21]||(e[21]=[f("关闭",-1)])]),_:1})]),default:l(()=>[t(r(D),{vertical:""},{default:l(()=>[t(Y,{type:"info"},{header:l(()=>[...e[16]||(e[16]=[f("导入说明",-1)])]),default:l(()=>[e[17]||(e[17]=w("ul",{style:{margin:"0","padding-left":"16px","line-height":"1.8"}},[w("li",null,"请先下载导入模板，按模板格式填写数据"),w("li",null,"支持 .xlsx 或 .xls 格式")],-1))]),_:1}),t(r(D),null,{default:l(()=>[t(r(g),{type:"primary",onClick:G},{icon:l(()=>[t(r(S),null,{default:l(()=>[t(r(fe))]),_:1})]),default:l(()=>[e[18]||(e[18]=f(" 下载模板 ",-1))]),_:1})]),_:1}),t(r(ue),{max:1,accept:".xlsx,.xls","show-file-list":!0,"custom-request":H},{default:l(()=>[t(te,null,{default:l(()=>[w("div",be,[t(r(S),{size:"48",depth:3},{default:l(()=>[t(r(me))]),_:1})]),t(Z,{style:{"font-size":"16px"}},{default:l(()=>[...e[19]||(e[19]=[f("点击或拖拽文件到此处上传",-1)])]),_:1}),t(ee,{depth:"3",style:{margin:"8px 0 0 0"}},{default:l(()=>[...e[20]||(e[20]=[f("支持 .xlsx 或 .xls 格式",-1)])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,["show"])])}}}),Ue=se(_e,[["__scopeId","data-v-2d2b2685"]]);export{Ue as default};
