Skip to content

Commit 0d7d2cd

Browse files
YunaiVgitee-org
authored andcommitted
!700 fix: 修复流程预测功能
Merge pull request !700 from SamllNorth_Lee/fix/bpm
2 parents 1de17ca + ee8de08 commit 0d7d2cd

File tree

6 files changed

+58
-15
lines changed

6 files changed

+58
-15
lines changed

src/api/bpm/processInstance/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const getProcessInstanceCopyPage = async (params: any) => {
9090

9191
// 获取审批详情
9292
export const getApprovalDetail = async (params: any) => {
93-
return await request.get({ url: 'bpm/process-instance/get-approval-detail', params })
93+
return await request.get({ url: '/bpm/process-instance/get-approval-detail', params })
9494
}
9595

9696
// 获取表单字段权限

src/components/SimpleProcessDesignerV2/src/consts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ export const CANDIDATE_STRATEGY: DictDataVO[] = [
532532
{ label: '部门负责人', value: CandidateStrategy.DEPT_LEADER },
533533
{ label: '连续多级部门负责人', value: CandidateStrategy.MULTI_LEVEL_DEPT_LEADER },
534534
{ label: '指定岗位', value: CandidateStrategy.MULTI_LEVEL_DEPT_LEADER },
535+
{ label: '发起人自选', value: CandidateStrategy.START_USER_SELECT },
535536
{ label: '发起人本人', value: CandidateStrategy.START_USER },
536537
{ label: '发起人部门负责人', value: CandidateStrategy.START_USER_DEPT_LEADER },
537538
{ label: '发起人连续部门负责人', value: CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER },

src/components/bpmnProcessDesigner/package/designer/ProcessDesigner.vue

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,8 @@
188188
:scroll="true"
189189
max-height="600px"
190190
>
191-
<!-- append-to-body -->
192-
<div v-highlight>
193-
<code class="hljs">
194-
<!-- 高亮代码块 -->
195-
{{ previewResult }}
196-
</code>
191+
<div>
192+
<pre><code v-dompurify-html="highlightedCode(previewResult)" class="hljs"></code></pre>
197193
</div>
198194
</Dialog>
199195
</div>
@@ -237,6 +233,8 @@ import { XmlNode, XmlNodeType, parseXmlString } from 'steady-xml'
237233
// const eventName = reactive({
238234
// name: ''
239235
// })
236+
import hljs from 'highlight.js' // 导入代码高亮文件
237+
import 'highlight.js/styles/github.css' // 导入代码高亮样式
240238
241239
defineOptions({ name: 'MyProcessDesigner' })
242240
@@ -308,6 +306,18 @@ const props = defineProps({
308306
}
309307
})
310308
309+
/**
310+
* 代码高亮
311+
*/
312+
const highlightedCode = (code: string) => {
313+
// 高亮
314+
if (previewType.value === 'json') {
315+
code = JSON.stringify(code, null, 2)
316+
}
317+
const result = hljs.highlight(code, { language: previewType.value, ignoreIllegals: true })
318+
return result.value || '&nbsp;'
319+
}
320+
311321
provide('configGlobal', props)
312322
let bpmnModeler: any = null
313323
const defaultZoom = ref(1)

src/components/bpmnProcessDesigner/package/penal/custom-config/components/UserTaskCustomConfig.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
</div>
124124

125125
<el-divider content-position="left">字段权限</el-divider>
126-
<div class="field-setting-pane" v-if="formType === 10">
126+
<div class="field-setting-pane" v-if="formType === BpmModelFormType.NORMAL">
127127
<div class="field-permit-title">
128128
<div class="setting-title-label first-title"> 字段名称 </div>
129129
<div class="other-titles">

src/views/bpm/processInstance/create/ProcessDefinitionDetail.vue

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
</template>
7575
<script lang="ts" setup>
7676
import { decodeFields, setConfAndFields2 } from '@/utils/formCreate'
77-
import { BpmModelType } from '@/utils/constants'
77+
import { BpmModelType, BpmModelFormType } from '@/utils/constants'
7878
import {
7979
CandidateStrategy,
8080
NodeId,
@@ -108,6 +108,7 @@ const fApi = ref<ApiAttrs>()
108108
// 指定审批人
109109
const startUserSelectTasks: any = ref([]) // 发起人需要选择审批人或抄送人的任务列表
110110
const startUserSelectAssignees = ref({}) // 发起人选择审批人的数据
111+
const hisStartUserSelectAssignees = ref({}) // 历史发起人选择审批人的数据
111112
const bpmnXML: any = ref(null) // BPMN 数据
112113
const simpleJson = ref<string | undefined>() // Simple 设计器数据 json 格式
113114
@@ -121,7 +122,7 @@ const initProcessInfo = async (row: any, formVariables?: any) => {
121122
startUserSelectAssignees.value = {}
122123
123124
// 情况一:流程表单
124-
if (row.formType == 10) {
125+
if (row.formType == BpmModelFormType.NORMAL) {
125126
// 设置表单
126127
// 注意:需要从 formVariables 中,移除不在 row.formFields 的值。
127128
// 原因是:后端返回的 formVariables 里面,会有一些非表单的信息。例如说,某个流程节点的审批人。
@@ -155,32 +156,57 @@ const initProcessInfo = async (row: any, formVariables?: any) => {
155156
}
156157
}
157158
159+
// 预测流程节点会因为输入的参数值而产生新的预测结果值,所以需重新预测一次
160+
watch(
161+
detailForm.value,
162+
(newValue) => {
163+
if (newValue && Object.keys(newValue.value).length > 0) {
164+
//记录之前的节点审批人
165+
hisStartUserSelectAssignees.value = startUserSelectAssignees.value
166+
startUserSelectAssignees.value = {}
167+
getApprovalDetail({
168+
id: props.selectProcessDefinition.id,
169+
processVariablesStr: newValue.value
170+
})
171+
}
172+
},
173+
{
174+
immediate: true
175+
}
176+
)
177+
158178
/** 获取审批详情 */
159179
const getApprovalDetail = async (row: any) => {
160180
try {
161181
// TODO 获取审批详情,设置 activityId 为发起人节点(为了获取字段权限。暂时只对 Simple 设计器有效)
162182
const data = await ProcessInstanceApi.getApprovalDetail({
163183
processDefinitionId: row.id,
164-
activityId: NodeId.START_USER_NODE_ID
184+
activityId: NodeId.START_USER_NODE_ID,
185+
processVariablesStr: JSON.stringify(row.processVariablesStr)
165186
})
166187
167188
if (!data) {
168189
message.error('查询不到审批详情信息!')
169190
return
170191
}
192+
// 获取审批节点,显示 Timeline 的数据
193+
activityNodes.value = data.activityNodes
171194
172195
// 获取发起人自选的任务
173196
startUserSelectTasks.value = data.activityNodes?.filter(
174197
(node: ApprovalNodeInfo) => CandidateStrategy.START_USER_SELECT === node.candidateStrategy
175198
)
199+
176200
if (startUserSelectTasks.value?.length > 0) {
177201
for (const node of startUserSelectTasks.value) {
178-
startUserSelectAssignees.value[node.id] = []
202+
if (hisStartUserSelectAssignees.value[node.id] && hisStartUserSelectAssignees.value[node.id].length > 0) {
203+
startUserSelectAssignees.value[node.id] = hisStartUserSelectAssignees.value[node.id]
204+
} else {
205+
startUserSelectAssignees.value[node.id] = []
206+
}
179207
}
180208
}
181-
182-
// 获取审批节点,显示 Timeline 的数据
183-
activityNodes.value = data.activityNodes
209+
184210
// 获取表单字段权限
185211
const formFieldsPermission = data.formFieldsPermission
186212
// 设置表单字段权限

src/views/bpm/processInstance/detail/ProcessInstanceOperationButton.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,12 @@ const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) =>
703703
// 校验表单
704704
if (!formRef) return
705705
await formRef.validate()
706+
//校验流程表单必填字段
707+
const valid = await validateNormalForm()
708+
if (!valid) {
709+
message.warning('表单校验不通过,请先完善表单!!')
710+
return
711+
}
706712
if (pass) {
707713
// 获取修改的流程变量, 暂时只支持流程表单
708714
const variables = getUpdatedProcessInstanceVariables()

0 commit comments

Comments
 (0)