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

2 lines
6.0 KiB
JavaScript

import{u as M,a2 as Q,r as l,bx as Y,j as e,Y as d,T as G,ab as T,B as i,ac as J,ad as U,a3 as W,a7 as j,a4 as X,a6 as Z,bn as ee,by as ae,bz as se,s as I,bA as te,bB as re}from"./index-CYM97J2V.js";import{u as C}from"./useDict-BjF_A4fe.js";import{P as le}from"./index-B7x062Ky.js";import{g as ie}from"./pagination-63Gtkzif.js";import{F as r}from"./index-CacOxAQN.js";import{T as f}from"./index-DqftVe8j.js";import{P as ne}from"./index-DfhCfAUo.js";import{C as v}from"./index-Bcf8yIZZ.js";import{I as y}from"./index-DV4zjsPW.js";import{F as me}from"./Table-CAs2vM8c.js";import{R as oe,C as _}from"./row-DNGQ3hV2.js";import{S as ce}from"./index-fyGQdrIw.js";import"./useForm-B5uILH8t.js";import"./index-M0Ae7f04.js";import"./Pagination-By0LqcoC.js";const{Text:N}=G;function Ce(){const{t:a}=M(),{can:u}=Q(),{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 Y(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)},A=s=>{S(s),n.setFieldsValue(s),o(!0)},B=async s=>{try{await se(s),I.success(a("common.success")),p()}catch{}},O=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)}},H=[{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:()=>A(t)}),u("sys_param:delete")&&t.isSystem!==1&&e.jsx(ne,{title:a("sysParamsExt.deleteConfirm"),okText:a("common.confirm"),cancelText:a("common.cancel"),onConfirm:()=>B(t.paramId),children:e.jsx(i,{type:"text",danger:!0,icon:e.jsx(U,{})})})]})}];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(W,{}),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(X,{}),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:H,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:O,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{Ce as default};