index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <el-card shadow="nover" class="page page-wrapper">
  3. <el-form :model="tableData.param" ref="queryRef" inline>
  4. <el-form-item>
  5. <el-button @click="onOpenEdit(queryRef)">
  6. <el-icon>
  7. <ele-Plus />
  8. </el-icon>
  9. 添加
  10. </el-button>
  11. <!-- <el-button disabled type="primary" class="ml10" @click="onOpenAdd" v-auth="'add'">
  12. <el-icon>
  13. <ele-FolderAdd />
  14. </el-icon>
  15. 批量执行
  16. </el-button> -->
  17. </el-form-item>
  18. </el-form>
  19. <el-table :data="tableData.data" style="width: 100%" @selection-change="handleSelectionChange" v-loading="tableData.loading">
  20. <!-- <el-table-column type="selection" width="55" align="center" /> -->
  21. <el-table-column label="序号" align="center" prop="id" width="100" />
  22. <el-table-column label="标题" prop="title" show-overflow-tooltip />
  23. <el-table-column label="说明" prop="description" show-overflow-tooltip />
  24. <el-table-column prop="status" label="类型" width="100" align="center" >
  25. <template #default="scope">
  26. <div v-if="scope.row.types == 1">手动</div>
  27. <div v-if="scope.row.types == 2">自动</div>
  28. </template>
  29. </el-table-column>
  30. <el-table-column prop="status" label="状态" width="80" align="center" >
  31. <template #default="scope">
  32. <el-tag type="success" size="small" v-if="scope.row.status == 1">启用</el-tag>
  33. <el-tag type="info" size="small" v-else>禁用</el-tag>
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="操作" width="220" align="center" fixed="right">
  37. <template #default="scope">
  38. <el-button size="small" text type="primary" @click="onOpenRecord(scope.row)">执行</el-button>
  39. <el-button size="small" text type="primary" @click="onOpenPolicyRecord(scope.row)">策略</el-button>
  40. <el-button size="small" text type="warning" @click="onOpenEdit(scope.row)">修改</el-button>
  41. <el-button size="small" text type="info" @click="onRowDel(scope.row)">删除</el-button>
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. <pagination v-show="tableData.total > 0" :total="tableData.total" v-model:page="tableData.param.pageNum" v-model:limit="tableData.param.pageSize" @pagination="typeList" />
  46. <Execute @getList="updeteList()" ref="executeRef" />
  47. <AddPolicy @getList="updeteList()" ref="addPolicyRef" />
  48. </el-card>
  49. </template>
  50. <script lang="ts" setup>
  51. import { ref, onMounted, defineAsyncComponent } from 'vue';
  52. import api from '/@/api/modules/policy';
  53. import { ElMessage, ElMessageBox } from "element-plus";
  54. import { getToken } from "/@/utils/auth";
  55. const Execute = defineAsyncComponent(() => import("/@/views/policy/components/execute.vue"));
  56. const AddPolicy = defineAsyncComponent(() => import("/@/views/policy/components/addItem.vue"));
  57. const tableData = ref({
  58. data: [],
  59. total: 0,
  60. loading: false,
  61. param: {
  62. pageNum: 1,
  63. pageSize: 20,
  64. }
  65. })
  66. const executeRef = ref();
  67. const addPolicyRef = ref();
  68. const onOpenEdit = (row:any) => {
  69. addPolicyRef.value.openDialog(row);
  70. };
  71. const onOpenRecord = (row: any) => {
  72. executeRef.value.openDialog(row);
  73. };
  74. const onRowDel = (row: any) => {
  75. let msg = '你确定要删除所选数据?';
  76. ElMessageBox.confirm(msg, '提示', {
  77. confirmButtonText: '确认',
  78. cancelButtonText: '取消',
  79. type: 'warning',
  80. }).then(() => {
  81. api.del(row.id).then(() => {
  82. ElMessage.success('删除成功');
  83. updeteList();
  84. });
  85. }).catch(() => { });
  86. };
  87. const onOpenPolicyRecord = async (row: any) => {
  88. localStorage.setItem("auth-tokens", `{"access_token":"${getToken()}"}`);
  89. const params:any = {};
  90. row.paramData.forEach((item: any) => {
  91. params[item.key] = item.value || '';
  92. });
  93. const url = `/plugin/rule/index.html?${(new URLSearchParams(params)).toString()}#${row.flowId}`;
  94. window.open(url);
  95. };
  96. const updeteList = ( ) => {
  97. if(tableData.value.param.pageNum !== 1) tableData.value.param.pageNum = 1;
  98. getList();
  99. }
  100. const getList = () => {
  101. tableData.value.loading = true;
  102. api.getList(tableData.value.param).then((res: any) => {
  103. tableData.value.data = res.list;
  104. tableData.value.total = res.Total;
  105. }).finally(() => {
  106. tableData.value.loading = false;
  107. });
  108. };
  109. // 页面加载时
  110. onMounted(() => {
  111. getList();
  112. });
  113. </script>