From 780ddc0d6df50bbb59b84ef61668da7c2deacc21 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Mon, 11 Sep 2023 10:32:26 +0800
Subject: [PATCH] 优惠卷

---
 src/main/resources/templates/febs/views/modules/goods/goodsCouponList.html |   55 +++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 45 insertions(+), 10 deletions(-)

diff --git a/src/main/resources/templates/febs/views/modules/goods/goodsCoupon.html b/src/main/resources/templates/febs/views/modules/goods/goodsCouponList.html
similarity index 74%
rename from src/main/resources/templates/febs/views/modules/goods/goodsCoupon.html
rename to src/main/resources/templates/febs/views/modules/goods/goodsCouponList.html
index 2aea078..b94cf36 100644
--- a/src/main/resources/templates/febs/views/modules/goods/goodsCoupon.html
+++ b/src/main/resources/templates/febs/views/modules/goods/goodsCouponList.html
@@ -53,6 +53,14 @@
         background-color: #5FB878 !important;
     }
 </style>
+
+<script type="text/html" id="isStateSwitch">
+    {{# if(d.state === 2) { }}
+    <input type="checkbox" value={{d.id}} lay-text="上架|下架" checked lay-skin="switch" lay-filter="isStateSwitch">
+    {{# } else { }}
+    <input type="checkbox" value={{d.id}} lay-text="上架|下架" lay-skin="switch" lay-filter="isStateSwitch">
+    {{# } }}
+</script>
 <!-- 表格操作栏 end -->
 <script data-th-inline="none" type="text/javascript">
     // 引入组件并初始化
@@ -78,13 +86,13 @@
         table.on('tool(couponRuleTable)', function (obj) {
             var data = obj.data,
                 layEvent = obj.event;
-            if (layEvent === 'carriageRuleDel') {
-                febs.modal.confirm('删除', '确认删除['+data.name+']运费模板?', function () {
-                    carriageRuleDel(data.id);
+            if (layEvent === 'couponRuleDel') {
+                febs.modal.confirm('删除', '确认删除['+data.name+']优惠卷?', function () {
+                    couponRuleDel(data.id);
                 });
             }
-            if (layEvent === 'carriageRuleUpdate') {
-                febs.modal.open('运费模板编辑', 'modules/goods/carriageRuleUpdate/' + data.id, {
+            if (layEvent === 'couponRuleUpdate') {
+                febs.modal.open('优惠卷编辑', 'modules/goods/goodsCouponUpdate/' + data.id, {
                     btn: ['提交', '取消'],
                     area:['100%','100%'],
                     yes: function (index, layero) {
@@ -96,8 +104,29 @@
                 });
             }
         });
-        function carriageRuleDel(id) {
-            febs.get(ctx + 'admin/goods/carriageRuleDel/' + id, null, function () {
+        function couponRuleDel(id) {
+            febs.get(ctx + 'admin/goods/couponRuleDel/' + id, null, function () {
+                febs.alert.success('操作成功');
+                $query.click();
+            });
+        }
+
+        form.on('switch(isStateSwitch)', function (data) {
+            if (data.elem.checked) {
+                upCoupon(data.value);
+            } else {
+                downCoupon(data.value);
+            }
+        })
+
+        function upCoupon(id) {
+            febs.get(ctx + 'admin/goods/upCoupon/' + id, null, function () {
+                febs.alert.success('操作成功');
+                $query.click();
+            });
+        }
+        function downCoupon(id) {
+            febs.get(ctx + 'admin/goods/downCoupon/' + id, null, function () {
                 febs.alert.success('操作成功');
                 $query.click();
             });
@@ -117,7 +146,7 @@
         });
 
         $add.on('click', function () {
-            febs.modal.open('运费模板新增', 'modules/goods/carriageRuleAdd/', {
+            febs.modal.open('优惠卷新增', 'modules/goods/goodsCouponAdd/', {
                 btn: ['提交', '取消'],
                 area:['100%','100%'],
                 yes: function (index, layero) {
@@ -136,16 +165,22 @@
                 url: ctx + 'admin/goods/couponRuleList',
                 cols: [[
                     {field: 'name', title: '名称', minWidth: 200,align:'left'},
+                    {field: 'isState', title: '是否生效', templet: '#isStateSwitch', minWidth: 100,align:'center'},
                     {field: 'costAmount', title: '满足金额', minWidth: 200,align:'left'},
                     {field: 'realAmount', title: '减免金额', minWidth: 200,align:'left'},
                     {field: 'expireDay', title: '过期天数', minWidth: 200,align:'left'},
                     {field: 'createdTime', title: '创建时间', minWidth: 140,align:'left'},
                     {title: '操作',
                         templet: function (d) {
+                            if (d.state === 1) {
                                 return ''
-                                + '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="carriageRuleUpdate" shiro:hasPermission="user:update">编辑</button>'
-                                    + '<button class="layui-btn layui-btn-normal layui-btn-xs febs-bg-red" lay-event="carriageRuleDel" shiro:hasPermission="user:update">删除</button>'
+                                    + '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="couponRuleUpdate" shiro:hasPermission="user:update">编辑</button>'
+                                    + '<button class="layui-btn layui-btn-normal layui-btn-xs febs-bg-red" lay-event="couponRuleDel" shiro:hasPermission="user:update">删除</button>'
 
+                            }else{
+                                return '';
+
+                            }
                         },minWidth: 160,align:'center'}
                 ]]
             });

--
Gitblit v1.9.1