|
|
|
@ -30,6 +30,8 @@ import {
|
|
|
|
|
} from 'naive-ui' |
|
|
|
|
import { queryTenantList } from '@/service/modules/tenants' |
|
|
|
|
import { SaveForm, WorkflowDefinition } from './types' |
|
|
|
|
import { useRoute } from 'vue-router' |
|
|
|
|
import { verifyName } from '@/service/modules/process-definition' |
|
|
|
|
import './x6-style.scss' |
|
|
|
|
|
|
|
|
|
const props = { |
|
|
|
@ -54,8 +56,10 @@ export default defineComponent({
|
|
|
|
|
props, |
|
|
|
|
emits: ['update:show', 'save'], |
|
|
|
|
setup(props, context) { |
|
|
|
|
const route = useRoute() |
|
|
|
|
const { t } = useI18n() |
|
|
|
|
|
|
|
|
|
const projectCode = Number(route.params.projectCode) |
|
|
|
|
const tenants = ref<Tenant[]>([]) |
|
|
|
|
const tenantsDropdown = computed(() => { |
|
|
|
|
if (tenants.value) { |
|
|
|
@ -86,19 +90,59 @@ export default defineComponent({
|
|
|
|
|
const formRef = ref() |
|
|
|
|
const rule = { |
|
|
|
|
name: { |
|
|
|
|
required: true |
|
|
|
|
required: true, |
|
|
|
|
message: t('project.dag.dag_name_empty') |
|
|
|
|
}, |
|
|
|
|
timeout: { |
|
|
|
|
validator() { |
|
|
|
|
if (formValue.value.timeoutFlag && formValue.value.timeout <= 0) { |
|
|
|
|
return new Error(t('project.dag.positive_integer')) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
globalParams: { |
|
|
|
|
validator() { |
|
|
|
|
const props = new Set() |
|
|
|
|
for (const param of formValue.value.globalParams) { |
|
|
|
|
const prop = param.value |
|
|
|
|
if (!prop) { |
|
|
|
|
return new Error(t('project.dag.prop_empty')) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (props.has(prop)) { |
|
|
|
|
return new Error(t('project.dag.prop_repeat')) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
props.add(prop) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const onSubmit = () => { |
|
|
|
|
formRef.value.validate(async (valid: any) => { |
|
|
|
|
if (!valid) { |
|
|
|
|
const params = { |
|
|
|
|
name: formValue.value.name |
|
|
|
|
} |
|
|
|
|
if ( |
|
|
|
|
props.definition?.processDefinition.name !== formValue.value.name |
|
|
|
|
) { |
|
|
|
|
verifyName(params, projectCode) |
|
|
|
|
.then(() => context.emit('save', formValue.value)) |
|
|
|
|
.catch((error: any) => { |
|
|
|
|
window.$message.error(error.message) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
context.emit('save', formValue.value) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
const onCancel = () => { |
|
|
|
|
context.emit('update:show', false) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
|
() => props.definition, |
|
|
|
|
() => { |
|
|
|
|
const updateModalData = () => { |
|
|
|
|
const process = props.definition?.processDefinition |
|
|
|
|
if (process) { |
|
|
|
|
formValue.value.name = process.name |
|
|
|
@ -108,11 +152,18 @@ export default defineComponent({
|
|
|
|
|
formValue.value.timeoutFlag = true |
|
|
|
|
formValue.value.timeout = process.timeout |
|
|
|
|
} |
|
|
|
|
formValue.value.globalParams = process.globalParamList.map( |
|
|
|
|
(param) => ({ key: param.prop, value: param.value }) |
|
|
|
|
) |
|
|
|
|
formValue.value.globalParams = process.globalParamList.map((param) => ({ |
|
|
|
|
key: param.prop, |
|
|
|
|
value: param.value |
|
|
|
|
})) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onMounted(() => updateModalData()) |
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
|
() => props.definition?.processDefinition, |
|
|
|
|
() => updateModalData() |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
return () => ( |
|
|
|
|