nursing_unit_vue/src/views/invoicing/configSuppliersInfo/components/ConfigSuppliersInfoModal.vue

88 lines
3.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<BasicDrawer
v-bind="$attrs"
@register="registerDrawer"
:title="getTitle"
:width="adaptiveWidth"
@ok="handleSubmit"
:showFooter="showFooter"
destroyOnClose
>
<BasicForm @register="registerForm" />
</BasicDrawer>
</template>
<script lang="ts" setup>
import { defineComponent, ref, computed, unref, useAttrs } from 'vue';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from '../ConfigSuppliersInfo.data';
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import { saveOrUpdate } from '../ConfigSuppliersInfo.api';
import { useDrawerAdaptiveWidth } from '/@/hooks/jeecg/useAdaptiveWidth';
import { getTenantId } from "/@/utils/auth";
// 声明Emits
const emit = defineEmits(['success', 'register']);
const attrs = useAttrs();
const isUpdate = ref(true);
const rowId = ref('');
const departOptions = ref([]);
let isFormDepartUser = false;
//表单配置
const [registerForm, { setProps, resetFields, setFieldsValue, validate, updateSchema }] = useForm({
labelWidth: 90,
schemas: formSchema,
showActionButtonGroup: false,
});
const showFooter = ref(true);
//表单赋值
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
await resetFields();
showFooter.value = data?.showFooter ?? true;
setDrawerProps({ confirmLoading: false, showFooter: showFooter.value });
isUpdate.value = !!data?.isUpdate;
if (unref(isUpdate)) {
//表单赋值
await setFieldsValue({
...data.record,
});
}
setProps({ disabled: !showFooter.value });
});
//获取标题
const getTitle = computed(() => {
// update-begin--author:liaozhiyang---date:20240306---for【QQYUN-8389】系统用户详情抽屉title更改
if (!unref(isUpdate)) {
return '新增';
} else {
return unref(showFooter) ? '编辑' : '详情';
}
// update-end--author:liaozhiyang---date:20240306---for【QQYUN-8389】系统用户详情抽屉title更改
});
const { adaptiveWidth } = useDrawerAdaptiveWidth();
//提交事件
async function handleSubmit() {
try {
let values = await validate();
setDrawerProps({ confirmLoading: true });
values.userIdentity === 1 && (values.departIds = '');
let isUpdateVal = unref(isUpdate);
// -update-begin--author:liaozhiyang---date:20240702---for【TV360X-1737】部门用户编辑接口增加参数updateFromPage:"deptUsers"
let params = values;
if (isFormDepartUser) {
params = { ...params, updateFromPage: 'deptUsers' };
}
// -update-end--author:liaozhiyang---date:20240702---for【TV360X-1737】部门用户编辑接口增加参数updateFromPage:"deptUsers"
//提交表单
await saveOrUpdate(params, isUpdateVal);
//关闭弹窗
closeDrawer();
//刷新列表
emit('success',{isUpdateVal ,values});
} finally {
setDrawerProps({ confirmLoading: false });
}
}
</script>