BPM 模型重构 1:新建流程时,只填写 name、description、key
parent
e863b60300
commit
c4950e1b13
|
@ -56,7 +56,7 @@ public class BpmModelController {
|
||||||
public CommonResult<String> importModel(@Valid BpmModeImportReqVO importReqVO) throws IOException {
|
public CommonResult<String> importModel(@Valid BpmModeImportReqVO importReqVO) throws IOException {
|
||||||
BpmModelCreateReqVO createReqVO = BpmModelConvert.INSTANCE.convert(importReqVO);
|
BpmModelCreateReqVO createReqVO = BpmModelConvert.INSTANCE.convert(importReqVO);
|
||||||
// 读取文件
|
// 读取文件
|
||||||
createReqVO.setBpmnXml(IoUtils.readUtf8(importReqVO.getBpmnFile().getInputStream(), false));
|
// createReqVO.setBpmnXml(IoUtils.readUtf8(importReqVO.getBpmnFile().getInputStream(), false));
|
||||||
return success(bpmModelService.createModel(createReqVO));
|
return success(bpmModelService.createModel(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,17 @@ import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
@ApiModel("流程模型的创建 Request VO")
|
@ApiModel("流程模型的创建 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
public class BpmModelCreateReqVO {
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class BpmModelCreateReqVO extends BpmModelBaseVO {
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "BPMN XML", required = true)
|
@ApiModelProperty(value = "流程标识", required = true, example = "process_yudao")
|
||||||
@NotEmpty(message = "BPMN XML 不能为空")
|
@NotEmpty(message = "流程标识不能为空")
|
||||||
private String bpmnXml;
|
private String key;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程名称", required = true, example = "芋道")
|
||||||
|
@NotEmpty(message = "流程名称不能为空")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程描述", example = "我是描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,19 @@ public class BpmModelUpdateReqVO extends BpmModelBaseVO {
|
||||||
@NotEmpty(message = "编号不能为空")
|
@NotEmpty(message = "编号不能为空")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程名称", example = "芋道")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程描述", example = "我是描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程分类", notes = "参见 bpm_model_category 数据字典", example = "1")
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "表单编号", example = "1024")
|
||||||
|
private Long formId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "BPMN XML", required = true)
|
@ApiModelProperty(value = "BPMN XML", required = true)
|
||||||
@NotEmpty(message = "BPMN XML 不能为空")
|
|
||||||
private String bpmnXml;
|
private String bpmnXml;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,8 +95,7 @@ public interface BpmModelConvert {
|
||||||
default void copy(Model model, BpmModelCreateReqVO bean) {
|
default void copy(Model model, BpmModelCreateReqVO bean) {
|
||||||
model.setName(bean.getName());
|
model.setName(bean.getName());
|
||||||
model.setKey(bean.getKey());
|
model.setKey(bean.getKey());
|
||||||
model.setCategory(bean.getCategory());
|
model.setMetaInfo(JsonUtils.toJsonString(this.buildMetaInfo(bean.getDescription(), null)));
|
||||||
model.setMetaInfo(JsonUtils.toJsonString(this.buildMetaInfo(bean.getDescription(), bean.getFormId())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default void copy(Model model, BpmModelUpdateReqVO bean) {
|
default void copy(Model model, BpmModelUpdateReqVO bean) {
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package cn.iocoder.yudao.adminserver.modules.bpm.enums.definition;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BPM 模型的表单类型的枚举
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum BpmModelFormTypeEnum {
|
||||||
|
|
||||||
|
NORMAL(10, "流程表单"), // 对应 BpmFormDO
|
||||||
|
CUSTOM(20, "业务表单") // 业务自己定义的表单,自己进行数据的存储
|
||||||
|
;
|
||||||
|
|
||||||
|
private final Integer type;
|
||||||
|
private final String desc;
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto;
|
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmModelFormTypeEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,9 +16,24 @@ public class BpmModelMetaInfoRespDTO {
|
||||||
* 流程描述
|
* 流程描述
|
||||||
*/
|
*/
|
||||||
private String description;
|
private String description;
|
||||||
|
/**
|
||||||
|
* 表单类型
|
||||||
|
*/
|
||||||
|
private Long formType;
|
||||||
/**
|
/**
|
||||||
* 表单编号
|
* 表单编号
|
||||||
|
* 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时
|
||||||
*/
|
*/
|
||||||
private Long formId;
|
private Long formId;
|
||||||
|
/**
|
||||||
|
* 自定义表单的提交路径,使用 Vue 的路由地址
|
||||||
|
* 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时
|
||||||
|
*/
|
||||||
|
private String formCustomSubmitPath;
|
||||||
|
/**
|
||||||
|
* 自定义表单的查看路径,使用 Vue 的路由地址
|
||||||
|
* 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时
|
||||||
|
*/
|
||||||
|
private String formCustomViewPath;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,15 +121,12 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||||
BpmModelConvert.INSTANCE.copy(model, createReqVO);
|
BpmModelConvert.INSTANCE.copy(model, createReqVO);
|
||||||
// 保存流程定义
|
// 保存流程定义
|
||||||
repositoryService.saveModel(model);
|
repositoryService.saveModel(model);
|
||||||
// 添加 BPMN XML
|
|
||||||
repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(createReqVO.getBpmnXml()));
|
|
||||||
return model.getId();
|
return model.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务
|
@Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务
|
||||||
public void updateModel(BpmModelUpdateReqVO updateReqVO) {
|
public void updateModel(BpmModelUpdateReqVO updateReqVO) {
|
||||||
checkKeyNCName(updateReqVO.getKey());
|
|
||||||
// 校验流程模型存在
|
// 校验流程模型存在
|
||||||
Model model = repositoryService.getModel(updateReqVO.getId());
|
Model model = repositoryService.getModel(updateReqVO.getId());
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
|
|
|
@ -109,51 +109,50 @@
|
||||||
<my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" />
|
<my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 对话框(添加) -->
|
||||||
|
<el-dialog title="新建模型" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="流程标识" prop="key">
|
||||||
|
<el-input v-model="form.key" placeholder="请输入流标标识" style="width: 350px;" />
|
||||||
|
<el-tooltip class="item" effect="light" content="新建后,流程标识不可修改!" placement="top">
|
||||||
|
<i style="padding-left: 5px;" class="el-icon-question" />
|
||||||
|
</el-tooltip>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="流程名称" prop="name">
|
||||||
|
<el-input v-model="form.name" placeholder="请输入流程名称" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="流程描述" prop="description">
|
||||||
|
<el-input type="textarea" v-model="form.description" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
<!-- 用户导入对话框 -->
|
<!-- 用户导入对话框 -->
|
||||||
<el-dialog title="导入流程模型" :visible.sync="upload.open" width="400px" append-to-body>
|
<el-dialog title="导入流程模型" :visible.sync="upload.open" width="400px" append-to-body>
|
||||||
<el-upload
|
<el-upload ref="upload" :limit="1" accept=".bpmn, .xml" :headers="upload.headers" :action="upload.url"
|
||||||
ref="upload"
|
:disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess"
|
||||||
:limit="1"
|
:auto-upload="false" name="bpmnFile" :data="upload.form" drag>
|
||||||
accept=".bpmn, .xml"
|
|
||||||
:headers="upload.headers"
|
|
||||||
:action="upload.url"
|
|
||||||
:disabled="upload.isUploading"
|
|
||||||
:on-progress="handleFileUploadProgress"
|
|
||||||
:on-success="handleFileSuccess"
|
|
||||||
:auto-upload="false"
|
|
||||||
name="bpmnFile"
|
|
||||||
:data="upload.form"
|
|
||||||
drag
|
|
||||||
>
|
|
||||||
<i class="el-icon-upload"></i>
|
<i class="el-icon-upload"></i>
|
||||||
<div class="el-upload__text">
|
<div class="el-upload__text">
|
||||||
将文件拖到此处,或
|
将文件拖到此处,或
|
||||||
<em>点击上传</em>
|
<em>点击上传</em>
|
||||||
</div>
|
</div>
|
||||||
<div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“bpm”或“xml”格式文件!</div>
|
<div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“bpm”或“xml”格式文件!</div>
|
||||||
|
|
||||||
<!-- <div class="el-upload__tip" slot="tip">-->
|
|
||||||
<!-- 流程名称:<el-input v-model="upload.name"/>-->
|
|
||||||
<!-- 流程分类:<el-input v-model="upload.category"/>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<div class="el-upload__tip" slot="tip">
|
<div class="el-upload__tip" slot="tip">
|
||||||
<el-form ref="uploadForm" size="mini" label-width="90px" :model="upload.form" :rules="upload.rules" @submit.native.prevent>
|
<el-form ref="uploadForm" size="mini" label-width="90px" :model="upload.form" :rules="upload.rules" @submit.native.prevent>
|
||||||
<el-form-item label="流程标识" prop="key">
|
<el-form-item label="流程标识" prop="key">
|
||||||
<el-input v-model="upload.form.key" placeholder="请输入流标标识" />
|
<el-input v-model="upload.form.key" placeholder="请输入流标标识" style="width: 250px;" />
|
||||||
|
<el-tooltip class="item" effect="light" content="新建后,流程标识不可修改!" placement="top">
|
||||||
|
<i style="padding-left: 5px;" class="el-icon-question" />
|
||||||
|
</el-tooltip>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="流程名称" prop="name">
|
<el-form-item label="流程名称" prop="name">
|
||||||
<el-input v-model="upload.form.name" placeholder="请输入流程名称" clearable />
|
<el-input v-model="upload.form.name" placeholder="请输入流程名称" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="流程分类" prop="category">
|
|
||||||
<el-select v-model="upload.form.category" placeholder="请选择流程分类" clearable style="width: 100%">
|
|
||||||
<el-option v-for="dict in categoryDictDatas" :key="dict.value" :label="dict.label" :value="dict.value"/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="流程表单" prop="formId">
|
|
||||||
<el-select v-model="upload.form.formId" placeholder="请选择流程表单,非必选哟!" clearable style="width: 100%">
|
|
||||||
<el-option v-for="form in forms" :key="form.id" :label="form.name" :value="form.id"/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="流程描述" prop="description">
|
<el-form-item label="流程描述" prop="description">
|
||||||
<el-input type="textarea" v-model="upload.form.description" clearable />
|
<el-input type="textarea" v-model="upload.form.description" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -169,14 +168,12 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {deleteModel, deployModel, getModelPage, getModel, updateModelState} from "@/api/bpm/model";
|
import {deleteModel, deployModel, getModelPage, getModel, updateModelState, createModel} from "@/api/bpm/model";
|
||||||
import {DICT_TYPE, getDictDatas} from "@/utils/dict";
|
import {DICT_TYPE, getDictDatas} from "@/utils/dict";
|
||||||
import {getForm, getSimpleForms} from "@/api/bpm/form";
|
import {getForm, getSimpleForms} from "@/api/bpm/form";
|
||||||
import {decodeFields} from "@/utils/formGenerator";
|
import {decodeFields} from "@/utils/formGenerator";
|
||||||
import Parser from '@/components/parser/Parser'
|
import Parser from '@/components/parser/Parser'
|
||||||
import {getToken} from "@/utils/auth";
|
|
||||||
import {getBaseHeader} from "@/utils/request";
|
import {getBaseHeader} from "@/utils/request";
|
||||||
import {addUser, updateUser} from "@/api/system/user";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "model",
|
name: "model",
|
||||||
|
@ -212,6 +209,15 @@ export default {
|
||||||
fields: []
|
fields: []
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 流程表单
|
||||||
|
open: false,
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
key: [{ required: true, message: "流程标识不能为空", trigger: "blur" }],
|
||||||
|
name: [{ required: true, message: "流程名称不能为空", trigger: "blur" }],
|
||||||
|
},
|
||||||
|
|
||||||
// 流程导入参数
|
// 流程导入参数
|
||||||
upload: {
|
upload: {
|
||||||
// 是否显示弹出层(用户导入)
|
// 是否显示弹出层(用户导入)
|
||||||
|
@ -228,7 +234,6 @@ export default {
|
||||||
rules: {
|
rules: {
|
||||||
key: [{ required: true, message: "流程标识不能为空", trigger: "blur" }],
|
key: [{ required: true, message: "流程标识不能为空", trigger: "blur" }],
|
||||||
name: [{ required: true, message: "流程名称不能为空", trigger: "blur" }],
|
name: [{ required: true, message: "流程名称不能为空", trigger: "blur" }],
|
||||||
category: [{ required: true, message: "流程分类不能为空", trigger: "blur" }],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// 流程表单的下拉框的数据
|
// 流程表单的下拉框的数据
|
||||||
|
@ -256,10 +261,19 @@ export default {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
/** 取消按钮 */
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
// 表单重置
|
// 表单重置
|
||||||
reset() {
|
reset() {
|
||||||
this.bpmnData = {}
|
this.form = {
|
||||||
this.bpmnXML = ""
|
key: undefined,
|
||||||
|
name: undefined,
|
||||||
|
description: undefined
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
},
|
},
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
|
@ -274,9 +288,8 @@ export default {
|
||||||
},
|
},
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
handleAdd() {
|
handleAdd() {
|
||||||
this.$router.push({
|
this.reset();
|
||||||
path:"/bpm/manager/model/edit"
|
this.open = true;
|
||||||
});
|
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
|
@ -287,6 +300,19 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
createModel(this.form).then(response => {
|
||||||
|
this.msgSuccess("新增成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
const that = this;
|
const that = this;
|
||||||
|
|
Loading…
Reference in New Issue