2 lines
6.1 KiB
JavaScript
2 lines
6.1 KiB
JavaScript
import{u as B,G as M,r as l,aN as G,j as e,z as d,T as U,Q as T,B as i,U as J,V as W,H as X,M as j,I as Y,K as Z,aD as ee,aO as ae,aP as se,s as I,aQ as te,aR as re}from"./index-BGI3tmtB.js";import{u as C}from"./useDict-BeEL9edl.js";import{P as le}from"./index-xsV5o4zp.js";import{g as ie}from"./pagination-CLXPzAaG.js";import{F as r}from"./index-BuOmEnKg.js";import{T as f}from"./index-bzjak6Z4.js";import{P as ne}from"./index-D6NeKG5r.js";import{C as v}from"./index-DxgbQv5l.js";import{I as y}from"./index-FqFqpoYX.js";import{F as me}from"./Table-BewG91sh.js";import{R as oe,C as _}from"./row-C3H8lbGw.js";import{S as ce}from"./index-jz-iTrQo.js";import"./useForm-BpWJqkw6.js";import"./iconUtil-IZQuqZwd.js";import"./index-DUXqiKOh.js";import"./index-DJxTfCUX.js";import"./Pagination-COOq01L8.js";const{Text:N}=U;function _e(){const{t:a}=B(),{can:u}=M(),{items:g}=C("sys_common_status"),{items:P}=C("sys_param_type"),[V,b]=l.useState(!1),[k,w]=l.useState(!1),[E,F]=l.useState([]),[K,R]=l.useState(0),[m,x]=l.useState({pageNum:1,pageSize:10}),[D,o]=l.useState(!1),[c,S]=l.useState(null),[n]=r.useForm(),p=l.useCallback(async(s=m)=>{b(!0);try{const t=await G(s);F(t.records||[]),R(t.total||0)}finally{b(!1)}},[m]);l.useEffect(()=>{p()},[p]);const z=s=>{x({...m,...s,pageNum:1})},L=()=>{n.resetFields(),x({pageNum:1,pageSize:10})},$=(s,t)=>{x(h=>({...h,pageNum:s,pageSize:t}))},q=()=>{S(null),n.resetFields(),n.setFieldsValue({isSystem:0,status:1}),o(!0)},O=s=>{S(s),n.setFieldsValue(s),o(!0)},H=async s=>{try{await se(s),I.success(a("common.success")),p()}catch{}},Q=async()=>{try{const s=await n.validateFields();w(!0),c?await te(c.paramId,s):await re(s),I.success(a("common.success")),o(!1),p()}finally{w(!1)}},A=[{title:a("sysParams.paramKey"),dataIndex:"paramKey",key:"paramKey",render:(s,t)=>e.jsxs(d,{direction:"vertical",size:0,children:[e.jsx(N,{className:"param-key-text",children:s}),t.isSystem===1&&e.jsx(f,{color:"orange",style:{fontSize:10,marginTop:2,padding:"0 4px"},children:a("sysParams.isSystem")})]})},{title:a("sysParams.paramValue"),dataIndex:"paramValue",key:"paramValue",ellipsis:!0,render:s=>e.jsx(T,{title:s,children:e.jsx(N,{code:!0,children:s})})},{title:a("sysParams.paramType"),dataIndex:"paramType",key:"paramType",width:120,render:s=>e.jsx(f,{className:"param-type-tag",children:s||a("sysParamsExt.defaultType")})},{title:a("sysParams.description"),dataIndex:"description",key:"description",ellipsis:!0},{title:a("common.status"),dataIndex:"status",width:80,render:s=>{const t=g.find(h=>h.itemValue===String(s));return e.jsx(f,{color:s===1?"green":"red",children:t?t.itemLabel:a(s===1?"sysParamsExt.enabled":"sysParamsExt.disabled")})}},{title:a("common.action"),key:"action",width:110,fixed:"right",render:(s,t)=>e.jsxs(d,{children:[u("sys_param:update")&&e.jsx(i,{type:"text",icon:e.jsx(J,{}),onClick:()=>O(t)}),u("sys_param:delete")&&t.isSystem!==1&&e.jsx(ne,{title:a("sysParamsExt.deleteConfirm"),okText:a("common.confirm"),cancelText:a("common.cancel"),onConfirm:()=>H(t.paramId),children:e.jsx(i,{type:"text",danger:!0,icon:e.jsx(W,{})})})]})}];return e.jsxs("div",{className:"app-page sys-params-page",children:[e.jsx(le,{title:a("sysParams.title"),subtitle:a("sysParams.subtitle")}),e.jsx(v,{className:"sys-params-table-card app-page__filter-card",styles:{body:{padding:"16px"}},children:e.jsxs("div",{className:"app-page__toolbar",style:{justifyContent:"space-between",width:"100%"},children:[e.jsxs(r,{layout:"inline",onFinish:z,className:"app-page__toolbar",children:[e.jsx(r.Item,{name:"paramKey",children:e.jsx(y,{placeholder:a("sysParams.paramKey"),prefix:e.jsx(X,{}),allowClear:!0,style:{width:200}})}),e.jsx(r.Item,{name:"paramType",children:e.jsx(j,{placeholder:a("sysParams.paramType"),allowClear:!0,style:{width:150},options:P.map(s=>({label:s.itemLabel,value:s.itemValue}))})}),e.jsx(r.Item,{children:e.jsxs(d,{children:[e.jsx(i,{type:"primary",htmlType:"submit",children:a("common.search")}),e.jsx(i,{onClick:L,children:a("common.reset")})]})})]}),u("sys_param:create")&&e.jsx(i,{type:"primary",icon:e.jsx(Y,{}),onClick:q,children:a("common.create")})]})}),e.jsx(v,{className:"app-page__content-card flex-1 flex flex-col overflow-hidden",styles:{body:{padding:0,flex:1,display:"flex",flexDirection:"column",overflow:"hidden"}},children:e.jsx(me,{rowKey:"paramId",columns:A,dataSource:E,loading:V,size:"middle",scroll:{y:"calc(100vh - 350px)"},pagination:ie(K,m.pageNum||1,m.pageSize||10,$)})}),e.jsx(Z,{title:e.jsxs("span",{children:[e.jsx(ae,{className:"mr-2"}),a(c?"sysParams.drawerTitleEdit":"sysParams.drawerTitleCreate")]}),open:D,onClose:()=>o(!1),width:500,destroyOnClose:!0,footer:e.jsxs("div",{className:"app-page__drawer-footer",children:[e.jsx(i,{onClick:()=>o(!1),children:a("common.cancel")}),e.jsx(i,{type:"primary",loading:k,onClick:Q,children:a("common.save")})]}),children:e.jsxs(r,{form:n,layout:"vertical",children:[e.jsx(r.Item,{label:a("sysParams.paramKey"),name:"paramKey",rules:[{required:!0,message:a("sysParams.paramKey")}],children:e.jsx(y,{placeholder:a("sysParamsExt.paramKeyPlaceholder"),disabled:!!c})}),e.jsx(r.Item,{label:a("sysParams.paramValue"),name:"paramValue",rules:[{required:!0,message:a("sysParams.paramValue")}],children:e.jsx(y.TextArea,{rows:4,placeholder:a("sysParamsExt.paramValuePlaceholder")})}),e.jsxs(oe,{gutter:16,children:[e.jsx(_,{span:12,children:e.jsx(r.Item,{label:a("sysParams.paramType"),name:"paramType",rules:[{required:!0,message:a("sysParams.paramType")}],children:e.jsx(j,{options:P.map(s=>({label:s.itemLabel,value:s.itemValue}))})})}),e.jsx(_,{span:12,children:e.jsx(r.Item,{label:a("common.status"),name:"status",initialValue:1,children:e.jsx(j,{options:g.map(s=>({label:s.itemLabel,value:Number(s.itemValue)}))})})})]}),e.jsx(r.Item,{label:e.jsxs(d,{children:[a("sysParams.isSystem"),e.jsx(T,{title:a("sysParamsExt.systemHint"),children:e.jsx(ee,{style:{color:"#8c8c8c"}})})]}),name:"isSystem",valuePropName:"checked",getValueProps:s=>({checked:s===1}),getValueFromEvent:s=>s?1:0,children:e.jsx(ce,{})}),e.jsx(r.Item,{label:a("sysParams.description"),name:"description",children:e.jsx(y.TextArea,{rows:3,placeholder:a("sysParamsExt.descriptionPlaceholder")})})]})})]})}export{_e as default};
|