deploy.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <basic-container>
  3. <avue-form
  4. ref="form"
  5. :option="option"
  6. v-model="form"
  7. :upload-before="uploadBefore"
  8. :upload-after="uploadAfter"
  9. />
  10. </basic-container>
  11. </template>
  12. <script>
  13. import { deployUpload } from "@/api/flow/flow";
  14. import { flowCategory } from "@/util/flow";
  15. export default {
  16. data() {
  17. return {
  18. form: {
  19. flowCategory: "",
  20. tenantId: "",
  21. flowFile: [],
  22. file: {}
  23. },
  24. option: {
  25. labelWidth: 120,
  26. menuBtn: false,
  27. column: [
  28. {
  29. label: "流程类型",
  30. prop: "flowCategory",
  31. type: "select",
  32. dicUrl: `/api/blade-system/dict/dictionary?code=flow`,
  33. props: {
  34. label: "dictValue",
  35. value: "dictKey"
  36. },
  37. row: true,
  38. span: 12,
  39. dataType: "number",
  40. rules: [
  41. {
  42. required: true,
  43. message: "请选择流程类型",
  44. trigger: "blur"
  45. }
  46. ]
  47. },
  48. {
  49. label: "流程模式",
  50. prop: "flowMode",
  51. type: "radio",
  52. dicData: [
  53. {
  54. label: "通用流程",
  55. value: 1
  56. },
  57. {
  58. label: "定制流程",
  59. value: 2
  60. }
  61. ],
  62. value: 1,
  63. row: true,
  64. span: 12,
  65. rules: [
  66. {
  67. required: true,
  68. message: "请选择流程模式",
  69. trigger: "blur"
  70. }
  71. ]
  72. },
  73. {
  74. label: "所属租户",
  75. prop: "tenantId",
  76. type: "tree",
  77. multiple: true,
  78. dicUrl: "/api/blade-system/tenant/select",
  79. props: {
  80. label: "tenantName",
  81. value: "tenantId"
  82. },
  83. display: false,
  84. row: true,
  85. span: 12,
  86. rules: [
  87. {
  88. required: true,
  89. message: "请选择所属租户",
  90. trigger: "blur"
  91. }
  92. ]
  93. },
  94. {
  95. label: "附件上传",
  96. prop: "flowFile",
  97. type: "upload",
  98. loadText: "附件上传中,请稍等",
  99. span: 24,
  100. propsHttp: {
  101. res: "data"
  102. },
  103. tip: "请上传 bpmn20.xml 标准格式文件",
  104. action: "/api/blade-flow/manager/check-upload"
  105. }
  106. ]
  107. }
  108. };
  109. },
  110. watch: {
  111. "form.flowMode"() {
  112. this.$refs.form.option.column.filter(item => {
  113. if (item.prop === "tenantId") {
  114. item.display = this.form.flowMode === 2;
  115. }
  116. });
  117. }
  118. },
  119. methods: {
  120. uploadBefore(file, done) {
  121. this.$message.success("部署开始");
  122. this.file = file;
  123. done();
  124. },
  125. uploadAfter(res, done, loading) {
  126. if (!this.form.flowCategory) {
  127. this.$message.warning("清先选择流程类型");
  128. loading();
  129. return false;
  130. }
  131. if (this.form.flowMode === 2 && !this.form.tenantId) {
  132. this.$message.warning("清先选择对应租户");
  133. loading();
  134. return false;
  135. }
  136. if (res.success) {
  137. deployUpload(
  138. flowCategory(this.form.flowCategory),
  139. this.form.tenantId ? this.form.tenantId.join(",") : "",
  140. [this.file]
  141. ).then(res => {
  142. const data = res.data;
  143. if (data.success) {
  144. done();
  145. } else {
  146. this.$message.error(data.msg);
  147. loading();
  148. }
  149. });
  150. } else {
  151. this.$message.warning("请上传 bpmn20.xml 标准格式文件");
  152. loading();
  153. return false;
  154. }
  155. }
  156. }
  157. };
  158. </script>
  159. <style lang="scss" scoped>
  160. .basic-container /deep/ .basic-container__card {
  161. height: calc(100vh - 125px);
  162. }
  163. </style>