moreDevices.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div class="table">
  3. <div class="button">
  4. <el-button size="mini" icon="el-icon-plus" type="success" @click="goAdd">添加</el-button>
  5. <el-button size="mini" icon="el-icon-close" type="danger" @click="goDelete">删除</el-button>
  6. </div>
  7. <el-table :data="listDataCopy" @selection-change="handleSelectionChange">
  8. <el-table-column
  9. width="50"
  10. type="selection"
  11. />
  12. <el-table-column
  13. prop=""
  14. label="序号"
  15. width="50"
  16. type="index"
  17. :index="showIndex"
  18. />
  19. <el-table-column prop="mingCheng" label="名称">
  20. <template slot-scope="{row}">
  21. <el-input v-model="row.mingCheng" size="mini" />
  22. </template>
  23. </el-table-column>
  24. <el-table-column prop="guiGeXingHao1" label="规格型号" width="200">
  25. <template slot-scope="{row}">
  26. <el-input v-model="row.guiGeXingHao1" size="mini" />
  27. </template>
  28. </el-table-column>
  29. <el-table-column prop="danWei" label="单位" width="80">
  30. <template slot-scope="{row}">
  31. <el-input v-model="row.danWei" size="mini" />
  32. </template>
  33. </el-table-column>
  34. <el-table-column prop="shuLiang" label="数量" width="120">
  35. <template slot-scope="{row}">
  36. <el-input v-model="row.shuLiang" size="mini" type="number" />
  37. </template>
  38. </el-table-column>
  39. <el-table-column prop="yonTu" label="用途">
  40. <template slot-scope="{row}">
  41. <el-input v-model="row.yonTu" size="mini" />
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. <el-pagination
  46. style="margin-top: 5px; padding-bottom: 10px"
  47. :current-page="pagination.currentPage"
  48. :page-sizes="[10, 20,30, 50]"
  49. :page-size="pagination.pageSize"
  50. layout="prev,pager,next,jumper,sizes,->,total"
  51. :total="listDataCopy.length"
  52. @size-change="handleSizeChange"
  53. @current-change="handleCurrentChange"
  54. />
  55. </div>
  56. </template>
  57. <script>
  58. export default {
  59. props: {
  60. params: {
  61. type: Object,
  62. default: () => {}
  63. },
  64. listData: {
  65. type: Array,
  66. default: () => []
  67. }
  68. },
  69. data () {
  70. return {
  71. listDataCopy: [],
  72. pagination: {
  73. pageSize: 10,
  74. currentPage: 1
  75. },
  76. multipleSelection: []
  77. }
  78. },
  79. watch: {
  80. listData: {
  81. handler (val) {
  82. this.listDataCopy = this.listData
  83. }
  84. }
  85. },
  86. methods: {
  87. handleSelectionChange (val) {
  88. this.multipleSelection = val
  89. },
  90. goDelete () {
  91. this.listDataCopy = this.listDataCopy.filter(item => !this.multipleSelection.includes(item))
  92. },
  93. goAdd () {
  94. this.listDataCopy.push({
  95. mingCheng: '',
  96. guiGeXingHao1: '',
  97. danWei: '',
  98. shuLiang: '',
  99. yonTu: ''
  100. })
  101. // this.$set(this.listDataCopy, this.listDataCopy.length, {
  102. // mingCheng: '',
  103. // guiGeXingHao1: '',
  104. // danWei: '',
  105. // shuLiang: '',
  106. // yonTu: ''
  107. // })
  108. },
  109. // 当前页码改变
  110. handleCurrentChange (val) {
  111. this.pagination.currentPage = val
  112. },
  113. // 页码选择器改变
  114. handleSizeChange (val) {
  115. this.pagination.pageSize = val
  116. this.pagination.currentPage = 1
  117. },
  118. // 分页连续序号
  119. showIndex (index) {
  120. return index + 1 + (this.pagination.currentPage - 1) * this.pagination.pageSize
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .table{
  127. .button{
  128. margin-bottom: 5px;
  129. display: flex;
  130. justify-content: flex-end;
  131. }
  132. }
  133. </style>