1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
| <script lang="ts" setup>
| import type { VbenFormSchema } from '#/adapter/form';
|
| import { ref } from 'vue';
|
| import { useVbenModal } from '#/packages/effects/common-ui/src';
|
| import { message } from 'ant-design-vue';
|
| import { useVbenForm } from '#/adapter/form';
| import { terminateEmployeeContract } from '#/api/hrm/employee/contract';
| import { $t } from '#/locales';
|
| const emit = defineEmits(['success']);
| const contractId = ref<number>();
|
| /** 解除/终止表单 */
| const schema: VbenFormSchema[] = [
| {
| fieldName: 'terminateStatus',
| label: '操作类型',
| component: 'RadioGroup',
| componentProps: {
| options: [
| { label: '解除', value: 1 },
| { label: '终止', value: 2 },
| ],
| },
| rules: 'required',
| },
| {
| fieldName: 'terminateDate',
| label: '解除/终止日期',
| component: 'DatePicker',
| componentProps: {
| placeholder: '请选择日期',
| valueFormat: 'YYYY-MM-DD',
| style: { width: '100%' },
| },
| rules: 'required',
| },
| {
| fieldName: 'terminateReason',
| label: '原因',
| component: 'Textarea',
| formItemClass: 'col-span-2',
| componentProps: {
| placeholder: '请输入解除/终止原因',
| rows: 3,
| maxlength: 255,
| showCount: true,
| },
| rules: 'required',
| },
| ];
|
| const [Form, formApi] = useVbenForm({
| commonConfig: {
| componentProps: {
| class: 'w-full',
| },
| formItemClass: 'col-span-1',
| labelWidth: 110,
| },
| wrapperClass: 'grid-cols-2',
| layout: 'horizontal',
| schema,
| showDefaultActions: false,
| });
|
| const [Modal, modalApi] = useVbenModal({
| async onConfirm() {
| const { valid } = await formApi.validate();
| if (!valid) {
| return;
| }
| modalApi.lock();
| const data = await formApi.getValues();
| try {
| await terminateEmployeeContract({ id: contractId.value!, ...data });
| await modalApi.close();
| emit('success');
| message.success($t('ui.actionMessage.operationSuccess'));
| } finally {
| modalApi.unlock();
| }
| },
| async onOpenChange(isOpen: boolean) {
| if (!isOpen) {
| return;
| }
| const data = modalApi.getData<{ id: number }>();
| contractId.value = data.id;
| await formApi.resetForm();
| },
| });
| </script>
|
| <template>
| <Modal title="解除/终止合同" class="w-[520px]">
| <Form class="mx-4" />
| </Modal>
| </template>
|
|