maintenance.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <div class="table">
  3. <div v-if="!readonly" 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="weiHuLeiXing" label="维护类型" width="120" />
  20. <el-table-column prop="weiHuRiQi" label="维护日期" width="200" />
  21. <el-table-column prop="weiHuXiangMuC" label="维护项目" />
  22. <el-table-column prop="" label="操作" width="140">
  23. <template slot-scope="{row, $index}">
  24. <el-button size="mini" type="text" icon="el-icon-edit-outline" @click="goEdit(row, $index)">编辑</el-button>
  25. </template>
  26. </el-table-column>
  27. </el-table>
  28. <el-pagination
  29. style="margin-top: 5px; padding-bottom: 10px"
  30. :current-page="pagination.currentPage"
  31. :page-sizes="[10, 20,30, 50]"
  32. :page-size="pagination.pageSize"
  33. layout="prev,pager,next,jumper,sizes,->,total"
  34. :total="listDataCopy.length"
  35. @size-change="handleSizeChange"
  36. @current-change="handleCurrentChange"
  37. />
  38. <DeviceSubtableDialog
  39. v-if="visible"
  40. :dynamic-params="dynamicParams"
  41. :visible="visible"
  42. @close="close"
  43. @submit="getSonData"
  44. />
  45. </div>
  46. </template>
  47. <script>
  48. import DeviceSubtableDialog from '@/views/component/deviceSubtableDialog.vue'
  49. export default {
  50. components: {
  51. DeviceSubtableDialog
  52. },
  53. props: {
  54. params: {
  55. type: Object,
  56. default: () => {}
  57. },
  58. listData: {
  59. type: Array,
  60. default: () => []
  61. },
  62. readonly: {
  63. type: Boolean,
  64. default: false
  65. }
  66. },
  67. data () {
  68. return {
  69. pagination: {
  70. pageSize: 10,
  71. currentPage: 1
  72. },
  73. listDataCopy: this.listData,
  74. visible: false,
  75. dynamicParams: {
  76. editFromType: '添加',
  77. customComponent: true
  78. },
  79. multipleSelection: []
  80. }
  81. },
  82. watch: {
  83. listData: {
  84. handler (val) {
  85. this.listDataCopy = this.listData
  86. }
  87. }
  88. },
  89. methods: {
  90. mounted () {
  91. },
  92. // 子组件的提交事件
  93. getSonData (val) {
  94. this.$set(this.listDataCopy, typeof val.index === 'undefined' ? this.listDataCopy.length : val.index, {
  95. ...this.listDataCopy[val.index],
  96. weiHuLeiXing: val.weiHuLeiXing,
  97. weiHuRiQi: val.weiHuRiQi,
  98. weiHuXiangMuC: val.weiHuXiangMuC,
  99. riQiShuZi: val.riQiShuZi,
  100. kaiShiShiJian: val.kaiShiShiJian
  101. })
  102. },
  103. handleSelectionChange (val) {
  104. this.multipleSelection = val
  105. },
  106. goDelete () {
  107. this.listDataCopy = this.listDataCopy.filter(item => !this.multipleSelection.includes(item))
  108. },
  109. goAdd () {
  110. this.dynamicParams.editFromType = '添加'
  111. delete this.dynamicParams.row
  112. delete this.dynamicParams.index
  113. this.visible = true
  114. },
  115. goEdit (row, index) {
  116. this.dynamicParams.editFromType = '修改'
  117. this.dynamicParams.row = row
  118. this.dynamicParams.index = index
  119. this.visible = true
  120. },
  121. // 弹窗关闭事件回调
  122. close () {
  123. this.visible = false
  124. },
  125. // 当前页码改变
  126. handleCurrentChange (val) {
  127. this.pagination.currentPage = val
  128. },
  129. // 页码选择器改变
  130. handleSizeChange (val) {
  131. this.pagination.pageSize = val
  132. this.pagination.currentPage = 1
  133. },
  134. // 分页连续序号
  135. showIndex (index) {
  136. return index + 1 + (this.pagination.currentPage - 1) * this.pagination.pageSize
  137. }
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .table{
  143. .button{
  144. margin-bottom: 5px;
  145. display: flex;
  146. justify-content: flex-end;
  147. }
  148. }
  149. </style>