当前位置:   article > 正文

基于jeecgboot-vue3的Flowable流程-自定义业务表单处理(二)-挂接自定义业务表单_flowable绑定自定义表单

flowable绑定自定义表单
因为这个项目license问题无法开源,更多技术支持与服务请加入我的知识星球。

1、增加一个根据服务名称动态寻找对应自定义表单组件的hooks

  1. import { ref, reactive, computed, markRaw, onMounted, defineAsyncComponent } from 'vue';
  2. import { listCustomForm } from "/@/views/flowable/api/customForm";
  3. export const useFlowable = () => {
  4. const customformList = ref<any>([]);
  5. const formQueryParams = reactive<any>({
  6. pageNum: 1,
  7. pageSize: 1000
  8. });
  9. const allFormComponent = computed(() => {
  10. return customformList.value;
  11. })
  12. /* 挂载自定义业务表单列表 */
  13. const ListCustomForForm = async () => {
  14. listCustomForm(formQueryParams).then(res => {
  15. console.log("listCustomForm res = ",res)
  16. let  cfList = res.result.records;
  17.         cfList.forEach((item, index) => {
  18.           let cms = {
  19.               text:item.flowName,
  20.               routeName:item.routeName,
  21. component: markRaw(defineAsyncComponent( () => import(/* @vite-ignore */`../../${item.routeName}.vue`))),
  22.               businessTable:'test_demo'
  23.           }
  24.           customformList.value.push(cms);
  25.         })
  26. })
  27. }
  28. const getFormComponent = (routeName) => {
  29. return allFormComponent.value.find((item) => item.routeName === routeName) || {}
  30. }
  31. onMounted(() => {
  32. ListCustomForForm();
  33. });
  34. return {
  35. allFormComponent,
  36. getFormComponent
  37. }
  38. }

2、对应处理流程的界面上挂上自定义业务表单

  1. <!--初始化流程加载自定义表单信息-->
  2. <el-col :span="16" :offset="4" v-if="customForm.visible">
  3. <div>
  4. <component
  5. ref="refCustomForm"
  6. :formDisabled="customForm.disabled"
  7. :is="customForm.formComponent"
  8. v-model:value="customForm.model"
  9. :formData="customForm.customFormData"
  10. :isNew="customForm.isNew"
  11. />
  12. </div>

3、同时在启动初始化的表单里增加显示需要初始参数,需要的话也可以在流程里进行修改

  1. if (businessKey == 'newkey') {
  2. customForm.formId = route.query && route.query.formId;
  3. getCustomForm(customForm.formId).then((res) => {
  4. console.log('newkey res=', res);
  5. customForm.disabled = false;
  6. customForm.isNew = true;
  7. customForm.visible = true;
  8. customForm.disableSubmit = false;
  9. customForm.formComponent = getFormComponent(res.result.routeName).component;
  10. formConfOpen.value = true;
  11. });

4、需要的话也可以在提交表单的时候进行自定义业务表单的保存

  1. if (startUserForm.isStartUserNode && startUserForm.editFormType === 'ZDYYW') {
  2. createMessage.error("目前还不支持自定义表单的编辑修改功能!!!");
  3. refCustomForm.value.submitForm();
  4. }

5、效果图

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/酷酷是懒虫/article/detail/852416
推荐阅读
相关标签
  

闽ICP备14008679号