index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <ele-pro-table
  5. ref="table"
  6. :columns="columns"
  7. :datasource="datasource"
  8. :selection.sync="selection"
  9. >
  10. <!-- 表头工具栏 -->
  11. <template v-slot:toolbar>
  12. <el-button
  13. type="danger"
  14. icon="el-icon-delete"
  15. class="ele-btn-icon"
  16. v-if="selection.length"
  17. @click="handleBatchDelete"
  18. >
  19. 批量删除
  20. </el-button>
  21. </template>
  22. <!-- 操作列 -->
  23. <template v-slot:action="{ row }">
  24. <el-link
  25. type="primary"
  26. :underline="false"
  27. icon="el-icon-delete"
  28. :style="{ color: delColor }"
  29. @click="handleDelete(row.pointId)"
  30. >
  31. 删除
  32. </el-link>
  33. </template>
  34. </ele-pro-table>
  35. </el-card>
  36. <!-- 新增编辑弹窗 -->
  37. <formModel ref="formRef" :dId="deviceId" @success="reload" />
  38. </div>
  39. </template>
  40. <script>
  41. import * as DevicePointApi from '@/api/ledgerAssets/device/presetInfo'
  42. import formModel from './formModel.vue'
  43. export default {
  44. name: 'CameraPresetInfo',
  45. components: {
  46. formModel
  47. },
  48. props: {
  49. deviceId: ''
  50. },
  51. data() {
  52. return {
  53. delColor: '#F56C6C',
  54. selection: [],
  55. // 表格列配置
  56. columns: [
  57. {
  58. width: 45,
  59. type: 'selection',
  60. columnKey: 'selection',
  61. align: 'center',
  62. fixed: 'left'
  63. },
  64. {
  65. columnKey: 'index',
  66. label: '序号',
  67. type: 'index',
  68. width: 60,
  69. align: 'center'
  70. },
  71. {
  72. prop: 'pointName',
  73. label: '预置位名称',
  74. align: 'left',
  75. minWidth: 200,
  76. showOverflowTooltip: true
  77. },
  78. {
  79. prop: 'indexNo',
  80. label: '排序号',
  81. align: 'center',
  82. width: 100
  83. },
  84. {
  85. columnKey: 'action',
  86. fixed: 'right',
  87. label: '操作',
  88. width: 80,
  89. align: 'center',
  90. slot: 'action'
  91. }
  92. ]
  93. }
  94. },
  95. methods: {
  96. /* 表格数据源 */
  97. datasource({ page, limit }) {
  98. return DevicePointApi.getDevicePointPage({
  99. pageNo: page,
  100. pageSize: limit,
  101. deviceId: this.deviceId
  102. }).then((res) => {
  103. return {
  104. list: res.list.map((item) => ({
  105. ...item,
  106. pointJson: JSON.parse(item.pointJson || '{}')
  107. })),
  108. total: res.total
  109. }
  110. })
  111. },
  112. /* 刷新表格 */
  113. reload() {
  114. this.$refs.table.reload()
  115. },
  116. /** 预置位初始化 */
  117. preSetSuccess() {
  118. this.reload()
  119. },
  120. /** 打开表单 */
  121. openForm(type, id) {
  122. this.$refs.formRef.open(type, id)
  123. },
  124. /** 删除按钮操作 */
  125. handleDelete(id) {
  126. this.$confirm('是否确认删除该预置位?', '警告', {
  127. confirmButtonText: '确定',
  128. cancelButtonText: '取消',
  129. type: 'warning'
  130. })
  131. .then(async () => {
  132. await DevicePointApi.deletedDevicePoint(id)
  133. this.$message.success('删除成功')
  134. this.reload()
  135. })
  136. .catch(() => {})
  137. },
  138. /** 批量删除按钮操作 */
  139. handleBatchDelete() {
  140. if (this.selection.length === 0) {
  141. this.$message.warning('请选择要删除的数据项')
  142. return
  143. }
  144. const ids = this.selection.map((item) => item.pointId)
  145. this.$confirm('是否确认删除选中的预置位?', '警告', {
  146. confirmButtonText: '确定',
  147. cancelButtonText: '取消',
  148. type: 'warning'
  149. })
  150. .then(async () => {
  151. await DevicePointApi.batchDeleteDevicePoint(ids)
  152. this.$message.success('删除成功')
  153. this.reload()
  154. })
  155. .catch(() => {})
  156. }
  157. }
  158. }
  159. </script>
  160. <style lang="scss" scoped></style>