SubOrg.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <div>
  3. <div class="tw-bg-white tw-p-5 tw-rounded-xl tw-mb-5">
  4. <RootOrgSelect style="display: none" v-model:value="rootOrgId" />
  5. <a-input
  6. v-model:value="code"
  7. style="width: 178px"
  8. placeholder="机构代码"
  9. allowClear
  10. ></a-input>
  11. <span class="tw-mr-4"></span>
  12. <a-input
  13. v-model:value="name"
  14. class="tw-mr-4"
  15. style="width: 178px"
  16. placeholder="机构名称"
  17. allowClear
  18. ></a-input>
  19. <span class="tw-mr-4"></span>
  20. <StateSelect v-model:value="enable" />
  21. <span class="tw-mr-4"></span>
  22. <a-button @click="search">查询</a-button>
  23. <div class="tw-mt-4">
  24. <a-button>新增</a-button>
  25. </div>
  26. </div>
  27. <div class="tw-bg-white tw-p-5 tw-rounded-xl">
  28. <a-table
  29. row-key="code"
  30. :columns="columns"
  31. :data-source="data"
  32. :pagination="{
  33. pageSize: pageSize,
  34. current: pageNo,
  35. total: totalElements,
  36. showTotal: (total: number) => `总数:${total}`,
  37. onChange: (pageNoChanged: number, pageSizeChanged: number) => {
  38. pageNo = pageNoChanged;
  39. pageSize = pageSizeChanged;
  40. }
  41. }"
  42. >
  43. <template #enable="{ text }">
  44. <a>{{ $filters.booleanEnableDisableFilter(text) }}</a>
  45. </template>
  46. <template #action="{ record }">
  47. <span>
  48. <a-button>编辑</a-button>
  49. </span>
  50. </template>
  51. </a-table>
  52. </div>
  53. </div>
  54. </template>
  55. <script setup lang="ts">
  56. import { getSubOrgList } from "@/api/subOrgPage";
  57. import { useMainStore } from "@/store";
  58. import { watch, onMounted } from "vue";
  59. const store = useMainStore();
  60. store.currentLocation = "基础管理 / 机构管理";
  61. let rootOrgId = $ref(null);
  62. let code = $ref("");
  63. let name = $ref("");
  64. let enable = $ref(undefined as undefined | string);
  65. let data = $ref([]);
  66. let pageSize = $ref(10);
  67. let pageNo = $ref(1);
  68. let totalElements = $ref(0);
  69. async function search() {
  70. await fetchData();
  71. }
  72. watch(() => [pageNo, pageSize], fetchData);
  73. async function fetchData() {
  74. const res = await getSubOrgList({
  75. code,
  76. name,
  77. enable,
  78. rootOrgId: store.userInfo.rootOrgId,
  79. pageSize,
  80. pageNo,
  81. });
  82. console.log(res);
  83. data = res.data.content;
  84. pageNo = res.data.pageNo;
  85. pageSize = res.data.pageSize;
  86. totalElements = res.data.totalElements;
  87. }
  88. const columns = [
  89. {
  90. title: "顶级机构名称",
  91. dataIndex: "rootOrgName",
  92. width: 150,
  93. },
  94. {
  95. title: "机构代码",
  96. dataIndex: "code",
  97. width: 150,
  98. },
  99. {
  100. title: "机构名称",
  101. dataIndex: "name",
  102. width: 150,
  103. },
  104. {
  105. title: "状态",
  106. dataIndex: "enable",
  107. slots: { customRender: "enable" },
  108. },
  109. {
  110. title: "创建时间",
  111. dataIndex: "createTime",
  112. },
  113. {
  114. title: "创建人",
  115. dataIndex: "creator",
  116. },
  117. {
  118. title: "更新时间",
  119. dataIndex: "updateTime",
  120. },
  121. {
  122. title: "更新人",
  123. dataIndex: "updater",
  124. },
  125. {
  126. title: "Action",
  127. key: "action",
  128. slots: { customRender: "action" },
  129. },
  130. ];
  131. onMounted(async () => {
  132. await search();
  133. });
  134. </script>