RootOrg.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <div>
  3. <div class="tw-bg-white tw-p-5 tw-rounded-xl tw-mb-5">
  4. <a-input
  5. v-model:value="code"
  6. style="width: 178px"
  7. placeholder="顶级机构代码"
  8. allowClear
  9. ></a-input>
  10. <span class="tw-mr-4"></span>
  11. <a-input
  12. v-model:value="name"
  13. class="tw-mr-4"
  14. style="width: 178px"
  15. placeholder="顶级机构名称"
  16. allowClear
  17. ></a-input>
  18. <span class="tw-mr-4"></span>
  19. <StateSelect v-model:value="enable" />
  20. <span class="tw-mr-4"></span>
  21. <a-button @click="search" class="query-btn">查询</a-button>
  22. <a-button @click="handleRootOrgSync" style="float: right">同步</a-button>
  23. </div>
  24. <div class="tw-bg-white tw-p-5 tw-rounded-xl">
  25. <a-table
  26. row-key="code"
  27. :columns="columns"
  28. :data-source="data"
  29. :pagination="{
  30. pageSize: pageSize,
  31. current: pageNo,
  32. total: totalElements,
  33. showTotal: (total: number) => `总数:${total}`,
  34. onChange: (pageNoChanged: number, pageSizeChanged: number) => {
  35. pageNo = pageNoChanged;
  36. pageSize = pageSizeChanged;
  37. }
  38. }"
  39. >
  40. <template #enable="{ text }">
  41. <a>{{ $filters.booleanEnableDisableFilter(text) }}</a>
  42. </template>
  43. <template #action="{ record }">
  44. <span>
  45. <a-button @click="showModal(record)">编辑</a-button>
  46. <a-button @click="editRootOrgSettings(record.id)"
  47. >特殊设置</a-button
  48. >
  49. </span>
  50. </template>
  51. </a-table>
  52. </div>
  53. <a-modal
  54. v-model:visible="visible"
  55. title="顶级机构信息页"
  56. @ok="handleOk"
  57. ok-text="确定"
  58. cancel-text="取消"
  59. >
  60. <a-form :labelCol="{ span: 5 }">
  61. <a-form-item label="顶级机构代码">
  62. <a-input disabled v-model:value="rootOrgObj.code"></a-input>
  63. </a-form-item>
  64. <a-form-item label="顶级机构名称">
  65. <a-input disabled v-model:value="rootOrgObj.name"></a-input>
  66. </a-form-item>
  67. <a-form-item label="状态">
  68. <a-radio-group disabled v-model:value="rootOrgObj.enable">
  69. <a-radio :value="true">启用</a-radio>
  70. <a-radio :value="false">禁用</a-radio>
  71. </a-radio-group>
  72. </a-form-item>
  73. <a-form-item label="顶级机构域名">
  74. <a-input v-model:value="rootOrgObj.domainName"></a-input>
  75. </a-form-item>
  76. </a-form>
  77. </a-modal>
  78. </div>
  79. </template>
  80. <script setup lang="ts">
  81. import { getRootOrgList, syncRootOrg, updateRootOrg } from "@/api/rootOrgPage";
  82. import router from "@/router";
  83. import { useMainStore } from "@/store";
  84. import { message } from "ant-design-vue";
  85. import { ref, onMounted, reactive } from "vue";
  86. const store = useMainStore();
  87. store.currentLocation = "基础管理 / 顶级机构管理";
  88. let code = $ref("");
  89. let name = $ref("");
  90. let enable = $ref(undefined as undefined | boolean);
  91. let data = $ref([]);
  92. let pageSize = $ref(10);
  93. let pageNo = $ref(1);
  94. let totalElements = $ref(0);
  95. async function search() {
  96. const res = await getRootOrgList({ code, name, enable, pageSize, pageNo });
  97. // console.log(res);
  98. data = res.data.content;
  99. pageNo = res.data.pageNo;
  100. pageSize = res.data.pageSize;
  101. totalElements = res.data.totalElements;
  102. }
  103. const columns = [
  104. {
  105. title: "顶级机构代码",
  106. dataIndex: "code",
  107. width: 150,
  108. },
  109. {
  110. title: "顶级机构名称",
  111. dataIndex: "name",
  112. width: 150,
  113. },
  114. {
  115. title: "状态",
  116. dataIndex: "enable",
  117. slots: { customRender: "enable" },
  118. },
  119. {
  120. title: "顶级机构域名",
  121. dataIndex: "domainName",
  122. },
  123. {
  124. title: "更新时间",
  125. dataIndex: "updateTime",
  126. },
  127. {
  128. title: "操作",
  129. key: "action",
  130. slots: { customRender: "action" },
  131. },
  132. ];
  133. onMounted(async () => {
  134. await search();
  135. });
  136. const visible = ref<boolean>(false);
  137. const showModal = (record: any) => {
  138. Object.assign(rootOrgObj, record);
  139. visible.value = true;
  140. };
  141. const editRootOrgSettings = (orgId: number) => {
  142. router.push("/basic/rootOrg/edit/" + orgId);
  143. };
  144. const handleOk = async (e: MouseEvent) => {
  145. await updateRootOrg({ domainName: rootOrgObj.domainName });
  146. visible.value = false;
  147. await search();
  148. };
  149. const rootOrgObj = reactive({
  150. code: "",
  151. name: "",
  152. enable: true,
  153. domainName: "",
  154. });
  155. async function handleRootOrgSync() {
  156. await syncRootOrg();
  157. message.success("操作成功");
  158. }
  159. </script>