Table.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <el-table
  3. :data="tableData"
  4. border
  5. class="table"
  6. height="auto"
  7. @selection-change="handleSelectionChange"
  8. style="width: 100%">
  9. <el-table-column
  10. type="selection"
  11. fixed
  12. width="55">
  13. </el-table-column>
  14. <el-table-column
  15. prop="phone"
  16. label="手机号"
  17. width="360">
  18. </el-table-column>
  19. <el-table-column
  20. prop="stateName"
  21. label="状态"
  22. width="360">
  23. </el-table-column>
  24. <el-table-column
  25. prop="createTime"
  26. label="注册时间"
  27. width="360">
  28. </el-table-column>
  29. <el-table-column
  30. label="操作"
  31. fixed="right"
  32. >
  33. <template slot-scope="scope">
  34. <el-button v-if="scope.row.state === 0" type="text" @click="handleAudit(scope.row)">处理</el-button>
  35. <el-button v-else type="text" @click="handleUnAudit(scope.row)">撤回</el-button>
  36. </template>
  37. </el-table-column>
  38. </el-table>
  39. </template>
  40. <script>
  41. export default {
  42. name: 'Table',
  43. inject: {
  44. tableServiceData: {
  45. type: Object,
  46. default: () => {
  47. },
  48. },
  49. paginationServiceData: {
  50. type: Object,
  51. default: () => {
  52. },
  53. },
  54. },
  55. computed: {
  56. tableData() {
  57. return this.tableServiceData.myData;
  58. },
  59. },
  60. methods: {
  61. handleSelectionChange(data) {
  62. const arr = [];
  63. data.forEach(item => {
  64. arr.push(item.deId);
  65. });
  66. this.$emit('select-change', arr);
  67. },
  68. handleAudit(data) {
  69. this.$emit('audit', data);
  70. },
  71. handleUnAudit(data) {
  72. this.$emit('unAudit', data);
  73. },
  74. },
  75. };
  76. </script>
  77. <style lang="scss" scoped>
  78. .table {
  79. ::v-deep .is-leaf {
  80. .cell {
  81. text-align: center;
  82. }
  83. }
  84. ::v-deep .el-table-column--selection {
  85. .cell {
  86. text-align: center;
  87. }
  88. }
  89. }
  90. </style>