ClientTable.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div class="admin-department">
  3. <el-form :inline="true">
  4. <el-form-item label="人员名称">
  5. <el-input
  6. v-model="queryParams.name"
  7. size="small"
  8. placeholder="请输入"
  9. ></el-input>
  10. </el-form-item>
  11. <el-form-item>
  12. <el-button type="" size="small" @click="getList">查询</el-button>
  13. <el-button type="primary" size="small" @click="submit">保存</el-button>
  14. </el-form-item>
  15. </el-form>
  16. <el-table
  17. :data="tableData"
  18. v-loading="loading"
  19. style="width: 100%"
  20. v-if="showTable"
  21. >
  22. <el-table-column width="55" align="center">
  23. <template slot-scope="scope">
  24. <div>
  25. <el-checkbox :checked="personIds.indexOf(scope.row.id)!=-1" @change="getCheck(scope.row)" v-if="showCheck"></el-checkbox>
  26. </div>
  27. </template>
  28. </el-table-column>
  29. <el-table-column
  30. prop="name"
  31. label="人员名称"
  32. align="center"
  33. show-overflow-tooltip
  34. ></el-table-column>
  35. <el-table-column
  36. label="Email"
  37. prop="email"
  38. align="center"
  39. show-overflow-tooltip
  40. >
  41. </el-table-column>
  42. <el-table-column
  43. prop="mobile"
  44. label="手机号码"
  45. align="center"
  46. show-overflow-tooltip
  47. ></el-table-column>
  48. <el-table-column
  49. prop="personnelDescription"
  50. label="描述"
  51. align="center"
  52. show-overflow-tooltip
  53. ></el-table-column>
  54. </el-table>
  55. <div class="pagination">
  56. <el-pagination
  57. :current-page.sync="queryParams.current"
  58. :page-size="queryParams.size"
  59. :total="total"
  60. @current-change="handleCurrentChange"
  61. layout="total, prev, pager, next, jumper"
  62. background
  63. ></el-pagination>
  64. </div>
  65. </div>
  66. </template>
  67. <script>
  68. export default {
  69. props:{
  70. personIds:{
  71. default:[]
  72. },
  73. persons:{
  74. default:[]
  75. },
  76. },
  77. data() {
  78. name: "ClientTable";
  79. return {
  80. visible: false,
  81. loading: false,
  82. total: 0,
  83. tableData: [],
  84. queryParams: {
  85. tenantId: this.tenantId,
  86. tenantName: "",
  87. size: 10,
  88. current: 1,
  89. projectId: this.projectId,
  90. },
  91. showTable:true,
  92. showCheck:true
  93. };
  94. },
  95. mounted() {
  96. this.getList();
  97. },
  98. watch:{
  99. personIds(val){
  100. this.showCheck = false
  101. this.$nextTick(()=>{
  102. this.showCheck = true
  103. })
  104. }
  105. },
  106. computed: {
  107. },
  108. methods: {
  109. getList() {
  110. this.loading = true;
  111. this.$api
  112. .getPersonList(this.queryParams)
  113. .then((response) => {
  114. this.tableData = response.data;
  115. this.total = response.data.total;
  116. this.loading = false;
  117. })
  118. .catch((error) => {
  119. this.loading = false;
  120. });
  121. },
  122. close() {
  123. this.visible = false;
  124. },
  125. handleCurrentChange(val) {
  126. this.queryParams.current = val;
  127. this.getList();
  128. },
  129. //保存
  130. submit(){
  131. this.$emit('getPersonIds',{personIds:this.personIds,persons:this.persons})
  132. },
  133. //选择
  134. getCheck(row){
  135. var index = this.personIds.indexOf(row.id)
  136. if(index==-1){
  137. this.personIds.push(row.id)
  138. this.persons.push(row)
  139. }else{
  140. this.personIds.splice(index,1)
  141. this.persons.splice(index,1)
  142. }
  143. }
  144. },
  145. };
  146. </script>
  147. <style lang="scss" scoped>
  148. .admin-department {
  149. border: 1px solid #eee;
  150. padding: 20px;
  151. // border-radius: 8px;
  152. }
  153. </style>