index_cp.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div class="app-container">
  3. <div class="mymain-container">
  4. <div class="btn-group clearfix" style="margin-bottom: 20px">
  5. <div class="fl">
  6. <el-button size="small" icon="el-icon-refresh" @click="getListByScreen">刷新</el-button>
  7. <el-button size="small" type="primary" icon="el-icon-plus" @click="addOrEdit('add')">添加团购活动</el-button>
  8. </div>
  9. </div>
  10. <div class="tabs-container clearfix">
  11. <div class="fl">
  12. <el-tabs v-model="tabCurrent" type="card" @tab-click="getListByScreen">
  13. <el-tab-pane :name="key" v-for="(value, key, index) in tabList" :key="index">
  14. <div slot="label">{{value.name}}(<b style="color: red;">{{value.num}}</b>)</div>
  15. </el-tab-pane>
  16. </el-tabs>
  17. </div>
  18. <!-- <div class="fr">
  19. <el-date-picker
  20. v-model="screenForm.activityDate"
  21. @change="getListByScreen"
  22. type="daterange"
  23. size="small"
  24. style="margin-right: 20px; width: 260px !important;"
  25. value-format="yyyy-MM-dd"
  26. range-separator="至"
  27. start-placeholder="活动开始时间"
  28. end-placeholder="活动结束时间">
  29. </el-date-picker>
  30. <el-input placeholder="请输入活动名称进行搜索" v-model="screenForm.keyword" size="small" style="width: 240px; margin-top: 10px;" clearable>
  31. <el-button slot="append" icon="el-icon-search" size="small" @click="getListByScreen"></el-button>
  32. </el-input>
  33. </div> -->
  34. </div>
  35. <div class="table">
  36. <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit stripe>
  37. <el-table-column align="center" label="活动名称" prop="name" min-width="200"></el-table-column>
  38. <el-table-column align="center" label="参与产品数量" prop="goodsNum" min-width="120"></el-table-column>
  39. <el-table-column align="center" label="活动时间" min-width="200">
  40. <template slot-scope="scope">
  41. {{ scope.row.startTime | dateToDayFilter }} 至 {{ scope.row.endTime | dateToDayFilter }}
  42. </template>
  43. </el-table-column>
  44. <el-table-column align="center" label="状态">
  45. <template slot-scope="scope">
  46. {{ scope.row.status | statusFilter }}
  47. </template>
  48. </el-table-column>
  49. <el-table-column align="center" label="订单数量" prop="orderNum" min-width="120"></el-table-column>
  50. <el-table-column align="center" label="订单台数" prop="orderDetailNum" min-width="120"></el-table-column>
  51. <el-table-column align="center" label="订单总金额" prop="orderTotalAmount" min-width="120"></el-table-column>
  52. <el-table-column align="center" label="团长分佣总额" prop="shareTotalAmount" min-width="120"></el-table-column>
  53. <el-table-column align="center" label="商户" prop="companyName" min-width="120"></el-table-column>
  54. <el-table-column align="center" label="备注" prop="remark" min-width="200"></el-table-column>
  55. <el-table-column align="center" label="操作" width="240" fixed="right">
  56. <template slot-scope="scope">
  57. <el-button type="text" @click="addOrEdit('edit', scope.row.promotionGroupId)">编辑</el-button>
  58. <template>
  59. <el-popconfirm v-if="scope.row.status" style="margin: 0 10px;" title="确定关闭吗?" @confirm="changeActivityStatus(scope.row.promotionGroupId, false)" >
  60. <el-button slot="reference" type="text">关闭</el-button>
  61. </el-popconfirm>
  62. <el-popconfirm v-else style="margin: 0 10px;" title="确定开启吗?" @confirm="changeActivityStatus(scope.row.promotionGroupId, true)" >
  63. <el-button slot="reference" type="text">开启</el-button>
  64. </el-popconfirm>
  65. </template>
  66. <el-button type="text" @click="toDetail(scope.row.promotionGroupId)">拼团详情</el-button>
  67. <el-button type="text" @click="handleExport(scope.row.promotionGroupId)">导出订单</el-button>
  68. </template>
  69. </el-table-column>
  70. </el-table>
  71. </div>
  72. <div class="pagination clearfix">
  73. <div class="fr">
  74. <el-pagination
  75. @size-change="handleSizeChange"
  76. @current-change="handleCurrentChange"
  77. :current-page="currentPage"
  78. :page-sizes="[10, 20, 30, 50]"
  79. :page-size="10"
  80. layout="total, sizes, prev, pager, next, jumper"
  81. :total="listTotal">
  82. </el-pagination>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. </template>
  88. <script>
  89. import { getActivityCount, getActivityList, changeStatus } from '@/api/groupbuy'
  90. import { downloadFiles } from '@/utils/util'
  91. export default {
  92. filters: {
  93. statusFilter(val) {
  94. const MAP = {
  95. true: '进行中',
  96. false: '已结束',
  97. }
  98. return MAP[val];
  99. }
  100. },
  101. data() {
  102. return {
  103. dataList: null, // 列表数据
  104. listLoading: true, // 列表加载loading
  105. currentPage: 1, // 当前页码
  106. pageSize: 10, // 每页数量
  107. listTotal: 0, // 列表总数
  108. tabCurrent: 'all',
  109. tabList: {
  110. all: {name: '全部', num: 0, state: ''},
  111. jxz: {name: '进行中', num: 0, state: true},
  112. yjs: {name: '已结束', num: 0, state: false},
  113. },
  114. screenForm: {
  115. keyword: '',
  116. activityDate: '',
  117. },
  118. }
  119. },
  120. created() {
  121. this.getCount();
  122. this.getList();
  123. },
  124. methods: {
  125. // 获取统计
  126. getCount() {
  127. getActivityCount().then(res => {
  128. this.tabList.all.num = res.data.all;
  129. this.tabList.jxz.num = res.data.jxz;
  130. this.tabList.yjs.num = res.data.yjs;
  131. })
  132. },
  133. // 获取活动列表
  134. getList() {
  135. getActivityList({
  136. pageNum: this.currentPage,
  137. pageSize: this.pageSize,
  138. status: this.tabList[this.tabCurrent].state,
  139. // keyword: this.screenForm.keyword,
  140. // startTime: this.screenForm.activityDate ? this.screenForm.activityDate[0] + ' 00:00:00' : '',
  141. // endTime: this.screenForm.activityDate ? this.screenForm.activityDate[1] + ' 23:59:59' : '',
  142. }).then(res => {
  143. this.dataList = res.data.records;
  144. this.listTotal = res.data.total;
  145. this.listLoading = false;
  146. })
  147. },
  148. // 筛选后重新获取列表
  149. getListByScreen() {
  150. this.currentPage = 1;
  151. this.getCount();
  152. this.getList();
  153. },
  154. // 更改活动列表每页数量
  155. handleSizeChange(val) {
  156. this.pageSize = val;
  157. this.currentPage = 1;
  158. this.getList();
  159. },
  160. // 更改活动列表当前页
  161. handleCurrentChange(val) {
  162. this.currentPage = val;
  163. this.getList();
  164. },
  165. // 添加活动
  166. addOrEdit(type, id) {
  167. if(type == 'add') {
  168. this.$router.push({
  169. name:"groupbuy_add",
  170. query: {}
  171. })
  172. }else {
  173. this.$router.push({
  174. name:"groupbuy_add",
  175. query: {
  176. id
  177. }
  178. })
  179. }
  180. },
  181. // 操作 - 更改活动状态(type: 禁用0,启用1)
  182. changeActivityStatus(id, type) {
  183. changeStatus({promotionGroupId: id, status: type}).then(res => {
  184. this.getCount();
  185. this.getList();
  186. this.$successMsg();
  187. })
  188. },
  189. // 去详情
  190. toDetail(id) {
  191. this.$router.push({
  192. name:"groupbuy_detail",
  193. query: {
  194. id
  195. }
  196. })
  197. },
  198. // 导出
  199. handleExport(id) {
  200. let screenData = {
  201. promotionGroupId: id
  202. };
  203. downloadFiles('order/export', screenData);
  204. },
  205. },
  206. }
  207. </script>
  208. <style scoped>
  209. .app-container >>> .el-tabs__header {
  210. margin-bottom: 0;
  211. }
  212. .app-container >>> .el-tabs__nav-wrap::after {
  213. background: none;
  214. }
  215. .app-container >>> #tab-activity, .app-container >>> #tab-goods {
  216. font-size: 16px;
  217. }
  218. .table >>> .el-tag {
  219. margin-right: 6px;
  220. }
  221. .table >>> .el-tag:last-child {
  222. margin-right: 0;
  223. }
  224. </style>