index.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <div id="app" class="contents" v-cloak>
  2. <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;" style="min-width: 1000px;">
  3. <div slot="header">
  4. <div>
  5. <span>拼团活动</span>
  6. <div style="float:right;margin:-6px 0px">
  7. <el-button type="primary" size="small" @click="storage">创建活动</el-button>
  8. <!-- <com-export-dialog :field_list='exportList' :params="searchData">
  9. </com-export-dialog> -->
  10. </div>
  11. </div>
  12. </div>
  13. <div class="table-body">
  14. <el-form size="small" :inline="true" flex="dir:left cross:center">
  15. <div class="item-box" flex="dir:left cross:center">
  16. <div style="margin-right: 5px; margin-left: 25px;">活动名称</div>
  17. <el-input size="small" style="width: 200px" v-model="searchData.title" placeholder="请输入活动名称"></el-input>
  18. </div>
  19. <div class="item-box" flex="dir:left cross:center">
  20. <div style="margin-right: 5px; margin-left: 25px;">活动状态</div>
  21. <el-select v-model="searchData.activity_status" @change='search' class="select" size="small">
  22. <el-option :key="index" :label="item" :value="index" v-for="(item, index) in statusMap"></el-option>
  23. <!-- <el-option :key="1" label="未开始" :value="1"></el-option>
  24. <el-option :key="2" label="进行中" :value="2"></el-option>
  25. <el-option :key="3" label="停用" :value="3"></el-option>
  26. <el-option :key="4" label="已结束" :value="4"></el-option> -->
  27. </el-select>
  28. </div>
  29. <div class="item-box" flex="dir:left cross:center">
  30. <div style="margin-right: 5px; margin-left: 25px;">发布时间</div>
  31. <el-date-picker @change="selectedDateTime" size="small" v-model="selectTime" type="daterange" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
  32. </el-date-picker>
  33. </div>
  34. <div class="item-box" flex="dir:left cross:center">
  35. <el-button size="small" type="primary" style="padding: 9px 15px !important;margin-right: 5px; margin-left: 25px;" @click="search">搜索
  36. </el-button>
  37. </div>
  38. <div class="item-box" flex="dir:left cross:center" v-if="searchData.activity_status || searchData.title || searchData.start_time || searchData.end_time">
  39. <el-button size="small" type="warning" style="padding: 9px 15px !important;" @click="clearSearch">清除搜索条件
  40. </el-button>
  41. </div>
  42. </el-form>
  43. <el-table v-loading=" listLoading" :data="list" stripe style="width: 100%">
  44. <el-table-column prop="id" label="ID" width="80" align="center">
  45. </el-table-column>
  46. <el-table-column prop="title" label="活动名称" width="150" align="center"></el-table-column>
  47. <el-table-column prop="relate_good_number" label="关联商品数量" width="150" title="" align="center"></el-table-column>
  48. <el-table-column prop="" label="规则" width="150" title="" align="center">
  49. <template slot-scope="scope">
  50. <com-ellipsis :line="1">{{scope.row.group_num}}中{{scope.row.random_win_num}}</com-ellipsis>
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="拼团时间" align="center">
  54. <template slot-scope="scope">
  55. <com-ellipsis :line="1">{{scope.row.start_time}}至{{scope.row.end_time}}</com-ellipsis>
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="创建时间" align="center">
  59. <template slot-scope="scope">
  60. {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="状态" align="center">
  64. <template slot-scope="scope">
  65. {{statusMap[scope.row.activity_status]}}
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="操作" width="250" align="center">
  69. <template slot-scope="scope">
  70. <el-button circle size="small" type="text" @click="activityStatisticsData(scope.row.id)">数据</el-button>
  71. <el-button circle size="small" type="text" @click="getQueue(scope.row.id)">队列</el-button>
  72. <el-button circle size="small" type="text" @click="storage(scope.row.id, scope.$index)">编辑</el-button>
  73. <el-button v-if="scope.row.activity_status==2" circle size="small" type="text" @click="switchActivity(scope.row.id, 3, scope.$index)">停用</el-button>
  74. <el-button v-if="scope.row.activity_status==3" circle size="small" type="text" @click="switchActivity(scope.row.id, 2, scope.$index)">启用</el-button>
  75. <el-button v-if="scope.row.activity_status!=2" circle size="small" type="text" @click="activityDelete(scope.row.id)">删除</el-button>
  76. </template>
  77. </el-table-column>
  78. </el-table>
  79. <div style="text-align: right;margin: 20px 0;">
  80. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount">
  81. </el-pagination>
  82. </div>
  83. </div>
  84. </el-card>
  85. </div>
  86. <script>
  87. const app = new Vue({
  88. el: '#app',
  89. data: {
  90. list: [],
  91. listLoading: false,
  92. page: 1,
  93. level: 1,
  94. pageCount: 0,
  95. searchData: {
  96. title: '',
  97. start_time: '',
  98. end_time: '',
  99. },
  100. selectTime: [],
  101. // 导出
  102. exportList: [],
  103. statusMap: [],
  104. },
  105. mounted: function() {
  106. this.getList();
  107. },
  108. methods: {
  109. //搜索
  110. search() {
  111. this.page = 1;
  112. this.getList();
  113. },
  114. clearSearch() {
  115. this.searchData.title = '';
  116. this.searchData.activity_id = null;
  117. this.searchData.start_time = '';
  118. this.searchData.end_time = '';
  119. this.selectTime = [];
  120. this.getList();
  121. },
  122. // 时间搜索触发
  123. selectedDateTime(params) {
  124. if (params != null) {
  125. this.searchData.start_time = params[0];
  126. this.searchData.end_time = params[1];
  127. } else {
  128. this.searchData.start_time = '';
  129. this.searchData.end_time = '';
  130. }
  131. },
  132. //跳转拼团活动统计数据
  133. activityStatisticsData(id) {
  134. navigateTo({
  135. r: 'lucky-group/group-activity/activity-data',
  136. activity_id: id,
  137. });
  138. },
  139. // getQueue(id) {
  140. // request({
  141. // params: {
  142. // r: 'lucky-group/group-activity/get-queue',
  143. // activity_id: id,
  144. // },
  145. // method: 'get',
  146. // }).then(e => {
  147. // this.listLoading = false;
  148. // if (e.data.code == 0) {
  149. // // this.statusMap = e.data.data.status_map;
  150. // // this.list = e.data.data.list;
  151. // // this.pageCount = e.data.data.page_count;
  152. // // this.exportList = e.data.data.exportList;
  153. // } else {
  154. // this.$message.error(e.data.msg)
  155. // }
  156. //
  157. // }).catch(e => {
  158. // console.log(e);
  159. // });
  160. // },
  161. getQueue(id) {
  162. navigateTo({
  163. r: 'lucky-group/group-activity/get-data',
  164. activity_id: id,
  165. });
  166. request({
  167. params: {
  168. r: 'lucky-group/group-activity/get-queue',
  169. activity_id: id,
  170. },
  171. method: 'get',
  172. }).then(e => {
  173. this.listLoading = false;
  174. if (e.data.code == 0) {
  175. // this.statusMap = e.data.data.status_map;
  176. // this.list = e.data.data.list;
  177. // this.pageCount = e.data.data.page_count;
  178. // this.exportList = e.data.data.exportList;
  179. } else {
  180. this.$message.error(e.data.msg)
  181. }
  182. }).catch(e => {
  183. console.log(e);
  184. });
  185. },
  186. pagination(currentPage) {
  187. let self = this;
  188. self.page = currentPage;
  189. self.getList();
  190. },
  191. getList() {
  192. this.listLoading = true;
  193. request({
  194. params: {
  195. r: 'lucky-group/group-activity/index',
  196. pagesize: 10,
  197. page: this.page,
  198. ...this.searchData,
  199. },
  200. method: 'get',
  201. }).then(e => {
  202. // console.log('等级列表=='+JSON.stringify(e))
  203. this.listLoading = false;
  204. if (e.data.code == 0) {
  205. this.statusMap = e.data.data.status_map;
  206. this.list = e.data.data.list;
  207. this.pageCount = e.data.data.page_count;
  208. this.exportList = e.data.data.exportList;
  209. } else {
  210. this.$message.error(e.data.msg)
  211. }
  212. }).catch(e => {
  213. console.log(e);
  214. });
  215. },
  216. //编辑 or 添加
  217. storage(id = null, index = null) {
  218. let request_url = {
  219. r: 'lucky-group/group-activity/storage'
  220. };
  221. if (id) request_url.id = id;
  222. navigateTo(request_url);
  223. },
  224. //删除
  225. activityDelete(id) {
  226. let self = this;
  227. self.$confirm('删除该条拼团活动, 是否继续?', '提示', {
  228. confirmButtonText: '确定',
  229. cancelButtonText: '取消',
  230. type: 'warning'
  231. }).then(() => {
  232. self.listLoading = true;
  233. request({
  234. params: {
  235. r: 'lucky-group/group-activity/delete',
  236. },
  237. method: 'post',
  238. data: {id: id}
  239. }).then(e => {
  240. self.listLoading = false;
  241. if (e.data.code === 0) {
  242. self.$message.success(e.data.msg);
  243. this.getList();
  244. } else {
  245. self.$message.error(e.data.msg);
  246. }
  247. }).catch(e => {
  248. console.log(e);
  249. });
  250. }).catch(() => {
  251. self.$message.info('已取消删除')
  252. });
  253. },
  254. // 活动开关
  255. switchActivity(id, status, index) {
  256. self.listLoading = true;
  257. request({
  258. params: {
  259. r: 'lucky-group/group-activity/switch-acitity',
  260. },
  261. method: 'post',
  262. data: {id: id, status: status}
  263. }).then(e => {
  264. self.listLoading = false;
  265. if (e.data.code == 0) {
  266. this.$message.success('操作成功');
  267. this.list[index].activity_status = status;
  268. this.getList();
  269. } else {
  270. this.$message.error(e.data.msg);
  271. }
  272. }).catch(e => {
  273. console.log(e);
  274. this.$message.error('网络错误');
  275. });
  276. }
  277. }
  278. });
  279. </script>
  280. <style>
  281. .table-body {
  282. padding: 20px;
  283. background-color: #fff;
  284. }
  285. .input-item {
  286. display: inline-block;
  287. width: 250px;
  288. margin: 0 0 20px;
  289. }
  290. .input-item .el-input__inner {
  291. border-right: 0;
  292. }
  293. .input-item .el-input__inner:hover {
  294. border: 1px solid #dcdfe6;
  295. border-right: 0;
  296. outline: 0;
  297. }
  298. .input-item .el-input__inner:focus {
  299. border: 1px solid #dcdfe6;
  300. border-right: 0;
  301. outline: 0;
  302. }
  303. .input-item .el-input-group__append {
  304. background-color: #fff;
  305. border-left: 0;
  306. width: 10%;
  307. padding: 0;
  308. }
  309. .input-item .el-input-group__append .el-button {
  310. padding: 0;
  311. }
  312. .input-item .el-input-group__append .el-button {
  313. margin: 0;
  314. }
  315. /* .table-body .el-button {
  316. padding: 0 !important;
  317. border: 0;
  318. margin: 0 5px;
  319. }
  320. */
  321. .el-table th>.cell {
  322. color: #333;
  323. font-weight: bold;
  324. font-size: 14px;
  325. }
  326. .el-table__footer-wrapper,
  327. .el-table__header-wrapper {
  328. border-bottom: 1.4px solid #D6D6D6;
  329. }
  330. .el-button--mini.is-circle {
  331. padding: 3px;
  332. }
  333. .contents .el-button+.el-button {
  334. margin-left: 0px;
  335. }
  336. </style>