功能变化: 部门新增优化

pull/84/head
猿小天 2023-01-02 12:04:37 +08:00
parent 538c0b3983
commit 799876fe9b
2 changed files with 10 additions and 2 deletions

View File

@ -105,6 +105,14 @@ class DeptCreateUpdateSerializer(CustomModelSerializer):
部门管理 创建/更新时的列化器 部门管理 创建/更新时的列化器
""" """
def validate_parent(self, value):
"""
如果没有上级部门,则上级部门为创建者的部门
"""
if value is None:
value = self.request.user.dept_id
return value
def create(self, validated_data): def create(self, validated_data):
instance = super().create(validated_data) instance = super().create(validated_data)
instance.dept_belong_id = instance.id instance.dept_belong_id = instance.id

View File

@ -108,11 +108,11 @@ export const crudOptions = (vm) => {
value: 'id', value: 'id',
cache: false, cache: false,
getData: (url, dict, { form, component }) => { // 配置此参数会覆盖全局的getRemoteDictFunc getData: (url, dict, { form, component }) => { // 配置此参数会覆盖全局的getRemoteDictFunc
return api.DeptLazy().then(ret => { return ret.data }) return api.DeptLazy().then(ret => { return ret })
} }
}, },
form: { form: {
helper: '默认留空为根节点', helper: '默认留空为创建者的部门',
component: { component: {
span: 12, span: 12,
props: { props: {