125
125
{{ scope.row.formVariables[item.field] ?? '' }}
126
126
</template >
127
127
</el-table-column >
128
- <!-- TODO @lesan:可能要类似 manager 那,加个详情和取消? -->
128
+ <el-table-column label =" 操作" align =" center" fixed =" right" width =" 180" >
129
+ <template #default =" scope " >
130
+ <el-button
131
+ link
132
+ type =" primary"
133
+ v-hasPermi =" ['bpm:process-instance:cancel']"
134
+ @click =" handleDetail(scope.row)"
135
+ >
136
+ 详情
137
+ </el-button >
138
+ <el-button
139
+ link
140
+ type =" primary"
141
+ v-if =" scope.row.status === 1"
142
+ v-hasPermi =" ['bpm:process-instance:query']"
143
+ @click =" handleCancel(scope.row)"
144
+ >
145
+ 取消
146
+ </el-button >
147
+ </template >
148
+ </el-table-column >
129
149
</el-table >
130
150
<!-- 分页 -->
131
151
<Pagination
@@ -143,10 +163,14 @@ import * as ProcessInstanceApi from '@/api/bpm/processInstance'
143
163
import * as UserApi from ' @/api/system/user'
144
164
import * as DefinitionApi from ' @/api/bpm/definition'
145
165
import { parseFormFields } from ' @/components/FormCreate/src/utils'
166
+ import { ElMessageBox } from ' element-plus'
146
167
147
168
defineOptions ({ name: ' BpmProcessInstanceReport' })
148
169
170
+ const router = useRouter () // 路由
149
171
const { query } = useRoute ()
172
+ const message = useMessage () // 消息弹窗
173
+ const { t } = useI18n () // 国际化
150
174
151
175
const loading = ref (true ) // 列表的加载中
152
176
const total = ref (0 ) // 列表的总页数
@@ -206,13 +230,38 @@ const handleQuery = () => {
206
230
}
207
231
208
232
/** 重置按钮操作 */
209
- // TODO @lesan:动态表单的 search ,无法重置的样子
210
233
const resetQuery = () => {
211
234
queryFormRef .value .resetFields ()
212
- queryFormRef . value .formFieldsParams = {}
235
+ queryParams .formFieldsParams = {}
213
236
handleQuery ()
214
237
}
215
238
239
+ /** 查看详情 */
240
+ const handleDetail = (row ) => {
241
+ router .push ({
242
+ name: ' BpmProcessInstanceDetail' ,
243
+ query: {
244
+ id: row .id
245
+ }
246
+ })
247
+ }
248
+
249
+ /** 取消按钮操作 */
250
+ const handleCancel = async (row ) => {
251
+ // 二次确认
252
+ const { value } = await ElMessageBox .prompt (' 请输入取消原因' , ' 取消流程' , {
253
+ confirmButtonText: t (' common.ok' ),
254
+ cancelButtonText: t (' common.cancel' ),
255
+ inputPattern: / ^ [\s\S ] * . * \S [\s\S ] * $ / , // 判断非空,且非空格
256
+ inputErrorMessage: ' 取消原因不能为空'
257
+ })
258
+ // 发起取消
259
+ await ProcessInstanceApi .cancelProcessInstanceByAdmin (row .id , value )
260
+ message .success (' 取消成功' )
261
+ // 刷新列表
262
+ await getList ()
263
+ }
264
+
216
265
/** 初始化 **/
217
266
onMounted (async () => {
218
267
// 获取流程定义,用于 table column 的展示
0 commit comments