index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="添加人员"
  5. :visible.sync="drawer"
  6. append-to-body
  7. direction="rtl"
  8. width="60%">
  9. <div class="flex-align-center flex-between " style="margin-top:-10px;margin-bottom: 10px">
  10. <div class="flex-align-center">
  11. <el-input size="small" suffix-icon="el-icon-search" v-model="param.content.where.condition" placeholder="人员名称" @keyup.enter.native="listData(param.content.pageNumber = 1)" @clear="listData(param.content.pageNumber = 1)" clearable></el-input>&nbsp;
  12. </div>
  13. <el-button type="primary" size="mini" @click="onSbmit" :disabled="selectRowId.length == 0">批量添加</el-button>
  14. </div>
  15. <div class="produtMag-panel" style="margin-top: 10px">
  16. <el-table
  17. @select="selectionChange"
  18. border
  19. ref="tables"
  20. :data="list"
  21. style="width: 100%">
  22. <el-table-column
  23. type="selection"
  24. width="42"
  25. fixed>
  26. </el-table-column>
  27. <el-table-column
  28. prop="accountno"
  29. label="账号">
  30. </el-table-column>
  31. <el-table-column
  32. prop="name"
  33. label="账号名称">
  34. </el-table-column>
  35. <el-table-column
  36. prop="phonenumber"
  37. label="联系电话">
  38. </el-table-column>
  39. <el-table-column
  40. prop="usertypename"
  41. label="用户类型"
  42. width="160">
  43. </el-table-column>
  44. </el-table>
  45. <div>
  46. <div style="float: left">已选:{{selectRowId.length}}个人员</div>
  47. <div style="margin-top:16px;text-align:right">
  48. <el-pagination
  49. background
  50. small
  51. @size-change="handleSizeChange"
  52. @current-change="handleCurrentChange"
  53. :current-page="currentPage"
  54. :page-size="param.content.pageSize"
  55. layout="total, prev, pager, next, jumper"
  56. :total="total">
  57. </el-pagination>
  58. </div>
  59. </div>
  60. </div>
  61. </el-dialog>
  62. <slot name="input"></slot>
  63. </div>
  64. </template>
  65. <script>
  66. export default {
  67. props:['data'],
  68. components:{
  69. },
  70. data () {
  71. return {
  72. drawer:false,
  73. param:{
  74. "id": 20221031141102,
  75. "content": {
  76. "pageSize":20,
  77. "pageNumber":1,
  78. "where": {
  79. "condition": "",
  80. }
  81. }
  82. },
  83. list:[],
  84. currentPage:0,
  85. total:0,
  86. selectRowId:[],
  87. selectAllData:[]
  88. }
  89. },
  90. watch: {
  91. list (val) {
  92. this.list.forEach((row) => {
  93. this.selectRowId.forEach(item => {
  94. if (row.userid == item) {
  95. this.$nextTick(() => {
  96. this.$refs["tables"].toggleRowSelection(row, true);
  97. })
  98. }
  99. })
  100. });
  101. },
  102. },
  103. methods:{
  104. async listData () {
  105. this.param.content.sa_salesforecastbillid = this.$route.query.id
  106. const res = await this.$api.requested(this.param)
  107. console.log(res.data,"人员列表")
  108. this.list = res.data
  109. this.total = res.total
  110. this.currentPage = res.pageNumber
  111. },
  112. selectionChange (arrs,arr) {
  113. let index = this.selectRowId.findIndex(item => item == arr.userid)
  114. if (index != -1) {
  115. this.selectAllData.splice(index,1)
  116. this.selectRowId.splice(index,1)
  117. } else {
  118. this.selectRowId.push(arr.userid)
  119. this.selectAllData.push(arr)
  120. }
  121. },
  122. normalSetId () {
  123. this.listData()
  124. this.selectAllData = this.data.userids.map(item => {
  125. return {
  126. userid: item,
  127. name: this.data.usermsg[item]
  128. }
  129. })
  130. console.log(this.selectAllData);
  131. this.selectRowId = this.data.userids
  132. },
  133. onSbmit () {
  134. this.$emit('onResult',this.selectAllData)
  135. this.drawer = false
  136. },
  137. handleSizeChange(val) {
  138. // console.log(`每页 ${val} 条`);
  139. this.param.content.pageSize = val
  140. this.listData()
  141. },
  142. handleCurrentChange(val) {
  143. // console.log(`当前页: ${val}`);
  144. this.param.content.pageNumber = val
  145. this.listData()
  146. },
  147. },
  148. mounted () {
  149. }
  150. }
  151. </script>
  152. <style>
  153. </style>