Files
financial_system_frontend/dist/assets/PaymentMethods-qWcROH8o.js
T

2 lines
6.4 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{d as w,u as O,o as R,c as a,p as S,q as j,b as e,x as y,y as A,M as z,t as p,e as n,F,v as H,P as $,f as D,r,R as Y,B as M,j as o,n as J,A as G,E as I,C as K,J as Q}from"./index-DU2fjqYh.js";import{_ as W,b as x,a as X}from"./business-config-CDFDGnOE.js";const Z={class:"page-content route-list-page prototype-config-page"},ee={class:"card fill-list-card primary-list-card prototype-config-card"},te={class:"prototype-filter-bar"},se={class:"prototype-result-count"},ae={key:0,class:"prototype-loading"},oe={key:1,class:"prototype-error"},le={key:2,class:"table-wrap"},ne={class:"data-table prototype-table"},ie={key:0},de={key:1},re={key:2},ue={key:3},ce={key:0},pe={key:1},ve={key:2},me={key:3},ye=["disabled","onClick"],_e={key:1},ge={key:3,class:"prototype-empty"},be={class:"modal-head","data-dialog-drag-handle":""},fe=["disabled"],he={class:"modal-body"},ke={key:0,class:"prototype-form-error"},Ce={class:"prototype-form-grid"},Ee={class:"field full"},Te=["disabled"],Ve={class:"field full"},Ae=["disabled"],Me={class:"modal-actions"},Ie=["disabled"],xe=["disabled"],De=w({__name:"PaymentMethods",setup(Le){const _=O(),m=r([]),h=r(""),g=r("ALL"),k=r(!1),b=r(""),i=r(!1),v=r(""),C=r(null),f=r(null),u=Y({name:"",description:""}),L=M(()=>_.canEdit("ui.payment-methods.create")&&["name","description"].every(s=>_.canEdit(`dialog.payment-methods.create.${s}`))),B=M(()=>_.canEdit("ui.payment-methods.deactivate")),c=s=>_.canRead(`ui.payment-methods.column.${s}`),E=(s,t)=>s instanceof Error&&s.message?s.message:t,T=M(()=>{const s=h.value.toLocaleLowerCase();return m.value.filter(t=>(g.value==="ALL"||t.status===g.value)&&(!s||[t.code,t.name,t.description].some(d=>String(d||"").toLocaleLowerCase().includes(s)))).sort((t,d)=>t.code.localeCompare(d.code,"zh-CN"))}),N=async()=>{k.value=!0,b.value="";try{m.value=await x.paymentMethods()}catch(s){b.value=E(s,"付款方式加载失败")}finally{k.value=!1}},P=async()=>{var s;Object.assign(u,{name:"",description:""}),v.value="",await G(),(s=f.value)==null||s.showModal()},V=()=>{var s;i.value||(s=f.value)==null||s.close()},U=async()=>{var s;if(!u.name||!u.description)return void(v.value="请完整填写付款方式和适用说明");i.value=!0,v.value="";try{const t=await x.create("payment-methods",{...u});m.value.push(t),(s=f.value)==null||s.close(),I.success("付款方式已新增")}catch(t){v.value=E(t,"保存失败,请稍后重试")}finally{i.value=!1}},q=async s=>{const t=s.status==="ACTIVE"?"INACTIVE":"ACTIVE";try{await K.confirm(`确认${t==="ACTIVE"?"启用":"停用"}“${s.name}”?`,"状态确认",{type:"warning"})}catch{return}C.value=s.id;try{const d=await x.changeStatus("payment-methods",s.id,t);m.value.splice(m.value.findIndex(l=>l.id===s.id),1,d),I.success(`付款方式已${t==="ACTIVE"?"启用":"停用"}`)}catch(d){I.error(E(d,"状态更新失败"))}finally{C.value=null}};return R(()=>{N()}),(s,t)=>{const d=Q("dialog-drag");return o(),a("div",Z,[S(W,{eyebrow:"PAYMENT METHODS",title:"付款方式",description:"维护登记付款时允许选择的方式;停用后不再出现在登记付款表单中。"},{default:j(()=>[L.value?(o(),a("button",{key:0,class:"btn primary",onClick:P}," + 新增付款方式 ")):n("",!0)]),_:1}),t[12]||(t[12]=e("div",{class:"prototype-governance-note"},[e("strong",null,"编码规则"),e("span",null,"付款方式编码由系统在保存时统一生成,无需手工填写。")],-1)),e("section",ee,[e("div",te,[y(e("input",{"onUpdate:modelValue":t[0]||(t[0]=l=>h.value=l),type:"search",placeholder:"搜索付款方式或适用说明"},null,512),[[A,h.value,void 0,{trim:!0}]]),y(e("select",{"onUpdate:modelValue":t[1]||(t[1]=l=>g.value=l)},[...t[4]||(t[4]=[e("option",{value:"ALL"},"全部状态",-1),e("option",{value:"ACTIVE"},"启用",-1),e("option",{value:"INACTIVE"},"停用",-1)])],512),[[z,g.value]]),t[5]||(t[5]=e("span",{class:"prototype-filter-spacer"},null,-1)),e("span",se,"共 "+p(T.value.length)+" 种",1)]),k.value?(o(),a("div",ae,[...t[6]||(t[6]=[e("span",{class:"loader"},null,-1),e("span",null,"正在加载付款方式…",-1)])])):b.value?(o(),a("div",oe,[e("span",null,p(b.value),1),e("button",{class:"btn small",onClick:N},"重试")])):T.value.length?(o(),a("div",le,[e("table",ne,[e("thead",null,[e("tr",null,[c("code")?(o(),a("th",ie,"方式编码")):n("",!0),c("name")?(o(),a("th",de,"付款方式")):n("",!0),c("description")?(o(),a("th",re,"适用说明")):n("",!0),c("status")?(o(),a("th",ue,"状态")):n("",!0),t[7]||(t[7]=e("th",null,"操作",-1))])]),e("tbody",null,[(o(!0),a(F,null,H(T.value,l=>(o(),a("tr",{key:l.id},[c("code")?(o(),a("td",ce,[e("strong",null,p(l.code),1)])):n("",!0),c("name")?(o(),a("td",pe,p(l.name),1)):n("",!0),c("description")?(o(),a("td",ve,p(l.description),1)):n("",!0),c("status")?(o(),a("td",me,[S(X,{active:l.status==="ACTIVE"},null,8,["active"])])):n("",!0),e("td",null,[B.value?(o(),a("button",{key:0,class:J(["prototype-table-action",{danger:l.status==="ACTIVE"}]),disabled:C.value===l.id,onClick:Ne=>q(l)},p(l.status==="ACTIVE"?"停用":"启用"),11,ye)):(o(),a("span",_e,"—"))])]))),128))])])])):(o(),a("div",ge,"没有符合当前筛选条件的付款方式。"))]),L.value?y((o(),a("dialog",{key:0,ref_key:"dialog",ref:f,class:"app-dialog prototype-dialog",onCancel:$(V,["prevent"])},[e("form",{onSubmit:$(U,["prevent"])},[e("div",be,[t[8]||(t[8]=e("div",null,[e("span",{class:"eyebrow"},"PAYMENT METHOD"),e("h2",null,"新增付款方式"),e("p",null,"启用后可在登记付款时选择。")],-1)),e("button",{class:"modal-close",type:"button",disabled:i.value,onClick:V}," × ",8,fe)]),e("div",he,[v.value?(o(),a("p",ke,p(v.value),1)):n("",!0),e("div",Ce,[e("div",Ee,[t[9]||(t[9]=e("label",null,[D("付款方式 "),e("em",null,"*")],-1)),y(e("input",{"onUpdate:modelValue":t[2]||(t[2]=l=>u.name=l),required:"",maxlength:"100",disabled:i.value},null,8,Te),[[A,u.name,void 0,{trim:!0}]])]),e("div",Ve,[t[10]||(t[10]=e("label",null,[D("适用说明 "),e("em",null,"*")],-1)),y(e("textarea",{"onUpdate:modelValue":t[3]||(t[3]=l=>u.description=l),required:"",maxlength:"500",disabled:i.value},null,8,Ae),[[A,u.description,void 0,{trim:!0}]])])]),t[11]||(t[11]=e("div",{class:"prototype-code-note"}," 方式编码保存时自动生成,例如 PM-003。 ",-1))]),e("div",Me,[e("button",{class:"btn",type:"button",disabled:i.value,onClick:V}," 取消",8,Ie),e("button",{class:"btn primary",type:"submit",disabled:i.value},p(i.value?"保存中…":"保存付款方式"),9,xe)])],32)],32)),[[d]]):n("",!0)])}}});export{De as default};