workFlowCheck.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <script setup lang="ts">
  2. import { getNextUser, queryFlowDataList, submitFlow } from "@/api/flow";
  3. const dialogVisible = ref(false);
  4. const dialogTitle = ref("Workflow Check");
  5. const emits = defineEmits(["sureToSave"]);
  6. // 流程定义的列表
  7. const flowDataList = ref<any[]>([]);
  8. const getFlowList = () => {
  9. queryFlowDataList({ flowType: flowForm.flow_type }).then((res) => {
  10. flowDataList.value = res.data;
  11. });
  12. };
  13. const name = ref("");
  14. const nextUserList = ref<any[]>([]);
  15. const whenSelectFlow = () => {
  16. // 选择完模板之后 下一节点人员 type 1 流程 2 任务
  17. getNextUser("1", flowForm.definitionId).then((res) => {
  18. name.value = res.data?.roleName ?? "";
  19. nextUserList.value = res.data?.users ?? [];
  20. });
  21. };
  22. const flowFormRef = ref();
  23. const flowForm = reactive<any>({
  24. businessId: "",
  25. flow_type: "",
  26. definitionId: "",
  27. users: "",
  28. });
  29. const close = () => {
  30. dialogVisible.value = false;
  31. };
  32. const sureToSave = () => {
  33. submitFlow(flowForm).then(() => {
  34. ElMessage.success("提交成功");
  35. emits("sureToSave");
  36. dialogVisible.value = false;
  37. });
  38. };
  39. // businessId 业务ID 流程类型flow_type 测试类型 testService; 通用工艺提审 commonRouteFlowService;
  40. const openDialog = (businessId: string, flow_type: string) => {
  41. flowForm.businessId = businessId;
  42. flowForm.flow_type = flow_type;
  43. dialogVisible.value = true;
  44. getFlowList();
  45. };
  46. defineExpose({
  47. openDialog,
  48. close,
  49. });
  50. </script>
  51. <template>
  52. <el-drawer
  53. v-model="dialogVisible"
  54. direction="rtl"
  55. size="400"
  56. append-to-body
  57. destroy-on-close
  58. >
  59. <template #header>
  60. <h4 v-text="dialogTitle"></h4>
  61. </template>
  62. <template #default>
  63. <el-scrollbar>
  64. <div class="check-container">
  65. <el-form ref="flowFormRef" v-model="flowForm" label-width="100px">
  66. <el-form-item label="选择流程模板">
  67. <el-tree-select
  68. v-model="flowForm.definitionId"
  69. :data="flowDataList"
  70. filterable
  71. :props="{ label: 'flowName', value: 'id' }"
  72. @change="whenSelectFlow"
  73. />
  74. </el-form-item>
  75. <el-form-item :label="name" v-if="name">
  76. <el-tree-select
  77. v-model="flowForm.users"
  78. :data="nextUserList"
  79. filterable
  80. :props="{ label: 'userName', value: 'userName' }"
  81. />
  82. </el-form-item>
  83. </el-form>
  84. </div>
  85. </el-scrollbar>
  86. </template>
  87. <template #footer>
  88. <div style="flex: auto">
  89. <el-button @click="close">取消</el-button>
  90. <el-button type="primary" @click="sureToSave">保存</el-button>
  91. </div>
  92. </template>
  93. </el-drawer>
  94. </template>
  95. <style scoped lang="scss">
  96. :deep(.el-drawer__header) {
  97. margin: 0;
  98. }
  99. .check-container {
  100. font-size: 14px;
  101. }
  102. </style>