【更新】支持字典设定颜色

This commit is contained in:
CyberShen123 2025-10-18 10:23:40 +08:00
parent 080005805a
commit 1026bd4e7a
2 changed files with 18 additions and 4 deletions

View File

@ -36,6 +36,13 @@
:disabled="formData.parentId === '0'"
/>
</a-form-item>
<a-form-item label="字典颜色:" name="dictColor">
<a-select v-model:value="formData.dictColor" placeholder="请选择字典颜色" allow-clear>
<a-select-option v-for="item in dictColorList" :key="item" :value="item">
<a-tag :color="item">{{ item }}</a-tag>
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="排序:" name="sortCode">
<a-input-number class="xn-wd" v-model:value="formData.sortCode" :max="1000" />
</a-form-item>
@ -63,6 +70,9 @@
// ()
const defaultExpandedKeys = ref([0])
//
const dictColorList = ['default','pink', 'red', 'orange', 'green', 'cyan', 'blue', 'purple','gold','geekblue','volcano','magenta','processing','success','error','warning']
//
const onOpen = (record, type, parentId) => {
visible.value = true
@ -100,6 +110,7 @@
const formRules = {
dictLabel: [required('请输入字典名称')],
dictValue: [required('请选择字典值')],
dictColor: [required('请选择字典颜色')],
sortCode: [required('请选择排序')]
}
// label

View File

@ -27,10 +27,10 @@
allow-clear
:tree-data="treeData"
:field-names="{
children: 'children',
label: 'name',
value: 'id'
}"
children: 'children',
label: 'name',
value: 'id'
}"
selectable="false"
tree-line
/>
@ -84,6 +84,9 @@
<a-tag color="blue" v-if="record.level">{{ record.level }}</a-tag>
<a-tag color="green" v-else>子级</a-tag>
</template>
<template v-if="column.dataIndex === 'dictLabel'">
<a-tag :color="record.dictColor">{{ record.dictLabel }}</a-tag>
</template>
<template v-if="column.dataIndex === 'action'">
<a @click="formRef.onOpen(record, categoryType)">编辑</a>
<a-divider type="vertical" />