index.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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: 'recommen/default/edit'})"
  29. size="small">添加活动
  30. </el-button>
  31. <el-button style="display: none;" type="primary"
  32. @click="test"
  33. size="small">测试推荐活动
  34. </el-button>
  35. </div>
  36. </div>
  37. <div class="search-box">
  38. <!-- 搜索 -->
  39. <el-form :inline="true" :model="searchForm" size="small" class="demo-form-inline">
  40. <el-form-item label="活动名称">
  41. <el-date-picker
  42. size="small"
  43. v-model="searchForm.create_time"
  44. type="datetimerange"
  45. value-format="yyyy-MM-dd HH:mm:ss"
  46. range-separator="至"
  47. start-placeholder="开始日期"
  48. end-placeholder="结束日期">
  49. </el-date-picker>
  50. </el-form-item>
  51. <el-form-item label="活动名称">
  52. <el-input placeholder="请输入活动名称" v-model="searchForm.name"></el-input>
  53. </el-form-item>
  54. <el-form-item label="类型">
  55. <el-select v-model="searchForm.reward_type" placeholder="类型">
  56. <el-option v-for="(name,index) in reward_type_arr" :label="name" :value="index" :key="index"></el-option>
  57. </el-select>
  58. </el-form-item>
  59. <el-form-item label="状态">
  60. <el-select v-model="searchForm.status" placeholder="请选择状态">
  61. <el-option v-for="(item,index) in status_arr" :label="item" :value="index" :key="index"></el-option>
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item>
  65. <el-button type="primary" @click="search">搜索</el-button>
  66. <el-button type="danger" @click="resetSearch" v-if="show_clear_search_btn">清除条件</el-button>
  67. </el-form-item>
  68. </el-form>
  69. </div>
  70. <div class="table-body">
  71. <el-tabs>
  72. <el-table :data="list" stripe v-loading="loading" size="small" style="margin-bottom: 15px;">
  73. <el-table-column prop="id" label="序号" align="center"></el-table-column>
  74. <el-table-column prop="name" label="活动名称" align="center"></el-table-column>
  75. <el-table-column label="活动时间" min-width="90" align="center">
  76. <template slot-scope="scope">
  77. {{ scope.row.start_time | dateTimeFormat('Y-m-d H:i') }} 至 {{ scope.row.end_time | dateTimeFormat('Y-m-d H:i') }}
  78. </template>
  79. </el-table-column>
  80. <el-table-column prop="reward_type" label="类型" align="center">
  81. <template slot-scope="scope">
  82. {{ reward_type_arr[scope.row.type] }}
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="状态" align="center">
  86. <template slot-scope="scope">
  87. <el-tag type="danger" v-if="scope.row.status == 0">停用中</el-tag>
  88. <el-tag type="success" v-else-if="scope.row.start_time < now_time && scope.row.end_time > now_time">进行中</el-tag>
  89. <el-tag v-else-if="scope.row.start_time > now_time">未开始</el-tag>
  90. <el-tag type="info" v-else>已过期</el-tag>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="参与人数" align="center">
  94. <template slot-scope="scope">
  95. {{ scope.row.num ? scope.row.num : 0 }}
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="拉新人数" align="center">
  99. <template slot-scope="scope">
  100. {{ scope.row.new_num ? scope.row.new_num : 0 }}
  101. </template>
  102. </el-table-column>
  103. <el-table-column prop="created_at" label="创建时间" min-width="90" align="center">
  104. <template slot-scope="scope">
  105. {{ scope.row.created_at | dateTimeFormat('Y-m-d H:i') }}
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="操作" align="center">
  109. <template slot-scope="scope">
  110. <el-button type="text" v-if="scope.row.status == 1" @click="handle('operate', {id:scope.row.id, status:0, name:'停用'})">停用</el-button>
  111. <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>
  112. <el-button type="text" @click="handle('edit',scope.row)">编辑</el-button>
  113. <el-button type="text" @click="handle('log',scope.row)">奖励记录</el-button>
  114. <el-button type="text" @click="handle('destroy',scope.row)">删除</el-button>
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. <div style="text-align: right;margin: 20px 0;">
  119. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
  120. </div>
  121. </el-tabs>
  122. </div>
  123. </el-card>
  124. </div>
  125. <script>
  126. const app = new Vue({
  127. el: '#app',
  128. data: {
  129. loading: false,
  130. delLoading: false,
  131. page: 1,
  132. pageCount: 0,
  133. list: [],
  134. reward_type_arr: {
  135. 1: '条件奖励',
  136. 2: '阶梯奖励',
  137. },
  138. status_arr: {
  139. 0: '全部',
  140. 1: '进行中',
  141. 2: '已过期',
  142. 3: '停用',
  143. 4: '未开始',
  144. },
  145. now_time: 0,
  146. searchForm:{
  147. name:null,
  148. reward_type:null,
  149. status:null,
  150. },
  151. },
  152. mounted() {
  153. this.getList();
  154. },
  155. computed: {
  156. show_clear_search_btn: function() {
  157. return this.searchForm.name != null ||
  158. this.searchForm.reward_type != null ||
  159. this.searchForm.create_time != null ||
  160. this.searchForm.status != null;
  161. },
  162. },
  163. methods: {
  164. pagination(currentPage) {
  165. let self = this;
  166. self.page = currentPage;
  167. self.getList();
  168. },
  169. handle(type, data = null) {
  170. let id = data ? parseInt(data.id) : '';
  171. switch (type) {
  172. case 'edit':
  173. let params = {
  174. r: 'recommen/default/edit'
  175. };
  176. if (id) params = Object.assign(params, {
  177. id: id
  178. });
  179. navigateTo(params);
  180. break;
  181. case 'log':
  182. param = {
  183. r: 'recommen/reward/index'
  184. };
  185. if (id) param = Object.assign(param, {
  186. active_id: id
  187. });
  188. navigateTo(param);
  189. break;
  190. case 'destroy':
  191. param = {id: data.id,status: -1};
  192. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {this.send('recommen/default/handle',param)})
  193. break;
  194. case 'operate':
  195. param = {id: data.id, item_id:data.item_id, status:data.status};
  196. console.log(data,'param');
  197. this.$confirm('是否继续'+data.name+'该活动?', '警告', {type: 'warning'}).then(() => {this.send('recommen/default/handle',param)})
  198. break;
  199. }
  200. },
  201. send(url, params, callback = null) {
  202. let self = this;
  203. request({
  204. params: {
  205. r: url,
  206. },
  207. method: 'post',
  208. data: params
  209. }).then(e => {
  210. if (e.data.code == 0) {
  211. self.$message.success(e.data.msg);
  212. self.getList();
  213. } else {
  214. self.$message.error(e.data.msg);
  215. }
  216. }).catch(e => {
  217. console.log(e);
  218. });
  219. if(callback) return e.data;
  220. },
  221. search() {// 清空查询条件
  222. this.page = 1;
  223. this.getList(this.searchForm);
  224. },
  225. resetSearch() {// 清空查询条件
  226. this.searchForm = {
  227. name: null,
  228. reward_type: null,
  229. status: null,
  230. create_time:null,
  231. };
  232. this.page = 1;
  233. this.getList();
  234. },
  235. getList(search = {}) {
  236. let self = this;
  237. self.loading = true;
  238. let basic_params = {
  239. page: self.page,
  240. };
  241. params = Object.assign(basic_params, search);
  242. request({
  243. params: {
  244. r: 'recommen/default/index'
  245. },
  246. method: 'post',
  247. data: params
  248. }).then(e => {
  249. this.loading = false;
  250. if (e.data.code == 0) {
  251. self.list = e.data.data.list;
  252. self.now_time = e.data.data.now_time;
  253. self.pageCount = e.data.data.page_count;
  254. } else {
  255. self.$message.error(e.data.msg);
  256. }
  257. }).catch(e => {
  258. self.loading = false;
  259. });
  260. },
  261. test(){
  262. let self = this;
  263. self.loading = true;
  264. let basic_params = {
  265. page: self.page,
  266. };
  267. params = Object.assign(basic_params, this.searchForm);
  268. request({
  269. params: {
  270. r: 'recommen/default/test'
  271. },
  272. method: 'post',
  273. data: params
  274. }).then(e => {
  275. }).catch(e => {
  276. self.loading = false;
  277. });
  278. },
  279. }
  280. });
  281. </script>
  282. <style>
  283. .el-tabs__header {
  284. font-size: 16px;
  285. }
  286. .table-body {
  287. padding: 20px;
  288. background-color: #fff;
  289. }
  290. .table-body .el-button {
  291. padding: 0 !important;
  292. border: 0;
  293. margin: 0 5px;
  294. }
  295. .input-item {
  296. width: 250px;
  297. margin: 0 0 20px;
  298. display: inline-block;
  299. }
  300. .input-item .el-input__inner {
  301. border-right: 0;
  302. }
  303. .input-item .el-input__inner:hover {
  304. border: 1px solid #dcdfe6;
  305. border-right: 0;
  306. outline: 0;
  307. }
  308. .input-item .el-input__inner:focus {
  309. border: 1px solid #dcdfe6;
  310. border-right: 0;
  311. outline: 0;
  312. }
  313. .input-item .el-input-group__append {
  314. background-color: #fff;
  315. border-left: 0;
  316. width: 10%;
  317. padding: 0;
  318. }
  319. .input-item .el-input-group__append .el-button {
  320. padding: 0;
  321. }
  322. .input-item .el-input-group__append .el-button {
  323. margin: 0;
  324. }
  325. .batch {
  326. margin: 0 0 20px;
  327. display: inline-block;
  328. }
  329. .batch .el-button {
  330. padding: 9px 15px !important;
  331. }
  332. .el-table th>.cell{
  333. color: #333;
  334. font-weight: bold;
  335. font-size: 14px;
  336. }
  337. .el-table__footer-wrapper, .el-table__header-wrapper{
  338. border-bottom: 1.4px solid #D6D6D6;
  339. }
  340. .search-box {
  341. padding: 10px 0 0 10px;
  342. background-color: #fff;
  343. margin-bottom: 10px;
  344. }
  345. </style>