index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <?php
  2. /*
  3. * @Descripttion:
  4. * @copyright: Copyright (c) 2021 广东七件事集团
  5. * @Author: lun
  6. * @Date: 2021-12-28 23:01:04
  7. */
  8. ?>
  9. <style>
  10. .link_url {
  11. text-align: left;
  12. font-size: 14px;
  13. }
  14. .showqr .el-dialog__body {
  15. text-align: center;
  16. padding-bottom: 10px;
  17. }
  18. .el-dialog {
  19. min-width: 400px;
  20. }
  21. </style>
  22. <div id="app" v-cloak>
  23. <el-card shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  24. <div slot="header">
  25. <span>活动列表</span>
  26. <div style="float: right;margin-top: -5px">
  27. <el-button type="primary"
  28. @click="$navigate({r: 'random-red-packet/index/edit'})"
  29. size="small">添加活动
  30. </el-button>
  31. </div>
  32. </div>
  33. <div class="search-box">
  34. <!-- 搜索 -->
  35. <el-form :inline="true" :model="searchForm" size="small" class="demo-form-inline">
  36. <el-form-item label="活动名称">
  37. <el-input placeholder="请输入活动名称" v-model="searchForm.activities_name"></el-input>
  38. </el-form-item>
  39. <el-form-item label="活动编号">
  40. <el-input placeholder="请输入活动编号" v-model="searchForm.activities_number"></el-input>
  41. </el-form-item>
  42. <el-form-item label="奖品类型">
  43. <el-select v-model="searchForm.type" placeholder="奖品类型">
  44. <el-option v-for="(name,index) in type_arr" :label="name" :value="index" :key="index"></el-option>
  45. </el-select>
  46. </el-form-item>
  47. <el-form-item>
  48. <el-button type="primary" @click="search">搜索</el-button>
  49. <el-button type="danger" size="small" style="padding: 9px 15px !important;" @click="resetSearch" v-if="search.goods_id != ''">清除条件</el-button>
  50. </el-form-item>
  51. </el-form>
  52. </div>
  53. <div class="table-body">
  54. <el-tabs>
  55. <el-table :data="list" stripe v-loading="loading" size="small" style="margin-bottom: 15px;">
  56. <el-table-column prop="activities_number" min-width="30" label="活动编号" align="center"></el-table-column>
  57. <el-table-column prop="activities_name" label="活动名称" min-width="60" align="center"></el-table-column>
  58. <el-table-column prop="type" label="奖品类型" align="center">
  59. <template slot-scope="scope">
  60. {{ type_arr[scope.row.reward_type] }}
  61. </template>
  62. </el-table-column>
  63. <el-table-column prop="get_number" label="领取人数" min-width="60" align="center"></el-table-column>
  64. <el-table-column label="活动时间" min-width="90" align="center">
  65. <template slot-scope="scope">
  66. {{ scope.row.start_at | dateTimeFormat('Y-m-d H:i') }} 至 {{ scope.row.end_at | dateTimeFormat('Y-m-d H:i') }}
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="状态" align="center">
  70. <template slot-scope="scope">
  71. <el-tag type="danger" v-if="scope.row.status == 0">已失效</el-tag>
  72. <el-tag type="success" v-else-if="scope.row.start_at < now_time && scope.row.end_at > now_time">进行中</el-tag>
  73. <el-tag v-else-if="scope.row.start_at > now_time">未开始</el-tag>
  74. <el-tag type="info" v-else>已过期</el-tag>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="操作" align="center">
  78. <template slot-scope="scope">
  79. <el-button type="text" @click="handle('edit',scope.row)">编辑</el-button>
  80. <el-button type="text" v-if="scope.row.status == 1" @click="handle('operate', {id:scope.row.id, status:0, name:'停用'})">失效</el-button>
  81. <el-button type="text" v-if="scope.row.status == 0" @click="handle('operate', {id:scope.row.id, status:1, name:'启用'})">启用</el-button>
  82. <!-- <el-button type="text" @click="handle('log',scope.row)">奖励记录</el-button>-->
  83. <!-- <el-button type="text" @click="handle('destroy',scope.row)">删除</el-button>-->
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. <div style="text-align: right;margin: 20px 0;">
  88. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
  89. </div>
  90. </el-tabs>
  91. </div>
  92. </el-card>
  93. </div>
  94. <script>
  95. const app = new Vue({
  96. el: '#app',
  97. data: {
  98. loading: false,
  99. delLoading: false,
  100. page: 1,
  101. pageCount: 0,
  102. list: [],
  103. type_arr: {
  104. 1: '激活积分',
  105. 2: '贡献值',
  106. 3: '红包',
  107. 4: '余额',
  108. },
  109. status_arr: {
  110. 0: '全部',
  111. 1: '进行中',
  112. 2: '已过期',
  113. 3: '已失效',
  114. 4: '未开始',
  115. },
  116. now_time: 0,
  117. searchForm:{
  118. activities_name:null,
  119. activities_number:null,
  120. type:null,
  121. },
  122. },
  123. mounted() {
  124. this.getList();
  125. },
  126. computed: {
  127. show_clear_search_btn: function() {
  128. return this.searchForm.title != null ||
  129. this.searchForm.reward_type != null ||
  130. this.searchForm.status != null;
  131. },
  132. },
  133. methods: {
  134. pagination(currentPage) {
  135. let self = this;
  136. self.page = currentPage;
  137. self.getList();
  138. },
  139. handle(type, data = null) {
  140. let id = data ? parseInt(data.id) : '';
  141. switch (type) {
  142. case 'edit':
  143. let params = {
  144. r: 'random-red-packet/index/edit'
  145. };
  146. if (id) params = Object.assign(params, {
  147. id: id
  148. });
  149. navigateTo(params);
  150. break;
  151. // case 'log':
  152. // param = {
  153. // r: 'rebate/index/reward-log'
  154. // };
  155. // if (id) param = Object.assign(param, {
  156. // rid: id
  157. // });
  158. // navigateTo(param);
  159. // break;
  160. case 'destroy':
  161. param = {id: data.id,status: -1};
  162. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {this.send('random-red-packet/index/handle',param)})
  163. break;
  164. case 'operate':
  165. param = {id: data.id, status:data.status};
  166. console.log(data,'param');
  167. this.$confirm('是否继续'+data.name+'该活动?', '警告', {type: 'warning'}).then(() => {this.send('random-red-packet/index/handle',param)})
  168. break;
  169. }
  170. },
  171. send(url, params, callback = null) {
  172. let self = this;
  173. request({
  174. params: {
  175. r: url,
  176. },
  177. method: 'post',
  178. data: params
  179. }).then(e => {
  180. if (e.data.code == 0) {
  181. self.$message.success(e.data.msg);
  182. self.getList();
  183. } else {
  184. self.$message.error(e.data.msg);
  185. }
  186. }).catch(e => {
  187. console.log(e);
  188. });
  189. if(callback) return e.data;
  190. },
  191. search() {// 清空查询条件
  192. this.page = 1;
  193. this.getList(this.searchForm);
  194. },
  195. resetSearch() {// 清空查询条件
  196. this.searchForm = {
  197. activities_name:null,
  198. activities_number:null,
  199. type:null,
  200. };
  201. this.page = 1;
  202. this.getList();
  203. },
  204. getList(search = {}) {
  205. let self = this;
  206. self.loading = true;
  207. let basic_params = {
  208. page: self.page,
  209. };
  210. params = Object.assign(basic_params, search);
  211. request({
  212. params: {
  213. r: 'random-red-packet/index/index'
  214. },
  215. method: 'post',
  216. data: params
  217. }).then(e => {
  218. this.loading = false;
  219. if (e.data.code == 0) {
  220. self.list = e.data.data.list.list;
  221. self.now_time = e.data.data.now_time;
  222. self.pageCount = e.data.data.list.page_count;
  223. } else {
  224. self.$message.error(e.data.msg);
  225. }
  226. }).catch(e => {
  227. self.loading = false;
  228. });
  229. },
  230. }
  231. });
  232. </script>
  233. <style>
  234. .el-tabs__header {
  235. font-size: 16px;
  236. }
  237. .table-body {
  238. padding: 20px;
  239. background-color: #fff;
  240. }
  241. .table-body .el-button {
  242. padding: 0 !important;
  243. border: 0;
  244. margin: 0 5px;
  245. }
  246. .input-item {
  247. width: 250px;
  248. margin: 0 0 20px;
  249. display: inline-block;
  250. }
  251. .input-item .el-input__inner {
  252. border-right: 0;
  253. }
  254. .input-item .el-input__inner:hover {
  255. border: 1px solid #dcdfe6;
  256. border-right: 0;
  257. outline: 0;
  258. }
  259. .input-item .el-input__inner:focus {
  260. border: 1px solid #dcdfe6;
  261. border-right: 0;
  262. outline: 0;
  263. }
  264. .input-item .el-input-group__append {
  265. background-color: #fff;
  266. border-left: 0;
  267. width: 10%;
  268. padding: 0;
  269. }
  270. .input-item .el-input-group__append .el-button {
  271. padding: 0;
  272. }
  273. .input-item .el-input-group__append .el-button {
  274. margin: 0;
  275. }
  276. .batch {
  277. margin: 0 0 20px;
  278. display: inline-block;
  279. }
  280. .batch .el-button {
  281. padding: 9px 15px !important;
  282. }
  283. .el-table th>.cell{
  284. color: #333;
  285. font-weight: bold;
  286. font-size: 14px;
  287. }
  288. .el-table__footer-wrapper, .el-table__header-wrapper{
  289. border-bottom: 1.4px solid #D6D6D6;
  290. }
  291. .search-box {
  292. padding: 10px 0 0 10px;
  293. background-color: #fff;
  294. margin-bottom: 10px;
  295. }
  296. </style>