list.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. @extends('layouts.base')
  2. @section('title', "活动列表")
  3. @section('content')
  4. <style>
  5. #re_content{
  6. margin-top:20px;
  7. }
  8. .el-form .el-form-item{
  9. margin-right: 60px;
  10. }
  11. .list_total_num{
  12. margin-top:20px;
  13. }
  14. .el-table__header-wrapper{
  15. margin-top:20px;
  16. }
  17. .el-tag{font-weight:700;font-size:15px;}
  18. .rightlist-head{padding:15px 0;line-height:50px;}
  19. .rightlist-head-con{float:left;padding-right:20px;font-size:16px;color:#888;}
  20. .el-button+.el-button {
  21. margin-left: 0px;
  22. }
  23. .qr_code{
  24. text-align:center;
  25. }
  26. </style>
  27. <!-- tab -->
  28. <div id='re_content' v-loading="all_loading">
  29. <div class="rightlist-head">
  30. <div class="rightlist-head-con">活动列表</div>
  31. <a href="{{ yzWebFullUrl('plugin.lucky-draw.admin.controllers.activity.add') }}">
  32. <el-button>添加活动</el-button>
  33. </a>
  34. </div>
  35. <template>
  36. <el-form :inline="true" :model="search_form" ref="search_form">
  37. <el-row>
  38. <el-col :span="24">
  39. <el-form-item label="活动ID">
  40. <el-input v-model="search_form.id" placeholder="请输入活动ID"></el-input>
  41. </el-form-item>
  42. <el-form-item label="活动名称">
  43. <el-input v-model="search_form.name" placeholder="请输入活动名称"></el-input>
  44. </el-form-item>
  45. <el-form-item label="时间范围">
  46. <el-date-picker v-model="search_form.times" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
  47. </el-form-item>
  48. <el-form-item style="float:right;text-align:right;">
  49. <a href="#">
  50. <el-button type="success" icon="el-icon-search" @click="search()">搜索</el-button>
  51. </a>
  52. <a href="#">
  53. <!-- <el-button type="default" @click="outExcel()">导出EXCEL</el-button> -->
  54. </a>
  55. </el-form-item>
  56. </el-col>
  57. </el-row>
  58. </el-form>
  59. <template>
  60. <!-- 表格start -->
  61. <el-table :data="list" style="width: 100%" v-loading="search_loading">
  62. <el-table-column prop="id" label="ID" width="70px" align="center"></el-table-column>
  63. <el-table-column prop="name" label="活动名称" min-width="110" align="center"></el-table-column>
  64. <el-table-column prop="countdown_time" label="活动时间" min-width="100" align="center">
  65. <template slot-scope="scope">
  66. <div>[[scope.row.start_time]]</div>
  67. <div>至</div>
  68. <div>[[scope.row.end_time]]</div>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="活动奖品" prop="prize_list" align="center">
  72. <template slot-scope="scope">
  73. <el-popover
  74. placement="right-start"
  75. trigger="hover"
  76. width="50"
  77. >
  78. <div slot="reference"><div v-for="(item,index,key) in scope.row.prize_list.slice(0,3)" style="margin-left:5px;">[[item.name]]</div></div>
  79. <div v-for="(item,index,key) in scope.row.prize_list" >[[item.name]]</div>
  80. </el-popover>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="抽奖人数" prop="draw_times" align="center"></el-table-column>
  84. <el-table-column label="中奖人数" prop="member_draw_times" align="center"></el-table-column>
  85. <el-table-column label="操作" align="center" width="330px">
  86. <template slot-scope="scope">
  87. <a :href="'{{ yzWebFullUrl('plugin.lucky-draw.admin.controllers.activity.record', array('id' => '')) }}'+[[scope.row.id]]">
  88. <el-button size="mini">数据</el-button>
  89. </a>
  90. <el-popover
  91. placement="top"
  92. trigger="hover"
  93. popper-class="qr_code"
  94. >
  95. <img :src="scope.row.qr_code" style="width:100px;height:100px;">
  96. <el-button slot="reference" size="mini">二维码</el-button>
  97. </el-popover>
  98. <el-button size="mini" @click="copy(scope.$index)">链接</el-button>
  99. <a :href="'{{ yzWebFullUrl('plugin.lucky-draw.admin.controllers.activity.edit', array('id' => '')) }}'+[[scope.row.id]]"><el-button size="mini">编辑</el-button></a>
  100. <el-button size="mini" @click="del(scope, list)">删除</el-button>
  101. <el-input style="opacity:0;position: absolute;:1px;" v-model="scope.row.activity_url" :ref="'link'+scope.$index">
  102. </template>
  103. </el-table-column>
  104. </el-table>
  105. <el-row>
  106. <el-col :span="24" align="right" migra style="padding:15px 5% 15px 0" v-loading="loading">
  107. <el-pagination background layout="prev, pager, next" @current-change="currentChange" :total="page_total"
  108. :page-size="page_size" :current-page="current_page"></el-pagination>
  109. </el-col>
  110. </el-row>
  111. <!-- 表格end -->
  112. </template>
  113. </template>
  114. </div>
  115. <script>
  116. var vm = new Vue({
  117. el: "#re_content",
  118. delimiters: ['[[', ']]'],
  119. data() {
  120. let data = {!! $page_list?:'{}' !!}
  121. let category_list = {!! $category_list?:'{}' !!}
  122. let activate_list = {!! $type_list?:'{}' !!};
  123. let lang = {!! $lang?:'{}' !!};
  124. let time_list = [
  125. {id:0,name:"不搜索时间"},
  126. {id:1,name:"搜索时间"},
  127. ];
  128. return {
  129. list:[],
  130. page_total:1,
  131. data:'',
  132. loading:false,
  133. page:1,
  134. page_size:1,
  135. activeName: 'activate',
  136. lang:lang,
  137. all_loading:false,
  138. loading:false,
  139. search_loading:false,
  140. search_form:{},
  141. real_search_form:{},
  142. activate_list:activate_list,
  143. category_list: category_list,
  144. // status_list:status_list,
  145. time_list:time_list,
  146. page_total:data.total,
  147. // list:data.data,
  148. data:data,
  149. page_size:data.per_page,
  150. current_page:data.current_page,
  151. }
  152. },
  153. created () {
  154. this.currentChange(1);
  155. },
  156. methods: {
  157. timestampToTime(timestamp) {
  158. var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  159. var Y = date.getFullYear() + '-';
  160. var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
  161. var D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' ';
  162. var h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':';
  163. var m = (date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes()) + ':';
  164. var s = (date.getSeconds() < 10 ? '0'+date.getSeconds() : date.getSeconds());
  165. return Y+M+D+h+m+s;
  166. },
  167. del(scope, rows){
  168. rows.splice(scope.$index, 1);
  169. let json={
  170. id:scope.row.id
  171. }
  172. this.$http.post('{!! yzWebFullUrl('plugin.lucky-draw.admin.controllers.activity.del') !!}',json).then(function (response){
  173. this.$message({message:"删除成功!",type:"success"});
  174. this.loading = false;
  175. },function (response) {
  176. console.log(response);
  177. this.loading = false;
  178. }
  179. );
  180. },
  181. getData(){
  182. this.$http.get('{!! yzWebFullUrl('plugin.lucky-draw.admin.controllers.activity.getList') !!}').then(function (response){
  183. this.list=response.data.data.page_list.data;
  184. this.loading = false;
  185. },function (response) {
  186. console.log(response);
  187. this.loading = false;
  188. }
  189. );
  190. },
  191. search() {
  192. this.search_loading = true;
  193. if(this.search_form.is_time != 0 && this.search_form.times){
  194. this.search_form.start_time = Math.round(this.search_form.times[0]/1000).valueOf();
  195. this.search_form.end_time = Math.round(this.search_form.times[1]/1000).valueOf();
  196. }else{
  197. this.search_form.start_time = '';
  198. this.search_form.end_time = '';
  199. }
  200. this.$http.post('{!! yzWebFullUrl('plugin.lucky-draw.admin.controllers.activity.search') !!}',{search:this.search_form}
  201. ).then(function (response) {
  202. if (response.data.result){
  203. let data = response.data.data.page_list;
  204. this.page_total = data.total;
  205. this.list = data.data;
  206. this.list.map((item,index,key)=>{
  207. item.start_time=this.timestampToTime(item.countdown_time[0]);
  208. item.end_time=this.timestampToTime(item.countdown_time[1]);
  209. });
  210. this.page_size = data.per_page;
  211. this.current_page = data.current_page;
  212. this.loading = false;
  213. this.real_search_form=Object.assign({},this.search_form);
  214. }
  215. else {
  216. this.$message({message: response.data.msg,type: 'error'});
  217. }
  218. this.search_loading = false;
  219. },function (response) {
  220. this.search_loading = false;
  221. this.$message({message: response.data.msg,type: 'error'});
  222. }
  223. );
  224. },
  225. currentChange(val) {
  226. this.loading = true;
  227. this.$http.post('{!! yzWebFullUrl('plugin.lucky-draw.admin.controllers.activity.getList') !!}',{page:val,search:this.real_search_form}).then(function (response){
  228. let data = response.data.data.page_list;
  229. this.page_total = data.total;
  230. this.list = data.data;
  231. this.list.map((item,index,key)=>{
  232. item.start_time=this.timestampToTime(item.countdown_time[0]);
  233. item.end_time=this.timestampToTime(item.countdown_time[1]);
  234. })
  235. this.page_size = data.per_page;
  236. this.current_page = data.current_page;
  237. this.loading = false;
  238. },function (response) {
  239. console.log(response);
  240. this.loading = false;
  241. }
  242. );
  243. },
  244. copy(index) {
  245. that = this;
  246. let Url = that.$refs['link'+index];
  247. Url.select(); // 选择对象
  248. document.execCommand("Copy",false);
  249. that.$message({message:"复制成功!",type:"success"});
  250. },
  251. },
  252. });
  253. </script>
  254. @endsection