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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
| <!-- 流程发起(启动)的弹窗 -->
|
| <script setup lang="ts">
| import type { CompleteTaskReqData } from '#/api/workflow/task/model';
|
| import { useVbenModal } from '@vben/common-ui';
|
| import { cloneDeep } from 'lodash-es';
|
| import { useVbenForm } from '#/adapter/form';
| import { completeTask, getTaskByTaskId } from '#/api/workflow/task';
|
| import { CopyComponent } from '.';
|
| interface Emits {
| /**
| * 完成
| */
| complete: [];
| }
|
| const emit = defineEmits<Emits>();
|
| interface ModalProps {
| taskId: string;
| taskVariables: Record<string, any>;
| variables?: any; // 这个干啥的
| }
|
| const [BasicModal, modalApi] = useVbenModal({
| title: '流程发起',
| fullscreenButton: false,
| onConfirm: handleSubmit,
| async onOpenChange(isOpen) {
| if (!isOpen) {
| return null;
| }
| const { taskId } = modalApi.getData() as ModalProps;
|
| // 查询是否有按钮权限
| const resp = await getTaskByTaskId(taskId);
| const buttonPermissions: Record<string, boolean> = {};
| resp.buttonList.forEach((item) => {
| buttonPermissions[item.code] = item.show;
| });
|
| // 是否具有抄送权限
| const copyPermission = buttonPermissions?.copy ?? false;
| formApi.updateSchema([
| {
| fieldName: 'flowCopyList',
| dependencies: {
| if: copyPermission,
| triggerFields: [''],
| },
| },
| ]);
| },
| });
|
| const [BasicForm, formApi] = useVbenForm({
| commonConfig: {
| // 默认占满两列
| formItemClass: 'col-span-2',
| // 默认label宽度 px
| labelWidth: 100,
| // 通用配置项 会影响到所有表单项
| componentProps: {
| class: 'w-full',
| },
| },
| schema: [
| {
| fieldName: 'messageType',
| component: 'CheckboxGroup',
| componentProps: {
| options: [
| { label: '站内信', value: '1', disabled: true },
| { label: '邮件', value: '2' },
| { label: '短信', value: '3' },
| ],
| },
| label: '通知方式',
| defaultValue: ['1'],
| },
| {
| fieldName: 'attachment',
| component: 'FileUpload',
| componentProps: {
| resultField: 'ossId',
| maxNumber: 10,
| maxSize: 20,
| accept: [
| 'png',
| 'jpg',
| 'jpeg',
| 'doc',
| 'docx',
| 'xlsx',
| 'xls',
| 'ppt',
| 'pdf',
| ],
| },
| defaultValue: [],
| label: '附件上传',
| formItemClass: 'items-start',
| },
| {
| fieldName: 'flowCopyList',
| component: 'Input',
| defaultValue: [],
| label: '抄送人',
| },
| ],
| showDefaultActions: false,
| wrapperClass: 'grid-cols-2',
| });
|
| async function handleSubmit() {
| try {
| modalApi.modalLoading(true);
| const { messageType, flowCopyList, attachment } = cloneDeep(
| await formApi.getValues(),
| );
| const { taskId, taskVariables, variables } =
| modalApi.getData() as ModalProps;
| // 需要转换数据 抄送人员
| const flowCCList = (flowCopyList as Array<any>).map((item) => ({
| userId: item.userId,
| userName: item.nickName,
| }));
| const requestData = {
| fileId: attachment.join(','),
| messageType,
| flowCopyList: flowCCList,
| taskId,
| taskVariables,
| variables,
| } as CompleteTaskReqData;
| await completeTask(requestData);
| modalApi.close();
| emit('complete');
| } catch (error) {
| console.error(error);
| } finally {
| modalApi.modalLoading(false);
| }
| }
| </script>
|
| <template>
| <BasicModal>
| <BasicForm>
| <template #flowCopyList="slotProps">
| <CopyComponent v-model:user-list="slotProps.modelValue" />
| </template>
| </BasicForm>
| </BasicModal>
| </template>
|
|