index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div class="app-container">
  3. <el-button type="primary" icon="el-icon-plus" size="mini" @click="getDetail()"
  4. v-hasPermi="['operation:waken:add']">新增换醒音</el-button>
  5. <!-- 列表 -->
  6. <el-table :data="tableData" v-loading="loading">
  7. <el-table-column type="index" label="序号" align="center" />
  8. <el-table-column label="唤醒音名称" align="center" prop="name" show-overflow-tooltip />
  9. <el-table-column label="唤醒音封面" align="center" width="100px">
  10. <template slot-scope="scope">
  11. <el-image :src="scope.row.pic" />
  12. </template>
  13. </el-table-column>
  14. <el-table-column label="关联设备" align="center" :formatter="devFormatter" show-overflow-tooltip />
  15. <el-table-column label="关联内容数" align="center" prop="num" />
  16. <el-table-column label="操作" align="center">
  17. <template slot-scope="scope">
  18. <el-button type="text" @click="getDetail(scope.row.id, true)">查看</el-button>
  19. <el-button type="text" @click="getDetail(scope.row.id)" v-hasPermi="['operation:waken:edit']">
  20. 编辑
  21. </el-button>
  22. <el-button type="delete" @click="getDelete(scope.row)" v-hasPermi="['operation:waken:delete']">
  23. 删除
  24. </el-button>
  25. </template>
  26. </el-table-column>
  27. </el-table>
  28. </div>
  29. </template>
  30. <script>
  31. import { list, devices, remove } from '@/api/operation/waken'
  32. export default {
  33. data() {
  34. return {
  35. // 遮罩层
  36. loading: false,
  37. // 列表
  38. tableData: [],
  39. // 设备列表
  40. deviceOptions: []
  41. }
  42. },
  43. mounted() {
  44. this.getList()
  45. this.getDevices()
  46. },
  47. methods: {
  48. // 列表
  49. getList() {
  50. this.loading = true
  51. list().then(res => {
  52. if (res.code === 0) {
  53. this.tableData = res.data
  54. this.loading = false
  55. }
  56. })
  57. },
  58. // 设备列表
  59. getDevices() {
  60. this.$nextTick(() => {
  61. devices(1).then(res => {
  62. if (res.code === 0) {
  63. this.deviceOptions = res.data
  64. }
  65. })
  66. })
  67. },
  68. // 详情
  69. getDetail(id, boolean) {
  70. this.$router.push({
  71. path: `/operation/waken/detail`,
  72. query: {
  73. id: id,
  74. boolean: boolean
  75. }
  76. })
  77. },
  78. // 删除
  79. getDelete(row) {
  80. this.$confirm(`是否删除${row.name}?`, `提示`, {
  81. type: 'warning'
  82. }).then(() => {
  83. remove(row.id).then(res => {
  84. if (res.code === 0) {
  85. this.$message.success('删除成功!')
  86. this.getList()
  87. }
  88. })
  89. })
  90. },
  91. // 字典翻译
  92. devFormatter(row) {
  93. return this.deviceOptions.length > 0 ? row.deviceIds.split(',').map(i => this.deviceOptions.find(j => j.clientTypeId == i).name).join(',') : ''
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="scss" scoped></style>