ClientTable.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <div class="admin-department">
  3. <el-form :inline="true">
  4. <el-form-item label="人员名称">
  5. <el-input v-model="queryParams.name" size="small" placeholder="请输入"></el-input>
  6. </el-form-item>
  7. <el-form-item>
  8. <el-button type="primary" size="small" @click="init">查询</el-button>
  9. </el-form-item>
  10. </el-form>
  11. <el-table :data="tableData" v-loading="loading" style="width: 100%" @selection-change="handleSelectionChange">
  12. <el-table-column type="selection" width="55"></el-table-column>
  13. <el-table-column prop="name" label="人员名称" align="center" show-overflow-tooltip></el-table-column>
  14. <el-table-column label="Email" prop="email" align="center" show-overflow-tooltip>
  15. </el-table-column>
  16. <el-table-column prop="mobile" label="手机号码" align="center" show-overflow-tooltip></el-table-column>
  17. <el-table-column prop="remark" label="描述" align="center" show-overflow-tooltip></el-table-column>
  18. </el-table>
  19. <div class="pagination">
  20. <el-pagination :current-page.sync="queryParams.current" :page-size="queryParams.size" :total="total"
  21. @current-change="handleCurrentChange" layout="total, prev, pager, next, jumper" background></el-pagination>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. export default {
  27. name: "ClientTable",
  28. props: ["tenantId", "projectId"],
  29. data() {
  30. return {
  31. // 表格的loading
  32. loading: false,
  33. // 总条数
  34. total: 0,
  35. // 表格数据源
  36. tableData: [],
  37. multipleSelection: [],
  38. id: [],
  39. users: [],
  40. // 分页信息以及
  41. queryParams: {
  42. tenantId: this.tenantId,
  43. tenantName: "",
  44. size: 10,
  45. current: 1,
  46. },
  47. };
  48. },
  49. mounted() {
  50. this.getList();
  51. },
  52. computed: {
  53. },
  54. methods: {
  55. init(){
  56. this.queryParams.current = 1
  57. this.getList()
  58. },
  59. // 获取数据
  60. getList() {
  61. this.loading = true;
  62. let params = {
  63. projectId: this.projectId,
  64. ...this.queryParams,
  65. }
  66. this.$api
  67. .getPersonList(params)
  68. .then((response) => {
  69. this.tableData = response.data;
  70. this.total = response.pageColumn.total;
  71. this.loading = false;
  72. })
  73. .catch((error) => {
  74. this.loading = false;
  75. });
  76. },
  77. // 当选择项发生变化时会触发
  78. handleSelectionChange(val) {
  79. this.id = [];
  80. this.users = []
  81. this.multipleSelection = val;
  82. for (let i = 0; i < this.multipleSelection.length; i++) {
  83. this.id.push(this.multipleSelection[i].id)
  84. this.users.push({ userId: this.multipleSelection[i].id, tenantId: this.multipleSelection[i].tenantId })
  85. }
  86. // console.log(this.users);
  87. this.$emit('getId', this.id, this.users)
  88. },
  89. // 分页信息
  90. handleCurrentChange(val) {
  91. this.queryParams.current = val;
  92. this.getList();
  93. },
  94. },
  95. };
  96. </script>
  97. <style lang="scss" scoped>
  98. .admin-department {
  99. border: 1px solid #eee;
  100. padding: 20px;
  101. // border-radius: 8px;
  102. .pagination{
  103. margin-top: 10px;
  104. text-align: right;
  105. }
  106. }
  107. </style>