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

110 lines
3.4 KiB
Vue
Raw Normal View History

2025-03-21 10:15:35 +08:00
<template>
<BasicDrawer
v-bind="$attrs"
@register="registerDrawer"
:title="getTitle"
:width="adaptiveWidth"
@ok="handleSubmit"
:showFooter="showFooter"
2025-08-06 15:58:08 +08:00
:showOkBtn="showFooter"
2025-03-21 10:15:35 +08:00
destroyOnClose
>
2025-10-31 16:35:32 +08:00
<div class="card-class">
2025-03-21 10:15:35 +08:00
<BasicForm @register="registerForm" />
2025-10-31 16:35:32 +08:00
</div>
2025-03-21 10:15:35 +08:00
</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>
2025-10-31 16:35:32 +08:00
<style lang="less" scoped>
.antd-modal-form {
padding: 14px;
}
.card-class{
padding-top: 24px;
padding-bottom: 24px;
padding-left: 14px;
padding-right: 14px;
// background-color: rgba(255, 255, 255, 0.9);
background-color: #fcfdff;
border-radius: 10px;
// box-shadow: rgba(0, 0, 0, 0.1) 0px 2px 12px;
margin-bottom: 14px;
}
</style>