index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <div class="safetyList">
  3. <customHeader>数据中心-API管理</customHeader>
  4. <div class="device-manager-box">
  5. <!-- 分站监测 -->
  6. <BasicTable @register="registerTable">
  7. <template #tableTitle>
  8. <a-button type="primary" preIcon="ant-design:plus-outlined" @click="handleCreate"> 新增</a-button>
  9. </template>
  10. <template #action="{ record }">
  11. <a class="table-action-link" @click="handlerEdit(record)">编辑</a>
  12. <a-popconfirm title="删除内容无法恢复,是否删除" ok-text="确定" cancel-text="取消" @confirm="handleDelete(record)">
  13. <a class="table-action-link">删除</a>
  14. </a-popconfirm>
  15. </template>
  16. </BasicTable>
  17. </div>
  18. <ApiAddModal @register="registerAddModal" @success="reload" />
  19. </div>
  20. </template>
  21. <script setup lang="ts">
  22. import { ref, nextTick, computed, reactive, onMounted, onUnmounted, inject } from 'vue';
  23. import { BasicTable } from '/@/components/Table';
  24. import { usePermission } from '/@/hooks/web/usePermission';
  25. import customHeader from '/@/components/vent/customHeader.vue';
  26. import { apiManageList, apiManageDelete } from './apiManger.api';
  27. import { useModal } from '/@/components/Modal';
  28. import { tableColumns } from './apiManger.data';
  29. import ApiAddModal from './ApiAddModal.vue';
  30. import { useListPage } from '/@/hooks/system/useListPage';
  31. const { hasPermission } = usePermission();
  32. const [registerAddModal, { openModal: openAddModal }] = useModal();
  33. // 列表页面公共参数、方法
  34. const { prefixCls, tableContext } = useListPage({
  35. designScope: 'API-list',
  36. tableProps: {
  37. title: 'Api列表',
  38. api: apiManageList,
  39. columns: tableColumns,
  40. size: 'small',
  41. actionColumn: {
  42. width: 120,
  43. },
  44. beforeFetch(params) {
  45. return Object.assign(
  46. {
  47. column: 'createTime',
  48. },
  49. params
  50. );
  51. },
  52. showActionColumn: false,
  53. },
  54. });
  55. const [registerTable, { reload, updateTableDataRecord }, { selectedRows }] = tableContext;
  56. // 注册table数据
  57. // async function getAPIList(params) {
  58. // const result = await apiManageList(params);
  59. // // tableData.value = result.records;
  60. // }
  61. function handleCreate() {
  62. openAddModal(true, { isAdd: true });
  63. reload();
  64. }
  65. async function handlerEdit(record) {
  66. openAddModal(true, { record, isAdd: false });
  67. }
  68. async function handleDelete(record) {
  69. await apiManageDelete({ id: record.id });
  70. reload();
  71. }
  72. onMounted(async () => {
  73. // await getAPIList({
  74. // pageNo: 1,
  75. // pageSize: 1000,
  76. // });
  77. });
  78. onUnmounted(() => {});
  79. </script>
  80. <style lang="less" scoped>
  81. .safetyList {
  82. width: calc(100% - 20px);
  83. height: calc(100% - 80px);
  84. position: relative;
  85. margin: 40px 10px 10px 10px;
  86. }
  87. </style>