index.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <com-list-page :crumbs="crumbs" id="application">
  2. <com-list-table
  3. ref="table"
  4. :api-params="apiParams"
  5. :search-list="searchList"
  6. @get-api-data="setApiData"
  7. >
  8. <template slot="header-left">
  9. <el-button
  10. type="primary"
  11. size="mini"
  12. @click="$navigate({r: 'rebate/index/edit'})"
  13. icon="el-icon-plus"
  14. >添加活动</el-button>
  15. </template>
  16. <el-table-column prop="id" min-width="30" label="序号" align="center"></el-table-column>
  17. <el-table-column prop="title" label="活动名称" min-width="60" align="center"></el-table-column>
  18. <el-table-column label="活动时间" min-width="150" align="center">
  19. <template slot-scope="scope">
  20. {{ scope.row.start_date}} 至 {{ scope.row.end_date }}
  21. </template>
  22. </el-table-column>
  23. <el-table-column prop="reward_type" label="类型" align="center">
  24. <template slot-scope="scope">
  25. {{ reward_type_arr[scope.row.reward_type] }}
  26. </template>
  27. </el-table-column>
  28. <el-table-column label="状态" align="center">
  29. <template slot-scope="scope">
  30. <el-tag type="danger" v-if="scope.row.status == 0">停用中</el-tag>
  31. <el-tag type="success" v-else-if="scope.row.start_at < now_time && scope.row.end_at > now_time">进行中</el-tag>
  32. <el-tag v-else-if="scope.row.start_at > now_time">未开始</el-tag>
  33. <el-tag type="info" v-else>已过期</el-tag>
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="参与人数" min-width="50" align="center">
  37. <template slot-scope="scope">
  38. {{ scope.row.statistics ? scope.row.statistics.join_num : 0 }}
  39. </template>
  40. </el-table-column>
  41. <el-table-column label="成交金额" min-width="50" align="center">
  42. <template slot-scope="scope">
  43. {{ scope.row.statistics ? scope.row.statistics.pay_money : 0 }}
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="订单数" min-width="50" align="center">
  47. <template slot-scope="scope">
  48. {{ scope.row.statistics ? scope.row.statistics.pay_num : 0 }}
  49. </template>
  50. </el-table-column>
  51. <el-table-column prop="created_at" label="创建时间" min-width="70" align="center">
  52. <template slot-scope="scope">
  53. {{ scope.row.created_at | dateTimeFormat('Y-m-d H:i') }}
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="操作" align="center">
  57. <template slot-scope="scope">
  58. <el-button type="text" v-if="scope.row.status == 1" @click="handle('operate', {id:scope.row.id, status:0, name:'停用'})">停用</el-button>
  59. <el-button type="text" v-if="scope.row.status == 0" @click="handle('operate', {id:scope.row.id, item_id:scope.row.item_id, status:1, name:'启用'})">启用</el-button>
  60. <el-button type="text" @click="handle('edit',scope.row)">编辑</el-button>
  61. <el-button type="text" @click="handle('log',scope.row)">奖励记录</el-button>
  62. <el-button type="text" @click="handle('activity_log',scope.row)">活动记录</el-button>
  63. <el-button type="text" @click="handle('destroy',scope.row)">删除</el-button>
  64. </template>
  65. </el-table-column>
  66. </com-list-table>
  67. </com-list-page>
  68. <script>
  69. const application = new Vue({
  70. el: '#application',
  71. data: {
  72. apiParams: {
  73. r: 'rebate/index/index',
  74. },
  75. crumbs: [
  76. {
  77. title: '首页',
  78. router: 'mall/overview/index',
  79. },
  80. {
  81. title: '推三返一',
  82. },
  83. ],
  84. searchList: [
  85. {
  86. key: 'title',
  87. title: '活动名称',
  88. type: 'text',
  89. },
  90. {
  91. key: 'reward_type',
  92. title: '类型',
  93. type: 'select',
  94. options: [
  95. {
  96. label: '条件奖励',
  97. value: 1
  98. },
  99. {
  100. label: '阶梯奖励',
  101. value: 2
  102. },
  103. ],
  104. },
  105. {
  106. key: 'status',
  107. title: '状态',
  108. type: 'select',
  109. options: [
  110. {
  111. label: '全部',
  112. value: 0
  113. },
  114. {
  115. label: '进行中',
  116. value: 1
  117. },
  118. {
  119. label: '已过期',
  120. value: 2
  121. },
  122. {
  123. label: '停用',
  124. value: 3
  125. },
  126. {
  127. label: '未开始',
  128. value: 4
  129. },
  130. ],
  131. },
  132. ],
  133. reward_type_arr: {
  134. 1: '条件奖励',
  135. 2: '阶梯奖励',
  136. },
  137. status_arr: {
  138. 0: '全部',
  139. 1: '进行中',
  140. 2: '已过期',
  141. 3: '停用',
  142. 4: '未开始',
  143. },
  144. now_time: 0,
  145. },
  146. methods: {
  147. setApiData(e) {
  148. this.now_time = e.now_time;
  149. },
  150. handle(type, data = null) {
  151. let id = data ? parseInt(data.id) : '';
  152. switch (type) {
  153. case 'edit':
  154. let params = {
  155. r: 'rebate/index/edit'
  156. };
  157. if (id) params = Object.assign(params, {
  158. id: id
  159. });
  160. navigateTo(params);
  161. break;
  162. case 'log':
  163. param = {
  164. r: 'rebate/index/reward-log'
  165. };
  166. if (id) param = Object.assign(param, {
  167. rid: id
  168. });
  169. navigateTo(param);
  170. break;
  171. case 'activity_log':
  172. param = {
  173. r: 'rebate/index/activity-log'
  174. };
  175. if (id) param = Object.assign(param, {
  176. rid: id
  177. });
  178. navigateTo(param);
  179. break;
  180. case 'destroy':
  181. param = {id: data.id,status: -1};
  182. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {this.send('rebate/index/handle',param)})
  183. break;
  184. case 'operate':
  185. param = {id: data.id, item_id:data.item_id, status:data.status};
  186. console.log(data,'param');
  187. this.$confirm('是否继续'+data.name+'该活动?', '警告', {type: 'warning'}).then(() => {this.send('rebate/index/handle',param)})
  188. break;
  189. }
  190. },
  191. send(url, params, callback = null) {
  192. let self = this;
  193. request({
  194. params: {
  195. r: url,
  196. },
  197. method: 'post',
  198. data: params
  199. }).then(e => {
  200. if (e.data.code == 0) {
  201. self.$message.success(e.data.msg);
  202. self.getList();
  203. } else {
  204. self.$message.error(e.data.msg);
  205. }
  206. }).catch(e => {
  207. console.log(e);
  208. });
  209. if(callback) return e.data;
  210. },
  211. }
  212. });
  213. </script>