[Fix][UI][V1.0.0-Beta] Fix the task name cleared after switching the task type. (#9623)

This commit is contained in:
Amy0104 2022-04-20 16:31:06 +08:00 committed by GitHub
parent 93ee2e45c8
commit a378844820
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 3 deletions

View File

@ -32,7 +32,8 @@ export const useTaskNodeStore = defineStore({
postTaskOptions: [], postTaskOptions: [],
preTasks: [], preTasks: [],
resources: [], resources: [],
mainJars: {} mainJars: {},
name: ''
}), }),
persist: true, persist: true,
getters: { getters: {
@ -50,6 +51,9 @@ export const useTaskNodeStore = defineStore({
}, },
getMainJar(state) { getMainJar(state) {
return (type: ProgramType): IMainJar[] | undefined => state.mainJars[type] return (type: ProgramType): IMainJar[] | undefined => state.mainJars[type]
},
getName(): string {
return this.name
} }
}, },
actions: { actions: {
@ -116,12 +120,16 @@ export const useTaskNodeStore = defineStore({
updateMainJar(type: ProgramType, mainJar: IMainJar[]) { updateMainJar(type: ProgramType, mainJar: IMainJar[]) {
this.mainJars[type] = mainJar this.mainJars[type] = mainJar
}, },
updateName(name: string) {
this.name = name
},
init() { init() {
this.preTaskOptions = [] this.preTaskOptions = []
this.postTaskOptions = [] this.postTaskOptions = []
this.preTasks = [] this.preTasks = []
this.resources = [] this.resources = []
this.mainJars = {} this.mainJars = {}
this.name = ''
} }
} }
}) })

View File

@ -36,6 +36,7 @@ interface TaskNodeState {
preTasks: number[] preTasks: number[]
resources: IResource[] resources: IResource[]
mainJars: { [key in ProgramType]?: IMainJar[] } mainJars: { [key in ProgramType]?: IMainJar[] }
name: string
} }
export { export {
TaskNodeState, TaskNodeState,

View File

@ -39,6 +39,8 @@ import {
import { NIcon } from 'naive-ui' import { NIcon } from 'naive-ui'
import { TASK_TYPES_MAP } from '../../constants/task-type' import { TASK_TYPES_MAP } from '../../constants/task-type'
import { Router, useRouter } from 'vue-router' import { Router, useRouter } from 'vue-router'
import { querySubProcessInstanceByTaskCode } from '@/service/modules/process-instances'
import { useTaskNodeStore } from '@/store/project/task-node'
import type { import type {
ITaskData, ITaskData,
ITaskType, ITaskType,
@ -46,7 +48,6 @@ import type {
IWorkflowTaskInstance, IWorkflowTaskInstance,
WorkflowInstance WorkflowInstance
} from './types' } from './types'
import { querySubProcessInstanceByTaskCode } from '@/service/modules/process-instances'
const props = { const props = {
show: { show: {
@ -92,6 +93,8 @@ const NodeDetailModal = defineComponent({
setup(props, { emit }) { setup(props, { emit }) {
const { t, locale } = useI18n() const { t, locale } = useI18n()
const router: Router = useRouter() const router: Router = useRouter()
const taskStore = useTaskNodeStore()
const renderIcon = (icon: any) => { const renderIcon = (icon: any) => {
return () => h(NIcon, null, { default: () => h(icon) }) return () => h(NIcon, null, { default: () => h(icon) })
} }
@ -203,6 +206,7 @@ const NodeDetailModal = defineComponent({
async () => { async () => {
if (!props.show) return if (!props.show) return
initHeaderLinks(props.processInstance, props.data.taskType) initHeaderLinks(props.processInstance, props.data.taskType)
taskStore.init()
await nextTick() await nextTick()
detailRef.value.value.setValues(formatModel(props.data)) detailRef.value.value.setValues(formatModel(props.data))
} }

View File

@ -35,7 +35,6 @@ const NodeDetail = defineComponent({
emits: ['taskTypeChange'], emits: ['taskTypeChange'],
setup(props, { expose, emit }) { setup(props, { expose, emit }) {
const taskStore = useTaskNodeStore() const taskStore = useTaskNodeStore()
taskStore.init()
const formRef = ref() const formRef = ref()
const detailData: IDetailPanel = inject('data') || { const detailData: IDetailPanel = inject('data') || {
@ -58,6 +57,7 @@ const NodeDetail = defineComponent({
watch( watch(
() => model.taskType, () => model.taskType,
async (taskType) => { async (taskType) => {
taskStore.updateName(model.name || '')
emit('taskTypeChange', taskType) emit('taskTypeChange', taskType)
} }
) )

View File

@ -65,6 +65,7 @@ export function useTask({
const { model, json } = nodes[data.taskType || 'SHELL'](params) const { model, json } = nodes[data.taskType || 'SHELL'](params)
jsonRef.value = json jsonRef.value = json
model.preTasks = taskStore.getPreTasks model.preTasks = taskStore.getPreTasks
model.name = taskStore.getName
const getElements = () => { const getElements = () => {
const { rules, elements } = getElementByJson(jsonRef.value, model) const { rules, elements } = getElementByJson(jsonRef.value, model)