add 新增流程定义与表单关联

This commit is contained in:
gssong 2023-09-10 13:29:33 +08:00
parent e874069865
commit 3a9c651c28
5 changed files with 319 additions and 13 deletions

View File

@ -3,6 +3,7 @@ export interface FormVO extends BaseEntity {
formName: string; formName: string;
formConfig: string; formConfig: string;
content: string; content: string;
status?: string;
remark: string; remark: string;
} }
@ -11,6 +12,7 @@ export interface FormForm {
formName: string; formName: string;
formConfig?: string; formConfig?: string;
content?: string; content?: string;
status?: string;
remark: string; remark: string;
} }

View File

@ -0,0 +1,63 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FormDefinitionVO, FormDefinitionForm, FormDefinitionQuery } from '@/api/workflow/formDefinition/types';
/**
*
* @param query
* @returns {*}
*/
export const listFormDefinition = (query?: FormDefinitionQuery): AxiosPromise<FormDefinitionVO[]> => {
return request({
url: '/workflow/formDefinition/list',
method: 'get',
params: query
});
};
/**
*
* @param id
*/
export const getFormDefinition = (id: string | number): AxiosPromise<FormDefinitionVO> => {
return request({
url: '/workflow/formDefinition/' + id,
method: 'get'
});
};
/**
*
* @param data
*/
export const addFormDefinition = (data: FormDefinitionForm) => {
return request({
url: '/workflow/formDefinition',
method: 'post',
data: data
});
};
/**
*
* @param data
*/
export const updateFormDefinition = (data: FormDefinitionForm) => {
return request({
url: '/workflow/formDefinition',
method: 'put',
data: data
});
};
/**
*
* @param id
*/
export const delFormDefinition = (id: string | number | Array<string | number>) => {
return request({
url: '/workflow/formDefinition/' + id,
method: 'delete'
});
};

View File

@ -0,0 +1,101 @@
export interface FormDefinitionVO {
/**
*
*/
id: string | number;
/**
* id
*/
formId: string | number;
/**
* id
*/
processDefinitionKey: string;
/**
*
*/
processDefinitionName: string;
/**
* id
*/
processDefinitionId: string | number;
/**
*
*/
processDefinitionVersion: number;
}
export interface FormDefinitionForm extends BaseEntity {
/**
*
*/
id?: string | number;
/**
* id
*/
formId?: string | number;
/**
* id
*/
processDefinitionKey?: string;
/**
*
*/
processDefinitionName?: string;
/**
* id
*/
processDefinitionId?: string | number;
/**
*
*/
processDefinitionVersion?: number;
}
export interface FormDefinitionQuery extends PageQuery {
/**
* id
*/
formId?: string | number;
/**
* id
*/
processDefinitionKey?: string;
/**
*
*/
processDefinitionName?: string;
/**
* id
*/
processDefinitionId?: string | number;
/**
*
*/
processDefinitionVersion?: number;
/**
*
*/
params?: any;
}

View File

@ -109,3 +109,14 @@ export const migrationProcessDefinition = (currentProcessDefinitionId: string, f
method: 'put' method: 'put'
}); });
}; };
/**
*
* @returns
*/
export const getProcessDefinitionList = () => {
return request({
url: `/workflow/processDefinition/getProcessDefinitionList`,
method: 'get'
});
};

View File

@ -1,6 +1,7 @@
<template> <template>
<div class="p-2"> <div class="p-2">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave"> <transition :enter-active-class="proxy?.animate.searchAnimate.enter"
:leave-active-class="proxy?.animate.searchAnimate.leave">
<div class="search" v-show="showSearch"> <div class="search" v-show="showSearch">
<el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="70"> <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="70">
<el-form-item label="表单名称" prop="formName"> <el-form-item label="表单名称" prop="formName">
@ -17,16 +18,20 @@
<template #header> <template #header>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['workflow:form:add']">新增</el-button> <el-button type="primary" plain icon="Plus" @click="handleAdd"
v-hasPermi="['workflow:form:add']">新增</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['workflow:form:edit']">修改</el-button> <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()"
v-hasPermi="['workflow:form:edit']">修改</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['workflow:form:remove']">删除</el-button> <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()"
v-hasPermi="['workflow:form:remove']">删除</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['workflow:form:export']">导出</el-button> <el-button type="warning" plain icon="Download" @click="handleExport"
v-hasPermi="['workflow:form:export']">导出</el-button>
</el-col> </el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -36,22 +41,44 @@
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="表单主键" align="center" prop="formId" v-if="false" /> <el-table-column label="表单主键" align="center" prop="formId" v-if="false" />
<el-table-column label="表单名称" align="center" prop="formName" /> <el-table-column label="表单名称" align="center" prop="formName" />
<el-table-column label="备注" align="center" prop="remark" /> <el-table-column label="状态" align="center" key="status">
<template #default="scope">
<el-switch v-model="scope.row.status" active-value="0" inactive-value="1"
@change="handleStatusChange(scope.row)"></el-switch>
</template>
</el-table-column>
<el-table-column label="流程定义KEY" align="center" prop="wfFormDefinitionVo">
<template #default="scope">
<span v-if="scope.row.wfFormDefinitionVo">{{ scope.row.wfFormDefinitionVo.processDefinitionKey }}</span>
</template>
</el-table-column>
<el-table-column label="流程定义名称" align="center" prop="wfFormDefinitionVo">
<template #default="scope">
<span v-if="scope.row.wfFormDefinitionVo">{{ scope.row.wfFormDefinitionVo.processDefinitionName }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope"> <template #default="scope">
<el-tooltip content="详情" placement="top"> <el-tooltip content="详情" placement="top">
<el-button link type="primary" icon="View" @click="handleDetail(scope.row)" v-hasPermi="['workflow:form:query']"></el-button> <el-button link type="primary" icon="View" @click="handleDetail(scope.row)"
v-hasPermi="['workflow:form:query']"></el-button>
</el-tooltip> </el-tooltip>
<el-tooltip content="修改" placement="top"> <el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['workflow:form:edit']"></el-button> <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
v-hasPermi="['workflow:form:edit']"></el-button>
</el-tooltip> </el-tooltip>
<el-tooltip content="删除" placement="top"> <el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['workflow:form:remove']"></el-button> <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
v-hasPermi="['workflow:form:remove']"></el-button>
</el-tooltip>
<el-tooltip content="绑定流程" placement="top">
<el-button link type="primary" icon="Tickets" @click="handleProcess(scope.row)"></el-button>
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" /> <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card> </el-card>
<!-- 流程表单设计器对话框 --> <!-- 流程表单设计器对话框 -->
@ -88,11 +115,44 @@
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
<el-dialog v-if="processDefinitionDialog.visible" v-model="processDefinitionDialog.visible"
:title="processDefinitionDialog.title" width="70%">
<el-table v-loading="loading" :data="processDefinition.list">
<el-table-column fixed align="center" type="index" label="序号" width="50"></el-table-column>
<el-table-column fixed align="center" prop="name" label="流程定义名称"></el-table-column>
<el-table-column align="center" prop="key" label="标识Key"></el-table-column>
<el-table-column align="center" prop="version" label="版本号" width="90">
<template #default="scope"> v{{ scope.row.version }}.0</template>
</el-table-column>
<el-table-column align="center" prop="suspensionState" label="状态" min-width="70">
<template #default="scope">
<el-tag type="success" v-if="scope.row.suspensionState == 1">激活</el-tag>
<el-tag type="danger" v-else>挂起</el-tag>
</template>
</el-table-column>
<el-table-column align="center" prop="deploymentTime" label="部署时间"
:show-overflow-tooltip="true"></el-table-column>
<el-table-column fixed="right" label="操作" align="center" width="200" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" size="small" @click="handleConfirm(scope.row)">确认绑定</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="processDefinition.total > 0" :total="processDefinition.total"
v-model:page="processQueryParams.pageNum" v-model:limit="processQueryParams.pageSize"
@pagination="getDefinitionList" />
</el-dialog>
</div> </div>
</template> </template>
<script setup name="Form" lang="ts"> <script setup name="Form" lang="ts">
import { listForm, addForm, updateForm, getForm, delForm } from "@/api/workflow/form"; import { listForm, addForm, updateForm, getForm, delForm } from "@/api/workflow/form";
import {
listProcessDefinition
} from '@/api/workflow/processDefinition';
import {
addFormDefinition
} from '@/api/workflow/formDefinition';
import { FormForm, FormQuery, FormVO } from "@/api/workflow/form/types"; import { FormForm, FormQuery, FormVO } from "@/api/workflow/form/types";
import { ComponentInternalInstance } from "vue"; import { ComponentInternalInstance } from "vue";
@ -105,6 +165,14 @@ const ids = ref<Array<number | string>>([]);
const single = ref(true); const single = ref(true);
const multiple = ref(true); const multiple = ref(true);
const total = ref(0); const total = ref(0);
const formId = ref<number | string>();
const processDefinition = reactive<any>({
list: [],
total: 0
});
const vfDesignerRef = ref(null); const vfDesignerRef = ref(null);
const vfRenderRef = ref(null); const vfRenderRef = ref(null);
@ -116,6 +184,11 @@ const designer = reactive<DialogOption>({
title: '' title: ''
}) })
const processDefinitionDialog = reactive<DialogOption>({
visible: false,
title: '流程定义'
});
const designerConfig = reactive({ const designerConfig = reactive({
externalLink: true, externalLink: true,
toolbarMaxWidth: 510, toolbarMaxWidth: 510,
@ -142,11 +215,12 @@ const initFormData: FormForm = {
formName: '', formName: '',
formConfig: '', formConfig: '',
content: '', content: '',
status: '1',
remark: '' remark: ''
} }
const data = reactive<PageData<FormForm, FormQuery>>({ const data = reactive<PageData<FormForm, FormQuery>>({
form: {...initFormData}, form: { ...initFormData },
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
@ -159,6 +233,15 @@ const data = reactive<PageData<FormForm, FormQuery>>({
const { queryParams, form, rules } = toRefs<PageData<FormForm, FormQuery>>(data); const { queryParams, form, rules } = toRefs<PageData<FormForm, FormQuery>>(data);
//
const processQueryParams = ref<Record<string, any>>({
pageNum: 1,
pageSize: 10,
name: undefined,
key: undefined,
categoryCode: undefined
});
/** 查询岗位列表 */ /** 查询岗位列表 */
const getList = async () => { const getList = async () => {
loading.value = true; loading.value = true;
@ -174,7 +257,7 @@ const cancel = () => {
} }
/** 表单重置 */ /** 表单重置 */
const reset = () => { const reset = () => {
form.value = {...initFormData}; form.value = { ...initFormData };
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
@ -195,6 +278,7 @@ const handleSelectionChange = (selection: FormVO[]) => {
/** 新增表单操作 */ /** 新增表单操作 */
const handleAdd = () => { const handleAdd = () => {
designer.visible = true; designer.visible = true;
getDefinitionList()
nextTick(() => { nextTick(() => {
reset(); reset();
vfDesignerRef.value.clearDesigner(); vfDesignerRef.value.clearDesigner();
@ -203,6 +287,7 @@ const handleAdd = () => {
/** 修改表单操作 */ /** 修改表单操作 */
const handleUpdate = (row?: FormVO) => { const handleUpdate = (row?: FormVO) => {
designer.visible = true; designer.visible = true;
getDefinitionList()
nextTick(async () => { nextTick(async () => {
const formId = row?.formId || ids.value[0]; const formId = row?.formId || ids.value[0];
const res = await getForm(formId); const res = await getForm(formId);
@ -210,12 +295,26 @@ const handleUpdate = (row?: FormVO) => {
vfDesignerRef.value.setFormJson(form.value.content); vfDesignerRef.value.setFormJson(form.value.content);
}) })
} }
//
const handleStatusChange = async (row: FormVO) => {
let text = row.status === "0" ? "启用" : "停用"
try {
form.value = row
form.value.status === "0" ? "1" : "0";
await proxy?.$modal.confirm('确认要' + text + '【' + row.formName + '】表单?');
await updateForm(row);
proxy?.$modal.msgSuccess(text + "成功");
getList()
} catch (err) {
row.status = row.status === "0" ? "1" : "0";
}
}
/** 查看表单操作 */ /** 查看表单操作 */
const handleDetail = (row: FormVO) => { const handleDetail = (row: FormVO) => {
render.visible = true; render.visible = true;
render.title = '查看表单详情'; render.title = '查看表单详情';
nextTick(async () => { nextTick(async () => {
vfRenderRef.value.setFormJson(row.content || {formConfig: {}, widgetList: []}); vfRenderRef.value.setFormJson(row.content || { formConfig: {}, widgetList: [] });
}); });
} }
@ -246,7 +345,35 @@ const submitForm = () => {
getList(); getList();
}) })
} }
//
const getDefinitionList = () => {
listProcessDefinition(processQueryParams.value).then(res => {
processDefinition.list = res.rows
processDefinition.total = res.total;
loading.value = false;
})
}
const handleProcess = async (row?: FormVO) => {
formId.value = row?.formId
processDefinitionDialog.visible = true
getDefinitionList()
}
//
const handleConfirm = async (row?: any) => {
await proxy?.$modal.confirm('是否确认绑定【' + row.key + '】?');
let data = {
formId: formId.value,
processDefinitionKey: row.key,
processDefinitionName: row.name,
processDefinitionId: row.id,
processDefinitionVersion: row.version
}
await addFormDefinition(data);
processDefinitionDialog.visible = false
getList();
proxy?.$modal.msgSuccess("绑定成功");
}
onMounted(() => { onMounted(() => {
getList(); getList();
}); });
@ -257,9 +384,11 @@ onMounted(() => {
.main-container { .main-container {
margin: 0; margin: 0;
} }
label { label {
font-weight: normal; font-weight: normal;
} }
:deep(.external-link) { :deep(.external-link) {
display: flex; display: flex;
align-items: center; align-items: center;