organList.vue 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <div class="list_container">
  3. <div class="title_examine">
  4. <div class="pub_title">组织列表</div>
  5. </div>
  6. <div class="tableBox">
  7. <el-table :data="organizations" stripe border style="width: 100%" :header-cell-style="headerCellStyle">
  8. <el-table-column show-overflow-tooltip prop="name" label="组织名称" min-width="45"></el-table-column>
  9. <el-table-column show-overflow-tooltip prop="code" label="编码" min-width="45"></el-table-column>
  10. <el-table-column show-overflow-tooltip prop="ctime" label="创建时间" min-width="45"></el-table-column>
  11. <el-table-column label="操作" width="150px">
  12. <template slot-scope="scope">
  13. <div class="operate">
  14. <button style="color: #308fff;" @click="update(scope.row)">编辑</button>
  15. </div>
  16. </template>
  17. </el-table-column>
  18. </el-table>
  19. </div>
  20. <!-- 分页组件 -->
  21. <el-pagination :current-page="currentPage" :page-size="pageSize" :total="total"
  22. @current-change="handlePageChange" layout="total,prev, pager, next, jumper">
  23. </el-pagination>
  24. </div>
  25. </template>
  26. <script>
  27. import { API_CONFIG } from '@/common/apiConfig';
  28. export default {
  29. name: 'onList',
  30. data() {
  31. return {
  32. organizations: [],
  33. currentPage:1,
  34. pageSize: 10,
  35. total: 0
  36. }
  37. },
  38. methods: {
  39. // 表头的背景色
  40. headerCellStyle() {
  41. return { backgroundColor: "#f1f1f1" };
  42. },
  43. getOrgan() {
  44. let params = [
  45. {
  46. functionName: "getOrgan",
  47. page: this.currentPage,
  48. num: this.pageSize,
  49. }
  50. ];
  51. this.$ajax
  52. .post(API_CONFIG.baseUrl, params)
  53. .then((res) => {
  54. // console.log("返回的数据为:", res.data); // 检查返回的数据
  55. if (res.data && Array.isArray(res.data[0])) {
  56. // 使用 map() 提取所有组织名称
  57. this.organizations = res.data[0]
  58. this.total = res.data[0][0].num
  59. console.log(this.organizations);
  60. }
  61. })
  62. .catch((err) => {
  63. this.$message.error("查询失败");
  64. console.error("请求失败,错误信息:", err);
  65. });
  66. },
  67. // 页码扩展按钮
  68. handlePageChange(page) {
  69. this.currentPage = page;
  70. this.getOrgan();
  71. },
  72. },
  73. mounted() {
  74. this.getOrgan()
  75. }
  76. }
  77. </script>
  78. <style scoped>
  79. .list_container {
  80. width: 100%;
  81. height: 100%;
  82. padding: 10px;
  83. box-sizing: border-box;
  84. overflow: auto;
  85. }
  86. .tableBox {
  87. margin: 10px 0;
  88. }
  89. .operate button {
  90. background: none;
  91. border: none;
  92. cursor: pointer;
  93. }
  94. </style>