效果:
1. 打开 ruoyi-ui.css 文件,设置样式
// 公共的tag样式
.el-tag-common{
background-color: #ffe5f7;
border-color: #f3b5de;
color: #ea6dc1;
display: inline-flex;
justify-content: center;
align-items: center;
height: 24px;
padding: 0 9px;
font-size: 12px;
line-height: 1;
border-width: 1px;
border-style: solid;
border-radius: 4px;
box-sizing: border-box;
white-space: nowrap;
}
// 自定义颜色
.el-tag-pink {
background-color: #ffe5f7;
border-color: #f3b5de;
color: #ea6dc1;
}
2. 打开若依项目中的 系统管理 - 字典管理 ,找到对应设置的地方
找到对应的数据字典,进入字典数据,给样式属性上加上对应的class名,记得中间有空格。
新增时填写样式属性为 el-tag-common el-tag-pink
3. 在对应的表格页面去实现字典,会根据值匹配加上el-tag-common el-tag-pink
样式生效。
对应页面:
······
<el-table-column label="状态" align="center" prop="status" min-width="80">
<template #default="scope">
<dict-tag :options="purchase_order_status" :value="scope.row.status" />
</template>
</el-table-column>
······
const { purchase_order_status } = proxy.useDict("purchase_order_status");