index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div class="app-container">
  3. <search-form
  4. :list-loading="listLoading"
  5. @change="searchHandle"
  6. />
  7. <table-list
  8. :list-loading="listLoading"
  9. :data="tableData2"
  10. :columns="listConfig"
  11. :current-page="currentPage"
  12. :page-size="pageSize"
  13. :total-records="totalRecords"
  14. @currentChange="pageHandle"
  15. :isAdd="true"
  16. @add="openPopup"
  17. :insertSlotArr="[4]"
  18. >
  19. <div slot="OI4">
  20. <el-table-column
  21. width="50"
  22. label="链接"
  23. align="center"
  24. >
  25. <template slot-scope="scope">
  26. <a :href="scope.row.link" target="_blank" class="scoped-link">链接</a>
  27. </template>
  28. </el-table-column>
  29. </div>
  30. </table-list>
  31. <popup-edit
  32. :isShow="isDtlShow"
  33. :curObj="curObj"
  34. @close="closePopup"
  35. />
  36. </div>
  37. </template>
  38. <script>
  39. import { arrToObj } from '@/utils'
  40. import SearchForm from './components/searchForm/Index'
  41. import PopupEdit from './components/popup/IndexEdit'
  42. import baseTable from '_m/baseTable.js'
  43. export default {
  44. name: 'index',
  45. components: {
  46. SearchForm,
  47. PopupEdit,
  48. },
  49. provide() {
  50. return {
  51. parentData: this
  52. }
  53. },
  54. mixins: [baseTable],
  55. data() {
  56. return {
  57. apiStr: 'house.adminformationlist',
  58. searchForm: null,
  59. isDtlShow: false,
  60. curObj: {}
  61. }
  62. },
  63. computed: {
  64. tableData2() {
  65. const defaultImg = require('@/assets/ex_test.jpg')
  66. const arr = [...this.tableData]
  67. arr.map(item => {
  68. item.pri_image = item.pri_image || defaultImg
  69. item.hide_status = Number(item.hide_status)
  70. })
  71. return arr
  72. }
  73. },
  74. created() {},
  75. mounted() {
  76. this.listConfig = {
  77. rows: [
  78. { label: '标题', prop: 'title', fullShow: true, minWidth: 200 },
  79. { label: '分类', prop: 'information_category', type: 'flag', flags: arrToObj(this.$dictData.information_category) },
  80. { label: '主图', prop: 'pri_image', type: 'img' },
  81. // { label: '链接', prop: 'link' },
  82. { label: '作者', prop: 'author' },
  83. { label: '状态', prop: 'hide_status', type: 'tag', tags: arrToObj(this.$dictData.hide_status) },
  84. { label: '更新人', prop: 'update_by' },
  85. { label: '更新时间', prop: 'update_at' },
  86. { label: '操作', width: 120, type: 'handle2', operations:
  87. [
  88. { label: '编辑', func: this.openPopup, btnType: 'primary' },
  89. { label: '删除', func: this.delHandle, btnType: 'danger' },
  90. ]
  91. }
  92. ]
  93. }
  94. },
  95. methods: {
  96. delHandle(row) {
  97. this.$msg(`您确定要删除该文章吗?`, 'confirm', () => {
  98. this.$api.house.adminformationdel({
  99. id: row.id,
  100. }).then(data => {
  101. this.$msgs(`已删除!`)
  102. this.fetchData()
  103. })
  104. }, null, true)
  105. },
  106. openPopup(row) {
  107. if (row && row.id) {
  108. this.curObj = row
  109. } else {
  110. this.curObj = {}
  111. }
  112. this.isDtlShow = true
  113. },
  114. closePopup(obj) {
  115. this.isDtlShow = false
  116. if (obj) {
  117. this.fetchData()
  118. }
  119. }
  120. }
  121. }
  122. </script>
  123. <style lang="scss" scoped>
  124. .scoped-link {
  125. color: #2d8cf0;
  126. text-decoration: underline;
  127. }
  128. </style>