假设字段为角色
1.数据库
roleIds,roleNames,分别存放id和name,roleNames为冗余存放。
2.vue前端
代码位置:
<template slot-scope="{row}" slot="roles"> <el-tag>{{row.rolesName}}</el-tag> </template>
{ label: "通知角色", prop: "roles", type: "tree", slot: true, multiple:true, dicUrl: "/api/blade-system/role/list", props: { label: "roleName", value: "id" }, search: true, },
对应js
export const update = (row) => { row.deptsName=JSON.stringify(row.$depts); row.depts=row.depts.join(","); row.rolesName=JSON.stringify(row.$roles); row.roles=row.roles.join(","); row.usersName=JSON.stringify(row.$users); row.users=row.users.join(","); return request({ url: '/api/blade-subway/emergencyplan/submit', method: 'post', data: row }) }
效果: