diff --git a/mock/department/index.ts b/mock/department/index.ts index 8512f07b9..8a96b95e5 100644 --- a/mock/department/index.ts +++ b/mock/department/index.ts @@ -101,5 +101,40 @@ export default [ } } } + }, + // 保存接口 + { + url: '/department/user/save', + method: 'post', + timeout: 1000, + response: () => { + return { + data: { + code: code, + data: 'success' + } + } + } + }, + // 删除接口 + { + url: '/department/user/delete', + method: 'post', + response: ({ body }) => { + const ids = body.ids + if (!ids) { + return { + code: '500', + message: '请选择需要删除的数据' + } + } else { + return { + data: { + code: code, + data: 'success' + } + } + } + } } ] as MockMethod[] diff --git a/src/api/department/index.ts b/src/api/department/index.ts index 7c74aa34c..6339ad4d0 100644 --- a/src/api/department/index.ts +++ b/src/api/department/index.ts @@ -8,3 +8,11 @@ export const getDepartmentApi = () => { export const getUserByIdApi = (params: DepartmentUserParams) => { return request.get({ url: '/department/users', params }) } + +export const deleteUserByIdApi = (ids: string[] | number[]) => { + return request.post({ url: '/department/user/delete', data: { ids } }) +} + +export const saveUserApi = (data: any) => { + return request.post({ url: '/department/user/save', data }) +} diff --git a/src/api/department/types.ts b/src/api/department/types.ts index f838c7b8c..027a62806 100644 --- a/src/api/department/types.ts +++ b/src/api/department/types.ts @@ -23,6 +23,7 @@ export interface DepartmentUserItem { email: string createTime: string role: string + department: DepartmentItem } export interface DepartmentUserResponse { diff --git a/src/components/Descriptions/src/Descriptions.vue b/src/components/Descriptions/src/Descriptions.vue index cf1e16845..20dcc713c 100644 --- a/src/components/Descriptions/src/Descriptions.vue +++ b/src/components/Descriptions/src/Descriptions.vue @@ -6,6 +6,7 @@ import { ref, unref, PropType, computed, defineComponent } from 'vue' import { useAppStore } from '@/store/modules/app' import { DescriptionsSchema } from './types' import { Icon } from '@/components/Icon' +import { get } from 'lodash-es' const appStore = useAppStore() @@ -114,7 +115,7 @@ export default defineComponent({ default: () => item.slots?.default ? item.slots?.default(props.data) - : props.data[item.field] + : get(props.data, item.field) }} ) diff --git a/src/components/Form/src/Form.vue b/src/components/Form/src/Form.vue index 5b37abeae..fdf91781f 100644 --- a/src/components/Form/src/Form.vue +++ b/src/components/Form/src/Form.vue @@ -318,9 +318,19 @@ export default defineComponent({ } const Comp = () => { + // 如果field是多层路径,需要转换成对象 + const fields = item.field.split('.') + // 循环fields,绑定v-model + const vModel = fields.reduce((prev, next, index) => { + if (index === 0) { + return formModel.value[next] + } + return prev[next] + }, {}) + return ( setComponentRefMap(el, item.field)} {...(autoSetPlaceholder && setTextPlaceholder(item))} {...setComponentProps(item)} diff --git a/src/components/Form/src/helper/index.ts b/src/components/Form/src/helper/index.ts index f93edd128..74fb2840c 100644 --- a/src/components/Form/src/helper/index.ts +++ b/src/components/Form/src/helper/index.ts @@ -2,6 +2,7 @@ import { useI18n } from '@/hooks/web/useI18n' import { PlaceholderModel, FormSchema, ComponentNameEnum, ColProps } from '../types' import { isFunction } from '@/utils/is' import { firstUpperCase, humpToDash } from '@/utils' +import { set, get } from 'lodash-es' const { t } = useI18n() @@ -143,13 +144,14 @@ export const setItemComponentSlots = (slotsProps: Recordable = {}): Recordable = export const initModel = (schema: FormSchema[], formModel: Recordable) => { const model: Recordable = { ...formModel } schema.map((v) => { - // 如果是hidden,就删除对应的值 if (v.remove) { delete model[v.field] } else if (v.component && v.component !== 'Divider') { - const hasField = Reflect.has(model, v.field) + // const hasField = Reflect.has(model, v.field) + const hasField = get(model, v.field) // 如果先前已经有值存在,则不进行重新赋值,而是采用现有的值 - model[v.field] = hasField ? model[v.field] : v.value !== void 0 ? v.value : undefined + set(model, v.field, hasField ? get(model, v.field) : v.value !== void 0 ? v.value : undefined) + // model[v.field] = hasField ? model[v.field] : v.value !== void 0 ? v.value : undefined } }) return model diff --git a/src/components/Icon/src/Icon.vue b/src/components/Icon/src/Icon.vue index 4ecf04533..ae8ab2d38 100644 --- a/src/components/Icon/src/Icon.vue +++ b/src/components/Icon/src/Icon.vue @@ -19,8 +19,6 @@ const props = defineProps({ hoverColor: propTypes.string }) -const emit = defineEmits(['click']) - const isLocal = computed(() => props.icon.startsWith('svg-icon:')) const symbolId = computed(() => { @@ -34,14 +32,10 @@ const getIconifyStyle = computed(() => { color } }) - -const iconClick = () => { - emit('click') -}