create.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <div class="app-container">
  3. <!-- 第一步,通过流程定义的列表,选择对应的流程 -->
  4. <div v-if="!selectProcessInstance">
  5. <XTable @register="registerTable">
  6. <template #version_default="{ row }">
  7. <el-tag v-if="row">v{{ row.version }}</el-tag>
  8. </template>
  9. <template #actionbtns_default="{ row }">
  10. <el-button type="text" size="small" icon="el-icon-plus" @click="handleSelect(row)"
  11. >选择</el-button
  12. >
  13. </template>
  14. </XTable>
  15. </div>
  16. <!-- 第二步,填写表单,进行流程的提交 -->
  17. <div v-else>
  18. <el-card class="box-card">
  19. <div class="clearfix">
  20. <span class="el-icon-document">申请信息【{{ selectProcessInstance.name }}】</span>
  21. <el-button style="float: right" type="primary" @click="selectProcessInstance = undefined"
  22. >选择其它流程</el-button
  23. >
  24. </div>
  25. <el-col :span="16" :offset="6">
  26. <div>
  27. <!-- <parser :key="new Date().getTime()" :form-conf="detailForm" @submit="submitForm" /> -->
  28. </div>
  29. </el-col>
  30. </el-card>
  31. <el-card class="box-card">
  32. <div class="clearfix">
  33. <span class="el-icon-picture-outline">流程图</span>
  34. </div>
  35. <!-- <my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" /> -->
  36. </el-card>
  37. </div>
  38. </div>
  39. </template>
  40. <script setup lang="ts">
  41. import { reactive, ref } from 'vue'
  42. import { useXTable } from '@/hooks/web/useXTable'
  43. import * as definitionApi from '@/api/bpm/definition'
  44. // import {DICT_TYPE, getDictDatas} from "@/utils/dict";
  45. import { decodeFields } from '@/utils/formGenerator'
  46. // import Parser from '@/components/parser/Parser'
  47. // import * as processInstanceApi from "@/api/bpm/processInstance";
  48. import { allSchemas } from './process.create'
  49. import { useRouter } from 'vue-router'
  50. const router = useRouter()
  51. const queryParams = reactive({
  52. suspensionState: 1
  53. })
  54. const [registerTable] = useXTable({
  55. allSchemas: allSchemas,
  56. params: queryParams,
  57. getListApi: definitionApi.getProcessDefinitionListApi
  58. })
  59. // 流程表单详情
  60. const detailForm = ref({
  61. fields: []
  62. })
  63. // // BPMN 数据
  64. const bpmnXML = ref(null)
  65. // const bpmnControlForm=ref( {
  66. // prefix: "flowable"
  67. // })
  68. // 流程表单
  69. const selectProcessInstance = ref(undefined) // 选择的流程实例
  70. /** 处理选择流程的按钮操作 **/
  71. const handleSelect = (row) => {
  72. // 设置选择的流程
  73. selectProcessInstance.value = row
  74. // 流程表单
  75. if (row.formId) {
  76. // 设置对应的表单
  77. detailForm.value = {
  78. ...JSON.parse(row.formConf),
  79. fields: decodeFields([], row.formFields)
  80. }
  81. // 加载流程图
  82. definitionApi.getProcessDefinitionBpmnXMLApi(row.id).then((response) => {
  83. bpmnXML.value = response.data
  84. })
  85. } else if (row.formCustomCreatePath) {
  86. router.push({ path: row.formCustomCreatePath })
  87. // 这里暂时无需加载流程图,因为跳出到另外个 Tab;
  88. }
  89. }
  90. /** 提交按钮 */
  91. // const submitForm=(params)=> {
  92. // if (!params) {
  93. // return;
  94. // }
  95. // // 设置表单禁用
  96. // const conf = params.conf;
  97. // conf.disabled = true; // 表单禁用
  98. // conf.formBtns = false; // 按钮隐藏
  99. // // 提交表单,创建流程
  100. // const variables = params.values;
  101. // await processInstanceApi.createProcessInstanceApi({
  102. // processDefinitionId: this.selectProcessInstance.id,
  103. // variables: variables
  104. // }).then(response => {
  105. // this.$modal.msgSuccess("发起流程成功");
  106. // // 关闭当前窗口
  107. // this.$tab.closeOpenPage();
  108. // this.$router.go(-1);
  109. // }).catch(() => {
  110. // conf.disabled = false; // 表单开启
  111. // conf.formBtns = true; // 按钮展示
  112. // })
  113. // }
  114. </script>
  115. <style lang="scss">
  116. .my-process-designer {
  117. height: calc(100vh - 200px);
  118. }
  119. .box-card {
  120. width: 100%;
  121. margin-bottom: 20px;
  122. }
  123. </style>