index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div class="sys-plugin-container">
  3. <el-card shadow="hover" :body-style="{ paddingBottom: '0' }">
  4. <el-form :model="state.queryParams" ref="queryForm" :inline="true">
  5. <el-form-item label="功能名称">
  6. <el-input v-model="state.queryParams.name" placeholder="功能名称" clearable />
  7. </el-form-item>
  8. <el-form-item>
  9. <el-button-group>
  10. <el-button type="primary" icon="ele-Search" @click="handleQuery" v-auth="'sysPlugin:page'"> 查询 </el-button>
  11. <el-button icon="ele-Refresh" @click="resetQuery"> 重置 </el-button>
  12. </el-button-group>
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button type="primary" icon="ele-Plus" @click="openAddPlugin" v-auth="'sysPlugin:add'"> 新增 </el-button>
  16. </el-form-item>
  17. </el-form>
  18. </el-card>
  19. <el-card class="full-table" shadow="hover" style="margin-top: 5px">
  20. <el-table :data="state.pluginData" style="width: 100%" v-loading="state.loading" border>
  21. <el-table-column type="index" label="序号" width="55" align="center" fixed />
  22. <el-table-column prop="name" label="功能名称" header-align="center" show-overflow-tooltip />
  23. <el-table-column prop="assemblyName" label="程序集名称" header-align="center" show-overflow-tooltip />
  24. <el-table-column prop="orderNo" label="排序" width="70" align="center" show-overflow-tooltip />
  25. <el-table-column label="状态" width="70" align="center" show-overflow-tooltip>
  26. <template #default="scope">
  27. <el-tag type="success" v-if="scope.row.status === 1">启用</el-tag>
  28. <el-tag type="danger" v-else>禁用</el-tag>
  29. </template>
  30. </el-table-column>
  31. <el-table-column label="修改记录" width="100" align="center" show-overflow-tooltip>
  32. <template #default="scope">
  33. <ModifyRecord :data="scope.row" />
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="操作" width="140" fixed="right" align="center" show-overflow-tooltip>
  37. <template #default="scope">
  38. <el-button icon="ele-Edit" size="small" text type="primary" @click="openEditPlugin(scope.row)" v-auth="'sysPlugin:update'"> 编辑 </el-button>
  39. <el-button icon="ele-Delete" size="small" text type="danger" @click="delPlugin(scope.row)" v-auth="'sysPlugin:delete'"> 删除 </el-button>
  40. </template>
  41. </el-table-column>
  42. </el-table>
  43. <el-pagination
  44. v-model:currentPage="state.tableParams.page"
  45. v-model:page-size="state.tableParams.pageSize"
  46. :total="state.tableParams.total"
  47. :page-sizes="[10, 20, 50, 100]"
  48. size="small"
  49. background
  50. @size-change="handleSizeChange"
  51. @current-change="handleCurrentChange"
  52. layout="total, sizes, prev, pager, next, jumper"
  53. />
  54. </el-card>
  55. <EditPlugin ref="editPluginRef" :title="state.editPluginTitle" @handleQuery="handleQuery" />
  56. </div>
  57. </template>
  58. <script lang="ts" setup name="sysPlugin">
  59. import { onMounted, reactive, ref } from 'vue';
  60. import { ElMessageBox, ElMessage } from 'element-plus';
  61. import EditPlugin from '/@/views/system/plugin/component/editPlugin.vue';
  62. import ModifyRecord from '/@/components/table/modifyRecord.vue';
  63. import { getAPI } from '/@/utils/axios-utils';
  64. import { SysPluginApi } from '/@/api-services/api';
  65. import { SysPlugin } from '/@/api-services/models';
  66. const editPluginRef = ref<InstanceType<typeof EditPlugin>>();
  67. const state = reactive({
  68. loading: false,
  69. pluginData: [] as Array<SysPlugin>,
  70. queryParams: {
  71. name: undefined,
  72. },
  73. tableParams: {
  74. page: 1,
  75. pageSize: 20,
  76. total: 0 as any,
  77. },
  78. editPluginTitle: '',
  79. });
  80. onMounted(async () => {
  81. handleQuery();
  82. });
  83. // 查询操作
  84. const handleQuery = async () => {
  85. state.loading = true;
  86. let params = Object.assign(state.queryParams, state.tableParams);
  87. var res = await getAPI(SysPluginApi).apiSysPluginPagePost(params);
  88. state.pluginData = res.data.result?.items ?? [];
  89. state.tableParams.total = res.data.result?.total;
  90. state.loading = false;
  91. };
  92. // 重置操作
  93. const resetQuery = () => {
  94. state.queryParams.name = undefined;
  95. handleQuery();
  96. };
  97. // 打开新增页面
  98. const openAddPlugin = () => {
  99. state.editPluginTitle = '添加动态插件';
  100. editPluginRef.value?.openDialog({ orderNo: 100, status: 1 });
  101. };
  102. // 打开编辑页面
  103. const openEditPlugin = (row: any) => {
  104. state.editPluginTitle = '编辑动态插件';
  105. editPluginRef.value?.openDialog(row);
  106. };
  107. // 删除当前行
  108. const delPlugin = (row: any) => {
  109. ElMessageBox.confirm(`确定删除动态插件:【${row.name}】?`, '提示', {
  110. confirmButtonText: '确定',
  111. cancelButtonText: '取消',
  112. type: 'warning',
  113. })
  114. .then(async () => {
  115. await getAPI(SysPluginApi).apiSysPluginDeletePost({ id: row.id });
  116. handleQuery();
  117. ElMessage.success('删除成功');
  118. })
  119. .catch(() => {});
  120. };
  121. // 改变页面容量
  122. const handleSizeChange = (val: number) => {
  123. state.tableParams.pageSize = val;
  124. handleQuery();
  125. };
  126. // 改变页码序号
  127. const handleCurrentChange = (val: number) => {
  128. state.tableParams.page = val;
  129. handleQuery();
  130. };
  131. </script>