BPM 模型重构 1:新建流程时,只填写 name、description、key

pull/2/head
YunaiV 2022-01-11 20:17:01 +08:00
parent e863b60300
commit c4950e1b13
9 changed files with 132 additions and 57 deletions

View File

@ -56,7 +56,7 @@ public class BpmModelController {
public CommonResult<String> importModel(@Valid BpmModeImportReqVO importReqVO) throws IOException {
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));
}

View File

@ -10,12 +10,17 @@ import javax.validation.constraints.NotEmpty;
@ApiModel("流程模型的创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class BpmModelCreateReqVO extends BpmModelBaseVO {
public class BpmModelCreateReqVO {
@ApiModelProperty(value = "BPMN XML", required = true)
@NotEmpty(message = "BPMN XML 不能为空")
private String bpmnXml;
@ApiModelProperty(value = "流程标识", required = true, example = "process_yudao")
@NotEmpty(message = "流程标识不能为空")
private String key;
@ApiModelProperty(value = "流程名称", required = true, example = "芋道")
@NotEmpty(message = "流程名称不能为空")
private String name;
@ApiModelProperty(value = "流程描述", example = "我是描述")
private String description;
}

View File

@ -18,8 +18,19 @@ public class BpmModelUpdateReqVO extends BpmModelBaseVO {
@NotEmpty(message = "编号不能为空")
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)
@NotEmpty(message = "BPMN XML 不能为空")
private String bpmnXml;
}

View File

@ -95,8 +95,7 @@ public interface BpmModelConvert {
default void copy(Model model, BpmModelCreateReqVO bean) {
model.setName(bean.getName());
model.setKey(bean.getKey());
model.setCategory(bean.getCategory());
model.setMetaInfo(JsonUtils.toJsonString(this.buildMetaInfo(bean.getDescription(), bean.getFormId())));
model.setMetaInfo(JsonUtils.toJsonString(this.buildMetaInfo(bean.getDescription(), null)));
}
default void copy(Model model, BpmModelUpdateReqVO bean) {

View File

@ -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;
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto;
import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmModelFormTypeEnum;
import lombok.Data;
/**
@ -15,9 +16,24 @@ public class BpmModelMetaInfoRespDTO {
*
*/
private String description;
/**
*
*/
private Long formType;
/**
*
* {@link BpmModelFormTypeEnum#NORMAL}
*/
private Long formId;
/**
* 使 Vue
* {@link BpmModelFormTypeEnum#CUSTOM}
*/
private String formCustomSubmitPath;
/**
* 使 Vue
* {@link BpmModelFormTypeEnum#CUSTOM}
*/
private String formCustomViewPath;
}

View File

@ -121,15 +121,12 @@ public class BpmModelServiceImpl implements BpmModelService {
BpmModelConvert.INSTANCE.copy(model, createReqVO);
// 保存流程定义
repositoryService.saveModel(model);
// 添加 BPMN XML
repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(createReqVO.getBpmnXml()));
return model.getId();
}
@Override
@Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务
public void updateModel(BpmModelUpdateReqVO updateReqVO) {
checkKeyNCName(updateReqVO.getKey());
// 校验流程模型存在
Model model = repositoryService.getModel(updateReqVO.getId());
if (model == null) {

View File

@ -109,51 +109,50 @@
<my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" />
</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-upload
ref="upload"
:limit="1"
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
>
<el-upload ref="upload" :limit="1" 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>
<div class="el-upload__text">
将文件拖到此处
<em>点击上传</em>
</div>
<div class="el-upload__tip" style="color:red" slot="tip">提示仅允许导入bpmxml格式文件</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">
<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-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 label="流程名称" prop="name">
<el-input v-model="upload.form.name" placeholder="请输入流程名称" clearable />
</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-input type="textarea" v-model="upload.form.description" clearable />
</el-form-item>
@ -169,14 +168,12 @@
</template>
<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 {getForm, getSimpleForms} from "@/api/bpm/form";
import {decodeFields} from "@/utils/formGenerator";
import Parser from '@/components/parser/Parser'
import {getToken} from "@/utils/auth";
import {getBaseHeader} from "@/utils/request";
import {addUser, updateUser} from "@/api/system/user";
export default {
name: "model",
@ -212,6 +209,15 @@ export default {
fields: []
},
//
open: false,
form: {},
//
rules: {
key: [{ required: true, message: "流程标识不能为空", trigger: "blur" }],
name: [{ required: true, message: "流程名称不能为空", trigger: "blur" }],
},
//
upload: {
//
@ -228,7 +234,6 @@ export default {
rules: {
key: [{ 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() {
this.bpmnData = {}
this.bpmnXML = ""
this.form = {
key: undefined,
name: undefined,
description: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
@ -274,9 +288,8 @@ export default {
},
/** 新增按钮操作 */
handleAdd() {
this.$router.push({
path:"/bpm/manager/model/edit"
});
this.reset();
this.open = true;
},
/** 修改按钮操作 */
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) {
const that = this;