execute.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <el-dialog title="执行" v-model="isShowDialog" width="600px">
  3. <el-form>
  4. <el-form-item>
  5. <p>标题:{{currentPolicy.title}}</p>
  6. <p class="ml30">执行类型:{{typesText[currentPolicy.types]}}</p>
  7. </el-form-item>
  8. <el-form-item >
  9. <div style="width: 100%;">
  10. <p>参数配置</p>
  11. <div class="param-wrap" v-for="(item, index) in currentPolicy.paramData" :key="index">
  12. <p class="mr6 label">{{item.title}}:</p>
  13. <!-- int、long、float、double、string、boolean、date、timestamp -->
  14. <el-input v-if="item.types === 'string'" clearable :placeholder="`请输入${item.title}`" v-model="item.value" />
  15. <el-input-number v-if="['int', 'long'].indexOf(item.types) > -1" :placeholder="`请输入${item.title}`" v-model="item.value" :step="1" step-strictly />
  16. <el-input-number v-if="['float', 'double'].indexOf(item.types) > -1" :placeholder="`请输入${item.title}`" v-model="item.value" :precision="2" />
  17. <el-radio-group v-if="item.types === 'boolean'" v-model="item.value">
  18. <el-radio :label="0">否</el-radio>
  19. <el-radio :label="1">是</el-radio>
  20. </el-radio-group>
  21. <el-date-picker
  22. v-if="item.types === 'date'"
  23. v-model="item.value"
  24. type="datetime"
  25. :placeholder="`请选择${item.title}`"
  26. format="YYYY/MM/DD hh:mm:ss"
  27. value-format="YYYY-MM-DD h:m:s"
  28. />
  29. <el-date-picker
  30. v-if="item.types === 'timestamp'"
  31. v-model="item.value"
  32. type="datetime"
  33. :placeholder="`请选择${item.title}`"
  34. format="YYYY/MM/DD hh:mm:ss"
  35. value-format="x"
  36. />
  37. </div>
  38. </div>
  39. </el-form-item>
  40. </el-form>
  41. <div class="form-btn-wrap">
  42. <el-button @click="onSubmit('handle')">手动执行 </el-button>
  43. <el-button type="primary" @click="onSubmit('auto')"> 开始执行 </el-button>
  44. </div>
  45. </el-dialog>
  46. </template>
  47. <script lang="ts" setup>
  48. import { ref } from 'vue'
  49. import { ElMessage } from "element-plus";
  50. import api from '/@/api/modules/policy';
  51. import axios from 'axios';
  52. import { getToken } from "/@/utils/auth";
  53. const isShowDialog = ref(false);
  54. const typesText = {
  55. 1: '手动',
  56. 2: '自动'
  57. };
  58. const headers = {
  59. Authorization: "Bearer " + getToken(),
  60. };
  61. const currentPolicy = ref<any>({});
  62. const emit = defineEmits(['getList']);
  63. // 手动执行/开始执行
  64. const onSubmit = async () => {
  65. const params:any = {};
  66. currentPolicy.value.paramData.forEach((item:any) => {
  67. params[item.key] = item.value
  68. })
  69. await api.saveParam({
  70. id: currentPolicy.value.id,
  71. param: {
  72. ...params
  73. }
  74. })
  75. await axios.post(`${import.meta.env.VITE_RULE_SERVER_URL}/api/v1/rules/${currentPolicy.value.flowId}/execute/${currentPolicy.value.types}`, params, { headers }).catch(() => {
  76. ElMessage.error("规则不存在");
  77. }) as any;
  78. ElMessage.success('操作成功');
  79. isShowDialog.value = false;
  80. emit('getList');
  81. }
  82. // 打开弹窗
  83. const openDialog = (row?: any) => {
  84. if (row) {
  85. api.detail(row.id).then((res: any) => {
  86. currentPolicy.value = res.data;
  87. });
  88. }
  89. isShowDialog.value = true;
  90. };
  91. defineExpose({ openDialog });
  92. </script>
  93. <style lang="scss" scoped>
  94. .param-wrap {
  95. display: flex;
  96. justify-content: flex-start;
  97. align-items: center;
  98. margin-bottom: 10px;
  99. .label {
  100. width: 120px;
  101. text-align: right;
  102. }
  103. }
  104. .el-input-number,
  105. .el-input {
  106. width: 260px!important;
  107. }
  108. ::v-deep .el-date-editor.el-input {
  109. width: 260px!important;
  110. }
  111. ::v-deep .el-dialog__body {
  112. position: relative;
  113. }
  114. .form-btn-wrap {
  115. position: absolute;
  116. bottom: 20px;
  117. right: 20px;
  118. display: flex;
  119. justify-content: flex-end;
  120. align-items: center;
  121. width: 100%;
  122. }
  123. </style>