流程图时间和结果,流程审核表单默认勾选

This commit is contained in:
sjl
2025-12-16 11:15:27 +08:00
parent 72d836020b
commit 7b9f5302d0
3 changed files with 71 additions and 24 deletions

View File

@@ -150,7 +150,7 @@ defineOptions({ name: 'BpmProcessInstanceDetail' })
const { query } = useRoute() // 查询参数
const { proxy } = getCurrentInstance() as any
const states = history.state
console.log(states, '888888888888')
const userId = JSON.parse(window.localStorage.getItem('adminInfo')).id // 当前登录的编号
const id = (states.id as unknown as string) || query.id // 流程实例的编号
const historyInstanceId = states.historyInstanceId as unknown as string // 历史流程实例的编号
@@ -421,7 +421,32 @@ const loadRunningTask = tasks => {
// 2.4 处理 approve 表单
if (task.formId && task.formConf) {
const approveForm = {}
setConfAndFields2(approveForm, task.formConf, task.formFields, task.formVariable)
// 创建包含默认值的表单变量
const formVariablesWithDefaults = { ...task.formVariable }
// 解析 formFields 并设置默认值
let processedFormFields = task.formFields;
if (task.formFields && Array.isArray(task.formFields)) {
processedFormFields = task.formFields.map(field => {
// 如果是字符串,需要先解析为对象
let fieldObj = typeof field === 'string' ? JSON.parse(field) : field;
// 为 radio 类型设置默认值
if (fieldObj.type === 'radio' && fieldObj.options && fieldObj.options.length > 0) {
// 如果表单变量中还没有该字段的值,则设置默认值
if (!(fieldObj.field in formVariablesWithDefaults)) {
formVariablesWithDefaults[fieldObj.field] = fieldObj.defaultValue !== undefined ?
fieldObj.defaultValue : fieldObj.options[0].value;
}
// 设置字段的默认值
fieldObj.value = formVariablesWithDefaults[fieldObj.field];
}
// 将处理后的对象重新转换为JSON字符串如果是原始字符串
return typeof field === 'string' ? JSON.stringify(fieldObj) : fieldObj;
});
}
setConfAndFields2(approveForm, task.formConf, processedFormFields, task.formVariable)
approveForms.value.push(approveForm)
} else {
approveForms.value.push({}) // 占位,避免为空