index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryForm" inline size="small">
  4. <el-form-item label="关键词">
  5. <el-input v-model="queryForm.name" placeholder="关键词" />
  6. </el-form-item>
  7. </el-form>
  8. <el-row class="action-bar-container" type="flex" justify="end">
  9. <el-button type="primary" size="small" @click.native="fetchData">查询</el-button>
  10. <el-button-group>
  11. <el-button v-permission="['place.base.info.add']" size="small" @click.native="$refs.dialogForm.open({})">
  12. 新建
  13. </el-button>
  14. <el-button v-permission="['place.base.info.delete']" size="small" @click.native="deleteByIds(multipleSelection)">
  15. 删除
  16. </el-button>
  17. </el-button-group>
  18. </el-row>
  19. <el-table
  20. v-loading="isLoading"
  21. :data="pageData.records"
  22. border
  23. fit
  24. highlight-current-row
  25. @selection-change="selectionChange"
  26. >
  27. <el-table-column type="selection" width="55" fixed="left" />
  28. <el-table-column label="ID" prop="id" width="150" />
  29. <el-table-column label="名称" prop="name" min-width="200" />
  30. <el-table-column label="缩略图" width="80">
  31. <template slot-scope="scope">
  32. {{ scope.row.litpics.length }}张
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="地址" prop="address" min-width="350" />
  36. <el-table-column label="分类" prop="category.name" width="100" />
  37. <el-table-column label="联系人" prop="contacts" width="100" />
  38. <el-table-column label="联系电话" prop="contactNumber" width="150" />
  39. <el-table-column label="位置信息" width="200">
  40. <template slot-scope="scope">
  41. [ {{ scope.row.lng }}, {{ scope.row.lat }} ]
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="操作" width="70" fixed="right">
  45. <template slot-scope="scope">
  46. <el-button v-permission="['place.base.info.edit']" type="text" @click.native="$refs.dialogForm.open(scope.row)">编辑</el-button>
  47. </template>
  48. </el-table-column>
  49. </el-table>
  50. <el-pagination
  51. class="pagination-container"
  52. background
  53. layout="prev, pager, next"
  54. :total="pageData.total"
  55. :page-size="pageData.pageSize"
  56. @current-change="paginationChange"
  57. />
  58. <dialog-form ref="dialogForm" @ok="fetchData" />
  59. </div>
  60. </template>
  61. <script>
  62. import { deleteByIds, findPage } from '@/api/place/base_info'
  63. import { dateTimeFormatter } from '@/utils/formater'
  64. import DialogForm from './DialogForm'
  65. export default {
  66. components: { DialogForm },
  67. data() {
  68. return {
  69. queryForm: {},
  70. isLoading: true,
  71. pageData: {},
  72. currentPage: 1,
  73. multipleSelection: []
  74. }
  75. },
  76. created() {
  77. this.fetchData()
  78. },
  79. methods: {
  80. dateTimeFormatter,
  81. selectionChange(val) {
  82. const temp = []
  83. val.forEach(o => {
  84. temp.push(o.id)
  85. })
  86. this.multipleSelection = temp
  87. },
  88. deleteByIds(ids) {
  89. this.$confirm('确认要删除吗?', '提示', {
  90. confirmButtonText: '确定',
  91. cancelButtonText: '取消',
  92. type: 'warning'
  93. }).then(() => {
  94. deleteByIds(ids).then(() => {
  95. this.fetchData()
  96. })
  97. })
  98. },
  99. paginationChange(val) {
  100. this.currentPage = val
  101. this.fetchData()
  102. },
  103. fetchData() {
  104. this.isLoading = true
  105. findPage({ ...this.queryForm, current: this.currentPage })
  106. .then((response) => {
  107. this.pageData = response
  108. })
  109. .finally(() => (this.isLoading = false))
  110. }
  111. }
  112. }
  113. </script>