2 lines
8.9 KiB
JavaScript
2 lines
8.9 KiB
JavaScript
import{u as ne,a2 as oe,r as c,j as e,Y as p,B as d,a3 as me,ac as z,ad as F,a4 as R,c9 as L,T as pe,a5 as ue,ca as $,a6 as O,ae as xe,a7 as ye,s as f}from"./index-Dv-rJwbZ.js";import{u as he,f as fe,a as je,d as Ie,b as Te,c as we,e as be,g as ge,h as Ce}from"./useDict-ClxJHHDi.js";import{P as Ne}from"./index-D4i8Uis-.js";import{g as ve}from"./pagination-CboDhqDt.js";import{F as r}from"./index-DmVlNV9v.js";import{R as Se,C as q}from"./row-NVxLItiq.js";import{C as A}from"./index-EoMRal4G.js";import{I as o}from"./index-DFGcC-dW.js";import{F as K}from"./Table-BD43FaLh.js";import{P as B}from"./index-5rm_zQK_.js";import{T as Ee}from"./index-BymHESMU.js";import"./useForm-43P2UNGc.js";import"./index-58fJYkx8.js";import"./Pagination-xbf267Yj.js";const{Text:ke}=pe;function He(){const{t}=ne(),{can:m}=oe(),{items:N}=he("sys_common_status"),[H,M]=c.useState([]),[Y,v]=c.useState([]),[i,T]=c.useState(null),[G,S]=c.useState(!1),[J,E]=c.useState(!1),[Q,U]=c.useState(0),[n,w]=c.useState({current:1,size:10,typeCode:"",typeName:""}),[b,k]=c.useState(""),[W,u]=c.useState(!1),[j,D]=c.useState(null),[I]=r.useForm(),[X,x]=c.useState(!1),[g,P]=c.useState(null),[y]=r.useForm(),h=c.useCallback(async(s=n)=>{var a;S(!0);try{const l=await fe(s);if(M(l.records||[]),U(l.total||0),(a=l.records)!=null&&a.length&&!i)T(l.records[0]);else if(i){const V=l.records.find(de=>de.dictTypeId===i.dictTypeId);V&&T(V)}}finally{S(!1)}},[i,n]),C=async s=>{E(!0);try{const a=await je(s);v(a||[])}finally{E(!1)}};c.useEffect(()=>{h()},[n.current,n.size]),c.useEffect(()=>{i?C(i.typeCode):v([])},[i]);const Z=()=>{D(null),I.resetFields(),u(!0)},ee=s=>{D(s),I.setFieldsValue(s),u(!0)},te=async s=>{await Ie(s),f.success(t("common.success")),h()},se=async()=>{const s=await I.validateFields();j?await Te(j.dictTypeId,s):await we(s),f.success(t("common.success")),u(!1),h()},_=s=>{const a={...n,current:1,typeName:s};w(a),h(a)},ae=()=>{k("");const s={...n,current:1,typeName:""};w(s),h(s)},ie=()=>{if(!i){f.warning(t("dicts.selectType"));return}P(null),y.resetFields(),y.setFieldsValue({typeCode:i.typeCode,sortOrder:0,status:1}),x(!0)},le=s=>{P(s),y.setFieldsValue(s),x(!0)},ce=async s=>{await be(s),f.success(t("common.success")),i&&C(i.typeCode)},re=async()=>{const s=await y.validateFields();g?await ge(g.dictItemId,s):await Ce(s),f.success(t("common.success")),x(!1),i&&C(i.typeCode)};return e.jsxs("div",{className:"app-page dictionaries-page",children:[e.jsx(Ne,{title:t("dicts.title"),subtitle:t("dicts.subtitle")}),e.jsxs(Se,{gutter:24,className:"flex-1 min-h-0 overflow-hidden",children:[e.jsx(q,{span:8,className:"h-full flex flex-col overflow-hidden",children:e.jsxs(A,{title:e.jsxs(p,{children:[e.jsx(L,{"aria-hidden":"true"}),e.jsx("span",{children:t("dicts.dictType")})]}),className:"app-page__panel-card flex-1 flex flex-col overflow-hidden",styles:{body:{padding:"12px",flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}},extra:m("sys_dict:type:create")&&e.jsx(d,{type:"primary",size:"small",icon:e.jsx(R,{"aria-hidden":"true"}),onClick:Z,children:t("common.create")}),children:[e.jsx("div",{style:{marginBottom:12},className:"flex-shrink-0",children:e.jsxs(p.Compact,{style:{width:"100%"},children:[e.jsx(o,{placeholder:t("dictsExt.searchTypes"),allowClear:!0,value:b,onChange:s=>k(s.target.value),onPressEnter:()=>_(b)}),e.jsx(d,{type:"primary",icon:e.jsx(me,{"aria-hidden":"true"}),onClick:()=>_(b),children:t("common.search")}),e.jsx(d,{onClick:ae,children:t("common.reset")})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(K,{rowKey:"dictTypeId",loading:G,dataSource:H,pagination:{...ve(Q,n.current,n.size,(s,a)=>w({...n,current:s,size:a})),simple:!0,size:"small",position:["bottomCenter"]},size:"small",showHeader:!1,scroll:{y:"calc(100vh - 480px)"},onRow:s=>({onClick:()=>T(s),className:`cursor-pointer dict-type-row ${(i==null?void 0:i.dictTypeId)===s.dictTypeId?"dict-type-row-selected":""}`}),columns:[{render:(s,a)=>e.jsxs("div",{className:"dict-type-item flex justify-between items-center p-1",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"dict-type-name font-medium truncate",style:{fontSize:"14px"},children:a.typeName}),e.jsx("div",{className:"dict-type-code text-xs text-gray-400 truncate tabular-nums",children:a.typeCode})]}),e.jsxs("div",{className:"dict-type-actions flex gap-1",children:[m("sys_dict:type:update")&&e.jsx(d,{type:"text",size:"small",icon:e.jsx(z,{"aria-hidden":"true",style:{fontSize:"12px"}}),onClick:l=>{l.stopPropagation(),ee(a)}}),m("sys_dict:type:delete")&&e.jsx(B,{title:t("dictsExt.deleteType",{name:a.typeName}),okText:t("common.confirm"),cancelText:t("common.cancel"),onConfirm:l=>{l==null||l.stopPropagation(),te(a.dictTypeId)},children:e.jsx(d,{type:"text",size:"small",danger:!0,icon:e.jsx(F,{"aria-hidden":"true",style:{fontSize:"12px"}}),onClick:l=>l.stopPropagation()})})]})]})}]})})]})}),e.jsx(q,{span:16,className:"h-full flex flex-col overflow-hidden",children:e.jsx(A,{title:e.jsxs(p,{children:[e.jsx($,{"aria-hidden":"true"}),e.jsxs("span",{children:[t("dicts.dictItem"),i?` - ${i.typeName}`:""]})]}),className:"app-page__panel-card flex-1 flex flex-col overflow-hidden",styles:{body:{padding:0,flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}},extra:m("sys_dict:item:create")&&e.jsx(d,{type:"primary",size:"small",icon:e.jsx(R,{"aria-hidden":"true"}),onClick:ie,disabled:!i,children:t("common.create")}),children:i?e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(K,{rowKey:"dictItemId",loading:J,dataSource:Y,pagination:!1,size:"middle",scroll:{y:"calc(100vh - 320px)"},columns:[{title:t("dicts.itemLabel"),dataIndex:"itemLabel",render:s=>e.jsx(ke,{strong:!0,children:s})},{title:t("dicts.itemValue"),dataIndex:"itemValue",className:"tabular-nums"},{title:t("dicts.sort"),dataIndex:"sortOrder",width:80,className:"tabular-nums"},{title:t("common.status"),dataIndex:"status",width:100,render:s=>{const a=N.find(l=>l.itemValue===String(s));return e.jsx(Ee,{color:s===1?"green":"red",children:a?a.itemLabel:t(s===1?"dictsExt.enabled":"dictsExt.disabled")})}},{title:t("common.action"),width:120,fixed:"right",render:(s,a)=>e.jsxs(p,{children:[m("sys_dict:item:update")&&e.jsx(d,{type:"text",size:"small",icon:e.jsx(z,{"aria-hidden":"true"}),onClick:()=>le(a),"aria-label":t("common.edit")}),m("sys_dict:item:delete")&&e.jsx(B,{title:t("dictsExt.deleteItem",{name:a.itemLabel}),okText:t("common.confirm"),cancelText:t("common.cancel"),onConfirm:()=>ce(a.dictItemId),children:e.jsx(d,{type:"text",size:"small",danger:!0,icon:e.jsx(F,{"aria-hidden":"true"}),"aria-label":t("common.delete")})})]})}]})}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(ue,{description:t("dicts.selectType")})})})})]}),e.jsx(O,{title:e.jsxs(p,{children:[e.jsx(L,{"aria-hidden":"true"}),e.jsx("span",{children:t(j?"dicts.drawerTitleTypeEdit":"dicts.drawerTitleTypeCreate")})]}),open:W,onClose:()=>u(!1),width:400,destroyOnClose:!0,footer:e.jsxs("div",{className:"app-page__drawer-footer",children:[e.jsx(d,{onClick:()=>u(!1),children:t("common.cancel")}),e.jsx(d,{type:"primary",onClick:se,children:t("common.save")})]}),children:e.jsxs(r,{form:I,layout:"vertical",children:[e.jsx(r.Item,{label:t("dicts.typeCode"),name:"typeCode",rules:[{required:!0,message:t("dicts.typeCode")}],children:e.jsx(o,{disabled:!!j,placeholder:t("dictsExt.typeCodePlaceholder")})}),e.jsx(r.Item,{label:t("dicts.typeName"),name:"typeName",rules:[{required:!0,message:t("dicts.typeName")}],children:e.jsx(o,{placeholder:t("dictsExt.typeNamePlaceholder")})}),e.jsx(r.Item,{label:t("common.remark"),name:"remark",children:e.jsx(o.TextArea,{placeholder:t("dictsExt.typeRemarkPlaceholder"),rows:3})})]})}),e.jsx(O,{title:e.jsxs(p,{children:[e.jsx($,{"aria-hidden":"true"}),e.jsx("span",{children:t(g?"dicts.drawerTitleItemEdit":"dicts.drawerTitleItemCreate")})]}),open:X,onClose:()=>x(!1),width:400,destroyOnClose:!0,footer:e.jsxs("div",{className:"app-page__drawer-footer",children:[e.jsx(d,{onClick:()=>x(!1),children:t("common.cancel")}),e.jsx(d,{type:"primary",onClick:re,children:t("common.save")})]}),children:e.jsxs(r,{form:y,layout:"vertical",children:[e.jsx(r.Item,{label:t("dicts.typeCode"),name:"typeCode",children:e.jsx(o,{disabled:!0,className:"tabular-nums"})}),e.jsx(r.Item,{label:t("dicts.itemLabel"),name:"itemLabel",rules:[{required:!0,message:t("dicts.itemLabel")}],children:e.jsx(o,{placeholder:t("dictsExt.itemLabelPlaceholder")})}),e.jsx(r.Item,{label:t("dicts.itemValue"),name:"itemValue",rules:[{required:!0,message:t("dicts.itemValue")}],children:e.jsx(o,{placeholder:t("dictsExt.itemValuePlaceholder"),className:"tabular-nums"})}),e.jsx(r.Item,{label:t("dicts.sort"),name:"sortOrder",initialValue:0,children:e.jsx(xe,{className:"w-full tabular-nums"})}),e.jsx(r.Item,{label:t("common.status"),name:"status",initialValue:1,children:e.jsx(ye,{options:N.map(s=>({label:s.itemLabel,value:Number(s.itemValue)}))})}),e.jsx(r.Item,{label:t("common.remark"),name:"remark",children:e.jsx(o.TextArea,{placeholder:t("dictsExt.itemRemarkPlaceholder"),rows:3})})]})})]})}export{He as default};
|