mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat(projects): 流程实例添加变量修改功能
This commit is contained in:
@ -59,3 +59,20 @@ export function fetchGetMyDocument(data: Api.Workflow.InstanceSearchParams) {
|
|||||||
params: data
|
params: data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 更新流程变量信息 */
|
||||||
|
export function fetchUpdateInstanceVariable(data: Api.Workflow.InstanceVariableOperateParams) {
|
||||||
|
return request<boolean>({
|
||||||
|
url: '/workflow/instance/updateVariable',
|
||||||
|
method: 'put',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取流程变量信息 */
|
||||||
|
export function fetchGetInstanceVariable(instanceId: CommonType.IdType) {
|
||||||
|
return request<Api.Workflow.InstanceVariableInfo>({
|
||||||
|
url: `/workflow/instance/instanceVariable/${instanceId}`,
|
||||||
|
method: 'get'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
28
src/typings/api/workflow.api.d.ts
vendored
28
src/typings/api/workflow.api.d.ts
vendored
@ -175,6 +175,23 @@ declare namespace Api {
|
|||||||
/** definition list */
|
/** definition list */
|
||||||
type DefinitionList = Api.Common.PaginatingQueryRecord<Definition>;
|
type DefinitionList = Api.Common.PaginatingQueryRecord<Definition>;
|
||||||
|
|
||||||
|
type InstanceVariable = CommonType.RecordNullable<{
|
||||||
|
key: string;
|
||||||
|
value: string;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
type InstanceVariableOperateParams = CommonType.RecordNullable<{
|
||||||
|
instanceId: CommonType.IdType;
|
||||||
|
}> &
|
||||||
|
InstanceVariable;
|
||||||
|
|
||||||
|
type InstanceVariableInfo = CommonType.RecordNullable<{
|
||||||
|
/** 键 */
|
||||||
|
variable: string;
|
||||||
|
/** 值 */
|
||||||
|
variableList: InstanceVariable[];
|
||||||
|
}>;
|
||||||
|
|
||||||
/** 节点类型 */
|
/** 节点类型 */
|
||||||
type WorkflowNodeType = 0 | 1 | 2 | 3 | 4;
|
type WorkflowNodeType = 0 | 1 | 2 | 3 | 4;
|
||||||
|
|
||||||
@ -199,6 +216,10 @@ declare namespace Api {
|
|||||||
flowCode: string;
|
flowCode: string;
|
||||||
/** 业务ID */
|
/** 业务ID */
|
||||||
businessId: CommonType.IdType;
|
businessId: CommonType.IdType;
|
||||||
|
/** 业务编码 */
|
||||||
|
businessCode: string;
|
||||||
|
/** 业务名称 */
|
||||||
|
businessName: string;
|
||||||
/** 节点类型 */
|
/** 节点类型 */
|
||||||
nodeType: WorkflowNodeType;
|
nodeType: WorkflowNodeType;
|
||||||
/** 节点编码 */
|
/** 节点编码 */
|
||||||
@ -221,15 +242,8 @@ declare namespace Api {
|
|||||||
ext: string;
|
ext: string;
|
||||||
/** 流程定义版本 */
|
/** 流程定义版本 */
|
||||||
version: string;
|
version: string;
|
||||||
/** 创建者 */
|
|
||||||
createBy: string;
|
|
||||||
/** 创建者名称 */
|
/** 创建者名称 */
|
||||||
createByName: string;
|
createByName: string;
|
||||||
/** 创建时间 */
|
|
||||||
createTime: string;
|
|
||||||
|
|
||||||
/** 更新时间 */
|
|
||||||
updateTime: string;
|
|
||||||
/** 删除标志 */
|
/** 删除标志 */
|
||||||
delFlag: number;
|
delFlag: number;
|
||||||
}>;
|
}>;
|
||||||
|
@ -67,6 +67,18 @@ const baseColumns = ref<NaiveUI.TableColumn<Api.Workflow.Instance>[]>([
|
|||||||
align: 'center',
|
align: 'center',
|
||||||
width: 48
|
width: 48
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'businessCode',
|
||||||
|
title: '业务编码',
|
||||||
|
align: 'center',
|
||||||
|
width: 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'businessName',
|
||||||
|
title: '业务名称',
|
||||||
|
align: 'center',
|
||||||
|
width: 120
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'flowName',
|
key: 'flowName',
|
||||||
title: '流程名称',
|
title: '流程名称',
|
||||||
@ -109,7 +121,7 @@ const baseColumns = ref<NaiveUI.TableColumn<Api.Workflow.Instance>[]>([
|
|||||||
key: 'activityStatus',
|
key: 'activityStatus',
|
||||||
title: '状态',
|
title: '状态',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 100,
|
minWidth: 80,
|
||||||
render(row) {
|
render(row) {
|
||||||
return (
|
return (
|
||||||
<NTag type={row.activityStatus === 0 ? 'warning' : 'success'}>
|
<NTag type={row.activityStatus === 0 ? 'warning' : 'success'}>
|
||||||
@ -122,7 +134,7 @@ const baseColumns = ref<NaiveUI.TableColumn<Api.Workflow.Instance>[]>([
|
|||||||
key: 'flowStatus',
|
key: 'flowStatus',
|
||||||
title: '流程状态',
|
title: '流程状态',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 100,
|
minWidth: 80,
|
||||||
render(row) {
|
render(row) {
|
||||||
return <DictTag value={row.flowStatus} dictCode="wf_business_status" />;
|
return <DictTag value={row.flowStatus} dictCode="wf_business_status" />;
|
||||||
}
|
}
|
||||||
@ -242,7 +254,7 @@ const {
|
|||||||
: [...baseColumns.value, ...finishColumns.value, ...operateColumns.value]
|
: [...baseColumns.value, ...finishColumns.value, ...operateColumns.value]
|
||||||
});
|
});
|
||||||
|
|
||||||
const { checkedRowKeys, editingData, handleEdit, onBatchDeleted, onDeleted } = useTableOperate(data, getData);
|
const { checkedRowKeys, onBatchDeleted, onDeleted } = useTableOperate(data, getData);
|
||||||
// 监听运行状态变化
|
// 监听运行状态变化
|
||||||
watch(runningStatus, async () => {
|
watch(runningStatus, async () => {
|
||||||
const newApiFn = runningStatus.value ? fetchGetRunningInstanceList : fetchGetFinishedInstanceList;
|
const newApiFn = runningStatus.value ? fetchGetRunningInstanceList : fetchGetFinishedInstanceList;
|
||||||
@ -256,7 +268,7 @@ const categoryPattern = ref<string>();
|
|||||||
const categoryData = ref<Api.Common.CommonTreeRecord>([]);
|
const categoryData = ref<Api.Common.CommonTreeRecord>([]);
|
||||||
const selectedKeys = ref<string[]>([]);
|
const selectedKeys = ref<string[]>([]);
|
||||||
const expandedKeys = ref<CommonType.IdType[]>(['100']);
|
const expandedKeys = ref<CommonType.IdType[]>(['100']);
|
||||||
|
const instanceRowId = ref<CommonType.IdType>();
|
||||||
const selectable = computed(() => {
|
const selectable = computed(() => {
|
||||||
return !loading.value;
|
return !loading.value;
|
||||||
});
|
});
|
||||||
@ -312,7 +324,7 @@ async function handleCancel(instanceId: CommonType.IdType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleShowVariable(id: CommonType.IdType) {
|
async function handleShowVariable(id: CommonType.IdType) {
|
||||||
handleEdit('id', id);
|
instanceRowId.value = id;
|
||||||
showVariableDrawer();
|
showVariableDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,7 +421,7 @@ async function handlePreview(row: Api.Workflow.Instance) {
|
|||||||
class="sm:h-full"
|
class="sm:h-full"
|
||||||
/>
|
/>
|
||||||
<component :is="dynamicComponent" :visible="previewVisible" operate-type="detail" :business-id="businessId" />
|
<component :is="dynamicComponent" :visible="previewVisible" operate-type="detail" :business-id="businessId" />
|
||||||
<InstanceVariableModal v-model:visible="variableVisible" :row-data="editingData" />
|
<InstanceVariableModal v-model:visible="variableVisible" :instance-id="instanceRowId!" />
|
||||||
</NCard>
|
</NCard>
|
||||||
</div>
|
</div>
|
||||||
</TableSiderLayout>
|
</TableSiderLayout>
|
||||||
|
@ -1,23 +1,88 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { reactive, ref, watch } from 'vue';
|
||||||
|
import { useLoading } from '@sa/hooks';
|
||||||
|
import { fetchGetInstanceVariable, fetchUpdateInstanceVariable } from '@/service/api/workflow/instance';
|
||||||
|
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
||||||
import JsonPreview from '@/components/custom/json-preview.vue';
|
import JsonPreview from '@/components/custom/json-preview.vue';
|
||||||
|
import { $t } from '@/locales';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'InstanceVariableModal'
|
name: 'InstanceVariableModal'
|
||||||
});
|
});
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
rowData: Api.Workflow.Instance | null;
|
instanceId: CommonType.IdType;
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
|
const { formRef, validate, restoreValidation } = useNaiveForm();
|
||||||
|
const { createRequiredRule } = useFormRules();
|
||||||
|
const { loading: updateLoading, startLoading: startUpdateLoading, endLoading: endUpdateLoading } = useLoading();
|
||||||
|
|
||||||
const visible = defineModel<boolean>('visible', {
|
const visible = defineModel<boolean>('visible', {
|
||||||
default: false
|
default: false
|
||||||
});
|
});
|
||||||
|
const variableOptions = ref<CommonType.Option<string>[]>([]);
|
||||||
|
|
||||||
|
const instanceVariableInfo = ref<Api.Workflow.InstanceVariableInfo>();
|
||||||
|
|
||||||
|
type Model = Api.Workflow.InstanceVariableOperateParams;
|
||||||
|
|
||||||
|
const model: Model = reactive(createDefaultModel());
|
||||||
|
|
||||||
|
function createDefaultModel(): Model {
|
||||||
|
return {
|
||||||
|
instanceId: props.instanceId,
|
||||||
|
key: null,
|
||||||
|
value: ''
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
type RuleKey = Extract<keyof Model, 'key' | 'value'>;
|
||||||
|
|
||||||
|
const rules: Record<RuleKey, App.Global.FormRule> = {
|
||||||
|
key: createRequiredRule('变量KEY不能为空'),
|
||||||
|
value: createRequiredRule('变量值不能为空')
|
||||||
|
};
|
||||||
|
|
||||||
function closeDrawer() {
|
function closeDrawer() {
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getInstanceVariable() {
|
||||||
|
startUpdateLoading();
|
||||||
|
const { error, data } = await fetchGetInstanceVariable(props.instanceId);
|
||||||
|
if (error) return;
|
||||||
|
instanceVariableInfo.value = data;
|
||||||
|
if (data.variableList) {
|
||||||
|
variableOptions.value = data.variableList.map(item => ({
|
||||||
|
label: item.key!,
|
||||||
|
value: item.key!
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
endUpdateLoading();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleUpdateModelWhenEdit() {
|
||||||
|
Object.assign(model, createDefaultModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
await validate();
|
||||||
|
// request
|
||||||
|
const { error } = await fetchUpdateInstanceVariable(model);
|
||||||
|
if (error) return;
|
||||||
|
window.$message?.success($t('common.updateSuccess'));
|
||||||
|
await getInstanceVariable();
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(visible, () => {
|
||||||
|
if (visible.value) {
|
||||||
|
getInstanceVariable();
|
||||||
|
handleUpdateModelWhenEdit();
|
||||||
|
restoreValidation();
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -30,9 +95,27 @@ function closeDrawer() {
|
|||||||
class="max-w-90% w-600px"
|
class="max-w-90% w-600px"
|
||||||
@close="closeDrawer"
|
@close="closeDrawer"
|
||||||
>
|
>
|
||||||
<JsonPreview :code="props.rowData?.variable"></JsonPreview>
|
<NSpin :show="updateLoading">
|
||||||
|
<NSpace vertical :size="16">
|
||||||
|
<div class="max-h-300px overflow-auto">
|
||||||
|
<JsonPreview :code="instanceVariableInfo?.variable as string" />
|
||||||
|
</div>
|
||||||
|
<NDivider>变量管理</NDivider>
|
||||||
|
<NForm ref="formRef" :model="model" :rules="rules">
|
||||||
|
<NGrid responsive="screen" item-responsive>
|
||||||
|
<NFormItemGi span="24 s:12 m:12" label="变量KEY" path="key" class="pr-24px">
|
||||||
|
<NSelect v-model:value="model.key" clearable :options="variableOptions" placeholder="请选择变量KEY" />
|
||||||
|
</NFormItemGi>
|
||||||
|
<NFormItemGi span="24 s:12 m:12" label="变量值" path="value" class="pr-24px">
|
||||||
|
<NInput v-model:value="model.value" placeholder="请输入变量值" />
|
||||||
|
</NFormItemGi>
|
||||||
|
</NGrid>
|
||||||
|
</NForm>
|
||||||
|
</NSpace>
|
||||||
|
</NSpin>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<NSpace justify="end" :size="16">
|
<NSpace justify="end" :size="16">
|
||||||
|
<NButton type="primary" @click="handleSubmit">{{ $t('common.confirm') }}</NButton>
|
||||||
<NButton @click="closeDrawer">{{ $t('common.close') }}</NButton>
|
<NButton @click="closeDrawer">{{ $t('common.close') }}</NButton>
|
||||||
</NSpace>
|
</NSpace>
|
||||||
</template>
|
</template>
|
||||||
|
Reference in New Issue
Block a user