index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <template-page ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents"
  3. :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing"
  4. :operation="operation" :exportList="exportList" :operationColumnWidth="210">
  5. <div slot="moreSearch">
  6. <el-radio-group v-model="type" size="mini" @change="changeType">
  7. <el-radio-button label="">全部({{ statistics.all || 0 }})</el-radio-button>
  8. <el-radio-button :label="1">进行中({{ statistics.jxz || 0 }})</el-radio-button>
  9. <el-radio-button :label="0">已结束({{ statistics.yjs || 0 }})</el-radio-button>
  10. </el-radio-group>
  11. <br><br>
  12. </div>
  13. </template-page>
  14. </template>
  15. <script>
  16. import TemplatePage from '@/components/template/template-page-1.vue'
  17. import import_mixin from '@/components/template/import_mixin.js'
  18. import { promotionGroupListPageV2, promotionGroupPageExport, getActivityCount, changeStatus } from '@/api/groupbuy'
  19. import { downloadFiles } from '@/utils/util'
  20. export default {
  21. components: { TemplatePage },
  22. mixins: [import_mixin],
  23. data() {
  24. return {
  25. type: "",
  26. statistics: {},
  27. // 事件组合
  28. optionsEvensGroup: [
  29. [
  30. [
  31. {
  32. name: '添加团购活动',
  33. isRole: true,
  34. click: () => {
  35. this.$router.push({
  36. name: "groupbuy_add",
  37. query: {}
  38. })
  39. }
  40. }
  41. ],
  42. ],
  43. ],
  44. // 表格属性
  45. tableAttributes: {
  46. // 启用勾选列
  47. selectColumn: false
  48. },
  49. // 表格事件
  50. tableEvents: {
  51. 'selection-change': this.selectionChange
  52. },
  53. // 勾选选中行
  54. recordSelected: [],
  55. }
  56. },
  57. computed: {
  58. // 更多参数
  59. moreParameters() {
  60. return []
  61. },
  62. },
  63. methods: {
  64. // 切换状态
  65. changeType(val) {
  66. this.$refs.pageRef.refreshList()
  67. },
  68. // 列表请求函数
  69. getList(p) {
  70. try {
  71. var pam = JSON.parse(JSON.stringify(p))
  72. if (this.type) {
  73. pam.status = this.type
  74. pam.params.push({ "param": "a.status", "compare": "=", "value": this.type })
  75. }
  76. return promotionGroupListPageV2(pam)
  77. } catch (error) {
  78. console.log(error)
  79. } finally {
  80. getActivityCount().then(res => {
  81. this.statistics = res.data
  82. })
  83. }
  84. },
  85. // 列表导出函数
  86. exportList: promotionGroupPageExport,
  87. // 表格列解析渲染数据更改
  88. columnParsing(item, defaultData) {
  89. return defaultData
  90. },
  91. // 监听勾选变化
  92. selectionChange(data) {
  93. this.recordSelected = data
  94. },
  95. // 表格操作列
  96. operation(h, { row, index, column }) {
  97. return (
  98. <div class='operation-btns'>
  99. <el-popconfirm
  100. title={`是否确定${Number(row.status) ? "关闭" : "开启"}?`}
  101. onConfirm={() => {
  102. changeStatus({ promotionGroupId: row.promotionGroupId, status: Number(row.status) ? 0 : 1 }).then(res => {
  103. this.$message({ type: 'success', message: `${Number(row.status) ? "关闭" : "开启"}成功!` })
  104. this.$refs.pageRef.refreshList()
  105. })
  106. }}
  107. >
  108. <el-button type="text" slot="reference">{Number(row.status) ? "关闭" : "开启"}</el-button>
  109. </el-popconfirm>
  110. <el-button type="text" onClick={() => {
  111. this.$router.push({
  112. name: "groupbuy_add",
  113. query: {
  114. id: row.promotionGroupId
  115. }
  116. })
  117. }}>编辑</el-button>
  118. <el-button type="text" onClick={() => {
  119. this.$router.push({
  120. name: "groupbuy_detail",
  121. query: {
  122. id: row.promotionGroupId
  123. }
  124. })
  125. }}>拼团详情</el-button>
  126. <el-button type="text" onClick={() => {
  127. let screenData = {
  128. promotionGroupId: row.promotionGroupId
  129. };
  130. downloadFiles('order/export', screenData);
  131. }}>导出订单</el-button>
  132. </div>
  133. )
  134. },
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped></style>