import{t as e}from"./badge-C6DVGO8T.js";import{o as t,r as n}from"./XinForm-DX04WSwD.js";import{t as r}from"./tag-Bn-IyYw0.js";import{Ca as i,Cn as a,Ea as o,Lt as s,ba as c,c as l,gn as u,hn as d,rt as f,s as p,xa as m}from"./index-DThTpSPU.js";import{t as h}from"./XinTable-D_6_7i3V.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`}],_=o(i(),1),v=o(d(),1),y=p();function b(){let{t:i}=l(),o=c(),[d]=m(),p=d.get(`dictId`),b=d.get(`dictName`)||``,x=d.get(`dictCode`)||``,[S,C]=(0,_.useState)({id:p?parseInt(p):0,name:decodeURIComponent(b),code:x});(0,_.useEffect)(()=>{p&&C({id:parseInt(p),name:decodeURIComponent(b),code:x})},[p,b,x]);let w=[{title:i(`system.system.dict.item.id`),dataIndex:`id`,hideInForm:!0,width:80,align:`center`},{title:i(`system.system.dict.item.label`),dataIndex:`label`,valueType:`text`,rules:[{required:!0,message:i(`system.system.dict.item.label.required`)}]},{title:i(`system.system.dict.item.value`),dataIndex:`value`,valueType:`text`,rules:[{required:!0,message:i(`system.system.dict.item.value.required`)}]},{title:i(`system.system.dict.item.color`),dataIndex:`color`,valueType:`select`,colProps:{span:12},initialValue:`default`,fieldProps:{options:g.map(e=>({label:(0,y.jsx)(r,{color:e.value,children:e.label}),value:e.value}))},render:e=>(0,y.jsx)(r,{color:e,children:g.find(t=>t.value===e)?.label||e})},{title:i(`system.system.dict.item.isDefault`),dataIndex:`is_default`,valueType:`select`,colProps:{span:12},initialValue:0,rules:[{required:!0,message:i(`system.system.dict.item.isDefault.required`)}],fieldProps:{options:[{label:i(`system.system.dict.item.isDefault.yes`),value:1},{label:i(`system.system.dict.item.isDefault.no`),value:0}]},render:e=>e===1?(0,y.jsx)(r,{color:`blue`,children:i(`system.system.dict.item.isDefault.yes`)}):i(`system.system.dict.item.isDefault.no`)},{title:i(`system.system.dict.item.sort`),dataIndex:`sort`,valueType:`digit`,colProps:{span:12},hideInSearch:!0,initialValue:0,fieldProps:{min:0,style:{width:`100%`}}},{title:i(`system.system.dict.item.status`),dataIndex:`status`,valueType:`select`,colProps:{span:12},initialValue:0,rules:[{required:!0,message:i(`system.system.dict.item.status.required`)}],fieldProps:{options:[{label:i(`system.system.dict.item.status.normal`),value:0},{label:i(`system.system.dict.item.status.disabled`),value:1}]},render:t=>t===0?(0,y.jsx)(e,{status:`success`,text:i(`system.system.dict.item.status.normal`)}):(0,y.jsx)(e,{status:`error`,text:i(`system.system.dict.item.status.disabled`)})},{title:i(`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)(s,{orientation:`vertical`,style:{width:`100%`},children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(u,{type:`link`,onClick:()=>{o(`/system/dict`)},icon:(0,y.jsx)(a,{}),classNames:{root:`p-0 mb-2`},children:i(`system.dict.backToList`)}),(0,y.jsxs)(f.Title,{level:3,children:[(0,y.jsxs)(`span`,{className:`mr-2`,children:[i(`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(e,r,a,o)=>(r===`create`?(await n(`/system/dict/item`,{...e,dict_id:S.id}),window.$message?.success(i(`system.dict.item.createSuccess`))):(await t(`/system/dict/item/`+o?.id,{...e,dict_id:S.id}),window.$message?.success(i(`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:i(`system.dict.selectDictFirst`)})})}export{b as default};