当前位置:   article > 正文

基于RuoYi-Flowable-Plus的若依ruoyi-nbcio支持自定义业务表单流程(二)_若依工作流表格开发

若依工作流表格开发

更多ruoyi-nbcio功能请看演示系统

gitee源代码地址

前后端代码: https://gitee.com/nbacheng/ruoyi-nbcio

演示地址:RuoYi-Nbcio后台管理系统

     之前讲到了流程保存的时候还要看是否是自定义业务流程应用类型,若是保存的时候不再检查是否有关联表单。  

    那接下来就需要一个自己进行自定义表的流程关联工作了。

1、见下图,在流程管理里增加一个业务表单,就是进行自定义业务表单与流程的关联

具体相关内容可以看我的另外一个nbcio-boot项目,基本上是一样的。

1、前端增加一个mixins  flowableMixin 

  1. import Vue from 'vue'
  2. export const flowableMixin = {
  3. components: {
  4. },
  5. data(){
  6. return {
  7. customformList: [],
  8. formQueryParams:{
  9. pageNum: 1,
  10. pageSize: 1000,
  11. },
  12. }
  13. },
  14. created() {
  15. },
  16. computed:{
  17. /*所有的自定义业务流程表单,组件化注册,在此维护*/
  18. allFormComponent:function(){
  19. return [
  20. {
  21. text:'单表示例',
  22. routeName: '@/views/workflow/demo/wf',
  23. component: () => import('@/views/workflow/demo/wf'),
  24. businessTable:'wf_demo'
  25. },
  26. /*{
  27. text:'主子表示例',
  28. routeName:'@/views/workflow/demo/modules/CesOrderMainForm',
  29. component:() => import(`@/views/workflow/demo/modules/CesOrderMainForm`),
  30. businessTable:'ces_order_main'
  31. }*/
  32. ]
  33. }
  34. },
  35. methods:{
  36. getFormComponent(routeName){
  37. return _.find(this.allFormComponent,{routeName:routeName})||{};
  38. },
  39. handleTableChange(pagination, filters, sorter) {
  40. //分页、排序、筛选变化时触发
  41. //TODO 筛选
  42. if (Object.keys(sorter).length > 0) {
  43. this.isorter.column = sorter.field;
  44. this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
  45. }
  46. this.ipagination = pagination;
  47. // this.loadData();
  48. },
  49. millsToTime(mills) {
  50. if (!mills) {
  51. return "";
  52. }
  53. let s = mills / 1000;
  54. if (s < 60) {
  55. return s.toFixed(0) + " 秒"
  56. }
  57. let m = s / 60;
  58. if (m < 60) {
  59. return m.toFixed(0) + " 分钟"
  60. }
  61. let h = m / 60;
  62. if (h < 24) {
  63. return h.toFixed(0) + " 小时"
  64. }
  65. let d = h / 24;
  66. if (d < 30) {
  67. return d.toFixed(0) + " 天"
  68. }
  69. let month = d / 30
  70. if (month < 12) {
  71. return month.toFixed(0) + " 个月"
  72. }
  73. let year = month / 12
  74. return year.toFixed(0) + " 年"
  75. },
  76. }
  77. }

2、detail里增加下面内容

  1. <div v-if="customForm.visible"> <!-- 自定义表单 -->
  2. <!--<component ref="refCustomForm" :disabled="customForm.disabled" v-bind:is="customForm.formComponent" :model="customForm.model"
  3. :customFormData="customForm.customFormData" :isNew = "customForm.isNew"></component> -->
  4. <component ref="refCustomForm" :disabled="customForm.disabled" v-bind:is="customForm.formComponent" :model="customForm.model"
  5. :customFormData="customForm.customFormData" :isNew = "customForm.isNew"></component>
  6. </div>
  7. <div v-if="formOpen"> <!-- formdesigner表单 -->
  1. /** 获取流程变量内容 */
  2. processVariables(taskId) {
  3. console.log("processVariables taskId",taskId);
  4. if (taskId) {
  5. getProcessVariables(taskId).then(res => {
  6. console.log("getProcessVariables res=",res);
  7. if(res.code == 200) {
  8. if(res.data.hasOwnProperty('dataId') && res.data.dataId) {
  9. this.customForm.formId = res.data.dataId;
  10. // 流程任务重获取变量表单
  11. this.getProcessDetails(this.taskForm.procInsId, this.taskForm.taskId, res.data.dataId);
  12. this.loadIndex = this.taskForm.procInsId;
  13. if(this.processed) {
  14. this.activeName = "approval";
  15. }
  16. else {
  17. this.activeName = "form";
  18. }
  19. }
  20. else {
  21. // 流程任务重获取变量表单
  22. this.getProcessDetails(this.taskForm.procInsId, this.taskForm.taskId, "");
  23. this.loadIndex = this.taskForm.procInsId;
  24. if(this.processed) {
  25. this.activeName = "approval";
  26. }
  27. else {
  28. this.activeName = "form";
  29. // 回填数据,这里主要是处理文件列表显示,临时解决,以后应该在formdesigner里完成
  30. this.processFormList.forEach((item, i) => {
  31. if (item.hasOwnProperty('list')) {
  32. this.fillFormData(item.list, item)
  33. // 更新表单
  34. this.key = +new Date().getTime()
  35. }
  36. });
  37. }
  38. }
  39. }
  40. });
  41. }
  42. },
  43. getProcessDetails(procInsId, taskId, dataId) {
  44. const params = {procInsId: procInsId, taskId: taskId, dataId: dataId}
  45. detailProcess(params).then(res => {
  46. console.log("detailProcess res=",res);
  47. const data = res.data;
  48. this.xmlData = data.bpmnXml;
  49. this.processFormList = data.processFormList;
  50. if(this.processFormList.length == 1 &&
  51. this.processFormList[0].formValues.hasOwnProperty('routeName')) {
  52. this.customForm.disabled = true;
  53. this.customForm.visible = true;
  54. this.customForm.formComponent = this.getFormComponent(this.processFormList[0].formValues.routeName).component;
  55. this.customForm.model = this.processFormList[0].formValues.formData;
  56. this.customForm.customFormData = this.processFormList[0].formValues.formData;
  57. console.log("detailProcess customForm",this.customForm);
  58. }
  59. else {
  60. this.processFormList.forEach((item, index) => {
  61. this.formVal[index] = JSON.stringify(item.formValues);
  62. this.formViewData[index] = JSON.stringify(item);
  63. });
  64. this.taskFormOpen = data.existTaskForm;
  65. if (this.taskFormOpen) {
  66. this.taskFormData = data.taskFormData;
  67. }
  68. this.formOpen = true
  69. }
  70. this.historyProcNodeList = data.historyProcNodeList;
  71. this.finishedInfo = data.flowViewer;
  72. })
  73. },

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号