index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <div class="struct-manage h-full">
  3. <div class="flex-1 page-wrap">
  4. <div class="btn-group">
  5. <t-button
  6. v-perm="112"
  7. theme="success"
  8. @click="
  9. curRow = null;
  10. showAddNodeDialog = true;
  11. "
  12. >新增管理节点</t-button
  13. >
  14. </div>
  15. <t-table
  16. size="small"
  17. row-key="id"
  18. :columns="columns"
  19. :data="tableData"
  20. bordered
  21. v-loading="tableLoading"
  22. >
  23. <template #enable="{ row }">{{
  24. row.enable ? '启用' : '禁用'
  25. }}</template>
  26. </t-table>
  27. </div>
  28. <AddNodeDialog
  29. v-model:visible="showAddNodeDialog"
  30. :curRow="curRow"
  31. :orgTreeList="tableData || []"
  32. @success="addSuccess"
  33. ></AddNodeDialog>
  34. </div>
  35. </template>
  36. <script setup name="StructManage" lang="jsx">
  37. import { computed, ref } from 'vue';
  38. import { MessagePlugin } from 'tdesign-vue-next';
  39. import { useRequest } from 'vue-request';
  40. import { getOrgStructList, toggleOrgNodeStatus } from '@/api/user';
  41. import AddNodeDialog from './add-node-dialog.vue';
  42. const showAddNodeDialog = ref(false);
  43. const curRow = ref(null);
  44. const toggleStatus = (row) => {
  45. toggleOrgNodeStatus({ id: row.id, enable: !row.enable }).then(() => {
  46. MessagePlugin.success('操作成功');
  47. run();
  48. });
  49. };
  50. const columns = [
  51. { colKey: 'name', title: '管理节点' },
  52. { colKey: 'enable', title: '状态' },
  53. {
  54. title: '操作',
  55. colKey: 'operate',
  56. fixed: 'right',
  57. cell: (h, { row }) => {
  58. return (
  59. <div class="table-operations">
  60. <t-link
  61. theme="primary"
  62. hover="color"
  63. onClick={(e) => {
  64. e.stopPropagation();
  65. curRow.value = row;
  66. showAddNodeDialog.value = true;
  67. }}
  68. >
  69. 修改
  70. </t-link>
  71. <t-link
  72. theme={row.enable ? 'danger' : 'success'}
  73. hover="color"
  74. onClick={(e) => {
  75. e.stopPropagation();
  76. toggleStatus(row);
  77. }}
  78. >
  79. {row.enable ? '禁用' : '启用'}
  80. </t-link>
  81. </div>
  82. );
  83. },
  84. },
  85. ];
  86. const {
  87. data: tableData,
  88. loading: tableLoading,
  89. run,
  90. } = useRequest(getOrgStructList);
  91. run();
  92. const addSuccess = () => {
  93. showAddNodeDialog.value = false;
  94. MessagePlugin.success('操作成功');
  95. run();
  96. };
  97. </script>
  98. <style></style>