index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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: 8px">
  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. <el-popover placement="bottom" width="280" trigger="hover">
  34. <template #reference>
  35. <el-text type="primary">
  36. <el-icon><ele-InfoFilled /></el-icon>详情
  37. </el-text>
  38. </template>
  39. <el-descriptions direction="vertical" :column="2" border>
  40. <el-descriptions-item width="140">
  41. <template #label>
  42. <el-text>
  43. <el-icon><ele-UserFilled /></el-icon>创建者
  44. </el-text>
  45. </template>
  46. <el-tag>{{ scope.row.createUserName ?? '无' }}</el-tag>
  47. </el-descriptions-item>
  48. <el-descriptions-item>
  49. <template #label>
  50. <el-text>
  51. <el-icon><ele-Calendar /></el-icon>创建时间
  52. </el-text>
  53. </template>
  54. <el-tag>{{ scope.row.createTime ?? '无' }}</el-tag>
  55. </el-descriptions-item>
  56. <el-descriptions-item>
  57. <template #label>
  58. <el-text>
  59. <el-icon><ele-UserFilled /></el-icon>修改者
  60. </el-text>
  61. </template>
  62. <el-tag>{{ scope.row.updateUserName ?? '无' }}</el-tag>
  63. </el-descriptions-item>
  64. <el-descriptions-item>
  65. <template #label>
  66. <el-text>
  67. <el-icon><ele-Calendar /></el-icon>修改时间
  68. </el-text>
  69. </template>
  70. <el-tag>{{ scope.row.updateTime ?? '无' }}</el-tag>
  71. </el-descriptions-item>
  72. <el-descriptions-item>
  73. <template #label>
  74. <el-text>
  75. <el-icon><ele-Tickets /></el-icon>备注
  76. </el-text>
  77. </template>
  78. {{ scope.row.remark }}
  79. </el-descriptions-item>
  80. </el-descriptions>
  81. </el-popover>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="操作" width="140" fixed="right" align="center" show-overflow-tooltip>
  85. <template #default="scope">
  86. <el-button icon="ele-Edit" size="small" text type="primary" @click="openEditPlugin(scope.row)" v-auth="'sysPlugin:update'"> 编辑 </el-button>
  87. <el-button icon="ele-Delete" size="small" text type="danger" @click="delPlugin(scope.row)" v-auth="'sysPlugin:delete'"> 删除 </el-button>
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. <el-pagination
  92. v-model:currentPage="state.tableParams.page"
  93. v-model:page-size="state.tableParams.pageSize"
  94. :total="state.tableParams.total"
  95. :page-sizes="[10, 20, 50, 100]"
  96. small
  97. background
  98. @size-change="handleSizeChange"
  99. @current-change="handleCurrentChange"
  100. layout="total, sizes, prev, pager, next, jumper"
  101. />
  102. </el-card>
  103. <EditPlugin ref="editPluginRef" :title="state.editPluginTitle" @handleQuery="handleQuery" />
  104. </div>
  105. </template>
  106. <script lang="ts" setup name="sysPlugin">
  107. import { onMounted, reactive, ref } from 'vue';
  108. import { ElMessageBox, ElMessage } from 'element-plus';
  109. import EditPlugin from '/@/views/system/plugin/component/editPlugin.vue';
  110. import { getAPI } from '/@/utils/axios-utils';
  111. import { SysPluginApi } from '/@/api-services/api';
  112. import { SysPlugin } from '/@/api-services/models';
  113. const editPluginRef = ref<InstanceType<typeof EditPlugin>>();
  114. const state = reactive({
  115. loading: false,
  116. pluginData: [] as Array<SysPlugin>,
  117. queryParams: {
  118. name: undefined,
  119. },
  120. tableParams: {
  121. page: 1,
  122. pageSize: 20,
  123. total: 0 as any,
  124. },
  125. editPluginTitle: '',
  126. });
  127. onMounted(async () => {
  128. handleQuery();
  129. });
  130. // 查询操作
  131. const handleQuery = async () => {
  132. state.loading = true;
  133. let params = Object.assign(state.queryParams, state.tableParams);
  134. var res = await getAPI(SysPluginApi).apiSysPluginPagePost(params);
  135. state.pluginData = res.data.result?.items ?? [];
  136. state.tableParams.total = res.data.result?.total;
  137. state.loading = false;
  138. };
  139. // 重置操作
  140. const resetQuery = () => {
  141. state.queryParams.name = undefined;
  142. handleQuery();
  143. };
  144. // 打开新增页面
  145. const openAddPlugin = () => {
  146. state.editPluginTitle = '添加动态插件';
  147. editPluginRef.value?.openDialog({ orderNo: 100, status: 1 });
  148. };
  149. // 打开编辑页面
  150. const openEditPlugin = (row: any) => {
  151. state.editPluginTitle = '编辑动态插件';
  152. editPluginRef.value?.openDialog(row);
  153. };
  154. // 删除当前行
  155. const delPlugin = (row: any) => {
  156. ElMessageBox.confirm(`确定删除动态插件:【${row.name}】?`, '提示', {
  157. confirmButtonText: '确定',
  158. cancelButtonText: '取消',
  159. type: 'warning',
  160. })
  161. .then(async () => {
  162. await getAPI(SysPluginApi).apiSysPluginDeletePost({ id: row.id });
  163. handleQuery();
  164. ElMessage.success('删除成功');
  165. })
  166. .catch(() => {});
  167. };
  168. // 改变页面容量
  169. const handleSizeChange = (val: number) => {
  170. state.tableParams.pageSize = val;
  171. handleQuery();
  172. };
  173. // 改变页码序号
  174. const handleCurrentChange = (val: number) => {
  175. state.tableParams.page = val;
  176. handleQuery();
  177. };
  178. </script>