import{Or as e,Tr as t,t as n}from"./jsx-runtime-NwRKtVrk.js";import{t as r}from"./button-CM-rzMOH.js";import{t as i}from"./space-Dvitgohy.js";import{t as a}from"./badge-BLoxw4wl.js";import{n as o}from"./BarsOutlined-UcCNWNvv.js";import{i as s,s as c}from"./XinForm-ihfVpzb6.js";import{t as l}from"./tag-C0Yg14A-.js";import{D as u,at as d,h as f,it as p,s as m}from"./index-B7MUL4ct.js";import{t as h}from"./XinTable-Cyzgse09.js";var g=[{label:`默认`,value:`default`},{label:`蓝色`,value:`blue`},{label:`绿色`,value:`green`},{label:`红色`,value:`red`},{label:`橙色`,value:`orange`},{label:`紫色`,value:`purple`},{label:`青色`,value:`cyan`},{label:`金色`,value:`gold`},{label:`绿黄色`,value:`lime`},{label:`极客蓝`,value:`geekblue`},{label:`品红`,value:`magenta`},{label:`火山红`,value:`volcano`}],_=e(t(),1),v=e(u(),1),y=n();function b(){let{t:e}=m(),t=p(),[n]=d(),u=n.get(`dictId`),b=n.get(`dictName`)||``,x=n.get(`dictCode`)||``,[S,C]=(0,_.useState)({id:u?parseInt(u):0,name:decodeURIComponent(b),code:x});(0,_.useEffect)(()=>{u&&C({id:parseInt(u),name:decodeURIComponent(b),code:x})},[u,b,x]);let w=[{title:e(`system.system.dict.item.id`),dataIndex:`id`,hideInForm:!0,width:80,align:`center`},{title:e(`system.system.dict.item.label`),dataIndex:`label`,valueType:`text`,rules:[{required:!0,message:e(`system.system.dict.item.label.required`)}]},{title:e(`system.system.dict.item.value`),dataIndex:`value`,valueType:`text`,rules:[{required:!0,message:e(`system.system.dict.item.value.required`)}]},{title:e(`system.system.dict.item.color`),dataIndex:`color`,valueType:`select`,colProps:{span:12},initialValue:`default`,fieldProps:{options:g.map(e=>({label:(0,y.jsx)(l,{color:e.value,children:e.label}),value:e.value}))},render:e=>(0,y.jsx)(l,{color:e,children:g.find(t=>t.value===e)?.label||e})},{title:e(`system.system.dict.item.isDefault`),dataIndex:`is_default`,valueType:`select`,colProps:{span:12},initialValue:0,rules:[{required:!0,message:e(`system.system.dict.item.isDefault.required`)}],fieldProps:{options:[{label:e(`system.system.dict.item.isDefault.yes`),value:1},{label:e(`system.system.dict.item.isDefault.no`),value:0}]},render:t=>t===1?(0,y.jsx)(l,{color:`blue`,children:e(`system.system.dict.item.isDefault.yes`)}):e(`system.system.dict.item.isDefault.no`)},{title:e(`system.system.dict.item.sort`),dataIndex:`sort`,valueType:`digit`,colProps:{span:12},hideInSearch:!0,initialValue:0,fieldProps:{min:0,style:{width:`100%`}}},{title:e(`system.system.dict.item.status`),dataIndex:`status`,valueType:`select`,colProps:{span:12},initialValue:0,rules:[{required:!0,message:e(`system.system.dict.item.status.required`)}],fieldProps:{options:[{label:e(`system.system.dict.item.status.normal`),value:0},{label:e(`system.system.dict.item.status.disabled`),value:1}]},render:t=>t===0?(0,y.jsx)(a,{status:`success`,text:e(`system.system.dict.item.status.normal`)}):(0,y.jsx)(a,{status:`error`,text:e(`system.system.dict.item.status.disabled`)})},{title:e(`system.system.dict.item.createTime`),dataIndex:`created_at`,render:e=>e?(0,v.default)(e).format(`YYYY-MM-DD HH:mm`):`-`,hideInForm:!0,hideInSearch:!0,width:160}];return S.id?(0,y.jsxs)(i,{orientation:`vertical`,style:{width:`100%`},children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(r,{type:`link`,onClick:()=>{t(`/system/dict`)},icon:(0,y.jsx)(o,{}),classNames:{root:`p-0 mb-2`},children:e(`system.dict.backToList`)}),(0,y.jsxs)(f.Title,{level:3,children:[(0,y.jsxs)(`span`,{className:`mr-2`,children:[e(`system.dict.itemManagement`),` - `,S.name]}),(0,y.jsx)(f.Text,{type:`secondary`,children:S.code})]})]}),(0,y.jsx)(h,{api:`/system/dict/item`,columns:w,rowKey:`id`,accessName:`system.dict.item`,formProps:{grid:!0,colProps:{span:12},layout:`vertical`,rowProps:{gutter:[30,0]}},modalProps:{width:600},requestParams:e=>({...e,dict_id:S.id}),searchShow:!1,handleFinish:async(t,n,r,i)=>(n===`create`?(await s(`/system/dict/item`,{...t,dict_id:S.id}),window.$message?.success(e(`system.dict.item.createSuccess`))):(await c(`/system/dict/item/`+i?.id,{...t,dict_id:S.id}),window.$message?.success(e(`system.dict.item.updateSuccess`))),!0)})]}):(0,y.jsx)(`div`,{style:{padding:50,textAlign:`center`},children:(0,y.jsx)(`div`,{style:{marginTop:50,color:`#999`},children:e(`system.dict.selectDictFirst`)})})}export{b as default};