66
66
class =" !w-240px"
67
67
/>
68
68
</el-form-item >
69
+ <el-form-item
70
+ v-for =" (item, index) in formFields"
71
+ :key =" index"
72
+ :label =" item.title"
73
+ :prop =" item.field"
74
+ >
75
+ <!-- TODO 目前只支持input类型的字符串搜索 -->
76
+ <el-input
77
+ :disabled =" item.type !== 'input'"
78
+ v-model =" queryParams.formFieldsParams[item.field]"
79
+ :placeholder =" `请输入${item.title}`"
80
+ clearable
81
+ @keyup.enter =" handleQuery"
82
+ class =" !w-240px"
83
+ />
84
+ </el-form-item >
69
85
<el-form-item >
70
86
<el-button @click =" handleQuery" ><Icon icon =" ep:search" class =" mr-5px" /> 搜索</el-button >
71
87
<el-button @click =" resetQuery" ><Icon icon =" ep:refresh" class =" mr-5px" /> 重置</el-button >
98
114
:formatter =" dateFormatter"
99
115
/>
100
116
<el-table-column
101
- v-for =" (item, index) in formFieldsList "
117
+ v-for =" (item, index) in formFields "
102
118
:key =" index"
103
119
:label =" item.title"
104
120
:prop =" item.field"
105
121
width =" 120"
106
122
>
107
123
<!-- TODO 可以根据formField的type进行展示方式的控制,现在全部以字符串 -->
108
124
<template #default =" scope " >
109
- {{ scope.row.variables.find((variable) => variable.key === item.field)?.value }}
125
+ {{ scope.row.formVariables[ item.field] ?? '' }}
110
126
</template >
111
127
</el-table-column >
112
128
</el-table >
@@ -124,28 +140,28 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
124
140
import { dateFormatter } from ' @/utils/formatTime'
125
141
import * as ProcessInstanceApi from ' @/api/bpm/processInstance'
126
142
import * as UserApi from ' @/api/system/user'
143
+ import * as DefinitionApi from ' @/api/bpm/definition'
144
+ import { parseFormFields } from ' @/components/FormCreate/src/utils'
127
145
128
146
defineOptions ({ name: ' BpmProcessInstanceReport' })
129
147
130
- const router = useRouter () // 路由
131
- const { query } = useRoute () // 查询参数
132
- const message = useMessage () // 消息弹窗
133
- const { t } = useI18n () // 国际化
148
+ const { query } = useRoute ()
134
149
135
150
const loading = ref (true ) // 列表的加载中
136
151
const total = ref (0 ) // 列表的总页数
137
152
const list = ref ([]) // 列表的数据
138
- const formFieldsList = ref ([])
153
+ const formFields = ref ()
154
+ const processDefinitionId = query .processDefinitionId as string
139
155
const queryParams = reactive ({
140
156
pageNo: 1 ,
141
157
pageSize: 10 ,
142
158
startUserId: undefined ,
143
159
name: ' ' ,
144
- processDefinitionId: query .processDefinitionId ,
145
160
processDefinitionKey: query .processDefinitionKey ,
146
161
status: undefined ,
147
162
createTime: [],
148
- endTime: []
163
+ endTime: [],
164
+ formFieldsParams: {}
149
165
})
150
166
const queryFormRef = ref () // 搜索的表单
151
167
const userList = ref <any []>([]) // 用户列表
@@ -154,16 +170,31 @@ const userList = ref<any[]>([]) // 用户列表
154
170
const getList = async () => {
155
171
loading .value = true
156
172
try {
157
- const data = await ProcessInstanceApi . getProcessInstanceReportPage ( queryParams )
158
- list . value = data . pageResult . list
159
- total . value = data . pageResult . total
160
- // TODO @lesan:不确定,能不能通过 processDefinitionId 获取流程定义哈,从而拿到 formFields;
161
- formFieldsList .value = data .formFields
173
+ let queryParamsClone = { ... queryParams }
174
+ queryParamsClone . formFieldsParams = JSON . stringify ( queryParamsClone . formFieldsParams )
175
+ const data = await ProcessInstanceApi . getProcessInstanceManagerPage ( queryParamsClone )
176
+ list . value = data . list
177
+ total .value = data .total
162
178
} finally {
163
179
loading .value = false
164
180
}
165
181
}
166
182
183
+ const getProcessDefinition = async () => {
184
+ const processDefinition = await DefinitionApi .getProcessDefinition (processDefinitionId )
185
+ formFields .value = parseFormCreateFields (processDefinition .formFields )
186
+ }
187
+
188
+ const parseFormCreateFields = (formFields ? : string []) => {
189
+ const result: Array <Record <string , any >> = []
190
+ if (formFields ) {
191
+ formFields .forEach ((fieldStr : string ) => {
192
+ parseFormFields (JSON .parse (fieldStr ), result )
193
+ })
194
+ }
195
+ return result
196
+ }
197
+
167
198
/** 搜索按钮操作 */
168
199
const handleQuery = () => {
169
200
queryParams .pageNo = 1
@@ -173,11 +204,13 @@ const handleQuery = () => {
173
204
/** 重置按钮操作 */
174
205
const resetQuery = () => {
175
206
queryFormRef .value .resetFields ()
207
+ queryFormRef .value .formFieldsParams = {}
176
208
handleQuery ()
177
209
}
178
210
179
211
/** 初始化 **/
180
212
onMounted (async () => {
213
+ await getProcessDefinition ()
181
214
await getList ()
182
215
userList .value = await UserApi .getSimpleUserList ()
183
216
})
0 commit comments