index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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.keyword" 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="['bz.data.info.add']" size="small" @click.native="$refs.dialogForm.open({})">
  12. 新建
  13. </el-button>
  14. <el-button v-permission="['bz.data.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"/>
  28. <el-table-column label="ID" prop="id" width="150"/>
  29. <el-table-column label="名称" prop="name"/>
  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"/>
  36. <el-table-column label="联系人" prop="contacts" width="150"/>
  37. <el-table-column label="联系电话" prop="contactNumber" width="150"/>
  38. <el-table-column label="位置信息" width="200">
  39. <template slot-scope="scope">
  40. [ {{ scope.row.lng }}, {{ scope.row.lat }} ]
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="操作" width="70" fixed="right">
  44. <template slot-scope="scope">
  45. <el-button v-permission="['bz.data.info.edit']" type="text" @click.native="$refs.dialogForm.open(scope.row)">编辑</el-button>
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. <el-pagination
  50. class="pagination-container"
  51. background
  52. layout="prev, pager, next"
  53. :total="pageData.total"
  54. :page-size="pageData.pageSize"
  55. @current-change="paginationChange"
  56. />
  57. <dialog-form ref="dialogForm" @ok="fetchData"/>
  58. </div>
  59. </template>
  60. <script>
  61. import { deleteByIds, findPage } from '@/api/base/data_info'
  62. import { dateTimeFormatter } from '@/utils/formater'
  63. import DialogForm from './DialogForm'
  64. export default {
  65. components: { DialogForm },
  66. data() {
  67. return {
  68. queryForm: {},
  69. isLoading: true,
  70. pageData: {},
  71. currentPage: 1,
  72. multipleSelection: []
  73. }
  74. },
  75. created() {
  76. this.fetchData()
  77. },
  78. methods: {
  79. dateTimeFormatter,
  80. selectionChange(val) {
  81. const temp = []
  82. val.forEach(o => {
  83. temp.push(o.id)
  84. })
  85. this.multipleSelection = temp
  86. },
  87. deleteByIds(ids) {
  88. this.$confirm('确认要删除吗?', '提示', {
  89. confirmButtonText: '确定',
  90. cancelButtonText: '取消',
  91. type: 'warning'
  92. }).then(() => {
  93. deleteByIds(ids).then(() => {
  94. this.fetchData()
  95. })
  96. })
  97. },
  98. paginationChange(val) {
  99. this.currentPage = val
  100. this.fetchData()
  101. },
  102. fetchData() {
  103. this.isLoading = true
  104. findPage({ ...this.queryForm, current: this.currentPage })
  105. .then((response) => {
  106. this.pageData = response
  107. })
  108. .finally(() => (this.isLoading = false))
  109. }
  110. }
  111. }
  112. </script>