Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

综合示例-页面 列表中的重要性字段改为显示tag,内容字段隐藏应该用hidden,而不是show #3

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/utils/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,11 @@ export const treeMapEach = (
* @param parentNode 父节点
*/
export const eachTree = (treeDatas: any[], callBack: Fn, parentNode = {}) => {
treeDatas.forEach((element) => {
const newNode = callBack(element, parentNode) || element
if (element.children) {
eachTree(element.children, callBack, newNode)
}
})
treeDatas &&
treeDatas.forEach((element) => {
const newNode = callBack(element, parentNode) || element
if (element.children) {
eachTree(element.children, callBack, newNode)
}
})
}
27 changes: 17 additions & 10 deletions src/views/Example/Page/ExamplePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ useEventBus({
}
})

const renderImportance = (data: any) => {
return (
<ElTag type={data.importance === 1 ? 'success' : data.importance === 2 ? 'warning' : 'danger'}>
{data.importance === 1 ? '重要' : data.importance === 2 ? '良好' : ' 一般'}
</ElTag>
)
}

const crudSchemas = reactive<CrudSchema[]>([
{
field: 'selection',
Expand Down Expand Up @@ -157,15 +165,14 @@ const crudSchemas = reactive<CrudSchema[]>([
detail: {
slots: {
default: (data: any) => {
return (
<ElTag
type={
data.importance === 1 ? 'success' : data.importance === 2 ? 'warning' : 'danger'
}
>
{data.importance === 1 ? '重要' : data.importance === 2 ? '良好' : ' 一般'}
</ElTag>
)
return renderImportance(data)
}
}
},
table: {
slots: {
default: (data: any) => {
return renderImportance(data.row)
}
}
}
Expand All @@ -188,7 +195,7 @@ const crudSchemas = reactive<CrudSchema[]>([
hidden: true
},
table: {
show: false
hidden: true
},
form: {
component: 'Editor',
Expand Down
Loading