feat(sj_preview): 新增条件表达式手动校验按钮
This commit is contained in:
parent
32379906aa
commit
c09e51648e
@ -69,9 +69,9 @@ const handleUpdateType = (index: number) => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NDynamicInput v-model:value="content" item-style="margin-bottom: 0;" :on-create="onCreate" #="{ index }">
|
<NDynamicInput v-model:value="content" item-style="margin-bottom: 0;" :on-create="onCreate" #="{ index }">
|
||||||
<NGrid :x-gap="16">
|
<NGrid>
|
||||||
<NFormItemGi
|
<NFormItemGi
|
||||||
:span="8"
|
:span="7"
|
||||||
ignore-path-change
|
ignore-path-change
|
||||||
:show-label="false"
|
:show-label="false"
|
||||||
:rule="dynamicInputRule"
|
:rule="dynamicInputRule"
|
||||||
@ -79,9 +79,9 @@ const handleUpdateType = (index: number) => {
|
|||||||
>
|
>
|
||||||
<NInput v-model:value="content[index].key" placeholder="key" @keydown.enter.prevent />
|
<NInput v-model:value="content[index].key" placeholder="key" @keydown.enter.prevent />
|
||||||
</NFormItemGi>
|
</NFormItemGi>
|
||||||
<NGi :span="1" class="h-34px lh-34px">=</NGi>
|
<NGi :span="2" class="h-34px text-center lh-34px">=</NGi>
|
||||||
<NFormItemGi
|
<NFormItemGi
|
||||||
:span="8"
|
:span="7"
|
||||||
ignore-path-change
|
ignore-path-change
|
||||||
:show-label="false"
|
:show-label="false"
|
||||||
:rule="dynamicInputRule"
|
:rule="dynamicInputRule"
|
||||||
@ -109,8 +109,14 @@ const handleUpdateType = (index: number) => {
|
|||||||
@keydown.enter.prevent
|
@keydown.enter.prevent
|
||||||
/>
|
/>
|
||||||
</NFormItemGi>
|
</NFormItemGi>
|
||||||
<NFormItemGi :span="3" class="w-130px" ignore-path-change :show-label="false" :path="`${path}[${index}].type`">
|
<NFormItemGi
|
||||||
<div :span="1" class="h-34px lh-34px">(</div>
|
:span="3"
|
||||||
|
class="ml-12px w-115px"
|
||||||
|
ignore-path-change
|
||||||
|
:show-label="false"
|
||||||
|
:path="`${path}[${index}].type`"
|
||||||
|
>
|
||||||
|
<div class="h-34px lh-34px">(</div>
|
||||||
<NSelect
|
<NSelect
|
||||||
v-model:value="content[index].type"
|
v-model:value="content[index].type"
|
||||||
class="mx-3px"
|
class="mx-3px"
|
||||||
@ -119,7 +125,7 @@ const handleUpdateType = (index: number) => {
|
|||||||
@keydown.enter.prevent
|
@keydown.enter.prevent
|
||||||
@update:value="handleUpdateType(index)"
|
@update:value="handleUpdateType(index)"
|
||||||
/>
|
/>
|
||||||
<div :span="1" class="h-34px lh-34px">)</div>
|
<div class="h-34px lh-34px">)</div>
|
||||||
</NFormItemGi>
|
</NFormItemGi>
|
||||||
</NGrid>
|
</NGrid>
|
||||||
</NDynamicInput>
|
</NDynamicInput>
|
||||||
|
@ -72,25 +72,30 @@ const save = () => {
|
|||||||
.catch(() => window.$message?.warning('请检查表单信息'));
|
.catch(() => window.$message?.warning('请检查表单信息'));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const nodeExpressionFeedback = ref('');
|
||||||
|
|
||||||
const checkNodeExpression = async () => {
|
const checkNodeExpression = async () => {
|
||||||
if (!form.value.decision?.nodeExpression) {
|
if (!form.value.decision?.nodeExpression) {
|
||||||
return Promise.reject(new Error('请填写条件表达式'));
|
nodeExpressionFeedback.value = '请填写条件表达式';
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const { error, data } = await fetchCheckNodeExpression(form.value.decision!);
|
const { error, data } = await fetchCheckNodeExpression(form.value.decision!);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (data.key !== 1) {
|
if (data.key !== 1) {
|
||||||
return Promise.reject(data.value ?? '请检查条件表达式');
|
nodeExpressionFeedback.value = data.value || '请检查条件表达式';
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject(new Error('接口请求失败'));
|
nodeExpressionFeedback.value = '接口请求失败';
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
nodeExpressionFeedback.value = '';
|
||||||
};
|
};
|
||||||
|
|
||||||
const rules: FormRules = {
|
const rules: FormRules = {
|
||||||
decision: {
|
decision: {
|
||||||
expressionType: [{ required: true, message: '请选择表达式类型', trigger: 'change', type: 'number' }],
|
expressionType: [{ required: true, message: '请选择表达式类型', trigger: 'change', type: 'number' }],
|
||||||
nodeExpression: [{ required: true, validator: checkNodeExpression, trigger: 'blur' }]
|
nodeExpression: [{ required: true, message: '请填写条件表达式', trigger: 'blur' }]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@ -132,12 +137,24 @@ const rules: FormRules = {
|
|||||||
</NSpace>
|
</NSpace>
|
||||||
</NRadioGroup>
|
</NRadioGroup>
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem path="decision.nodeExpression" label="条件表达式">
|
<NFormItem
|
||||||
|
path="decision.nodeExpression"
|
||||||
|
label="条件表达式"
|
||||||
|
validation-status="error"
|
||||||
|
:feedback="nodeExpressionFeedback"
|
||||||
|
>
|
||||||
<CodeMirror v-model="form.decision!.nodeExpression" placeholder="请输入条件表达式" />
|
<CodeMirror v-model="form.decision!.nodeExpression" placeholder="请输入条件表达式" />
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem path="decision.checkContents" label="模拟上下文">
|
<NFormItem
|
||||||
|
path="decision.checkContents"
|
||||||
|
label="模拟上下文"
|
||||||
|
:show-feedback="form.decision?.checkContents && form.decision.checkContents.length === 0"
|
||||||
|
>
|
||||||
<DynamicInput v-model:value="form.decision!.checkContents!" path="decision.checkContents" />
|
<DynamicInput v-model:value="form.decision!.checkContents!" path="decision.checkContents" />
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
|
<NFormItem :show-label="false" :show-feedback="false">
|
||||||
|
<NButton type="primary" ghost block @click="checkNodeExpression">校验条件表达式</NButton>
|
||||||
|
</NFormItem>
|
||||||
</NForm>
|
</NForm>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
|
@ -210,7 +210,7 @@ const rules: Record<RuleKey, FormItemRule> = {
|
|||||||
</NFormItem>
|
</NFormItem>
|
||||||
</NGi>
|
</NGi>
|
||||||
</NGrid>
|
</NGrid>
|
||||||
<NFormItem path="wfContext" label="工作流上下文">
|
<NFormItem path="wfContext" label="工作流上下文" :show-feedback="false">
|
||||||
<DynamicInput v-model:value="form.wfContexts!" path="wfContexts" />
|
<DynamicInput v-model:value="form.wfContexts!" path="wfContexts" />
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem path="workflowStatus" label="节点状态">
|
<NFormItem path="workflowStatus" label="节点状态">
|
||||||
|
Loading…
Reference in New Issue
Block a user