index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <el-card shadow="hover">
  3. <div class="search">
  4. <el-form :inline="true">
  5. <el-form-item>
  6. <!-- <el-button size="default" type="primary" class="ml10" @click="getList(1)">
  7. <el-icon>
  8. <ele-Search />
  9. </el-icon>
  10. 查询
  11. </el-button> -->
  12. <el-button type="success" @click="addOrEdit()">
  13. <el-icon>
  14. <ele-FolderAdd />
  15. </el-icon>
  16. 新增规则编排
  17. </el-button>
  18. </el-form-item>
  19. </el-form>
  20. </div>
  21. <el-table :data="tableData" style="width: 100%" v-loading="loading">
  22. <el-table-column type="index" label="序号" width="80" align="center" />
  23. <el-table-column prop="flowId" label="流程ID" show-overflow-tooltip></el-table-column>
  24. <el-table-column prop="name" label="项目名称" show-overflow-tooltip></el-table-column>
  25. <el-table-column prop="createdAt" label="创建时间" min-width="100" align="center"></el-table-column>
  26. <el-table-column prop="status" label="状态" width="100" align="center">
  27. <template #default="scope">
  28. <el-tag type="success" size="small" v-if="scope.row.status==1">已启动</el-tag>
  29. <el-tag type="info" size="small" v-else>已停止</el-tag>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="操作" width="150" align="center">
  33. <template #default="scope">
  34. <!-- <el-button size="small" text type="primary" @click="preview(scope.row)">启动</el-button> -->
  35. <el-button size="small" text type="warning" @click="edit(scope.row)">编辑</el-button>
  36. <el-button size="small" text type="danger" @click="onDel(scope.row)">删除</el-button>
  37. </template>
  38. </el-table-column>
  39. </el-table>
  40. <pagination v-if="params.total" :total="params.total" v-model:page="params.pageNum" v-model:limit="params.pageSize" @pagination="getList()" />
  41. <EditForm ref="editFormRef" @getList="getList()" :types="0"></EditForm>
  42. </el-card>
  43. </template>
  44. <script lang="ts" setup>
  45. import { ref } from 'vue';
  46. import api from '/@/api/rule';
  47. import { ElMessageBox, ElMessage } from 'element-plus';
  48. import { useSearch } from '/@/hooks/useCommon';
  49. import { Session } from '/@/utils/storage';
  50. import EditForm from './edit.vue';
  51. const editFormRef = ref();
  52. const { params, tableData, getList, loading } = useSearch<any[]>(api.getList, 'Data', { types: 0 });
  53. getList();
  54. const addOrEdit = async (row?: any) => {
  55. if (row) {
  56. editFormRef.value.open(row);
  57. return;
  58. } else {
  59. editFormRef.value.open();
  60. }
  61. };
  62. const edit = async (row: any) => {
  63. const url = window.location.protocol + '//' + window.location.hostname + ':1880/?access_token=' + Session.get('token') + '#/flow/' + row.flowId;
  64. window.open(url);
  65. };
  66. const onDel = (row: any) => {
  67. ElMessageBox.confirm(`此操作将删除:“${row.name}”,是否继续?`, '提示', {
  68. confirmButtonText: '确认',
  69. cancelButtonText: '取消',
  70. type: 'warning',
  71. }).then(async () => {
  72. await api.del([row.id as string]);
  73. ElMessage.success('删除成功');
  74. getList();
  75. });
  76. };
  77. </script>