feat: 合同文档模板设置
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:visible="visible"
|
||||
:title="isEdit ? '编辑创建合同模板' : '新增创建合同模板'"
|
||||
title="新增创建合同模板"
|
||||
unmount-on-close
|
||||
@ok="handleSubmit"
|
||||
@cancel="handleCancel"
|
||||
@@ -37,7 +37,7 @@
|
||||
import { createTemplateSetting, updateTemplateSetting } from '@/api/setting';
|
||||
import { DepartmentItem, CreateTemplateSettingParam } from '@/types/setting';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
|
||||
import { useRouter } from 'vue-router';
|
||||
interface TreeNode {
|
||||
id: string | number;
|
||||
name: string;
|
||||
@@ -46,7 +46,7 @@
|
||||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
isEdit: boolean;
|
||||
record?: DepartmentItem | null;
|
||||
record?: any;
|
||||
departmentListData: TreeNode[]; // 修复类型
|
||||
}>();
|
||||
|
||||
@@ -54,13 +54,13 @@
|
||||
(e: 'update:visible', val: boolean): void;
|
||||
(e: 'submitted'): void;
|
||||
}>();
|
||||
|
||||
const router = useRouter();
|
||||
// 表单数据
|
||||
const formRef = ref<FormInstance>();
|
||||
const form = reactive<CreateTemplateSettingParam>({
|
||||
const form = reactive<any>({
|
||||
name: '',
|
||||
departmentId: null,
|
||||
// id: undefined,
|
||||
id: undefined,
|
||||
});
|
||||
|
||||
// 校验规则
|
||||
@@ -68,19 +68,18 @@
|
||||
name: [{ required: true, message: '请输入模板名称' }],
|
||||
departmentId: [{ required: true, message: '请选择适用范围' }],
|
||||
};
|
||||
|
||||
// Watch 弹窗控制 & 初始化
|
||||
// 表单事件
|
||||
const handleCancel = () => {
|
||||
emit('update:visible', false);
|
||||
};
|
||||
watch(
|
||||
() => props.visible,
|
||||
(val) => {
|
||||
if (val) {
|
||||
if (props.record) {
|
||||
// form.id = props.record?.id;
|
||||
// form.name = props.record?.name;
|
||||
// form.parent_id = props.record?.parentId ?? '';
|
||||
// form.user_id = props.record?.UserId ?? '';
|
||||
// form.remark = props.record?.remark ?? '';
|
||||
// Object.assign(form, props.record);
|
||||
Object.assign(form, {
|
||||
...props.record,
|
||||
});
|
||||
} else {
|
||||
Object.assign(form, {
|
||||
id: undefined,
|
||||
@@ -92,21 +91,29 @@
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
// 表单事件
|
||||
const handleCancel = () => {
|
||||
emit('update:visible', false);
|
||||
};
|
||||
const handleSubmit = async () => {
|
||||
await formRef.value?.validate();
|
||||
const { code, message } = props.isEdit
|
||||
if (!form.departmentId || !form.name) return;
|
||||
if (props.isEdit) {
|
||||
// saveType 保存类别:1 名称与适用范围数据,2 基础信息数据,3 条款数据)
|
||||
form.saveType = 1;
|
||||
}
|
||||
const { code, message, data } = props.isEdit
|
||||
? await updateTemplateSetting(form)
|
||||
: await createTemplateSetting(form);
|
||||
if (code === 200) {
|
||||
Message.success(message);
|
||||
if (props.isEdit) {
|
||||
emit('submitted');
|
||||
} else {
|
||||
const info = data as any;
|
||||
const id = info.contractTemplateSettingId;
|
||||
router.push({
|
||||
name: 'system-setting-contract-template-edit',
|
||||
query: { id },
|
||||
});
|
||||
}
|
||||
handleCancel();
|
||||
// 通知父组件更新部门列表数据
|
||||
emit('submitted');
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user