compete.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. />
  18. <popup-edit
  19. :isShow="isDtlShow"
  20. :curObj="curObj"
  21. @close="closePopup"
  22. />
  23. </div>
  24. </template>
  25. <script>
  26. import { arrToObj } from '@/utils'
  27. import SearchForm from './components/searchForm/Compete'
  28. import PopupEdit from './components/popup/CompeteEdit'
  29. import baseTable from '_m/baseTable.js'
  30. export default {
  31. name: 'price',
  32. components: {
  33. SearchForm,
  34. PopupEdit,
  35. },
  36. provide() {
  37. return {
  38. parentData: this
  39. }
  40. },
  41. mixins: [baseTable],
  42. data() {
  43. return {
  44. apiStr: 'house.admestatecompetelist',
  45. searchForm: {},
  46. isDtlShow: false,
  47. // noCreated: true,
  48. curObj: {},
  49. }
  50. },
  51. computed: {
  52. tableData2() {
  53. const arr = [...this.tableData]
  54. arr.map(item => {
  55. const product_type = item.product_type ? item.product_type.split(',') : []
  56. const productTypeName = product_type.map(v => {
  57. return arrToObj(this.$dictData.product_type)[v]
  58. })
  59. item.productTypeName = productTypeName.join(',')
  60. })
  61. return arr
  62. }
  63. },
  64. created() {
  65. const query = this.$route.query
  66. this.searchForm.estate_id = query.id || ''
  67. },
  68. mounted() {
  69. this.listConfig = {
  70. rows: [
  71. { label: '排序', prop: 'sort', type: 'input', width: 80},
  72. { label: '竞品', prop: 'estate_name'},
  73. { label: '所属区域', prop: 'area_type', type: 'flag', flags: arrToObj(this.$dictData.area_type) },
  74. { label: '产品类型', prop: 'productTypeName'},
  75. { label: '更新人', prop: 'update_by' },
  76. { label: '更新时间', prop: 'update_at' },
  77. { label: '操作', width: 200, type: 'handle2', operations:
  78. [
  79. // { label: '编辑', func: this.openPopup, btnType: 'primary' },
  80. { label: '保存排序', func: this.saveHandle, btnType: 'primary' },
  81. { label: '删除', func: this.delHandle, btnType: 'danger' },
  82. ]
  83. }
  84. ]
  85. }
  86. },
  87. methods: {
  88. saveHandle (row) {
  89. this.$api.house.admestatecompeteedit({
  90. id: row.id,
  91. compete_id: row.estate_id,
  92. sort: row.sort,
  93. }).then(data => {
  94. this.$msgs('更新成功')
  95. this.fetchData()
  96. })
  97. },
  98. delHandle(row) {
  99. this.$msg(`您确定要删除该竞品吗?`, 'confirm', () => {
  100. this.$api.house.admestatecompetedel({
  101. id: row.id,
  102. }).then(data => {
  103. this.$msgs(`已删除!`)
  104. this.fetchData()
  105. })
  106. }, null, true)
  107. },
  108. openPopup(row) {
  109. if (row && row.id) {
  110. this.curObj = row
  111. } else {
  112. this.curObj = {}
  113. }
  114. this.isDtlShow = true
  115. },
  116. closePopup(obj) {
  117. this.isDtlShow = false
  118. if (obj) {
  119. this.fetchData()
  120. }
  121. }
  122. }
  123. }
  124. </script>