在d2-crud框架中使用element的多选下拉框时,向后台传递数据时一定要转换类型
custom: [
{
title: '标签',
key: 'label',
// sortable: true
type: 'select',
// search: { disabled: true }, //开启查询
// form: { disabled: true } // 表单配置
// disabled: false //是否隐藏列
form: {
component: { props: { filterable: true, multiple: true, clearable: true } }
},
dict: {
url: '/assetsManage/manage/label',
value: 'name',
label: 'name',
getData: (url, dict) => { // 配置此参数会覆盖全局的getRemoteDictFunc
return request({ url: url }).then(ret => { return ret.data })
}
}
}
]
methods: {
updateRequest (row) {
// 在使用多选下拉框时,一定要将下拉框的值转化为String类型
row.label = row.label.toString()
return api.UpdateObj(row)
}
}
在向后台传递下拉框的值时,当后台的对应的实体类的字段类型为String时,一定要将下拉框的值转化为String类型,不然后台会报错。