|
|
|
@ -17,7 +17,6 @@
|
|
|
|
|
|
|
|
|
|
import { ref, onMounted } from 'vue' |
|
|
|
|
import { useI18n } from 'vue-i18n' |
|
|
|
|
import { uniqBy } from 'lodash' |
|
|
|
|
import { |
|
|
|
|
querySimpleList, |
|
|
|
|
queryProcessDefinitionByCode |
|
|
|
@ -46,69 +45,25 @@ export function useChildNode({
|
|
|
|
|
if (loading.value) return |
|
|
|
|
loading.value = true |
|
|
|
|
const res = await querySimpleList(projectCode) |
|
|
|
|
options.value = res.map((option: { name: string; code: number }) => ({ |
|
|
|
|
label: option.name, |
|
|
|
|
value: option.code |
|
|
|
|
})) |
|
|
|
|
options.value = res |
|
|
|
|
.filter((option: { name: string; code: number }) => option.code !== code) |
|
|
|
|
.map((option: { name: string; code: number }) => ({ |
|
|
|
|
label: option.name, |
|
|
|
|
value: option.code |
|
|
|
|
})) |
|
|
|
|
loading.value = false |
|
|
|
|
if (!model.processDefinitionCode) { |
|
|
|
|
model.processDefinitionCode = options.value[0].value |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const getProcessListByCode = async (processCode: number) => { |
|
|
|
|
if (!processCode) return |
|
|
|
|
const res = await queryProcessDefinitionByCode(processCode, projectCode) |
|
|
|
|
getTaskOptions(res) |
|
|
|
|
} |
|
|
|
|
const getTaskOptions = (processDefinition: { |
|
|
|
|
processTaskRelationList: [] |
|
|
|
|
taskDefinitionList: [] |
|
|
|
|
}) => { |
|
|
|
|
const { processTaskRelationList = [], taskDefinitionList = [] } = |
|
|
|
|
processDefinition |
|
|
|
|
|
|
|
|
|
const preTaskOptions: { code: number; name: string }[] = [] |
|
|
|
|
const tasks: { [field: number]: string } = {} |
|
|
|
|
taskDefinitionList.forEach( |
|
|
|
|
(task: { code: number; taskType: string; name: string }) => { |
|
|
|
|
tasks[task.code] = task.name |
|
|
|
|
if (task.code === code) return |
|
|
|
|
if ( |
|
|
|
|
task.taskType === 'CONDITIONS' && |
|
|
|
|
processTaskRelationList.filter( |
|
|
|
|
(relation: { preTaskCode: number }) => |
|
|
|
|
relation.preTaskCode === task.code |
|
|
|
|
).length >= 2 |
|
|
|
|
) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
preTaskOptions.push({ |
|
|
|
|
code: task.code, |
|
|
|
|
name: task.name |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
model.preTaskOptions = uniqBy(preTaskOptions, 'code') |
|
|
|
|
|
|
|
|
|
if (!code) return |
|
|
|
|
const preTasks: number[] = [] |
|
|
|
|
const postTaskOptions: { code: number; name: string }[] = [] |
|
|
|
|
processTaskRelationList.forEach( |
|
|
|
|
(relation: { preTaskCode: number; postTaskCode: number }) => { |
|
|
|
|
if (relation.preTaskCode === code) { |
|
|
|
|
postTaskOptions.push({ |
|
|
|
|
code: relation.postTaskCode, |
|
|
|
|
name: tasks[relation.postTaskCode] |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
if (relation.postTaskCode === code && relation.preTaskCode !== 0) { |
|
|
|
|
preTasks.push(relation.preTaskCode) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
model.preTasks = preTasks |
|
|
|
|
model.postTaskOptions = postTaskOptions |
|
|
|
|
model.definition = res |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const onChange = (code: number) => { |
|
|
|
|
getProcessListByCode(code) |
|
|
|
|
const onChange = (code: number, options: { label: string }) => { |
|
|
|
|
model.name = options.label |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
|