index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <div class="content-container">
  3. <el-row class="tool-bar">
  4. <el-col :span="12" class="left">
  5. <div class="content-title">
  6. {{ title }}
  7. </div>
  8. </el-col>
  9. <el-col :span="12" class="right">
  10. <el-input v-model="conditions.keywords" class="search-input m-right-15" placeholder="请输入内容">
  11. <el-button slot="append" icon="el-icon-search" @click="getData()" />
  12. </el-input>
  13. <el-button type="primary" @click="handleAdd">添加</el-button>
  14. </el-col>
  15. </el-row>
  16. <el-row class="m-top-15">
  17. <el-table v-loading="listLoading" class="page-table" border :data="dataList" height="calc(100vh - 180px)">
  18. <el-table-column type="index" label="序号" align="center" header-align="center" width="80" />
  19. <el-table-column label="地图名称" align="center" header-align="center" width="200">
  20. <template v-slot="{row}">
  21. <span>{{ row.mapTitle }}</span>
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="说明" align="left" header-align="left">
  25. <template v-slot="{row}">
  26. <span>{{ row.mapDesc }}</span>
  27. </template>
  28. </el-table-column>
  29. <el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width">
  30. <template v-slot="{row}">
  31. <el-button size="mini" type="primary" @click="handleEdit(row)">修改</el-button>
  32. <el-button size="mini" type="danger" @click="handleDelete(row)">删除</el-button>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. </el-row>
  37. <ent-map ref="AddMap" title="新增地图" @formSuccess="getData" />
  38. <ent-map ref="EditMap" title="编辑地图" @formSuccess="getData" />
  39. </div>
  40. </template>
  41. <script>
  42. import EntMap from './components/Map'
  43. import { getMapByPage, deleteMapById } from '@/api/system/mapApi'
  44. export default {
  45. name: 'Index',
  46. components: {
  47. EntMap
  48. },
  49. data() {
  50. return {
  51. title: '地图配置',
  52. dataList: [],
  53. listLoading: false,
  54. total: 0,
  55. conditions: {
  56. page: 1,
  57. limit: 10,
  58. keywords: ''
  59. }
  60. }
  61. },
  62. mounted() {
  63. this.getData()
  64. },
  65. methods: {
  66. // Fetch Data
  67. getData() {
  68. this.listLoading = true
  69. getMapByPage(this.conditions).then((resp) => {
  70. const { data, total } = resp
  71. this.listLoading = false
  72. this.total = total
  73. this.dataList = data
  74. }).catch((error) => {
  75. console.log(error)
  76. })
  77. },
  78. // 查询
  79. handleFilter() {
  80. this.conditions.page = 1
  81. this.getData()
  82. },
  83. // 添加
  84. handleAdd() {
  85. this.$refs['AddMap'].showAddModel()
  86. },
  87. // 修改
  88. handleEdit(data) {
  89. const { mapId } = data
  90. this.$refs['EditMap'].showEditModel(mapId)
  91. },
  92. // 删除
  93. handleDelete(data) {
  94. const { mapId } = data
  95. this.$confirm('此操作将永久删除, 是否继续?', '提示', {
  96. confirmButtonText: '确定',
  97. cancelButtonText: '取消',
  98. type: 'warning'
  99. }).then(() => {
  100. deleteMapById(mapId).then((resp) => {
  101. const { msg } = resp
  102. this.getData()
  103. this.$message({
  104. type: 'success',
  105. message: msg
  106. })
  107. }).catch((error) => {
  108. console.log(error)
  109. })
  110. }).catch(() => {
  111. this.$message({
  112. type: 'info',
  113. message: '已取消删除'
  114. })
  115. })
  116. }
  117. }
  118. }
  119. </script>