unis_crm/frontend1/dist/assets/index-Ctgjvmmn.js

2 lines
7.1 KiB
JavaScript

import{u as Y,G as q,r,j as e,z as u,H as w,B as p,c as G,I as J,J as T,K as Q,M as K,N,s as v,A as U,T as W,R as X,O as Z,P as ee,Q as te,U as se,V as ae}from"./index-D2cxrzyv.js";import{d as ne}from"./dayjs.min-DJskcR2o.js";import{l as re,u as le,c as oe,d as ie}from"./tenant-DSFtTF68.js";import{u as ce}from"./useDict-BN4y0n-Y.js";import{P as de}from"./index-DICUnuN_.js";import{F as l}from"./index-KuslyOWx.js";import{C as I}from"./index-BFDbUxK1.js";import{I as o}from"./index-4zw5l6IX.js";import{L as R}from"./index-Du4WDj4j.js";import{R as S,C as h}from"./row-C5EMotZ4.js";import{T as me}from"./index-C8Xnkbw4.js";import{P as pe}from"./index-Dv-9vGc2.js";import"./useForm-CaItC8xb.js";import"./Pagination-lXX40XmA.js";const{Title:xe,Text:j,Paragraph:ue}=W;function Ee(){const{t:s}=Y(),{can:f}=q(),{items:y}=ce("sys_common_status"),[E,g]=r.useState(!1),[P,b]=r.useState(!1),[z,k]=r.useState([]),[_,D]=r.useState(0),[a,i]=r.useState({current:1,size:12,name:"",code:""}),[F,c]=r.useState(!1),[x,C]=r.useState(null),[d]=l.useForm(),m=async(t=a)=>{g(!0);try{const n=await re(t);k(n.records||[]),D(n.total||0)}finally{g(!1)}};r.useEffect(()=>{m()},[a.current,a.size]);const $=()=>{const t={...a,current:1};i(t),m(t)},L=()=>{const t={current:1,size:12,name:"",code:""};i(t),m(t)},M=()=>{C(null),d.resetFields(),d.setFieldsValue({status:1}),c(!0)},O=t=>{C(t),d.setFieldsValue({...t,expireTime:t.expireTime?ne(t.expireTime):null}),c(!0)},V=async t=>{await ie(t),v.success(s("common.success")),m()},B=async()=>{const t=await d.validateFields();b(!0);try{const n={...t,expireTime:t.expireTime?t.expireTime.format("YYYY-MM-DD HH:mm:ss"):null};x?await le(x.id,n):await oe(n),v.success(s("common.success")),c(!1),m()}finally{b(!1)}},A=t=>{const n=y.find(H=>H.itemValue===String(t.status));return e.jsx(R.Item,{children:e.jsxs(I,{hoverable:!0,className:"tenant-card shadow-sm border-0",style:{borderRadius:"12px",overflow:"hidden"},actions:[f("sys_tenant:update")&&e.jsx(te,{title:s("common.edit"),children:e.jsx(se,{onClick:()=>O(t),style:{color:"#1677ff"}},"edit")},"edit-tip"),f("sys_tenant:delete")&&e.jsx(pe,{title:s("tenantsExt.deleteConfirm",{name:t.tenantName}),okText:s("common.confirm"),cancelText:s("common.cancel"),onConfirm:()=>V(t.id),children:e.jsx(ae,{style:{color:"#ff4d4f"}},"delete")},"delete-pop")].filter(Boolean),children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",marginBottom:16},children:[e.jsx(U,{size:48,icon:e.jsx(N,{}),style:{backgroundColor:t.status===1?"#e6f4ff":"#fff1f0",color:t.status===1?"#1677ff":"#ff4d4f",marginRight:12,borderRadius:"8px"}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(xe,{level:5,style:{margin:0,fontSize:"16px"},ellipsis:{tooltip:t.tenantName},children:t.tenantName}),e.jsx(me,{color:t.status===1?"green":"red",style:{margin:0,borderRadius:"4px"},children:n?n.itemLabel:t.status===1?"Enabled":"Disabled"})]}),e.jsxs(j,{type:"secondary",style:{fontSize:"12px"},className:"tabular-nums",children:["CODE: ",t.tenantCode]})]})]}),e.jsx("div",{className:"card-content",style:{fontSize:"13px"},children:e.jsxs(u,{direction:"vertical",size:8,style:{width:"100%"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",color:"#595959"},children:[e.jsx(X,{style:{marginRight:8,color:"#bfbfbf"}}),e.jsx(j,{ellipsis:{tooltip:t.contactName||"-"},children:t.contactName||"-"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",color:"#595959"},children:[e.jsx(Z,{style:{marginRight:8,color:"#bfbfbf"}}),e.jsx(j,{className:"tabular-nums",children:t.contactPhone||"-"})]})]})}),t.remark&&e.jsxs(e.Fragment,{children:[e.jsx(ee,{style:{margin:"12px 0"}}),e.jsx(ue,{ellipsis:{rows:2,tooltip:t.remark},style:{margin:0,fontSize:"12px",color:"#8c8c8c",height:"36px"},children:t.remark})]})]})})};return e.jsxs("div",{className:"app-page",children:[e.jsx(de,{title:s("tenants.title"),subtitle:s("tenants.subtitle")}),e.jsx(I,{className:"app-page__filter-card border-0",style:{borderRadius:"12px"},styles:{body:{padding:"16px"}},children:e.jsxs(u,{wrap:!0,size:"middle",className:"app-page__toolbar",style:{justifyContent:"space-between",width:"100%"},children:[e.jsxs(u,{wrap:!0,size:"middle",className:"app-page__toolbar",children:[e.jsx(o,{placeholder:s("tenants.tenantName"),prefix:e.jsx(w,{"aria-hidden":"true",className:"text-gray-400"}),style:{width:220,borderRadius:"6px"},value:a.name,onChange:t=>i({...a,name:t.target.value}),allowClear:!0}),e.jsx(o,{placeholder:s("tenants.tenantCode"),style:{width:180,borderRadius:"6px"},value:a.code,onChange:t=>i({...a,code:t.target.value}),allowClear:!0}),e.jsx(p,{type:"primary",icon:e.jsx(w,{"aria-hidden":"true"}),onClick:$,style:{borderRadius:"6px"},children:s("common.search")}),e.jsx(p,{icon:e.jsx(G,{"aria-hidden":"true"}),onClick:L,style:{borderRadius:"6px"},children:s("common.reset")})]}),f("sys_tenant:create")&&e.jsx(p,{type:"primary",icon:e.jsx(J,{"aria-hidden":"true"}),onClick:M,style:{borderRadius:"6px"},children:s("common.create")})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto pr-2",children:e.jsx(R,{grid:{gutter:24,xs:1,sm:2,md:2,lg:3,xl:4,xxl:4},loading:E,dataSource:z,renderItem:A,pagination:{total:_,current:a.current,pageSize:a.size,onChange:(t,n)=>i({...a,current:t,size:n||a.size}),showSizeChanger:!0,showQuickJumper:!0,showTotal:t=>s("common.total",{total:t}),pageSizeOptions:["10","20","50","100"],style:{marginTop:"24px",marginBottom:"24px"}},locale:{emptyText:e.jsx(T,{image:T.PRESENTED_IMAGE_SIMPLE,description:s("tenantsExt.emptyText")})}})}),e.jsx(Q,{title:e.jsxs(u,{children:[e.jsx(N,{"aria-hidden":"true"}),e.jsx("span",{children:s(x?"tenants.drawerTitleEdit":"tenants.drawerTitleCreate")})]}),open:F,onClose:()=>c(!1),width:480,destroyOnClose:!0,footer:e.jsxs("div",{className:"app-page__drawer-footer",children:[e.jsx(p,{onClick:()=>c(!1),children:s("common.cancel")}),e.jsx(p,{type:"primary",loading:P,onClick:B,children:s("common.save")})]}),children:e.jsxs(l,{form:d,layout:"vertical",children:[e.jsxs(S,{gutter:16,children:[e.jsx(h,{span:12,children:e.jsx(l.Item,{label:s("tenants.tenantName"),name:"tenantName",rules:[{required:!0,message:s("tenants.tenantName")}],children:e.jsx(o,{placeholder:s("tenantsExt.tenantNamePlaceholder")})})}),e.jsx(h,{span:12,children:e.jsx(l.Item,{label:s("tenants.tenantCode"),name:"tenantCode",rules:[{required:!0,message:s("tenants.tenantCode")}],children:e.jsx(o,{placeholder:s("tenantsExt.tenantCodePlaceholder"),disabled:!!x,className:"tabular-nums"})})})]}),e.jsxs(S,{gutter:16,children:[e.jsx(h,{span:12,children:e.jsx(l.Item,{label:s("tenants.contactName"),name:"contactName",children:e.jsx(o,{placeholder:s("tenantsExt.contactNamePlaceholder")})})}),e.jsx(h,{span:12,children:e.jsx(l.Item,{label:s("tenants.contactPhone"),name:"contactPhone",children:e.jsx(o,{placeholder:s("tenantsExt.contactPhonePlaceholder"),className:"tabular-nums"})})})]}),e.jsx(l.Item,{label:s("common.status"),name:"status",initialValue:1,children:e.jsx(K,{options:y.map(t=>({label:t.itemLabel,value:Number(t.itemValue)}))})}),e.jsx(l.Item,{label:s("common.remark"),name:"remark",children:e.jsx(o.TextArea,{rows:3,placeholder:s("tenantsExt.remarkPlaceholder")})})]})})]})}export{Ee as default};