index.blade.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. @extends('layouts.base')
  2. @section('title', '优惠券管理')
  3. @section('content')
  4. <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}" />
  5. <style>
  6. .edit-i{display:none;}
  7. .el-table_1_column_2:hover .edit-i{font-weight:900;padding:0;margin:0;display:inline-block;}
  8. .el-tabs__item,.is-top{font-size:16px}
  9. .el-tabs__active-bar { height: 3px;}
  10. </style>
  11. <div class="all">
  12. <div id="app" v-cloak>
  13. <div class="vue-nav" style="margin-bottom:15px">
  14. <el-tabs v-model="activeName" @tab-click="handleClick">
  15. <el-tab-pane label="优惠券设置" name="1"></el-tab-pane>
  16. <el-tab-pane label="优惠券列表" name="2"></el-tab-pane>
  17. <el-tab-pane label="领取发放记录" name="3"></el-tab-pane>
  18. <el-tab-pane label="分享领取记录" name="4"></el-tab-pane>
  19. <el-tab-pane label="使用记录" name="5"></el-tab-pane>
  20. <el-tab-pane label="领券中心幻灯片" name="6"></el-tab-pane>
  21. <el-tab-pane label="会员优惠券" name="7"></el-tab-pane>
  22. </el-tabs>
  23. </div>
  24. <div class="vue-head">
  25. <div class="vue-main-title" style="margin-bottom:20px">
  26. <div class="vue-main-title-left"></div>
  27. <div class="vue-main-title-content">优惠券列表</div>
  28. <div class="vue-main-title-button">
  29. <el-button type="primary" plain icon="el-icon-plus" size="small" @click="addModal">新增优惠券</el-button>
  30. </div>
  31. </div>
  32. <div class="vue-search">
  33. <el-form :inline="true" :model="search_form" class="demo-form-inline">
  34. <el-form-item label="">
  35. <el-input v-model="search_form.keyword" placeholder="优惠券名称"></el-input>
  36. </el-form-item>
  37. <el-form-item label="">
  38. <el-form-item label="">
  39. <el-select v-model="search_form.gettype" clearable placeholder="领取中心是否显示">
  40. <el-option label="不显示" value="0"></el-option>
  41. <el-option label="显示" value="1"></el-option>
  42. </el-select>
  43. </el-form-item>
  44. <el-form-item label="">
  45. <el-select v-model="search_form.timesearchswtich" clearable placeholder="是否搜索时间">
  46. <el-option label="不搜索时间" value="0"></el-option>
  47. <el-option label="搜索时间" value="1"></el-option>
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item label="">
  51. <el-date-picker
  52. v-model="times"
  53. type="datetimerange"
  54. value-format="timestamp"
  55. range-separator="至"
  56. start-placeholder="开始日期"
  57. end-placeholder="结束日期"
  58. style="margin-left:5px;"
  59. align="right">
  60. </el-date-picker>
  61. </el-form-item>
  62. <el-form-item label="">
  63. <el-button type="primary" @click="search(1)">搜索</el-button>
  64. </el-form-item>
  65. </el-form>
  66. </div>
  67. </div>
  68. <div class="vue-main">
  69. <div class="vue-main-form">
  70. <el-table :data="list" style="width: 100%">
  71. <el-table-column label="ID" align="center" prop="id" width="80"></el-table-column>
  72. <el-table-column label="排序" align="center" prop="display_order" width="110"></el-table-column>
  73. <el-table-column label="优惠券名称" align="center" prop="name"></el-table-column>
  74. <el-table-column label="使用条件" align="center">
  75. <template slot-scope="scope">
  76. <div>
  77. <div>[[scope.row.enough>0?'满'+scope.row.enough+'可用':'不限']]</div>
  78. </div>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="优惠" align="center" prop="id">
  82. <template slot-scope="scope">
  83. <div v-if="scope.row.coupon_method==1">
  84. 立减[[scope.row.deduct?scope.row.deduct:'0']]元
  85. </div>
  86. <div v-else>
  87. 打[[scope.row.discount?scope.row.discount:'1']]折
  88. </div>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="已使用" align="center" prop="usetotal" width="80"></el-table-column>
  92. <el-table-column label="已发出" align="center" prop="gettotal" width="80"></el-table-column>
  93. <el-table-column label="剩余数量" align="center" prop="id" width="80">
  94. <template slot-scope="scope">
  95. <div v-if="scope.row.total==-1">
  96. 无限数量
  97. </div>
  98. <div v-else>
  99. [[scope.row.lasttotal]]
  100. </div>
  101. </template>
  102. </el-table-column>
  103. <el-table-column label="领取中心" align="center" width="80">
  104. <template slot-scope="scope">
  105. <div>
  106. <div>[[scope.row.get_type==0?'不显示':'显示']]</div>
  107. </div>
  108. </template>
  109. </el-table-column>
  110. <el-table-column label="创建时间" align="center" prop="created_at"></el-table-column>
  111. <el-table-column prop="refund_time" label="操作" align="center" width="300">
  112. <template slot-scope="scope">
  113. <!-- <el-link type="warning" :underline="false" :href="'{{ yzWebUrl('coupon.coupon.coupon-view', array('id' => '')) }}'+[[scope.row.id]]" class="el-link-edit el-link-edit-middle">
  114. 编辑
  115. </el-link>
  116. <el-link type="warning" :underline="false" :href="'{{ yzWebUrl('goods.comment.updated', array('id' => '')) }}'+[[scope.row.id]]" class="el-link-edit el-link-edit-middle">
  117. 删除
  118. </el-link>
  119. <el-link type="warning" :underline="false" :href="'{{ yzWebUrl('coupon.coupon.log-view', array('id' => '')) }}'+[[scope.row.id]]" title="点击查看发放记录" class="el-link-edit el-link-edit-middle">
  120. 记录
  121. </el-link>
  122. <el-link type="warning" :underline="false" :href="'{{ yzWebUrl('coupon.send-coupon', array('id' => '')) }}'+[[scope.row.id]]" class="el-link-edit el-link-edit-end">
  123. 发放
  124. </el-link> -->
  125. <el-link title="编辑" :underline="false" :href="'{{ yzWebUrl('coupon.coupon.coupon-view', array('id' => '')) }}'+[[scope.row.id]]" style="width:50px;">
  126. <i class="iconfont icon-ht_operation_edit"></i>
  127. </el-link>
  128. <el-link title="删除" :underline="false" @click="del(scope.row.id,scope.$index)" style="width:50px;">
  129. <i class="iconfont icon-ht_operation_delete"></i>
  130. </el-link>
  131. <el-link title="查看发放记录" :underline="false" :href="'{{ yzWebUrl('coupon.coupon.log-view', array('id' => '')) }}'+[[scope.row.id]]" style="width:50px;">
  132. <i class="iconfont icon-member-order"></i>
  133. </el-link>
  134. <el-link title="发放优惠券" :underline="false" :href="'{{ yzWebUrl('coupon.send-coupon', array('id' => '')) }}'+[[scope.row.id]]" style="width:50px;">
  135. <i class="iconfont icon-supplier_release"></i>
  136. </el-link>
  137. <el-link title="添加优惠券" :underline="false" style="width:50px;">
  138. <i v-if="scope.row.lasttotal > 0" class="el-icon-s-ticket" @click="couponAddCount(scope.row.id)"></i>
  139. </el-link>
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. </div>
  144. </div>
  145. <!-- 分页 -->
  146. <div class="vue-page" v-if="total>0">
  147. <el-row>
  148. <el-col align="right">
  149. <el-pagination layout="prev, pager, next,jumper" @current-change="search" :total="total"
  150. :page-size="per_page" :current-page="current_page" background
  151. ></el-pagination>
  152. </el-col>
  153. </el-row>
  154. </div>
  155. </div>
  156. </div>
  157. <script>
  158. var app = new Vue({
  159. el: "#app",
  160. delimiters: ['[[', ']]'],
  161. name: 'test',
  162. data() {
  163. return {
  164. activeName:'2',
  165. list:[],
  166. change_sort:'',
  167. times:[],
  168. options:[
  169. {id:0,name:'全部评价类型'},
  170. {id:1,name:'真实评价'},
  171. {id:2,name:'模拟评价'},
  172. ],
  173. search_form:{
  174. },
  175. rules: {},
  176. current_page:1,
  177. total:1,
  178. per_page:1,
  179. }
  180. },
  181. created() {
  182. },
  183. mounted() {
  184. this.getData(1);
  185. },
  186. methods: {
  187. getData(page) {
  188. console.log(this.times);
  189. let json = {
  190. page:page,
  191. keyword:this.search_form.keyword,
  192. gettype:this.search_form.gettype || '',
  193. timesearchswtich:this.search_form.timesearchswtich,
  194. };
  195. if(this.times && this.times.length>0) {
  196. json.time = [];
  197. json.time = {start:this.times[0]/1000,end:this.times[1]/1000}
  198. // json.starttime = this.times[0]/1000;
  199. // json.endtime = this.times[1]/1000
  200. }
  201. console.log(json)
  202. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  203. this.$http.post('{!! yzWebFullUrl('coupon.coupon.coupon-data') !!}',json).then(function(response) {
  204. if (response.data.result) {
  205. this.list = response.data.data.list.data;
  206. this.list.forEach((item,index) => {
  207. if(item.goods) {
  208. item.goods.title = this.escapeHTML(item.goods.title);
  209. }
  210. });
  211. this.current_page=response.data.data.list.current_page;
  212. this.total=response.data.data.list.total;
  213. this.per_page=response.data.data.list.per_page;
  214. loading.close();
  215. } else {
  216. this.$message({
  217. message: response.data.msg,
  218. type: 'error'
  219. });
  220. }
  221. loading.close();
  222. }, function(response) {
  223. this.$message({
  224. message: response.data.msg,
  225. type: 'error'
  226. });
  227. loading.close();
  228. });
  229. },
  230. search(val) {
  231. this.getData(val);
  232. },
  233. // 添加新品牌
  234. addModal() {
  235. let link = `{!! yzWebFullUrl('coupon.coupon.coupon-view') !!}`;
  236. console.log(link);
  237. window.location.href = link;
  238. },
  239. del(id,index) {
  240. console.log(id,index)
  241. this.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  242. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  243. this.$http.post('{!! yzWebFullUrl('coupon.coupon.destory') !!}',{id:id}).then(function (response) {
  244. if (response.data.result) {
  245. this.list.splice(index,1);
  246. this.$message({type: 'success',message: '删除成功!'});
  247. }
  248. else{
  249. this.$message({type: 'error',message: response.data.msg});
  250. }
  251. loading.close();
  252. this.search(this.current_page)
  253. },function (response) {
  254. this.$message({type: 'error',message: response.data.msg});
  255. loading.close();
  256. }
  257. );
  258. }).catch(() => {
  259. this.$message({type: 'info',message: '已取消删除'});
  260. });
  261. },
  262. // 编辑排序
  263. editTitle(index) {
  264. let that = this;
  265. that.change_sort = "";
  266. that.change_sort = that.list[index].display_order;
  267. },
  268. confirmChangeSort(id) {
  269. let that = this;
  270. if (!(/^\d+$/.test(that.change_sort))) {
  271. that.$message.error('请输入正确数字');
  272. return false;
  273. }
  274. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  275. let json = {id: id, sort: that.change_sort};
  276. that.$http.post("{!! yzWebFullUrl('goods.dispatch.sort-v2') !!}", json).then(response => {
  277. console.log(response);
  278. if (response.data.result == 1) {
  279. that.$message.success('操作成功!');
  280. // that.$refs.search_form.click();
  281. if (document.all) {
  282. document.getElementById('app').click();
  283. } else {// 其它浏览器
  284. var e = document.createEvent('MouseEvents')
  285. e.initEvent('click', true, true)
  286. document.getElementById('app').dispatchEvent(e)
  287. }
  288. that.search(this.current_page);
  289. } else {
  290. that.$message.error(response.data.msg);
  291. }
  292. loading.close();
  293. }), function (res) {
  294. console.log(res);
  295. loading.close();
  296. };
  297. },
  298. // 快速修改
  299. changeStatus(id,index,type,value) {
  300. let that = this;
  301. let json = {id: id, type: type, status: value};
  302. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  303. that.$http.post("{!! yzWebFullUrl('goods.dispatch.quick-edit') !!}", json).then(response => {
  304. console.log(response);
  305. if (response.data.result == 1) {
  306. that.$message.success('操作成功!');
  307. } else {
  308. that.$message.error(response.data.msg);
  309. that.list[index][type] == 1 ? 0 : 1;
  310. }
  311. that.search(this.current_page);
  312. loading.close();
  313. }), function (res) {
  314. console.log(res);
  315. loading.close();
  316. };
  317. },
  318. handleClick(val) {
  319. console.log(val.name)
  320. if(val.name == 1) {
  321. window.location.href = `{!! yzWebFullUrl('coupon.base-set.see') !!}`;
  322. }
  323. else if(val.name == 2) {
  324. window.location.href = `{!! yzWebFullUrl('coupon.coupon.index') !!}`;
  325. }
  326. else if(val.name == 3) {
  327. window.location.href = `{!! yzWebFullUrl('coupon.coupon.log-view') !!}`;
  328. }
  329. else if(val.name == 4) {
  330. window.location.href = `{!! yzWebFullUrl('coupon.share-coupon.log') !!}`;
  331. }
  332. else if(val.name == 5) {
  333. window.location.href = `{!! yzWebFullUrl('coupon.coupon-use.index') !!}`;
  334. }
  335. else if(val.name == 6) {
  336. window.location.href = `{!! yzWebFullUrl('coupon.slide-show') !!}`;
  337. }
  338. else if(val.name == 7) {
  339. window.location.href = `{!! yzWebFullUrl('coupon.member-coupon.index') !!}`;
  340. }
  341. },
  342. // 字符转义
  343. escapeHTML(a) {
  344. a = "" + a;
  345. return a.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&apos;/g, "'");;
  346. },
  347. couponAddCount(id) {
  348. const that = this
  349. this.$prompt('输入增加的优惠劵数量', '提示', {
  350. confirmButtonText: '确定',
  351. cancelButtonText: '取消',
  352. inputPattern: /^[0-9]*$/,
  353. inputErrorMessage: '请输入整型'
  354. }).then(({ value }) => {
  355. let params = {
  356. id: id,
  357. total: value
  358. }
  359. that.$http.post("{!! yzWebFullUrl('coupon.coupon.add-coupon-count') !!}", params).then(response => {
  360. if (response.data.result === 1) {
  361. this.$message({
  362. type: 'success',
  363. message: '成功添加优惠券: ' + value + '张'
  364. });
  365. that.search(1);
  366. }else{
  367. this.$message({
  368. type: 'fail',
  369. message: '添加失败, 请重试'
  370. });
  371. }
  372. }), function (res) {
  373. console.log(res);
  374. };
  375. }).catch(() => {
  376. this.$message({
  377. type: 'info',
  378. message: '取消优惠券添加'
  379. });
  380. });
  381. }
  382. },
  383. })
  384. </script>
  385. @endsection