2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
|
|
import{d as oe,o as ue,b as x,e as m,m as a,z as o,p as C,U as se,x as ne,s as de,y as g,r as d,C as i,T as ie,g as v,j as r,F as T,h as F,t as U,k as B,V as re,W as me,f as ve,X as ce,J as V,_ as pe}from"./index-eVF4AHSu.js";import{a as fe,f as ge,b as Ve,e as ye,g as _e,h as be}from"./product-B3Fr265h.js";import{r as we}from"./media-BgGGvhcR.js";import{R as he}from"./RichEditor-DD1hYfzj.js";import{M as Ze}from"./MediaSelector-DyRQc9ag.js";import"./pagination-BgSlm-mj.js";import"./upload-C79x1DTb.js";const xe={class:"product-manage"},Ce={class:"page-header"},Ue={class:"filter-bar"},ke={key:1,class:"table-thumb-placeholder"},Pe={class:"pagination-bar"},ze={class:"dialog-row"},Me={class:"dialog-row"},Se={class:"dialog-row"},Ee={class:"dialog-row"},Ie={class:"dialog-row"},Ne={class:"dialog-row"},$e={class:"dialog-row"},Re={class:"dialog-row"},Be=oe({__name:"ProductManage",setup(He){const k=d(!1),H=d([]),b=d([]),L=d(0),P=d(1),z=d(20),M=d(void 0),S=d(void 0),E=d(""),y=d(!1),I=d("新增产品"),w=d(null),N=d(!1),t=d({categoryId:0,nameZh:"",nameEn:"",code:"",mainImage:"",summaryZh:"",summaryEn:"",descriptionZh:"",descriptionEn:"",sizeZh:"",materialZh:"",priceMin:null,priceMax:null,isShowPrice:0,isHot:0,isNew:0,isRecommend:0,status:1,sortOrder:0}),D=ve(()=>{const u=[];for(const e of b.value)if(u.push({id:e.id,nameZh:e.nameZh,prefix:""}),e.children)for(const n of e.children)u.push({id:n.id,nameZh:n.nameZh,prefix:" "});return u});async function c(){k.value=!0;try{const u=await fe({categoryId:M.value,status:S.value,keyword:E.value||void 0,page:P.value,size:z.value});H.value=u.records,L.value=u.total}catch(u){console.warn("fetchProductList failed:",u)}finally{k.value=!1}}async function K(){try{b.value=await ge()}catch{}}ue(()=>{K(),c()});function q(){var u;w.value=null,I.value="新增产品",t.value={categoryId:((u=b.value[0])==null?void 0:u.id)??0,nameZh:"",nameEn:"",code:"",mainImage:"",summaryZh:"",summaryEn:"",status:1,sortOrder:0,isHot:0,isNew:0,isRecommend:0,isShowPrice:0},y.value=!0}function j(u){w.value=u.id,I.value="编辑产品",t.value={...u},y.value=!0}async function A(u){try{await ce.confirm(`确定删除产品「${u.nameZh}」?`,"确认删除",{type:"warning"}),await Ve(u.id),V.success("删除成功"),await c()}catch{}}async function G(u){const e=u.status===1?0:1;try{await ye(u.id,e),u.status=e,V.success(e===1?"已上架":"已下架")}catch{V.error("操作失败")}}async function J(){if(!t.value.nameZh||!t.value.categoryId){V.warning("请填写产品名称和分类");return}N.value=!0;try{w.value?(await _e(w.value,t.value),V.success("更新成功")):(await be(t.value),V.success("创建成功")),y.value=!1,await c()}catch(u){V.error(u instanceof Error?u.message:"操作失败")}finally{N.value=!1}}function W(u){for(const e of b.value){if(e.id===u)return e.nameZh;if(e.children){for(const n of e.children)if(n.id===u)return`${e.nameZh} / ${n.nameZh}`}}return String(u)}function X(u,e){return!u&&!e?"面议":u===e?`¥${u}`:`¥${u??""} - ¥${e??""}`}return(u,e)=>{const n=i("el-button"),h=i("el-option"),$=i("el-select"),p=i("el-input"),Q=i("el-image"),f=i("el-table-column"),Z=i("el-tag"),Y=i("el-table"),ee=i("el-pagination"),s=i("el-form-item"),R=i("el-input-number"),_=i("el-switch"),le=i("el-form"),ae=i("el-dialog"),te=ie("loading");return v(),x("div",xe,[m("div",Ce,[e[26]||(e[26]=m("h2",{class:"page-title"},"产品管理",-1)),a(n,{type:"primary",icon:C(se),onClick:q},{default:o(()=>[...e[25]||(e[25]=[r("新增产品",-1)])]),_:1},8,["icon"])]),m("div",Ue,[a($,{modelValue:M.value,"onUpdate:modelValue":e[0]||(e[0]=l=>M.value=l),placeholder:"选择分类",clearable:"",onChange:c,style:{width:"180px"}},{default:o(()=>[(v(!0),x(T,null,F(D.value,l=>(v(),g(h,{key:l.id,label:l.prefix+l.nameZh,value:l.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),a($,{modelValue:S.value,"onUpdate:modelValue":e[1]||(e[1]=l=>S.value=l),placeholder:"状态",clearable:"",onChange:c,style:{width:"120px"}},{default:o(()=>[a(h,{label:"上架",value:1}),a(h,{label:"下架",value:0})]),_:1},8,["modelValue"]),a(p,{modelValue:E.value,"onUp
|