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